"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.NumberCellValueRenderer = void 0;
var react_1 = __importDefault(require("react"));
var ramda_1 = require("ramda");
var ui_i18n_1 = __importDefault(require("ui-i18n"));
var mdm_sdk_1 = require("@reltio/mdm-sdk");
var Typography_1 = __importDefault(require("@mui/material/Typography"));
var Cached_1 = __importDefault(require("@mui/icons-material/Cached"));
var SmallIconButton_1 = require("../../../SmallIconButton");
var ColorBar_1 = require("../../../ColorBar");
var styles_1 = require("./styles");
var NumberCellValueRenderer = function (_a) {
    var value = _a.value, maxValue = _a.columnData.maxValue, _b = _a.rowValue, _c = _b.onLoadButtonClick, onLoadButtonClick = _c === void 0 ? ramda_1.identity : _c, isLoading = _b.isLoading;
    var styles = (0, styles_1.useStyles)();
    var showLoadButton = value === -1;
    return (react_1.default.createElement("div", { className: styles.numberContainer }, showLoadButton ? (react_1.default.createElement(react_1.default.Fragment, null,
        react_1.default.createElement(SmallIconButton_1.SmallIconButton, { icon: Cached_1.default, disabled: isLoading, onClick: onLoadButtonClick }),
        react_1.default.createElement(Typography_1.default, { className: styles.loadCaption, variant: "caption" }, isLoading ? ui_i18n_1.default.text('Loading data') : ui_i18n_1.default.text('Load data')))) : (react_1.default.createElement(react_1.default.Fragment, null,
        react_1.default.createElement(Typography_1.default, { className: styles.number }, (0, mdm_sdk_1.formatNumberAsMetric)(value, 9999)),
        !(0, ramda_1.isNil)(maxValue) && (react_1.default.createElement("div", { className: styles.colorBarContainer },
            react_1.default.createElement(ColorBar_1.ColorBar, { width: value, maxWidth: maxValue })))))));
};
exports.NumberCellValueRenderer = NumberCellValueRenderer;
