/* Scoped to: home-appliances-template-trusted-partnership-testimonial */
(function() {
  'use strict';
  var componentRoots = document.querySelectorAll('[data-component-slug="home-appliances-template-trusted-partnership-testimonial"]');
  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-trusted-partnership-testimonial"] ~ ' + 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 () { setTimeout(function () { var CONFIG = { autoplayEnabled: "{{autoplay_enabled}}" !== "false", autoplayInterval: parseInt("{{autoplay_interval}}") || 5000, transitionDuration: parseInt("{{transition_duration}}") || 500, }; var carousel = document.querySelector("[data-carousel]"); if (!carousel) return; var slides = carousel.querySelectorAll("[data-slide]"); var dots = carousel.querySelectorAll("[data-dot]"); var prevBtn = carousel.querySelector("[data-prev]"); var nextBtn = carousel.querySelector("[data-next]"); var currentIndex = 0; var slideCount = slides.length; var autoplayTimer = null; var isPaused = false; function goToSlide(index) { if (index < 0) index = slideCount - 1; if (index >= slideCount) index = 0; slides.forEach(function (slide, i) { if (i === index) { slide.classList.remove("opacity-0"); slide.classList.add("opacity-100"); } else { slide.classList.remove("opacity-100"); slide.classList.add("opacity-0"); } }); dots.forEach(function (dot, i) { if (i === index) { dot.classList.remove("bg-[#73748C]"); dot.classList.add("bg-[#1D398D]"); } else { dot.classList.remove("bg-[#1D398D]"); dot.classList.add("bg-[#73748C]"); } }); currentIndex = index; } function nextSlide() { goToSlide(currentIndex + 1); } function prevSlide() { goToSlide(currentIndex - 1); } function startAutoplay() { if (!CONFIG.autoplayEnabled || isPaused) return; stopAutoplay(); autoplayTimer = setInterval(nextSlide, CONFIG.autoplayInterval); } function stopAutoplay() { if (autoplayTimer) { clearInterval(autoplayTimer); autoplayTimer = null; } } if (prevBtn) prevBtn.addEventListener("click", function () { prevSlide(); startAutoplay(); }); if (nextBtn) nextBtn.addEventListener("click", function () { nextSlide(); startAutoplay(); }); dots.forEach(function (dot, index) { dot.addEventListener("click", function () { goToSlide(index); startAutoplay(); }); }); carousel.addEventListener("mouseenter", function () { isPaused = true; stopAutoplay(); }); carousel.addEventListener("mouseleave", function () { isPaused = false; startAutoplay(); }); carousel.setAttribute("tabindex", "0"); carousel.addEventListener("keydown", function (e) { if (e.key === "ArrowLeft") prevSlide(); if (e.key === "ArrowRight") nextSlide(); }); startAutoplay(); }, 0); })();(function () { setTimeout(function () { var CONFIG = { counter1: parseInt("{{counter_1_value}}") || 380, }; var counters = document.querySelectorAll("[data-counter]"); if (!counters.length) return; function easeOutQuart(t) { return 1 - Math.pow(1 - t, 4); } function animateCounter(element, target, duration) { var startTime = null; function step(timestamp) { if (!startTime) startTime = timestamp; var progress = Math.min((timestamp - startTime) / duration, 1); var easedProgress = easeOutQuart(progress); var current = Math.floor(easedProgress * target); element.textContent = current.toLocaleString(); if (progress < 1) { requestAnimationFrame(step); } else { element.textContent = target.toLocaleString(); } } requestAnimationFrame(step); } var observer = new IntersectionObserver( function (entries) { entries.forEach(function (entry) { if (entry.isIntersecting) { var counterEl = entry.target; var counterNum = counterEl.getAttribute("data-counter"); var target = CONFIG["counter" + counterNum]; animateCounter(counterEl, target, CONFIG.duration); observer.unobserve(counterEl); } }); }, { threshold: 0.3 }, ); counters.forEach(function (counter) { observer.observe(counter); }); }, 0); })();
  });
})();