import { BookingPackageFlight } from '@qite/tide-client/build/types';

export interface Settings {
  officeId: number;
  token?: string;
  bookingOptions: BookingOptions;
  productPath: string;
  basePath: string;
  skipBasePathInRouting?: boolean;
  roomOptions: {
    isHidden?: boolean | null;
    pathSuffix?: string | null;
  };
  flightOptions: {
    isHidden?: boolean | null;
    pathSuffix?: string | null;
  };
  options: {
    pathSuffix: string;
    showRoomOptions?: boolean | null;
    reportPrintActionId?: number | null;
  };
  travellers: {
    pathSuffix: string;
    compactForm?: boolean;
    formFields?: FormField[];
    mainBookerFormFields?: FormField[];
    countries?: Country[];
    travelersFirstStep?: boolean;
    showAllCountries?: boolean;
  };
  summary: {
    pathSuffix: string;
    checkboxes?: SummaryCheckbox[] | null;
  };
  confirmation: {
    pathSuffix: string;
  };
  error: {
    pathSuffix: string;
  };
  language: string;
  includeFlights?: boolean;
  generatePaymentUrl?: boolean;
  skipPaymentWithAgent?: boolean;
  companyContactEmail: string;
  companyContactPhone: string;
  showProductCardRating: boolean;
  showSidebarDeposit: boolean;
  showCommission?: boolean;
  sidebarHeaderComponent?: JSX.Element | null;
  sidebarFooterComponent?: JSX.Element | null;
  loaderComponent?: JSX.Element | null;
  icons?: string | null;
  tagIds?: number[];
  agentRequired?: boolean;
  hideAgentSelection?: boolean;
  agentAdressId?: number;
  affiliateSlug?: string;
  enableVoucher?: boolean;
  skipRouter?: boolean;
  apiUrl?: string;
  apiKey?: string;
  hideTags?: boolean;
  translationFiles?: {
    language: string;
    path: string;
  }[];
  accommodations?: AccommodationContent[];
  regimes?: RegimeContent[];
  accommodationViewId?: number;
  isOffer?: boolean;
  allowOption?: boolean;
  customOptionStatus?: number;
  customValidateText?: string;
  showPricesPerPaxType?: boolean; // BasePrice split by pax type in summary and price details, show Price should be enabled
}

export interface FormField {
  type: string;
}

export interface Country {
  iso2: string;
  name: string;
  phonePrefix: string;
}

export interface BookingOptions {
  b2b: BookingOptionsDetail;
  b2b2c: BookingOptionsDetail;
  b2c: BookingOptionsDetail;
}

export interface BookingOptionsDetail {
  entryStatus: number;
  customEntryStatusId?: number;
  tagIds?: number[];
}

export interface SummaryCheckbox {
  id: string;
  text: string;
  isSelected: boolean;
}

export interface Traveler {
  id: number;
  gender: string;
  firstName: string;
  lastName: string;
  birthDate: string;
  age?: number;
}

export interface Room {
  adults: number;
  children: number;
  childAges: number[];
  accommodationCode?: string;
  regimeCode?: string;
}

export interface FlightInfo {
  outwardCode: string;
  outwardAirlines: string[] | null;
  outwardNumbers: string[];
  outwardFareCode: string | null;
  outwardMarketingName: string | null;
  outwardClass: string;
  outwardDepartureDate: string | null;
  outwardArrivalDate: string | null;
  returnCode: string;
  returnAirlines: string[] | null;
  returnNumbers: string[];
  returnFareCode: string | null;
  returnMarketingName: string | null;
  returnClass: string;
  returnDepartureDate: string | null;
  returnArrivalDate: string | null;
  luggageIncluded: boolean; // used to get correct flight from amadeus
}

export interface TravelersFormValues {
  rooms: TravelersFormRoomValues[];
  startDate?: string;
  mainBookerId: number;
  street: string;
  houseNumber: string;
  box: string;
  zipCode: string;
  place: string;
  country: string;
  phone: string;
  email: string;
  emailConfirmation: string;
  travelAgentId: number;
  travelAgentName: string;
}

