/** Opt-in input diagnostics. Never record content, field values, URLs, or typed keys. */ export function traceSecondaryClick(build: string) { const panel = document.createElement('pre'); panel.style.cssText = 'position:fixed;bottom:6px;right:6px;z-index:2147483647;margin:0;padding:10px;max-width:95vw;white-space:pre-wrap;background:#211c28;color:#fff;border-radius:6px;font:12px/1.45 monospace;pointer-events:none'; const rows: string[] = []; const title = `albedo input trace ยท ${build}\n`; panel.textContent = title + 'waiting for ctrl + right-click'; document.body.append(panel); function record(text: string) { rows.push(text); if (rows.length > 9) rows.shift(); panel.textContent = title + rows.join('\n'); } for (const type of ['keydown', 'keyup'] as const) { window.addEventListener( type, (event) => { if (event.key === 'Control' && !event.repeat) record(`${type}: Control`); }, true, ); } for (const type of [ 'pointerdown', 'mousedown', 'pointerup', 'contextmenu', ] as const) { window.addEventListener( type, (event) => { if (event.button === 0 && !event.ctrlKey && type !== 'contextmenu') return; const under = event.target instanceof Element ? event.target : null; const region = under?.closest('.window-slot')?.getAttribute('data-place') ?? under?.tagName ?? '?'; const mods = [ event.shiftKey && 'shift', event.ctrlKey && 'ctrl', event.altKey && 'alt', event.metaKey && 'meta', ] .filter(Boolean) .join('+') || 'none'; const button = event.button; // Observe the final state without changing or intercepting the gesture. setTimeout( () => record( `${type}: button=${button} mods=${mods} ${region} ${event.cancelable ? (event.defaultPrevented ? 'canceled' : 'allowed') : 'not cancelable'}`, ), 0, ); }, true, ); } window.addEventListener('blur', () => setTimeout( () => record( document.activeElement instanceof HTMLIFrameElement ? 'focus left for an iframe' : 'window lost focus', ), 0, ), ); }