'use strict';

var index = require('./index-pX0sBY0-.js');
var domUtils = require('./dom-utils-BdvOgC2b.js');
var tracking = require('./tracking-BPjaTlNR.js');

const treeViewCss = () => `:host{display:block}.tree-view{font-family:var(--ifx-font-family, sans-serif);font-size:14px;color:var(--ifx-color-text, #1a1a1a);display:flex;flex-wrap:wrap;flex-direction:column;overflow-x:auto;overflow-y:hidden}.tree-view__label{font:600 1.125rem/1.625rem "Source Sans 3";margin-bottom:8px}`;

const TreeView = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.ifxTreeViewExpandAllChange = index.createEvent(this, "ifxTreeViewExpandAllChange", 7);
        this.ifxTreeViewDisableAllChange = index.createEvent(this, "ifxTreeViewDisableAllChange", 7);
    }
    get el() { return index.getElement(this); }
    /** Optional label displayed for the tree view. */
    label;
    /** If true, disables all items in the tree view. */
    disableAllItems = false;
    /** If true, expands all items in the tree view. */
    expandAllItems = false;
    /** Accessible label for the tree view container. */
    ariaLabelText;
    /** Fired when the “expand all items” state changes. */
    ifxTreeViewExpandAllChange;
    /** Fired when the “disable all items” state changes. */
    ifxTreeViewDisableAllChange;
    handleExpandAllItemsChange(newValue) {
        this.ifxTreeViewExpandAllChange.emit(newValue);
    }
    handleDisableAllItemsChange(newValue) {
        this.ifxTreeViewDisableAllChange.emit(newValue);
    }
    handleSlotRef = (el) => {
        if (el) {
            if (this.disableAllItems) {
                el.setAttribute("data-disable-all-items", "true");
            }
            else {
                el.removeAttribute("data-disable-all-items");
            }
            if (this.expandAllItems) {
                el.setAttribute("data-expand-all-items", "true");
            }
            else {
                el.removeAttribute("data-expand-all-items");
            }
        }
    };
    async componentDidLoad() {
        if (!domUtils.isNestedInIfxComponent(this.el)) {
            const framework = tracking.detectFramework();
            tracking.trackComponent("ifx-tree-view", await framework);
        }
    }
    render() {
        return (index.h("div", { key: 'd5930a9e3d87902a0d03d7ce0912c1a3a4ae6172', class: `tree-view ${this.disableAllItems ? " tree-view--disabled" : ""}`, role: "tree", "aria-label": this.ariaLabelText }, this.label && this.label.trim() !== "" && (index.h("div", { key: 'b504f190ecad24579c98a2e188e8162d43e2bf0c', class: "tree-view__label" }, this.label)), index.h("slot", { key: '9dd1005f627e2669c797087aa1047fbd7a560213', ref: this.handleSlotRef })));
    }
    static get watchers() { return {
        "expandAllItems": [{
                "handleExpandAllItemsChange": 0
            }],
        "disableAllItems": [{
                "handleDisableAllItemsChange": 0
            }]
    }; }
};
TreeView.style = treeViewCss();

exports.ifx_tree_view = TreeView;
