import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,r as n}from"./markdown-Biq8ujIZ.js";import{n as r}from"./AuthContext-Bov8HYX4.js";import{n as i,r as a,t as o}from"./validation-BzXm0WTc.js";import{Z as s,a as c,i as l}from"./index-Bh9Wgd1K.js";import{t as u}from"./Alert-DgQ1Y_9i.js";import{t as d}from"./OAuthButtons-Cxuz28le.js";var f=e(t(),1),p=n();function m(){let{signUp:e}=r(),[t,n]=(0,f.useState)(``),[m,g]=(0,f.useState)(``),[_,v]=(0,f.useState)(``),[y,b]=(0,f.useState)(``),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(!1),T=o(_);async function E(n){if(n.preventDefault(),b(``),!t.trim())return b(`Please enter your name.`);if(!i(m))return b(`Please enter a valid email address.`);if(!T.valid)return b(`Password must be at least 8 characters.`);S(!0);let r=await e(m.trim(),_,{name:t.trim()});S(!1),r.success?w(!0):b(r.error??`Could not create your account.`)}return C?(0,p.jsx)(a,{variant:`signup`,title:`Check your inbox`,subtitle:`One quick step to secure your account.`,footer:(0,p.jsx)(s,{to:`/login`,className:`font-medium text-brand-600 hover:underline`,children:`Back to sign in`}),children:(0,p.jsxs)(u,{tone:`success`,children:[`We sent a verification link to `,(0,p.jsx)(`strong`,{children:m}),`. Click it to activate your account, then sign in.`]})}):(0,p.jsxs)(a,{variant:`signup`,title:`Create your account`,subtitle:`Start studying smarter in under a minute.`,footer:(0,p.jsxs)(p.Fragment,{children:[`Already have an account?`,` `,(0,p.jsx)(s,{to:`/login`,className:`font-medium text-brand-600 hover:underline`,children:`Sign in`})]}),children:[(0,p.jsxs)(`form`,{onSubmit:E,className:`space-y-4`,children:[y&&(0,p.jsx)(u,{tone:`error`,children:y}),(0,p.jsx)(l,{label:`Full name`,name:`name`,autoComplete:`name`,placeholder:`Alex Student`,value:t,onChange:e=>n(e.target.value)}),(0,p.jsx)(l,{label:`Email`,name:`email`,type:`email`,autoComplete:`email`,placeholder:`you@example.com`,value:m,onChange:e=>g(e.target.value)}),(0,p.jsxs)(`div`,{children:[(0,p.jsx)(l,{label:`Password`,name:`password`,type:`password`,autoComplete:`new-password`,placeholder:`At least 8 characters`,value:_,onChange:e=>v(e.target.value)}),_&&(0,p.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,p.jsx)(`div`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-border`,children:(0,p.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${T.score/4*100}%`,backgroundColor:T.score<2?`#ef4444`:T.score<3?`#f59e0b`:`#10b981`}})}),(0,p.jsx)(`span`,{className:`w-16 text-right text-xs text-text-muted`,children:T.label})]})]}),(0,p.jsx)(c,{type:`submit`,fullWidth:!0,loading:x,children:`Create account`})]}),(0,p.jsxs)(`p`,{className:`mt-4 text-center text-xs text-text-muted`,children:[`By signing up you agree to our`,` `,(0,p.jsx)(s,{to:`/terms`,className:`text-brand-600 hover:underline`,children:`Terms`}),` &`,` `,(0,p.jsx)(s,{to:`/privacy`,className:`text-brand-600 hover:underline`,children:`Privacy Policy`}),`.`]}),(0,p.jsx)(h,{}),(0,p.jsx)(d,{onError:b})]})}function h(){return(0,p.jsxs)(`div`,{className:`my-6 flex items-center gap-3 text-xs text-text-muted`,children:[(0,p.jsx)(`span`,{className:`h-px flex-1 bg-border`}),`or continue with`,(0,p.jsx)(`span`,{className:`h-px flex-1 bg-border`})]})}export{m as default};