export type SimpleAlignedLyric = {
  text: string;
  startSeconds: number;
  endSeconds: number;
};

export type AlignedRangeLyric = {
  text: string;
  dirty: boolean;
  timing: {
    type: 'range';
    startSeconds: number;
    endSeconds: number;
  };
};

export type AlignedPointLyric = {
  text: string;
  dirty: boolean;
  timing: {
    type: 'point';
    seconds: number;
  };
};

export type AlignedUntimedLyric = {
  text: string;
  dirty: boolean;
  timing: null;
};

export type AlignedLyric =
  | AlignedRangeLyric
  | AlignedPointLyric
  | AlignedUntimedLyric;

export type LyricsCorrection = {
  startSeconds: number;
  endSeconds: number;
  alignedLyrics: AlignedLyric[];
};

export type LyricsCorrectionsByClipId = Record<string, LyricsCorrection[]>;

export default function fixLyricsCorrectionsByClipId(
  lyricsCorrectionsByClipId: unknown
): LyricsCorrectionsByClipId {
  if (
    typeof lyricsCorrectionsByClipId !== 'object' ||
    lyricsCorrectionsByClipId === null
  ) {
    return {};
  }
  return lyricsCorrectionsByClipId as LyricsCorrectionsByClipId;
}
