import type { Page } from "./urlState";

// Tiny decoupled navigator so deep components (a feed card's download toast, the Download
// Center) can switch pages without threading setPage through the whole tree. App registers
// its setPage on mount; navigateTo is a no-op until then.
let _navigate: ((p: Page) => void) | null = null;

export function setNavigator(fn: (p: Page) => void): void {
  _navigate = fn;
}

export function navigateTo(p: Page): void {
  _navigate?.(p);
}
