{"version":3,"sources":["../../src/logger/index.ts"],"sourcesContent":["export type Color = \"Red\" | \"Green\" | \"Yellow\" | \"Blue\" | \"Magenta\" | \"Cyan\" | \"White\";\n\nconst ANSI: Record<Color, number> = {\n    Red: 31, Green: 32, Yellow: 33, Blue: 34,\n    Magenta: 35, Cyan: 36, White: 37,\n};\n\nconst timestamp = (): string => `[LOG] - ${new Date().toLocaleString()}    `;\n\nexport const Logger = {\n    disabled: false,\n\n    log(msg: string, color: Color = \"White\"): void {\n        if (this.disabled) return;\n        console.log(`%s\\x1b[${ANSI[color]}m%s\\x1b[0m`, timestamp(), msg);\n    },\n    error(msg: string): void {\n        if (this.disabled) return;\n        console.log(`%s\\x1b[31m%s\\x1b[0m`, timestamp(), msg);\n    },\n    warn(msg: string): void {\n        if (this.disabled) return;\n        console.log(`%s\\x1b[33m%s\\x1b[0m`, timestamp(), msg);\n    },\n    succ(msg: string): void {\n        if (this.disabled) return;\n        console.log(`%s\\x1b[32m%s\\x1b[0m`, timestamp(), msg);\n    },\n    /**\n     * Renders a progress bar to stdout.\n     * @param current Current progress value.\n     * @param total Total value.\n     * @param sameLine Overwrite the current line instead of printing a new one.\n     */\n    nodeProgress(current: number, total: number, sameLine: boolean = false): void {\n        const percent = current / total;\n        const barLen = 20;\n        const filled = Math.round(barLen * percent);\n        const empty = barLen - filled;\n\n        let bar = filled > 1 ? \"❤️\".repeat(filled - 1) + \"🐰\" : \"🐰\";\n        if (empty > 0) bar += \"  \".repeat(empty - 1) + \"🥕\";\n\n        const text = `[${bar}] ${Math.round(percent * 100)}%`;\n\n        if (sameLine) {\n            process.stdout.clearLine(0);\n            process.stdout.cursorTo(0);\n            process.stdout.write(text);\n            if (percent >= 1) process.stdout.write(\"\\n\");\n        } else {\n            console.log(text);\n        }\n    },\n};\n\n"],"mappings":";AAEA,IAAM,OAA8B;AAAA,EAChC,KAAK;AAAA,EAAI,OAAO;AAAA,EAAI,QAAQ;AAAA,EAAI,MAAM;AAAA,EACtC,SAAS;A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