"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTotalCompute = void 0;
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const use_translation_wrapper_1 = require("../../../common/hooks/use-translation-wrapper");
const utils_1 = require("../../../common/utils");
const getTotalCompute = (selectedAgents, t) => {
    const totals = selectedAgents.reduce((acc, agent) => {
        var _a, _b, _c, _d;
        acc.cpus += ((_b = (_a = agent.status) === null || _a === void 0 ? void 0 : _a.inventory.cpu) === null || _b === void 0 ? void 0 : _b.count) || 0;
        acc.memory += ((_d = (_c = agent.status) === null || _c === void 0 ? void 0 : _c.inventory.memory) === null || _d === void 0 ? void 0 : _d.usableBytes) || 0;
        return acc;
    }, {
        cpus: 0,
        memory: 0,
    });
    return t('ai:{{cpus}} CPU cores | {{memory}} Memory', {
        cpus: totals.cpus,
        memory: (0, utils_1.fileSize)(totals.memory, 2, 'iec'),
    });
};
exports.getTotalCompute = getTotalCompute;
const ShortCapacitySummary = ({ selectedAgents }) => {
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    return (react_1.default.createElement("div", null,
        t('ai:Total compute'),
        ": ",
        (0, exports.getTotalCompute)(selectedAgents, t)));
};
exports.default = ShortCapacitySummary;
//# sourceMappingURL=ShortCapacitySummary.js.map