1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([["maxia-listing-image-switcher.plugin"],{882:(e,t,i)=>{i.r(t),i.d(t,{default:()=>o});let a=window.PluginBaseClass,r=window.PluginManager,s=window.Feature;class o extends a{init(){if(this.productBox=this.el.closest(this.options.productBoxSelector),null===this.productBox)return;if(this.imageWrapper=[...this.productBox.querySelectorAll(this.options.imageWrapperSelector)].slice(-1)[0],s.isActive("ACCESSIBILITY_TWEAKS")&&null!==this.imageWrapper&&null!==this.imageWrapper.firstElementChild&&"IMG"!==this.imageWrapper.firstElementChild.tagName&&(this.imageWrapper=[...this.productBox.querySelectorAll(".product-image-link")].slice(-1)[0]),null===this.imageWrapper){console.warn("product box image not found");return}let e=this.imageWrapper.querySelectorAll("noscript");e&&e.forEach(e=>e.remove()),void 0===this.productBox._maxiaImageSwitcher&&this._updateDefaultImage(),this.configuratorPlugin=r.getPluginInstanceFromElement(this.productBox,"MaxiaListingConfigurator"),this._registerEvents()}_registerEvents(){this.el.addEventListener("mouseenter",this._setImage.bind(this)),this.el.addEventListener("mouseleave",this._restoreImage.bind(this)),this.el.addEventListener("focus",this._setImage.bind(this)),this.el.addEventListener("blur",this._restoreImage.bind(this)),document.$emitter.subscribe("MaxiaVariantsInitProductBox",e=>{e.detail.productBoxElement.isSameNode(this.productBox)&&this._updateDefaultImage()})}_updateDefaultImage(){this.productBox._maxiaImageSwitcher={timeoutId:null,defaultImageHtml:this.imageWrapper.innerHTML.trim()}}_setImage(){null!==this.productBox._maxiaImageSwitcher.timeoutId&&clearTimeout(this.productBox._maxiaImageSwitcher.timeoutId),this.configuratorPlugin.isLoading||this._preloadAndSwitchImage(this.options.imageHtml)}_restoreImage(){this.configuratorPlugin.isLoading||(this.productBox._maxiaImageSwitcher.timeoutId=setTimeout(()=>{this._preloadAndSwitchImage(this.productBox._maxiaImageSwitcher.defaultImageHtml,()=>{this.productBox._maxiaImageSwitcher.timeoutId=null})},this.options.restoreTimeout))}_preloadAndSwitchImage(e,t){let i=document.createElement("div");i.innerHTML=e;let a=i.querySelector("img:not("+this.options.imgIgnoreClasses+")");if(!a){t();return}a.classList.add("new-image"),a.style.transition="none",a.style.position="absolute",a.style.opacity=0;let r=()=>{a.removeEventListener("load",r),this._onImageLoaded(a,t)};a.addEventListener("load",r);let s=this.imageWrapper.querySelector(".product-wishlist");s?s.insertAdjacentElement("beforebegin",a):this.imageWrapper.insertAdjacentElement("beforeend",a)}_onImageLoaded(e,t){if(this.configuratorPlugin.isLoading){e.remove();return}let i=e.parentElement.querySelectorAll("img:not(.new-image,"+this.options.imgIgnoreClasses+"), .product-image-placeholder");i&&i.forEach(e=>e.remove()),e.classList.remove("new-image"),e.style.opacity="",e.style.position="",setTimeout(()=>{e.style.transition=""},10),document.body.classList.contains("maxia-lazy")&&this.imageWrapper.classList.add("maxia-lazy-loaded"),"function"==typeof t&&t(e)}}o.options={productBoxSelector:".product-box",imageWrapperSelector:s.isActive("ACCESSIBILITY_TWEAKS")?".product-image-wrapper":".product-image-link",imgIgnoreClasses:".is-custom, .cover-switch",restoreTimeout:400,imageHtml:""}}}]);
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.