/* Navigation can wrap, and HTMX replaces the body on boosted navigation. */ (() => { let observer; function observeLayout() { observer?.disconnect(); const header = document.querySelector('.gc-app-header'); const context = document.querySelector('.gc-case-context'); const measure = () => { document.documentElement.style.setProperty('--gc-header-height', `${header?.getBoundingClientRect().height || 0}px`); document.documentElement.style.setProperty('--gc-context-height', `${context?.getBoundingClientRect().height || 0}px`); }; measure(); observer = new ResizeObserver(measure); if (header) observer.observe(header); if (context) observer.observe(context); } // A label dispatches a second click to its checkbox. Use checked state once. document.addEventListener('change', event => { const input = event.target; if (!input.matches('input[data-gc-collapse]')) return; const panel = document.getElementById(input.getAttribute('aria-controls')); if (panel) panel.classList.toggle('show', input.checked); input.setAttribute('aria-expanded', String(input.checked)); }); document.addEventListener('DOMContentLoaded', observeLayout); document.addEventListener('htmx:load', observeLayout); document.addEventListener('htmx:historyRestore', observeLayout); window.addEventListener('pageshow', observeLayout); })();