1import{r as s,j as e,L as i}from"./react-core-B0dokwlC.js";import{u as C,S as L,B as h}from"./index-Bk-MTYAN.js";import{I as p}from"./input-Drn4J9gH.js";import{L as f}from"./label-Dp9VQt2u.js";import{A as R}from"./affne-logo-ZGd0xEuO.js";import{motion as E}from"./framer-motion-V3lmxFoN.js";import{L as g,k as q,h as A,i as F,E as B,l as I}from"./lucide-BAInuTRQ.js";import"./tanstack-vd4r7a6S.js";import"./radix-D2EKS-RZ.js";import"./charts-CgPya_By.js";function G(){const[a]=s.useState(()=>new URLSearchParams(window.location.search).get("token")),[o,m]=s.useState(a?"checking":"missing"),[n,b]=s.useState(""),[x,j]=s.useState(""),[l,v]=s.useState(!1),[w,u]=s.useState(!1),[y,N]=s.useState(!1),{toast:d}=C();s.useEffect(()=>{a&&window.history.replaceState(null,"",window.location.pathname)},[a]),s.useEffect(()=>{if(!a)return;let t=!1;return(async()=>{try{const c=await(await fetch(`/api/auth/reset-password/validate?token=${encodeURIComponent(a)}`,{credentials:"include"})).json().catch(()=>null);t||m(c?.valid?"valid":"invalid")}catch{t||m("invalid")}})(),()=>{t=!0}},[a]);const k=async t=>{if(t.preventDefault(),n.length<8){d({title:"Password too short",description:"Use at least 8 characters.",variant:"destructive"});return}if(n!==x){d({title:"Passwords don't match",description:"Both fields must be identical.",variant:"destructive"});return}u(!0);try{const r=await fetch("/api/auth/reset-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:a,newPassword:n}),credentials:"include"}),c=await r.json().catch(()=>null);if(!r.ok)throw new Error(c?.message||"Failed to reset password. Please try again.");N(!0)}catch(r){d({title:"Reset failed",description:r.message||"Failed to reset password. Please try again.",variant:"destructive"})}finally{u(!1)}},S=e.jsxs("div",{className:"text-center","data-testid":"block-token-invalid",children:[e.jsx("div",{className:"mx-auto mb-6 flex h-14 w-14 items-center justify-center rounded-2xl bg-rose-500/10 border border-rose-500/20",children:e.jsx(q,{className:"h-7 w-7 text-rose-400"})}),e.jsx("h1",{className:"text-3xl font-black tracking-tight mb-3","data-testid":"text-title",children:o==="missing"?"Reset link missing":"Link expired or invalid"}),e.jsx("p",{className:"text-slate-400 text-base mb-8",children:o==="missing"?"This page needs the reset link from your email. Open the link directly, or request a new one.":"Reset links only work once and expire after a short time. Request a new one below."}),e.jsx(i,{href:"/forgot-password",children:e.jsx(h,{type:"button",className:"w-full h-12 rounded-xl bg-gradient-to-r from-[#e11d48] to-[#ea580c] hover:from-rose-500 hover:to-orange-500 text-white shadow-[0_0_20px_rgba(225,29,72,0.3)] font-semibold text-base transition-all hover:shadow-[0_0_25px_rgba(225,29,72,0.5)] active:scale-[0.98]","data-testid":"button-request-new-link",children:"Request a new link"})}),e.jsxs(i,{href:"/signin",className:"mt-6 inline-flex items-center justify-center gap-1 text-sm font-medium text-slate-400 hover:text-white transition-colors","data-testid":"link-back-signin",children:[e.jsx(A,{className:"h-3 w-3"})," Back to sign in"]})]}),_=e.jsxs("div",{className:"text-center","data-testid":"block-reset-done",children:[e.jsx("div",{className:"mx-auto mb-6 flex h-14 w-14 items-center justify-center rounded-2xl bg-emerald-500/10 border border-emerald-500/20",children:e.jsx(F,{className:"h-7 w-7 text-emerald-400"})}),e.jsx("h1",{className:"text-3xl font-black tracking-tight mb-3","data-testid":"text-title",children:"Password updated"}),e.jsx("p",{className:"text-slate-400 text-base mb-8",children:"Your password has been changed. You can now sign in with the new one."}),e.jsx(i,{href:"/signin",children:e.jsx(h,{type:"button",className:"w-full h-12 rounded-xl bg-gradient-to-r from-[#e11d48] to-[#ea580c] hover:from-rose-500 hover:to-orange-500 text-white shadow-[0_0_20px_rgba(225,29,72,0.3)] font-semibold text-base transition-all hover:shadow-[0_0_25px_rgba(225,29,72,0.5)] active:scale-[0.98]","data-testid":"button-go-signin",children:"Sign in"})})]}),P=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-10 text-center lg:text-left",children:[e.jsx("h1",{className:"text-3xl font-black tracking-tight mb-2","data-testid":"text-title",children:"Set a new password"}),e.jsx("p",{className:"text-slate-400 text-base","data-testid":"text-subtitle",children:"Choose a strong password of at least 8 characters."})]}),e.jsxs("form",{onSubmit:k,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"new-password",className:"text-slate-300 text-sm font-semibold",children:"New password"}),e.jsxs("div",{className:"relative",children:[e.jsx(p,{id:"new-password",type:l?"text":"password",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",value:n,onChange:t=>b(t.target.value),required:!0,minLength:8,autoFocus:!0,autoComplete:"new-password",className:"bg-white/[0.03] border-white/[0.07] text-white placeholder:text-slate-600 focus:border-rose-500 focus:ring-1 focus:ring-rose-500/50 h-12 rounded-xl transition-all pr-12","data-testid":"input-new-password"}),e.jsx("button",{type:"button",onClick:()=>v(t=>!t),className:"absolute right-4 top-1/2 -translate-y-1/2 text-slate-500 hover:text-slate-300 transition-colors","aria-label":l?"Hide password":"Show password","data-testid":"button-toggle-password",children:l?e.jsx(B,{className:"h-4 w-4"}):e.jsx(I,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{htmlFor:"confirm-password",className:"text-slate-300 text-sm font-semibold",children:"Confirm new password"}),e.jsx(p,{id:"confirm-password",type:l?"text":"password",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",value:x,onChange:t=>j(t.target.value),required:!0,minLength:8,autoComplete:"new-password",className:"bg-white/[0.03] border-white/[0.07] text-white placeholder:text-slate-600 focus:border-rose-500 focus:ring-1 focus:ring-rose-500/50 h-12 rounded-xl transition-all","data-testid":"input-confirm-password"})]}),e.jsxs(h,{type:"submit",className:"w-full h-12 rounded-xl bg-gradient-to-r from-[#e11d48] to-[#ea580c] hover:from-rose-500 hover:to-orange-500 text-white shadow-[0_0_20px_rgba(225,29,72,0.3)] font-semibold text-base transition-all hover:shadow-[0_0_25px_rgba(225,29,72,0.5)] active:scale-[0.98]",disabled:w,"data-testid":"button-reset-password",children:[w&&e.jsx(g,{className:"mr-2 h-5 w-5 animate-spin"}),"Update password"]})]})]});return e.jsxs("div",{className:"min-h-screen bg-[#08090C] text-white flex flex-col",children:[e.jsx(L,{title:"Reset Password | Affne",description:"Set a new password for your Affne account.",noIndex:!0}),e.jsx("div",{className:"absolute inset-0 bg-[url('/noise.svg')] opacity-[0.02] mix-blend-overlay pointer-events-none"}),e.jsxs("nav",{className:"flex items-center justify-between px-6 lg:px-12 py-4 lg:py-6 border-b border-white/[0.05] relative z-10",children:[e.jsx(i,{href:"/",children:e.jsx(R,{size:"md",variant:"light"})}),e.jsx(i,{href:"/signin",className:"text-sm font-medium text-slate-400 hover:text-white transition-colors","data-testid":"link-back-signin-top",children:"â Sign in"})]}),e.jsx("main",{className:"flex-1 flex items-center justify-center p-6 relative z-10",children:e.jsx(E.div,{initial:{opacity:0,y:20}
1,animate:{opacity:1,y:0},transition:{duration:.5},className:"w-full max-w-[400px]",children:y?_:o==="checking"?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16","data-testid":"block-token-checking",children:[e.jsx(g,{className:"h-8 w-8 animate-spin text-rose-400 mb-4"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"Checking your reset linkâ¦"})]}):o==="valid"?P:S})})]})}export{G 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.