import{u as w,r as i,j as s,R as N,a as C}from"./app-BwDemWQz.js";import{I as k}from"./Input-BJaxI6jp.js";import{B as x}from"./Button-B-KWyoQR.js";import{A as D}from"./AuthLayout--k4aA7aD.js";import{u as S}from"./LanguageContext-zkEAKPTE.js";import{A as R}from"./arrow-left-B11txR0s.js";/* empty css            */import"./createLucideIcon-BASx8f0E.js";function K(){const{errors:d}=w().props,[n,m]=i.useState(["","","","","",""]),[A,B]=i.useState(""),[u,l]=i.useState(!1),c=i.useRef([]),a=S(),p=()=>{window.history.back()},g=(r,e)=>{const{value:t}=r.target;if(/^\d*$/.test(t)&&t.length<=1){const o=[...n];o[e]=t,m(o),t&&e<5&&c.current[e+1].focus()}},y=(r,e)=>{r.key==="Backspace"&&!n[e]&&e>0&&c.current[e-1].focus()},b=r=>{r.preventDefault();const e=r.clipboardData.getData("text").trim();if(/^\d+$/.test(e)){const t=e.split("").slice(0,6),o=[...n];t.forEach((v,h)=>{h<o.length&&(o[h]=v)}),m(o);const f=t.length<6?t.length:5;c.current[f]&&c.current[f].focus()}},j=r=>{r.preventDefault(),l(!0);const e=n.join(""),t=route("auth.password.verify.code");C.post(t,{otp_code:e},{onFinish:()=>l(!1),onError:()=>l(!1)})};return s.jsx(D,{children:s.jsxs("div",{className:"relative",children:[" ",s.jsx(x,{variant:"ghost",size:"icon",onClick:p,className:"absolute -top-2 -left-2 text-gray-600 dark:text-gray-200 hover:bg-gray-100","aria-label":"Go back",children:s.jsx(R,{className:"h-6 w-6"})}),s.jsx("h1",{className:"text-2xl font-bold mb-4 text-center text-gray-700 dark:text-gray-200",children:a("Verification Code")}),s.jsx("p",{className:"text-center text-gray-600 dark:text-gray-200 mb-8",children:a("Please enter the code we sent to your email")}),s.jsxs("form",{onSubmit:j,children:[s.jsx("div",{className:"flex justify-center items-center space-x-2 mb-8",children:n.map((r,e)=>s.jsxs(N.Fragment,{children:[s.jsx(k,{type:"text",maxLength:"1",value:r,onChange:t=>g(t,e),onKeyDown:t=>y(t,e),onPaste:b,ref:t=>c.current[e]=t,className:"w-12 h-12 text-center text-2xl font-bold border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-primary",inputMode:"numeric",pattern:"[0-9]","aria-label":`Digit ${e+1} of verification code`}),e===2&&s.jsx("span",{className:"lg:text-3xl text-2xl font-bold text-gray-400",children:"-"})]},e))}),s.jsx(x,{type:"submit",isLoading:u,className:"w-full bg-gradient-to-r from-primary to-secondary text-white hover:from-secondary hover:to-primary shadow-md hover:shadow-lg transition-all duration-200",children:a(u?"Verifying...":"Continue")})]}),d.otp_code&&s.jsx("p",{className:"mt-4 text-center text-sm text-red-600",children:d.otp_code}),s.jsxs("p",{className:"mt-4 text-center text-sm text-gray-500",children:[a("Didn't receive a code?")," ",s.jsx("a",{href:"#",className:"text-primary hover:underline",children:a("Resend")})]})]})})}export{K as default};
