1import{u as E,r as s,t as a,j as e,L as n,l as p,B as w,a as F}from"./index-CudHG6B4.js";import{I as u}from"./input-kx1YXBs7.js";import{L as f}from"./label-B2onvOiF.js";import{P as T,g as I}from"./PasswordStrengthMeter-C0b97wPh.js";import{E as g}from"./eye-off-Cm4tYUKG.js";import{E as j}from"./eye-uFk1fLjc.js";import{C as q}from"./circle-check-CTosiqnS.js";import"./circle-C1ccQMbh.js";function z(){const[,y]=E(),[r,N]=s.useState(""),[l,b]=s.useState(""),[d,v]=s.useState(!1),[c,P]=s.useState(!1),[m,h]=s.useState(!1),[S,C]=s.useState(!1),[x,L]=s.useState("");s.useEffect(()=>{const o=new URLSearchParams(window.location.search).get("token");o?L(o):a.error("Invalid reset link",{description:"This password reset link is invalid or has expired"})},[a]);const k=async t=>{t.preventDefault();const o=I(r);if(o){a.error("Password requirements not met",{description:o.message});return}if(!l){a.error("Password confirmation required",{description:"Please re-enter your new password"});return}if(r!==l){a.error("Passwords don't match",{description:"Please make sure both passwords are the same"});return}h(!0);try{const i=await fetch("/api/auth/reset-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:x,password:r})}),R=await i.json();if(!i.ok)throw new Error(R.message||"Failed to reset password");C(!0),a("Password reset successful!",{description:"You can now sign in with your new password"}),setTimeout(()=>{y("/login")},3e3)}catch(i){a.error("Reset failed",{description:i.message})}finally{h(!1)}};return x?e.jsxs("div",{className:"min-h-screen bg-white flex flex-col",children:[e.jsx("header",{className:"border-b border-gray-200",children:e.jsx("div",{className:"w-full px-4 sm:px-6 lg:px-8",children:e.jsx("div",{className:"flex h-16 items-center",children:e.jsx(n,{href:"/",className:"flex items-center",children:e.jsx("img",{src:p,alt:"Land Ledger",className:"h-12 w-auto"})})})})}),e.jsx("div",{className:"flex-1 flex items-center justify-center px-6 py-12",children:e.jsx("div",{className:"w-full max-w-md",children:S?e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"mx-auto w-16 h-16 bg-green-100 rounded-full flex items-center justify-center",children:e.jsx(q,{className:"h-8 w-8 text-green-600"})}),e.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Password reset successful!"}),e.jsx("p",{className:"text-gray-600",children:"You can now sign in with your new password"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Redirecting to sign in page..."})]}),e.jsx("div",{className:"text-center",children:e.jsx(n,{href:"/login",className:"text-brand hover:text-brand-hover font-medium",children:"Go to sign in page"})})]}):e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Set new password"}),e.jsx("p",{className:"text-gray-600",children:"Choose a strong password for your account"})]}),e.jsxs("form",{onSubmit:k,className:"space-y-4",autoComplete:"off","data-testid":"form-reset-password",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"password",className:"text-sm font-medium text-gray-900",children:"New Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(u,{id:"password",name:"reset-new-password",type:d?"text":"password",autoComplete:"new-password",placeholder:"Enter a strong password",value:r,onChange:t=>N(t.target.value),className:"h-12 text-base pr-10",autoFocus:!0,"data-testid":"input-password"}),e.jsx("button",{type:"button",onClick:()=>v(!d),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700","data-testid":"toggle-password-visibility",children:d?e.jsx(g,{className:"h-5 w-5"}):e.jsx(j,{className:"h-5 w-5"})})]}),e.jsx(T,{password:r,className:"pt-1"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"confirmPassword",className:"text-sm font-medium text-gray-900",children:"Confirm New Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(u,{id:"confirmPassword",name:"reset-confirm-password",type:c?"text":"password",autoComplete:"new-password",placeholder:"Re-enter your password",value:l,onCh
1ange:t=>b(t.target.value),className:"h-12 text-base pr-10","data-testid":"input-confirm-password"}),e.jsx("button",{type:"button",onClick:()=>P(!c),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700","data-testid":"toggle-confirm-password-visibility",children:c?e.jsx(g,{className:"h-5 w-5"}):e.jsx(j,{className:"h-5 w-5"})})]})]}),e.jsx(w,{type:"submit",className:"w-full h-12 bg-brand hover:bg-brand-hover active:bg-brand-pressed text-white font-semibold text-base",disabled:m,"data-testid":"button-reset-password",children:m?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"mr-2 h-5 w-5 animate-spin"}),"Resetting password..."]}):"Reset password"})]})]})})})]}):e.jsxs("div",{className:"min-h-screen bg-white flex flex-col",children:[e.jsx("header",{className:"border-b border-gray-200",children:e.jsx("div",{className:"w-full px-4 sm:px-6 lg:px-8",children:e.jsx("div",{className:"flex h-16 items-center",children:e.jsx(n,{href:"/",className:"flex items-center",children:e.jsx("img",{src:p,alt:"Land Ledger",width:848,height:209,className:"h-12 w-auto object-contain",fetchPriority:"high",loading:"eager"})})})})}),e.jsx("div",{className:"flex-1 flex items-center justify-center px-6 py-12",children:e.jsxs("div",{className:"w-full max-w-md text-center space-y-4",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Invalid Reset Link"}),e.jsx("p",{className:"text-gray-600",children:"This password reset link is invalid or has expired. Please request a new one."}),e.jsx(n,{href:"/forgot-password",children:e.jsx(w,{className:"bg-brand hover:bg-brand-hover",children:"Request new reset link"})})]})})]})}export{z as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.