"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.theme = exports.pkgColor = exports.highlight = exports.ir = exports.em = exports.link = exports.spinner = exports.clearSpinners = exports.stopLastSpinner = exports.stopSpinner = exports.startSpinner = exports.prettyPrompt = exports.format = exports.prefix = exports.prettyprint = exports.hr = exports.ascii = exports.igniteHeading = exports.warning = exports.direction = exports.command = exports.heading = exports.p = exports.INDENT = void 0;
var gluegun_1 = require("gluegun");
var assets_1 = require("../assets");
var _a = gluegun_1.print.colors, bgRed = _a.bgRed, bgWhite = _a.bgWhite, underline = _a.underline, gray = _a.gray, white = _a.white, bold = _a.bold, red = _a.red, yellow = _a.yellow;
exports.INDENT = "   ";
var p = function (m) {
    if (m === void 0) { m = ""; }
    return gluegun_1.print.info(gray(exports.INDENT + m));
};
exports.p = p;
var heading = function (m) {
    if (m === void 0) { m = ""; }
    return (0, exports.p)(white(bold(m)));
};
exports.heading = heading;
var command = function (m, second, examples) {
    if (m === void 0) { m = ""; }
    if (second === void 0) { second = ""; }
    if (examples === void 0) { examples = []; }
    m = typeof m === "string" ? m : m.m + " ".repeat(m.width - m.m.length);
    (0, exports.p)(white(m) + "  " + gray(second));
    var indent = m.length + 2;
    if (examples) {
        examples.forEach(function (ex) { return (0, exports.p)(gray(" ".repeat(indent) + white(ex))); });
    }
};
exports.command = command;
var direction = function (m) {
    if (m === void 0) { m = ""; }
    return (0, exports.p)(red(m));
};
exports.direction = direction;
var warning = function (m) {
    if (m === void 0) { m = ""; }
    return (0, exports.p)(yellow(m));
};
exports.warning = warning;
var igniteHeading = function () {
    return (0, exports.p)(red(bold("· · · · · · · · · · · · · · · · · · 🔥 Ignite 🔥 · · · · · · · · · · · · · · · · · ·\n")));
};
exports.igniteHeading = igniteHeading;
var ascii = function (assetname) {
    console.log(assets_1.asset
        .get(assetname)
        .split("\n")
        .map(function (line) { return exports.INDENT + line; })
        .join("\n"));
};
exports.ascii = ascii;
var hr = function () { return (0, exports.p)(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"); };
exports.hr = hr;
exports.prettyprint = {
    ascii: exports.ascii,
    command: exports.command,
    direction: exports.direction,
    heading: exports.heading,
    hr: exports.hr,
    igniteHeading: exports.igniteHeading,
    p: exports.p,
    warning: exports.warning,
};
/**
 * enquirer style customization
 * @see https://github.dev/enquirer/enquirer/blob/36785f3399a41cd61e9d28d1eb9c2fcd73d69b4c/examples/select/option-elements.js#L19
 */
var prefix = function (state) {
    return {
        pending: "📝",
        submitted: "✅",
        cancelled: "❌",
    }[state.status];
};
exports.prefix = prefix;
/** Format displayed messages for prompts */
exports.format = {
    /** Format boolean values for human on prompts  */
    boolean: function (value) {
        return value ? "Yes" : "No";
    },
};
exports.prettyPrompt = {
    prefix: exports.prefix,
    format: exports.format,
};
var spinners = {};
var startSpinner = function (m) {
    if (m === void 0) { m = ""; }
    var spinner = spinners[m];
    if (!spinner) {
        spinner = gluegun_1.print.spin({ prefixText: exports.INDENT, text: gray(m) });
        spinners[m] = spinner;
    }
    return spinner;
};
exports.startSpinner = startSpinner;
var stopSpinner = function (m, symbol) {
    var spinner = spinners[m];
    if (spinner) {
        spinner.stopAndPersist({ symbol: symbol });
        delete spinners[m];
    }
};
exports.stopSpinner = stopSpinner;
var stopLastSpinner = function (symbol) {
    var lastKey = Object.keys(spinners).pop();
    if (lastKey) {
        var lastSpinner = spinners[lastKey];
        lastSpinner.stopAndPersist({ symbol: symbol });
        delete spinners[lastKey];
    }
};
exports.stopLastSpinner = stopLastSpinner;
var clearSpinners = function () {
    Object.keys(spinners).forEach(function (m) {
        spinners[m].stop();
        delete spinners[m];
    });
};
exports.clearSpinners = clearSpinners;
exports.spinner = {
    start: exports.startSpinner,
    stop: exports.stopSpinner,
    stopLast: exports.stopLastSpinner,
    clear: exports.clearSpinners,
};
var link = function (m) {
    if (m === void 0) { m = ""; }
    return underline(white(m));
};
exports.link = link;
var em = function (m) {
    if (m === void 0) { m = ""; }
    return bold(white(m));
};
exports.em = em;
var ir = function (m) {
    if (m === void 0) { m = ""; }
    return bgRed(bold(white(m)));
};
exports.ir = ir;
var highlight = function (m) {
    if (m === void 0) { m = ""; }
    return bold(bgWhite(red(m)));
};
exports.highlight = highlight;
var pkgColor = function (packagerName) {
    var packagerColors = {
        npm: "red",
        yarn: "blue",
        pnpm: "yellow",
        bun: "cyan",
    };
    return gluegun_1.print.colors[packagerColors[packagerName]];
};
exports.pkgColor = pkgColor;
exports.theme = {
    em: exports.em,
    highlight: exports.highlight,
    link: exports.link,
    ir: exports.ir,
};
//# sourceMappingURL=pretty.js.map