import{r as Y,s as Z,q as ee,b as te,c as ae,d as oe,_ as se,a as re,e as ne,f as le}from"./Layout.vue_vue_type_script_setup_true_lang-CE0KfyI0.js";import{c as q,_ as b}from"./AppLogoIcon.vue_vue_type_script_setup_true_lang-M23wUS8o.js";import{d as _,a as d,o as s,s as E,J as C,u as e,c as B,A as h,q as ie,g as y,w as r,e as t,i as p,b as a,k as ce,z as de,t as M,j as z,m as I,F as k,B as R,v as J,O as ue,P as fe,I as pe,r as me,h as ve,n as ye,p as he}from"./app-KXUNt_n9.js";import{c as $}from"./createLucideIcon-CFEmdjHu.js";import{E as be,a as _e}from"./eye-Da4bX1ky.js";import{_ as we}from"./InputError.vue_vue_type_script_setup_true_lang-DniwR9eG.js";import{d as xe,a as ge,b as ke,c as Ce,_ as $e}from"./DialogTitle.vue_vue_type_script_setup_true_lang-BSi28IEM.js";import{_ as Se,a as Fe,b as Te}from"./PinInputSlot.vue_vue_type_script_setup_true_lang-DexabK1A.js";import{c as Me}from"./useForwardExpose-B0NY7lip.js";import{L as N}from"./loader-circle-nLMSKP1C.js";import{C as Re}from"./check-BjrxEgzM.js";import{_ as U}from"./index-C5XcASgH.js";import{_ as qe}from"./AppLayout.vue_vue_type_script_setup_true_lang-BA0fi5xR.js";import"./index-Z7dItZLR.js";import"./index-CTpRNI-n.js";import"./index-KOXzqeVR.js";import"./index-C0lT1AXe.js";import"./VisuallyHidden-OJAPlYzx.js";import"./useArrowNavigation-C6Y-ieo6.js";import"./VisuallyHiddenInput-CfI0hj2P.js";import"./RovingFocusGroup-DKdqcDpA.js";/**
 * @license lucide-vue-next v0.468.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ee=$("CopyIcon",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
 * @license lucide-vue-next v0.468.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ve=$("LockKeyholeIcon",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]);/**
 * @license lucide-vue-next v0.468.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const je=$("RefreshCwIcon",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
 * @license lucide-vue-next v0.468.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ze=$("ScanLineIcon",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 12h10",key:"b7w52i"}]]);/**
 * @license lucide-vue-next v0.468.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ae=$("ShieldBanIcon",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m4.243 5.21 14.39 12.472",key:"1c9a7c"}]]);/**
 * @license lucide-vue-next v0.468.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Q=$("ShieldCheckIcon",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),De=_({__name:"Card",props:{class:{}},setup(i){const n=i;return(l,u)=>(s(),d("div",{"data-slot":"card",class:C(e(q)("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",n.class))},[E(l.$slots,"default")],2))}}),Le=_({__name:"CardContent",props:{class:{}},setup(i){const n=i;return(l,u)=>(s(),d("div",{"data-slot":"card-content",class:C(e(q)("px-6",n.class))},[E(l.$slots,"default")],2))}}),Be=_({__name:"CardDescription",props:{class:{}},setup(i){const n=i;return(l,u)=>(s(),d("p",{"data-slot":"card-description",class:C(e(q)("text-muted-foreground text-sm",n.class))},[E(l.$slots,"default")],2))}}),Ie=_({__name:"CardHeader",props:{class:{}},setup(i){const n=i;return(l,u)=>(s(),d("div",{"data-slot":"card-header",class:C(e(q)("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",n.class))},[E(l.$slots,"default")],2))}}),Oe=_({__name:"CardTitle",props:{class:{}},setup(i){const n=i;return(l,u)=>(s(),d("h3",{"data-slot":"card-title",class:C(e(q)("leading-none font-semibold",n.class))},[E(l.$slots,"default")],2))}}),L=async i=>{const n=await fetch(i,{headers:{Accept:"application/json"}});if(!n.ok)throw new Error(`Failed to fetch: ${n.status}`);return n.json()},F=h(null),T=h(null),j=h([]),Ke=B(()=>F.value!==null&&T.value!==null),O=()=>{const i=async()=>{const{svg:o}=await L(ee.url());F.value=o},n=async()=>{const{secretKey:o}=await L(Z.url());T.value=o},l=()=>{T.value=null,F.value=null};return{qrCodeSvg:F,manualSetupKey:T,recoveryCodesList:j,hasSetupData:Ke,clearSetupData:l,clearTwoFactorAuthData:()=>{l(),j.value=[]},fetchQrCode:i,fetchSetupKey:n,fetchSetupData:async()=>{try{await Promise.all([i(),n()])}catch(o){console.error("Failed to fetch setup data:",o),F.value=null,T.value=null}},fetchRecoveryCodes:async()=>{try{j.value=await L(Y.url())}catch(o){console.error("Failed to fetch recovery codes:",o),j.value=[]}}}},Pe={class:"flex flex-col gap-3 select-none sm:flex-row sm:items-center sm:justify-between"},He={class:"mt-3 space-y-3"},Ne={key:0,class:"space-y-2"},Ue=_({__name:"TwoFactorRecoveryCodes",setup(i){const{recoveryCodesList:n,fetchRecoveryCodes:l}=O(),u=h(!1),m=h(null),w=async()=>{!u.value&&!n.value.length&&await l(),u.value=!u.value,u.value&&(await J(),m.value?.scrollIntoView({behavior:"smooth"}))};return ie(async()=>{n.value.length||await l()}),(o,c)=>(s(),y(e(De),null,{default:r(()=>[t(e(Ie),null,{default:r(()=>[t(e(Oe),{class:"flex gap-3"},{default:r(()=>[t(e(Ve),{class:"size-4"}),c[0]||(c[0]=p("2FA Recovery Codes ",-1))]),_:1}),t(e(Be),null,{default:r(()=>[...c[1]||(c[1]=[p(" Recovery codes let you regain access if you lose your 2FA device. Store them in a secure password manager. ",-1)])]),_:1})]),_:1}),t(e(Le),null,{default:r(()=>[a("div",Pe,[t(e(b),{onClick:w,class:"w-fit"},{default:r(()=>[(s(),y(de(u.value?e(be):e(_e)),{class:"size-4"})),p(" "+M(u.value?"Hide":"View")+" Recovery Codes ",1)]),_:1}),u.value?(s(),y(e(z),I({key:0},e(te).form(),{method:"post",options:{preserveScroll:!0},onSuccess:e(l)}),{default:r(({processing:x})=>[t(e(b),{variant:"secondary",type:"submit",disabled:x},{default:r(()=>[t(e(je)),c[2]||(c[2]=p(" Regenerate Codes ",-1))]),_:1},8,["disabled"])]),_:1},16,["onSuccess"])):ce("",!0)]),a("div",{class:C(["relative overflow-hidden transition-all duration-300",u.value?"h-auto opacity-100":"h-0 opacity-0"])},[a("div",He,[a("div",{ref_key:"recoveryCodeSectionRef",ref:m,class:"grid gap-1 rounded-lg bg-muted p-4 font-mono text-sm"},[e(n).length?(s(!0),d(k,{key:1},R(e(n),(x,g)=>(s(),d("div",{key:g},M(x),1))),128)):(s(),d("div",Ne,[(s(),d(k,null,R(8,x=>a("div",{key:x,class:"h-4 animate-pulse rounded bg-muted-foreground/20"})),64))]))],512),c[3]||(c[3]=a("p",{class:"text-xs text-muted-foreground select-none"},[p(" Each recovery code can be used once to access your account and will be removed after use. If you need more, click "),a("span",{class:"font-bold"},"Regenerate Codes"),p(" above. ")],-1))])],2)]),_:1})]),_:1}))}}),Qe={class:"mb-3 w-auto rounded-full border border-border bg-card p-0.5 shadow-sm"},Je={class:"relative overflow-hidden rounded-full border border-border bg-muted p-2.5"},We={class:"absolute inset-0 grid grid-cols-5 opacity-50"},Ge={class:"absolute inset-0 grid grid-rows-5 opacity-50"},Xe={class:"relative flex w-auto flex-col items-center justify-center space-y-5"},Ye={class:"relative mx-auto flex max-w-md items-center overflow-hidden"},Ze={class:"relative mx-auto aspect-square w-64 overflow-hidden rounded-lg border border-border"},et={key:0,class:"absolute inset-0 z-10 flex aspect-square h-auto w-full animate-pulse items-center justify-center bg-background"},tt={key:1,class:"relative z-10 overflow-hidden border p-5"},at=["innerHTML"],ot={class:"flex w-full items-center space-x-5"},st={class:"flex w-full items-center justify-center space-x-2"},rt={class:"flex w-full items-stretch overflow-hidden rounded-xl border border-border"},nt={key:0,class:"flex h-full w-full items-center justify-center bg-muted p-3"},lt=["value"],it=["value"],ct={class:"flex w-full flex-col items-center justify-center space-y-3 py-2"},dt={class:"flex w-full items-center space-x-5"},ut=_({__name:"TwoFactorSetupModal",props:ue({requiresConfirmation:{type:Boolean},twoFactorEnabled:{type:Boolean}},{isOpen:{type:Boolean},isOpenModifiers:{}}),emits:["update:isOpen"],setup(i){const n=i,l=fe(i,"isOpen"),{copy:u,copied:m}=Me(),{qrCodeSvg:w,manualSetupKey:o,clearSetupData:c,fetchSetupData:x}=O(),g=h(!1),S=h([]),K=B(()=>S.value.join("")),P=h(null),A=B(()=>n.twoFactorEnabled?{title:"Two-Factor Authentication Enabled",description:"Two-factor authentication is now enabled. Scan the QR code or enter the setup key in your authenticator app.",buttonText:"Close"}:g.value?{title:"Verify Authentication Code",description:"Enter the 6-digit code from your authenticator app",buttonText:"Continue"}:{title:"Enable Two-Factor Authentication",description:"To finish enabling two-factor authentication, scan the QR code or enter the setup key in your authenticator app",buttonText:"Continue"}),W=()=>{if(n.requiresConfirmation){g.value=!0,J(()=>{P.value?.querySelector("input")?.focus()});return}c(),l.value=!1},G=()=>{n.twoFactorEnabled&&c(),g.value=!1,S.value=[]};return pe(()=>l.value,async H=>{if(!H){G();return}w.value||await x()}),(H,f)=>(s(),y(e(xe),{open:l.value,"onUpdate:open":f[5]||(f[5]=v=>l.value=v)},{default:r(()=>[t(e($e),{class:"sm:max-w-md"},{default:r(()=>[t(e(ge),{class:"flex items-center justify-center"},{default:r(()=>[a("div",Qe,[a("div",Je,[a("div",We,[(s(),d(k,null,R(5,v=>a("div",{key:`col-${v}`,class:"border-r border-border last:border-r-0"})),64))]),a("div",Ge,[(s(),d(k,null,R(5,v=>a("div",{key:`row-${v}`,class:"border-b border-border last:border-b-0"})),64))]),t(e(ze),{class:"relative z-20 size-6 text-foreground"})])]),t(e(ke),null,{default:r(()=>[p(M(A.value.title),1)]),_:1}),t(e(Ce),{class:"text-center"},{default:r(()=>[p(M(A.value.description),1)]),_:1})]),_:1}),a("div",Xe,[g.value?(s(),y(e(z),I({key:1},e(ae).form(),{"reset-on-error":"",onFinish:f[3]||(f[3]=v=>S.value=[]),onSuccess:f[4]||(f[4]=v=>l.value=!1)}),{default:r(({errors:v,processing:D})=>[a("input",{type:"hidden",name:"code",value:K.value},null,8,it),a("div",{ref_key:"pinInputContainerRef",ref:P,class:"relative w-full space-y-3"},[a("div",ct,[t(e(Se),{id:"otp",placeholder:"○",modelValue:S.value,"onUpdate:modelValue":f[1]||(f[1]=V=>S.value=V),type:"number",otp:""},{default:r(()=>[t(e(Fe),null,{default:r(()=>[(s(),d(k,null,R(6,(V,X)=>t(e(Te),{autofocus:"",key:V,index:X,disabled:D},null,8,["index","disabled"])),64))]),_:2},1024)]),_:2},1032,["modelValue"]),t(we,{message:v?.confirmTwoFactorAuthentication?.code},null,8,["message"])]),a("div",dt,[t(e(b),{type:"button",variant:"outline",class:"w-auto flex-1",onClick:f[2]||(f[2]=V=>g.value=!1),disabled:D},{default:r(()=>[...f[7]||(f[7]=[p(" Back ",-1)])]),_:1},8,["disabled"]),t(e(b),{type:"submit",class:"w-auto flex-1",disabled:D||K.value.length<6},{default:r(()=>[...f[8]||(f[8]=[p(" Confirm ",-1)])]),_:1},8,["disabled"])])],512)]),_:1},16)):(s(),d(k,{key:0},[a("div",Ye,[a("div",Ze,[e(w)?(s(),d("div",tt,[a("div",{innerHTML:e(w),class:"flex aspect-square size-full items-center justify-center"},null,8,at)])):(s(),d("div",et,[t(e(N),{class:"size-6 animate-spin"})]))])]),a("div",ot,[t(e(b),{class:"w-full",onClick:W},{default:r(()=>[p(M(A.value.buttonText),1)]),_:1})]),f[6]||(f[6]=a("div",{class:"relative flex w-full items-center justify-center"},[a("div",{class:"absolute inset-0 top-1/2 h-px w-full bg-border"}),a("span",{class:"relative bg-card px-2 py-1"},"or, enter the code manually")],-1)),a("div",st,[a("div",rt,[e(o)?(s(),d(k,{key:1},[a("input",{type:"text",readonly:"",value:e(o),class:"h-full w-full bg-background p-3 text-foreground"},null,8,lt),a("button",{onClick:f[0]||(f[0]=v=>e(u)(e(o)||"")),class:"relative block h-auto border-l border-border px-3 hover:bg-muted"},[e(m)?(s(),y(e(Re),{key:0,class:"w-4 text-green-500"})):(s(),y(e(Ee),{key:1,class:"w-4"}))])],64)):(s(),d("div",nt,[t(e(N),{class:"size-4 animate-spin"})]))])])],64))])]),_:1})]),_:1},8,["open"]))}}),ft={class:"space-y-6"},pt={key:0,class:"flex flex-col items-start justify-start space-y-4"},mt={key:1,class:"flex flex-col items-start justify-start space-y-4"},vt={class:"relative inline"},Dt=_({__name:"TwoFactor",props:{requiresConfirmation:{type:Boolean,default:!1},twoFactorEnabled:{type:Boolean,default:!1}},setup(i){const n=[{title:"Two-Factor Authentication",href:oe.url()}],{hasSetupData:l,clearTwoFactorAuthData:u}=O(),m=h(!1);return me(()=>{u()}),(w,o)=>(s(),y(qe,{breadcrumbs:n},{default:r(()=>[t(e(ve),{title:"Two-Factor Authentication"}),t(se,null,{default:r(()=>[a("div",ft,[t(re,{title:"Two-Factor Authentication",description:"Manage your two-factor authentication settings"}),i.twoFactorEnabled?(s(),d("div",mt,[t(e(U),{variant:"default"},{default:r(()=>[...o[7]||(o[7]=[p("Enabled",-1)])]),_:1}),o[9]||(o[9]=a("p",{class:"text-muted-foreground"}," With two-factor authentication enabled, you will be prompted for a secure, random pin during login, which you can retrieve from the TOTP-supported application on your phone. ",-1)),t(Ue),a("div",vt,[t(e(z),ye(he(e(le).form())),{default:r(({processing:c})=>[t(e(b),{variant:"destructive",type:"submit",disabled:c},{default:r(()=>[t(e(Ae)),o[8]||(o[8]=p(" Disable 2FA ",-1))]),_:1},8,["disabled"])]),_:1},16)])])):(s(),d("div",pt,[t(e(U),{variant:"destructive"},{default:r(()=>[...o[3]||(o[3]=[p("Disabled",-1)])]),_:1}),o[6]||(o[6]=a("p",{class:"text-muted-foreground"}," When you enable two-factor authentication, you will be prompted for a secure pin during login. This pin can be retrieved from a TOTP-supported application on your phone. ",-1)),a("div",null,[e(l)?(s(),y(e(b),{key:0,onClick:o[0]||(o[0]=c=>m.value=!0)},{default:r(()=>[t(e(Q)),o[4]||(o[4]=p("Continue Setup ",-1))]),_:1})):(s(),y(e(z),I({key:1},e(ne).form(),{onSuccess:o[1]||(o[1]=c=>m.value=!0)}),{default:r(({processing:c})=>[t(e(b),{type:"submit",disabled:c},{default:r(()=>[t(e(Q)),o[5]||(o[5]=p("Enable 2FA",-1))]),_:1},8,["disabled"])]),_:1},16))])])),t(ut,{isOpen:m.value,"onUpdate:isOpen":o[2]||(o[2]=c=>m.value=c),requiresConfirmation:i.requiresConfirmation,twoFactorEnabled:i.twoFactorEnabled},null,8,["isOpen","requiresConfirmation","twoFactorEnabled"])])]),_:1})]),_:1}))}});export{Dt as default};
