/* Scoped to: marathon-navbar */
(function() {
  'use strict';
  var componentRoots = document.querySelectorAll('[data-component-slug="marathon-navbar"]');
  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="marathon-navbar"] ~ ' + 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 () { var path = window.location.pathname; if (path.charAt(0) === "/") path = path.substring(1); if (path.charAt(path.length - 1) === "/") path = path.slice(0, -1); if (path.indexOf("page/") === 0) path = path.substring(5); path = path.split("#")[0]; var currentPath = path.toLowerCase(); if (!currentPath) currentPath = "home"; var textToPath = { home: ["home", "", "#"], "about us": ["about", "about-us"], programs: ["programs"], events: ["events"], "contact us": ["contact", "contact-us"], }; var desktopLinks = document.querySelectorAll('nav[data-component-type="Navigation"] a[data-node^="nav_link_"]'); desktopLinks.forEach(function (link, index) { var linkText = link.textContent.trim().toLowerCase(); var href = link.getAttribute("href") || ""; var linkPath = href .replace(/^\/|\/$/g, "") .replace(/#$/, "") .toLowerCase(); var isActive = false; if (index === 0 && (currentPath === "home" || currentPath === "")) { isActive = true; } else if (linkPath === currentPath) { isActive = true; } else if (textToPath[linkText]) { isActive = textToPath[linkText].some(function (p) { return p === currentPath; }); } if (isActive) { link.classList.remove("text-white/70", "hover:text-lime-400"); link.classList.add("text-white"); link.style.padding = "20px 30px"; link.style.backgroundColor = "rgba(255, 255, 255, 0.05)"; } else { link.classList.remove("text-lime-400"); link.classList.add("text-white"); link.style.border = "none"; link.style.padding = "0"; link.style.backgroundColor = "transparent"; } }); var mobileLinks = document.querySelectorAll(".mobile-menu a"); var mobileIndex = 0; mobileLinks.forEach(function (link) { if (link.classList.contains("bg-lime-400")) return; var linkText = link.textContent.trim().toLowerCase(); var isActive = false; if (mobileIndex === 0 && (currentPath === "home" || currentPath === "")) { isActive = true; } else if (textToPath[linkText]) { isActive = textToPath[linkText].some(function (p) { return p === currentPath; }); } if (isActive) { link.classList.add("text-lime-400"); link.classList.remove("text-white"); } else { link.classList.remove("text-lime-400"); link.classList.add("text-white"); } mobileIndex++; }); })(); var btn = document.querySelector(".mobile-menu-btn"); var menu = document.querySelector(".mobile-menu"); var closeBtn = document.querySelector(".mobile-menu-close"); function openMenu() { menu.classList.remove("translate-x-full"); document.body.classList.add("overflow-hidden"); var hamburger = btn.querySelector(".hamburger-icon"); var close = btn.querySelector(".close-icon"); if (hamburger) hamburger.classList.add("hidden"); if (close) close.classList.remove("hidden"); } function closeMenu() { menu.classList.add("translate-x-full"); document.body.classList.remove("overflow-hidden"); var hamburger = btn.querySelector(".hamburger-icon"); var close = btn.querySelector(".close-icon"); if (hamburger) hamburger.classList.remove("hidden"); if (close) close.classList.add("hidden"); } if (btn && menu) { btn.addEventListener("click", function () { var isOpen = !menu.classList.contains("translate-x-full"); if (isOpen) { closeMenu(); } else { openMenu(); } }); } if (closeBtn && menu) { closeBtn.addEventListener("click", function () { closeMenu(); }); }
  });
})();