// Core domain types shared across the whole transcription engine.
// Kept tiny and dependency-free so every pure module can import from here
// without pulling in React Native, Expo, or any platform code.

/** Whisper always works at 16 kHz mono. */
export const WHISPER_SAMPLE_RATE = 16000 as const;

/**
 * A contiguous transcribed segment. Times are in SECONDS and, once a media
 * file has been fully processed, ABSOLUTE to the whole media (post-stitch).
 * Engine implementations emit chunk-local times (0-based per chunk); the pure
 * pipeline offsets and stitches them into absolute time.
 */
export interface Segment {
  /** Inclusive start time in seconds. */
  start: number;
  /** Exclusive end time in seconds. */
  end: number;
  /** Recognized text for this segment (already trimmed). */
  text: string;
  /** Optional confidence in [0,1], derived from avg token logprob when available. */
  confidence?: number;
}

/** Decoded audio ready for Whisper: 16 kHz, mono, normalized to [-1, 1]. */
export interface PcmAudio {
  readonly sampleRate: typeof WHISPER_SAMPLE_RATE;
  readonly samples: Float32Array;
}

/** The Whisper model variants we expose. `.en` = English-only (smaller/faster). */
export type ModelId =
  | 'tiny.en'
  | 'tiny'
  | 'base.en'
  | 'base'
  | 'small.en'
  | 'small';

export interface TranscribeOptions {
  modelId: ModelId;
  /** ISO language code; undefined => auto-detect (multilingual models only). */
  language?: string;
  /** Translate the result to English (multilingual models only). */
  translate?: boolean;
}

/** Which compute backend an engine resolved to, for UX and model gating. */
export type Backend = 'coreml' | 'metal' | 'cpu' | 'webgpu' | 'wasm';
