import { h } from "@stencil/core";
export class EclMenuItem {
    constructor() {
        this.external = false;
        this.current = false;
        this.hasChildren = false;
        this.child = false;
    }
    getClass() {
        let styleClasses = [
            'ecl-menu__item',
            `sc-ecl-menu-${this.theme}`,
            this.styleClass
        ];
        if (this.current) {
            styleClasses.push('ecl-menu__item--current');
        }
        if (this.child) {
            styleClasses = [
                'ecl-menu__subitem',
                `sc-ecl-menu-${this.theme}`,
                this.styleClass
            ];
            if (this.current) {
                styleClasses.push('ecl-menu__subitem--current');
            }
        }
        return styleClasses.join(' ');
    }
    getAttrs() {
        let attrs = {
            'data-ecl-menu-item': true,
            'aria-expanded': "false",
        };
        if (this.hasChildren) {
            attrs['data-ecl-has-children'] = true;
        }
        if (this.child) {
            delete attrs['data-ecl-menu-item'];
            attrs['data-ecl-menu-subitem'] = true;
        }
        return attrs;
    }
    getLinkClass() {
        let linkClasses = [
            'ecl-menu__link',
            'ecl-link--standalone',
            `sc-ecl-link-${this.theme}`,
            `sc-ecl-menu-${this.theme}`,
        ];
        if (this.child) {
            linkClasses = [
                'ecl-menu__sublink',
                'ecl-link--standalone',
                `sc-ecl-link-${this.theme}`,
                `sc-ecl-menu-${this.theme}`,
            ];
            if (this.current) {
                linkClasses.push('ecl-menu__sublink--current');
            }
            if (this.external) {
                linkClasses.push('ecl-link--icon-after');
            }
        }
        return linkClasses.join(' ');
    }
    componentWillLoad() {
        var _a;
        this.theme = (_a = document.documentElement.getAttribute('data-ecl-theme')) !== null && _a !== void 0 ? _a : (this.theme || 'ec');
    }
    render() {
        const buttonAttrs = this.hasChildren ? { 'data-ecl-menu-caret': true } : {};
        return (h("li", Object.assign({ key: '2a078bedbe74eda693b08dc999aca73bcc45e6a8', class: this.getClass() }, this.getAttrs()), h("a", { key: '5fef3c4572a1f0c7c92d7f98c6dfd18038f3cab4', href: this.link, class: this.getLinkClass(), "data-ecl-menu-link": true }, h("slot", { key: '9ecf355491a2938e279740cd2bf188ea79715137' }), this.external ?
            h("ecl-icon", { icon: "external", size: "xs", styleClass: `sc-ecl-icon-${this.theme} sc-ecl-menu-${this.theme} ecl-menu__link-icon--external ${this.child ? 'ecl-menu__sublink-icon' : 'ecl-menu__link-icon'}` }) : ''), this.hasChildren ?
            h("ecl-button", Object.assign({ styleClass: `ecl-menu__button-caret sc-ecl-menu-${this.theme}`, type: "button", size: "m", theme: this.theme, variant: "tertiary", buttonStyle: "neutral", hideLabel: true }, buttonAttrs), h("ecl-icon", { icon: "corner-arrow", size: "xs", rotate: "180", slot: "icon-after", styleClass: `sc-ecl-icon-${this.theme} sc-ecl-menu-${this.theme}` })) : '', this.hasChildren ?
            h("div", { class: `ecl-menu__mega sc-ecl-menu-${this.theme}`, "data-ecl-menu-mega": true }, h("ul", { class: `ecl-menu__sublist sc-ecl-menu-${this.theme}` }, h("slot", { name: "sublist" }))) : ''));
    }
    static get is() { return "ecl-menu-item"; }
    static get originalStyleUrls() {
        return {
            "$": ["build/styles/ecl-menu-item.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["build/styles/ecl-menu-item.css"]
        };
    }
    static get properties() {
        return {
            "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"
            },
            "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"
            },
            "external": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "external",
                "defaultValue": "false"
            },
            "current": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "current",
                "defaultValue": "false"
            },
            "hasChildren": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "has-children",
                "defaultValue": "false"
            },
            "child": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "child",
                "defaultValue": "false"
            },
            "link": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "link"
            },
            "triggerAriaLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "trigger-aria-label"
            }
        };
    }
    static get elementRef() { return "el"; }
}
