1(()=>{if(document.querySelector("#productVariantsInfo")){let lowInventoryMsg4=function(stockMsg){if(document.querySelector("#lowStockMsg1"))document.querySelector("#lowStockMsg1").innerHTML=stockMsg;else{const lowStockMsgDiv=document.createElement("div");lowStockMsgDiv.id="lowStockMsg1",lowStockMsgDiv.classList.add("lowStockMsg"),lowStockMsgDiv.textContent=stockMsg,document.querySelector("product-info variant-radios").appendChild(lowStockMsgDiv)}if(document.querySelector("#lowStockMsg2"))document.querySelector("#lowStockMsg2").innerHTML=stockMsg;else{const lowStockMsgDiv=document.createElement("div");lowStockMsgDiv.id="lowStockMsg2",lowStockMsgDiv.classList.add("lowStockMsg"),lowStockMsgDiv.textContent=stockMsg,document.querySelector(".product-form__buttons-aside").appendChild(lowStockMsgDiv)}},displayInventoryMessages2=function(prods,threshold2){prods.forEach(function(prod){document.querySelectorAll('.product-form__input-inner input[type="radio"]').forEach(optn=>{optn.classList.remove("highlightRed")}),prod.inventory_quantity<threshold2&&prod.inventory_quantity>1?(lowInventoryMsg4(lowInventoryMsg1),document.querySelectorAll('.product-form__input-inner input[type="radio"]:checked').forEach(optn=>{optn.classList.add("highlightRed")})):prod.inventory_quantity==1?(lowInventoryMsg4(lowInventoryMsg2),document.querySelectorAll('.product-form__input-inner input[type="radio"]:checked').forEach(optn=>{optn.classList.add("highlightRed")})):prod.inventory_quantity==0?(lowInventoryMsg4(""),document.querySelectorAll('.product-form__input-inner input[type="radio"]').forEach(optn=>{optn.classList.remove("highlightRed")})):(lowInventoryMsg4(""),document.querySelectorAll('.product-form__input-inner input[type="radio"]').forEach(optn=>{optn.classList.remove("highlightRed")}))})},handleInputChange2=function(){let inputElement=document.querySelector('input[type="hidden"][name="id"]'),inputValue=parseInt(inputElement.value,10),variantInfo2=document.querySelector("script#productVariantsInfo").textContent,prod=JSON.parse(variantInfo2).find(function(item){return item.id==inputValue});prod&&displayInventoryMessages2([prod],threshold)};var lowInventoryMsg=lowInventoryMsg4,displayInventoryMessages=displayInventoryMessages2,handleInputChange=handleInputChange2;let variantInfo=document.querySelector("script#productVariantsInfo").textContent,jsonInfo=JSON.parse(variantInfo),threshold=10;document.querySelector("#thresholdQty")&&(threshold=document.querySelector("#thresholdQty").dataset.threshold);let lowInventoryMsg1="Low inventory: Only a few left! ",lowInventoryMsg2="Low inventory: Last one! ",lowInventoryMsg3="Low inventory: refilling soon! ";document.querySelector("#low_inv_msg1")&&document.querySelector("#low_inv_msg1").dataset.msg.trim()!==""&&(lowInventoryMsg1=document.querySelector("#low_inv_msg1").dataset.msg),document.querySelector("#low_inv_msg2")&&document.querySelector("#low_inv_msg2").dataset.msg.trim()!==""&&(lowInventoryMsg2=document.querySelector("#low_inv_msg2").dataset.msg),document.querySelector("#low_inv_msg3")&&document.querySelector("#low_inv_msg3").dataset.msg.trim()!==""&&(lowInventoryMsg3=document.querySelector("#low_inv_msg3").dataset.msg),document.querySelector('input[name="id"]').addEventListener("change",handleInputChange2),handleInputChange2()}document.addEventListener("click",event=>{const colorLinks=event.target.closest("color-links");if(colorLinks!=null&&event.target.classList.contains("js-product-swatch")){event.preventDefault();const swatchLink=event.target;let linkURL=swatchLink.dataset.href;window.location.href.includes("collections/")&&(linkURL=`/collections/${window.location.href.split("collections/")[1].split("/")[0]}/products`+linkURL.split("/products")[1]);const shopURL=swatchLink.dataset.shop,sectionId=swatchLink.closest("color-links").dataset.sectionId,productTitle=swatchLink.dataset.title,url=`${shopURL}${linkURL}`,variantSectionUrl=`${linkURL}/?section_id=${sectionId}`;fetch(variantSectionUrl).then(response=>response.text()).then(responseText=>{document.dispatchEvent(new CustomEvent("pdp:swatch:change",{detail:{handle:event.target.dataset.handle}})),history.pushState({},productTitle,url);const new_html=new DOMParser().parseFromString(responseText,"text/html").querySelector(".product").innerHTML,new_upsellElement=new DOMParser().parseFromString(responseText,"text/html").querySelector(".upsell");if(new_upsellElement){const new_upsell=new_upsellElement.innerHTML,upsell_element=document.querySelector(".upsell");upsell_element&&(upsell_element.innerHTML=new_upsell)}document.querySelector(".product").innerHTML=new_html,document.querySelector(".product color-links").innerHTML=colorLinks.innerHTML,completeTheLookUpsell();const allNewLinks=document.querySelectorAll(".product color-links li"),currentID=swatchLink.closest("li").querySelector("img").dataset.id;document.querySelectorAll('.product color-links li input[type="radio"]').forEach(input=>{input.removeAttribute("checked"),input.checked=!1}
1),allNewLinks.forEach(newLink=>{newLink.querySelector("img").dataset.id===currentID&&(newLink.querySelector("input").checked=!0,newLink.querySelector("input").setAttribute("checked",""))});let new_jsonInfo=new DOMParser().parseFromString(responseText,"text/html")?.querySelector("#productVariantsInfo")?.innerHTML;if(new_jsonInfo){let new_jsonInfoParsed=JSON.parse(new_jsonInfo);document.querySelector("#productVariantsInfo").innerHTML=new_jsonInfo,document.querySelector("#productVariantsInfo")&&(document.querySelector('input[name="id"]').addEventListener("change",handleInputChange),handleInputChange())}})}})})(); 2//# sourceMappingURL=/cdn/shop/t/1106/assets/product-swatches.js.map?v=69743946426709718881790351889
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.