/**
 * Typed event subscription helpers over the bridge's event map
 * (`MapmapNav.types.ts` §events). Work identically against the real native
 * handle (`native.ts`) and `MapmapNavMock` — both satisfy
 * `MapmapNavEmitterLike`.
 */
import type {
  BridgeError,
  GuidanceEvent,
  MapmapNavEvents,
  TerritoryProgressEvent,
  VoiceStateEvent,
} from "./MapmapNav.types";
import type { MapmapNavEmitterLike } from "./emitter";

export type { EventSubscription } from "expo-modules-core";
import type { EventSubscription } from "expo-modules-core";

export function addGuidanceListener(
  handle: MapmapNavEmitterLike<MapmapNavEvents>,
  listener: (event: GuidanceEvent) => void
): EventSubscription {
  return handle.addListener("guidance", listener);
}

export function addTerritoryProgressListener(
  handle: MapmapNavEmitterLike<MapmapNavEvents>,
  listener: (event: TerritoryProgressEvent) => void
): EventSubscription {
  return handle.addListener("territoryProgress", listener);
}

export function addVoiceStateListener(
  handle: MapmapNavEmitterLike<MapmapNavEvents>,
  listener: (event: VoiceStateEvent) => void
): EventSubscription {
  return handle.addListener("voiceState", listener);
}

export function addBridgeErrorListener(
  handle: MapmapNavEmitterLike<MapmapNavEvents>,
  listener: (event: BridgeError) => void
): EventSubscription {
  return handle.addListener("bridgeError", listener);
}
