let g_emojis;

function get_emojis() {
	if (g_emojis) {
		return Promise.resolve(g_emojis);
	}
	return fetch('emojis.json').then(function (result) {
		g_emojis = result.json();
		return g_emojis;
	});
}

export async function from_name(name) {
	if (name.startsWith(':') && name.endsWith(':')) {
		name = name.substring(1, name.length - 1);
	}
	let emojis = await get_emojis();
	for (let group of Object.values(emojis)) {
		if (group[name]) {
			return group[name];
		}
	}
	return name;
}
