import{aj as P,p as k,r,j as s,e as x,ak as S,al as p,am as b,L as C}from"./vendor-DyCecx-5.js";import{t as h,a as R}from"./index-BFnDPF9i.js";const I=()=>{const[g]=P(),l=g.get("token"),n=k(),[i,j]=r.useState(!1),[c,N]=r.useState(!1),[d,w]=r.useState(!1),[e,v]=r.useState({password:"",confirmPassword:""}),[t,u]=r.useState({}),f=a=>{v({...e,[a.target.name]:a.target.value}),u({...t,[a.target.name]:""})},y=async a=>{if(a.preventDefault(),!l){h.error("Invalid or missing reset token.");return}const o={};if(e.password.length<8&&(o.password="Password must be at least 8 characters"),e.password!==e.confirmPassword&&(o.confirmPassword="Passwords don't match"),Object.keys(o).length>0){u(o);return}w(!0);const m=await R.resetPassword({token:l,password:e.password});w(!1),m.success?(h.success(m.message||"Your password h reset successfully. Redirecting to sign in..."),setTimeout(()=>{n("/signin")},3e3)):h.error(m.message||"An error occurred")};return l?s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-slate-50 px-4",children:s.jsxs("div",{className:"max-w-md w-full bg-white p-8 rounded shadow-sm border border-slate-100",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("div",{className:"inline-flex items-center justify-center w-14 h-14 bg-slate-900 text-white rounded mb-4 shadow-lg shadow-slate-200",children:s.jsx(S,{className:"w-7 h-7"})}),s.jsx("h1",{className:"text-3xl font-extrabold text-slate-900",children:"Set New Password"}),s.jsx("p",{className:"text-slate-500 mt-2",children:"Please enter your new password below."})]}),s.jsxs("form",{onSubmit:y,className:"space-y-5 text-left",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-semibold text-slate-700 mb-1.5",htmlFor:"password",children:"New Password"}),s.jsxs("div",{className:"relative group",children:[s.jsx("input",{name:"password",value:e.password,onChange:f,type:i?"text":"password",id:"password",className:`w-full pl-4 pr-12 py-3 bg-slate-50 border rounded outline-none transition-all duration-200 focus-white focus-4 focus-slate-100 ${t.password?"border-rose-300 focus-rose-400":"border-slate-200 focus-slate-400 group-hover:bg-slate-300"}`,placeholder:"••••••••"}),s.jsx("button",{type:"button",onClick:()=>j(!i),className:"absolute right-4 top-1/2 -translate-y-1/2 text-slate-400 hover:bg-slate-600 transition-colors",children:i?s.jsx(p,{className:"w-5 h-5"}):s.jsx(b,{className:"w-5 h-5"})})]}),t.password&&s.jsxs("p",{className:"mt-1.5 text-xs font-medium text-rose-500 flex items-center gap-1",children:[s.jsx(x,{className:"w-3 h-3"})," ",t.password]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-semibold text-slate-700 mb-1.5",htmlFor:"confirmPassword",children:"Confirm Password"}),s.jsxs("div",{className:"relative group",children:[s.jsx("input",{name:"confirmPassword",value:e.confirmPassword,onChange:f,type:c?"text":"password",id:"confirmPassword",className:`w-full pl-4 pr-12 py-3 bg-slate-50 border rounded outline-none transition-all duration-200 focus-white focus-4 focus-slate-100 ${t.confirmPassword?"border-rose-300 focus-rose-400":"border-slate-200 focus-slate-400 group-hover:bg-slate-300"}`,placeholder:"••••••••"}),s.jsx("button",{type:"button",onClick:()=>N(!c),className:"absolute right-4 top-1/2 -translate-y-1/2 text-slate-400 hover:bg-slate-600 transition-colors",children:c?s.jsx(p,{className:"w-5 h-5"}):s.jsx(b,{className:"w-5 h-5"})})]}),t.confirmPassword&&s.jsxs("p",{className:"mt-1.5 text-xs font-medium text-rose-500 flex items-center gap-1",children:[s.jsx(x,{className:"w-3 h-3"})," ",t.confirmPassword]})]}),s.jsx("button",{type:"submit",disabled:d,className:`w-full py-3.5 px-4 bg-slate-900 text-white rounded font-bold shadow-lg shadow-slate-200 hover:bg-slate-800 hover-xl hover:-translate-y-0.5 active-y-0 transition-all duration-200 flex items-center justify-center gap-2 ${d?"opacity-70 cursor-not-allowed":""}`,children:d?s.jsxs(s.Fragment,{children:[s.jsx(C,{className:"w-5 h-5 animate-spin"}),"Resetting Password..."]}):"Reset Password"})]}),s.jsxs("p",{className:"mt-8 text-center text-sm text-slate-500",children:["Remember your password?"," ",s.jsx("button",{onClick:()=>n("/login"),className:"text-slate-900 font-bold hover transition-all",children:"Sign In"})]})]})}):s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-slate-50 px-4",children:s.jsxs("div",{className:"max-w-md w-full bg-white p-8 rounded shadow-sm border border-slate-100 text-center",children:[s.jsx(x,{className:"w-16 h-16 text-red-500 mx-auto mb-4"}),s.jsx("h1",{className:"text-2xl font-bold text-slate-900 mb-2",children:"Invalid Reset Link"}),s.jsx("p",{className:"text-slate-600 mb-6",children:"This password reset link is invalid or h."}),s.jsx("button",{onClick:()=>n("/signin"),className:"w-full bg-slate-900 text-white py-3 rounded-lg font-medium hover:bg-slate-800 transition-colors",children:"Back to Sign In"})]})})};export{I as default};
