1(function(){"use strict";var dialog=null,content=null,state=null,documentClickBound=!1;document.addEventListener("DOMContentLoaded",init),document.addEventListener("shopify:section:load",init);function init(){var found=document.getElementById("PdpQuickAddModal");!found||found===dialog||(dialog&&dialog.remove(),dialog=found,content=dialog.querySelector("[data-qa-content]"),state=null,document.body.appendChild(dialog),dialog.addEventListener("click",onDialogClick),dialog.addEventListener("close",cleanup),dialog.addEventListener("cancel",cleanup),dialog.addEventListener("keydown",function(e){e.key==="Escape"&&(e.preventDefault(),closeDialog())}),dialog.addEventListener("wheel",blockBackdropScroll,{passive:!1}),dialog.addEventListener("touchmove",blockBackdropScroll,{passive:!1}),documentClickBound||(documentClickBound=!0,document.addEventListener("click",onDocumentClick)))}function onDocumentClick(event){var trigger=event.target.closest("[data-quick-add-trigger]");if(!(!trigger||trigger.disabled)){event.preventDefault();var source=trigger.getAttribute("data-quick-add-source")||"pdp-recommendation",directVariantId=trigger.getAttribute("data-quick-add-variant");if(directVariantId){addDirect(trigger,Number(directVariantId),source);return}openModal(trigger,source)}}function openModal(trigger,source){var cell=trigger.closest(".Carousel__Cell")||trigger.parentElement,template=cell.querySelector("template[data-quick-add-template]"),jsonEl=cell.querySelector("[data-product-item-json]");if(!(!template||!jsonEl)){var productData;try{productData=JSON.parse(jsonEl.textContent).product}catch(err){return}if(typeof dialog.showModal!="function"){var link=template.content.querySelector(".PdpQuickAdd__Title");link&&(window.location.href=link.getAttribute("href"));return}content.innerHTML="",content.appendChild(template.content.cloneNode(!0)),state={product:productData,source:source,selected:{},optionCount:productData.options.length,addButton:content.querySelector("[data-qa-add]"),addLabel:content.querySelector("[data-qa-add-label]"),errorEl:content.querySelector(".PdpQuickAdd__Error"),variant:null,busy:!1},groups().forEach(function(group){var enabled=group.querySelectorAll("[data-qa-option]:not([disabled])");enabled.length===1&&selectSwatch(enabled[0],!0)}),resolveVariant(),content.querySelectorAll("[data-qa-option][data-image-src]").forEach(function(b){new Image().src=b.getAttribute("data-image-src")});var slider=content.querySelector("[data-qa-slider]"),bar=content.querySelector("[data-qa-progress]");slider&&bar&&slider.addEventListener("scroll",function(){var max=slider.scrollWidth-slider.clientWidth;if(!(max<=0)){var count=slider.children.length;bar.style.transform="translateX("+slider.scrollLeft/max*(count-1)*100+"%)"}},{passive:!0}),dialog.showModal()}}function blockBackdropScroll(e){e.target===dialog&&e.preventDefault()}function cleanup(){state=null,content.innerHTML=""}function closeDialog(){cleanup(),dialog.open&&dialog.close()}function onDialogClick(event){if(event.target===dialog){closeDialog();return}if(event.target.closest("[data-qa-close]")){closeDialog();return}var slideNav=event.target.closest("[data-qa-slide-prev], [data-qa-slide-next]");if(slideNav){var slider=content.querySelector("[data-qa-slider]");if(slider){var dir=slideNav.hasAttribute("data-qa-slide-next")?1:-1;slider.scrollBy({left:dir*slider.clientWidth,behavior:"smooth"})}return}var swatch=event.target.closest("[data-qa-option]");if(swatch&&!swatch.disabled&&state){selectSwatch(swatch,!1),resolveVariant();return}var addButton=event.target.closest("[data-qa-add]");addButton&&state&&state.variant&&!state.busy&&addFromModal()}function groups(){return Array.prototype.slice.call(content.querySelectorAll("[data-qa-option-group]"))}function selectSwatch(swatch,silent){var group=swatch.closest("[data-qa-option-group]");group.querySelectorAll(".is-active").forEach(function(el){el.classList.remove("is-active"),el.setAttribute("aria-pressed","false")}),swatch.classList.add("is-active"),swatch.setAttribute("aria-pressed","true"),state.selected[swatch.getAttribute("data-position")]=swatch.getAttribute("data-value");var option=group.closest(".PdpQuickAdd__Option"),selectedLabel=option&&option.querySelector("[data-qa-selected]");selectedLabel&&(selectedLabel.textContent=swatch.getAttribute("data-value")),showVariantImage(swatch),silent||hideError()}function showVariantImage(swatch){var imageId=swatch.getAttribute("data-image-id");if(imageId){var slider=content.querySelector("[data-qa-slider]");if(slider){for(var slides=slider.children,target=-1,i=0;i<slides.length;i++)if(slides[i].getAttribute("data-image-id")===imageId){target=i;break}if(target===-1){var firstImg=slides[0]&&slides[0].querySelector("img"),src=swatch.getAttribute("data-image-src");if(!firstImg||!src)return;firstImg.src=src,slides[0].setAttribute("data-image-id",imageId),target=0}slider.scrollLeft=target*slider.clientWidth}}}function matchesSelection(variant,exceptPosition){for(var position in state.selected)if(Number(position)!==exceptPosition&&variant["option"+position]!==state.selected[position])return!1;return!0}function resolveVariant(){var product=state.product,chosen=Object.keys(state.selected).length;
1if(groups().forEach(function(group){var position=Number(group.getAttribute("data-option-position"));group.querySelectorAll("[data-qa-option]").forEach(function(swatch){var value=swatch.getAttribute("data-value"),purchasable=product.variants.some(function(variant2){return variant2.available&&variant2["option"+position]===value&&matchesSelection(variant2,position)});swatch.disabled=!purchasable})}),chosen<state.optionCount){state.variant=null,setAddButton(!1,"Select "+pendingOptionNames().join(" / "));return}for(var variant=null,i=0;i<product.variants.length;i++)if(matchesSelection(product.variants[i],-1)){variant=product.variants[i];break}if(!variant||!variant.available){state.variant=null,setAddButton(!1,"Out of Stock");return}state.variant=variant,showPriceFor(variant.id),setAddButton(!0,"Add to Cart")}function pendingOptionNames(){var names=[];return state.product.options.forEach(function(name,index){state.selected[String(index+1)]||names.push(name.toLowerCase())}),names.length?names:["options"]}function showPriceFor(variantId){content.querySelectorAll("[data-qa-price]").forEach(function(el){el.hidden=Number(el.getAttribute("data-variant-id"))!==variantId})}function setAddButton(enabled,label){state.addButton&&(state.addButton.disabled=!enabled,state.addLabel&&(state.addLabel.textContent=label))}function addFromModal(){var session=state,variant=session.variant,source=session.source;session.busy=!0,setAddButton(!1,"Adding..."),hideError(),postToCart(variant.id,source).then(function(result){if(result.ok){trackAdd(variant,source),closeDialog(),notifyCart(variant);return}session.busy=!1,state===session&&(setAddButton(!0,"Add to Cart"),showError(result.description))})}function addDirect(trigger,variantId,source){trigger.getAttribute("aria-disabled")!=="true"&&(trigger.setAttribute("aria-disabled","true"),trigger.classList.add("is-busy"),postToCart(variantId,source).then(function(result){trigger.removeAttribute("aria-disabled"),trigger.classList.remove("is-busy"),result.ok&&(trackAdd({id:variantId},source),notifyCart({id:variantId,quantity:1}))}))}function postToCart(variantId,source){return document.dispatchEvent(new CustomEvent("theme:loading:start")),fetch("/cart/add.js",{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify({items:[{id:variantId,quantity:1,properties:{_source:"pdp-"+source}}]})}).then(function(response){return document.dispatchEvent(new CustomEvent("theme:loading:end")),response.ok?{ok:!0}:response.json().then(function(data){return{ok:!1,description:data.description||"Something went wrong. Please try again."}}).catch(function(){return{ok:!1,description:"Something went wrong. Please try again."}})}).catch(function(){return document.dispatchEvent(new CustomEvent("theme:loading:end")),{ok:!1,description:"Something went wrong. Please try again."}})}function notifyCart(variant){var dispatch=function(){document.dispatchEvent(new CustomEvent("product:added",{bubbles:!0,detail:{variant:variant,quantity:1}}))};typeof Shopify!="undefined"&&typeof Shopify.getCart=="function"?Shopify.getCart(dispatch):dispatch()}function trackAdd(variant,source){window.dataLayer&&window.dataLayer.push({event:"pdp_quick_add",quick_add_source:source,variant_id:variant.id,price:typeof variant.price=="number"?variant.price/100:void 0})}function showError(message){!state||!state.errorEl||(state.errorEl.textContent=message,state.errorEl.hidden=!1)}function hideError(){!state||!state.errorEl||(state.errorEl.hidden=!0,state.errorEl.textContent="")}})(); 2//# sourceMappingURL=/cdn/shop/t/548/assets/pdp-quick-add.js.map?v=166161455725240117991787064779
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.