{
  "version": 3,
  "sources": ["/cdn/shop/t/66/assets/product-card-image-slider.js?cb=16427"],
  "sourcesContent": ["/* global CarouselSlider */\n\nif (!customElements.get('product-card-image-slider')) {\n  customElements.whenDefined('carousel-slider').then(() => {\n    class ProductCardImageSlider extends CarouselSlider {\n      constructor() {\n        super();\n        this.productCard = this.closest('product-card');\n        this.productCardSwatches = this.productCard.querySelectorAll('.card__swatches .opt-btn');\n        this.slides = this.querySelectorAll('.slider__item');\n\n        this.productCard.addEventListener('change', this.handleSwatchChange.bind(this));\n      }\n\n      init() {\n        super.init();\n\n        this.slider.addEventListener('scroll', this.scrollInProgress.bind(this));\n\n        // If swatches are enabled, mark the swatch anchors in the slideshow\n        if (this.productCardSwatches) {\n          const activeSlide = this.querySelector('.slider__item[aria-current]');\n          const activeSwatchId = this.productCard.querySelector('.card__swatches .opt-btn:checked')?.dataset.mediaId || activeSlide?.dataset.mediaId;\n          let activeSwatchSlide;\n\n          if (activeSwatchId) {\n            this.productCardSwatches.forEach((swatch) => {\n              const swatchSlide = this.querySelector(`[data-media-id=\"${swatch.dataset.mediaId}\"]`);\n              if (swatchSlide) {\n                swatchSlide.setAttribute('data-swatch-anchor', 'true');\n\n                // Set the active set of slideshow images\n                if (swatchSlide.dataset.mediaId === activeSwatchId) {\n                  activeSlide.removeAttribute('aria-current');\n                  swatchSlide.setAttribute('aria-current', 'true');\n                  activeSwatchSlide = swatchSlide;\n                }\n              }\n            });\n          }\n\n          if (activeSwatchSlide) this.handleSwatchChange(null, activeSwatchSlide.dataset.mediaId);\n        } else {\n          // Show the current slider item\n          const activeSlide = this.querySelector('.slider__item[aria-current]');\n          if (activeSlide) {\n            this.handleSwatchChange(null, activeSlide.dataset.mediaId);\n          } else {\n            this.slider.slides[1]?.setAttribute('aria-current', 'true');\n          }\n        }\n      }\n\n      /**\n       * Updates the visibility of slides based on the state of card swatches.\n       * @param {string} mediaId - The media ID to match against the slides.\n       */\n      updateSlideVisibility(mediaId) {\n        let hideSlide = true;\n        let foundMediaId = false;\n        this.slides.forEach((slide) => {\n          if (!foundMediaId && slide.getAttribute('data-media-id') === mediaId) {\n            hideSlide = false;\n            foundMediaId = true;\n          } else if (foundMediaId && slide.hasAttribute('data-swatch-anchor')) {\n            hideSlide = true;\n          }\n\n          slide.toggleAttribute('hidden', hideSlide);\n        });\n\n        this.setButtonStates();\n      }\n\n      /**\n       * Handles 'change' events in the product card swatches.\n       * @param {object} evt - Event object.\n       * @param {string} mediaId - The media ID to match against the slides.\n       */\n      handleSwatchChange(evt, mediaId) {\n        const swatchMediaId = evt?.target.dataset.mediaId || mediaId;\n        if (swatchMediaId) {\n          this.updateSlideVisibility(swatchMediaId);\n\n          const variantMedia = this.querySelector(`[data-media-id=\"${swatchMediaId}\"]`);\n          if (variantMedia) {\n            const left = variantMedia.closest('.slider__item').offsetLeft;\n            this.slider.scrollTo({ left, behavior: 'instant' });\n          }\n        }\n      }\n\n      /**\n       * Sets the disabled state of the nav buttons.\n       */\n      setButtonStates() {\n        if (!this.prevBtn && !this.nextBtn) {\n          return;\n        }\n\n        const currentSlideIndex = Math.round(this.slider.scrollLeft / this.slideSpan) + 1;\n        const visibleSlideCount = this.slides.filter((slide) => slide.hidden !== true).length;\n\n        this.prevBtn.disabled = currentSlideIndex === 1\n          || (this.getSlideVisibility(this.slides[0]) && this.slider.scrollLeft === 0);\n        this.nextBtn.disabled = visibleSlideCount === currentSlideIndex\n          || this.getSlideVisibility(this.slides[this.slides.length - 1]);\n      }\n\n      /**\n       * Handles 'scroll' events on the slider element.\n       */\n      scrollInProgress() {\n        this.slider.querySelector('[aria-current]')?.removeAttribute('aria-current');\n      }\n\n      /**\n       * Handles 'scroll' events on the slider element.\n       */\n      handleScroll() {\n        super.handleScroll();\n        this.slides[this.currentIndex].setAttribute('aria-current', 'true');\n      }\n    }\n\n    customElements.define('product-card-image-slider', ProductCardImageSlider);\n  });\n}\n"],
  "mappings": "AAEK,eAAe,IAAI,2BAA2B,GACjD,eAAe,YAAY,iBAA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