import { h } from "@stencil/core";
import DescriptionList from "@ecl/description-list";
export class EclDescriptionList {
    constructor() {
        this.styleClass = '';
        this.colorMode = '';
        this.variant = 'vertical';
        this.noScript = false;
    }
    getClass() {
        const styleClasses = [
            `ecl-description-list`,
            `ecl-description-list--${this.variant}`,
            this.styleClass
        ];
        if (this.colorMode) {
            styleClasses.push(`ecl-color-mode--${this.colorMode}`);
        }
        return styleClasses.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;
    }
    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.DescriptionList = DescriptionList;
            const descriptionList = new DescriptionList(this.el.firstElementChild);
            descriptionList.init();
            const firstTerm = this.el.querySelectorAll('.ecl-description-list__term');
            if (firstTerm[0]) {
                firstTerm[0].classList.add('is-first');
            }
            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}`);
                    more.firstElementChild.classList.add(`sc-ecl-description-list-${this.theme}`);
                });
            }
        }
    }
    render() {
        return (h("dl", Object.assign({ key: 'e57f33ab1221ea3ca99cf9e7cc08376a0be45780' }, this.getAttrs()), h("slot", { key: 'c3c485e7b19743f4e26a71718cac2248c340eb7a' })));
    }
    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 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": "''"
            },
            "colorMode": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "color-mode",
                "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"
            },
            "variant": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "variant",
                "defaultValue": "'vertical'"
            },
            "visibleItems": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "visible-items"
            },
            "moreLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "more-label"
            },
            "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"
            }
        };
    }
    static get elementRef() { return "el"; }
}