export interface TravelersFormRoomValues {
  adults: Traveler[];
  children: Traveler[];
}

export interface ProductAttributes {
  productCode: string;
  productName: string;
}

export interface BookingAttributes {
  startDate: string;
  endDate: string;
  catalogueId: number;
  rooms: Room[];
  flight: FlightInfo | null;
  tourCode: string | null;
  allotmentName: string | null;
  allotmentIds: number[];
  includeFlights?: boolean;
  flightRouteId?: string | null;
  vendorConfigurationId?: number | null;
  searchConfigurationId?: number | null;
  productCode?: string;
  productName?: string;
}

export interface FlightLine {
  departureAirportIata?: string;
  departureAirportDescription?: string;
  departureDate?: string;
  departureTime?: string;
  arrivalAirportIata?: string;
  arrivalAirportDescription?: string;
  arrivalDate?: string;
  arrivalTime?: string;
  airlineIata?: string;
  airlineDescription?: string;
  airlineNumber?: string;
  travelClass?: string;
  number?: string;
  airlineCode?: string;
}

export interface AccommodationContent {
  code: string;
  title: string;
  imageUrl: string;
  usps: string[];
  description: string | undefined;
}

export interface RegimeContent {
  code: string;
  title: string;
}

export interface SelectableRoom {
  index: number;
  selected: SelectableRoomAccommodation;
  alternatives: SelectableRoomAccommodation[];
}

export interface SelectableRoomAccommodation {
  code: string;
  regimeCode: string;
  from: string;
  to: string;
  price: number;
  regimes: SelectableRoomRegime[];
  title: string;
  image: string | undefined;
  usps: string[];
  description: string | undefined;
  viewHtml: string | undefined;
}

export interface SelectableRoomRegime {
  code: string;
  title: string;
  price: number;
}

export interface GroupedFlights {
  isSelected: boolean;
  price: number;

  outward: GroupedFlightDetails;
  return: GroupedFlightDetails;

  selectedOutward: BookingPackageFlight;
  selectedReturn: BookingPackageFlight;
}

export interface GroupedFlightDetails {
  airlineCode: string;
  airline: string;
  departureDate: string;
  departureTime: string;
  departureAirportCode: string;
  departureAirport: string;
  arrivalDate: string;
  arrivalTime: string;
  arrivalAirport: string;
  changeDurationMinutes: number;
  travelDurationMinutes: number;
  travelDuration: string;
  numberOfStops: number;
  isNextDay: boolean;
  travelClass: string;
  flightLines: GroupedFlightLine[];
}

export interface GroupedFlightLine {
  airline: string;
  number: string;
  departureDate: string;
  departureTime: string;
  departureAirport: string;
  arrivalDate: string;
  arrivalTime: string;
  arrivalAirport: string;
  travelDuration: string;
  waitDuration: string | undefined;
}

export interface FlightFilterOptions {
  airports: FlightFilterOption[];
  airlines: FlightFilterOption[];
  numberOfStops: FlightFilterOption[];
  outward: FlightDirectionFilter;
  return: FlightDirectionFilter;
}

export interface FlightFilterOption {
  value: string;
  label: string;
  count: number;
  isSelected: boolean;
}

export interface FlightDirectionFilter {
  departurePeriod: FlightFilterOption[];
  travelDuration: TimeRangeFilter;
  changeDuration: TimeRangeFilter;
}

export interface TimeRangeFilter {
  min: number;
  max: number;

  selectedMin: number;
  selectedMax: number;
}

export interface RoomTraveler {
  id: number;
  age: number;
}

export interface PricePerPaxType {
  paxType: string;
  pricePerPaxType: number;
  numberOfPax: number;
  details: PriceDetailsPerPaxType[];
}

export interface PriceDetailsPerPaxType {
  numberOfPax: number;
  description: string;
  price: number;
  paxIds: number[];
}
