"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.avgTotalsCurrencyFormatter = void 0;
const utils_1 = require("@slickgrid-universal/utils");
const formatterUtilities_js_1 = require("../formatters/formatterUtilities.js");
const utilities_js_1 = require("../services/utilities.js");
const avgTotalsCurrencyFormatter = (totals, columnDef, grid) => {
    const field = columnDef.field ?? '';
    const val = totals.avg?.[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.avgTotalsCurrencyFormatter = avgTotalsCurrencyFormatter;
//# sourceMappingURL=avgTotalsCurrencyFormatter.js.map