import { h } from "@stencil/core";
import Expandable from "@ecl/expandable";
export class EclExpandable {
    constructor() {
        this.styleClass = '';
        this.noScript = false;
        this.isExpanded = false;
        this.elId = `ecl-expandable-${Math.random().toString(36).substr(2, 9)}`;
        this.labelCollapsed = '';
        this.labelExpanded = '';
    }
    componentWillLoad() {
        var _a;
        this.theme = (_a = document.documentElement.getAttribute('data-ecl-theme')) !== null && _a !== void 0 ? _a : (this.theme || 'ec');
    }
    componentDidLoad() {
        const p = this.el.querySelectorAll('p');
        if (p[0]) {
            p.forEach((paragraph) => {
                paragraph.classList.add(`sc-ecl-expandable-${this.theme}`);
            });
        }
        if (!this.noScript) {
            ;
            window.ECL = window.ECL || {};
            ECL.Expandable = Expandable;
            const expandable = new Expandable(this.el.firstElementChild);
            expandable.init();
        }
        ;
    }
    getClass() {
        return [
            `ecl-expandable`,
            this.styleClass
        ].join(' ');
    }
    render() {
        return (h("div", { key: '244c3e92fc1121945d747c5e04e777272c27cc92', class: this.getClass() }, h("ecl-button", { key: 'b146b88ee1e03465ab627e4dc09a8a34ebd26393', theme: this.theme, variant: "tertiary", "style-class": `ecl-expandable__toggle sc-ecl-expandable-${this.theme}`, type: "button", "aria-controls": `${this.elId}-content`, "aria-expanded": "false", "data-ecl-expandable-toggle": true, "data-ecl-label-expanded": this.labelExpanded, "data-ecl-label-collapsed": this.labelCollapsed }, h("span", { key: '17ff131cfa40bc05f785a1d2a6188ab2a2d57360', class: "ecl-button__label", "data-ecl-label": true }, this.labelCollapsed), h("ecl-icon", { key: '3bc5e9e7d45bfd31a8b177bf1e049f665d4d36d4', slot: "icon-after", icon: "corner-arrow", size: "fluid", rotate: "180", "style-class": `ecl-button__icon ecl-button__icon--after sc-ecl-button-${this.theme} sc-ecl-expandable-${this.theme}` })), h("div", { key: '1769509628f59f2af553e566eb7cb4aaa0090ad6', class: "ecl-expandable__content", id: `${this.elId}-content`, hidden: true }, h("slot", { key: 'c6fbc7d5ce61ac38fab38dc715eaafae2faceece' }))));
    }
    static get is() { return "ecl-expandable"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "ec": ["./build/styles/ecl-expandable-ec.css"],
            "eu": ["./build/styles/ecl-expandable-eu.css"]
        };
    }
    static get styleUrls() {
        return {
            "ec": ["build/styles/ecl-expandable-ec.css"],
            "eu": ["build/styles/ecl-expandable-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",
                "defaultValue": "''"
            },
            "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"
            },
            "isExpanded": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "is-expanded",
                "defaultValue": "false"
            },
            "elId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "el-id",
                "defaultValue": "`ecl-expandable-${Math.random().toString(36).substr(2, 9)}`"
            },
            "labelCollapsed": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "label-collapsed",
                "defaultValue": "''"
            },
            "labelExpanded": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "label-expanded",
                "defaultValue": "''"
            },
            "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"
            }
        };
    }
    static get elementRef() { return "el"; }
}
