import{b as o}from"./basketPage.DOPbNynT.js";import{V as h}from"./Variation.s44fb9oC.js";import{u as n}from"./index.TVdSjJ03.js";import"./BannerCallouts.astro_astro_type_script_index_0_lang.BqzaIR3c.js";import"./hoisted.Cb2DzZ9C.js";import"./hoisted.Bu3BPyzk.js";import{f as t}from"./Tabs.astro_astro_type_script_index_0_lang.CDcEUK8k.js";import"./hoisted.CnGWLtae.js";import"./hoisted.CF4wbrlJ.js";import"./hoisted.BjNckpo4.js";import"./GlobalDispatchAndDateCountdownWidget.astro_astro_type_script_index_0_lang.BMMQOUyj.js";import"./SelectYourSample.astro_astro_type_script_index_0_lang.CBlow97T.js";import"./ProductCardWrapper.BP9Srrqz.js";o();window.sharedFunctions||(window.sharedFunctions={});window.sharedFunctions.Variation=h;window.sharedFunctions.useFetchApi=n;const{lang:e}=window;class a extends HTMLElement{successIcon;textElement;tierOneThreshold;tierTwoThreshold;amountSpentSoFar;progressValue;progressMax;thresholdAmountDisplay;message;isPassingTierOneThreshold;startPriceIndicator;deliveryThresholdContainer;currentTierText;progressBarElement=this.querySelector("#basket-progress");static get observedAttributes(){return["data-amountspentsofar"]}constructor(){super(),this.deliveryThresholdContainer=this.querySelector(".delivery-threshold-value"),this.successIcon=this.querySelector(".success-icon"),this.textElement=this.querySelector("#message-text"),this.startPriceIndicator=this.querySelector("#progress-start-text"),this.currentTierText=this.querySelector("#current-tier-text"),this.progressBarElement=this.querySelector("#basket-progress"),this.tierOneThreshold=parseFloat(this.getAttribute("data-tieronethreshold")),this.tierTwoThreshold=parseFloat(this.getAttribute("data-tiertwothreshold")),this.amountSpentSoFar=parseFloat(this.getAttribute("data-amountspentsofar"))||0,this.progressValue=0,this.successIcon?.classList.remove("hidden"),this.amountSpentSoFar===0&&this.updateUiNoItemsInBasket(),this.progressMax=this.amountSpentSoFar<this.tierOneThreshold?this.tierOneThreshold:this.tierTwoThreshold}attributeChangedCallback(s,i,r){s==="data-amountspentsofar"&&(this.isPassingTierOneThreshold=i<this.tierOneThreshold&&r>=this.tierOneThreshold,this.handleAmountSpentChange())}handleTierOneThreshold(){this.message=window.altitude.i18n(()=>e.altitude.basket.progressbar.tieronethreshold.unlocked.text),this.progressMax=this.tierOneThreshold,this.progressValue=this.tierOneThreshold,this.thresholdAmountDisplay="",this.startPriceIndicator.textContent="",this.showIcon(),this.shiftText(),this.updateProgressBarUI(),this.deliveryThresholdContainer?.classList.add("hidden"),this.tierTwoThreshold&&setTimeout(()=>{if(this.progressMax=this.tierTwoThreshold,this.progressValue=this.amountSpentSoFar,this.hideIcon(),this.resetText(),this.deliveryThresholdContainer?.classList.remove("hidden"),this.amountSpentSoFar<this.tierTwoThreshold){const s=this.tierTwoThreshold-this.amountSpentSoFar,i=t(s,window.__PRICE_LOCALE__,window.__CURRENCY_LOCALE__);this.startPriceIndicator.textContent=t(this.amountSpentSoFar,window.__PRICE_LOCALE__,window.__CURRENCY_LOCALE__),this.message=window.altitude.i18n(()=>e.altitude.basket.progressbar.tiertwothreshold.locked.text,i),this.thresholdAmountDisplay=t(this.tierTwoThreshold,window.__PRICE_LOCALE__,window.__CURRENCY_LOCALE__)}else this.progressValue=this.tierTwoThreshold,this.message=window.altitude.i18n(()=>e.altitude.basket.progressbar.tiertwothreshold.unlocked.text),this.thresholdAmountDisplay="",this.startPriceIndicator.textContent="",this.deliveryThresholdContainer?.classList.add("hidden"),this.showIcon(),this.shiftText();this.updateProgressBarUI()},2e3)}handleTierTwoThreshold(){this.progressMax=this.tierTwoThreshold,this.progressValue=this.tierTwoThreshold,this.message=window.altitude.i18n(()=>e.altitude.basket.progressbar.tiertwothreshold.unlocked.text),this.thresholdAmountDisplay="",this.startPriceIndicator.textContent="",this.showIcon(),this.shiftText(),this.updateProgressBarUI(),this.deliveryThresholdContainer?.classList.add("hidden")}handleTierTwoProgress(){this.progressMax=this.tierTwoThreshold,this.progressValue=this.amountSpentSoFar,this.deliveryThresholdContainer?.classList.remove("hidden");const s=this.tierTwoThreshold-this.amountSpentSoFar,i=t(s,window.__PRICE_LOCALE__,window.__CURRENCY_LOCALE__);this.message=window.altitude.i18n(()=>e.altitude.basket.progressbar.tiertwothreshold.locked.text,i),this.thresholdAmountDisplay=t(this.tierTwoThreshold,window.__PRICE_LOCALE__,window.__CURRENCY_LOCALE__),this.startPriceIndicator.textContent=t(this.amountSpentSoFar,window.__PRICE_LOCALE__,window.__CURRENCY_LOCALE__),this.hideIcon(),this.resetText(),this.updateProgressBarUI()}handleTierOneProgress(){this.progressMax=this.tierOneThreshold,this.progressValue=this.amountSpentSoFar;const s=this.tierOneThreshold-this.amountSpentSoFar,i=t(s,window.__PRICE_LOCALE__,window.__CURRENCY_LOCALE__);this.message=window.altitude.i18n(()=>e.altitude.basket.progressbar.tieronethreshold.locked.text,i),this.thresholdAmountDisplay=t(this.tierOneThreshold,window.__PRICE_LOCALE__,window.__CURRENCY_LOCALE__),this.startPriceIndicator.textContent=t(this.amountSpentSoFar,window.__PRICE_LOCALE__,window.__CURRENCY_LOCALE__),this.hideIcon(),this.resetText(),this.updateProgressBarUI()}handleAmountSpentChange(){this.amountSpentSoFar=parseFloat(this.getAttribute("data-amountspentsofar"))||0,this.amountSpentSoFar>=this.tierOneThreshold&&this.amountSpentSoFar<this.tierTwoThreshold?this.isPassingTierOneThreshold?this.handleTierOneThreshold():this.handleTierTwoProgress():!this.tierTwoThreshold&&this.amountSpentSoFar>=this.tierOneThreshold?this.handleTierOneThreshold():this.amountSpentSoFar>=this.tierTwoThreshold?this.handleTierTwoThreshold():this.amountSpentSoFar<this.tierOneThreshold&&this.amountSpentSoFar!==0?this.handleTierOneProgress():this.amountSpentSoFar===0&&this.updateUiNoItemsInBasket()}updateUiNoItemsInBasket(){this.message=window.altitude.i18n(()=>e.altitude.basket.progressbar.noitems.text),this.textElement.innerHTML=this.message,this.progressValue=0,this.progressMax=0,this.hideIcon(),this.resetText(),this.startPriceIndicator.textContent="",this.thresholdAmountDisplay=`${t(this.tierOneThreshold,window.__PRICE_LOCALE__,window.__CURRENCY_LOCALE__)} ${window.altitude.i18n(()=>e.altitude.basket.progressbar.noitems.threshold)}`,this.currentTierText.textContent=this.thresholdAmountDisplay,this.deliveryThresholdContainer?.classList.remove("hidden"),this.progressBarElement&&(this.progressBarElement.value=this.progressValue,this.progressBarElement.max=this.progressMax)}showIcon(){this.successIcon?.classList.remove("icon-hidden"),this.successIcon?.classList.add("icon-visible")}hideIcon(){this.successIcon?.classList.remove("icon-visible"),this.successIcon?.classList.add("icon-hidden")}shiftText(){this.textElement?.classList.remove("text-normal"),this.textElement?.classList.add("text-shifted")}resetText(){this.textElement?.classList.remove("text-shifted"),this.textElement?.classList.add("text-normal")}updateProgressBarUI(){this.progressBarElement&&(this.progressBarElement.value=this.progressValue,this.progressBarElement.max=this.progressMax),this.textElement&&(this.textElement.innerHTML=this.message),this.currentTierText&&(this.currentTierText.textContent=this.thresholdAmountDisplay||"")}}customElements.get("basket-progress-bar")||customElements.define("basket-progress-bar",a);
