import type {
  ElectronApi,
  ElectronWindow,
  LinuxScreenShareAudioRoutingInfo,
  LinuxScreenShareMonitorAudioChunkPayload,
  LinuxScreenShareMonitorAudioEndedPayload,
  LinuxScreenShareMonitorCaptureInfo
} from '../../../../core/platform/electron/electron-api.models';

export interface DesktopSource {
  id: string;
  name: string;
  thumbnail: string;
}

export interface ElectronDesktopSourceSelection {
  includeSystemAudio: boolean;
  source: DesktopSource;
}

export interface ElectronDesktopCaptureResult {
  includeSystemAudio: boolean;
  stream: MediaStream;
}

export type {
  LinuxScreenShareAudioRoutingInfo,
  LinuxScreenShareMonitorAudioChunkPayload,
  LinuxScreenShareMonitorAudioEndedPayload,
  LinuxScreenShareMonitorCaptureInfo
};

export type ScreenShareElectronApi = Partial<Pick<
  ElectronApi,
  | 'getSources'
  | 'prepareLinuxScreenShareAudioRouting'
  | 'activateLinuxScreenShareAudioRouting'
  | 'deactivateLinuxScreenShareAudioRouting'
  | 'startLinuxScreenShareMonitorCapture'
  | 'stopLinuxScreenShareMonitorCapture'
  | 'onLinuxScreenShareMonitorAudioChunk'
  | 'onLinuxScreenShareMonitorAudioEnded'
>>;

export type ElectronDesktopVideoConstraint = MediaTrackConstraints & {
  mandatory: {
    chromeMediaSource: 'desktop';
    chromeMediaSourceId: string;
    maxWidth: number;
    maxHeight: number;
    maxFrameRate: number;
  };
};

export type ElectronDesktopAudioConstraint = MediaTrackConstraints & {
  mandatory: {
    chromeMediaSource: 'desktop';
    chromeMediaSourceId: string;
  };
};

export interface ElectronDesktopMediaStreamConstraints extends MediaStreamConstraints {
  video: ElectronDesktopVideoConstraint;
  audio?: false | ElectronDesktopAudioConstraint;
}

export type ScreenShareWindow = ElectronWindow;
