import type { Lexics, Episodes } from 'requests'

import type { Match } from 'features/Matches'

import type { MatchPlaylistIds } from './helpers/buildPlaylists'

export enum PlaylistTypes {
  MATCH,
  PLAYER,
  INTERVIEW,
  EVENT,
}

export type MatchPlaylistOption = {
  duration?: number,
  episodes: Episodes,
  id: MatchPlaylistIds,
  lexic: number | string,
  type: PlaylistTypes.MATCH,
}

export type PlayerPlaylistOption = {
  dur: number,
  episodes: Episodes,
  gk?: boolean,
  id: number,
  name_eng: string,
  name_rus: string,
  num: string,
  start?: boolean,
  type: PlaylistTypes.PLAYER,
}

export type InterviewPlaylistOption = {
  episodes: Episodes,
  id: number,
  name_eng: string,
  name_rus: string,
  type: PlaylistTypes.INTERVIEW,
}

export type EventPlaylistOption = {
  episodes: Episodes,
  id: number,
  type: PlaylistTypes.EVENT,
}

export type PlaylistOption = (
  MatchPlaylistOption
  | PlayerPlaylistOption
  | InterviewPlaylistOption
  | EventPlaylistOption
)

export type InterviewPlaylistOptions = Array<InterviewPlaylistOption>
export type MatchPlaylistOptions = Array<MatchPlaylistOption>
export type PlayerPlaylistOptions = Array<PlayerPlaylistOption>

export type Playlists = {
  interview: InterviewPlaylistOptions,
  lexics?: Lexics,
  match: MatchPlaylistOptions,
  players: {
    team1: PlayerPlaylistOptions,
    team2: PlayerPlaylistOptions,
  },
  score1: number,
  score2: number,
  state?: string,
}

export type TournamentData = {
  matchDates: Array<string>,
  matches: Array<Match>,
}
