1import{d as addItemById,a as contexts}from"./cart-e301c7f3.js";import{d as dialog}from"./modals-32d7ef9a.js";import{E as EVENTS}from"./events-6c2ed57e.js";import{i as insertedMarkupFixes}from"./inserted-markup-fixes-2c66fe51.js";import"./svg-images-loaded-7454cac3.js";class ProductItemQuickShopping extends HTMLElement{constructor(){super(),this.selectors={allowedProductBlocks:"[js-product-block-allowed-in-quickview]",allowedProductDialog:".product-dialog-allowed-in-quickview",storeAvailabilityContent:"[js-store-availability-container]",productDetails:"[js-product-details]",productMediaTemplate:"[js-quick-view-media-template]",productInner:"[js-product-inner]",productSection:"[js-product-section]",quickShopButton:"[js-quick-shop-button]",quickShopButtonWrapper:"[js-quick-shop-button-wrapper]",quickShopError:"[js-quick-shop-error]",quickViewContent:"[js-quick-view-content]",quickViewFullDetailsTemplate:"[js-quick-view-full-details-template]",quickViewTemplate:"[js-quick-view-template]",quickShoppingWrapper:"[js-quick-shopping-wrapper]",removeFromQuickView:"[js-remove-from-quick-view]",swatchImages:"[js-product-item-swatch-image]",swatches:"[js-swatch]",swatchOverflowButton:"[js-product-listing-swatch-overflow]"},this.classes={hasError:"has-error",active:"active",quickViewProductInner:"product-inner--quick-view",success:"success",swatchActive:"swatch-active",selectedSwatch:"swatch--selected"}}connectedCallback(){this.controller=new AbortController,this.quickShopButton=this.querySelector(this.selectors.quickShopButton),this.quickShopButtonWrapper=this.querySelector(this.selectors.quickShopButtonWrapper),this.quickShopButton&&(this.quickShopType=this.quickShopButton.getAttribute("data-type"),this.quickShopWithinDialog=this.getAttribute("data-within-dialog")==="true",this.hasVariants=this.quickShopButton.getAttribute("data-has-variants")==="true",this.quickShoppingWrapper=this,this.quickViewTemplate=this.querySelector(this.selectors.quickViewTemplate),this.quickViewID=`quick-view-${this.getAttribute("data-product-id")}`,this.quickShopButton.addEventListener("click",this.handleQuickShopClick.bind(this),{signal:this.controller.signal}),this.quickShopType==="quick-add"&&!this.hasVariants&&(this.addEventListener(EVENTS.QUICK_ADD_SUCCESS,this.handleQuickAddSuccess.bind(this),{signal:this.controller.signal}),this.quickShopError=this.querySelector(this.selectors.quickShopError),this.addEventListener(EVENTS.QUICK_ADD_ERROR,this.handleQuickAddError.bind(this),{signal:this.controller.signal}),document.addEventListener(EVENTS.CART_CHANGED,this.handleCartUpdate.bind(this),{signal:this.controller.signal})),this.quickShopButton.addEventListener(EVENTS.QUICK_ADD_ERROR,this.handleQuickAddError.bind(this),{signal:this.controller.signal}))}handleQuickShopClick(event){event.preventDefault(),this.quickShopType==="quick-add"&&!this.hasVariants?this.handleQuickAdd():this.openQuickView()}handleQuickAdd(){this.quickShopButtonWrapper.dispatchEvent(new CustomEvent(EVENTS.BUTTON_STATE_STARTED)),addItemById(this.quickShopButton.dataset.variantId,1,contexts.productItem,this)}handleQuickAddSuccess(){this.quickShopButtonWrapper.dispatchEvent(new CustomEvent(EVENTS.BUTTON_STATE_COMPLETED)),this.classList.remove(this.classes.hasError)}handleQuickAddError(event){this.quickShopButtonWrapper.dispatchEvent(new CustomEvent(EVENTS.BUTTON_STATE_INCOMPLETED)),this.classList.add(this.classes.hasError),this.quickShopError.innerText=event.detail.errorMessage}handleCartUpdate(){this.classList.remove(this.classes.hasError)}async openQuickView(){if(!this.quickViewTemplate){console.debug("openQuickView called when template doesn't exist");return}this.quickShopButtonWrapper.dispatchEvent(new CustomEvent(EVENTS.BUTTON_STATE_STARTED));const templateContent=this.quickViewTemplate.content.cloneNode(!0),quickViewModal=templateContent.querySelector("dialog");if(this.quickShopWithinDialog){window.flu.dialogs[this.quickViewID]&&window.flu.dialogs[this.quickViewID][1].destroy({deregister:!0});const parentDialogContainer=this.closest("dialog").parentElement;parentDialogContainer.appendChild(templateContent),this.quickView=parentDialogContainer.querySelector(`dialog[data-fluco-dialog='${this.quickViewID}']`),this.quickViewContent=this.quickView.querySelector(this.selectors.quickViewContent)}else this.quickShoppingWrapper.appendChild(templateContent),this.quickViewContent=this.querySelector(this.selectors.quickViewContent);window.flu.dialogs[`quick-view-${this.getAttribute("data-product-id")}`]||dialog(quickViewModal);const productSection=await this.getQuickViewProductSection(),productSectionElement=productSection.cloneNode(!1),productSectionInner=productSection.querySelector(this.selectors.productInner).cloneNode(!1),productMediaFragment=productSection.querySelector(this.selectors.productMediaTemplate).content;this.quickViewFullDetailsLink=productSection.querySelector(this.selectors.quickViewFullDetailsTemplate)?.content.cloneNode(!0);const productDetails=productSection.querySelector(this.selectors.productDetails).cloneNode(!1);productSectionElement.setAttribute("data-section-type","quick-view-product"),productSectionElement.style="",productSectionInner.classList.add(this.classes.quickViewProductInner),productSectionInner.setAttribute("data-mobile-media-width","full_width");let buyButtonBlockToInsert;productSection.querySelectorAll(this.selectors.allowedProductBlocks).forEac
1h(block=>{if(block.querySelector(this.selectors.allowedProductDialog)&&block.querySelectorAll("dialog").forEach(subDialog=>{const clonedDialog=subDialog.cloneNode(!0);subDialog.remove();const subDialogId=clonedDialog.getAttribute("data-fluco-dialog");window.flu.dialogs[subDialogId]&&window.flu.dialogs[subDialogId][1].destroy({deregister:!0}),document.querySelector(`dialog[data-fluco-dialog='${subDialogId}']`)?.remove(),quickViewModal.after(clonedDialog),dialog(clonedDialog)}),block.hasAttribute("js-product-block-title")){const titleLink=document.createElement("a");titleLink.setAttribute("href",this.getAttribute("data-product-url")),titleLink.innerHTML=block.innerHTML,block.replaceChildren(titleLink)}else block.hasAttribute("js-product-block-buy-buttons")&&(block.querySelector(this.selectors.storeAvailabilityContent)?.remove(),this.quickViewFullDetailsLink&&block.append(this.quickViewFullDetailsLink),buyButtonBlockToInsert=block,block=null);block&&productDetails.appendChild(block)}),buyButtonBlockToInsert&&(buyButtonBlockToInsert.querySelectorAll(this.selectors.removeFromQuickView)?.forEach(feature=>{feature.remove()}),productDetails.appendChild(buyButtonBlockToInsert)),productSectionInner.appendChild(productMediaFragment),productSectionInner.appendChild(productDetails),productSectionElement.appendChild(productSectionInner),insertedMarkupFixes(productSectionElement),window.dispatchEvent(new CustomEvent(EVENTS.MODAL_POPUP_OPEN(this.quickViewID))),this.quickViewContent.replaceChildren(productSectionElement),this.quickShopButtonWrapper.dispatchEvent(new CustomEvent(EVENTS.BUTTON_STATE_INCOMPLETED))}async getQuickViewProductSection(){const productPage=await fetch(`${this.getAttribute("data-product-url")}`);if(productPage){const productPageText=await productPage.text();return new DOMParser().parseFromString(productPageText,"text/html").querySelector(this.selectors.productSection)}}disconnectedCallback(){this.controller.abort()}}customElements.get("product-item-quick-shopping")||customElements.define("product-item-quick-shopping",ProductItemQuickShopping); 2//# sourceMappingURL=/cdn/shop/t/26/assets/product-item-quick-shopping.js.map?v=17114289499392951221754552164
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.