import { h } from "@stencil/core";
import getAssetPath from "../../utils/assetPath";
export class EclDescriptionList {
    constructor() {
        this.styleClass = '';
        this.theme = 'ec';
        this.variant = 'vertical';
        this.visibleItems = undefined;
        this.moreLabel = undefined;
        this.eclScript = false;
    }
    getClass() {
        return [
            `ecl-description-list`,
            `ecl-description-list--${this.variant}`,
            this.styleClass
        ].join(' ');
    }
    getAttrs() {
        const attrs = {
            'class': this.getClass(),
        };
        if (this.visibleItems) {
            attrs['data-ecl-description-list'] = true;
            attrs['data-ecl-description-list-more-label'] = this.moreLabel;
            attrs['data-ecl-description-list-visible-items'] = this.visibleItems;
        }
        return attrs;
    }
    componentDidRender() {
        if (this.eclScript) {
            const src = getAssetPath('./build/scripts/ecl-description-list-vanilla.js');
            if (document.querySelector(`script[src="${src}"]`)) {
                document.querySelector(`script[src="${src}"]`).remove();
            }
            const script = document.createElement('script');
            script.src = src;
            script.onload = () => {
                const descriptionList = new ECL.DescriptionList(this.el.firstElementChild);
                descriptionList.init();
                const seeMore = this.el.querySelectorAll('.ecl-description-list__see_more');
                if (seeMore[0]) {
                    seeMore.forEach((more) => {
                        more.classList.add(`sc-ecl-description-list-${this.theme}`);
                    });
                }
            };
            document.body.appendChild(script);
        }
    }
    render() {
        return (h("dl", Object.assign({}, this.getAttrs()), h("slot", null)));
    }
    static get is() { return "ecl-description-list"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "ec": ["./build/styles/ecl-description-list-ec.css"],
            "eu": ["./build/styles/ecl-description-list-eu.css"]
        };
    }
    static get styleUrls() {
        return {
            "ec": ["build/styles/ecl-description-list-ec.css"],
            "eu": ["build/styles/ecl-description-list-eu.css"]
        };
    }
    static get assetsDirs() { return ["build"]; }
    static get properties() {
        return {
            "styleClass": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "style-class",
                "reflect": false,
                "defaultValue": "''"
            },
            "theme": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "theme",
                "reflect": false,
                "defaultValue": "'ec'"
            },
            "variant": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "variant",
                "reflect": false,
                "defaultValue": "'vertical'"
            },
            "visibleItems": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "visible-items",
                "reflect": false
            },
            "moreLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "more-label",
                "reflect": false
            },
            "eclScript": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "ecl-script",
                "reflect": false,
                "defaultValue": "false"
            }
        };
    }
    static get elementRef() { return "el"; }
}
//# sourceMappingURL=ecl-description-list.js.map
