"use client"; /** * Typed window-event bus for preview-panel actions. Lets the global * keybinding handler in `routes/_chat.tsx` reach `ChatView`'s URL-aware * arbitration without prop drilling or shared refs. */ export type PreviewAction = | "toggle-panel" | "refresh" | "focus-url" | "zoom-in" | "zoom-out" | "reset-zoom"; const EVENT_NAME = "t3code:preview-action"; export function dispatchPreviewAction(action: PreviewAction): void { if (typeof window === "undefined") return; window.dispatchEvent(new CustomEvent(EVENT_NAME, { detail: action })); } export function subscribePreviewAction(listener: (action: PreviewAction) => void): () => void { if (typeof window === "undefined") return () => {}; const handler = (event: Event) => { const detail = (event as CustomEvent).detail; if (typeof detail === "string") listener(detail); }; window.addEventListener(EVENT_NAME, handler); return () => window.removeEventListener(EVENT_NAME, handler); }