/* Scoped to: home-appliances-template-subscribe_banner */
(function() {
  'use strict';
  var componentRoots = document.querySelectorAll('[data-component-slug="home-appliances-template-subscribe_banner"]');
  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-subscribe_banner"] ~ ' + 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 rawNotifyEndpoint = "{{notify_api_endpoint}}"; var CONFIG = { notifyEndpoint: rawNotifyEndpoint, }; var notifyForm = document.querySelector("[data-notify-form]"); var statusEl = document.getElementById("notify-status"); if (notifyForm) { notifyForm.addEventListener("submit", function (e) { e.preventDefault(); var emailInput = notifyForm.querySelector('input[type="email"]'); var submitBtn = notifyForm.querySelector('button[type="submit"]'); var originalText = submitBtn.textContent; submitBtn.textContent = "Subscribing..."; submitBtn.disabled = true; if (CONFIG.notifyEndpoint && CONFIG.notifyEndpoint.indexOf("http") === 0) { fetch(CONFIG.notifyEndpoint, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email: emailInput.value }), }) .then(function (res) { if (!res.ok) throw new Error("Failed"); return res.json(); }) .then(function () { showStatus("Thanks! We'll notify you when we launch.", "success"); notifyForm.reset(); }) .catch(function () { showStatus("Something went wrong. Please try again.", "error"); }) .finally(function () { submitBtn.textContent = originalText; submitBtn.disabled = false; }); } else { setTimeout(function () { showStatus("Thanks! We'll notify you when we launch.", "success"); notifyForm.reset(); submitBtn.textContent = originalText; submitBtn.disabled = false; }, 1000); } }); } function showStatus(message, type) { if (!statusEl) return; statusEl.textContent = message; statusEl.className = "mt-4 py-2 px-4 text-sm " + (type === "success" ? "bg-[#FFDE16]/70 text-white" : "bg-red-500/20 text-red-300"); statusEl.classList.remove("hidden"); } }, 0); })();
  });
})();