// RemoteRig TypeScript types

/** Full camera status from GET /api/v1/cameras and SSE events */
export interface CameraStatus {
  camera_id: string
  friendly_name: string
  battery_pct: number | null
  video_remaining_sec: number | null
  recording: boolean
  mode: string
  resolution: string
  fps: number
  online: boolean
  last_seen: string // ISO 8601
}

/** SSE event envelope from /api/v1/events/stream */
export interface SSEEvent {
  type: string
  ts: string
  payload?: unknown
}

/** A single status log entry from GET /api/v1/cameras/{id} */
export interface StatusLog {
  id: number
  camera_id: string
  recorded_at: string
  battery_pct: number | null
  video_remaining_sec: number | null
  recording_state: number // 0 or 1 (SQLite bool)
  mode: string
  resolution: string
  fps: number
  online: number // 0 or 1
  raw_battery_pct: number | null
}

/** Camera detail response from GET /api/v1/cameras/{id} */
export interface CameraDetail {
  camera: CameraInfo
  last_status: StatusLog
  history: StatusLog[]
}

export interface CameraInfo {
  CameraID: string
  FriendlyName: string
  MacAddress: string | null
  CreatedAt: string
  UpdatedAt: string
}

/** Generic API responses */
export interface StartStopResponse {
  status: string
  camera_id: string
}

export interface Camera {
  id: string
  name: string
  streamUrl: string
  status: 'online' | 'offline' | 'error' | 'connecting'
  position?: string
  fps: number
  resolution?: string
  recording: boolean
}

export interface CameraFeed {
  cameraId: string
  thumbnailUrl?: string
  frameRate: number
  bitrate?: string
}

export interface SystemHealth {
  cpuUsage: number
  memoryUsage: number
  gpuUsage: number
  temperature: number
  uptime: string
}

export interface StreamConfig {
  width: number
  height: number
  fps: number
  codec: string
  bitrate: string
}
