import { h } from "@stencil/core";
import MegaMenu from "@ecl/mega-menu";
export class EclMegaMenu {
    constructor() {
        this.noScript = false;
        this.menuId = `ecl-mega-menu-${Math.random().toString(36).slice(2, 10)}`;
        this.featuredPriority = 'secondary';
    }
    componentWillLoad() {
        var _a;
        this.theme = (_a = document.documentElement.getAttribute('data-ecl-theme')) !== null && _a !== void 0 ? _a : (this.theme || 'ec');
    }
    componentDidLoad() {
        const subLists = this.el.querySelectorAll('.ecl-mega-menu__sublist');
        if (subLists) {
            [...subLists].forEach((list) => {
                const items = list.querySelectorAll('.ecl-mega-menu__sublink');
                if (items.length > 0) {
                    const lastItem = items[items.length - 1];
                    lastItem.classList.add('ecl-mega-menu__sublink--last');
                }
            });
        }
        if (!this.noScript) {
            ;
            window.ECL = window.ECL || {};
            const megaMenu = new MegaMenu(this.el.firstElementChild);
            megaMenu.init();
        }
    }
    getClass() {
        const styleClasses = [
            `ecl-mega-menu`,
            this.styleClass
        ];
        if (this.featuredPriority === 'primary') {
            styleClasses.push('ecl-mega-menu--featured--primary');
        }
        return styleClasses.join(' ');
    }
    render() {
        return (h("nav", { key: '473dd1b9e844f4c8ceefed2f8c65c234d72bb6a6', class: this.getClass(), "data-ecl-mega-menu": true, role: "navigation", id: this.menuId, "aria-label": this.ariaLabel }, h("div", { key: '57228c679444804e26aa71cf6df95cc68c0203cc', class: "ecl-mega-menu__overlay" }), h("div", { key: '4a4d5fa34431ddcdae97ef5904974dd8f4e3418b', class: "ecl-container ecl-mega-menu__container" }, h("ecl-button", { key: '3ac3e702de4f89c252586bf2ba3e9350c6efa127', variant: "tertiary", type: "button", "hide-label": true, "button-style": "neutral", "style-class": `ecl-mega-menu__open sc-ecl-mega-menu-${this.theme}`, "aria-expanded": "false", "data-ecl-mega-menu-open": true }, h("ecl-icon", { key: '3c0f37b720c4816b636f9e9bc47a02f9ac965310', "style-class": `sc-ecl-mega-menu-${this.theme} is-first`, icon: "hamburger", size: "m", slot: "icon-after" }), h("ecl-icon", { key: '7b58613b75e90d47669d5539f5ab35b86b49dcac', "style-class": `sc-ecl-mega-menu-${this.theme}`, icon: "close", size: "m", slot: "icon-after" }), this.toggleLabel), h("section", { key: '2e9aff525b7187cf1f27e406794a3572c9b6e581', class: "ecl-mega-menu__inner", "data-ecl-mega-menu-inner": true }, h("header", { key: '8ee87901ed3a6ae590c54c91c967fd6f274dead5', class: "ecl-mega-menu__inner-header" }, this.backLabel && (h("ecl-button", { key: '24da53cc5eeb69994721a58172df6a97db36e0e0', "style-class": `ecl-mega-menu__back sc-ecl-mega-menu-${this.theme}`, type: "button", variant: "tertiary", "icon-position": "before", "data-ecl-mega-menu-back": true }, h("ecl-icon", { key: 'c17f30bea6295629faca9943ea3509295a5c256b', icon: "corner-arrow", size: "xs", rotate: "270", "style-class": `sc-ecl-mega-menu-${this.theme}` }), this.backLabel))), h("ul", { key: 'ad60c3335c8d5a88ec42f31fadf4eb7c52c53650', class: "ecl-mega-menu__list" }, h("slot", { key: '19953038879e104fb7bfa3f4af0c270556ccd336' }))))));
    }
    static get is() { return "ecl-mega-menu"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "ec": ["./build/styles/ecl-mega-menu-ec.css"],
            "eu": ["./build/styles/ecl-mega-menu-eu.css"]
        };
    }
    static get styleUrls() {
        return {
            "ec": ["build/styles/ecl-mega-menu-ec.css"],
            "eu": ["build/styles/ecl-mega-menu-eu.css"]
        };
    }
    static get properties() {
        return {
            "styleClass": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "style-class"
            },
            "theme": {
                "type": "string",
                "mutable": true,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "theme"
            },
            "noScript": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "no-script",
                "defaultValue": "false"
            },
            "menuId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "menu-id",
                "defaultValue": "`ecl-mega-menu-${Math.random().toString(36).slice(2, 10)}`"
            },
            "ariaLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "aria-label"
            },
            "backLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "back-label"
            },
            "toggleLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "toggle-label"
            },
            "featuredPriority": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'primary' | 'secondary'",
                    "resolved": "\"primary\" | \"secondary\"",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "featured-priority",
                "defaultValue": "'secondary'"
            }
        };
    }
    static get elementRef() { return "el"; }
}
