export type VQMouthShape =
  | "a"
  | "i"
  | "u"
  | "e"
  | "o"
  | "closed"
  | "rest";

export type VQAvatarAnimationContext = Readonly<{
  frame: number;
  fps: number;
  focused: boolean;
  hasMultipleCharacters: boolean;
}>;

export type VQAvatarAnimation = (context: VQAvatarAnimationContext) => number;

export type VQIdleAvatarAnimationType = "none" | "gentleBob";

export type VQSpeakingAvatarAnimationType =
  | "none"
  | "rhubarbLipSync"
  | "gentleBob"
  | "quickHop";

export type VQAvatarNameplatePosition = "top" | "bottom" | "none";

export type VQAvatarImageLayout = Readonly<{
  width?: number | string;
  maxHeight?: number | string;
  height?: number | string;
  translateY?: number;
  flipX?: boolean;
}>;

export type VQAvatarDefinition = Readonly<{
  kind?: string;
  imagePath: string;
  mouthImageDir: string;
  imageLayout?: VQAvatarImageLayout;
  accentColor: string;
  nameplatePosition?: VQAvatarNameplatePosition;
  idleAnimationType?: VQIdleAvatarAnimationType;
  speakingAnimationType?: VQSpeakingAvatarAnimationType;
}>;

export type VQCharacterDefinition = Readonly<{
  displayName: string;
  avatar: VQAvatarDefinition;
}>;

export type VQSpeechEventLike = Readonly<{
  text: string;
  subtitle?: string;
  readAs?: string;
}>;

export type VQMouthResolverContext<CharacterId extends string = string> =
  Readonly<{
    characterId: CharacterId;
    character: VQCharacterDefinition;
    speechId?: string;
    speakingLocalFrame: number;
    fps: number;
    speakingAnimationType: VQSpeakingAvatarAnimationType;
  }>;

export type VQMouthResolver<CharacterId extends string = string> = (
  context: VQMouthResolverContext<CharacterId>
) => VQMouthShape;
