!function(n){var s;"undefined"!=typeof wc_price_based_country_ajax_geo_params&&(s={xhr:!1,get_product_ids:function(){var a=[],r=null;return n("span.wcpbc-price.loading").each(function(){var e;void 0===(r=n(this).data("productId"))&&null!=(e=n(this).attr("class").match(/wcpbc-price-\d+/))&&0<e.length&&(r=parseInt(e[0].replace("wcpbc-price-",""))),r&&void 0!==r&&a.push(r)}),0<n("[data-product_variations]").length&&n("[data-product_variations]").each(function(){var e=n(this).data("product_variations");null!=e&&n.each(e,function(e,r){void 0!==r.variation_id&&a.push(r.variation_id)})}),n(document.body).trigger("wc_price_based_country_get_product_ids",[a]),a.sort(),a},get_areas:function(){var i={};return n(".wc-price-based-country-refresh-area:not(.refreshed)").each(function(e,r){var a=n(r).data("area"),c=n(r).data("id"),r=n(r).data("options");void 0!==a&&void 0!==c&&void 0!==r&&(void 0===i[a]&&(i[a]={}),i[a][c]=r)}),i},refresh_product_price:function(o){var a;n.each(o,function(e,r){void 0!==(a=n("<div>"+r.price_html+"</div>").find(".wcpbc-price.wcpbc-price-"+r.id+":first"))&&n(".wcpbc-price.wcpbc-price-"+r.id).html(a.html()).removeClass("loading")}),0<n("[data-product_variations]").length&&n("[data-product_variations]").each(function(){var i=n(this).data("product_variations"),t=n(this);null!=i&&(n.each(i,function(e,r){var a,c;void 0!==o[r.variation_id]&&(c=n(r.price_html),i[e].display_price=o[r.variation_id].display_price,i[e].display_regular_price=o[r.variation_id].display_regular_price,0<c.length?c=c.hasClass("price")&&1===c.length?((a=n("<div></div>").append(c)).find(".price").html(o[r.variation_id].price_html),n(a.html())):n(o[r.variation_id].price_html):n("body").hasClass("single-product")||(c=s.compatibility.variation_price_html(c,t,o[r.variation_id].price_html)),0<c.length&&(c.find(".wcpbc-price").css("visibility",""),c.find(".wcpbc-price").removeClass("loading"),c=n("<div></div>").append(c),i[e].price_html=c.html()))}),n(this).data("product_variations",i))}),n(document.body).trigger("wc_price_based_country_set_product_price",[o]),n(".wcpbc-price").css("visibility",""),n(".wcpbc-price").css("display",""),n(".wcpbc-price").removeClass("loading")},refresh_areas:function(e){n.each(e,function(e,r){var a='.wc-price-based-country-refresh-area[data-id="'+r.id+'"][data-area="'+r.area+'"]',r=n("<div>"+r.content+"</div>").find('.wc-price-based-country-refresh-area[data-area="'+r.area+'"]').html();n(a).html(r).addClass("refreshed")}),n(document.body).trigger("wc_price_based_country_refresh_areas",[e])},refresh_currency_settings:function(e){var r,a;"undefined"!=typeof woocommerce_price_slider_params&&"undefined"!=typeof accounting&&(r=n(".price_slider_amount #min_price").val(),a=n(".price_slider_amount #max_price").val(),n(".price_slider_amount span.from").html(accounting.formatMoney(r,{symbol:e.symbol,decimal:e.decimal_sep,thousand:e.thousand_sep,precision:woocommerce_price_slider_params.currency_format_num_decimals,format:e.format})),n(".price_slider_amount span.to").html(accounting.formatMoney(a,{symbol:e.symbol,decimal:e.decimal_sep,thousand:e.thousand_sep,precision:woocommerce_price_slider_params.currency_format_num_decimals,format:e.format})),woocommerce_price_slider_params.currency_format_symbol=e.symbol,woocommerce_price_slider_params.currency_format_decimal_sep=e.decimal_sep,woocommerce_price_slider_params.currency_format_thousand_sep=e.thousand_sep,woocommerce_price_slider_params.currency_format=e.format),n(document.body).trigger("wc_price_based_country_set_currency_params",[e])},compatibility:{variation_price_html:function(e,r,a){return e=e.length<=0&&r.hasClass("wvs-archive-variation-wrapper")?n("<span></span>").append(a):e},bind:function(){0<n(".wc-price-based-country-refresh-area .wcsatt-options-wrapper").length&&(n(".wc-price-based-country-refresh-area .wcsatt-options-wrapper").each(function(){var e=n(this).closest(".wc-price-based-country-refresh-area").data("id");n(this).addClass("wcpbc-refresh-flag wcpbc-refresh-flag-"+e)}),n(document.body).on("wc_price_based_country_refresh_areas",function(){n(".wcsatt-options-wrapper.wcpbc-refresh-flag").length&&n(".wc-price-based-country-refresh-area .wcsatt-options-wrapper").each(function(){var e=n(this).closest(".wc-price-based-country-refresh-area").data("id"),r=n(this).closest(".wc-price-based-country-refresh-area").html();n(".wcsatt-options-wrapper.wcpbc-refresh-flag-"+e).replaceWith(r),n(this).remove()}),n(".product form.cart").each(function(){n(this).data("satt_script",null)}),n(document.body).triggerHandler("wcsatt-initialize")})),0<n(".variations_form.cart").length&&0<n('[class^="wcsatt"]').length&&n(document.body).on("wc_price_based_country_set_product_price",function(){0<n(".variations_form.cart .wcsatt-options-wrapper").length&&n(".variations_form.cart .variations select").trigger("change.wc-variation-form")}),n(".skeleton-loading").length&&n(".skeleton-loading").on("skeleton-loaded",function(){n(document.body).trigger("wc_price_based_country_ajax_geolocation")}),n(".wvs-archive-variations-wrapper").length&&(n(".wvs-archive-variations-wrapper").removeClass("wvs-archive-variations-wrapper").addClass("wcpbc-wvs-archive-variations-wrapper"),n(document.body).on("wc_price_based_country_after_ajax_geolocation",function(){n(".wcpbc-wvs-archive-variations-wrapper").removeClass("wcpbc-wvs-archive-variations-wrapper").addClass("wvs-archive-variations-wrapper"),n(document).trigger("woo_variation_swatches_pro_init")}))}},geolocate_customer:function(){s.xhr&&s.xhr.abort();var e={ids:s.get_product_ids(),areas:s.get_areas(),is_single:n("body").hasClass("single")?"1":"0"};0===e.ids.length&&n.isEmptyObject(e.areas)&&0===n(".wcpbc-content:not(.refreshed)").length||(s.xhr=n.ajax({url:wc_price_based_country_ajax_geo_params.wc_ajax_url.toString().replace("%%endpoint%%","wcpbc_get_location"),data:e,type:"POST",cache:!1,headers:{"Cache-Control":"no-cache, max-age=0"},success:function(e){s.refresh_product_price(e.products),s.refresh_areas(e.areas),s.refresh_currency_settings(e.currency_params),n(document.body).trigger("wc_price_based_country_after_ajax_geolocation",[e.zone_id])},error:function(e,r){"abort"!==r&&(n(".wcpbc-price").css("visibility",""),n(".wcpbc-price").css("display",""),n(".wcpbc-price").removeClass("loading"))},complete:function(){s.xhr=!1}}))},infinite_scroll:function(){if(!n("body").hasClass("single")){const e=document.body,r={childList:!0,subtree:!0},a=new MutationObserver(function(){n(".wcpbc-price.loading").length&&(a.disconnect(),n(document.body).triggerHandler("wc_price_based_country_ajax_geolocation"))});n(document.body).on("wc_price_based_country_after_ajax_geolocation",function(){a.observe(e,r)})}},init:function(){n(document.body).on("wc_price_based_country_ajax_geolocation",s.geolocate_customer),this.compatibility.bind(),this.infinite_scroll(),this.geolocate_customer()}}).init()}(jQuery);