1(self.webpackChunkapp_project=self.webpackChunkapp_project||[]).push([[1312],{30420:(t,e,a)=>{"use strict";a.r(e),a.d(e,{default:()=>n});var r=a(38302),s=a(12737),i=a(14863);class n extends r.default{get SELECTORS(){return{addToCart:".wishlist-add-to-cart",select:"select",pid:'[name="pid"]',groupAddToCart:'[data-component="GroupAddToCartComponent"]',productTile:".js-product-tile-wishlist",tilePicture:".tile-image"}}constructor(t){super(t),this.pid=null,this.bindChange(),this.handleButton(),this.handleSubmit(),this.handleGroupAddToCart()}async handleGroupAddToCart(){s.Z.on("wishlist:beforeGroupAddToCart",(()=>{const t=document.querySelector(this.SELECTORS.groupAddToCart);t&&t.componentInstance&&this.pid&&t.componentInstance.addPid(this.pid)}))}async getVarationInfo(){let t;try{const e=new FormData(this.element),a=new URLSearchParams(e).toString(),r=this.element.dataset.variationUrl,s=await(0,i.ZP)("".concat(r,"?").concat(a));t=await s.json()}catch(t){console.error(t)}return t}async handleSubmit(){this.element.addEventListener("submit",(async t=>{t.preventDefault();try{s.Z.emit("body:loading");const t=this.element.action,e=new FormData(this.element),a=await(0,i.ZP)(t,{method:"POST",body:e}),r=await a.json(),n=document.querySelector(".error-message-wishlist");if(n.classList.contains("d-none")||n.classList.add("d-none"),r&&r.quantityTotal&&!r.error)s.Z.emit("update:minicart",r),s.Z.emit("product:afterAddToCart");else{const t=r.message;n.innerText=t,n.classList.remove("d-none")}}catch(t){console.error(t)}finally{s.Z.emit("body:loaded")}}))}async handleButton(t){const e=[...this.element.querySelectorAll(this.SELECTORS.select)],a=e.filter((t=>!!t.value)).map((t=>t.value)),r=this.element.querySelector(this.SELECTORS.addToCart);if(e.length===a.length){if(t){const e=this.element.querySelector(this.SELECTORS.pid);r.setAttribute("data-pid",t),e.setAttribute("value",t),r.removeAttribute("disabled"),this.pid=t}else this.pid=null,e.forEach((t=>{t.dispatchEvent(new Event("change"))}));return!0}r.setAttribute("disabled","true")}getFirstImage(t){let e;try{t.large&&t.large.length>0&&(e=t.large[0])}catch(t){console.error(t)}return e}async renderImages(t){if(!t)return;const e=this.getFirstImage(t);if(e){const t=this.element.closest(this.SELECTORS.productTile),a=t.querySelector(this.SELECTORS.tilePicture),r=t.querySelector(".tile-image-link"),s=a.querySelector("img"),{displaySet:i,absURL:n,alt:o,title:l}=e;r.setAttribute("title",l),s.setAttribute("data-src",n),s.setAttribute("src",n),s.setAttribute("alt",o),i.forEach((t=>{const e=a.querySelector('source[media="'.concat(t.query,'"]'));e&&(e.setAttribute("data-srcset",t.image),e.setAttribute("srcset",t.image))}))}}handleResult(t){if(!t)return!1;const{product:e}=t;if(!e)return!1;this.handleButton(e.id),this.renderImages(e.images)}async bindChange(){[...this.element.querySelectorAll(this.SELECTORS.select)].forEach((t=>{t.addEventListener("change",(async t=>{const e=await this.getVarationInfo();this.handleResult(e)}))}))}}}}]);
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.