/*!
 * Built by Revolist OU ❤️
 */
/**
 * Hide items from main collection
 * But keep them in store
 */
export const trimmedPlugin = (store) => ({
    set(k, newVal) {
        switch (k) {
            case 'trimmed': {
                // full sorted items list
                const proxy = store.get('proxyItems');
                const trimmed = gatherTrimmedItems(newVal);
                // filter our physical indexes which are not trimmed
                const newItems = proxy.filter(v => !trimmed[v]);
                // set trimmed items in store
                store.set('items', newItems);
                break;
            }
        }
    },
});
export function gatherTrimmedItems(trimmedItems) {
    const trimmed = {};
    for (let trimmedKey in trimmedItems) {
        // trimmed overweight not trimmed
        for (let t in trimmedItems[trimmedKey]) {
            trimmed[t] = trimmed[t] || trimmedItems[trimmedKey][t];
        }
    }
    return trimmed;
}
