"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sumTotalsCurrencyFormatter = void 0;
const utils_1 = require("@slickgrid-universal/utils");
const utilities_js_1 = require("../services/utilities.js");
const formatterUtilities_js_1 = require("../formatters/formatterUtilities.js");
const sumTotalsCurrencyFormatter = (totals, columnDef, grid) => {
    const field = columnDef.field ?? '';
    const val = totals.sum?.[field];
    const params = columnDef?.params;
    const prefix = params?.groupFormatterPrefix || '';
    const suffix = params?.groupFormatterSuffix || '';
    const currencyPrefix = params?.groupFormatterCurrencyPrefix || '';
    const currencySuffix = params?.groupFormatterCurrencySuffix || '';
    const { minDecimal, maxDecimal, decimalSeparator, thousandSeparator, wrapNegativeNumber } = (0, formatterUtilities_js_1.retrieveFormatterOptions)(columnDef, grid, 'currency', 'group');
    if ((0, utils_1.isNumber)(val)) {
        const formattedNumber = (0, utilities_js_1.formatNumber)(val, minDecimal, maxDecimal, wrapNegativeNumber, currencyPrefix, currencySuffix, decimalSeparator, thousandSeparator);
        return `${prefix}${formattedNumber}${suffix}`;
    }
    return '';
};
exports.sumTotalsCurrencyFormatter = sumTotalsCurrencyFormatter;
//# sourceMappingURL=sumTotalsCurrencyFormatter.js.map