jQuery(document).ready(function($){if(void 0===tieredPricingGlobalData)return;function TieredPriceTable(isTooltip=!1){this.productPageManager=null,this.dataProvider=null,this.isTooltip=isTooltip,this.init=function($wrapper){this.$wrapper=$wrapper,this.productPageManager.bindEvents(),this.isTooltip&&(jQuery.widget.bridge("uiTooltip",jQuery.ui.tooltip),this.dataProvider.isVariableProduct()||this.initTooltip())},this.$getPricingElement=function(){return this.$wrapper.find("[data-tiered-pricing-table]")},this.$getPricingElementPart=function(){return this.$wrapper.find("[data-tiered-pricing-table]").find("tbody").find("tr")},this.initTooltip=function(){this.dataProvider.isTooltipBorder()&&this.$getPricingElement().css("border","2px solid "+this.dataProvider.getActiveTierColor()),jQuery(document).uiTooltip({items:".tiered-pricing-tooltip-icon",tooltipClass:"tiered-pricing-tooltip",content:function(){return this.productPageManager.$getQuantityField().trigger("change"),this.$getPricingElement().clone()}.bind(this),hide:{effect:"fade"},position:{my:"center bottom-40",at:"center bottom",using:function(position){jQuery(this).css(position)}},close:function(e,tooltip){tooltip.tooltip.innerHTML=""}})}}function TieredPricingDropdown(){this.isExpanded=!1,this.$selectedElement=null,this.productPageManager=null,this.dataProvider=null,this.$getList=function(){return this.$wrapper.find(".tiered-pricing-dropdown__list")},this.$getSelectBox=function(){return this.$wrapper.find(".tiered-pricing-dropdown__select-box")},this.init=function($wrapper){this.$wrapper=$wrapper,this.productPageManager.bindEvents(),$(document).on("click",".tiered-pricing-dropdown__select-box",this.handleSelectBoxClick.bind(this)),$(document).on("click",this.hide.bind(this)),$(document).on("tiered_price_update",this.update.bind(this)),$(document).on("keyup",this.$wrapper,function(e){13!==e.which&&32!==e.which||this.show()}.bind(this))},this.setActiveElement=function(el){this.$selectedElement=el,this.$getList().find(".tiered-pricing-dropdown-option").removeClass("tiered-pricing-dropdown-option--selected"),this.$selectedElement.addClass("tiered-pricing-dropdown-option--selected"),this.$getSelectBox().find(".tiered-pricing-dropdown-option").html(el.html())},this.update=function(){var activeEl=this.$getPricingElementPart().filter(".tiered-pricing--active");activeEl.length&&this.setActiveElement(activeEl)},this.handleSelectBoxClick=function(e){e.stopPropagation(),this.isExpanded?this.hide():this.show()},this.show=function(){this.$getList().show(),this.$getSelectBox().addClass("tiered-pricing-dropdown__select-box--active"),this.isExpanded=!0},this.hide=function(){this.isExpanded&&(this.$getList().hide(),this.$getSelectBox().removeClass("tiered-pricing-dropdown__select-box--active"),this.isExpanded=!1)},this.$getPricingElement=function(){return this.$wrapper.find(".tiered-pricing-dropdown")},this.$getPricingElementPart=function(){return this.$wrapper.find(".tiered-pricing-dropdown__list .tiered-pricing-dropdown-option")}}function TieredPricingBlocks(){this.productPageManager=null,this.dataProvider=null,this.init=function($wrapper){this.$wrapper=$wrapper,this.productPageManager.bindEvents()},this.$getPricingElement=function(){return this.$wrapper.find(".tiered-pricing-blocks")},this.$getPricingElementPart=function(){return this.$wrapper.find(".tiered-pricing-blocks").find(".tiered-pricing-block")}}function TieredPricingOptions(){this.productPageManager=null,this.dataProvider=null,this.init=function($wrapper){this.$wrapper=$wrapper,this.productPageManager.bindEvents(),jQuery(document).on("tiered_price_update",this.updateTotals.bind(this))},this.updateTotals=function(event,data){var originalTotal=jQuery(""),data=(originalTotal.html(data.__instance.formatting.formatPrice(data.__instance.dataProvider.getPriceByTieredQuantity(!1)*data.quantity)),data.__instance.formatting.formatPrice(data.price*data.quantity));this.$getPricingElementPart().find(".tiered-pricing-option-total__original_total").html(originalTotal),this.$getPricingElementPart().find(".tiered-pricing-option-total__discounted_total").html(data)},this.$getPricingElement=function(){return this.$wrapper.find(".tiered-pricing-options")},this.$getPricingElementPart=function(){return this.$wrapper.find(".tiered-pricing-option")}}function ProductPageManager(tieredPricingInstance){this.tieredPricingInstance=tieredPricingInstance,this.bindEvents=function(){this.$getQuantityField().on("change input",function(event){this.updatePricingByQuantity(jQuery(event.target).val())}.bind(this)),this.tieredPricingInstance.dataProvider.isClickableRows()&&jQuery(document).on("click",tieredPricingInstance.$getPricingElementPart(),this.setQuantityByClick.bind(this)),this.tieredPricingInstance.dataProvider.isVariableProduct()&&(jQuery(".single_variation_wrap").on("show_variation",this.loadVariationPricing.bind(this)),jQuery(document).on("reset_data",function(){this.tieredPricingInstance.dataProvider.updatePriceSuffix(""),this.tieredPricingInstance.$wrapper.html(""),jQuery(".product").find(".tiered-pricing-dynamic-price-wrapper").first().length&&this.defaultVariableProductPrice&&this.updateProductPriceHTML(this.defaultVariableProductPrice,!0)}.bind(this)))},this.loadVariationPricing=function(event,variation){jQuery.post(document.location.origin+document.location.pathname+"?wc-ajax=get_pricing_table",{variation_id:variation.variation_id,nonce:tieredPricingGlobalData.loadVariationTieredPricingNonce},function(response){tieredPricingInstance.$wrapper.html(response),response?(this.$getQuantityField().trigger("change"),"tooltip"===this.tieredPricingInstance.dataProvider.getDisplayType()&&this.tieredPricingInstance.initTooltip()):(this.updateProductPriceHTML(variation.price_html,!0),variation.min_qty&&0this.tieredPricingInstance.dataProvider.getMinimum();let price,originalPrice,priceSuffix;return this.tieredPricingInstance.dataProvider.isShowTotalPrice()&&1")).html(suffix),0=(tieredQuantity=parseInt(tieredQuantity))){pricing.price=this.getPriceByTieredQuantity(tieredQuantity),pricing.price_excl_tax=this.getPriceByTieredQuantity(tieredQuantity,"excl_tax"),pricing.price_incl_tax=this.getPriceByTieredQuantity(tieredQuantity,"incl_tax"),pricing.priceHtml=this.getPriceByTieredQuantity(tieredQuantity,"html"),pricing.tieredQuantity=tieredQuantity,pricing.eventQuantity=quantity;break}return pricing}return!1},this.getPricingRules=function(){let rawPricingRules=JSON.parse(this.tieredPricingInstance.$getPricingElement().attr("data-price-rules"));return Object.keys(rawPricingRules).sort((a,b)=>a-b).reverse().reduce((obj,key)=>(obj[key+" "]=rawPricingRules[key],obj),{})},this.getMinimum=function(){var min=this.tieredPricingInstance.$getPricingElement().data("minimum");return min?parseInt(min):1},this.getProductName=function(){return this.tieredPricingInstance.$getPricingElement().data("product-name")},this.getPriceSuffix=function(){return"undefined"!=typeof tieredPriceTableGetProductPriceSuffix?tieredPriceTableGetProductPriceSuffix():this.tieredPricingInstance.$getPricingElement().data("product-price-suffix")},this.updatePriceSuffix=function(suffix){this.tieredPricingInstance.$getPricingElement().attr("data-product-price-suffix",suffix)},this.getProductType=function(){return this.tieredPricingInstance.$wrapper.data("product-type")},this.getPriceByTieredQuantity=function(tieredQuantity,type="regular"){tieredQuantity=tieredQuantity||this.getMinimum();var pricingElement=this.tieredPricingInstance.$getPricingElement().find('[data-tiered-quantity="'+tieredQuantity+'"]');return!(pricingElement.length<1)&&("html"===type?formatting.formatPrice(this.getPriceByTieredQuantity(tieredQuantity,"regular")):"excl_tax"===type?parseFloat(pricingElement.data("tiered-price-exclude-taxes")):"incl_tax"===type?parseFloat(pricingElement.data("tiered-price-include-taxes")):parseFloat(pricingElement.data("tiered-price")))},this.isClickableRows=function(){return this.getSettings().clickable_rows},this.isShowTotalPrice=function(){return this.getSettings().show_total_price},this.isTooltipBorder=function(){return this.getSettings().tooltip_border},this.getDisplayType=function(){return this.getSettings().display_type},this.getActiveTierColor=function(){return this.getSettings().active_tier_color},this.isUpdatePriceOnProductPage=function(){return this.getSettings().update_price_on_product_page},this.isShowTieredPriceAsDiscount=function(){return this.getSettings().show_tiered_price_as_discount},this.isProductOnSale=function(){return""!==this.tieredPricingInstance.$getPricingElement().data("sale-price")},this.getRegularPrice=function(){return parseFloat(this.tieredPricingInstance.$getPricingElement().data("regular-price"))},this.getSalePrice=function(){return parseFloat(this.tieredPricingInstance.$getPricingElement().data("sale-price"))},this.getOriginalPrice=function(){return parseFloat(this.tieredPricingInstance.$getPricingElement().data("price"))}}document.tieredPricingInstances=[];const formatting=new function(currencyOptions){this.currencyOptions=currencyOptions,this.formatNumber=function(number,decimals,dec_point,thousands_sep,trim_zeros){let i,j,kw,kd,km;return isNaN(decimals=Math.abs(decimals))&&(decimals=this.currencyOptions.decimals),void 0===dec_point&&(dec_point=this.currencyOptions.decimal_separator),void 0===thousands_sep&&(thousands_sep=this.currencyOptions.thousand_separator),void 0===trim_zeros&&(trim_zeros=this.currencyOptions.trim_zeros),i=parseInt(number=(+number||0).toFixed(decimals))+"",3<(j=i.length)?j%=3:j=0,km=j?i.substr(0,j)+thousands_sep:"",kw=i.substr(j).replace(/(\d{3})(?=\d)/g,"$1"+thousands_sep),kd=decimals?dec_point+Math.abs(number-i).toFixed(decimals).replace(/-/,0).slice(2):"",trim_zeros?(kd=kd.replace(/0+$/,""),thousands_sep=new RegExp("\\"+dec_point+"+$"),(km+kw+kd).replace(thousands_sep,"")):km+kw+kd},this.formatPrice=function(price,originalPrice="",suffix=""){price=this.formatNumber(price,this.currencyOptions.decimals,this.currencyOptions.decimal_separator,this.currencyOptions.thousand_separator,this.currencyOptions.trim_zeros);var currency=''+this.currencyOptions.currency_symbol+"",priceSuffixPart=suffix?" %3$s ":"";let template;return template=originalPrice?""+this.formatPrice(originalPrice)+' '+this.currencyOptions.price_format+priceSuffixPart+"":''+this.currencyOptions.price_format+priceSuffixPart+"",jQuery("