/**
 * Shared app-level types used across state stores and the screen manifest.
 * Re-exports the bridge contract types builders will already recognise,
 * plus a handful of app-only types that don't belong in the read-only
 * contract file.
 */
import type {
  BridgeError,
  GuidanceEvent,
  Route,
  RouteProfile,
  RouteResult,
  SearchResult,
  TerritoryInfo,
  TerritoryPhase,
  TerritorySummary,
} from "../../modules/mapmap-react-native/src/MapmapNav.types";

export type {
  BridgeError,
  GuidanceEvent,
  Route,
  RouteProfile,
  RouteResult,
  SearchResult,
  TerritoryInfo,
  TerritoryPhase,
  TerritorySummary,
};

/** A place chosen from search or the map — same shape as a search result. */
export type SelectedPlace = SearchResult;

export type Units = "km" | "mi";

export type MapTheme = "light" | "dark";

export type AppSettings = {
  voiceMuted: boolean;
  /** 0..1 */
  volume: number;
  units: Units;
  keepAwake: boolean;
  /** Map layer preferences (Explore/Preview). */
  show3dBuildings: boolean;
  showPois: boolean;
  mapTheme: MapTheme;
};

export const defaultSettings: AppSettings = {
  voiceMuted: false,
  volume: 1,
  units: "km",
  keepAwake: true,
  show3dBuildings: true,
  showPois: true,
  mapTheme: "light",
};

export type RecentSearch = SearchResult & { searchedAtEpochMs: number };

export type TerritoryInstallState = {
  territoryId: string;
  phase: TerritoryPhase;
  bytesDone: number;
  bytesTotal: number;
  error?: BridgeError;
};

export type JourneyStats = {
  durationSeconds: number;
  distanceMeters: number;
};
