import { h } from "@stencil/core";
export class BpSdkBackButton {
    constructor() {
        this.text = '';
        this.icon = 'chevron-left';
        this.buttonDisabled = false;
        this.cssClasses = undefined;
        this.useExternal = false;
    }
    resetState() { }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-back-button');
        customElements.whenDefined('bp-sdk-external-back-button').then(() => {
            this.useExternal = true;
        });
        this.isButtonDisabled(this.buttonDisabled);
    }
    isButtonDisabled(isDisabled) {
        this.buttonDisabled = isDisabled;
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (h("bp-sdk-external-back-button", { buttonDisabled: this.buttonDisabled, cssClasses: this.cssClasses, icon: this.icon, text: this.text }));
    }
    renderInternal() {
        return (h("div", { class: "bp-sdk-back-button__container" }, h("bp-sdk-button", { onClick: () => !this.buttonDisabled && this.navigateBack.emit(), text: this.text, buttonDisabled: this.buttonDisabled, class: this.cssClasses }, h("bp-sdk-icon-container", { name: this.icon }))));
    }
    static get is() { return "bp-sdk-back-button"; }
    static get originalStyleUrls() {
        return {
            "$": ["./bp-sdk-back-button.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-back-button.css"]
        };
    }
    static get properties() {
        return {
            "text": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Back button text"
                },
                "attribute": "text",
                "reflect": false,
                "defaultValue": "''"
            },
            "icon": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Icon name"
                },
                "attribute": "icon",
                "reflect": false,
                "defaultValue": "'chevron-left'"
            },
            "buttonDisabled": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Controls disabled state of button"
                },
                "attribute": "button-disabled",
                "reflect": false,
                "defaultValue": "false"
            },
            "cssClasses": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Extra CSS classes to be added onto the back button"
                },
                "attribute": "css-classes",
                "reflect": false
            }
        };
    }
    static get states() {
        return {
            "useExternal": {}
        };
    }
    static get events() {
        return [{
                "method": "navigateBack",
                "name": "navigateBack",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "Navigate event"
                },
                "complexType": {
                    "original": "void",
                    "resolved": "void",
                    "references": {}
                }
            }];
    }
    static get watchers() {
        return [{
                "propName": "buttonDisabled",
                "methodName": "isButtonDisabled"
            }];
    }
}
