1import{j as e}from"./tanstack-CrI89DsE.js";import{d as s,u as t,a,L as r}from"./router-Bxqj6nru.js";import{n as i}from"./utils-BNGK_p3N.js";import{c as o,m as n,X as l,f as c,R as d,A as u,v as m,t as h,u as x,V as g}from"./ui-oE360lam.js";function p(){const p=s(),f=t(),y=new URLSearchParams(f.search),[b,w]=a.useState("email"),[N,j]=a.useState(y.get("email")||""),[I,k]=a.useState(""),[v,C]=a.useState(""),[S,J]=a.useState(""),[E,F]=a.useState(""),[z,O]=a.useState(!1),[X,D]=a.useState(null),[T,Y]=a.useState(!1),[P,B]=a.useState(!1),[R,L]=a.useState(0),Z=a.useRef(null),q=a.useRef(null);a.useEffect(()=>{if(R>0){const e=setTimeout(()=>L(e=>e-1),1e3);return()=>clearTimeout(e)}},[R]),a.useEffect(()=>{"code"===b&&Z.current?Z.current.focus():"password"===b&&q.current&&q.current.focus()},[b]);const G=a.useCallback(()=>{D(null),"code"===b?(w("email"),C("")):"password"===b&&w("code")},[b]),M=(e=>{let s=0;return e.length>=8&&s++,e.length>=12&&s++,/[A-Z]/.test(e)&&s++,/[0-9]/.test(e)&&s++,/[^A-Za-z0-9]/.test(e)&&s++,s<=1?{strength:1,label:"Weak",color:"bg-red-500"}:s<=2?{strength:2,label:"Fair",color:"bg-yellow-500"}:s<=3?{strength:3,label:"Good",color:"bg-blue-500"}:{strength:4,label:"Strong",color:"bg-green-500"}})(S);return e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-gray-900 to-gray-800 flex items-center justify-center px-4 py-12 sm:px-6 lg:px-8",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsx(o,{mode:"wait",children:e.jsxs(n.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.3},className:"bg-gray-800/50 rounded-2xl p-8 shadow-2xl relative",children:[e.jsx("button",{onClick:()=>p("/sign-in"),className:"absolute top-4 left-4 p-2 text-gray-400 hover:text-white transition-colors rounded-full hover:bg-gray-700/50",children:e.jsx(l,{className:"h-5 w-5"})}),e.jsx("div",{className:"text-center mb-8",children:e.jsx(r,{to:"/",className:"inline-block",children:e.jsx("h1",{className:"text-2xl font-bold text-indigo-500",children:"RaceAlpha"})})}),"email"===b&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-2xl font-bold text-white text-center mb-2",children:"Find your account"}),e.jsx("p",{className:"text-gray-400 text-center text-sm mb-6",children:"Enter the email address associated with your account."}),e.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),N)try{O(!0),D(null);const e=await fetch("https://pabqrixgzcnqttrkwkil.supabase.co/functions/v1/password-reset-otp",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBhYnFyaXhnemNucXR0cmt3a2lsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDkyNDkxNDksImV4cCI6MjA2NDgyNTE0OX0.L-NIoMr98k9Y39WTGuVlu4Gzkbi1Fn1hUfp1hEzEQo0"},body:JSON.stringify({email:N})}),s=await e.json();if(!e.ok||!s.success)throw new Error(s.error||"Failed to send code");k(s.maskedEmail||N.replace(/(.{2})(.*)(@.*)/,"$1***$3")),w("code"),L(60),i.success("Code sent to your email")}catch(s){const e=s instanceof Error?s.message:"Failed to send code. Please try again.";D(e),i.error(e)}finally{O(!1)}else D("Please enter your email address")},className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"email",className:"sr-only",children:"Email address"}),e.jsxs("div",{className:"relative",children:[e.jsx(c,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-5 w-5 text-gray-400"}),e.jsx("input",{id:"email",type:"email",autoComplete:"email",required:!0,value:N,onChange:e=>j(e.target.value),className:"pl-10 block w-full rounded-lg border-0 bg-gray-700/50 py-3 text-white shadow-sm ring-1 ring-inset ring-gray-600 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-500 sm:text-sm",placeholder:"Email address"})]})]}),X&&e.jsx(n.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"bg-red-900/50 text-red-200 p-3 rounded-lg text-sm",children:X}),e.jsx("button",{type:"submit",disabled:z||!N,className:"w-full flex justify-center py-3 px-4 rounded-full bg-white text-gray-900 font-semibold hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:z?e.jsx(d,{className:"h-5 w-5 animate-spin"}):"Next"}),e.jsx(r,{to:"/sign-in",className:"block text-center text-sm text-indigo-400 hover:text-indigo-300 transition-colors mt-4",children:"Back to sign in"})]})]}),"code"===b&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-2xl font-bold text-white text-center mb-2",children:"We sent you a code"}),e.jsx("p",{className:"text-gray-400 text-center text-sm mb-6",children:"Check your email to get your confirmation code. If you need to request a new code, go back and reselect a confirmation."}),e.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),!v||v.length<8)D("Please enter the 8-character code");else try{O(!0),D(null);const e=await fetch("https://pabqrixgzcnqttrkwkil.supabase.co/functions/v1/verify-password-otp",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBhYnFyaXhnemNucXR0cmt3a2lsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDkyNDkxNDksImV4cCI6MjA2NDgyNTE0OX0.L-NIoMr98k9Y39WTGuVlu4Gzkbi1Fn1hUfp1hEzEQo0"},body:JSON.stringify({email:N,otp:v})}),s=await e.json();if(!e.ok||!s.success)throw new Error(s.error||"Invalid code");w("password"),i.success("Code verified!")}catch(s){const e=s instanceof Error?s.message:"Invalid code. Please try again.";D(e),i.error(e)}finally{O(!1)}},className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-indigo-400 mb-1 ml-1",children:"Enter your co
1de"}),e.jsx("input",{ref:Z,type:"text",required:!0,value:v,onChange:e=>C(e.target.value.toLowerCase().slice(0,8)),maxLength:8,className:"block w-full rounded-lg border-0 bg-gray-700/50 py-3 px-4 text-white shadow-sm ring-1 ring-inset ring-indigo-500 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-500 sm:text-sm font-mono tracking-widest",placeholder:"xxxxxxxx",autoComplete:"one-time-code"})]}),X&&e.jsx(n.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},className:"bg-red-900/50 text-red-200 p-3 rounded-lg text-sm",children:X}),e.jsx("button",{type:"submit",disabled:z||v.length<8,className:"w-full flex justify-center py-3 px-4 rounded-full bg-white text-gray-900 font-semibold hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:z?e.jsx(d,{className:"h-5 w-5 animate-spin"}):"Next"}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("button",{type:"button",onClick:G,className:"text-sm text-indigo-400 hover:text-indigo-300 transition-colors flex items-center gap-1",children:[e.jsx(u,{className:"h-4 w-4"}),"Back"]}),e.jsx("button",{type:"button",onClick:async()=>{if(!(R>0))try{O(!0),D(null);const e=await fetch("https://pabqrixgzcnqttrkwkil.supabase.co/functions/v1/password-reset-otp",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBhYnFyaXhnemNucXR0cmt3a2lsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDkyNDkxNDksImV4cCI6MjA2NDgyNTE0OX0.L-NIoMr98k9Y39WTGuVlu4Gzkbi1Fn1hUfp1hEzEQo0"},body:JSON.stringify({email:N})}),s=await e.json();if(!e.ok||!s.success)throw new Error(s.error||"Failed to resend code");L(60),C(""),i.success("New code sent!")}catch(e){i.error("Failed to resend code")}finally{O(!1)}},disabled:R>0||z,className:"text-sm text-indigo-400 hover:text-indigo-300 transition-colors disabled:text-gray-500 disabled:cursor-not-allowed",children:R>0?`Resend in ${R}s`:"Resend code"})]})]})]}),"password"===b&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-2xl font-bold text-white text-center mb-2",children:"Choose a new password"}),e.jsx("p",{className:"text-gray-400 text-center text-sm mb-6",children:"Make sure your new password is at least 8 characters."}),e.jsxs("form",{onSubmit:async e=>{if(e.preventDefault(),!S||S.length<8)D("Password must be at least 8 characters");else if(S===E)try{O(!0),D(null);const e=await fetch("https://pabqrixgzcnqttrkwkil.supabase.co/functions/v1/verify-password-otp",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBhYnFyaXhnemNucXR0cmt3a2lsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NDkyNDkxNDksImV4cCI6MjA2NDgyNTE0OX0.L-NIoMr98k9Y39WTGuVlu4Gzkbi1Fn1hUfp1hEzEQo0"},body:JSON.stringify({email:N,otp:v,newPassword:S})}),s=await e.json();if(!e.ok||!s.success)throw new Error(s.error||"Failed to reset password");w("success"),i.success("Password reset successfully!")}catch(s){const e=s instanceof Error?s.message:"Failed to reset password. Please try again.";D(e),i.error(e)}finally{O(!1)}else D("Passwords do not match")},className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"new-password",className:"sr-only",children:"New password"}),e.jsxs("div",{className:"relative",children:[e.jsx(m,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-5 w-5 text-gray-400"}),e.jsx("input",{ref:q,id:"new-password",type:T?"text":"password",required:!0,value:S,onChange:e=>J(e.target.value),minLength:8,className:"pl-10 pr-10 block w-full rounded-lg border-0 bg-gray-700/50 py-3 text-white shadow-sm ring-1 ring-inset ring-gray-600 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-500 sm:text-sm",placeholder:"New password",autoComplete:"new-password"}),e.jsx("button",{type:"button",onClick:()=>Y(!T),className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-white",children:T?e.jsx(h,{className:"h-5 w-5"}):e.jsx(x,{className:"h-5 w-5"})})]}),S&&e.jsxs("div",{className:"mt-2",children:[e.jsx("div",{className:"flex gap-1 mb-1",children:[1,2,3,4].map(s=>e.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${s<=M.strength?M.color:"bg-gray-600"}`},s))}),e.jsx("p",{className:`text-xs ${M.color.replace("bg-","text-")}`,children:M.label})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"confirm-password",className:"sr-only",children:"Confirm password"}),e.jsxs("div",{className:"relative",children:[e.jsx(m,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-5 w-5 text-gray-400"}),e.jsx("input",{id:"confirm-password",type:P?"text":"password",required:!0,value:E,onChange:e=>F(e.target.value),minLength:8,className:"pl-10 pr-10 block w-full rounded-lg border-0 bg-gray-700/50 py-3 text-white shadow-sm ring-1 ring-inset ring-gray-600 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-500 sm:text-sm",placeholder:"Confirm password",autoComplete:"new-password"}),e.jsx("button",{type:"button",onClick:()=>B(!P),className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-white",children:P?e.jsx(h,{className:"h-5 w-5"}):e.jsx(x,{className:"h-5 w-5"})})]}),E&&e.jsx("p",{className:"text-xs mt-1 "+(S===E?"text-green-400":"text-red-400"),children:S===E?"â Passwords match":"â Passwords do not match"})]}),X&&e.jsx(n.div,{initial:{opacity:0,y:-10}
1,animate:{opacity:1,y:0},className:"bg-red-900/50 text-red-200 p-3 rounded-lg text-sm",children:X}),e.jsx("button",{type:"submit",disabled:z||S.length<8||S!==E,className:"w-full flex justify-center py-3 px-4 rounded-full bg-white text-gray-900 font-semibold hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:z?e.jsx(d,{className:"h-5 w-5 animate-spin"}):"Change password"}),e.jsxs("button",{type:"button",onClick:G,className:"w-full text-center text-sm text-indigo-400 hover:text-indigo-300 transition-colors flex items-center justify-center gap-1 pt-2",children:[e.jsx(u,{className:"h-4 w-4"}),"Back"]})]})]}),"success"===b&&e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 bg-green-500/20 rounded-full flex items-center justify-center mb-6",children:e.jsx(g,{className:"h-8 w-8 text-green-500"})}),e.jsx("h2",{className:"text-2xl font-bold text-white mb-2",children:"Password changed"}),e.jsx("p",{className:"text-gray-400 text-sm mb-8",children:"Your password has been successfully reset. You can now sign in with your new password."}),e.jsx("button",{onClick:()=>p("/sign-in"),className:"w-full flex justify-center py-3 px-4 rounded-full bg-indigo-600 text-white font-semibold hover:bg-indigo-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition-colors",children:"Sign in"})]})]},b)})})})}export{p 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.