"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get defaultFilter () {
        return defaultFilter;
    },
    get filterItems () {
        return filterItems;
    }
});
const filterItems = (items, textValue, currentLabel, customFilter)=>{
    if (!textValue && !customFilter || textValue === currentLabel) return items;
    const filter = customFilter || defaultFilter;
    const dfs = (items)=>{
        const newItems = [];
        items.forEach((item)=>{
            if (item.items) {
                if (filter(item, textValue)) {
                    newItems.push(item);
                    return;
                }
                const res = dfs(item.items);
                if (res.length > 0) {
                    newItems.push({
                        ...item,
                        items: res
                    });
                }
            } else if (filter(item, textValue)) {
                newItems.push(item);
            }
        });
        return newItems;
    };
    return dfs(items);
};
const defaultFilter = (item, textValue)=>item.label.toLowerCase().includes(textValue.toLowerCase());
