!function(o){"use strict";o(document).ready(function(){if("active"==wps_wpr.is_restrict_status_set){wps_wpr.is_restrict_message_enable&&(o(".wps_wpr_restrict_user_message").hide(),o(".wps_wpr_show_restrict_message").html(wps_wpr.wps_restrict_rewards_msg),o(".wps_wpr_show_restrict_message").css("color","red"),setTimeout(()=>{jQuery(document).find(".wp-block-woocommerce-cart-order-summary-coupon-form-block.wc-block-components-totals-wrapper").append('
'+wps_wpr.wps_restrict_rewards_msg+"
"),o(".wps_wpr_color_for_restriction_msg").css("color","red")},2e3));var e=window.location.protocol+"//"+window.location.host+window.location.pathname;"undefined"!=window.history&&"undefined"!=window.history.pushState&&window.history.pushState({path:e},"",e)}var t=document.querySelectorAll("button");new ClipboardJS(t),o(".wps_wpr_level_benefits").click(function(){var e=o(this).data("id");jQuery("#wps_wpr_popup_wrapper_"+e).css("display","block"),jQuery(".wps_wpr_close").click(function(){jQuery("#wps_wpr_popup_wrapper_"+e).css("display","none")})}),o(document).on("click",".wps_wpr_common_slider",function(){jQuery(this).siblings(".wps_wpr_points_view").slideToggle()}),o(document).on("click","#wps_cart_points_apply",function(){var e=o(this).data("id"),t=wps_wpr.wps_user_current_points.trim(),s=o(this).data("order-limit"),p="",a=o("#wps_cart_points").val().trim();if(o("#wps_wpr_cart_points_notice").html(""),o("wps_wpr_cart_points_success").html(""),"undefined"!==a&&""!==a&&null!==a&&a>0){if(null!==t&&t>0&&parseFloat(t)>=parseFloat(a)){r(o(".woocommerce-cart-form")),r(o(".woocommerce-checkout"));var n={action:"wps_wpr_apply_fee_on_cart_subtotal",user_id:e,wps_cart_points:a,wps_nonce:wps_wpr.wps_wpr_nonce};o.ajax({url:wps_wpr.ajaxurl,type:"POST",data:n,dataType:"json",success:function(e){!0==e.result?(p=e.message,o("#wps_wpr_cart_points_success").addClass("woocommerce-message"),o("#wps_wpr_cart_points_success").removeClass("wps_rwpr_settings_display_none_notice"),o("#wps_wpr_cart_points_success").html(p),o("#wps_wpr_cart_points_success").show()):(p=e.message,o("#wps_wpr_cart_points_notice").addClass("woocommerce-error"),o("#wps_wpr_cart_points_notice").removeClass("wps_rwpr_settings_display_none_notice"),o("#wps_wpr_cart_points_notice").html(p),o("#wps_wpr_cart_points_notice").show())},complete:function(){if(c(o(".woocommerce-cart-form")),c(o(".woocommerce-cart-form")),0!==jQuery("#wps_wpr_button_to_add_points_section").length||wps_wpr.checkout_page||o("html, body").animate({scrollTop:jQuery(".woocommerce-cart-form").offset().top},800),wps_wpr.is_restrict_message_enable){var e=window.location.protocol+"//"+window.location.host+window.location.pathname+"?status=active&nonce="+wps_wpr.wps_wpr_nonce;"undefined"!=window.history&&"undefined"!=window.history.pushState&&window.history.pushState({path:e},"",e),0===jQuery("#wps_wpr_button_to_add_points_section").length?setTimeout(()=>{location.reload()},1500):location.reload()}else 0===jQuery("#wps_wpr_button_to_add_points_section").length?setTimeout(()=>{location.reload()},1500):location.reload()}})}else if("undefined"!==s&&""!==s&&null!==s&&s>0){if(o(".woocommerce-cart-form").offset()){o(".wps_error").remove(),0!==jQuery("#wps_wpr_button_to_add_points_section").length||wps_wpr.checkout_page||o("html, body").animate({scrollTop:o(".woocommerce-cart-form").offset().top},800);var i='";o(i).insertBefore(o(".woocommerce-cart-form"))}else{o(".wps_error").remove(),0===jQuery("#wps_wpr_button_to_add_points_section").length&&wps_wpr.checkout_page&&o("html, body").animate({scrollTop:o(".custom_point_checkout").offset().top},800);var i='";o(i).insertBefore(o(".custom_point_checkout"))}}else if(o(".woocommerce-cart-form").offset()){o(".wps_error").remove(),0!==jQuery("#wps_wpr_button_to_add_points_section").length||wps_wpr.checkout_page||o("html, body").animate({scrollTop:o(".woocommerce-cart-form").offset().top},800);var i='";o(i).insertBefore(o(".woocommerce-cart-form"))}else{o(".wps_error").remove(),0!==jQuery("#wps_wpr_button_to_add_points_section").length||wps_wpr.checkout_page||o("html, body").animate({scrollTop:o(".custom_point_checkout").offset().top},800);var i='";o(i).insertBefore(o(".custom_point_checkout"))}}}),o(document).on("click",".wps_remove_virtual_coupon",function(e){e.preventDefault(),wps_wpr.is_checkout||r(o(".woocommerce-cart-form"));var t=o(this),s={action:"wps_wpr_remove_cart_point",coupon_code:o(this).data("coupon"),wps_nonce:wps_wpr.wps_wpr_nonce,is_checkout:wps_wpr.is_checkout};o.ajax({url:wps_wpr.ajaxurl,type:"POST",data:s,dataType:"json",success:function(e){!0==e.result&&(o("#wps_cart_points").val(""),wps_wpr.is_checkout&&setTimeout(function(){t.closest("tr.cart-discount").remove(),jQuery(document.body).trigger("update_checkout")},200),location.reload())},complete:function(){wps_wpr.is_checkout||(c(o(".woocommerce-cart-form")),location.reload())}})});var r=function(o){s(o)||o.addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},s=function(o){return o.is(".processing")||o.parents(".processing").length},c=function(o){o.removeClass("processing").unblock()};o(document).on("click","#wps_wpr_upgrade_level_click",function(){confirm(wps_wpr.confirmation_msg)&&o(document).find("#wps_wpr_upgrade_level").click()}),o(".wps_wpr_custom_wallet").click(function(){var e=o(this).data("id"),t=o("#wps_custom_wallet_point_num").val().trim();if(o("#wps_wpr_custom_wallet").prop("disabled",!0),t){o("#wps_wpr_wallet_notification").html("");var r={action:"wps_wpr_generate_custom_wallet",points:t=parseFloat(t),user_id:e,wps_nonce:wps_wpr.wps_wpr_nonce};jQuery("#wps_wpr_loader").show(),o.ajax({url:wps_wpr.ajaxurl,type:"POST",data:r,dataType:"json",success:function(e){if(o("#wps_wpr_custom_wallet").prop("disabled",!1),jQuery("#wps_wpr_loader").hide(),!0==e.result)var t=''+e.message+"";if(!1==e.result)var t=''+e.message+"";o("#wps_wpr_wallet_notification").html(t)}})}else o("#wps_wpr_custom_wallet").prop("disabled",!1),o("#wps_wpr_wallet_notification").html(''+wps_wpr.empty_notice+"")})})}(jQuery);