1import{U as m,V as u,N as S,C as _,r as g}from"./storefrontApp.5Jl33SLO.min.js";import{F as c}from"./chunk-full_product_gallery_service.DyTRqyD.js";import{a as p}from"./chunk-product_constants.e09mIDD.js";import{P as f}from"./chunk-product_stock_changed_handler.D1B5WJH.js";import{S as y}from"./chunk-storefront_base_lit_element.BngXaMu.js";import{U as b,e as a}from"./chunk-vendor-lit.NvY0u02.js";import{f as v}from"./chunk-vendor-lodash.CWHFt7Z.js";import"./chunk-vendor-di.Bh23gdA.js";import"./chunk-storefront_settings_constants.DIF02Gz.js";import"./chunk-vendor-rxjs.Dp7kflo.js";import"./chunk-vendor-phoenix.cdKS79L.js";import"./chunk-product_events_constants.BHFu5GP.js";function T(r,t){const{track:e}=t.Elements;let i;function s(){i=document.createElement("div"),i.classList.add("splide__slide-number"),e.parentElement.insertBefore(i,e.nextSibling),n(),r.on("move",n)}function n(){i.textContent=`${r.index+1}/${r.length}`}return{mount:s}}var C=Object.defineProperty,d=(r,t,e,i)=>{for(var s=void 0,n=r.length-1,o;n>=0;n--)(o=r[n])&&(s=o(t,e,s)||s);return s&&C(t,e,s),s};class l extends y{constructor(){super(),this.main="",this.thumbnails="",this.moveBy=3,this._hideArrowsOnPositionLimit=t=>{const e=t.root.querySelector(".js__splide-move-by-next"),i=t.root.querySelector(".js__splide-move-by-prev"),s="product-gallery__thumbnail-arrow_hidden",n=t.Components.Move.getLimit(!1),o=t.Components.Move.getLimit(!0),h=t.Components.Move.getPosition();h===n?(i?.classList.add(s),e?.classList.remove(s)):h===o?(e?.classList.add(s),i?.classList.remove(s)):(e?.classList.remove(s),i?.classList.remove(s))},this._changeDisplayedSlideOnStockChanged=t=>{const e=this._getSlider(this.main),i=t.body?.images[p]?.imageName;if(!i||this._isImageToDisplaySameAsCurrent(i))return;const s=this._getIndexOfSlideToGoAfterStockChangedTemporary(i);s>-1&&e?.go(s)},this.images=this.querySelectorAll(`img.${m.galleryOpener}`),this._imagesUrls=[...this.images].map(t=>new URL(t.currentSrc?t.currentSrc:t.src).pathname)}static{this.moduleName=u.component}firstUpdated(t){super.firstUpdated(t);const e=this._getSliders(),i=this.querySelectorAll(`.${m.arrowsContainer}`),s=this._getMainSliderDimensions().width;this._syncSliders(e),this._mountSliders(e),this._showArrowContainers(i),window.addEventListener("resize",v(()=>{const n=this._getSliders(),o=this._getMainSliderDimensions().width;this._adjustThumbnailSliderWidthToMainSliderWidth(n,o)},200)),e[1]&&(this._addThumbnailSliderScrolling(e[1]),this._hideArrowsOnPositionLimit(e[1]),e[1].on("moved",()=>this._hideArrowsOnPositionLimit(e[1])),e[1].on("scrolled",()=>this._hideArrowsOnPositionLimit(e[1]))),e[1]&&e[1].options.direction==="ttb"?this._adjustHeightDimensions(e):this._adjustThumbnailSliderWidthToMainSliderWidth(e,s),new f(this._changeDisplayedSlideOnStockChanged)}_addThumbnailSliderScrolling(t){let e=0;t.options.direction==="ttb"&&t.options.fixedHeight?e=this.moveBy*Number(t.options.fixedHeight):t.options.fixedWidth?e=this.moveBy*Number(t.options.fixedWidth):e=this.moveBy*50;const i=t.root.querySelector(".js__splide-move-by-next"),s=t.root.querySelector(".js__splide-move-by-prev");i?.addEventListener("click",()=>{const o=t.Components.Move.getPosition()-e;t.Components.Scroll.scroll(o,300,!0)}),s?.addEventListener("click",()=>{const o=t.Components.Move.getPosition()+e;t.Components.Scroll.scroll(o,300,!0)})}async _adjustHeightDimensions(t){const e=this.querySelector(`#${this.thumbnails} img:last-child`);e&&(e.complete?this._adjustThumbnailSliderHeightToMainSliderHeight(t):e.onload=()=>{this._adjustThumbnailSliderHeightToMainSliderHeight(t)})}_getMainSliderDimensions(){const t=this.querySelector(`#${this.main}`),{width:e,height:i}=t.getBoundingClientRect();return{width:e,height:i}}_getThumbnailSliderDimensions(){const t=this.querySelector(`#${this.thumbnails}`),{width:e,height:i}=t.getBoundingClientRect();return{width:e,height:i}}_syncSliders(t){const[e,i]=t;e&&i&&e.sync(i)}_mountSliders(t){const[e,i]=t;e.mount({SlideNumber:T}),i&&i.mount({})}_getSliders(){const t=[],e=this._getSlider(this.main),i=this._getSlider(this.thumbnails);return e&&t.push(e),i&&t.push(i),t}_getSlider(t){const e=this.querySelector(`#${t}`);if(e){const i=e.getSlider();if(i)return i}return null}
1_adjustThumbnailSliderHeightToMainSliderHeight(t){const[,e]=t,{height:i}=this._getMainSliderDimensions(),{height:s}=this._getThumbnailSliderDimensions(),n=e.length<=4?e.length*86:Math.max(i,344);s>=i&&(e.options={height:n},this._showThumbnailSliderArrows(e))}_showThumbnailSliderArrows(t){const e=t.root.querySelector(".js__splide-move-by-next"),i=t.root.querySelector(".js__splide-move-by-prev");e?.removeAttribute("hidden"),i?.removeAttribute("hidden")}_adjustThumbnailSliderWidthToMainSliderWidth(t,e){const[,i]=t;if(i){const{width:s}=this._getThumbnailSliderDimensions();s>=e&&this._showThumbnailSliderArrows(i),i.options={width:e}}}_isImageToDisplaySameAsCurrent(t){const e=this.querySelector(".splide__slide.is-active .js__gallery-anchor-image");return e?e.href?.includes(`productGfx_${t}`):!1}_getFileNamesFromSlides(){const t=[];return this.images.forEach(e=>{const i=e.title,s=i.substring(0,i.lastIndexOf("."));t.push(s)}),t}_getImagesUrls(){return[...this.images].map(t=>new URL(t.currentSrc).pathname)}_getIndexOfSlideToGoAfterStockChanged(t,e){return e.findIndex(i=>i===t)}_getIndexOfSlideToGoAfterStockChangedTemporary(t){return this._imagesUrls.findIndex(e=>e.includes(`productGfx_${t}`))}_showArrowContainers(t){t.forEach(e=>{b.show(e)})}}d([a()],l.prototype,"main");d([a()],l.prototype,"thumbnails");d([a()],l.prototype,"images");d([a()],l.prototype,"moveBy");class j extends S{static{this.featureName=u.feature}async init(){const t=[];return c.isCreated||t.push(new c),{cores:[{type:_,instance:[l]},{type:g.service,instance:t}]}}}export{j as ProductGalleryInitializer};
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.