/**
 * Data model types for the Schedule feature.
 *
 * Reuses flight types from online-board where possible.
 * Schedule-specific types cover the different URL/API param shapes.
 *
 * @module
 */

import type { IFlight, ISimpleFlight, IBoardResponse, IFlightLeg } from "../online-board/types.js";

// Re-export shared flight types used by schedule
export type { IFlight, ISimpleFlight, IBoardResponse, IFlightLeg };

// ---------------------------------------------------------------------------
// URL parameter types
// ---------------------------------------------------------------------------

/**
 * Parsed route direction params from a single URL segment.
 * Format: {dep}-{arr}-{dateFrom}-{dateTo}[-{timeFromTo}][-C{connections}]
 */
export interface IScheduleRouteDirectionParams {
  departure: string;
  arrival: string;
  dateFrom: string;
  dateTo: string;
  timeFrom?: string;
  timeTo?: string;
  connections?: number;
}

/**
 * Full parsed schedule route params (one-way or round-trip).
 */
export interface IScheduleRouteParams {
  outbound: IScheduleRouteDirectionParams;
  inbound?: IScheduleRouteDirectionParams;
}

/**
 * Parsed flight ID for schedule details (reuses online-board's IParsedFlightId shape).
 */
export interface IScheduleFlightId {
  carrier: string;
  flightNumber: string;
  suffix?: string;
  date: string;
}

/**
 * Parsed details params from the catch-all URL.
 */
export interface IScheduleDetailsParams {
  flights: IScheduleFlightId[];
}

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

/**
 * Parameters for POST schedule/1 search.
 */
export interface IScheduleSearchRequest {
  departure: string;
  arrival: string;
  dateFrom: string;
  dateTo: string;
  timeFrom?: string;
  timeTo?: string;
  connections?: number;
  attribute?: 1 | 2;
}

/**
 * Schedule search API response -- array of flights.
 */
export type IScheduleResponse = IFlight[];

/**
 * Schedule details API response -- same as online board response.
 */
export type IScheduleDetailsResponse = IBoardResponse;

/**
 * Parameters for GET days/.../schedule/v1 calendar endpoint.
 */
export interface IScheduleCalendarParams {
  date: string;
  departure: string;
  arrival: string;
  connections: boolean;
}

/**
 * Calendar days API response.
 */
export interface IScheduleDaysResponse {
  days: string;
}
