import { h } from "@stencil/core";
export class BpSdkVehicleYears {
    constructor() {
        this.answerId = undefined;
        this.code = undefined;
        this.label = undefined;
        this.pristine = true;
        this.touched = false;
        this.errors = [];
        this.years = [];
        this.selectedYear = undefined;
        this.isVehicleTrailer = false;
        this.answeredBySource = '';
        this.fieldType = 'dropdown';
        this.inputComponentType = 'dropdown';
        this.useExternal = false;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-vehicle-years');
        customElements.whenDefined('bp-sdk-external-vehicle-years').then(() => {
            this.useExternal = true;
        });
        this.onIsVehicleTrailerChange(this.isVehicleTrailer);
    }
    onIsVehicleTrailerChange(isTrailer) {
        this.fieldType = isTrailer ? 'vehicle' : 'dropdown';
        this.inputComponentType = isTrailer ? 'vehicle' : 'dropdown';
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (h("bp-sdk-external-vehicle-years", { answerId: this.answerId, code: this.code, errors: this.errors, isVehicleTrailer: this.isVehicleTrailer, label: this.label, pristine: this.pristine, selectedYear: this.selectedYear, touched: this.touched, years: this.years }));
    }
    renderInternal() {
        return (h("bp-sdk-dynamic-input", { answerId: this.answerId, choiceId: this.selectedYear, choices: this.years, code: this.code, errors: this.errors, fieldType: this.fieldType, inputComponentType: this.inputComponentType, isAutocomplete: this.isVehicleTrailer, isLabelledField: true, isRequired: true, label: this.label, pristine: this.pristine, referenceType: "years", touched: this.touched, answeredBySource: this.answeredBySource }));
    }
    static get is() { return "bp-sdk-vehicle-years"; }
    static get originalStyleUrls() {
        return {
            "$": ["./bp-sdk-vehicle-years.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-vehicle-years.css"]
        };
    }
    static get properties() {
        return {
            "answerId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The id of the answer associated with this field"
                },
                "attribute": "answer-id",
                "reflect": false
            },
            "code": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The question code associated with this field"
                },
                "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": "[]"
            },
            "years": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "IChoice[]",
                    "resolved": "IChoice[]",
                    "references": {
                        "IChoice": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IChoice"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Year choices"
                },
                "defaultValue": "[]"
            },
            "selectedYear": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string | undefined",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Selected year"
                },
                "attribute": "selected-year",
                "reflect": false
            },
            "isVehicleTrailer": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Is vehicle a trailer"
                },
                "attribute": "is-vehicle-trailer",
                "reflect": false,
                "defaultValue": "false"
            },
            "answeredBySource": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The source a question was answered by, if not answered directly"
                },
                "attribute": "answered-by-source",
                "reflect": false,
                "defaultValue": "''"
            }
        };
    }
    static get states() {
        return {
            "fieldType": {},
            "inputComponentType": {},
            "useExternal": {}
        };
    }
    static get watchers() {
        return [{
                "propName": "isVehicleTrailer",
                "methodName": "onIsVehicleTrailerChange"
            }];
    }
}
