https://drinkghia.com/cdn/shop/t/243/assets/web-components-product.js?v=4329127280255472061786976037
1class RelatedProductsSelector extends HTMLElement{connectedCallback(){this.setupListeners()}setupListeners(){const label=this.querySelector(".active-label"),flavors=this.querySelectorAll("[data-flavor]");label.innerHTML=this.dataset.selected,flavors.forEach(flavor=>{flavor.addEventListener("click",()=>{label.innerHTML=flavor.dataset.flavor,this.dataset.selected=flavor.dataset.flavor}),flavor.addEventListener("mouseover",()=>{label.innerHTML=flavor.dataset.flavor}),this.addEventListener("mouseout",()=>{label.innerHTML=this.dataset.selected})})}}customElements.define("related-products-selector",RelatedProductsSelector);class ProductFixedBar extends HTMLElement{constructor(){super(),this.handleScroll=this.handleScroll.bind(this),this.offset=0,this.bar=null}connectedCallback(){this.bar=this.querySelector(".product-fixed-bar"),this.bar&&(this.bar.classList.add("translate-y-full"),this.offset=this.bar.getBoundingClientRect().top+window.scrollY,window.addEventListener("scroll",this.handleScroll))}disconnectedCallback(){window.removeEventListener("scroll",this.handleScroll)}handleScroll(){(window.scrollY||window.pageYOffset)>this.offset+800?this.bar.classList.contains("active")||(this.bar.classList.add("active"),this.bar.classList.remove("hidden"),setTimeout(()=>{this.bar.classList.add("anim")},100)):this.bar.classList.contains("active")&&(this.bar.classList.remove("anim"),setTimeout(()=>{this.bar.classList.remove("active"),this.bar.classList.add("hidden")},100))}}customElements.define("product-fixed-bar",ProductFixedBar);class ProductDetailsController extends HTMLElement{connectedCallback(){this.productHandle=this.dataset.productHandle,this.sectionId=this.dataset.sectionId,this.subscriptionPurchaseCheked=!1,this.addVariantChangeEvents(),this.addSubscribeChangeEvents()}async updateProductDetailsHTML(){const url=new URL(window.location),variantParam=url.searchParams.get("variant")?`variant=${url.searchParams.get("variant")}`:"",sellingPlanParam=url.searchParams.get("selling_plan")?`&selling_plan=${url.searchParams.get("selling_plan")}`:"",focusEl=document.activeElement,rawPathWithParams=`/products/${this.productHandle}?sections=${this.sectionId}&${variantParam}${sellingPlanParam}`;try{const rawResponse=await fetch(rawPathWithParams);if(!rawResponse.ok){window.ghiaReport&&window.ghiaReport("pdp_error",{error_message:"section render failed",error_stage:"fetch",http_status:rawResponse.status,product_handle:this.productHandle});return}const mainProductSubscriptionEl=(await rawResponse.json())[this.sectionId],element=this.htmlToElement(mainProductSubscriptionEl),replacement=element&&element.querySelector("product-details-controller");if(!replacement){window.ghiaReport&&window.ghiaReport("pdp_error",{error_message:"section markup missing controller",error_stage:"parse",product_handle:this.productHandle});return}if(this.innerHTML=replacement.innerHTML,this.addSubscribeChangeEvents(),this.addVariantChangeEvents(),this.explicitOneTime&&this.restoreOneTimeSelection(),focusEl&&focusEl.id){const restored=document.getElementById(focusEl.id);restored&&restored.focus()}}catch(e){window.ghiaReport&&window.ghiaReport("pdp_error",{error_message:e&&e.message?e.message:String(e),error_stage:"exception",product_handle:this.productHandle})}}addVariantChangeEvents(){const variantsSelectorEl=this.querySelectorAll("[name='variant-selector']");!variantsSelectorEl.length>0||variantsSelectorEl.forEach(option=>{option.addEventListener("change",()=>{const url=new URL(window.location),droppedPlan=url.searchParams.get("selling_plan");url.searchParams.set("variant",option.value),url.searchParams.delete("selling_plan"),droppedPlan&&window.ghiaReport&&window.ghiaReport("subscription_reset",{error_message:"selling plan cleared by variant change",product_handle:this.productHandle,variant_id:option.value,selling_plan:droppedPlan}),window.history.replaceState({},"",url),this.updateProductDetailsHTML()})})}addSubscribeChangeEvents(){const purchaseOptions=this.querySelectorAll("[name='purchase-options']"),sellingPlanSelectorEl=this.querySelector("#selling-plan-selector");!purchaseOptions||!sellingPlanSelectorEl||(purchaseOptions.forEach(option=>{option.addEventListener("change",()=>{const url=new URL(window.location);option.id=="subscribe-purchase"?(this.explicitOneTime=!1,this.sellingPlanSelector()):(this.subscriptionPurchaseCheked=!1,this.explicitOneTime=!0,url.searchParams.delete("selling_plan"),window.history.replaceState({},"",url),this.updateProductDetailsHTML(this.productHandle))})}),sellingPlanSelectorEl.addEventListener("change",()=>{this.sellingPlanSelector()}
1))}restoreOneTimeSelection(){const oneTime=this.querySelector("#one-time-purchase"),subscribe=this.querySelector("#subscribe-purchase");if(!oneTime||oneTime.checked)return;oneTime.checked=!0,subscribe&&(subscribe.checked=!1),this.querySelectorAll('[name="selling_plan"]').forEach(input=>{input.value=""});const oneTimePrice=this.querySelector("#sub-box-one-time-price"),fullPrice=this.querySelector("#atc-full-price"),struckPrice=this.querySelector("#atc-discount-price");oneTimePrice&&fullPrice&&(fullPrice.textContent=oneTimePrice.textContent.trim()),struckPrice&&(struckPrice.textContent="")}sellingPlanSelector(){const url=new URL(window.location),sellingPlanSelectorEl=this.querySelector("#selling-plan-selector");sellingPlanSelectorEl&&(url.searchParams.set("selling_plan",sellingPlanSelectorEl.value),window.history.replaceState({},"",url),this.updateProductDetailsHTML(this.productHandle))}htmlToElement(html){var template=document.createElement("template");return html=html.trim(),template.innerHTML=html,template.content.firstChild}}customElements.define("product-details-controller",ProductDetailsController); 2//# sourceMappingURL=/cdn/shop/t/243/assets/web-components-product.js.map?v=4329127280255472061786976037
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.