import { UmbControllerBase } from '../../../../libs/class-api/index.js';
import { UmbEntityExpansionManager } from '../../utils/index.js';
/**
 * Manages the expansion state of a tree
 * @exports
 * @class UmbTreeExpansionManager
 * @augments {UmbControllerBase}
 */
export class UmbTreeExpansionManager extends UmbControllerBase {
    constructor() {
        super(...arguments);
        this.#manager = new UmbEntityExpansionManager(this);
        this.expansion = this.#manager.expansion;
    }
    #manager;
    /**
     * Observe the expansion entry for a specific entity
     * @param {UmbEntityModel} entity - The entity to observe
     * @returns {Observable<UmbEntityExpansionEntryModel | undefined>} - An observable of the expansion entry
     * @memberof UmbTreeExpansionManager
     */
    entry(entity) {
        return this.#manager.entry(entity);
    }
    /**
     * Checks if an entity is expanded
     * @param {UmbEntityModel} entity The entity to check
     * @param {string} entity.entityType The entity type
     * @param {string} entity.unique The unique key
     * @returns {Observable<boolean>} True if the entity is expanded
     * @memberof UmbTreeExpansionManager
     */
    isExpanded(entity) {
        return this.#manager.isExpanded(entity);
    }
    /**
     * Sets the expansion state
     * @param {UmbTreeExpansionModel | undefined} expansion The expansion state
     * @memberof UmbTreeExpansionManager
     * @returns {void}
     */
    setExpansion(expansion) {
        this.#manager.setExpansion(expansion);
    }
    /**
     * Gets the expansion state
     * @memberof UmbTreeExpansionManager
     * @returns {UmbTreeExpansionModel} The expansion state
     */
    getExpansion() {
        return this.#manager.getExpansion();
    }
    /**
     * Opens a child tree item
     * @param {UmbEntityModel} entity The entity to open
     * @param {string} entity.entityType The entity type
     * @param {string} entity.unique The unique key
     * @memberof UmbTreeExpansionManager
     * @returns {Promise<void>}
     */
    async expandItem(entity) {
        this.#manager.expandItem(entity);
    }
    /**
     * Closes a child tree item
     * @param {UmbEntityModel} entity The entity to close
     * @param {string} entity.entityType The entity type
     * @param {string} entity.unique The unique key
     * @memberof UmbTreeExpansionManager
     * @returns {Promise<void>}
     */
    async collapseItem(entity) {
        this.#manager.collapseItem(entity);
    }
    /**
     * Closes all child tree items
     * @memberof UmbTreeExpansionManager
     * @returns {Promise<void>}
     */
    async collapseAll() {
        this.#manager.collapseAll();
    }
    /**
     * Gets a tree item from the expansion state
     * @param {UmbEntityModel} entity The entity to get
     * @param {string} entity.entityType The entity type
     * @param {string} entity.unique The unique key
     * @returns {*}  {(Promise<UmbEntityExpansionEntryModel | undefined>)}
     * @memberof UmbEntityExpansionManager
     */
    async getItem(entity) {
        return this.#manager.getItem(entity);
    }
}
