1import{j as e,k as S,I as w,f as b,A as v,r as m,n as C,o as E,L as P}from"./index-DbbrNrzR.js";import{s as r,S as k}from"./authPages.module-Wt-9mjK7.js";import{E as y}from"./EastRounded-CR1bwq4Y.js";import{u as N}from"./useAuthForm-SzYfTVTn.js";import"./formValidation-Dy1AWG5q.js";import"./libphonenumber-BoA-XnCi.js";const F=({email:s,errors:t,touched:o,handleChange:n,handleBlur:a,handleSubmit:l,isLoading:i})=>e.jsxs("div",{className:r.cardContainer,children:[e.jsx("h4",{className:r.loginTitle,children:"Forgot Password"}),e.jsx("p",{className:r.stepDescription,children:"Enter your registered email, you will receive a link to create a new password."}),e.jsxs("div",{className:r.stepContainer,children:[e.jsx("div",{className:r.formContainer,children:e.jsx(S,{field:{path:"email",label:"Email Address",type:"email",required:!0},value:s,onChange:n,onBlur:a,error:o.email?t.email:"",variant:"standard"})}),e.jsx("div",{className:r.buttonContainer,children:e.jsx(w,{className:r.arrowButton,onClick:l,disabled:!s||!!t.email||i,children:i?e.jsx(b,{size:24,color:"inherit"}):e.jsx(y,{className:r.arrowIcon})})})]})]}),A=({email:s})=>e.jsxs("div",{className:r.cardContainer,children:[e.jsx("h4",{children:"Email Sent!"}),e.jsx("div",{className:r.stepContainer,children:e.jsxs("div",{className:r.contentContainer,children:[e.jsxs("p",{children:["We've sent a password reset link to:",e.jsx("br",{}),e.jsx("strong",{children:s})]}),e.jsx("p",{children:"Please check your inbox and follow the instructions to reset your password."})]})})]}),L=()=>{const{formData:s,errors:t,touched:o,handleChange:n,handleBlur:a,validateForm:l}=N({email:""}),i=v.getInstance(),[u,c]=m.useState({step:1,errorMessage:null,emailSent:!1,isLoading:!1});return{formData:s,errors:t,touched:o,forgotPasswordState:u,forgotPasswordActions:{handleEmailSubmit:async()=>{var p,j;if(l()){c(h=>({...h,isLoading:!0}));try{await i.forgotPassword(s.email),c(h=>({...h,step:2,emailSent:!0,errorMessage:null,isLoading:!1}))}catch(h){const x=((j=(p=h==null?void 0:h.response)==null?void 0:p.data)==null?void 0:j.message)||"Failed to process your request. Please try again.";c(f=>({...f,errorMessage:x,isLoading:!1}))}}},handleBackToEmail:()=>{c(g=>({...g,step:1,errorMessage:null}))}},handleChange:n,handleBlur:a}},B=({children:s})=>{const{formData:t,errors:o,touched:n,forgotPasswordState:a,forgotPasswordActions:l,handleChange:i,handleBlur:u}=L(),c={formData:t,errors:o,touched:n,forgotPasswordState:a,forgotPasswordActions:l,handleChange:i,handleBlur:u};return e.jsx(e.Fragment,{children:s(c)})},M=({forgotPasswordContext:s})=>{const{formData:t,errors:o,touched:n,forgotPasswordState:a,forgotPasswordActions:l,handleChange:i,handleBlur:u}=s;return a.step===1?e.jsx(F,{email:t.email,errors:o,touched:n,handleChange:i,handleBlur:u,handleSubmit:l.handleEmailSubmit,errorMessage:a.errorMessage,isLoading:a.isLoading}):a.step===2?e.jsx(A,{email:t.email,handleBackToEmail:l.handleBackToEmail}):null},T=()=>e.jsxs("div",{className:r.linksContainer,children:[e.jsx("p",{children:e.jsx("a",{href:"login",children:"Back to Login"})}),e.jsxs("p",{children:["Don't have an account? ",e.jsx("a",{href:"signup",children:"Sign Up"})]})]}),D=({forgotPasswordContext:s,onLastSubmitTimeChange:t,onErrorMessageChange:o})=>{m.useEffect(()=>{o(s.forgotPasswordState.errorMessage||"")},[s.forgotPasswordState.errorMessage,o]);const n=s.forgotPasswordActions.handleEmailSubmit;if(!s.forgotPasswordActions.handleEmailSubmit.isWrapped){const a=async()=>{t(Date.now()),await n()};a.isWrapped=!0,s.forgotPasswordActions.handleEmailSubmit=a}return e.jsxs("div",{className:r.container,children:[e.jsx("div",{className:r.logoContainer,children:e.jsx(P,{})}),e.jsxs("div",{className:r.squirrelContainer,children:[e.jsx(k,{children:e.jsx(M,{forgotPasswordContext:s})}),e.jsx(T,{})]})]})},O=()=>{const[s,t]=m.useState({open:!1,message:"",severity:"error"}),[o,n]=m.useState(0),[a,l]=m.useState(""),i=()=>{t(d=>({...d,open:!1}))};m.useEffect(()=>{o>0&&a&&t({open:!0,message:a,severity:"error"})},[o,a]);const u=m.useCallback(d=>{n(d)},[]),c=m.useCallback(d=>{l(d)},[]);return e.jsx(B,{children:d=>e.jsxs(e.Fragment,{children:[e.jsx(D,{forgotPasswordContext:d,onLastSubmitTimeChange:u,onErrorMessageChange:c}),e.jsx(C,{open:s.open,autoHideDuration:6e3,onClose:i,anchorOrigin:{vertical:"top",horizontal:"right"},children:e.jsx(E,{onClose:i,severity:s.severity,children:s.message})})]})})};export{O 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.