"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.search = exports.register = void 0;
const misc_1 = require("@cocalc/util/misc");
const searchInfo = {};
function register(info) {
    const search = (info.desc +
        " " +
        info.path +
        " " +
        info.title +
        " " +
        JSON.stringify(info.search ?? "")).toLowerCase();
    searchInfo[info.path] = { ...info, search };
}
exports.register = register;
function search(s, allowEmpty) {
    const v = (0, misc_1.search_split)(s.toLowerCase().trim());
    const result = [];
    if (v.length == 0 && !allowEmpty)
        return result;
    for (const path in searchInfo) {
        if (v.length == 0 ||
            (searchInfo[path].search && (0, misc_1.search_match)(searchInfo[path].search, v))) {
            result.push(searchInfo[path]);
        }
    }
    return result;
}
exports.search = search;
//# sourceMappingURL=entries.js.map