import { h } from "@stencil/core";
import { generateId } from "@boldpenguin/sdk-utility";
export class BpSdkVehicleVinInput {
    constructor() {
        this.code = undefined;
        this.label = undefined;
        this.pristine = true;
        this.touched = false;
        this.errors = [];
        this.value = undefined;
        this.labelId = generateId(8);
        this.useExternal = false;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-vehicle-vin-input');
        customElements.whenDefined('bp-sdk-external-vehicle-vin-input').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (h("bp-sdk-external-vehicle-vin-input", { code: this.code, errors: this.errors, label: this.label, pristine: this.pristine, touched: this.touched }));
    }
    renderInternal() {
        return (h("div", { class: "bp-sdk-vehicle-vin-input__container" }, h("bp-sdk-text-input", { code: this.code, errors: this.errors, fieldType: 'text', label: this.label, labelId: this.labelId, placeholder: "Vin", pristine: this.pristine, questionId: this.labelId, touched: this.touched, text: this.value })));
    }
    static get is() { return "bp-sdk-vehicle-vin-input"; }
    static get originalStyleUrls() {
        return {
            "$": ["./bp-sdk-vehicle-vin-input.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-vehicle-vin-input.css"]
        };
    }
    static get properties() {
        return {
            "code": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "code to use"
                },
                "attribute": "code",
                "reflect": false
            },
            "label": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Label to display"
                },
                "attribute": "label",
                "reflect": false
            },
            "pristine": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Is pristine"
                },
                "attribute": "pristine",
                "reflect": false,
                "defaultValue": "true"
            },
            "touched": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Is touched"
                },
                "attribute": "touched",
                "reflect": false,
                "defaultValue": "false"
            },
            "errors": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "string[]",
                    "resolved": "string[]",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Error messages"
                },
                "defaultValue": "[]"
            },
            "value": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Value of input"
                },
                "attribute": "value",
                "reflect": false
            }
        };
    }
    static get states() {
        return {
            "labelId": {},
            "useExternal": {}
        };
    }
}
