import{r as e}from"./rolldown-runtime-CpWojdLp.js";import{n as t,r as n,t as r}from"./jsx-runtime-BrKkGzFB.js";import{B as i,Et as a,O as o,Ot as s,Tt as c}from"./app-KzKSswgw.js";import{t as l}from"./input-error-B1iqlu2_.js";import{c as u,l as d,o as f,s as p,u as m}from"./use-two-factor-auth-C4Bh9Rcd.js";var h=t(),g=e(n(),1),_=r();function v(){let e=(0,h.c)(14),[t,n]=(0,g.useState)(!1),[r,d]=(0,g.useState)(``),v;bb0:{if(t){let t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={title:`Recovery code`,description:`Please confirm access to your account by entering one of your emergency recovery codes.`,toggleText:`login using an authentication code`},e[0]=t):t=e[0],v=t;break bb0}let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n={title:`Authentication code`,description:`Enter the authentication code provided by your authenticator application.`,toggleText:`login using a recovery code`},e[1]=n):n=e[1],v=n}let b=v;s({title:b.title,description:b.description});let x;e[2]===t?x=e[3]:(x=e=>{n(!t),e(),d(``)},e[2]=t,e[3]=x);let S=x,C;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,_.jsx)(a,{title:`Two-factor authentication`}),e[4]=C):C=e[4];let w;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(w=f.form(),e[5]=w):w=e[5];let T=!t,E;e[6]!==b.toggleText||e[7]!==r||e[8]!==t||e[9]!==S?(E=e=>{let{errors:n,processing:a,clearErrors:s}=e;return(0,_.jsxs)(_.Fragment,{children:[t?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(o,{name:`recovery_code`,type:`text`,placeholder:`Enter recovery code`,autoFocus:t,required:!0}),(0,_.jsx)(l,{message:n.recovery_code})]}):(0,_.jsxs)(`div`,{className:`flex flex-col items-center justify-center space-y-3 text-center`,children:[(0,_.jsx)(`div`,{className:`flex w-full items-center justify-center`,children:(0,_.jsx)(p,{name:`code`,maxLength:6,value:r,onChange:e=>d(e),disabled:a,pattern:m,children:(0,_.jsx)(u,{children:Array.from({length:6},y)})})}),(0,_.jsx)(l,{message:n.code})]}),(0,_.jsx)(i,{type:`submit`,className:`w-full`,disabled:a,children:`Continue`}),(0,_.jsxs)(`div`,{className:`text-center text-sm text-muted-foreground`,children:[(0,_.jsx)(`span`,{children:`or you can `}),(0,_.jsx)(`button`,{type:`button`,className:`cursor-pointer text-foreground underline decoration-neutral-300 underline-offset-4 transition-colors duration-300 ease-out hover:decoration-current! dark:decoration-neutral-500`,onClick:()=>S(s),children:b.toggleText})]})]})},e[6]=b.toggleText,e[7]=r,e[8]=t,e[9]=S,e[10]=E):E=e[10];let D;return e[11]!==T||e[12]!==E?(D=(0,_.jsxs)(_.Fragment,{children:[C,(0,_.jsx)(`div`,{className:`space-y-6`,children:(0,_.jsx)(c,{...w,className:`space-y-4`,resetOnError:!0,resetOnSuccess:T,children:E})})]}),e[11]=T,e[12]=E,e[13]=D):D=e[13],D}function y(e,t){return(0,_.jsx)(d,{index:t},t)}export{v as default};