import { Host, h } from "@stencil/core";
import { heading2 } from "../../../../styles/parts";
export class LegalAddressForm {
    constructor() {
        this.errors = {};
        this.inputHandler = this.inputHandler.bind(this);
    }
    componentDidLoad() {
        this.formController.errors.subscribe(errors => (this.errors = Object.assign({}, errors)));
        this.formController.values.subscribe(values => (this.legal_address = Object.assign({}, values.legal_address)));
    }
    inputHandler(name, value) {
        this.formController.setValues(Object.assign(Object.assign({}, this.formController.values.getValue()), { legal_address: Object.assign(Object.assign({}, this.formController.values.getValue().legal_address), { [name]: value }) }));
    }
    render() {
        var _a;
        const legalAddressDefaultValue = this.formController.getInitialValues().legal_address;
        return (h(Host, { key: '856cd25caef521b651b9dd8a40dc6f9f0c727706' }, h("fieldset", { key: '150ad1f56747aae80ae8d2610fa08fcabee27c87' }, h("legend", { key: '565a46bd0977680e400663ef0590d65e977135be', part: heading2 }, "Business Legal Address"), h("form-address-fields", { key: 'c2ce05c006ec80c5319b30b40387e400ec52ab86', country: this.country, errors: (_a = this.errors) === null || _a === void 0 ? void 0 : _a.legal_address, defaultValues: legalAddressDefaultValue, inputHandler: this.inputHandler }))));
    }
    static get is() { return "legal-address-form"; }
    static get properties() {
        return {
            "formController": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "FormController",
                    "resolved": "FormController",
                    "references": {
                        "FormController": {
                            "location": "import",
                            "path": "../../../../components",
                            "id": "src/components.d.ts::FormController"
                        }
                    }
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false
            },
            "country": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "CountryCode",
                    "resolved": "CountryCode.CAN | CountryCode.USA",
                    "references": {
                        "CountryCode": {
                            "location": "import",
                            "path": "../../../../utils/country-codes",
                            "id": "src/utils/country-codes.ts::CountryCode"
                        }
                    }
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "country"
            }
        };
    }
    static get states() {
        return {
            "errors": {},
            "legal_address": {}
        };
    }
}
