import { h } from "@stencil/core";
export class BpSdkTakeOver {
    constructor() {
        this.isLocked = undefined;
        this.isCloned = undefined;
        this.canTakeOver = undefined;
        this.isOwner = undefined;
        this.isFormLoaded = undefined;
        this.takeOverHandler = undefined;
        this.useExternal = false;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-take-over');
        customElements.whenDefined('bp-sdk-external-take-over').then(() => {
            this.useExternal = true;
        });
    }
    shouldRender() {
        return this.isFormLoaded && this.canTakeOver && !this.isOwner && !this.isCloned && !this.isLocked;
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (h("bp-sdk-external-take-over", { canTakeOver: this.canTakeOver, isCloned: this.isCloned, isLocked: this.isLocked, isOwner: this.isOwner, isFormLoaded: this.isFormLoaded, shouldRender: this.shouldRender(), takeOverHandler: this.takeOverHandler }));
    }
    renderInternal() {
        return (this.shouldRender() && (h("div", { class: "bp-sdk-take-over__container" }, h("bp-sdk-take-over-button", { onClick: this.takeOverHandler }))));
    }
    static get is() { return "bp-sdk-take-over"; }
    static get originalStyleUrls() {
        return {
            "$": ["./bp-sdk-take-over.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-take-over.css"]
        };
    }
    static get properties() {
        return {
            "isLocked": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Flag to indicate if application form is locked"
                },
                "attribute": "is-locked",
                "reflect": false
            },
            "isCloned": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Flag to indicate if application form is cloned"
                },
                "attribute": "is-cloned",
                "reflect": false
            },
            "canTakeOver": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Flag to indicate if user has permission to take over application form"
                },
                "attribute": "can-take-over",
                "reflect": false
            },
            "isOwner": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Flag to indicate if user is owner of application form"
                },
                "attribute": "is-owner",
                "reflect": false
            },
            "isFormLoaded": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Flag to indicate if there is an application form currently loaded"
                },
                "attribute": "is-form-loaded",
                "reflect": false
            },
            "takeOverHandler": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "() => void",
                    "resolved": "() => void",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Take over handler function"
                }
            }
        };
    }
    static get states() {
        return {
            "useExternal": {}
        };
    }
}
