import{i as M,f as d,m as W,u,t as A,a as U,b as Z,c as q}from"./index.TVdSjJ03.js";import{h as z,p as H,i as B}from"./ProductCardWrapper.BP9Srrqz.js";import{V as g}from"./Variation.s44fb9oC.js";import{r as $,f as G,h as Y,i as X,j as K,e as D,c as x,g as j}from"./GlobalDispatchAndDateCountdownWidget.astro_astro_type_script_index_0_lang.BMMQOUyj.js";import"./BannerCallouts.astro_astro_type_script_index_0_lang.BqzaIR3c.js";import"./hoisted.Bu3BPyzk.js";import"./hoisted.CnGWLtae.js";import{i as Q,f as J}from"./Tabs.astro_astro_type_script_index_0_lang.CDcEUK8k.js";import"./hoisted.CF4wbrlJ.js";import"./hoisted.BjNckpo4.js";import"./basketPage.DOPbNynT.js";window.sharedFunctions={fetchFragment:d,isInViewport:M};function tt(o,i){o.addEventListener("mousemove",t=>{const e=o.getBoundingClientRect(),s=t.clientX-e.left,n=t.clientY-e.top;let a=s/e.width*100,l=n/e.height*80;a=a<5?5:a,l=l<5?5:l,i.style.transformOrigin=`${a}% ${l}%`,i.style.transform="translate(-50%, -50%) scale(3)"})}function et(){class o extends HTMLElement{carouselWrapper;thumbnailWrapper;productImages;thumbnailImages;thumbnailFigures;videoWrapper;intersectionObserver;nextButton;prevButton;sku;productTitle;zoomImageGallery;touchStartHandler;lastPosX;lastPosY;containerEdges;minPosY;minPosX;maxPosY;maxPosX;touchMoveHandler;touchEndHandler;isZoomedIn;indicatorWrapper;galleryBullets;enableNutritionPDP;isRTL;static get observedAttributes(){return["data-refresh-product-gallery"]}constructor(){super(),this.render()}render(){this.isZoomedIn=!1,this.carouselWrapper=this.querySelector("#gallery-carousel"),this.thumbnailWrapper=this.querySelector("#thumbnail-container"),this.nextButton=this.querySelector("#product-image-next"),this.prevButton=this.querySelector("#product-image-prev"),this.zoomImageGallery=this.querySelector("#zoom-image-gallery"),this.videoWrapper=this.querySelector("#gallery-video-wrapper"),this.indicatorWrapper=this.querySelector("#indicator-wrapper"),this.isRTL=document?.dir==="rtl",this.productTitle=window.__CURRENTVARIANT__?.title;const t=window.__DEFAULTIMAGES__;this.sku=window.__CURRENTVARIANT__?.sku;const e=window.__PRODUCTVIDEO__,s=this.carouselWrapper.dataset.isZoomModal;this.enableNutritionPDP=window.enableNutritionPDP,this.enableNutritionPDP||(this.initResponsiveImageZoomTouchDrag=this.initResponsiveImageZoomTouchDrag.bind(this)),this.bindResponsiveImageZoomEventListeners=this.bindResponsiveImageZoomEventListeners.bind(this),this.videoWrapper&&e&&d("/fragments/videoFragment",this.videoWrapper,{video:e,autoplay:!0});const n=d("/fragments/productGalleryFragment",this.carouselWrapper,{productTitle:this.productTitle,images:t||[],sku:this.sku,hydrate:t?.length>1,imgClass:s?`snap-center w-full scroll-smooth h-full ${this.enableNutritionPDP&&"gallery-image"}`:"",enableNutritionPDP:this.enableNutritionPDP},!0),a=d("/fragments/productThumbnailFragment",this.thumbnailWrapper,{productTitle:this.productTitle,images:t||[],hydrate:!0,customClass:"product-thumbnail",video:e,enableNutritionPDP:this.enableNutritionPDP},!0);Promise.all([n,a]).then(()=>{this.observe(),this.productImages=[...this.querySelectorAll(".carouselImages")],this.thumbnailImages=[...this.querySelectorAll(".product-thumbnail")],this.thumbnailImages.forEach((r,c)=>{r.addEventListener("click",this.imageHandler.bind(this));const h=`Open image ${c+1}`;r.setAttribute("aria-label",h)});for(const r of this.productImages)this.intersectionObserver.observe(r),r.setAttribute("role","presentation"),r.setAttribute("aria-hidden","true");this.mutationObserver();const l=()=>{let r=this.querySelector(".gallery-bullet");this.indicatorWrapper.innerHTML="",this.productImages.forEach((c,h)=>{let k=r?r.cloneNode(!0):document.createElement("div");r||k?.classList.add("gallery-bullet","w-8","h-1","rounded-full","bg-primary","mr-2"),k.dataset.index=h,this.indicatorWrapper.appendChild(k)})};this.indicatorWrapper&&l()}).catch(l=>{console.error(l)}),this.prevButton&&this.prevButton.addEventListener("click",this.scrollImages.bind(this)),this.nextButton&&this.nextButton.addEventListener("click",this.scrollImages.bind(this))}scrollImages(t){t.target.id.includes("next")?(this.carouselWrapper.scrollLeft+=this.productImages[0].clientWidth*1,window.Tracker.handlers.productImageNav({title:this.productTitle,id:this.sku,action:"next"})):(this.carouselWrapper.scrollLeft-=this.productImages[0].clientWidth*1,window.Tracker.handlers.productImageNav({title:this.productTitle,id:this.sku,action:"previous"}))}observe(){this.intersectionObserver&&this.intersectionObserver.disconnect(),this.productImages=[...this.querySelectorAll(".carouselImages")],this.thumbnailImages=[...this.querySelectorAll(".product-thumbnail")],this.thumbnailFigures=[...this.querySelectorAll(".thumbnail-image")],this.thumbnailFigures.forEach(t=>{t.setAttribute("role","presentation"),t.setAttribute("aria-hidden","true")}),this.intersectionObserver=new IntersectionObserver(t=>{t.forEach(e=>{const{target:s}=e,n=this.productImages.findIndex(a=>a.isSameNode(s));if(n==0?this.isRTL?e.intersectionRatio>.99?this.nextButton&&this.nextButton?.classList.add("hidden"):this.nextButton&&this.nextButton?.classList.remove("hidden"):e.intersectionRatio>.99?this.prevButton&&this.prevButton?.classList.add("hidden"):this.prevButton&&this.prevButton?.classList.remove("hidden"):n==this.productImages.length-1&&(this.isRTL?e.intersectionRatio>.99?this.prevButton&&this.prevButton?.classList.add("hidden"):this.prevButton&&this.prevButton?.classList.remove("hidden"):e.intersectionRatio>.99?this.nextButton&&this.nextButton?.classList.add("hidden"):this.nextButton&&this.nextButton?.classList.remove("hidden")),this.galleryBullets=[...this.querySelectorAll(".gallery-bullet")],e.isIntersecting){const a=this.productImages.findIndex(c=>c.isSameNode(s)),l=this.productImages[a].querySelector("img")?.src||"";this.updateResponsiveZoomImage(l),this.resetResponsiveZoom(),this.removeResponsiveImageZoomTouchDrag(this);const r=this.videoWrapper?.childNodes?.[0];this.videoWrapper=document.querySelector("#gallery-video-wrapper"),window.Tracker.store.set("imageIndex",{index:a,id:this.sku,title:this.productTitle}),this.thumbnailImages.forEach((c,h)=>{h!==a?(c?.classList.remove("border-gray-500"),c?.classList.add("border-transparent")):(c?.classList.remove("border-transparent"),c?.classList.add("border-gray-500"))}),r instanceof HTMLVideoElement&&(s.getAttribute("id")==="videoPlayer"?s.readyState>=3&&s.hasAttribute("autoplay")&&s.play():r.pause()),this.galleryBullets[n]?.classList.remove("bg-base-200"),this.galleryBullets[n]?.classList.add("bg-primary")}else this.galleryBullets[n]?.classList.remove("bg-primary"),this.galleryBullets[n]?.classList.add("bg-base-200")})},{root:this.carouselWrapper,rootMargin:"100% 0px 100% 0px",threshold:.99});for(const t of this.productImages)this.intersectionObserver.observe(t)}mutationObserver(){new MutationObserver(function(e){e.forEach(function(s){if(s.type==="childList"){for(const n of this.productImages)this.intersectionObserver.unobserve(n);this.thumbnailImages.forEach(n=>{n.removeEventListener("click",this.imageHandler)}),this.observe()}}.bind(this))}.bind(this)).observe(this.carouselWrapper,{childList:!0})}imageHandler(t){const e=this.thumbnailImages.findIndex(s=>s.isSameNode(t.target));window.Tracker.handlers.productThumbnailClicked({index:e,id:this.sku,title:this.productTitle}),this.scrollThumbnailImage(e)}scrollThumbnailImage(t){const e=this.productImages[0].clientWidth*t;this.carouselWrapper.focus(),this.carouselWrapper.scrollTo({top:0,left:this.isRTL?-e:e,behavior:"smooth"}),this.observe()}updateResponsiveZoomImage(t){const e=this.querySelector("#zoom-container-gallery"),s=e.querySelector("#zoom-image-gallery")?.src;e&&(e.style.opacity="0",e.style.visibility="hidden"),!(s&&s===t)&&d("/fragments/imageZoomResponsiveFragment",e,{image:t})}connectedCallback(){this.initImageZoomResponsive(this)}disconnectedCallback(){this.removeEventListener("click",this.bindResponsiveImageZoomEventListeners)}attributeChangedCallback(t,e,s){e!==null&&t=="data-refresh-product-gallery"&&s!==e&&this.render()}resetResponsiveZoom(){this.lastPosX=0,this.lastPosY=0,this.isZoomedIn=!1}initImageZoomResponsive(){this.resetResponsiveZoom();const t=this.querySelector("#zoom-container-gallery");this.containerEdges=t.getBoundingClientRect(),this.minPosY=-this.containerEdges.height,this.minPosX=-this.containerEdges.width,this.maxPosY=this.containerEdges.height,this.maxPosX=this.containerEdges.width,this.addEventListener("click",e=>{e.target?.classList.contains("gallery-action")||this.bindResponsiveImageZoomEventListeners()})}bindResponsiveImageZoomEventListeners(){const t=this.querySelector("#zoom-container-gallery");this.isZoomedIn?(t.style.opacity="0",t.style.visibility="hidden",this.isZoomedIn=!1,!this.enableNutritionPDP&&this.removeResponsiveImageZoomTouchDrag(this),this.removeResponsiveImageZoomMouseDrag(this)):(t.style.opacity="1",t.style.visibility="visible",!this.enableNutritionPDP&&this.initResponsiveImageZoomTouchDrag(this),this.initResponsiveImageZoomMouseDrag(this),this.isZoomedIn=!0)}initResponsiveImageZoomMouseDrag(t){const e=document.getElementById("zoom-image-gallery"),s=this.querySelector("#zoom-container-gallery"),n=t.getBoundingClientRect();this.mouseMoveHandler=a=>{const l=a.clientX-n.left,r=a.clientY-n.top;let c=l/n.width*130,h=r/n.height*130;this.lastPosX=this.minMaxValue(c,5,100),this.lastPosY=this.minMaxValue(h,5,100),e?.style&&(e.style.transformOrigin=`${this.lastPosX}% ${this.lastPosY}%`,e.style.transform="translate3d(-50%, -50%) scale(2)")},s?.addEventListener("mousemove",this.mouseMoveHandler),e&&e.addEventListener("dragstart",a=>{a.preventDefault()})}initResponsiveImageZoomTouchDrag(t){const e=document.getElementById("zoom-image-gallery"),s=this.querySelector("#zoom-container-gallery");let n=!1,a,l;e?.style&&(e.style.transform="scale(3)"),this.touchStartHandler=r=>{n=!0;const c=r.touches[0];a=c.clientX-this.lastPosX,l=c.clientY-this.lastPosY,e.style.transition="none"},this.touchMoveHandler=r=>{if(!n)return;r.preventDefault();const c=r.touches[0];this.lastPosX=c.clientX-a,this.lastPosY=c.clientY-l,this.lastPosX=this.minMaxValue(this.lastPosX,this.minPosX,this.maxPosX),this.lastPosY=this.minMaxValue(this.lastPosY,this.minPosY,this.maxPosY),e.style.transform=`translate3d(${this.lastPosX}px, ${this.lastPosY}px, 0) scale(3)`,e.style.webkitTransform=`translate3d(${this.lastPosX}px, ${this.lastPosY}px, 0) scale(3)`},this.touchEndHandler=()=>{n&&(n=!1)},s?.addEventListener("touchstart",this.touchStartHandler,!0),s?.addEventListener("touchmove",this.touchMoveHandler,!0),s?.addEventListener("touchend",this.touchEndHandler,!0),e&&e.addEventListener("dragstart",r=>{r.preventDefault()})}minMaxValue(t,e,s){return Math.min(Math.max(t,e),s)}removeResponsiveImageZoomMouseDrag(t){t.removeEventListener("mousemove",this.mouseMoveHandler)}removeResponsiveImageZoomTouchDrag(t){t.removeEventListener("touchstart",this.touchStartHandler),t.removeEventListener("touchmove",this.touchMoveHandler),t.removeEventListener("touchend",this.touchEndHandler)}}!customElements.get("product-gallery")&&customElements.define("product-gallery",o)}window?.tenantConfig?.features?.enableHoverProductItem?z():H();window.sharedFunctions.initImageZoom=tt;window.sharedFunctions.modalToggleVisibility=W;window.sharedFunctions.useFetchApi=u;window.sharedFunctions.recaptchaResponse=$;window.sharedFunctions.setRecaptchaResponse=G;window.sharedFunctions.reCaptchaTriggered=Y;window.sharedFunctions.setRecaptchaId=X;window.sharedFunctions.recaptchaIds=K;window.sharedFunctions.triggerModal=A;window.sharedFunctions.triggerDrawer=U;window.sharedFunctions.initQuantitySelector=B;window.sharedFunctions.Variation=g;const{lang:S}=window;class it extends HTMLElement{loaded;constructor(){super(),this.loaded=!1,this.loadReviews=this.loadReviews.bind(this),new IntersectionObserver(this.loadReviews,{rootMargin:"0px",threshold:.1}).observe(this)}async loadReviews(i){const t=window.__CURRENTVARIANT__?.sku||window.__MASTERSKU__;var s=window.__EXPERIMENTMAP__?.reviews_sort_experiment=="v1|newToOld"?"NEWEST_TO_OLDEST":window?.tenantConfig?.features?.reviews?.sort;i.forEach(async n=>{if(n.isIntersecting&&!this.loaded){this.loaded=!0;const a=await u({operation:"ProductReviews",variables:{sku:t,sort:s}});d("/fragments/pdpReviews",this,{reviews:a?.data?.product?.reviews,image:a?.data?.product?.images?.[0]?.original,alt:a?.data?.product?.title,title:a?.data?.product?.title,sku:window.__MASTERSKU__,isLoggedIn:D.get()}).then(()=>{this?.classList.add("opacity-100")})}})}}customElements.define("reviews-wrapper",it);class st extends HTMLElement{stickyAtbPrice;wishlistBtn;productZoomButton;atbBtn;initialSubContract;selectedVariant;pdpVariationId;isClothingProduct;pdpPremiumVariationId;constructor(){super(),this.atbBtn=this.querySelector("#add-to-basket"),this.productZoomButton=this.querySelector("#product-image-zoom"),this.wishlistBtn=this.querySelector("#wishlist"),this.stickyAtbPrice=document.getElementById(`pdp-sticky-${window.__CURRENTVARIANT__?.sku}`),this.selectedVariant=window.__CURRENTVARIANT__,et(),this.updateSubscriptionContract(),this.updateMacroNutrientsInfo(),this.pdpVariationId=`pdp-allvariants-${window.__MASTERSKU__}`,this.pdpPremiumVariationId=`pdp-premium-${window.__MASTERSKU__}`;const i=window.__CURRENTVARIANT__?.sku;this.fetchPDPpageProductVariants().then(()=>{{const t={defaultVariation:window.__CURRENTVARIANT__,options:window.__OPTIONS__,variants:window.__VARIANTS__,linkedOn:window.__LINKEDON__},e=new g(this.pdpVariationId,{config:{payload:t,layout:{button:["Size","Amount","Colour","Shade","Option"]},activeVariant:i}});this.subscribeToVariationUpdateEvents(e)}}),this.productZoomButton&&this.productZoomButton.addEventListener("click",async()=>{const t=window.__CURRENTVARIANT__;A("/fragments/imageZoomModalContentFragment",{images:window.__DEFAULTIMAGES__,title:t?.title,sku:t?.sku,enableNutritionPDP:window.enableNutritionPDP})})}async fetchPDPpageProductVariants(){try{const i=await u({operation:"ProductVariants",variables:{sku:window.__MASTERSKU__,currency:window.siteObj?.currency||"",shippingDestination:window.siteObj?.country||"",buyNowPayLater:window.tenantConfig?.features?.buyNowPayLater||!1,enableWishlist:window.tenantConfig?.features?.enableWishlist||!1,hasSubscriptions:window.tenantConfig?.features?.hasSubscriptions||!1}});i?.data?.product?.variants&&(window.__PREMIUMVARIANTS__=(i?.data?.product?.variants||[]).filter(t=>t?.content?.some(e=>e?.key==="nutri_premiumFlavour"&&e?.value?.stringValue==="Y")),window.__VARIANTS__=i.data.product.variants)}catch(i){console.error("Error fetching product variants:",i)}}async handlePDPvariationUpdate(i){const t=new URL(location);t.searchParams.set("variation",i?.sku),history.replaceState(null,null,t),this.selectedVariant=window.__VARIANTS__?.find(e=>e?.sku===i?.sku),window.__CURRENTVARIANT__=this.selectedVariant,this.isClothingProduct=this.selectedVariant?.choices?.some(e=>e.optionKey==="Size"||e.optionKey==="Colour"),!this.isClothingProduct&&this.dispatchEvent(new CustomEvent("nutritionProductVariationChange",{bubbles:!0,detail:{wrapperToReplace:"product-description-wrapper",variantContent:window.__CURRENTVARIANT__?.content||[],mainProductContent:window.__PARENT_SKU_CONTENT__,image:window.__CURRENTVARIANT__?.images?.length>0?window.__CURRENTVARIANT__?.images?.[0]?.original:window.__CURRENTVARIANT__?.product?.images?.[0]?.original}})),this.atbBtn.dataset.sku=i?.sku,this.atbBtn.dataset.stock=i?.stock,this.wishlistBtn.dataset.sku=i?.sku,window.tenantConfig?.features?.pdpStickyAtb&&this.updateSticky(i),this.updateSubscriptionContract(),this.updateSubs(),this.updateImages(),this.updateTitlePrices(),this.updateMacroNutrientsInfo()}updateSubscriptionContract(){this.initialSubContract=window.__CURRENTVARIANT__?.subscriptionContracts?.find(i=>i?.recommended)?.id,this.atbBtn.dataset.subscriptionId=this.initialSubContract}updateSubs(){const i=document.getElementById("subscribe-tab");i?.classList.contains("active")&&d(`/fragments/subscriptionVariationFragment/${window.location.search}`,document.getElementById("tab-content-wrapper"),{currentVariant:this.selectedVariant}),i&&(i.dataset.fragment=`/fragments/subscriptionVariationFragment/${window.location.search}`)}updateTitlePrices(){const i=document.getElementById("product-title"),t=document.getElementById("product-price"),e=document.getElementById("product-price-secondary");i.innerText=this.selectedVariant?.title.includes(" - ")?this.selectedVariant?.title.split(" - ")[0]:this.selectedVariant?.title,d("/fragments/productPriceFragment",t,{currentVariant:this.selectedVariant,showModals:!0,hideBNPL:!1,enableNutritionPDP:window.enableNutritionPDP}),e&&d("/fragments/productPriceFragment",e,{currentVariant:this.selectedVariant,showModals:!0,enableNutritionPDP:window.enableNutritionPDP,hideBNPL:!1})}updateImages(){const i=window.__DEFAULTIMAGES__!==void 0&&window.__DEFAULTIMAGES__?.[0]?.original===this.selectedVariant?.images?.[0]?.original;this.selectedVariant?.images?.length>0||this.selectedVariant?.product?.images?.length>0?window.__DEFAULTIMAGES__=this.selectedVariant?.images?.length>0?this.selectedVariant?.images:this.selectedVariant?.product?.images:window.__DEFAULT_VARIANT__?.images.length>0&&(window.__DEFAULTIMAGES__=window.__DEFAULT_VARIANT__?.images),i||d("/fragments/productGalleryUpdate",document.querySelector("#pdp-gallery-container"),{images:window.__DEFAULTIMAGES__,title:this.selectedVariant?.title,sku:this.selectedVariant?.sku,video:window.__PRODUCTVIDEO__,enableNutritionPDP:window.enableNutritionPDP})}updateSticky(i){const t=document.getElementById("pdp-sticky-atb"),e=document.getElementById("pdp-sticky-atb-btn");if(t){const s=document.getElementById("pdp-sticky-atb-text");i?.stock?(e.removeAttribute("disabled"),s.innerText=window.altitude.i18n(()=>S.altitude.addtobasket.button.available.text)):(e.disabled=!0,s.innerText=window.altitude.i18n(()=>S.altitude.addtobasket.button.unavailable.text)),d("/fragments/productPriceFragment",this.stickyAtbPrice,{currentVariant:this.selectedVariant,hideBNPL:!0,hidePricePerServing:!0,hidePricePerKg:!0,enableNutritionPDP:window.enableNutritionPDP})}}subscribeToVariationUpdateEvents(i){i.subscribe("variation_updated",this.handlePDPvariationUpdate.bind(this)),i.subscribe("linked_variation_updated",this.handlePDPvariationUpdate.bind(this))}updateMacroNutrientsInfo(){const i=document.getElementById("macro-information-wrapper");if(i&&window?.enableNutritionPDP){const t=Z(this.selectedVariant?.content),e=this.selectedVariant?.content?.find(s=>s?.key==="showMacros")?.value?.stringListValue?.[0]==="FALSE";d("/fragments/macroInfoFragment",i,{macroContent:t,hideMacros:e}).then(()=>q(t))}}async handleVariationTabChange({detail:i}){const t=parseInt(i.tabIndex),e={defaultVariation:window.__CURRENTVARIANT__,options:window.__OPTIONS__,variants:window.__VARIANTS__,linkedOn:window.__LINKEDON__},s={defaultVariation:window.__PREMIUMVARIANTS__[0],options:window.__OPTIONS__,variants:window.__PREMIUMVARIANTS__,linkedOn:window.__LINKEDON__};if(t===0){const n=new g(this.pdpVariationId,{config:{payload:e,layout:{button:["Size","Amount","Colour","Shade","Option"]},activeVariant:window.__DEFAULT_VARIANT__.sku}});this.subscribeToVariationUpdateEvents(n),this.handlePDPvariationUpdate({sku:window.__DEFAULT_VARIANT__.sku,stock:!0})}else if(t===1&&window.__PREMIUMVARIANTS__?.length>0){const n=new g(this.pdpPremiumVariationId,{config:{payload:s,layout:{button:["Size","Amount","Colour","Shade","Option"]},activeVariant:window.__PREMIUMVARIANTS__[0]?.sku}});this.subscribeToVariationUpdateEvents(n),this.handlePDPvariationUpdate({sku:window.__PREMIUMVARIANTS__[0].sku,stock:!0})}}connectedCallback(){this.addEventListener("variation-tab-change",this.handleVariationTabChange)}}customElements.define("product-details-wrapper",st);x();B();const R=document.querySelector("#product-reviews"),E=document.querySelector("[aria-controls=product-description-reviews]"),nt=document.getElementById("reviews-wrapper"),ot=document.getElementById("reviews");R&&R.addEventListener("click",()=>{E&&E.ariaExpanded==="false"&&E.click(),nt.scrollIntoView({behavior:"smooth"}),document.activeElement.blur(),ot.focus()});const w=document.getElementById("size-guide-button"),m=document.getElementById("size-guide"),v=async()=>{try{const o=parseInt(w?.dataset.sku),i=await u({operation:"ProductSizeGuide",variables:{sku:o}});i?.data.product?.sizeGuide?.content?.[0]?.content&&(document.getElementById("accordion_sizeguide").innerHTML=at(i.data.product?.sizeGuide?.content[0].content)),w&&w.removeEventListener("click",v),m&&m.removeEventListener("click",v)}catch(o){console.error("Failed to fetch product data:",o)}};function at(o){return new DOMParser().parseFromString(o,"text/html").documentElement.innerHTML}var _=!1;w&&w.addEventListener("click",()=>{_||(v(),m.click(),m.setAttribute("aria-expanded",!0),_=!0),m.scrollIntoView({behavior:"smooth",block:"center"})});m&&m.addEventListener("click",()=>{_=!_,v()});const rt=document.getElementById("add-to-bag-info-message"),dt=document.getElementById("product-details")?.dataset?.hasSubscription,ct=document.getElementById("add-to-basket")?.dataset?.sku,{lang:lt}=window;dt&&await u({operation:"ProductPageBasket",variables:{id:j(),currency:window.siteObj.currency,shippingDestination:window.siteObj.country,hasSubscriptions:window.tenantConfig?.features?.hasSubscriptions}}).then(o=>{const i=o?.data?.basket?.items;if(i&&(window.__BASKETITEMS__=i),i?.some(t=>t.subscriptionContract?.id&&t.id?.includes(ct))){const t={type:"info",message:window.altitude.i18n(()=>lt.altitude.subscriptions.alert.info1)};d("/fragments/alertFragment",rt,{fragmentData:t})}});Q(!0);const ut=(o=[])=>o.reduce((i,t)=>parseFloat(i)+parseFloat(t));class ht extends HTMLElement{mainContainerFBT;addBothToBasketAnchor;basketPriceElement;recommendedProduct_;wrapperContainer;productTitle;priceContainer;productImageContainer;isMainProductSection;constructor(){super(),this.isMainProductSection=this.dataset.wrapperId==="main-product-wrapper",this.recommendedProduct_=this.isMainProductSection?window.__FBT_SELECTED_MAIN_PRODUCT:window.__FBT_RECOMMENDATION_PRODUCT__,this.wrapperContainer=document.querySelector(`#${this.dataset.wrapperId}`),this.mainContainerFBT=document.querySelector("#frequently-bought-together"),this.addBothToBasketAnchor=document.querySelector("#fbt-atb-anchor"),this.basketPriceElement=document.querySelector("#basket-price"),this.productTitle=this.wrapperContainer.querySelector(".fbt-product-title"),this.priceContainer=this.wrapperContainer.querySelector(".fbt-price-container"),this.productImageContainer=this.wrapperContainer.querySelector(".fbt-picture-wrapper"),this.initIntersectionObserver()}initIntersectionObserver(){const i={root:null,rootMargin:"0px",threshold:.1},t=(s,n)=>{s.forEach(a=>{a.isIntersecting&&(this.initVariationObserver(),n.unobserve(a.target))})};new IntersectionObserver(t,i).observe(this.mainContainerFBT)}async initVariationObserver(){const i=this.getAttribute("data-id");if(this.getAttribute("data-mode")==="async"){const e=await u({operation:"FBT",variables:{currency:window.siteObj.currency,shippingDestination:window.siteObj.country,sku:this.recommendedProduct_?.sku}});if(!e)return;const s=new g(i,{config:{payload:e.data?.product,layout:{button:["Size","Amount","Colour","Shade","Option"]},activeVariant:this.recommendedProduct_?.defaultVariant?.sku}});this.recommendedProduct_=e.data?.product,this.subscribeToEvents(s)}}subscribeToEvents(i){i.subscribe("variation_updated",this.handleVariationUpdate.bind(this)),i.subscribe("linked_variation_updated",this.handleVariationUpdate.bind(this))}handleVariationUpdate(i){const t=this.recommendedProduct_?.variants?.find(n=>n.sku===Number(i.sku)),e={mainSku:this.addBothToBasketAnchor?.dataset?.mainProductSku,recommendedSku:this.addBothToBasketAnchor?.dataset?.recommendedProductSku};this.dataset.wrapperId==="main-product-wrapper"?(e.mainSku=i?.sku,this.basketPriceElement.setAttribute("data-selected-product-amount",t?.price?.price?.amount),this.addBothToBasketAnchor.setAttribute("data-main-product-sku",i?.sku),this.addBothToBasketAnchor.setAttribute("data-main-product-in-stock",t?.inStock)):(e.recommendedSku=i.sku,this.basketPriceElement.setAttribute("data-recommended-product-amount",t?.price?.price?.amount),this.addBothToBasketAnchor.setAttribute("data-recommended-product-sku",i.sku),this.addBothToBasketAnchor.setAttribute("data-recommended-product-in-stock",t?.inStock)),t?.inStock||(this.addBothToBasketAnchor&&(this.addBothToBasketAnchor.setAttribute("disabled",!0),this.addBothToBasketAnchor.setAttribute("aria-disabled",!0),this.addBothToBasketAnchor.setAttribute("tabindex","-1")),this.addBothToBasketAnchor?.classList.add("pointer-events-none")),this.addBothToBasketAnchor.hasAttribute("disabled")&&this.addBothToBasketAnchor.getAttribute("data-main-product-in-stock")==="true"&&this.addBothToBasketAnchor.getAttribute("data-recommended-product-in-stock")==="true"&&(this.addBothToBasketAnchor.removeAttribute("disabled"),this.addBothToBasketAnchor.removeAttribute("aria-disabled"),this.addBothToBasketAnchor.removeAttribute("tabindex"),this.addBothToBasketAnchor?.classList.remove("pointer-events-none")),this.addBothToBasketAnchor.setAttribute("data-skus",JSON.stringify([e.mainSku,e.recommendedSku])),this.addBothToBasketAnchor.setAttribute("href",`/basket?buylist=${e.mainSku},${e.recommendedSku}&rctxt=fbt`),d("/fragments/productPriceFragment",this.priceContainer,{currentVariant:t,hideBNPL:!0}),d("/fragments/fbtProductVariantImageFragment",this.productImageContainer,{src:t?.images.length?t?.images[0]?.original:t?.product?.images[0]?.original,alt:t?.title}),this.productTitle.textContent=t?.title;const s=J(ut([this.basketPriceElement.dataset.selectedProductAmount||0,this.basketPriceElement.dataset.recommendedProductAmount||0]),window.__PRICE_LOCALE__,window.__CURRENCY_LOCALE__);this.basketPriceElement.textContent=`${s}`}}customElements.get("frequently-bought-together")||customElements.define("frequently-bought-together",ht);class mt extends HTMLElement{constructor(){super();const i=this.dataset.skuList.split(",");let t=!1;const e=()=>{!t&&M(this,750)&&(d("/fragments/ProductComparisonFragment",this,{skuList:i,enableNutritionPDP:window.enableNutritionPDP}),t=!0)};e();const s=()=>{e(),t&&window.removeEventListener("scroll",s)};window.addEventListener("scroll",s)}}customElements.define("product-comparison-widget",mt);x();B();const L=document.getElementById("product-reviews"),P=document.querySelector("[aria-controls=product-description-reviews]"),pt=document.getElementById("reviews-wrapper"),gt=document.getElementById("reviews");L&&L.addEventListener("click",()=>{P&&P.ariaExpanded==="false"&&P.click(),pt.scrollIntoView({behavior:"smooth"}),document.activeElement.blur(),gt.focus()});const b=document.getElementById("size-guide-button"),p=document.getElementById("Size-Guide"),f=async()=>{try{const o=parseInt(b?.dataset.sku),i=await u({operation:"ProductSizeGuide",variables:{sku:o}});i?.data.product?.sizeGuide?.content?.[0]?.content&&(document.getElementById("accordion_sizeguide").innerHTML=wt(i.data.product?.sizeGuide?.content[0].content)),b&&b.removeEventListener("click",f),p&&p.removeEventListener("click",f)}catch(o){console.error("Failed to fetch product data:",o)}};function wt(o){return new DOMParser().parseFromString(o,"text/html").documentElement.innerHTML}var I=!1;b&&b.addEventListener("click",()=>{I||(f(),p.click(),p.setAttribute("aria-expanded",!0),I=!0),p.scrollIntoView({behavior:"smooth",block:"center"})});p&&p.addEventListener("click",()=>{I=!I,f()});document.getElementById("add-to-basket")?.dataset?.sku;class bt extends HTMLElement{wishlistButton;icon;currentVariant;loggedIn;sku;wishListNode;constructor(){super(),this.wishlistButton=this.querySelector("#wishlist"),this.icon=this.wishlistButton?.firstElementChild,this.wishListNode=this.wishlistButton,this.currentVariant=null,this.loggedIn=!1,this.sku=this.wishlistButton?.dataset.sku,D.subscribe(async i=>{this.loggedIn=i,this.loggedIn&&await this.fetchData()}),this.handleWishlist=this.handleWishlist.bind(this)}connectedCallback(){this?.addEventListener("click",this.handleWishlist),new MutationObserver(t=>{t.forEach(e=>{if(e.type==="attributes"&&e.attributeName=="data-sku")this.currentVariant&&(this.sku=e?.target?.dataset?.sku,this.updateWishlist(this.currentVariant));else return})}).observe(this.wishListNode,{attributes:!0})}disconnectedCallback(){this?.removeEventListener("click",this.handleWishlist)}showWishlistModal(i,t,e,s){A("/fragments/wishlistModalContentFragment",{sku:i,url:t,title:e,image:s})}async fetchData(){const i=await u({operation:"ProductVariantWishlist",variables:{sku:Number(this.sku),currency:window.siteObj.currency,shippingDestination:window.siteObj.country,loyaltyEnabled:window?.tenantConfig?.features?.loyalty?.enabled||!1,enableWishlist:window?.tenantConfig?.features?.wishlist?.enabled}});this.currentVariant=i.data.productVariant,this.currentVariant.inWishlist?(this.wishlistButton.dataset.wishlist="true",this.icon?.classList.add("wishlist"),this.wishlistButton?.classList.add("border-black")):(this.wishlistButton.dataset.wishlist="false",this.icon?.classList.remove("wishlist"),this.wishlistButton?.classList.remove("border-black"))}async handleWishlist(i){const t=i.target.dataset.wishlist==="true";if(!this.loggedIn){window.Tracker.handlers.wishlistLoggedout(this.sku),this.showWishlistModal(this.sku,this.dataset.url,this.dataset.title,window.__DEFAULTIMAGES__[0].original);return}if(t){const e=await u({operation:"RemoveProductFromWishlist",variables:{sku:this.sku}});window.Tracker.handlers.wishlistRemove(this.sku),e.data.removeProductFromWishlist&&await this.fetchData()}else{const e=await u({operation:"AddProductToWishlist",variables:{sku:this.sku}});window.Tracker.handlers.wishlistAdded(this.sku),e.data.addProductToWishlist&&await this.fetchData()}}updateWishlist(i){if(this.wishlistButton.dataset.wishlist=i?.inWishlist?"true":"false",!i?.eligibleForWishlist)this.wishlistButton?.classList.add("hidden");else if(this.wishlistButton?.classList.remove("hidden"),i?.inWishlist)if(!this.icon?.classList.contains("wishlist"))this.icon?.classList.add("wishlist"),this.wishlistButton?.classList.add("border-black");else return;else this.icon?.classList.contains("wishlist")&&(this.icon?.classList.remove("wishlist"),this.wishlistButton?.classList.remove("border-black"))}}customElements.define("product-wishlist",bt);const V=document.getElementById("subscribe-tab"),F=document.getElementById("add-to-basket"),C=document.getElementById("sticky-atb-btn"),[vt,_t]=document.querySelectorAll(".carousel-tab"),y=document.getElementById("add-to-bag-info-message"),T=F?.dataset?.sku,ft=document.getElementById("product-price"),N=document.getElementById(`sticky-${window.__DEFAULTSKU__}`),{lang:O}=window;vt?.addEventListener("click",()=>{const o=window.__BASKETITEMS__;new URLSearchParams(window.location.search).get("variation"),y.innerHTML="";const t=window.__CURRENTVARIANT__;if(d("/fragments/productPriceFragment",ft,{currentVariant:t,showModals:!0}),window.tenantConfig?.features?.pdpStickyAtb&&N&&d("/fragments/productPriceFragment",N,{currentVariant:t,hideBNPL:!0}),o?.some(e=>e.subscriptionContract?.id&&e.id?.includes(T))){const e={type:"info",message:window.altitude.i18n(()=>O.altitude.subscriptions.alert.info1)};d("/fragments/alertFragment",y,{fragmentData:e})}});_t?.addEventListener("click",()=>{const o=window.__BASKETITEMS__;if(y.innerHTML="",F.dataset.subscriptionId=V?.dataset?.contractId,C&&(C.dataset.subscriptionId=V?.dataset?.contractId),o?.some(i=>i.id===T)){const i={type:"info",message:window.altitude.i18n(()=>O.altitude.subscriptions.alert.info2)};d("/fragments/alertFragment",y,{fragmentData:i})}});
