import {getStandeeSet, type AvatarDefinition} from "../../standee-sets";

export type VoicevoxVoice = Readonly<{
  speakerName: string;
  styleName: string;
}>;

export type CharacterDefinition = Readonly<{
  displayName: string;
  voicevox: VoicevoxVoice;
  avatar: AvatarDefinition;
}>;

export const characters = {
  sayo: {
    displayName: "小夜",
    voicevox: {
      speakerName: "小夜/SAYO",
      styleName: "ノーマル",
    },
    avatar: {
      ...getStandeeSet("sayo_ohnegus_ai"),
      accentColor: "#6b5f83",
      speakingAnimationType: "rhubarbLipSync",
      idleAnimationType: "none",
    },
  },
} as const satisfies Record<string, CharacterDefinition>;

export type CharacterId = keyof typeof characters;

export type SpeechOptions = Readonly<{
  subtitle?: string;
  voicevox?: Partial<VoicevoxVoice>;
  durationSeconds?: number;
}>;

export type SpeechEvent = Readonly<{
  type: "say";
  id: string;
  character: CharacterId;
  text: string;
  subtitle?: string;
  voicevox?: Partial<VoicevoxVoice>;
  durationSeconds?: number;
}>;

export type TimelineEvent = SpeechEvent;

export const say = (
  id: string,
  character: CharacterId,
  text: string,
  options: SpeechOptions = {}
): SpeechEvent => ({
  type: "say",
  id,
  character,
  text,
  ...options,
});

export const timeline = [
  say("pizza-oven-project-01-sayo-001", "sayo", "こんにちは。小夜です。"),
  say("pizza-oven-project-01-sayo-002", "sayo", "ピザって美味しいじゃないですか。"),
  say("pizza-oven-project-01-sayo-003", "sayo", "だから、作る事にしたんですよね。"),
  say("pizza-oven-project-01-sayo-004", "sayo", "ピザ窯を。"),
] satisfies TimelineEvent[];

export const script = timeline;
