/**
 * `mapmap-react-native` module JS API (T3, CONTRACTS.md §2/§Task-plan).
 *
 * Two interchangeable handles implement `MapmapNavModule`:
 *  - `MapmapNav` — the real native-backed module (`native.ts`).
 *  - `MapmapNavMock` — a pure-TS simulator with no native dependency
 *    (`mock.ts`), for Expo Go, Storybook-style UI work, and tests.
 *
 * `getMapmapNav(useMock)` picks between them.
 */
import { MapmapNav } from "./native";
import { createMapmapNavMock } from "./mock";
import type { MapmapNavMockOptions } from "./mock";
import type { MapmapNavEmitterLike } from "./emitter";
import type { MapmapNavEvents, MapmapNavModule } from "./MapmapNav.types";

export * from "./MapmapNav.types";
export { MapmapNav } from "./native";
export type { NativeMapmapNavModule } from "./native";
export { MapmapNavMock, createMapmapNavMock } from "./mock";
export type { MapmapNavMockOptions } from "./mock";
export {
  addBridgeErrorListener,
  addGuidanceListener,
  addTerritoryProgressListener,
  addVoiceStateListener,
} from "./events";
export type { EventSubscription } from "./events";
export type { MapmapNavEmitterLike } from "./emitter";

/** Combined shape returned by `getMapmapNav`: the promise-based API plus the typed event emitter. */
export type MapmapNavHandle = MapmapNavModule & MapmapNavEmitterLike<MapmapNavEvents>;

/**
 * Resolves either the real native-backed module or the pure-TS mock.
 * Pass `useMock: true` in Expo Go, unit tests, and any UI work happening
 * ahead of a native build.
 */
export function getMapmapNav(useMock: boolean, mockOptions?: MapmapNavMockOptions): MapmapNavHandle {
  return useMock ? createMapmapNavMock(mockOptions) : MapmapNav;
}
