(()=>{"use strict";var o,e,n=function(o){var e=o("body");!e.find(".rtsb-shopify-order-summery").length>0&&!e.find(".elementor-widget-container").length>0||(e.off("click.rtsbApplyCoupon"),e.on("click.rtsbApplyCoupon",'button[name="apply_coupon"]',function(e){e.preventDefault();var n=[],t=null,r=!1,c=!1,i=!1;if(o(this).parents(".rtsb-shopify-order-summery").length>0?(t=o(this).parents(".rtsb-shopify-order-summery"),r=!0,i=!0):o("body").find(".woocommerce-form-coupon").length>0?(t=o(this).parents(".woocommerce-form-coupon"),r=!0):o("body").find(".rtsb-cart-table").length>0&&(t=o(this).parents(".rtsb-cart-table, .rtsb-coupon-wrapper"),c=!0,n.push(o(".rtsb-cart-totals"))),t){n.push(t),n.forEach(function(o){o.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})});var a=t.find('input[name="coupon_code"]').val(),u=null;if("undefined"!=typeof wc_checkout_params?u=wc_checkout_params:"undefined"!=typeof wc_cart_params&&(u=wc_cart_params),u){var p={security:u.apply_coupon_nonce,coupon_code:a};o.ajax({type:"POST",url:u.wc_ajax_url.toString().replace("%%endpoint%%","apply_coupon"),data:new URLSearchParams(p).toString(),success:function(e){e&&(o(".woocommerce-error, .woocommerce-message").remove(),r?requestAnimationFrame(function(){window.displayNotice(e),i?o(document.body).trigger("applied_coupon_in_checkout",[a]):t.slideUp(),o(document.body).trigger("update_checkout",{update_shipping_method:!0})}):c&&(o(document).trigger("wc_update_cart"),setTimeout(function(){requestAnimationFrame(function(){window.displayNotice(e)})},700)),requestAnimationFrame(function(){n.forEach(function(o){o.removeClass("processing").unblock()})}))},error:function(o){console.log(o),console.log("Error applying coupon.")}})}}}))};o=jQuery,window.RTSB&&window.RTSB._initialized&&(null===(e=window.RTSB.modules.register("applyCoupon",function(){return{name:"applyCoupon",version:"1.0.0",init:function(){return n(o),this},refresh:function(){n(o)}}}))||void 0===e||e.init())})();