import{r,y as V,o as k,g as q,w as _,a as n,h as u,f as o,t as A,j as B,m as F,S as D}from"./index-25eb6331.js";import{E as R}from"./dialog-66decf59.js";import"./overlay-25bb32bf.js";import{E as j}from"./button-c2afb424.js";/* empty css              */import{_ as I}from"./QrCodePreview-b18390db.js";import{e as y,E as g,a as N}from"./request-14d7fed5.js";import{t as T}from"./vue3-clipboard.esm-f774ce6a.js";import{g as L}from"./qrcode-fcd8dde4.js";const M=()=>y({url:"/admin/2fa/setup",method:"get"}),O=c=>y({url:"/admin/2fa/verify",method:"post",data:c}),Q={class:"text-center"},U=n("div",null,"可使用双因素认证软件扫描下方二维码或复制下方密钥到软件中添加。",-1),z={class:"flex justify-between space-x-2"},P={__name:"two-fa-dialog",props:{visible:{type:Boolean,required:!0}},emits:["close"],setup(c,{emit:p}){const f=c,a=r(f.visible),i=r(!1),d=r(!1);V(()=>f.visible,t=>{a.value=t,t&&(i.value=!1,m())});const b=()=>{i.value||p("close","")},e=r({}),m=()=>{M().then(t=>{e.value=t.data,e.value.svg=L({text:e.value.qrcode,correctLevel:1,isSpace:!1},D.rendererRect)})},h=()=>{d.value=!0,O(e.value).then(()=>{g.success("绑定成功"),i.value=!0,p("close",e.value.secret)}).finally(()=>{d.value=!1})},x=()=>{T(e.value.secret).then(()=>{g.success("复制成功")})};return(t,s)=>{const w=N,C=j,E=R;return k(),q(E,{"append-to-body":"",modelValue:o(a),"onUpdate:modelValue":s[1]||(s[1]=l=>F(a)?a.value=l:null),"destroy-on-close":!0,onClose:b,title:"绑定双因素认证",draggable:"",top:"5vh",width:"30%"},{default:_(()=>{var l,v;return[n("div",Q,[U,u(I,{class:"block my-4 mx-auto w-56 h-56",onClick:m,src:(l=o(e))==null?void 0:l.svg,alt:(v=o(e))==null?void 0:v.qrcode,filename:"two-fa-qrcode.png"},null,8,["src","alt"]),n("div",{onClick:x,class:"text-gray-300 mb-4"},A(o(e).secret),1),n("div",z,[u(w,{modelValue:o(e).code,"onUpdate:modelValue":s[0]||(s[0]=S=>o(e).code=S),placeholder:"请绑定双因素认证软件后，输入显示的验证码。"},null,8,["modelValue"]),u(C,{loading:o(d),type:"primary",onClick:h},{default:_(()=>[B("验证并绑定")]),_:1},8,["loading"])])])]}),_:1},8,["modelValue"])}}},ee=Object.freeze(Object.defineProperty({__proto__:null,default:P},Symbol.toStringTag,{value:"Module"}));export{P as _,ee as t,O as v};
