"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLibaries = void 0;
var misc_1 = require("@cocalc/util/misc");
// client side processing, used to generate the data for the Antd tables
function getLibaries(spec, inventory, components) {
    var _a, _b;
    var libs = [];
    for (var name_1 in components) {
        var _c = (_a = components[name_1]) !== null && _a !== void 0 ? _a : {}, url = _c.url, summary = _c.summary;
        var item = {
            index: libs.length,
            name: name_1,
            key: name_1.toLowerCase(),
            summary: summary !== null && summary !== void 0 ? summary : "",
            // there may be multiple url's separated by commas in some cases
            // TODO show all URLs
            url: url === null || url === void 0 ? void 0 : url.split(",")[0],
            search: (name_1 + (summary !== null && summary !== void 0 ? summary : "")).toLowerCase(),
        };
        for (var env in spec) {
            var envInfo = (_b = inventory[spec[env].cmd]) === null || _b === void 0 ? void 0 : _b[name_1];
            if (envInfo != null)
                item[env] = envInfo;
        }
        libs.push(item);
    }
    libs.sort((0, misc_1.field_cmp)("key"));
    return libs;
}
exports.getLibaries = getLibaries;
//# sourceMappingURL=get-libraries.js.map