/* Scoped to: mobile-launch-template-effortless-slider */
(function() {
  'use strict';
  var componentRoots = document.querySelectorAll('[data-component-slug="mobile-launch-template-effortless-slider"]');
  componentRoots.forEach(function(componentRoot) {
    // Helper to query within component, with fallback to document for sibling elements
    var $ = function(sel) { 
      return componentRoot.querySelector(sel) || document.querySelector('[data-component-slug="mobile-launch-template-effortless-slider"] ~ ' + sel) || document.querySelector(sel);
    };
    var $$ = function(sel) { 
      var results = componentRoot.querySelectorAll(sel);
      return results.length ? results : document.querySelectorAll(sel);
    };
    // Original component JS runs in this scope
    const track = document.getElementById("sliderTrack"); const slides = document.querySelectorAll(".slide-item"); const indicators = document.querySelectorAll(".indicator"); let index = 0; let startX = 0; let currentX = 0; let baseX = 0; let dragging = false; let autoplayTimer = null; const GAP = 48; const SNAP = 120; const AUTOPLAY_DELAY = 4000; function slideSize() { return slides[0].offsetWidth + GAP; } function setTranslate(x) { track.style.transform = `translateX(${x}px)`; } function snapToSlide() { track.style.transition = "transform 0.6s cubic-bezier(.22,.61,.36,1)"; setTranslate(-index * slideSize()); indicators.forEach((d, i) => { d.style.width = i === index ? "32px" : "12px"; d.style.background = i === index ? "#fff" : "#444"; }); } function startAutoplay() { stopAutoplay(); autoplayTimer = setInterval(() => { index = index < slides.length - 1 ? index + 1 : 0; snapToSlide(); }, AUTOPLAY_DELAY); } function stopAutoplay() { if (autoplayTimer) clearInterval(autoplayTimer); } track.addEventListener("pointerdown", (e) => { dragging = true; stopAutoplay(); track.setPointerCapture(e.pointerId); startX = e.clientX; currentX = startX; baseX = -index * slideSize(); track.style.transition = "none"; track.style.cursor = "grabbing"; e.preventDefault(); }); track.addEventListener("pointermove", (e) => { if (!dragging) return; currentX = e.clientX; setTranslate(baseX + (currentX - startX)); }); track.addEventListener("pointerup", () => { if (!dragging) return; dragging = false; track.releasePointerCapture(event.pointerId); track.style.cursor = "grab"; const delta = currentX - startX; if (delta < -SNAP && index < slides.length - 1) index++; if (delta > SNAP && index > 0) index--; snapToSlide(); startAutoplay(); }); track.addEventListener("pointercancel", () => { if (!dragging) return; dragging = false; snapToSlide(); startAutoplay(); }); indicators.forEach((dot, i) => { dot.addEventListener("click", () => { stopAutoplay(); index = i; snapToSlide(); startAutoplay(); }); }); snapToSlide(); startAutoplay();
  });
})();