import { h } from "@stencil/core";
import Popover from "@ecl/popover";
export class EclPopover {
    constructor() {
        this.noScript = false;
        this.close = false;
        this.indicator = false;
    }
    getClass() {
        const styleClasses = [
            `ecl-popover`,
            this.styleClass
        ];
        return styleClasses.join(' ');
    }
    getAttrs() {
        const attrs = {
            'aria-controls': this.itemId,
            'data-ecl-popover-toggle': 'data-ecl-popover-toggle',
            'aria-expanded': 'false',
        };
        if (this.indicator) {
            attrs['indicator'] = true;
        }
        if (this.indicatorValue) {
            attrs['hide-label'] = true;
            attrs["indicator-value"] = this.indicatorValue;
        }
        return attrs;
    }
    componentWillLoad() {
        var _a;
        this.theme = (_a = document.documentElement.getAttribute('data-ecl-theme')) !== null && _a !== void 0 ? _a : (this.theme || 'ec');
    }
    componentDidLoad() {
        if (!this.noScript) {
            ;
            window.ECL = window.ECL || {};
            ECL.Popover = Popover;
            const popover = new Popover(this.el.firstElementChild);
            popover.init();
        }
    }
    render() {
        return (h("div", { key: '8e0e7e9d4ea27e37794fcd7145468fcf0da61e6c', class: this.getClass() }, h("ecl-link", Object.assign({ key: '11007d2495a9f72e9b824102ce9f96b3785992dd', "style-class": `sc-ecl-link-${this.theme} sc-ecl-popover-${this.theme} ecl-popover__toggle`, variant: "standalone" }, this.getAttrs()), this.icon &&
            h("ecl-icon", { key: '4a9108025e2db7bc2fd0e9d0ae3d2fd9caf72abb', icon: this.icon, size: "fluid", "style-class": "ecl-link__icon--before", slot: "icon-after" }), this.toggleLabel), h("div", { key: '15e26748178187de97da25d3986957105fcaaf8c', class: "ecl-popover__container", id: this.itemId, hidden: true }, h("div", { key: '16d34e83442fbe25f8b72416526bb04800e293f7', class: "ecl-popover__scrollable" }, this.close &&
            h("ecl-button", { key: 'cd7fea7e4cd9ae4859f09799b7d10037860be3c2', variant: "tertiary", type: "button", buttonStyle: "neutral", "style-class": `sc-ecl-popover-${this.theme} ecl-popover__close`, "hide-label": true, "data-ecl-popover-close": true }, "Close", h("ecl-icon", { key: 'e2c9d13426ec836f97cb8a6f1cef64bad7c60647', icon: "close", slot: "icon-after", "style-class": `sc-ecl-popover-${this.theme}` })), h("div", { key: 'c9e01c7695f8baac2e84f296d607b6cac8ac0c66', class: "ecl-popover__content" }, h("slot", { key: '7e91b46677513ed5abac1ff98c4ebc6dabc03a1d' }))))));
    }
    static get is() { return "ecl-popover"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "ec": ["./build/styles/ecl-popover-ec.css"],
            "eu": ["./build/styles/ecl-popover-eu.css"]
        };
    }
    static get styleUrls() {
        return {
            "ec": ["build/styles/ecl-popover-ec.css"],
            "eu": ["build/styles/ecl-popover-eu.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"
            },
            "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"
            },
            "itemId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "item-id"
            },
            "toggleLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "toggle-label"
            },
            "close": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "close",
                "defaultValue": "false"
            },
            "icon": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "icon"
            },
            "indicator": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "indicator",
                "defaultValue": "false"
            },
            "indicatorValue": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "indicator-value"
            }
        };
    }
    static get elementRef() { return "el"; }
}
