!function($){"use strict";function o(){return"undefined"!=typeof security_ninja_coupon&&(!0===security_ninja_coupon.is_banned||"1"===security_ninja_coupon.is_banned||1===security_ninja_coupon.is_banned)}function n(){const o="undefined"!=typeof security_ninja_coupon?security_ninja_coupon.ban_message:"Coupon application is temporarily disabled due to too many invalid attempts. Please wait before trying again.";"undefined"!=typeof wc_add_to_cart_params?$(document.body).trigger("added_to_cart",[null,null,null,o]):alert(o)}function e(){$('input[name="coupon_code"], .coupon-code-input').prop("disabled",!0);$(".woocommerce-apply-coupon, .apply-coupon").prop("disabled",!0);$('[data-block-name="woocommerce/cart-order-summary-coupon-form-block"] input, [data-block-name="woocommerce/checkout-order-summary-coupon-form-block"] input').prop("disabled",!0);$('[data-block-name="woocommerce/cart-order-summary-coupon-form-block"] button, [data-block-name="woocommerce/checkout-order-summary-coupon-form-block"] button').prop("disabled",!0);$('[data-block-name="woocommerce/cart-order-summary-coupon-form-block"], [data-block-name="woocommerce/checkout-order-summary-coupon-form-block"]').each((function(){const o=$(this);if(!o.hasClass("security-ninja-banned")){o.addClass("security-ninja-banned");const n="undefined"!=typeof security_ninja_coupon?security_ninja_coupon.ban_message:"Coupon application is temporarily disabled due to too many invalid attempts. Please wait before trying again.";o.html('<div class="woocommerce-info">'+n+"</div>")}}));$('input[placeholder*="coupon"], input[placeholder*="Coupon"], input[name*="coupon"]').prop("disabled",!0);$('button[value*="coupon"], button:contains("Apply"), button:contains("Coupon")').prop("disabled",!0)}$(document).ready((function(){o()&&(e(),n()),setInterval((function(){if(o()){$('[data-block-name*="coupon-form"]:not(.security-ninja-banned)').length>0&&e()}}),1e3)})),$(document).on("submit","form.woocommerce-coupon-form, .woocommerce-coupon-form form",(function(e){if(o())return e.preventDefault(),n(),!1})),$(document).on("click",".woocommerce-apply-coupon, .apply-coupon",(function(e){if(o())return e.preventDefault(),n(),!1})),$(document).on("input",'input[name="coupon_code"], .coupon-code-input',(function(e){o()&&($(this).val("").prop("disabled",!0),n())})),$(document).on("submit",'[data-block-name="woocommerce/cart-order-summary-coupon-form-block"] form, [data-block-name="woocommerce/checkout-order-summary-coupon-form-block"] form',(function(e){if(o())return e.preventDefault(),n(),!1})),$(document).on("click",'[data-block-name="woocommerce/cart-order-summary-coupon-form-block"] button, [data-block-name="woocommerce/checkout-order-summary-coupon-form-block"] button',(function(e){if(o())return e.preventDefault(),n(),!1})),$(document).on("input",'[data-block-name="woocommerce/cart-order-summary-coupon-form-block"] input, [data-block-name="woocommerce/checkout-order-summary-coupon-form-block"] input',(function(e){o()&&($(this).val("").prop("disabled",!0),n())})),$(document).on("woocommerce_cart_coupon_errors",(function(e,c){if(o())return n(),!1}));const c=window.fetch;window.fetch=function(...n){const e=n[0];return"string"==typeof e&&(e.includes("coupons")||e.includes("cart")||e.includes("checkout")||e.includes("apply_coupon"))&&o()?Promise.reject(new Error("Too many invalid coupon attempts. Please wait before trying again.")):c.apply(this,n)};const t=new MutationObserver((function(n){n.forEach((function(n){"childList"===n.type&&o()&&n.addedNodes.forEach((function(o){if(1===o.nodeType){const n=$(o);(n.is('[data-block-name*="coupon-form"]')||n.find('[data-block-name*="coupon-form"]').length)&&e()}}))}))}));o()&&t.observe(document.body,{childList:!0,subtree:!0}),o()&&setInterval((function(){if(!o())return;$('[data-block-name*="coupon"], .coupon, [class*="coupon"], [id*="coupon"]').each((function(){const o=$(this);if(!o.hasClass("security-ninja-banned")){o.addClass("security-ninja-banned");const n="undefined"!=typeof security_ninja_coupon?security_ninja_coupon.ban_message:"Coupon application is temporarily disabled due to too many invalid attempts. Please wait before trying again.";o.html('<div class="woocommerce-info">'+n+"</div>")}}))}),2e3)}(jQuery);