/// <reference types="vite/client" />

interface ImportMetaEnv {
  readonly VITE_TMDB_API_KEY?: string
  readonly VITE_FANART_API_KEY?: string
}

interface ImportMeta {
  readonly env: ImportMetaEnv
}

/* ── Browser API extensions ── */

interface Navigator {
  mediaCapabilities?: {
    decodingInfo(configuration: unknown): Promise<unknown>
  }
}

interface VideoPlaybackQuality {
  droppedVideoFrames: number
}

interface HTMLVideoElement {
  getVideoPlaybackQuality?(): VideoPlaybackQuality
  audioTracks?: { length: number; [i: number]: { enabled: boolean } }
  mozPreservesPitch?: boolean
  webkitPreservesPitch?: boolean
}

interface Document {
  pictureInPictureElement?: Element | null
  exitPictureInPicture?(): Promise<void>
}

interface Window {
  webkitAudioContext?: typeof AudioContext
  SubtitlesOctopus?: unknown
}

/* eslint-disable @typescript-eslint/no-empty-object-type */
declare module 'react' {
  interface CSSProperties {
    WebkitUserSelect?: string
  }
}

/* ── Extended Jellyfin item with synthetic TMDB fields ── */

import type { BaseItemDto } from '@jellyfin/sdk/lib/generated-client/models'

type SyntheticBaseItemDto = BaseItemDto & {
  _tmdbPoster?: string
  _tmdbBackdrop?: string
  _inLibrary?: boolean
  _tmdbId?: string
  _kind?: string
}

declare module '@jellyfin/sdk/lib/generated-client/models' {
  interface BaseItemDto {
    _tmdbPoster?: string
    _tmdbBackdrop?: string
    _inLibrary?: boolean
    _tmdbId?: string
    _kind?: string
  }
}
