"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.progressBarFormatter = void 0;
const utils_1 = require("@slickgrid-universal/utils");
/** Takes a cell value number (between 0-100) and displays Bootstrap "progress-bar" a red (<30), silver (>30 & <70) or green (>=70) bar */
const progressBarFormatter = (_row, _cell, value) => {
    if (!(0, utils_1.isNumber)(value)) {
        return '';
    }
    let color = '';
    let inputNumber = parseFloat(value);
    if (inputNumber > 100) {
        inputNumber = 100;
    }
    if (inputNumber < 30) {
        color = 'danger';
    }
    else if (inputNumber < 70) {
        color = 'warning';
    }
    else {
        color = 'success';
    }
    const container = (0, utils_1.createDomElement)('div', { className: 'progress' });
    container.appendChild((0, utils_1.createDomElement)('div', {
        className: `progress-bar progress-bar-${color} bg-${color}`,
        role: 'progressbar',
        ariaValueNow: String(inputNumber),
        ariaValueMin: '0',
        ariaValueMax: '100',
        textContent: `${inputNumber}%`,
        style: { minWidth: '2em', width: `${inputNumber}%` },
    }));
    return container;
};
exports.progressBarFormatter = progressBarFormatter;
//# sourceMappingURL=progressBarFormatter.js.map