{"version":3,"file":"header.DX9JmUq-.js","sources":["../../../src/components/layout/header/header.ts"],"sourcesContent":["import { isLoggedIn } from '@lib/session'\nimport styles from './header.module.css'\nimport { disableScroll, enableScroll } from '@lib/utils'\n\nconst openMobileMenu = () => {\n disableScroll()\n\n const mobileMenuContainer = document.getElementById('mobileMenuContainer')\n mobileMenuContainer?.classList.add(styles.mobileMenuContainerOpen)\n\n const mobileMenu = document.getElementById('mobileMenu')\n mobileMenu?.classList.add(styles.mobileMenuOpen)\n\n showMobileMainMenu()\n hideMobileSubMenus()\n}\n\nconst closeMobileMenu = () => {\n enableScroll()\n\n const mobileMenuContainer = document.getElementById('mobileMenuContainer')\n mobileMenuContainer?.classList.remove(styles.mobileMenuContainerOpen)\n\n const mobileMenu = document.getElementById('mobileMenu')\n mobileMenu?.classList.remove(styles.mobileMenuOpen)\n\n setTimeout(() => {\n resetMobileMenuAnimantions()\n }, 300)\n}\n\nconst showMobileMainMenu = () => {\n const mobileMenuMain = document.getElementById('mobileMenuMain')\n mobileMenuMain?.classList.remove(styles.mobileMenuMainHidden)\n\n document.getElementById('mobileMenuBackButton')!.style.display = 'none'\n document.getElementById('mobileMenuSearchButton')!.style.display = 'block'\n}\n\nconst showMobileSubMenu = (id: string) => {\n const mobileSubMenu = document.getElementById(`mobileSubMenu-${id}`)\n mobileSubMenu?.classList.add(styles.mobileSubMenuVisible)\n\n const mobileMenuMain = document.getElementById('mobileMenuMain')\n mobileMenuMain?.classList.add(styles.mobileMenuMainHidden)\n\n document.getElementById('mobileMenuBackButton')!.style.display = 'block'\n document.getElementById('mobileMenuSearchButton')!.style.display = 'none'\n}\n\nconst hideMobileSubMenus = () => {\n document.querySelectorAll('[id^=mobileSubMenu-]').forEach((mobileSubMenu) => {\n mobileSubMenu.classList.remove(styles.mobileSubMenuVisible)\n })\n}\n\nconst resetMobileMenuAnimantions = () => {\n const mobileMenuMain = document.getElementById('mobileMenuMain')\n mobileMenuMain?.classList.remove(styles.mobileMenuMainHidden)\n\n document.querySelectorAll('[id^=mobileSubMenu-]').forEach((mobileSubMenu) => {\n mobileSubMenu.classList.remove(styles.mobileSubMenuVisible)\n })\n}\n\nconst showLoggedInState = () => {\n document.querySelectorAll('[data-show-logged-out=false]').forEach((element) => {\n element.classList.remove('hidden')\n })\n\n const desktopLoginButton = document.getElementById('headerDesktopLoginButton')\n desktopLoginButton?.classList.add('desktop:hidden')\n\n const mobileLoginButton = document.getElementById('headerMobileLoginButton')\n mobileLoginButton?.classList.add('hidden')\n\n const desktopAccountMenuItem = document.getElementById('desktopAccountMenuItem')\n desktopAccountMenuItem?.classList.remove('hidden')\n}\n\nconst setMobileMenuEventListeners = () => {\n document.getElementById('mobileMenuOpenButton')?.addEventListener('click', (e) => {\n openMobileMenu()\n e.preventDefault()\n })\n\n document.getElementById('mobileMenuCloseButton')?.addEventListener('click', (e) => {\n closeMobileMenu()\n e.preventDefault()\n })\n\n document.getElementById('mobileMenuBackButton')?.addEventListener('click', (e) => {\n hideMobileSubMenus()\n showMobileMainMenu()\n e.preventDefault()\n })\n\n document.querySelectorAll('[id^=mobileMainMenuItem-]').forEach((mobileMainMenuItem) => {\n mobileMainMenuItem.addEventListener('click', (e) => {\n const id = mobileMainMenuItem.getAttribute('data-id')\n showMobileSubMenu(id!)\n e.preventDefault()\n })\n })\n}\n\nconst setDesktopMenuEventListeners = () => {\n document.querySelectorAll('[data-main-menu-item=true]').forEach((desktopMainMenuItem) => {\n desktopMainMenuItem.addEventListener('mouseenter', () => {\n const headerDesktopOverlay = document.getElementById('headerDesktopOverlay')\n headerDesktopOverlay!.classList.remove('invisible')\n })\n\n desktopMainMenuItem.addEventListener('mouseleave', () => {\n const headerDesktopOverlay = document.getElementById('headerDesktopOverlay')\n headerDesktopOverlay!.classList.add('invisible')\n })\n })\n}\n\n// Close the mobile menu when we navigate back to the page.\nconst closeMobileMenuOnPageLoad = () => {\n window.addEventListener('pageshow', () => {\n closeMobileMenu()\n })\n}\n\nconst handleLoggedInState = async () => {\n try {\n const userIsLoggedIn = await isLoggedIn()\n if (userIsLoggedIn) {\n showLoggedInState()\n }\n } catch (error) {\n console.error('Error checking login status:', error)\n }\n}\n\nconst setGetStartedButtonEventListeners = (onGetStartedClick: () => void) => {\n document.getElementById('headerGetStartedLink')?.addEventListener('click', (e) => {\n onGetStartedClick()\n e.preventDefault()\n })\n\n document.getElementById('headerGetStartedLinkMobile')?.addEventListener('click', (e) => {\n onGetStartedClick()\n closeMobileMenu()\n e.preventDefault()\n })\n}\n\nconst setLoginButtonEventListener = (onLoginClick: () => void) => {\n document.getElementById('headerDesktopLoginButton')?.addEventListener('click', (e) => {\n onLoginClick()\n e.preventDefault()\n })\n\n document.getElementById('headerMobileLoginButton')?.addEventListener('click', (e) => {\n onLoginClick()\n closeMobileMenu()\n e.preventDefault()\n })\n}\n\nconst init = () => {\n setMobileMenuEventListeners()\n setDesktopMenuEventListeners()\n closeMobileMenuOnPageLoad()\n handleLoggedInState()\n}\n\nexport { init, setGetStartedButtonEventListeners, setLoginButtonEventListener }\n"],"names":["openMobileMenu","disableScroll","styles","showMobileMainMenu","hideMobileSubMenus","closeMobileMenu","enableScroll","resetMobileMenuAnimantions","showMobileSubMenu","id","mobileSubMenu","showLoggedInState","element","setMobileMenuEventListeners","mobileMainMenuItem","e","setDesktopMenuEventListeners","desktopMainMenuItem","closeMobileMenuOnPageLoad","handleLoggedInState","isLoggedIn","error","setGetStartedButtonEventListeners","onGetStartedClick","setLoginButtonEventListener","onLoginClick","init"],"mappings":"8eAIA,MAAMA,EAAiB,IAAM,CACbC,IAEc,SAAS,eAAe,qBAAqB,GACpD,UAAU,IAAIC,EAAO,uBAAuB,EAE9C,SAAS,eAAe,YAAY,GAC3C,UAAU,IAAIA,EAAO,cAAc,EAE5BC,IACAC,GACrB,EAEMC,EAAkB,IAAM,CACfC,IAEe,SAAS,eAAe,qBAAqB,GACpD,UAAU,OAAOJ,EAAO,uBAAuB,EAEjD,SAAS,eAAe,YAAY,GAC3C,UAAU,OAAOA,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