(function(n,r){typeof exports=="object"&&typeof module<"u"?module.exports=r(require("vue")):typeof define=="function"&&define.amd?define(["vue"],r):(n=typeof globalThis<"u"?globalThis:n||self,n.VueTurnstile=r(n.Vue))})(this,function(n){"use strict";var m=Object.defineProperty;var w=(n,r,o)=>r in n?m(n,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[r]=o;var l=(n,r,o)=>w(n,typeof r!="symbol"?r+"":r,o);class r{constructor(){l(this,"events",{})}on(e,i){this.events[e]||(this.events[e]=[]),this.events[e].push(i)}off(e,i){this.events[e]&&(this.events[e]=this.events[e].filter(s=>s!==i))}emit(e,...i){this.events[e]&&this.events[e].forEach(s=>s(...i))}}const o=new r,u=n.defineComponent({name:"VueTurnstile",emits:["rendering","rendered","verified","error"],props:{siteKey:{type:String,required:!0},theme:{type:String,required:!1,default:"auto"},size:{type:String,required:!1,default:"normal"},autoReset:{type:Boolean,required:!1,default:!1},resetTimeout:{type:Number,required:!1,default:295*1e3},recaptchaCompat:{type:Boolean,required:!1,default:!1},explicitRender:{type:Boolean,required:!1,default:!1},appearance:{type:String,required:!1,default:"always"},language:{type:String,required:!1,default:"auto"}},data(){return{widgetId:null}},methods:{initTurnstile(){const t=document.createElement("script"),e="https://challenges.cloudflare.com/turnstile/v0/api.js",i="onloadTurnstileCallback",s=this.recaptchaCompat?"&compat=recaptcha":"",d=this.explicitRender?"&render=explicit":"";t.src=`${e}?onload=${i}${s}${d}`,t.async=!0,t.defer=!0,document.head.appendChild(t)},reset(){window.turnstile&&window.turnstile.reset(this.widgetId)},remove(){this.widgetId&&(window.turnstile.remove(this.widgetId),this.widgetId=null)},async execute(){return new Promise((t,e)=>{try{const i=s=>{o.off("verified",i),t(s)};o.on("verified",i),this.render()}catch(i){e(i)}})},render(){this.widgetId=window.turnstile.render("#cf-turnstile",{sitekey:this.siteKey,theme:this.theme,size:this.size,appearance:this.appearance,language:this.language,callback:t=>{this.$emit("verified",t),this.remove(),this.autoReset&&setTimeout(()=>{this.reset()},this.resetTimeout)},"expired-callback":()=>{this.reset()},"error-callback":t=>{console.error(`Error callback: ${t}`),this.$emit("error",t)}}),this.$emit("rendered")},onloadTurnstileCallback(){window.onloadTurnstileCallback=()=>{this.render()}}},beforeMount(){(window.turnstile===void 0||!window.turnstile)&&this.initTurnstile()},mounted(){this.$emit("rendering"),window.turnstile===void 0||!window.turnstile?this.onloadTurnstileCallback():this.render()},beforeUnmount(){this.remove()}});function c(t,e,i,s,d,y,g,_){var a=typeof t=="function"?t.options:t;return e&&(a.render=e,a.staticRenderFns=i,a._compiled=!0),{exports:t,options:a}}var f=function(){var e=this,i=e._self._c;return e._self._setupProxy,i("div",{attrs:{id:"cf-turnstile"}},[e._t("default")],2)},h=[],p=c(u,f,h);return p.exports});