import{e as x}from"./vendor-ui-DXwyveTF.js";import{v as w,aA as y,a4 as C,ab as _,j as b,aO as u,r as h,ax as d,q as B,ap as g,af as k,g as I}from"./vendor-core-CzvSW5ae.js";import{_ as S}from"./LoadingWrapper.vue_vue_type_script_setup_true_lang-bBtkKtmz.js";const j=w({__name:"AuthCodeSendBtn",props:{type:{default:"primary"},disabled:{type:Boolean,default:!1},text:{default:""},countdownText:{default:""},duration:{default:60}},emits:["send","finish"],setup(n,{expose:r,emit:i}){const{t:c}=y(),a=n,l=i,e=k(0);let t=null;const f=I(()=>e.value>0?c(a.countdownText,{n:e.value.toString()}):a.text),s=()=>{e.value=a.duration,t=window.setInterval(()=>{e.value--,e.value<=0&&(clearInterval(t),t=null,l("finish"))},1e3)},p=async o=>{a.disabled||e.value>0||(o.start(),l("send",{end:o.end,startCountdown:s}))};return C(()=>{t&&(clearInterval(t),t=null)}),r({startCountdown:s,getCountdown:()=>e.value}),(o,T)=>(_(),b(d(S),null,{default:u(({instance:m,loading:v})=>[h(d(x),{type:n.type??"default",loading:v,disabled:n.disabled||e.value>0,class:"whitespace-nowrap",onClick:A=>p(m)},{default:u(()=>[B(g(f.value),1)]),_:1},8,["type","loading","disabled","onClick"])]),_:1}))}});export{j as _};
