{ "version": 3, "sources": ["../../src/js/nav.ts"], "sourcesContent": ["declare const htmx: any;\ndeclare const hcaptcha: any;\n// declare const nav: any;\ndeclare const HCAPTCHA_SITEKEY: string;\n\n(() => {\n\n\tlet captchaWidget: any = null;\n\tlet previousPath: string = '';\n\n\tnav.initialized = false;\n\n\tnav.init = () => {\n\t\tif (!nav.initialized) {\n\t\t\thtmx.onLoad(() => {\n\t\t\t\tif (!nav.captchaLoaded) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tnav.refresh();\n\t\t\t});\n\t\t\tnav.initialized = true;\n\t\t}\n\t};\n\n\tnav.refresh = () => {\n\t\tconst currentTab = document.querySelector(\".nav a.active\");\n\t\tcurrentTab?.classList.remove('active');\n\n\t\tconst menuLinks = document.querySelectorAll(\".nav a\");\n\t\tfor (const link of menuLinks) {\n\t\t\tconst href = link.attributes.getNamedItem('href');\n\t\t\tif (href?.value === window.location.pathname) {\n\t\t\t\tlink.classList.add('active');\n\t\t\t}\n\t\t}\n\n\t\tconst header = document.querySelector('header');\n\t\tif (window.location.pathname !== '/') {\n\t\t\theader?.classList.add('border-bottom');\n\t\t} else {\n\t\t\theader?.classList.remove('border-bottom');\n\t\t}\n\n\t\tif (window.location.pathname !== previousPath && window.location.pathname !== '/app') {\n\t\t\tconst captchaExists = document.getElementById('hcaptcha');\n\t\t\tif (captchaExists) {\n\t\t\t\tcaptchaWidget = hcaptcha.render('hcaptcha', { sitekey: HCAPTCHA_SITEKEY });\n\t\t\t} else {\n\t\t\t\tcaptchaWidget = null;\n\t\t\t}\n\t\t}\n\n\t\tpreviousPath = window.location.pathname;\n\t};\n\n\tnav.acknowledgeCookies = () => {\n\t\tdocument.cookie = `cookieNoticeAcknowledged=true;max-age=31536000;path=/;SameSite=Strict`;\n\t\tconst cookieNotice = document.querySelector('#cookieNotice');\n\t\tcookieNotice?.classList.add('d-none');\n\t};\n\n\tnav.onFormSubmit = (formId: string) => {\n\t\tconst form = document.getElementById(formId);\n\t\tif (form) {\n\t\t\tconst event = new Event('verified');\n\t\t\tform.dispatchEvent(event);\n\t\t}\n\t};\n\n\tnav.onFormClick = async (formId: string) => {\n\t\tconst form = document.getElementById(formId) as HTMLFormElement;\n\t\tif (form && captchaWidget) {\n\t\t\tconst valid = form.reportValidity();\n\t\t\tif (valid) {\n\t\t\t\ttry {\n\t\t\t\t\tawait hcaptcha.execute(captchaWidget, { async: true });\n\t\t\t\t\tnav.onFormSubmit(formId);\n\t\t\t\t} catch (err) {\n\t\t\t\t\treportAppError('Captcha error', err);\n\t\t\t\t\thcaptcha.reset(captchaWidget);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n})();\n\n"], "mappings": "oBAKC,IAAM,CAEN,IAAIA,EAAqB,KACrBC,EAAuB,GAE3B,IAAI,YAAc,GAElB,IAAI,KAAO,IAAM,CACX,IAAI,cACR,KAAK,OAAO,IAAM,CACZ,IAAI,eAGT,IAAI,QAAQ,CACb,CAAC,EACD,IAAI,YAAc,GAEpB,EAEA,IAAI,QAAU,IAAM,CACA,SAAS,cAAc,eAAe,GAC7C,UAAU,OAAO,QAAQ,EAErC,IAAMC,EAAY,SAAS,iBAAiB,QAAQ,EACpD,QAAWC,KAAQD,EACLC,EAAK,WAAW,aAAa,MAAM,GACtC,QAAU,OAAO,SAAS,UACnCA,EAAK,UAAU,IAAI,QAAQ,EAI7B,IAAMC,EAAS,SAAS,cAAc,QAAQ,EAC1C,OAAO,SAAS,WAAa,IAChCA,GAAQ,UAAU,IAAI,eAAe,EAErCA,GAAQ,UAAU,OAAO,eAAe,EAGrC,OAAO,SAAS,WAAaH,GAAgB,OAAO,SAAS,WAAa,SACvD,SAAS,eAAe,UAAU,EAEvDD,EAAgB,SAAS,OAAO,WAAY,CAAE,QAAS,gBAAiB,CAAC,EAEzEA,EAAgB,MAIlBC,EAAe,OAAO,SAAS,QAChC,EAEA,IAAI,mBAAqB,IAAM,CAC9B,SAAS,OAAS,wEACG,SAAS,cAAc,eAAe,GAC7C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