var j=(i,c)=>()=>(c||i((c={exports:{}}).exports,c),c.exports);var S=j((_,y)=>{(function(i,c){typeof _=="object"&&typeof y<"u"?y.exports=c():typeof define=="function"&&define.amd?define(c):(i=typeof globalThis<"u"?globalThis:i||self,i.FormValidation=i.FormValidation||{},i.FormValidation.plugins=i.FormValidation.plugins||{},i.FormValidation.plugins.Recaptcha3=c())})(void 0,function(){function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function v(e,t,r){return t&&c(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function g(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function P(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},l(e)}function p(e,t){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,n){return o.__proto__=n,o},p(e,t)}function A(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function m(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return m(e)}function O(e){var t=A();return function(){var o=l(e),n;if(t){var a=l(this).constructor;n=Reflect.construct(o,arguments,a)}else n=o.apply(this,arguments);return b(this,n)}}var w=FormValidation.Plugin,C=FormValidation.utils.fetch,d=function(e){P(r,e);var t=O(r);function r(o){var n;return i(this,r),n=t.call(this,o),n.opts=Object.assign({},{minimumScore:0},o),n.iconPlacedHandler=n.onIconPlaced.bind(m(n)),n}return v(r,[{key:"install",value:function(){var n=this;this.core.on("plugins.icon.placed",this.iconPlacedHandler);var a=typeof window[r.LOADED_CALLBACK]>"u"?function(){}:window[r.LOADED_CALLBACK];window[r.LOADED_CALLBACK]=function(){a();var h=document.createElement("input");h.setAttribute("type","hidden"),h.setAttribute("name",r.CAPTCHA_FIELD),document.getElementById(n.opts.element).appendChild(h),n.core.addField(r.CAPTCHA_FIELD,{validators:{promise:{message:n.opts.message,promise:function(I){return new Promise(function(L,E){window.grecaptcha.execute(n.opts.siteKey,{action:n.opts.action}).then(function(D){C(n.opts.backendVerificationUrl,{method:"POST",params:g({},r.CAPTCHA_FIELD,D)}).then(function(s){var F="".concat(s.success)==="true"&&s.score>=n.opts.minimumScore;L({message:s.message||n.opts.message,meta:s,valid:F})}).catch(function(s){E({valid:!1})})})})}}}})};var u=this.getScript();if(!document.body.querySelector('script[src="'.concat(u,'"]'))){var f=document.createElement("script");f.type="text/javascript",f.async=!0,f.defer=!0,f.src=u,document.body.appendChild(f)}}},{key:"uninstall",value:function(){this.core.off("plugins.icon.placed",this.iconPlacedHandler);var n=this.getScript(),a=[].slice.call(document.body.querySelectorAll('script[src="'.concat(n,'"]')));a.forEach(function(u){return u.parentNode.removeChild(u)}),this.core.removeField(r.CAPTCHA_FIELD)}},{key:"getScript",value:function(){var n=this.opts.language?"&hl=".concat(this.opts.language):"";return"https://www.google.com/recaptcha/api.js?"+"onload=".concat(r.LOADED_CALLBACK,"&render=").concat(this.opts.siteKey).concat(n)}},{key:"onIconPlaced",value:function(n){n.field===r.CAPTCHA_FIELD&&(n.iconElement.style.display="none")}}]),r}(w);return d.CAPTCHA_FIELD="___g-recaptcha-token___",d.LOADED_CALLBACK="___reCaptcha3Loaded___",d})});export default S();
