import{d as t,a0 as e,a3 as a,F as s,af as i,a1 as n,v as o,ak as r,aj as h}from"./vendor-DezibNX8.js";import{_ as d}from"./index-ANzWZHpw.js";const c=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=t.replace(/\D/g,""),e==this.ctSize-1)this.getCtData[this.ctSize-1]=t[0];else if(t.length>1){let a=e;for(a=e;a<this.ctSize&&a-e<t.length;a++)this.getCtData[a]=t[a];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()}}}),u={id:"app"},l={class:"captcha"},p=["onUpdate:modelValue","onInput","onKeydown","disabled"];const C=d(c,[["render",function(t,d,c,C,g,f){return n(),e("div",u,[a("div",l,[(n(!0),e(s,null,i(t.getCtData,(a,s)=>o((n(),e("input",{key:s,type:"number","onUpdate:modelValue":e=>t.getCtData[s]=e,ref_for:!0,ref:"input",onInput:e=>{t.onInput(e.target.value,s)},onKeydown:h(e=>{t.onKeydown(e.target.value,s)},["delete"]),onFocus:d[0]||(d[0]=(...e)=>t.onFocus&&t.onFocus(...e)),disabled:t.loading},null,40,p)),[[r,t.getCtData[s]]])),128))])])}],["__scopeId","data-v-96142174"]]);export{C as V};
