// Client -> Server messages
export type StartMessage = {
  type: "start";
  sampleRate: number;
  channels: number;
  encoding: "pcm32f" | "pcm16";
};

export type StopMessage = {
  type: "stop";
  reason?: string;
};

export type ClientMessage = StartMessage | StopMessage;

// Server -> Client messages
export type ReadyMessage = {
  type: "ready";
  sessionId: string;
};

export type TranscriptMessage = {
  type: "transcript";
  speaker: string;
  start: number;
  end: number;
  text: string;
  isFinal: boolean;
};

export type ErrorMessage = {
  type: "error";
  code: string;
  message: string;
};

export type StoppedMessage = {
  type: "stopped";
  reason: string;
};

export type ServerMessage =
  | ReadyMessage
  | TranscriptMessage
  | ErrorMessage
  | StoppedMessage;

// Transcript entry for display
export interface TranscriptEntry {
  id: string;
  speaker: string;
  start: number;
  end: number;
  text: string;
  isFinal: boolean;
}
