// Every page: client errors → server (E3); hide the sticky bar while a field has focus (keyboard open on phones). import { reportErrors, whenVisible, idle } from '/engine/engine.js'; reportErrors(); // Lazy modules carry this file's ?v= so a new deploy never mixes old and new code (unversioned files cache 1 h). const V = new URL(import.meta.url).search; // Hero scene: pulses run only while on screen (engine data-off pauses them when it leaves, E22). const scene = document.querySelector('.scene'); if (scene) { scene.classList.add('live'); whenVisible(scene); } // Coverage map: halo pulses only while on screen. for (const m of document.querySelectorAll('.map')) { m.classList.add('live'); whenVisible(m); } // Drag / zoom for the map, loaded only where a map exists. if (document.querySelector('figure[data-map]')) import('/js/map.mjs' + V).then((m) => m.start()).catch((e) => globalThis.reportError?.(e)); // Visitor area detection, loaded only on pages that use it. if (document.querySelector('[data-loc-btn],[data-loc],[data-city]')) import('/js/loc.mjs' + V).then((m) => m.start()).catch((e) => globalThis.reportError?.(e)); // Typeable car picker + /mobil table filter, only where present. if (document.querySelector('select[data-pick],input[data-filter]')) import('/js/pick.mjs' + V).then((m) => m.start()).catch((e) => globalThis.reportError?.(e)); // Kelurahan search: module loaded only where the box exists; its data file only on first focus. if (document.querySelector('[data-cari]')) import('/js/cari.mjs' + V).then((m) => m.start()).catch((e) => globalThis.reportError?.(e)); const root = document.documentElement; document.addEventListener('focusin', (e) => { if (e.target.matches?.('input,select,textarea')) root.classList.add('kb'); }); document.addEventListener('focusout', () => root.classList.remove('kb')); // Real-user Core Web Vitals (owner #54), loaded when the browser is idle; observers are buffered so nothing is missed. idle(() => import('/js/vitals.mjs' + V).then((m) => m.start()).catch((e) => globalThis.reportError?.(e))); // Instant repeat visits (owner #55): pages seen before open from the phone, refreshed quietly in the background (public/sw.js). if ('serviceWorker' in navigator && location.protocol !== 'file:') idle(() => navigator.serviceWorker.register('/sw.js').catch(() => {}));