"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var logSymbols = require("log-symbols");
var chalk_1 = require("chalk");
var change_1 = require("../diff/changes/change");
function getSymbol(level) {
    var _a;
    var symbols = (_a = {},
        _a[change_1.CriticalityLevel.Dangerous] = logSymbols.warning,
        _a[change_1.CriticalityLevel.Breaking] = logSymbols.error,
        _a[change_1.CriticalityLevel.NonBreaking] = logSymbols.success,
        _a);
    return symbols[level];
}
exports.getSymbol = getSymbol;
function renderChange(change) {
    return [getSymbol(change.criticality.level), bolderize(change.message)];
}
exports.renderChange = renderChange;
function bolderize(msg) {
    var findSingleQuotes = /\'([^']+)\'/gim;
    var findDoubleQuotes = /\"([^"]+)\"/gim;
    return msg
        .replace(findSingleQuotes, function (_, value) { return chalk_1.default.bold(value); })
        .replace(findDoubleQuotes, function (_, value) { return chalk_1.default.bold(value); });
}
exports.bolderize = bolderize;
function renderInvalidDocument(invalidDoc) {
    var errors = invalidDoc.errors.map(function (e) { return " - " + bolderize(e.message); }).join('\n');
    return [
        logSymbols.error,
        chalk_1.default.redBright(bolderize(invalidDoc.source.name + ':\n\n')),
        errors,
        '\n\n',
    ];
}
exports.renderInvalidDocument = renderInvalidDocument;
var ConsoleRenderer = /** @class */ (function () {
    function ConsoleRenderer() {
    }
    ConsoleRenderer.prototype.emit = function () {
        var msgs = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            msgs[_i] = arguments[_i];
        }
        console.log.apply(console, msgs);
    };
    return ConsoleRenderer;
}());
exports.ConsoleRenderer = ConsoleRenderer;
//# sourceMappingURL=render.js.map