import{s as w,u as y,x as v,c as x,o as _}from"./app-BhD6J0Va.js";const b=w({__name:"vueRecaptcha",props:{sitekey:{type:String,required:!0},size:{type:String,required:!1,default:"normal"},theme:{type:String,required:!1,default:"light"},hl:{type:String,required:!1},loadingTimeout:{type:Number,required:!1,default:0}},emits:{verify:e=>e!=null&&e!="",error:e=>e,expire:null,fail:null},setup(e,{expose:m,emit:n}){const t=e,u=y(null);let i=null;m({execute:function(){window.grecaptcha.execute(i)},reset:function(){window.grecaptcha.reset(i)}});function s(){i=window.grecaptcha.render(u.value,{sitekey:t.sitekey,theme:t.theme,size:t.size,callback:r=>n("verify",r),"expired-callback":()=>n("expire"),"error-callback":()=>n("fail")})}return v(()=>{window.grecaptcha==null?new Promise((r,d)=>{let o,c=!1;window.recaptchaReady=function(){c||(c=!0,clearTimeout(o),r())};const p="recaptcha-script",l=g=>()=>{var h;c||(c=!0,clearTimeout(o),(h=document.getElementById(p))==null||h.remove(),d(g))};t.loadingTimeout>0&&(o=setTimeout(l("timeout"),t.loadingTimeout));const f=window.document,a=f.createElement("script");a.id=p,a.onerror=l("error"),a.onabort=l("aborted"),a.setAttribute("src",`https://www.google.com/recaptcha/api.js?onload=recaptchaReady&render=explicit&hl=${t.hl}&_=${+new Date}`),f.head.appendChild(a)}).then(()=>{s()}).catch(r=>{n("error",r)}):s()}),(r,d)=>(_(),x("div",{ref_key:"recaptchaDiv",ref:u},null,512))}});export{b as _};
