/**
 * Data model types for the Flights Map feature.
 *
 * Covers API request/response shapes, map marker/polyline props,
 * and filter state.
 *
 * @module
 */

// ---------------------------------------------------------------------------
// API request types
// ---------------------------------------------------------------------------

/**
 * Parameters for GET destinations/1 search.
 */
export interface FlightsMapSearchParams {
  departure: string;
  arrival?: string | undefined;
  dateFrom: string;
  dateTo: string;
  connections?: number | undefined;
}

/**
 * Parameters for GET days/{date}/200/{route}/flights-map/v1 calendar.
 */
export interface FlightsMapCalendarParams {
  date: string;
  departure: string;
  arrival?: string | undefined;
  connections: boolean;
}

// ---------------------------------------------------------------------------
// API response types
// ---------------------------------------------------------------------------

/**
 * A single flight route from the destinations API.
 */
export interface IFlightRoute {
  route: string[];
  isDirect: boolean;
}

/**
 * Response from GET destinations/1.
 */
export interface IDestinationsResponse {
  data: {
    routes: IFlightRoute[];
  };
}

/**
 * Response from GET days/.../flights-map/v1.
 * The `days` field is a string of "0" and "1" characters, one per day.
 */
export interface IFlightsMapDaysResponse {
  days: string;
}

// ---------------------------------------------------------------------------
// Map component prop types
// ---------------------------------------------------------------------------

/**
 * Marker style variant for the map.
 */
export type MarkerStyle = "blue" | "blue-small" | "orange";

/**
 * A marker to render on the map.
 *
 * When `zoomLevel` and `countryType` are both set, MapCanvas places the
 * marker into the categorized-rendering flow (10 LayerGroups keyed by
 * countryType × zoomLevel). Otherwise the marker renders via the legacy
 * flat-layer flow.
 *
 * When `highlighted` is true, the marker is forced into the always-on
 * highlight layer with an orange icon regardless of `style` and
 * `zoomLevel`.
 */
export interface IMapMarker {
  id: string;
  lat: number;
  lng: number;
  style: MarkerStyle;
  label?: string | undefined;
  tooltipPermanent?: boolean | undefined;
  zoomLevel?: number | undefined;
  countryType?: "ru" | "other" | undefined;
  highlighted?: boolean | undefined;
}

/**
 * Polyline style variant for the map.
 */
export type PolylineStyle = "direct" | "connecting";

/**
 * A polyline to render on the map.
 *
 * Cities are referenced by code; MapCanvas resolves coordinates via its
 * internal markerIndex and filters out cities whose marker is not currently
 * on the map (matches Angular `drawPolyline` behavior).
 */
export interface IMapPolyline {
  id: string;
  cityIds: string[];
  style: PolylineStyle;
}

/**
 * Popup content to show on the map.
 */
export interface IMapPopup {
  lat: number;
  lng: number;
  content: string;
}

// ---------------------------------------------------------------------------
// Filter state
// ---------------------------------------------------------------------------

/**
 * State shape for the flights map filter.
 */
export interface IFlightsMapFilterState {
  departure?: string | undefined;
  arrival?: string | undefined;
  date?: string | undefined;
  connections: boolean;
  domestic: boolean;
  international: boolean;
}
