interface TwitchAuth {
  channelId: string;
  clientId: string;
  token: string;
  userId: string;
  helixToken?: string;
}

interface TwitchContext {
  game: string;
  language: string;
  mode: 'viewer' | 'dashboard' | 'config';
  isFullScreen: boolean;
  isPaused: boolean;
  theme: 'light' | 'dark';
  arePlayerControlsVisible: boolean;
  bitrate: number;
  bufferSize: number;
  displayResolution: string;
  videoCurrentTime: number;
  videoDuration: number;
  videoResolution: string;
  hlsLatencyBroadcaster: number;
}

interface TwitchExt {
  onAuthorized(callback: (auth: TwitchAuth) => void): void;
  onContext(
    callback: (context: TwitchContext, changed: (keyof TwitchContext)[]) => void
  ): void;
  onVisibilityChanged(
    callback: (isVisible: boolean, context: TwitchContext) => void
  ): void;
  listen(
    target: string,
    callback: (target: string, contentType: string, message: string) => void
  ): void;
  unlisten(
    target: string,
    callback: (target: string, contentType: string, message: string) => void
  ): void;
  send(target: string, contentType: string, message: object): void;
}

interface Window {
  Twitch?: { ext: TwitchExt };
}
