import{j as e}from"./query-PJ0ZdjbV.js";import{j as N,u as C,a as r}from"./vendor-CWhr2lg4.js";import{m as P,d as p,h as x,e as y,f as b,g as E,I as h,i as S,B as A,k as I,l as k,R as L}from"./index-BSPIaiZU.js";import"./ui-aO-W1bxx.js";function F(){const[j]=N(),c=j.get("token")??"",v=C(),[a,g]=r.useState(""),[o,f]=r.useState(""),[d,n]=r.useState(""),[l,u]=r.useState([]),i=P(),w=s=>{if(s.preventDefault(),n(""),u([]),a!==o){n("Passwords do not match.");return}i.mutate({token:c,password:a},{onSuccess:()=>v(`${L.LOGIN}?invited=1`),onError:t=>{const m=I(t,"password");m.length?u(m):n(k(t,"Invalid or expired invite link."))}})};return c?e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-muted/50",children:e.jsxs(p,{className:"w-full max-w-md",children:[e.jsxs(y,{className:"text-center",children:[e.jsx(b,{children:"Activate Your Account"}),e.jsx(E,{children:"Create a password to complete your account setup"})]}),e.jsxs("form",{onSubmit:w,children:[e.jsxs(x,{className:"space-y-4",children:[d&&e.jsx("p",{className:"text-sm text-destructive",children:d}),l.length>0&&e.jsx("ul",{className:"space-y-1 rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:l.map((s,t)=>e.jsxs("li",{className:"flex gap-1.5",children:[e.jsx("span",{"aria-hidden":!0,children:"•"}),e.jsx("span",{children:s})]},t))}),e.jsx(h,{type:"password",placeholder:"Create a password",value:a,onChange:s=>g(s.target.value),required:!0,minLength:8}),e.jsx(h,{type:"password",placeholder:"Confirm password",value:o,onChange:s=>f(s.target.value),required:!0,minLength:8})]}),e.jsx(S,{children:e.jsx(A,{type:"submit",className:"w-full",disabled:i.isPending,children:i.isPending?"Activating...":"Activate Account"})})]})]})}):e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-muted/50",children:e.jsx(p,{className:"w-full max-w-md",children:e.jsx(x,{className:"pt-6",children:e.jsx("p",{className:"text-center text-sm text-destructive",children:"Invalid invite link. Please contact your administrator."})})})})}export{F as AcceptInvitePage};
