"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.search = exports.register = void 0;
var misc_1 = require("@cocalc/util/misc");
var searchInfo = {};
function register(info) {
    var _a;
    var search = (info.desc +
        " " +
        info.path +
        " " +
        info.title +
        " " +
        JSON.stringify((_a = info.search) !== null && _a !== void 0 ? _a : "")).toLowerCase();
    searchInfo[info.path] = __assign(__assign({}, info), { search: search });
}
exports.register = register;
function search(s, allowEmpty) {
    var v = (0, misc_1.search_split)(s.toLowerCase().trim());
    var result = [];
    if (v.length == 0 && !allowEmpty)
        return result;
    for (var 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