/* Scoped to: home-appliances-template-testimonials */
(function() {
  'use strict';
  var componentRoots = document.querySelectorAll('[data-component-slug="home-appliances-template-testimonials"]');
  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="home-appliances-template-testimonials"] ~ ' + 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
    (function () { const initTestimonials = () => { const slider = document.getElementById("carouselContainer"); const prevBtn = document.getElementById("prevBtn"); const nextBtn = document.getElementById("nextBtn"); if (!slider || !prevBtn || !nextBtn) return; const items = Array.from(slider.children); if (items.length === 0) return; const itemWidth = items[0].offsetWidth + 24; const totalWidth = itemWidth * items.length; items.forEach((item) => { const clone = item.cloneNode(true); slider.appendChild(clone); }); items .slice() .reverse() .forEach((item) => { const clone = item.cloneNode(true); slider.insertBefore(clone, slider.firstChild); }); slider.scrollLeft = totalWidth; const scrollNext = () => { slider.scrollBy({ left: itemWidth, behavior: "smooth" }); }; const scrollPrev = () => { slider.scrollBy({ left: -itemWidth, behavior: "smooth" }); }; nextBtn.addEventListener("click", scrollNext); prevBtn.addEventListener("click", scrollPrev); let isScrolling; slider.addEventListener("scroll", () => { window.clearTimeout(isScrolling); isScrolling = setTimeout(() => { if (slider.scrollLeft >= totalWidth * 2 - 10) { slider.style.scrollBehavior = "auto"; slider.scrollLeft = slider.scrollLeft - totalWidth; slider.style.scrollBehavior = "smooth"; } else if (slider.scrollLeft <= totalWidth - 10) { if (slider.scrollLeft <= 0) { slider.style.scrollBehavior = "auto"; slider.scrollLeft = slider.scrollLeft + totalWidth; slider.style.scrollBehavior = "smooth"; } else if (slider.scrollLeft >= totalWidth * 2) { slider.style.scrollBehavior = "auto"; slider.scrollLeft = slider.scrollLeft - totalWidth; slider.style.scrollBehavior = "smooth"; } } }, 50); }); }; if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", initTestimonials); } else { initTestimonials(); } })();
  });
})();