export interface SeedConfig {
  event_device_id: string;
  primary_api_base_url: string;
  backup_api_base_url: string | null;
  onsite_api_base_url: string | null;
  aether_api_key: string;
}

export interface AetherNativeBridge {
  get_seed_config: () => Promise<SeedConfig | null>;
  get_device_config: () => Promise<any>;
  get_jwt: () => Promise<string | null>;
  get_device_info: () => Promise<any>;

  // Shell Handlers
  open_folder: (path: string) => Promise<{success: boolean, error?: string}>;
  run_cmd: (args: {cmd: string, timeout?: number}) => Promise<{success: boolean, stdout: string, stderr: string, error?: string}>;
  run_cmd_sync: (args: {cmd: string}) => Promise<{success: boolean, stdout: string, error?: string, stderr?: string}>;
  run_osascript: (script: string) => Promise<{success: boolean, stdout: string, stderr: string, error?: string}>;
  kill_processes: (args: {process_name_li: string[]}) => Promise<{success: boolean, results: any[]}>;
  open_local_file_v2: (path: string) => Promise<{success: boolean, error?: string}>;

  // File/Cache Handlers
  check_cache: (args: {cache_root: string, hash: string, hash_prefix_length?: number}) => Promise<boolean>;
  download_to_cache: (args: {url: string, cache_root: string, hash: string, api_key: string, account_id?: string, hash_prefix_length?: number}) => Promise<{success: boolean, error?: string}>;
  copy_from_cache_to_temp: (args: {cache_root: string, hash: string, temp_root: string, filename: string, hash_prefix_length?: number}) => Promise<{success: boolean, path?: string, error?: string}>;
  launch_from_cache: (args: {cache_root: string, hash: string, temp_root: string, filename: string, hash_prefix_length?: number, native_template?: string}) => Promise<{success: boolean, error?: string}>;

  // Specialized Presentation Handlers (Phase 5)
  launch_presentation: (args: {path: string, app?: string}) => Promise<{success: boolean, error?: string, stdout?: string, stderr?: string}>;
  control_presentation: (args: {app: 'powerpoint' | 'keynote', action: 'next' | 'prev' | 'start' | 'stop'}) => Promise<{success: boolean, error?: string, stdout?: string, stderr?: string}>;

  // System Handlers (Phase 5)
  window_control: (args: {action: 'maximize' | 'unmaximize' | 'minimize' | 'restore' | 'close' | 'devtools' | 'kiosk' | 'fullscreen' | 'reload', value?: boolean}) => Promise<{success: boolean, error?: string}>;
  set_wallpaper: (args: {path: string}) => Promise<{success: boolean, error?: string, stdout?: string, stderr?: string}>;
  power_control: (args: {action: 'shutdown' | 'reboot' | 'sleep'}) => Promise<{success: boolean, error?: string}>;
  open_external: (args: {url: string, app?: 'chrome' | 'firefox'}) => Promise<{success: boolean, error?: string}>;
  manage_recording: (args: {action: 'start' | 'stop' | 'status', options?: {fps?: number, audioDeviceId?: string, output?: string}}) => Promise<{success: boolean, isRecording?: boolean, pid?: number, error?: string}>;
  set_display_layout: (args: {mode: 'mirror' | 'extend', configStr?: string | null}) => Promise<{success: boolean, error?: string, stdout?: string, stderr?: string}>;
  update_app: (args: {source: 'url' | 'file', url?: string, path?: string}) => Promise<{success: boolean, message?: string, downloadedPath?: string, error?: string}>;

  // Self-Documentation
  list_tools: () => Promise<Array<{name: string, description: string, params: object}>>;
}

declare global {
  interface Window {
    aetherNative: AetherNativeBridge;
  }
}
