PageSourceSearch

https://www.japanesegreenteain.com/cdn/shop/t/82/assets/product.js?v=80585877363377718061790585020

js japanesegreenteain.com collected 2026-10-03 19:46:51 UTC 15,697 bytes, 2 lines download raw bytes

1if(!customElements.get("variant-selects")){class VariantSelects extends HTMLElement{constructor(){super(),this.sticky=this.dataset.sticky,this.updateUrl=this.dataset.updateUrl==="true",this.isDisabledFeature=this.dataset.isDisabled,this.addEventListener("change",this.onVariantChange),this.other=Array.from(document.querySelectorAll("variant-selects")).filter(selector=>selector!=this),this.productWrapper=this.closest(".thb-product-detail")}connectedCallback(){this.updateOptions(),this.updateMasterId(),this.setDisabled()}onVariantChange(){this.updateOptions(),this.updateMasterId(),this.toggleAddButton(!0,"",!1),this.updatePickupAvailability(),this.removeErrorMessage(),this.updateVariantText(),this.setDisabled(),this.currentVariant?(this.updateUrl&&this.updateURL(),this.updateVariantInput(),this.renderProductInfo()):(this.toggleAddButton(!0,"",!0),this.setUnavailable()),this.updateOther(),dispatchCustomEvent("product:variant-change",{variant:this.currentVariant,sectionId:this.dataset.section})}updateOptions(){this.fieldsets=Array.from(this.querySelectorAll("fieldset")),this.options=[],this.option_keys=[],this.fieldsets.forEach((fieldset,i)=>{fieldset.querySelector("select")?(this.options.push(fieldset.querySelector("select").value),this.option_keys.push(fieldset.querySelector("select").name)):fieldset.querySelectorAll("input").length&&(this.options.push(fieldset.querySelector("input:checked").value),this.option_keys.push(fieldset.querySelector("input").name))})}updateVariantText(){Array.from(this.querySelectorAll("fieldset")).forEach((item,i)=>{let label=item.querySelector(".form__label__value");label&&(label.innerHTML=this.options[i])})}updateMasterId(){this.currentVariant=this.getVariantData().find(variant=>!variant.options.map((option,index)=>this.options[index]===option).includes(!1))}updateOther(){if(this.dataset.updateUrl!=="false"&&this.other.length){let fieldsets=this.other[0].querySelectorAll("fieldset"),fieldsets_array=Array.from(fieldsets);this.options.forEach((option,i)=>{fieldsets_array[i].querySelector("select")?fieldsets_array[i].querySelector("select").value=option:fieldsets_array[i].querySelectorAll("input").length&&(fieldsets_array[i].querySelector(`input[value="${option}"]`).checked=!0)}),this.other[0].updateOptions(),this.other[0].updateMasterId(),this.other[0].updateVariantText(),this.other[0].setDisabled()}}updateMedia(){this.currentVariant&&window.ProductGallery&&window.ProductGallery.init(document)}updateURL(){!this.currentVariant||this.dataset.updateUrl==="false"||window.history.replaceState({},"",`${this.dataset.url}?variant=${this.currentVariant.id}`)}updateShareUrl(){const shareButton=document.getElementById(`Share-${this.dataset.section}`);shareButton&&shareButton.updateUrl(`${window.shopUrl}${this.dataset.url}?variant=${this.currentVariant.id}`)}updateVariantInput(){document.querySelectorAll(`#product-form-${this.dataset.section}, #product-form-installment`).forEach(productForm=>{const input=productForm.querySelector('input[name="id"]');input.value=this.currentVariant.id,input.dispatchEvent(new Event("change",{bubbles:!0}))})}updatePickupAvailability(){const pickUpAvailability=document.querySelector(".pickup-availability-wrapper");pickUpAvailability&&(this.currentVariant&&this.currentVariant.available?pickUpAvailability.fetchAvailability(this.currentVariant.id):(pickUpAvailability.removeAttribute("available"),pickUpAvailability.innerHTML=""))}removeErrorMessage(){const section=this.closest("section");if(!section)return;const productForm=section.querySelector("product-form");productForm&&productForm.handleErrorMessage()}getSectionsToRender(){const galleryInstance=this.dataset.galleryInstance||this.dataset.section;return[`price-${this.dataset.section}`,`price-${this.dataset.section}--sticky`,`product-image-${this.dataset.section}--sticky`,`inventory-${this.dataset.section}`,`sku-${this.dataset.section}`,`quantity-${this.dataset.section}`,`product-${galleryInstance}-mobile-gallery`,`product-${galleryInstance}-desktop-gallery`]}renderProductInfo(){let sections=this.getSectionsToRender();fetch(`${this.dataset.url}?variant=${this.currentVariant.id}&section_id=${this.dataset.section}`).then(response=>response.text()).then(responseText=>{const html=new DOMParser().parseFromString(responseText,"text/html");sections.forEach(id=>{const destination=document.getElementById(id),source=html.getElementById(id);source&&destination&&(window.ProductGallery&&window.ProductGallery.destroy(destination),destination.innerHTML=source.innerHTML);const price=document.getElementById(id),price_fixed=document.getElementById(id+"--sticky");price&&price.classList.remove("visibility-hidden"),price_fixed&&price_fixed.classList.remove("visibility-hidden")}),this.toggleAddButton(!this.currentVariant.available,window.theme.variantStrings.soldOut),this.updateMedia()})}toggleAddButton(disable=!0,text=!1,modifyClass=!0){if(!document.getElementById(`product-form-${this.dataset.section}`))return;const submitButtons=document.querySelectorAll(".single-add-to-cart-button");submitButtons&&submitButtons.forEach(submitButton=>{const submitButtonText=submitButton.querySelector(".single-add-to-cart-button--text");submitButtonText&&(disable?(submitButton.setAttribute("disabled","disabled"),text&&(submitButtonText.textContent=text)):(submitButton.removeAttribute("disabled"),submitButton.classList.remove("loading"),submitButtonText.textContent=window.theme.variantStrings.addToCart))})}setUnavailable(){const submitButtons=document.querySelectorAll(".single-add-to-cart-button"),price=document.getElementById(`price-${this.dataset.section}`),price_fixed=document.getElementById(`price-${this.dataset.section}--sticky`);submitButtons.forEach(submitButton=>{const submitButtonText=submitButton.querySelector(".single-add-to-cart-button--text");submitButton&&(submitButtonText.textContent=window.theme.variantStrings.unavailable,submitButton.classList.add("sold-out"))}),price&&price.classList.add("visibility-hidden"),price_fixed&&price_fixed.classList.add("visibility-hidden")}setDisabled(){if(this.isDisabledFeature!="true")return;const variant_data=this.getVariantData();if(variant_data.length){const selected_options=(this.currentVariant?this.currentVariant.options:this.options).map((value,index)=>({value,index:`option${index+1}`})),available_options=this.createAvailableOptionsTree(variant_data,selected_options);
1this.fieldsets.forEach((fieldset,i)=>{const fieldset_options=Object.values(available_options)[i];fieldset_options&&(fieldset.querySelector("select")?fieldset_options.forEach((option,option_i)=>{option.isUnavailable?fieldset.querySelector("option[value="+JSON.stringify(option.value)+"]").disabled=!0:fieldset.querySelector("option[value="+JSON.stringify(option.value)+"]").disabled=!1}):fieldset.querySelectorAll("input").length&&fieldset.querySelectorAll("input").forEach((input,input_i)=>{input.classList.toggle("is-disabled",fieldset_options[input_i].isUnavailable)}))})}return!0}createAvailableOptionsTree(variant_data,selected_options){return variant_data.reduce((options,variant)=>(Object.keys(options).forEach(index=>{if(variant[index]===null)return;let entry=options[index].find(option=>option.value===variant[index]);typeof entry>"u"&&(entry={value:variant[index],isUnavailable:!0},options[index].push(entry)),selected_options.reduce((count,{value,index:index2})=>variant[index2]===value?count+1:count,0)>=selected_options.length-1&&(entry.isUnavailable=entry.isUnavailable&&variant.available?!1:entry.isUnavailable),(!this.currentVariant||!this.currentVariant.available)&&selected_options.find(option=>option.value===entry.value&&index===option.index)&&(entry.isUnavailable=!0),index==="option1"&&(entry.isUnavailable=entry.isUnavailable&&variant.available?!1:entry.isUnavailable)}),options),{option1:[],option2:[],option3:[]})}getVariantData(){if(this.variantData)return this.variantData;const dataSource=this.dataset.variantsId?document.getElementById(this.dataset.variantsId):null;return dataSource?(this.variantData=JSON.parse(dataSource.textContent),this.variantData):(this.variantDataMissingReported||(console.error(`Variant data #${this.dataset.variantsId||"(no data-variants-id)"} is missing`,this),this.variantDataMissingReported=!0),[])}}customElements.define("variant-selects",VariantSelects);class VariantRadios extends VariantSelects{constructor(){super()}updateOptions(){const fieldsets=Array.from(this.querySelectorAll("fieldset"));this.options=fieldsets.map(fieldset=>Array.from(fieldset.querySelectorAll("input")).find(radio=>radio.checked).value)}}customElements.define("variant-radios",VariantRadios)}if(customElements.get("product-form")||customElements.define("product-form",class extends HTMLElement{constructor(){super(),this.sticky=this.dataset.sticky,this.form=document.getElementById(`product-form-${this.dataset.section}`),this.form.querySelector("[name=id]").disabled=!1,this.sticky||this.form.addEventListener("submit",this.onSubmitHandler.bind(this)),this.cartNotification=document.querySelector("cart-notification"),this.body=document.body,this.hideErrors=this.dataset.hideErrors==="true"}onSubmitHandler(evt){if(evt.preventDefault(),!this.form.reportValidity())return;const submitButtons=document.querySelectorAll(".single-add-to-cart-button");submitButtons.forEach(submitButton=>{submitButton.classList.contains("loading")||(submitButton.setAttribute("aria-disabled",!0),submitButton.classList.add("loading"))}),this.handleErrorMessage();const config={method:"POST",headers:{"X-Requested-With":"XMLHttpRequest",Accept:"application/javascript"}};let formData=new FormData(this.form);formData.append("sections",this.getSectionsToRender().map(section=>section.section)),formData.append("sections_url",window.location.pathname),config.body=formData,fetch(`${theme.routes.cart_add_url}`,config).then(response=>response.json()).then(response=>{if(response.status){dispatchCustomEvent("product:variant-error",{source:"product-form",productVariantId:formData.get("id"),errors:response.description,message:response.message}),this.handleErrorMessage(response.description);return}this.renderContents(response),dispatchCustomEvent("cart:item-added",{product:response.hasOwnProperty("items")?response.items[0]:response})}).catch(e=>{console.error(e)}).finally(()=>{submitButtons.forEach(submitButton=>{submitButton.classList.remove("loading"),submitButton.removeAttribute("aria-disabled")})})}getSectionsToRender(){return[{id:"Cart",section:"main-cart",selector:".thb-cart-form"},{id:"Cart-Drawer",section:"cart-drawer",selector:".cart-drawer"},{id:"cart-drawer-toggle",section:"cart-bubble",selector:".thb-item-count"}]}
1renderContents(parsedState){this.getSectionsToRender().forEach(section=>{if(!document.getElementById(section.id))return;const elementToReplace=document.getElementById(section.id).querySelector(section.selector)||document.getElementById(section.id);elementToReplace.innerHTML=this.getSectionInnerHTML(parsedState.sections[section.section],section.selector),typeof CartDrawer<"u"&&new CartDrawer,typeof Cart<"u"&&new Cart().renderContents(parsedState)});let product_drawer=document.getElementById("Product-Drawer");product_drawer&&product_drawer.contains(this)?(product_drawer.querySelector(".product-quick-images--container").classList.remove("active"),document.body.classList.remove("open-quick-view"),window.innerWidth<1069?(product_drawer.classList.remove("active"),document.getElementById("Cart-Drawer")&&(document.getElementById("Cart-Drawer").classList.add("active"),document.body.classList.add("open-cart"),document.getElementById("Cart-Drawer").querySelector(".product-recommendations--full").classList.add("active"),dispatchCustomEvent("cart-drawer:open"))):product_drawer.querySelector(".product-quick-images--container").addEventListener("transitionend",function(){product_drawer.classList.remove("active"),document.getElementById("Cart-Drawer")&&(document.getElementById("Cart-Drawer").classList.add("active"),document.body.classList.add("open-cart"),document.getElementById("Cart-Drawer").querySelector(".product-recommendations--full").classList.add("active"),dispatchCustomEvent("cart-drawer:open"))}),document.getElementById("Cart-Drawer")||document.body.classList.remove("open-cc")):document.getElementById("Cart-Drawer")&&(document.body.classList.add("open-cc"),document.body.classList.add("open-cart"),document.getElementById("Cart-Drawer").classList.add("active"),dispatchCustomEvent("cart-drawer:open"))}getSectionInnerHTML(html,selector=".shopify-section"){return new DOMParser().parseFromString(html,"text/html").querySelector(selector).innerHTML}handleErrorMessage(errorMessage=!1){this.hideErrors||(this.errorMessageWrapper=this.errorMessageWrapper||this.querySelector(".product-form__error-message-wrapper"),this.errorMessage=this.errorMessage||this.errorMessageWrapper.querySelector(".product-form__error-message"),this.errorMessageWrapper.toggleAttribute("hidden",!errorMessage),errorMessage&&(this.errorMessage.textContent=errorMessage))}}),!customElements.get("product-add-to-cart-sticky")){class ProductAddToCartSticky extends HTMLElement{constructor(){super(),this.animations_enabled=document.body.classList.contains("animations-true")&&typeof gsap<"u"}connectedCallback(){this.setupObservers(),this.setupToggle()}setupToggle(){const button=this.querySelector(".product-add-to-cart-sticky--inner"),content=this.querySelector(".product-add-to-cart-sticky--content");if(this.animations_enabled){const tl=gsap.timeline({reversed:!0,paused:!0,onStart:()=>{button.classList.add("sticky-open")},onReverseComplete:()=>{button.classList.remove("sticky-open")}});tl.set(content,{display:"block",height:"auto"},"start").from(content,{height:0,duration:.25},"start+=0.001"),button.addEventListener("click",function(){return tl.reversed()?tl.play():tl.reverse(),!1})}else button.addEventListener("click",function(){return content.classList.toggle("active"),!1})}setupObservers(){let _this=this,observer=new IntersectionObserver(function(entries){entries.forEach(entry=>{if(entry.target===footer&&(entry.intersectionRatio>0?_this.classList.remove("sticky--visible"):entry.intersectionRatio==0&&_this.formPassed&&_this.classList.add("sticky--visible")),entry.target===form){let boundingRect=form.getBoundingClientRect();entry.intersectionRatio===0&&window.scrollY>boundingRect.top+boundingRect.height?(_this.formPassed=!0,_this.classList.add("sticky--visible")):entry.intersectionRatio===1&&(_this.formPassed=!1,_this.classList.remove("sticky--visible"))}})},{threshold:[0,1]}),form=document.getElementById(`product-form-${this.dataset.section}`),footer=document.getElementById("footer");_this.formPassed=!1,observer.observe(form),observer.observe(footer)}}customElements.define("product-add-to-cart-sticky",ProductAddToCartSticky)}if(!customElements.get("side-panel-links")){class ProductSidePanelLinks extends HTMLElement{constructor(){super(),this.links=this.querySelectorAll("button"),this.drawer=document.getElementById("Product-Information-Drawer"),this.buttons=this.drawer.querySelector(".side-panel-content--tabs"),this.panels=this.drawer.querySelector(".side-panel-content--inner").querySelectorAll(".side-panel-content--tab-panel"),this.body=document.body}connectedCallback(){this.setupObservers()}disconnectedCallback(){}setupObservers(){this.links.forEach((item,i)=>{item.addEventListener("click",e=>{this.body.classList.add("open-cc"),this.buttons.toggleActiveClass(i),this.drawer.classList.add("active")})})}}customElements.define("side-panel-links",ProductSidePanelLinks)}typeof addIdToRecentlyViewed<"u"&&addIdToRecentlyViewed();
2//# sourceMappingURL=/cdn/shop/t/82/assets/product.js.map?v=80585877363377718061790585020

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.