1import{a as L,aX as B,b as T,r as c,j as e,C as $,c as A,d as I,e as M,f as P,B as V,g as z,al as K}from"./main-DUZ67waj.js";import{I as _}from"./input-CaDOemLg.js";function H(){const d=L(),{email:i,returnTo:u}=B.useSearch(),{verifyMagicCode:N,requestMagicCode:w,isLoading:p,error:g,clearError:j,isAuthenticated:y}=T(),[o,m]=c.useState(["","","","","",""]),[f,C]=c.useState(!0),[h,b]=c.useState(60),n=c.useRef([]);c.useEffect(()=>{i||d({to:"/login",search:{returnTo:u}}),y&&d({to:u||"/dashboard"})},[i,y,d,u]),c.useEffect(()=>{if(h>0){const t=setTimeout(()=>b(s=>s-1),1e3);return()=>clearTimeout(t)}else C(!1)},[h]),c.useEffect(()=>{n.current[0]?.focus()},[]);const D=(t,s)=>{const a=s.slice(-1).toLowerCase();if(!/^[a-z0-9]$/.test(a)&&a!=="")return;const r=[...o];r[t]=a,m(r),a&&t<5&&n.current[t+1]?.focus(),r.every(l=>l!=="")&&r.join("").length===6&&x(r.join(""))},k=(t,s)=>{s.key==="Backspace"&&!o[t]&&t>0&&n.current[t-1]?.focus()},R=t=>{t.preventDefault();const s=t.clipboardData.getData("text").toLowerCase().slice(0,6);if(/^[a-z0-9]{1,6}$/.test(s)){const a=[...o];s.split("").forEach((l,v)=>{v<6&&(a[v]=l)}),m(a);const r=a.findIndex(l=>l==="");r!==-1?n.current[r]?.focus():(n.current[5]?.focus(),x(a.join("")))}},x=async t=>{j();const s=t||o.join("");if(s.length===6)try{await N(i,s)}catch{m(["","","","","",""]),n.current[0]?.focus()}},E=async()=>{if(!f){j(),C(!0),b(60);try{await w(i)}catch{}}},S=()=>{d({to:"/login",search:{returnTo:u}})};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background bg-gradient-radial p-4",children:e.jsxs("div",{className:"w-full max-w-md animate-[fade-up_0.5s_ease-out]",children:[e.jsx("div",{className:"flex justify-center mb-8",children:e.jsx("img",{src:"/logo.svg",alt:"Quidkey",className:"h-10"})}),e.jsxs($,{className:"border-border/50",children:[e.jsxs(A,{className:"text-center",children:[e.jsx(I,{className:"text-xl",children:"Check your email"}),e.jsxs(M,{children:["We sent a 6-character code to"," ",e.jsx("span",{className:"font-medium text-foreground",children:i})]})]}),e.jsx(P,{children:e.jsxs("form",{onSubmit:t=>{t.preventDefault(),x()},className:"space-y-6",children:[e.jsx("div",{className:"flex justify-center gap-2",children:o.map((t,s)=>e.jsx(_,{ref:a=>{n.current[s]=a},type:"text",inputMode:"text",maxLength:1,value:t,onChange:a=>D(s,a.target.value),onKeyDown:a=>k(s,a),onPaste:R,className:"w-12 h-14 text-center text-xl font-mono uppercase","aria-label":`Code digit ${s+1}`},s))}),g&&e.jsx("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md text-center",children:g}),e.jsx(V,{type:"submit",className:"w-full",disabled:p||o.some(t=>t===""),children:p?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"animate-spin"}),"Verifying..."]}):"Verify Code"}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("button",{type:"button",onClick:S,className:"text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1",children:[e.jsx(K,{className:"h-4 w-4"}),"Back"]}),e.jsx("button",{type:"button",onClick:E,disabled:f,className:`${f?"text-muted-foreground cursor-not-allowed":"text-primary hover:text-primary/80"} transition-colors`,children:f?`Resend in ${h}s`:"Resend code"})]})]})})]})]})})}export{H as component};
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.