1(function(){function normalize(text){return(text||"").toLowerCase().replace(/\s+/g," ").trim()}function getBcpoRoot(){return document.querySelector("#bcpo")}function unlockSoldOutColorSwatches(){const root=getBcpoRoot();if(!root)return;root.querySelectorAll(".bcpo-images .bcpo-image-parent.bcpo-disabled, .bcpo-images .bcpo-image-parent.bcpo-really-disabled").forEach(parent=>{const input=parent.querySelector("input.bcpo-front-image-option"),label=parent.querySelector("label");input&&(input.removeAttribute("disabled"),input.disabled=!1,input.setAttribute("data-jg-sold-out-clickable","true"),parent.classList.remove("bcpo-really-disabled"),parent.setAttribute("data-jg-sold-out","true"),parent.style.pointerEvents="auto",label&&(label.style.pointerEvents="auto",label.style.cursor="pointer"))})}function resetStalePreorderLabel(button){const buttonText=button.querySelector("span");!(button.classList.contains("hengam-preorder-button")||buttonText&&buttonText.textContent.trim()==="Pre-Order Now")||(button.closest("form")||document.querySelector("product-form"))?.querySelector('input[name="selling_plan"], input[name="properties[_purchase_type]"]')||(button.classList.remove("hengam-preorder-button"),button.removeAttribute("disabled"),button.removeAttribute("aria-disabled"),buttonText&&(buttonText.textContent=window.variantStrings?.addToCart||"Add to cart"))}function updateSoldOutPurchaseState(){const isSoldOutSelection=!!document.querySelector('#bcpo .bcpo-images input.bcpo-front-image-option[data-jg-sold-out-clickable="true"]:checked');document.querySelectorAll('product-form button[type="submit"][name="add"], button.product-form__submit').forEach(button=>{const buttonText=button.querySelector("span");if(isSoldOutSelection){button.setAttribute("disabled","disabled"),button.setAttribute("aria-disabled","true"),button.classList.add("is-jg-sold-out"),buttonText&&(buttonText.textContent="Sold Out");return}button.classList.contains("is-jg-sold-out")&&(button.removeAttribute("disabled"),button.removeAttribute("aria-disabled"),button.classList.remove("is-jg-sold-out"),buttonText&&(buttonText.textContent=window.variantStrings?.addToCart||"Add to cart")),resetStalePreorderLabel(button)})}function getSelectedEmbroidery(){const selected=document.querySelector('#bcpo input[name="properties[Embroidery]"]:checked');return normalize(selected?selected.value:"")}function getSelectedProductColor(){const selected=document.querySelector("#bcpo .bcpo-images input.bcpo-front-image-option:checked");if(selected&&selected.value)return normalize(selected.value);const visibleColorLabel=document.querySelector("#bcpo .bcpo-images .bcpo-label .bcpo-value");return normalize(visibleColorLabel?visibleColorLabel.textContent:"")}function getEmbroideryColorGroups(){const root=getBcpoRoot();return root?Array.from(root.querySelectorAll(".selector-wrapper.bcpo-colors")).filter(group=>{const title=group.querySelector(".bcpo-title");return normalize(title?title.textContent:"").includes("embroidery color")}):[]}function setGroupVisible(group,visible){const label=group.querySelector(".bcpo-label"),selector=group.querySelector(".single-option-selector");group.style.display=visible?"":"none",label&&(label.style.display=visible?"":"none"),selector&&(selector.style.display=visible?"":"none"),group.querySelectorAll("input, select, textarea").forEach(field=>{visible?(field.removeAttribute("disabled"),field.disabled=!1):(field.checked=!1,field.setAttribute("disabled","disabled"),field.disabled=!0)})}function updateEmbroideryColorVisibility(){const embroidery=getSelectedEmbroidery(),selectedColor=getSelectedProductColor(),shouldShowColorOptions=embroidery==="add custom embroidery";getEmbroideryColorGroups().forEach(group=>{const title=normalize(group.querySelector(".bcpo-title")?.textContent||""),matchesCurrentColor=selectedColor&&title.startsWith(selectedColor)&&title.includes("embroidery color");setGroupVisible(group,shouldShowColorOptions&&matchesCurrentColor)})}function observePreorderFormMutations(){document.querySelectorAll('product-form form[data-type="add-to-cart-form"]').forEach(form=>{if(form.dataset.jgPreorderWatched==="true")return;form.dataset.jgPreorderWatched="true",new MutationObserver(()=>{scheduleRun()}).observe(form,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]})})}function runJollyProductOptionFixes(){unlockSoldOutColorSwatches(),updateEmbroideryColorVisibility(),updateSoldOutPurchaseState(),observePreorderFormMutations()}let scheduled=!1;function scheduleRun(){scheduled||(scheduled=!0,requestAnimationFrame(()=>{runJollyProductOptionFixes(),scheduled=!1}))}document.addEventListener("DOMContentLoaded",scheduleRun),window.addEventListener("load",scheduleRun),document.addEventListener("click",
1scheduleRun),document.addEventListener("change",scheduleRun)})(); 2//# sourceMappingURL=/cdn/shop/t/1/assets/jg-product-options.js.map?v=141055664804898196511784409779
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.