1import{r as l,j as e,s as x,a as h}from"./app-BIxlAa1M.js";import{u as j}from"./useTracking-DDYiB0pv.js";function E({otpLength:n,resend:p,label:u,error:d,handleOtpChange:m,trackingAttributes:r}){const[i,c]=l.useState(Array(n).fill(""));l.useEffect(()=>{const o=parseInt([...i].join(""),10);m(o)},[i]);const f=(o,a)=>{c(t=>{const s=[...t];return s[o]=a,s})};return e.jsxs("div",{className:"ol-form-field otp-field",children:[e.jsx("div",{className:"otp-label",children:e.jsx("span",{children:u})}),e.jsx("div",{className:"flex w-full",children:i.map((o,a)=>e.jsx("input",{type:"text",className:"otp-input-field",value:o,onChange:t=>{const s=t.target.value.replace(/\D/g,"");f(a,s),s&&a<i.length-1&&t.target.nextSibling.focus()},onPaste:t=>{const g=t.clipboardData.getData("Text").replace(/\D/g,"").substring(0,n).padEnd(n," ").split("");c(g)},onKeyUp:t=>{t.key==="Backspace"&&!t.target.value&&a>0&&t.target.previousSibling.focus()},maxLength:1},a))}),e.jsx("div",{className:"error-msg",children:d}),e.jsx(v,{resend:p,trackingAttributes:r})]})}function v({resend:n,trackingAttributes:p}){const{email:u,form:d}=p,m=j(x.otpLogin,d),[r,i]=l.useState(n.inSeconds),[c,f]=l.useState(null);l.useEffect(()=>{if(r>0){const t=setInterval(()=>{i(s=>s-1)},1e3);return()=>clearInterval(t)}return f(n.endpoint),()=>{}},[r,n.endpoint]);const o=t=>{const s=Math.floor(t/60),g=t%60;return`${s.toString().padStart(2,"0")}:${g.toString().padStart(2,"0")}`},a=()=>r>0?`${n.timer.running} ${o(r)}s`:n.timer.stopped;return e.jsx("div",{className:"resend-otp-link",children:e.jsxs("span",{children:[n.label," ",r>0&&e.jsx("span",{children:a()}),r<1&&e.jsx(h,{id:"resend-otp-link",onClick:()=>{m("resendOtpIntend",{"Email address":u})},href:c,className:"resend-link",children:a()})]})})}export{E 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.