1import{r,a as E,j as s,L as C,f as I,I as h,B as R,s as l,g as p}from"./index-B3_8eyoK.js";import{L as y}from"./label-BKcyM16a.js";import{C as L}from"./circle-check-big-C_8TdE0E.js";import{o as D,s as g}from"./types-3c7sL9OC.js";const T=D({password:g().min(8,"Password must be at least 8 characters"),confirmPassword:g()}).refine(t=>t.password===t.confirmPassword,{message:"Passwords don't match",path:["confirmPassword"]}),A=()=>{const[t,j]=r.useState(""),[f,N]=r.useState(""),[m,w]=r.useState(!1),[b,P]=r.useState(!1),[v,i]=r.useState(!0),[e,x]=r.useState({}),u=E();r.useEffect(()=>{(async()=>{const{data:{subscription:n}}=l.auth.onAuthStateChange(async(a,d)=>{(a==="PASSWORD_RECOVERY"||a==="SIGNED_IN"&&d)&&i(!1)}),{data:{session:c}}=await l.auth.getSession();return c?i(!1):setTimeout(async()=>{const{data:{session:a}}=await l.auth.getSession();a?i(!1):(p.error("Invalid or expired reset link. Please request a new one."),u("/forgot-password"))},2e3),()=>n.unsubscribe()})()},[u]);const S=async o=>{if(o.preventDefault(),m)return;x({});const n=T.safeParse({password:t,confirmPassword:f});if(!n.success){const a={};n.error.errors.forEach(d=>{d.path[0]==="password"&&(a.password=d.message),d.path[0]==="confirmPassword"&&(a.confirmPassword=d.message)}),x(a);return}w(!0);const{error:c}=await l.auth.updateUser({password:t});w(!1),c?p.error(c.message||"Failed to update password"):(P(!0),p.success("Password updated successfully!"),setTimeout(()=>u("/login"),3e3))};return s.jsx(C,{children:s.jsx("section",{className:"py-20 md:py-28",children:s.jsx("div",{className:"container mx-auto px-4",children:s.jsxs("div",{className:"max-w-md mx-auto",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("h1",{className:"text-3xl font-display font-bold mb-2",children:"Set New Password"}),s.jsx("p",{className:"text-muted-foreground",children:"Enter your new password below"})]}),s.jsx("div",{className:"bg-card rounded-xl p-8 border border-border",children:v?s.jsxs("div",{className:"text-center space-y-4 py-8",children:[s.jsx(I,{size:"lg",className:"mx-auto text-primary"}),s.jsx("p",{className:"text-muted-foreground",children:"Verifying your reset link..."})]}):b?s.jsxs("div",{className:"text-center space-y-4",children:[s.jsx("div",{className:"mx-auto w-16 h-16 bg-primary/10 rounded-full flex items-center justify-center",children:s.jsx(L,{className:"h-8 w-8 text-primary"})}),s.jsx("h2",{className:"text-xl font-semibold",children:"Password Updated!"}),s.jsx("p",{className:"text-muted-foreground",children:"Your password has been successfully reset. Redirecting you to sign in..."})]}):s.jsxs("form",{onSubmit:S,className:"space-y-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(y,{htmlFor:"password",children:"New Password"}),s.jsx(h,{id:"password",type:"password",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",value:t,onChange:o=>j(o.target.value),required:!0,"aria-describedby":e.password?"password-error":"password-hint","aria-invalid":!!e.password}),s.jsx("p",{id:"password-hint",className:"text-xs text-muted-foreground",children:"At least 8 characters"}),e.password&&s.jsx("p",{id:"password-error",className:"text-sm text-destructive",children:e.password})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(y,{htmlFor:"confirmPassword",children:"Confirm New Password"}),s.jsx(h,{id:"confirmPassword",type:"password",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",value:f,onChange:o=>N(o.target.value),required:!0,"aria-describedby":e.confirmPassword?"confirm-password-error":void 0,"aria-invalid":!!e.confirmPassword}),e.confirmPassword&&s.jsx("p",{id:"confirm-password-error",className:"text-sm text-destructive",children:e.confirmPassword})]}),s.jsx(R,{type:"submit",className:"w-full",disabled:m,children:m?"Updating...":"Update Password"})]})})]})})})})};export{A 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.