/**
 * Which bookmark list the map is currently scoped to.
 *
 * Module state rather than a route prop because `m-map` lives outside the
 * router's `main` landmark — it persists across navigations, so it can't
 * receive the active list as an attribute. Set by "View on map" on a list's
 * own page (`routes/list.ts`) and cleared by the "Clear" button `m-map.ts`
 * shows while it's active — not tied to any route. Mirrors `utils/nav.ts`.
 */
export const LIST_FILTER_EVENT = 'list-filter'

let activeListId: string | null = null

export function getListFilter(): string | null {
  return activeListId
}

export function setListFilter(id: string | null): void {
  if (id === activeListId) return
  activeListId = id
  globalThis.dispatchEvent(new CustomEvent(LIST_FILTER_EVENT))
}
