import { h } from "@stencil/core";
import getAssetPath from "../../utils/assetPath";
export class EclModal {
    constructor() {
        this.theme = 'ec';
        this.variant = 'default';
        this.styleClass = undefined;
        this.withBody = false;
        this.withBodyFixed = false;
        this.withHeader = false;
        this.eclScript = false;
        this.withFooter = false;
        this.toggleId = undefined;
        this.size = 'l';
        this.closeLabel = undefined;
        this.itemId = undefined;
    }
    getClass() {
        return [
            `ecl-modal`,
            `ecl-modal--${this.variant}`,
            `ecl-modal--${this.size}`,
            this.styleClass
        ].join(' ');
    }
    getContentClasses() {
        return this.size === 's' ? 'ecl-modal__content ecl-col-12' : 'ecl-modal__content ecl-col-m-10 ecl-col-l-8';
    }
    componentDidRender() {
        if (this.eclScript) {
            const src = getAssetPath('./build/scripts/ecl-modal-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 modal = new ECL.Modal(this.el.firstElementChild);
                modal.init();
            };
            document.body.appendChild(script);
        }
    }
    render() {
        return (h("dialog", { class: this.getClass(), "data-ecl-modal-toggle": this.toggleId, id: this.itemId }, h("div", { class: "ecl-modal__container ecl-container" }, h("div", { class: this.getContentClasses() }, h("header", { class: "ecl-modal__header" }, this.withHeader && this.variant !== 'default' ? (h("ecl-icon", { theme: this.theme, icon: this.variant, size: "m", class: `ecl-modal__icon sc-ecl-modal-${this.theme}` })) : '', this.withHeader ? (h("div", { class: "ecl-modal__header-content" }, h("slot", { name: "header" }))) : '', h("ecl-button", { theme: this.theme, type: "button", variant: "ghost", styleClass: `ecl-modal__close sc-ecl-modal-${this.theme}`, "data-ecl-modal-close": true }, this.closeLabel, h("ecl-icon", { theme: this.theme, icon: "close-filled", size: "s" }))), h("div", { class: "ecl-modal__body" }, this.withBody ?
            h("div", { class: "ecl-modal__body-scroll", "data-ecl-modal-scroll": true }, h("slot", { name: "body" })) : '', this.withBody ?
            h("div", { class: "ecl-modal__body-overflow", "aria-hidden": "true" }) : '', this.withBodyFixed ?
            h("div", { class: "ecl-modal__body-fixed" }, h("slot", { name: "body-fixed" })) : ''), this.withFooter ?
            h("footer", { class: "ecl-modal__footer" }, h("div", { class: "ecl-modal__footer-content" }, h("slot", { name: "footer" }))) : ''))));
    }
    static get is() { return "ecl-modal"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "ec": ["./build/styles/ecl-modal-ec.css"],
            "eu": ["./build/styles/ecl-modal-eu.css"]
        };
    }
    static get styleUrls() {
        return {
            "ec": ["build/styles/ecl-modal-ec.css"],
            "eu": ["build/styles/ecl-modal-eu.css"]
        };
    }
    static get assetsDirs() { return ["build"]; }
    static get properties() {
        return {
            "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": "'default'"
            },
            "styleClass": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "style-class",
                "reflect": false
            },
            "withBody": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "with-body",
                "reflect": false,
                "defaultValue": "false"
            },
            "withBodyFixed": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "with-body-fixed",
                "reflect": false,
                "defaultValue": "false"
            },
            "withHeader": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "with-header",
                "reflect": false,
                "defaultValue": "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"
            },
            "withFooter": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "with-footer",
                "reflect": false,
                "defaultValue": "false"
            },
            "toggleId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "toggle-id",
                "reflect": false
            },
            "size": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "size",
                "reflect": false,
                "defaultValue": "'l'"
            },
            "closeLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "close-label",
                "reflect": false
            },
            "itemId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "item-id",
                "reflect": false
            }
        };
    }
    static get elementRef() { return "el"; }
}
//# sourceMappingURL=ecl-modal.js.map
