import { h } from "@stencil/core";
export class BpSdkDialog {
    constructor() {
        this.onClick = () => {
            this.isOpen = false;
        };
        this.answerId = undefined;
        this.code = undefined;
        this.questionId = undefined;
        this.isRequired = true;
        this.useExternal = false;
        this.isOpen = true;
    }
    resetState() {
        this.isOpen = true;
    }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-dialog');
        customElements.whenDefined('bp-sdk-external-dialog').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (h("bp-sdk-external-dialog", { answerId: this.answerId, code: this.code, questionId: this.questionId, isRequired: this.isRequired }, h("slot", null)));
    }
    renderInternal() {
        return (h("dialog", { open: this.isOpen, class: `bp-sdk-dialog__container bp-sdk-dialog__container-${this.answerId} bp-sdk-dialog__container-${this.code}` }, h("div", { class: "bp-sdk-dialog__header bp-sdk-row" }, !this.isRequired && h("bp-sdk-dialog-close-button", { onClick: this.onClick })), h("slot", null)));
    }
    static get is() { return "bp-sdk-dialog"; }
    static get originalStyleUrls() {
        return {
            "$": ["./bp-sdk-dialog.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-dialog.css"]
        };
    }
    static get properties() {
        return {
            "answerId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Answer id"
                },
                "attribute": "answer-id",
                "reflect": false
            },
            "code": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Question code"
                },
                "attribute": "code",
                "reflect": false
            },
            "questionId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Question Id"
                },
                "attribute": "question_id",
                "reflect": false
            },
            "isRequired": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Is required"
                },
                "attribute": "is-required",
                "reflect": false,
                "defaultValue": "true"
            }
        };
    }
    static get states() {
        return {
            "useExternal": {},
            "isOpen": {}
        };
    }
}
