export type TaskStatus =
  | 'queued'
  | 'extracting'
  | 'vad_processing'
  | 'transcribing'
  | 'translating'
  | 'completed'
  | 'failed'

export type TargetLanguage = 'zh' | 'en'
export type OutputMode = 'source' | 'translate'

export interface SubtitleSegment {
  id: string
  taskId: string
  start: number
  end: number
  sourceText: string
  translatedText?: string | null
}

export interface SubtitleTask {
  id: string
  filePath: string
  fileName: string
  sourceLang?: string | null
  targetLang: TargetLanguage
  outputMode: OutputMode
  bilingualOutput: boolean
  status: TaskStatus
  progress: number
  segments: SubtitleSegment[]
  error?: string | null
}

export interface TranslationConfig {
  apiBase: string
  apiKey: string
  model: string
  batchSize: number
  contextSize: number
}

export interface DefaultModelPaths {
  whisperModelPath: string
  vadModelPath: string
}

export interface StartTaskPayload {
  filePath: string
  sourceLang?: string | null
  targetLang: TargetLanguage
  outputMode: OutputMode
  bilingualOutput: boolean
  translationConfig?: TranslationConfig | null
  whisperModelPath?: string | null
  vadModelPath?: string | null
}

export interface ProgressEvent {
  taskId: string
  status: TaskStatus
  progress: number
  message: string
}

export interface SegmentEvent {
  taskId: string
  segment: SubtitleSegment
}

export interface ErrorEvent {
  taskId: string
  message: string
}

export interface LogEvent {
  taskId: string
  message: string
}

export interface ResetSegmentsEvent {
  taskId: string
}
