1import{u as A,r,j as e,s as f}from"./index-DGKuAvwV.js";import{L as i}from"./lock-DIh_BGKt.js";import{C as F}from"./check-circle-DabB4cA6.js";import{A as g}from"./alert-circle-DVx8qyvI.js";import{E as j,a as N}from"./eye-CMgnpxku.js";import{L}from"./loader-2-C56mIhMr.js";import"./createLucideIcon-ClvgWHNO.js";function Z(){const d=A(),[a,v]=r.useState(""),[c,y]=r.useState(""),[m,P]=r.useState(!1),[x,k]=r.useState(!1),[o,u]=r.useState(!1),[C,E]=r.useState(!1),[h,n]=r.useState(null),[p,w]=r.useState([]);r.useEffect(()=>{window.location.hash.includes("access_token")||d("/login")},[d]);const S=s=>{const t=[];return s.length<8&&t.push("Password must be at least 8 characters long"),/[A-Z]/.test(s)||t.push("Password must contain at least one uppercase letter"),/[a-z]/.test(s)||t.push("Password must contain at least one lowercase letter"),/[0-9]/.test(s)||t.push("Password must contain at least one number"),t},U=async s=>{var b;s.preventDefault(),n(null),w([]);const t=S(a);if(t.length>0){w(t);return}if(a!==c){n("Passwords do not match");return}u(!0);try{const{error:l}=await f.auth.updateUser({password:a});if(l){if((b=l.message)!=null&&b.includes("JWT expired")){n("Your reset link has expired. Please request a new password reset.");return}throw l}await f.auth.signOut(),E(!0),setTimeout(()=>{d("/login")},2500)}catch(l){console.error("Error updating password:",l),n(l.message||"Failed to update password. Please try again.")}finally{u(!1)}};return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-white to-sky-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"w-16 h-16 bg-gradient-to-r from-sky-500 to-blue-600 rounded-2xl flex items-center justify-center mx-auto mb-6",children:e.jsx(i,{className:"w-8 h-8 text-white"})}),e.jsx("h1",{className:"text-3xl font-bold text-slate-900 mb-2",children:"Update Password"}),e.jsx("p",{className:"text-slate-600",children:"Choose a strong password to secure your account."})]}),e.jsx("div",{className:"bg-white rounded-2xl shadow-xl border border-slate-200 p-8",children:C?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"w-16 h-16 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(F,{className:"w-8 h-8 text-green-600"})}),e.jsx("h3",{className:"text-xl font-bold text-slate-900 mb-2",children:"Password Updated!"}),e.jsx("p",{className:"text-slate-600",children:"Your password has been successfully updated."}),e.jsx("p",{className:"text-sm text-slate-500 mt-4",children:"Redirecting to login..."})]}):e.jsxs("form",{onSubmit:U,className:"space-y-6",children:[h&&e.jsxs("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg text-red-800 text-sm flex items-start gap-2",children:[e.jsx(g,{className:"w-5 h-5 flex-shrink-0 mt-0.5"}),e.jsx("span",{children:h})]}),p.length>0&&e.jsxs("div",{className:"p-4 bg-amber-50 border border-amber-200 rounded-lg",children:[e.jsx("p",{className:"text-sm font-semibold text-amber-900 mb-2",children:"Password Requirements:"}),e.jsx("ul",{className:"space-y-1",children:p.map((s,t)=>e.jsxs("li",{className:"text-sm text-amber-800 flex items-start gap-2",children:[e.jsx(g,{className:"w-4 h-4 flex-shrink-0 mt-0.5"}),e.jsx("span",{children:s})]},t))})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"newPassword",className:"block text-sm font-semibold text-slate-700 mb-2",children:"New Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:e.jsx(i,{className:"h-5 w-5 text-slate-400"})}),e.jsx("input",{id:"newPassword",type:m?"text":"password",value:a,onChange:s=>v(s.target.value),required:!0,disabled:o,className:"block w-full pl-10 pr-12 py-3 border border-slate-300 rounded-lg focus:ring-2 focus:ring-sky-500 focus:border-transparent disabled:bg-slate-100 disabled:cursor-not-allowed transition-colors",placeholder:"Enter new password"}),e.jsx("button",{type:"button",onClick:()=>P(!m),className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:m?e.jsx(j,{className:"h-5 w-5 text-slate-400 hover:text-slate-600"}):e.jsx(N,{className:"h-5 w-5 text-slate-400 hover:text-slate-600"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirmPassword",className:"block text-sm font-semibold text-slate-700 mb-2",children:"Confirm Password"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:e.jsx(i,{className:"h-5 w-5 text-slate-400"})}),e.jsx("input",{id:"confirmPassword",type:x?"text":"password",value:c,onChange:s=>y(s.target.value),required:!0,disabled:o,className:"block w-full pl-10 pr-12 py-3 border border-slate-300 rounded-lg focus:ring-2 focus:ring-sky-500 focus:border-transparent disabled:bg-slate-100 disabled:cursor-not-allowed transition-colors",placeholder:"Confirm new password"}),e.jsx("button",{type:"button",onClick:()=>k(!x),className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:x?e.jsx(j,{className:"h-5 w-5 text-slate-400 hover:text-slate-600"}):e.jsx(N,{className:"h-5 w-5 text-slate-400 hover:text-slate-600"})})]})]}),e.jsxs("div",{className:"bg-slate-50 rounded-lg p-4",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-700 mb-2",children:"Password must contain:"}),e.jsxs("ul",{className:"space-y-1 text-xs text-slate-600",children:[e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${a.length>=8?"bg-green-500":"bg-slate-300"}`}),"At least 8 characters"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${/[A-Z]/.test(a)?"bg-green-500":"bg-slate-300"}`}),"One uppercase letter"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${/[a-z]/.test(a)?"bg-green-500":"bg-slate-300"}`}),"One lowercase letter"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-1.5 h-1.5 rounded-full ${/[0-9]/.test(a)?"bg-green-500":"bg-slate-300"}`}),"One number"]})]})]}),e.jsx("button",{type:"submit",disabled:o||!a||!c,className:"w-full flex items-center justify-center gap-2 px-6 py-3 bg-gradient-to-r from-sky-600 to-blue-600 text-white font-semibold rounded-lg hover:from-sky-700 hover:to-blue-700 transition-all duration-200 shadow-lg hover:shadow-xl disabled:opacity-50 disabled:cursor-not-allowed",children:o?e.jsxs(e.Fragment,{children:[e.jsx(L,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Updating..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(i,{className:"w-5 h-5"}),e.jsx("span",{children:"Update Password"})]})})]})})]})})}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.