1import{r as V}from"./rolldown-runtime.C1f3BsDW.js";import{t as w}from"./inertia.BE4YqsTM.js";import"./http.DWpeO7Ui.js";import{Kt as D,Qr as W,Xt as O,_r as A,it as I,yr as B}from"./icons.ChOq_Y4q.js";import{t as q}from"./react-core.CAMe6Z4j.js";import"./utils.CgzVjNgC.js";import"./state.L8kQliOB.js";import{Bt as F,i as L,k as g}from"./entry-client.DX3aUoe5.js";import{t as K}from"./SEO.gPDL2mFy.js";import{t as z}from"./logo.7ZVhR9ER.js";import{t as G}from"./Card.CbhBZ5MF.js";import{n as Q}from"./postAuthDestination.BcKgx72u.js";var t=V(W(),1),e=V(q(),1),U=60;const X=()=>{const{verifyEmail:o,resendVerification:j,user:l}=L(),[r,a]=(0,t.useState)("loading"),[i,x]=(0,t.useState)(""),[c,n]=(0,t.useState)(""),[p,y]=(0,t.useState)("idle"),[C,E]=(0,t.useState)(""),[N,k]=(0,t.useState)(0),d=(0,t.useRef)(null),[v,_]=(0,t.useState)("/dashboard");(0,t.useEffect)(()=>{const s=new URLSearchParams(window.location.search),m=s.get("token"),b=s.get("email"),f=s.get("next");if(F(f)&&_(f),!m||!b){l?.email&&n(l.email),a("error_no_token");return}n(b);const M=F(f)?f:null;(async()=>{try{await o(m,b),a("success");const u=M??Q(L.getState().user,"");
1_(u),setTimeout(()=>{window.location.replace(u)},1500)}catch(u){const S=u instanceof Error?u.message:"Could not verify your email. Try again.";x(S);const h=S.toLowerCase();h.includes("expired")||h.includes("invalid")||h.includes("already")||h.includes("not found")?a("error_expired"):a("error_generic")}})()},[o,l]),(0,t.useEffect)(()=>()=>{d.current&&clearInterval(d.current)},[]);const P=()=>{k(U),d.current=setInterval(()=>{k(s=>s<=1?(d.current&&clearInterval(d.current),0):s-1)},1e3)},R=async()=>{const s=c.trim();if(s&&!(p==="sending"||N>0)){y("sending"),E("");try{await j(s),y("sent"),P()}catch(m){E(m instanceof Error?m.message:"Could not resend the email. Try again."),y("error")}}};return(0,e.jsxs)("main",{id:"main-content",className:"min-h-screen bg-background flex items-center justify-center p-6",children:[(0,e.jsx)(K,{title:"Verify email",noIndex:!0}),(0,e.jsxs)("div",{className:"w-full max-w-md animate-fade-in",children:[(0,e.jsx)("div",{className:"flex justify-center mb-8",children:(0,e.jsx)("a",{href:"/",children:(0,e.jsx)(z,{className:"size-8"})})}),(0,e.jsxs)(G,{variant:"default",padding:"lg",className:"border-border/50 text-center",children:[r==="loading"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"flex justify-center mb-6",children:(0,e.jsx)("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center",children:(0,e.jsx)(O,{className:"h-8 w-8 text-primary animate-spin","aria-hidden":"true"})})}),(0,e.jsx)("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Verifying your email"}),(0,e.jsx)("p",{className:"text-muted-foreground",children:"We are checking your verification linkâ¦"})]}),r==="success"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"flex justify-center mb-6",children:(0,e.jsx)("div",{className:"h-16 w-16 rounded-full bg-success/10 flex items-center justify-center",children:(0,e.jsx)(A,{className:"h-8 w-8 text-success","aria-hidden":"true"})})}),(0,e.jsx)("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Email verified"}),(0,e.jsxs)("p",{className:"text-muted-foreground mb-6",children:["Your email is verified."," ",v.startsWith("/pricing")?"Taking you to your planâ¦":"Redirecting youâ¦"]}),(0,e.jsx)(g,{className:"w-full",asChild:!0,children:(0,e.jsx)("a",{href:v,children:v.startsWith("/pricing")?"Choose my plan":"Continue"})})]}),r==="error_no_token"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"flex justify-center mb-6",children:(0,e.jsx)("div",{className:"h-16 w-16 rounded-full bg-primary/10 flex items-center justify-center",children:(0,e.jsx)(D,{className:"h-8 w-8 text-primary","aria-hidden":"true"})})}),(0,e.jsx)("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Check your email"}),(0,e.jsx)("p",{className:"text-muted-foreground mb-6",children:"We sent a verification link to your email. Open the link in that email to activate your account."}),(0,e.jsx)(T,{email:c,onEmailChange:n,onResend:R,resendState:p,resendError:C,cooldownSecs:N,hint:"Didn't receive it? Enter your email to resend."}),(0,e.jsx)("div",{className:"mt-4 pt-4 border-t border-border/40",children:(0,e.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Already verified?"," ",(0,e.jsx)(w,{href:"/login",className:"text-primary hover:text-primary/80 transition-colors font-medium",children:"Log in"})]})})]}),r==="error_expired"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"flex justify-center mb-6",children:(0,e.jsx)("div",{className:"h-16 w-16 rounded-full bg-warning/10 flex items-center justify-center",children:(0,e.jsx)(I,{className:"h-8 w-8 text-warning","aria-hidden":"true"})})}),(0,e.jsx)("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"This link has expired"}),(0,e.jsx)("p",{className:"text-muted-foreground mb-6",children:"Verification links expire after 24 hours. Enter your email below to get a fresh one."}),(0,e.jsx)(T,{email:c,onEmailChange:n,onResend:R,resendState:p,resendError:C,cooldownSecs:N}),(0,e.jsx)("div",{className:"mt-4 pt-4 border-t border-border/40",children:(0,e.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Already verified?"," ",(0,e.jsx)(w,{href:"/login",className:"text-primary hover:text-primary/80 transition-colors font-medium",children:"Log in"})]})})]}),r==="error_generic"&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"flex justify-center mb-6",children:(0,e.jsx)("div",{className:"h-16 w-16 rounded-full bg-destructive/10 flex items-center justify-center",children:(0,e.jsx)(B,{className:"h-8 w-8 text-destructive","aria-hidden":"true"})})}),(0,e.jsx)("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Could not verify your email"}),(0,e.jsx)("p",{className:"text-muted-foreground mb-6",children:i||"Something went wrong. Try again, or email [email protected]."}),(0,e.jsxs)("div",{className:"space-y-3",children:[(0,e.jsx)(g,{className:"w-full",variant:"outline",onClick:()=>window.location.reload(),children:"Try again"}),(0,e.jsx)(g,{className:"w-full",asChild:!0,children:(0,e.jsx)(w,{href:"/login",children:"Go to log in"})})]})]})]})]})]})};var T=({email:o,onEmailChange:j,onResend:l,resendState:r,resendError:a,cooldownSecs:i,hint:x})=>{const c=r==="sending"||i>0;return(0,e.jsxs)("div",{className:"space-y-3 text-left",children:[x&&(0,e.jsx)("p",{className:"text-sm text-muted-foreground text-center",children:x}),(0,e.jsx)("input",{type:"email",value:o,onChange:n=>j(n.target.value),placeholder:"[email protected]",className:"w-full rounded-lg border border-border bg-background px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/50 transition","aria-label":"Email address for resending verification",onKeyDown:n=>{n.key==="Enter"&&l()}}),r==="sent"?(0,e.jsxs)("div",{className:"rounded-lg bg-success/10 border border-success/20 px-4 py-3 text-sm text-success text-center",children:["Verification email sent. Check your inbox.",i>0&&(0,e.jsxs)("span",{className:"block mt-1 text-muted-foreground text-xs",children:["Resend again in ",i,"s"]})]}):null,r==="error"&&a&&(0,e.jsx)("p",{className:"text-sm text-destructive text-center",children:a}),(0,e.jsx)(g,{className:"w-full",onClick:l,disabled:c||!o.trim(),children:r==="sending"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(O,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),"Sendingâ¦"]}):i>0?`Resend in ${i}s`:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(D,{className:"h-4 w-4","aria-hidden":"true"}),r==="sent"?"Resend email":"Send verification email"]})})]})},oe=X;export{X as VerifyEmailPage,oe 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.