jQuery(document).ready(function(t){"use strict";var e=function(t,e,i){t=encodeURI(t),e=encodeURI(e);for(var n,a=i.parents(".yith-wcwtl-output").find("a.button, form"),r=void 0!==a.attr("action")?"action":"href",o=a.attr(r).split("&"),s=o.length;s--;)if((n=o[s].split("="))[0]==t){n[1]=e,o[s]=n.join("=");break}s<0&&(o[o.length]=[t,e].join("=")),a.prop(r,o.join("&"))},i=function(t,e){var i,n,a=t.split("?")[1].split("&");for(n=0;n<a.length;n++)i=a[n].split("="),e.push({name:i[0],value:i[1]});return e},n=function(e,n){t(document).trigger("yith-wcwtl-submit");var a=[{name:"action",value:"yith_wcwtl_submit"},{name:"context",value:"frontend"}],o=n.closest(".yith-wcwtl-output");a=i(e,a),o.addClass("active"),o.block({message:null,overlayCSS:{background:"#fff",opacity:.6}});let s=!o.find(".yith-wcwtl-submit").hasClass("button-leave");r(s).then(function(e){!0!==e&&a.push({name:"gtoken",value:e}),t.ajax({url:woocommerce_params.ajax_url,data:t.param(a),method:"POST",dataType:"json",error:function(t){},success:function(e){t(document).find(".yith-wcwtl-ajax-message").remove(),"error"===e.type?(o.replaceWith(e.form),t(document).find(".yith-wcwtl-notices").show().append(e.msg),t(document).find("#yith-wcwtl-user-email").trigger("input")):(t(document).find(".yith-wcwtl-output").addClass("success"),t(document).find(".yith-wcwtl-output").empty().html(e.msg)),t(document).find(".yith-wcwtl-output").removeClass("active"),t(document).find(".yith-wcwtl-output.active").unblock(),t(document).trigger("yith-wcwtl-submit-success")}})}).catch(function(e){console.log(e),t(document).find(".yith-wcwtl-output").removeClass("active"),t(document).find(".yith-wcwtl-output").unblock()})};let a="yes"===yith_wcwtl.is_ajax_enabled;t(document).on("click",".yith-wcwtl-output a.yith-wcwtl-submit",function(e){if(e.preventDefault(),a)n(t(this).attr("href"),t(this));else{let i=!t(this).hasClass("button-leave");r(i).then(function(){window.location.href=t(".yith-wcwtl-submit").attr("href")})}}),t(document).on("submit",".yith-wcwtl-output form",function(e){e.preventDefault(),n(t(this).attr("action"),t(this))}),t(document).on("input","#yith-wcwtl-user-email",function(){var i=t(this),n=i.val();e(i.attr("name"),n,i)}),t(document).on("change",".yith-wcwtl-policy-check",function(){var i,n=t(this);e(n.attr("name"),n.is(":checked")?"yes":"no",n)});var r=function(e=!0){if(!e)return new Promise(function(t){t(!0)});var i=t("#yith-wcwtl-user-email"),n=i.val();if(i.removeClass("error"),i.next(".yith-wcwtl-error-message").remove(),!n){var a='<div class="yith-wcwtl-error-message" style="color: red; font-size: 12px;margin: 20px 0; position: absolute; bottom: 0;">'+yith_wcwtl.email_empty_error+"</div>";return i.addClass("error").after(a),new Promise(function(t,e){e(yith_wcwtl.email_empty)})}return void 0!==yith_wcwtl.recaptcha_site_key&&yith_wcwtl.recaptcha_site_key?ywtwlGetCaptchaToken():new Promise(function(t){t(!0)})};t(document).on("input","#yith-wcwtl-user-email",function(){var e=t(this);e.removeClass("error"),e.next(".yith-wcwtl-error-message").remove()})});