"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getLibaries = void 0;
const misc_1 = require("@cocalc/util/misc");
// client side processing, used to generate the data for the Antd tables
function getLibaries(spec, inventory, components) {
    const libs = [];
    for (const name in components) {
        const { url, summary } = components[name] ?? {};
        const item = {
            index: libs.length,
            name,
            key: name.toLowerCase(),
            summary: summary ?? "",
            // there may be multiple url's separated by commas in some cases
            // TODO show all URLs
            url: url?.split(",")[0],
            search: (name + (summary ?? "")).toLowerCase(),
        };
        for (const env in spec) {
            const envInfo = inventory[spec[env].cmd]?.[name];
            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