import{d as t,a0 as e,a3 as s,F as a,af as i,a1 as n,aj as o}from"./vendor-C4fU48ba.js";import{_ as r}from"./index-20QKAx9H.js";const h=t({props:["ct"],data:()=>({loading:!1}),computed:{getCtData(){return this.ct},ctSize(){return this.getCtData.length},cIndex(){let t=this.getCtData.findIndex(t=>""===t);return t=(t+this.ctSize)%this.ctSize,t},lastCode(){return this.getCtData[this.ctSize-1]}},watch:{cIndex(){this.resetCaret()},lastCode(t,e){t&&t!=e&&(this.$refs.input[this.ctSize-1].blur(),this.sendCaptcha())}},mounted(){this.resetCaret()},methods:{onInput(t,e){if(t=String(t).replace(/\D/g,""),this.getCtData[e]=t,e==this.ctSize-1)this.getCtData[this.ctSize-1]=t[0];else if(t.length>1){let s=e;for(s=e;s<this.ctSize&&s-e<t.length;s++)this.getCtData[s]=t[s];this.resetCaret()}else t+""||(this.getCtData[e]="")},resetCaret(){this.$refs.input[this.ctSize-1].focus()},onFocus(){let t=this.getCtData.findIndex(t=>""===t);t=(t+this.ctSize)%this.ctSize,this.$refs.input[t].focus()},onKeydown(t,e){""===t&&e>0&&(this.getCtData[e-1]="",this.$refs.input[e-1].focus())},sendCaptcha(){let t=this.getCtData.map(t=>t).join("");this.$emit("sendCaptcha",t)},reset(){this.getCtData=this.getCtData.map(t=>""),this.resetCaret()}}}),c={id:"app"},d={class:"captcha"},u=["onInput","onKeydown","disabled"];const p=r(h,[["render",function(t,r,h,p,l,C){return n(),e("div",c,[s("div",d,[(n(!0),e(a,null,i(t.getCtData,(s,a)=>(n(),e("input",{key:a,type:"text",ref_for:!0,ref:"input",onInput:e=>{t.onInput(e.target.value,a)},onKeydown:o(e=>{t.onKeydown(e.target.value,a)},["delete"]),onFocus:r[0]||(r[0]=(...e)=>t.onFocus&&t.onFocus(...e)),disabled:t.loading},null,40,u))),128))])])}],["__scopeId","data-v-611c406a"]]);export{p as V};
