import type { RegionalName } from '$lib/regional-name';

/**
 * Character definitions.
 */
export interface Character {
	/**
	 * Character ID.
	 */
	chara_id: number;
	/**
	 * Regional name of the character.
	 * E.g., Special Week for Global, or スペシャルウィーク for JP.
	 */
	name: string;
}

export async function character(): Promise<Character[]> {
	const resp = await fetch('/api/global/character');
	return resp.json();
}

export function charaNames(charas: Character[]) {
	return charas.reduce((m, c) => m.set(c.chara_id, { en: c.name }), new Map<number, RegionalName>());
}
