"use strict"; (function () { const params = new URLSearchParams(location.search || ""); const enabled = params.get("debug") === "1" || params.get("debug") === "true"; if (!enabled) return; const panel = document.createElement("div"); panel.id = "debugOverlay"; panel.style.cssText = [ "position:fixed", "left:8px", "top:76px", "z-index:99999", "min-width:230px", "max-width:360px", "font:11px/1.45 ui-monospace,SFMono-Regular,Menlo,monospace", "color:#f7fbff", "background:rgba(18,24,30,.78)", "border:1px solid rgba(255,255,255,.18)", "border-radius:10px", "padding:8px 10px", "pointer-events:none", "white-space:pre-wrap", "box-shadow:0 8px 24px rgba(0,0,0,.22)" ].join(";"); document.addEventListener("DOMContentLoaded", () => document.body.appendChild(panel)); let lastEvents = []; let lastAudio = []; window.TarinaiEvents?.on("*", ev => { lastEvents.unshift(ev.type); if (lastEvents.length > 10) lastEvents.length = 10; }); window.TarinaiEvents?.on("audio:play", ev => { lastAudio.unshift(`${ev.detail?.id || "?"}:${ev.detail?.category || "?"}`); if (lastAudio.length > 8) lastAudio.length = 8; }); window.setInterval(() => { const w = window.world; const perf = window.TarinaiPerformance?.debugSnapshot(w) || {}; const input = window.TarinaiInputMode?.snapshot?.() || {}; panel.textContent = [ `tarinai v${window.TARINAI_VERSION || "?"}`, `fps ${perf.fps ?? window.__tarinaiFps ?? "?"} perf ${perf.level ?? "?"}`, `items ${(w?.items || []).length} tarinai ${(w?.tarinai || []).length} ants ${(w?.ants || []).length}`, `effects ${(w?.effects || []).length}`, `terrain v${w?.terrainVersion ?? 0} spatial v${w?.spatialVersion ?? 0}`, `drawList ${(w?.drawList || []).length} logs ${(w?.logs || []).length}`, `dpr ${uiCache?.canvasDpr || "?"} cache ${window.TARINAI_APP?.cacheName || "?"}`, `sw ${navigator.serviceWorker?.controller ? "controlled" : "uncontrolled"} soundPack ${window.TarinaiAudio?.soundPackVersion || "?"}`, `input ${input.currentMode || "?"} touchFirst:${Boolean(input.touchFirst)} coarse:${Boolean(input.pointerCoarse)} hover:${Boolean(input.hasHover)} compact:${Boolean(input.isCompactViewport)} uaMobile:${Boolean(input.userAgentMobile)}`, `audio ${lastAudio.join(", ") || window.TarinaiAudio?.lastPlayedId || "-"}`, `effects ${window.TarinaiEffectRegistry?.debugSnapshot?.().length || 0} registered`, `events ${lastEvents.join(", ")}`, ].join("\n"); }, 500); })();