/**
 * @typedef {object} WordList
 * @property {{[key:string]:string}} [macros]
 * @property {(Topic|Word)[]} words
 */
/**
 * @typedef {object} Topic
 * @property {"topic"} type
 * @property {string} name
 * @property {Word[]} words
 */
/**
 * @typedef {object} Word
 * @property {"word"} [type]
 * @property {string} word
 * @property {string} [context]
 * @property {string} [description]
 * @property {string[]} [synonyms]
 */
let words = (async()=>{
	let response = await fetch("./Skribbl.json");
	/** @type {WordList} */
	let json = await response.json();
	let words = json.words.map(wordOrTopic=>wordOrTopic.type=="topic"?wordOrTopic.words:[wordOrTopic]).flat();
	return words;
})();
/**
 * Wrapper for the word list specified in `Skribbl.json`.
 */
export default class SkribblWords {
	/**
	 * Returns a random word from the list.
	 */
	static async get(){
		let array = await words;
		return array[Math.floor(Math.random()*array.length)];
	}
}