import{k as e,b7 as r,bq as a,X as t,E as n,S as s,a7 as u,c1 as o,q as c,aC as l,a1 as i,a6 as d,aw as g,bo as h,a8 as v,af as p,W as f,x as b,bt as x,b9 as y,dd as w}from"./index-WdfADTOW.js";const m=()=>{const{back:m}=e(),[_,k]=r(()=>a.post("/auth/2fa/generate")),q=c(),[$,C]=t(),[E,I]=t("");(async()=>{if(f().otp)return b.warning(q("users.2fa_already_enabled")),void m();const e=await k();x(e,C)})();const[S,W]=r(()=>{var e;return a.post("/auth/2fa/verify",{code:E(),secret:null==(e=$())?void 0:e.secret})}),j=async()=>{const e=await W();y(e,()=>{w({...f(),otp:!0}),m()})};return n(p,{get loading(){return _()},get children(){return n(s,{get when(){return $()},get children(){return n(u,{spacing:"$2",alignItems:"start",get children(){return[n(o,{get children(){return q("users.scan_qr")}}),n(l,{boxSize:"$xs",rounded:"$lg",get src(){var e;return null==(e=$())?void 0:e.qr}}),n(o,{get children(){return[i(()=>q("users.or_manual")),":"," ",n(d,{get color(){return g()},get children(){var e;return null==(e=$())?void 0:e.secret}})]}}),n(h,{maxW:"$xs",get placeholder(){return q("users.input_code")},get value(){return E()},onInput:e=>I(e.currentTarget.value),onKeyDown:e=>{"Enter"===e.key&&j()}}),n(v,{get loading(){return S()},onClick:j,get children(){return q("users.verify")}})]}})}})}})};export{m as default};
