import { UmbStoreBase } from '../../store/index.js';
import { UmbArrayState } from '../../../../libs/observable-api/index.js';
// TODO: remove Unique from name when we have switched to uniques
/**
 * @class UmbUniqueTreeStore
 * @augments {UmbStoreBase}
 * @description - Entity Tree Store
 */
export class UmbUniqueTreeStore extends UmbStoreBase {
    constructor(host, storeAlias) {
        super(host, storeAlias, new UmbArrayState([], (x) => x.unique));
        /**
         * An observable to observe the root items
         * @memberof UmbUniqueTreeStore
         */
        this.rootItems = this._data.asObservablePart((items) => items.filter((item) => item.parent.unique === null));
    }
    /**
     * Returns an observable to observe the children of a given parent
     * @param {(string | null)} parentUnique
     * @returns {*}
     * @memberof UmbUniqueTreeStore
     */
    childrenOf(parentUnique) {
        return this._data.asObservablePart((items) => items.filter((item) => item.parent.unique === parentUnique));
    }
}
