var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var src_exports = {}; __export(src_exports, { TRIVIA_CATEGORIES: () => TRIVIA_CATEGORIES, getEverySentence: () => getEverySentence, neverHaveIEver: () => neverHaveIEver, trivia: () => trivia, truthOrDare: () => truthOrDare, wouldYouRather: () => wouldYouRather }); module.exports = __toCommonJS(src_exports); var import_node_fs = require("node:fs"); var import_node_path = require("node:path"); const JSON_PATH = (0, import_node_path.join)(process.cwd(), "src", "json"); const NEVER_HAVE_I_EVER_PATH = (0, import_node_path.join)(JSON_PATH, "never-have-i-ever.json"); const TRUTH_OR_DARE_PATH = (0, import_node_path.join)(JSON_PATH, "truth-or-dare.json"); const WOULD_YOU_RATHER_PATH = (0, import_node_path.join)(JSON_PATH, "would-you-rather.json"); const NEVER_HAVE_I_EVER = getJson(NEVER_HAVE_I_EVER_PATH); const TRUTH_OR_DARE = getJson(TRUTH_OR_DARE_PATH); const WOULD_YOU_RATHER = getJson(WOULD_YOU_RATHER_PATH); const TRIVIA_CATEGORIES = [ "Animal", "Brain Teaser", "Celebrities", "Entertainment", "For Kids", "General", "Geography", "History", "Hobbies", "Humanities", "Literature", "Movies", "Music", "People", "Religion", "Science", "Sports", "Television", "Video Games", "World" ]; const TRIVIA_QUESTIONS = [].concat(...getTriviaJson()); function random(arr) { return arr[Math.floor(Math.random() * arr.length)]; } function getJson(path) { return JSON.parse((0, import_node_fs.readFileSync)(path, "utf-8")); } function getTriviaJson() { return TRIVIA_CATEGORIES.map( (category) => getJson( (0, import_node_path.join)( JSON_PATH, "trivia", `${category.replace(/\s+/g, "-").toLowerCase()}.json` ) ) ); } function wouldYouRatherConstructor(choices) { return { sentence: `Would you rather ${choices[0]} or ${choices[1]}?`, choices }; } function neverHaveIEverConstructor(str) { return `Never have I ever ${str}.`; } function neverHaveIEver() { return neverHaveIEverConstructor(random(NEVER_HAVE_I_EVER)); } function truthOrDare(type) { if (typeof type !== "string") throw new Error('"type" parameter needs to be a string'); if (!["truth", "dare"].includes(type)) throw new Error('"type" parameter needs to be either "truth" or "dare"'); if (type === "truth") return random(TRUTH_OR_DARE.truth); else return random(TRUTH_OR_DARE.dare); } function wouldYouRather() { return wouldYouRatherConstructor(random(WOULD_YOU_RATHER)); } function trivia(options = { categories: [] }) { if (options.categories.length > 0 && !options.categories.every( (category) => TRIVIA_CATEGORIES.includes(category) )) throw new Error( '"options.categories" parameter can only consist of elements also found in "TRIVIA_CATEGORIES"' ); return random( options.categories.length === 0 ? TRIVIA_QUESTIONS : TRIVIA_QUESTIONS.filter((x) => options.categories.includes(x.category)) ); } function getEverySentence(partyGame, raw = false) { switch (partyGame) { case "never-have-i-ever": { if (raw) return NEVER_HAVE_I_EVER; else return NEVER_HAVE_I_EVER.map((x) => neverHaveIEverConstructor(x)); } case "trivia": { return TRIVIA_QUESTIONS; } case "truth-or-dare": { return TRUTH_OR_DARE; } case "would-you-rather": { const res = WOULD_YOU_RATHER; if (raw) return res; else return res.map((choices) => wouldYouRatherConstructor(choices)); } default: { throw Error(`Party game "${partyGame}" does not exist`); } } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { TRIVIA_CATEGORIES, getEverySentence, neverHaveIEver, trivia, truthOrDare, wouldYouRather });