Current File : /home/kelaby89/kelaby.company/wp-content/plugins/advanced-google-recaptcha/js/icon-captcha.min.js |
/*! IconCaptcha v3.1.1 | (c) 2023, Fabian Wennink (fabianwennink.nl) | fabianwennink.nl/projects/IconCaptcha/license */
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var IconCaptchaPolyfills=function(){var e={extend:function(e){e=e||{};for(var t=1;t<arguments.length;t++){var a=arguments[t];if(a)for(var n in a)a.hasOwnProperty(n)&&("object"===_typeof(a[n])?a[n]instanceof Array?e[n]=a[n].slice(0):e[n]=IconCaptchaPolyfills.extend(e[n],a[n]):e[n]=a[n])}return e},ajax:function(){var t=(t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{})||{},a=new XMLHttpRequest;if(a.open(t.type||"get",t.url,t.async||!0),t.success&&(a.onload=function(){if(200===a.status)try{t.success(JSON.parse(a.responseText))}catch(e){t.success(a.responseText)}else t.error&&t.error({message:"Request returned ".concat(a.status,".")})}),t.error&&(a.onerror=function(e){return t.error(e)}),t.headers)for(var e in t.headers)a.setRequestHeader(e,t.headers[e]);if(a.setRequestHeader("X-Requested-With","XMLHttpRequest"),t.data)if(t.processData=t.processData||!0,t.data instanceof FormData||t.processData){if(t.data=t.data||{},t.processData&&"object"===_typeof(t.data)){var n,o=new FormData;for(n in t.data)o.append(n,t.data[n]);t.data=o}a.send(t.data)}else a.setRequestHeader("Content-Type","application/json"),a.send(JSON.stringify(t.data));else a.send()},trigger:function(e,t,a){var n=null;window.CustomEvent&&"function"==typeof window.CustomEvent?n=new CustomEvent(t,{detail:a}):(n=document.createEvent("CustomEvent")).initCustomEvent(t,!0,!0,a),e.dispatchEvent(n)},empty:function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},offset:function(e){if(!e.getClientRects().length)return{top:0,left:0};var t=e.getBoundingClientRect(),e=e.ownerDocument.defaultView;return{top:t.top+e.pageYOffset,left:t.left+e.pageXOffset}},width:function(e){return parseFloat(getComputedStyle(e,null).width.replace("px",""))}};return e}();function ownKeys(t,e){var a,n=Object.keys(t);return Object.getOwnPropertySymbols&&(a=Object.getOwnPropertySymbols(t),e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,a)),n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(a),!0).forEach(function(e){_defineProperty(t,e,a[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))})}return t}function _defineProperty(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}var IconCaptcha=function(){var e={},o={general:{validationPath:null,fontFamily:null,credits:"show"},security:{clickDelay:1500,hoverDetection:!0,enableInitialMessage:!0,initializeDelay:500,selectionResetDelay:3e3,loadingAnimationDelay:1e3,invalidateTime:12e4},messages:{initialization:{loading:"Loading challenge...",verify:"Verify that you are human."},header:"Select the image displayed the <u>least</u> amount of times",correct:"Verification complete.",incorrect:{title:"Uh oh.",subtitle:"You've selected the wrong image."},timeout:{title:"Please wait 60 sec.",subtitle:"You made too many incorrect selections."}}},D="https://www.fabianwennink.nl/projects/IconCaptcha",q="IconCaptcha by Fabian Wennink";e.$init=function(e,t){return a(this,e,t),this},e.init=function(e,t){return a(this,document.querySelectorAll(e),t),this},e.reset=function(t){return void 0===this.instances?console.error("IconCaptcha has not yet been initialized. Cannot use 'reset' yet."):void 0===t?T(this.instances,function(e){null!=e&&e.reset()}):null!==(e=this.instances.find(function(e){return e.id===t}))&&void 0!==e&&e.reset(),this;var e},e.bind=function(t,a){return void 0===this.nodes?console.error("IconCaptcha has not yet been initialized. Cannot use 'bind' yet."):T(this.nodes,function(e){e.addEventListener(t,a)}),this};var T=function(e,t){for(var a=0;a<e.length;a++)t(e[a],a)},a=function(a,e,t){var n;a.nodes?console.error("IconCaptcha has already been initialized."):(a.instances=[],a.nodes=e,n=IconCaptchaPolyfills.extend({},o,t||{}),T(a.nodes,function(e,t){a.instances.push(i(e,t,n))}))},i=function(e,t,o){var i,n,c,r=t+1,s=e,a=!1,l=null,d=0,u=!1,p=0,h=!1,f=!1;if(o.general.validationPath)return y(),{id:r,reset:function(){w(),f=h=u=a=!1,IconCaptchaPolyfills.trigger(s,"reset",{captchaId:r}),y()}};function y(){c=null===(e=document.querySelector('input[name="_iconcaptcha-token"]'))||void 0===e?void 0:e.value;var e,t=s.getAttribute("data-theme")||"light";if(s.classList.add("iconcaptcha-theme-"+t),o.general.fontFamily&&(s.style.fontFamily=o.general.fontFamily),!a&&o.security.enableInitialMessage)return o.security.enableInitialMessage&&s.addEventListener("click",function(e){a||e.target instanceof HTMLAnchorElement||(a=!0,s.querySelector(".iconcaptcha-modal__body-circle").style.animationDuration="2s",s.querySelector(".iconcaptcha-modal__body-title").innerText=o.messages.initialization.loading,setTimeout(function(){s.classList.remove("iconcaptcha-init"),y()},o.security.initializeDelay))}),e=["<div class='iconcaptcha-modal'>","<div class='iconcaptcha-modal__body'>","<div class='iconcaptcha-modal__body-circle'></div>","<div class='iconcaptcha-modal__body-info'>","<a href='".concat(D,"' target='_blank' rel='follow' title='").concat(q,"'>IconCaptcha ©</a>"),"</div>","<div class='iconcaptcha-modal__body-title'>".concat(o.messages.initialization.verify,"</div>"),"</div>","</div>"],s.classList.add("iconcaptcha-init"),s.classList.remove("iconcaptcha-error","iconcaptcha-success"),void(s.innerHTML=e.join(""));u||function(){var e=[];{var t;e.push("<div class='iconcaptcha-modal'>","<div class='iconcaptcha-modal__header'>","<span>".concat(o.messages.header,"</span>"),"</div>","<div class='iconcaptcha-modal__body'>","<div class='iconcaptcha-modal__body-icons'></div>","</div>","<div class='iconcaptcha-modal__footer'>"),"show"!==o.general.credits&&"hide"!==o.general.credits||(t="hide"===o.general.credits?"display: none":"",e.push("<span style='".concat(t,"'><a href='").concat(D,"' target='_blank' rel='follow' title='").concat(q,"'>IconCaptcha</a> ©</span>")))}e.push("</div>","<div class='iconcaptcha-modal__fields'>","<input type='hidden' name='ic-hf-se' required />","<input type='hidden' name='ic-hf-id' value='".concat(r,"' required />"),"<input type='hidden' name='ic-hf-hp' required />","</div>"),e.push("</div>"),s.innerHTML=e.join(""),i=s.querySelector(".iconcaptcha-modal__body")}(),_(),o.security.loadingAnimationDelay&&0<o.security.loadingAnimationDelay&&!o.security.enableInitialMessage?setTimeout(function(){return v(t)},o.security.loadingAnimationDelay):v(t)}function v(e){e=P({i:r,a:1,t:e,tk:c});IconCaptchaPolyfills.ajax({url:o.general.validationPath,type:"post",headers:S(c),data:{payload:e},success:function(e){if(e&&"string"==typeof e){var t=JSON.parse(atob(e));if(t.error)return void function(e,t){switch(e=parseInt(e)){case 1:b(o.messages.timeout.title,o.messages.timeout.subtitle,!1);var a=s.querySelector(".iconcaptcha-modal__header");a.parentNode.removeChild(a),IconCaptchaPolyfills.trigger(s,"timeout",{captchaId:r}),setTimeout(function(){return C(!1)},t);break;case 2:I(!0,"The captcha token is missing or is incorrect.","A server request was made without including a captcha token, however this option is enabled.");break;default:I(!0,"An unexpected error occurred.","An unexpected error occurred while IconCaptcha performed an action.")}}(t.error,t.data);var a=P({i:r,tk:c}),e=-1<o.general.validationPath.indexOf("?")?"&":"?",t=i.querySelector(".iconcaptcha-modal__body-icons");t.style.backgroundImage="url(".concat(o.general.validationPath).concat(e,"payload=").concat(a,")"),function(e){var t=e.style.backgroundImage.match(/\((.*?)\)/)[1].replace(/(['"])/g,""),e=new Image;e.onload=function(){var e;i.classList.remove("captcha-opacity");var t=i.querySelector(".captcha-loader");null==t||null!==(e=t.parentNode)&&void 0!==e&&e.removeChild(t)},e.src=t,e.complete&&e.onload(this)}(t),t.parentNode.insertAdjacentHTML("beforeend",'<div class="iconcaptcha-modal__body-selection"><i></i></div>'),n=i.querySelector(".iconcaptcha-modal__body-selection > i"),function(e){for(var t in e._ic_listeners={click:function(e){var t,a,n;new Date-p<=o.security.clickDelay||o.security.hoverDetection&&!f||(t=IconCaptchaPolyfills.offset(e.currentTarget),a=e.pageX-t.left,n=e.pageY-t.top,a&&n&&(i.classList.contains("captcha-opacity")||(IconCaptchaPolyfills.trigger(s,"selected",{captchaId:r}),o.security.loadingAnimationDelay&&0<o.security.loadingAnimationDelay?(_(),setTimeout(function(){return g(a,n)},o.security.loadingAnimationDelay)):g(a,n))))},mousemove:function(e){f&&!h&&u&&k(e)},mouseenter:function(e){n.style.display="inline",k(e),f=!0},mouseleave:function(){n.style.display="none",f=!1}},e._ic_listeners)e.addEventListener(t,e._ic_listeners[t])}(s.querySelector(".iconcaptcha-modal__body-selection")),u||IconCaptchaPolyfills.trigger(s,"init",{captchaId:r});t=i.querySelector(".iconcaptcha-modal__body-selection");return d=IconCaptchaPolyfills.width(t),p=new Date,u=!0,void(l=setTimeout(function(){return C(!0)},o.security.invalidateTime))}I(!0,"The IconCaptcha could not be loaded.","Invalid data was returned by the captcha back-end service. Make sure IconCaptcha is installed/configured properly.")},error:function(){return b()}})}function m(){s.classList.remove("iconcaptcha-error"),s.querySelector("input[name='ic-hf-se']").setAttribute("value",null),IconCaptchaPolyfills.empty(i),i.insertAdjacentHTML("beforeend","<div class='iconcaptcha-modal__body-icons'></div>"),y(),IconCaptchaPolyfills.trigger(s,"refreshed",{captchaId:r})}function g(e,t){void 0!==e&&void 0!==t&&(h=!0,w(),e=Math.round(e),t=Math.round(t),s.querySelector('input[name="ic-hf-se"]').setAttribute("value",[e,t,d].join(",")),s.querySelector('input[name="ic-hf-id"]').setAttribute("value",r),n.style.display="none",t=P({i:r,x:e,y:t,w:d,a:2,tk:c}),IconCaptchaPolyfills.ajax({url:o.general.validationPath,type:"POST",headers:S(c),data:{payload:t},success:function(){i.classList.remove("captcha-opacity"),j(s.querySelector(".iconcaptcha-modal__body-selection"));var e=s.querySelectorAll(".iconcaptcha-modal__header, .iconcaptcha-modal__footer, .iconcaptcha-modal__body");T(e,function(e){e.parentNode.removeChild(e)}),s.classList.add("iconcaptcha-success"),s.querySelector(".iconcaptcha-modal").innerHTML+='<div class="iconcaptcha-modal__body">'+'<div class="iconcaptcha-modal__body-title">'.concat(o.messages.correct,"</div>")+'<div class="iconcaptcha-modal__body-checkmark">'.concat('<svg viewBox="0 0 98.5 98.5" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><path class="checkmark" d="M81.7 17.8C73.5 9.3 62 4 49.2 4 24.3 4 4 24.3 4 49.2s20.3 45.2 45.2 45.2 45.2-20.3 45.2-45.2c0-8.6-2.4-16.6-6.5-23.4L45.6 68.2 24.7 47.3" fill="none" stroke-miterlimit="10" stroke-width="8"/></svg>',"</div>")+"<div class='iconcaptcha-modal__body-info'>"+"<a href='".concat(D,"' target='_blank' rel='follow' title='").concat(q,"'>IconCaptcha ©</a>")+"</div></div>",h=!1,IconCaptchaPolyfills.trigger(s,"success",{captchaId:r})},error:function(){return b()}}))}function b(e,t,a){a=!(2<arguments.length&&void 0!==a)||a;i.classList.remove("captcha-opacity"),j(s.querySelector(".iconcaptcha-modal__body-selection")),e=e||o.messages.incorrect.title,t=t||o.messages.incorrect.subtitle,s.classList.add("iconcaptcha-error"),i.innerHTML='<div class="iconcaptcha-modal__body-title">'.concat(e,"</div>")+'<div class="iconcaptcha-modal__body-subtitle">'.concat(t,"</div>"),h=!1,IconCaptchaPolyfills.trigger(s,"error",{captchaId:r}),a&&setTimeout(m,o.security.selectionResetDelay)}function _(){i.classList.add("captcha-opacity"),i.insertAdjacentHTML("beforeend",'<div class="captcha-loader"></div>')}function C(e){a=u=!1,!(0<arguments.length&&void 0!==e)||e?(e=P({i:r,a:3,tk:c}),IconCaptchaPolyfills.ajax({url:o.general.validationPath,type:"post",headers:S(c),data:{payload:e},success:function(){IconCaptchaPolyfills.trigger(s,"invalidated",{captchaId:r}),m()},error:function(){return b()}})):m()}function w(){null!==l&&(clearTimeout(l),l=null)}function I(e,t,a){a=2<arguments.length&&void 0!==a?a:"";b("IconCaptcha Error",t,!1),console.error(a),e&&IconCaptchaPolyfills.trigger(s,"error",{captchaId:r})}function P(e){return btoa(JSON.stringify(_objectSpread(_objectSpread({},e),{},{ts:Date.now()})))}function S(e){return e?{"X-IconCaptcha-Token":e}:{}}function j(e){if(e&&e._ic_listeners)for(var t in e._ic_listeners)e.removeEventListener(t,e._ic_listeners[t])}function k(e){var t;null!=e.currentTarget&&(t=IconCaptchaPolyfills.offset(e.currentTarget),n.style.left=Math.round(e.pageX-t.left)-8+"px",n.style.top=Math.round(e.pageY-t.top)-7+"px")}I(!0,"IconCaptcha was configured incorrectly","The IconCaptcha option `validationPath` has not been set.")};return e}();null!=window.jQuery&&function(t){t.fn.extend({iconCaptcha:function(e){var a=[];return t.each(this,function(e,t){a.push(t)}),IconCaptcha.$init(a,e)}})}(jQuery);