!function(t,e){"use strict";e=e||{};var n={FIELD_NAME:"wpdef-turnstile-response",SELECTORS:{ROOT:"body",ADMIN:".wp-admin",RESPONSE_FIELD:'input[name="wpdef-turnstile-response"]',BUTTON:"input:submit",CONTAINER:".wpdef_captcha_turnstile",WIDGET:'div[id^="wpdef_turnstile_"]'},ATTRIBUTES:{VERIFIED:"data-verified",RENDERED:"data-rendered"},BUTTON_STATES:{ENABLED:{disabled:!1,css:{pointerEvents:"auto",cursor:"pointer",opacity:"1"}},DISABLED:{disabled:!0,css:{pointerEvents:"none",cursor:"not-allowed",opacity:"0.5"}}}},i=new Map;function r(t,e){if(t&&0!==t.length){var i=e?n.BUTTON_STATES.ENABLED:n.BUTTON_STATES.DISABLED;t.prop("disabled",i.disabled),t.css(i.css)}}function E(e){var i=e.find(n.SELECTORS.RESPONSE_FIELD);return 0===i.length&&(i=t("<input>").attr({type:"hidden",name:n.FIELD_NAME}).appendTo(e)),i}function a(t,e,i){r(e,!1),i.removeAttr(n.ATTRIBUTES.VERIFIED),E(t).val("")}function o(o){if(void 0===window.turnstile||!(null===(s=window.WPDEF)||void 0===s?void 0:s.options))return!1;var s;if(i.has(o))return!0;var T=t("#"+o);if(0===T.length)return!1;if("true"===T.attr(n.ATTRIBUTES.RENDERED))return!0;var u=T.closest("form"),l=t(n.SELECTORS.ROOT).hasClass(n.SELECTORS.ADMIN.slice(1)),d=null;u.length>0&&!l&&r(d=u.find(n.SELECTORS.BUTTON),!1);var c=window.turnstile.render("#"+o,{sitekey:e.options.sitekey,theme:e.options.theme,size:e.options.size,language:e.options.lang,"response-field-name":n.FIELD_NAME,callback:function(t){return function(t,e,i,a){E(t).val(e),r(i,!0),a.attr(n.ATTRIBUTES.VERIFIED,"true")}(u,t,d,T)},"error-callback":function(){return a(u,d,T)},"expired-callback":function(){return a(u,d,T)},"timeout-callback":function(){return a(u,d,T)}});return i.set(o,c),T.attr(n.ATTRIBUTES.RENDERED,"true"),!0}window.wpdefTurnstileCallback=function(){var e;0!==(e=t(n.SELECTORS.CONTAINER)).length&&e.each(function(){var e=t(this).find(n.SELECTORS.WIDGET);if(0!==e.length&&e.is(":empty")){var i=e.attr("id");i&&o(i)}})}}(jQuery,WPDEF);
