import { p as proxyCustomElement, H, h } from './p-604af0ee.js';
import { d as defineCustomElement$3 } from './p-115ed7c3.js';
import { d as defineCustomElement$2 } from './p-42103fc2.js';
import { d as defineCustomElement$1 } from './p-66861708.js';

const SubmenuComponent = /*@__PURE__*/ proxyCustomElement(class SubmenuComponent extends H {
    constructor() {
        super();
        this.__registerHost();
    }
    handleExpanded(expanded) {
        if (expanded) {
            this.submenuElement.style.maxHeight = 'fit-content';
        }
        else {
            this.submenuElement.style.maxHeight = '';
        }
        const subHeight = this.submenuElement.scrollHeight;
        this.onChildExpanded(expanded, subHeight);
    }
    render() {
        if (!this.childRoute.children || this.childRoute.children.length === 0) {
            return (h("li", { key: this.childRoute.path }, h("tab-link", { text: this.childRoute.name, link: `${this.route.path}${this.childRoute.path}`, level: this.childRoute.level, type: "child", icon: this.childRoute.icon, badge: this.childRoute.badge, disabled: this.childRoute.disabled })));
        }
        return (h("li", { key: this.childRoute.path }, h("tab-link", { text: this.childRoute.name, link: `${this.route.path}${this.childRoute.path}`, type: "parent", icon: this.childRoute.icon, disabled: this.childRoute.disabled, onExpand: this.handleExpanded.bind(this) }), h("ul", { class: "sidepanel__submenu-list", ref: el => (this.submenuElement = el) }, this.childRoute.children.map((subSubRoute, index) => (h("submenu-component", { key: index, route: this.route, childRoute: subSubRoute }))))));
    }
}, [0, "submenu-component", {
        "route": [16],
        "childRoute": [16],
        "onChildExpanded": [16]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["submenu-component", "dga-icon-v2", "dga-tag", "submenu-component", "tab-link"];
    components.forEach(tagName => { switch (tagName) {
        case "submenu-component":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, SubmenuComponent);
            }
            break;
        case "dga-icon-v2":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "dga-tag":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "submenu-component":
            if (!customElements.get(tagName)) {
                defineCustomElement();
            }
            break;
        case "tab-link":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}

export { SubmenuComponent as S, defineCustomElement as d };

//# sourceMappingURL=p-9efe8fae.js.map