import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-CV0Pyo1O.js';
import { a3 as inputInvalidAndFocused, v as inputFocused, q as inputInvalid, w as input, x as label, u as inputDisabled, a0 as buttonSecondary } from './parts-CPKMvyV_.js';
import { F as FormControlHelpText } from './form-control-help-text-DGMpMuAm.js';
import { F as FormControlErrorText } from './form-control-error-text-Di9QePY5.js';
import './event-types-CZfYo5-1.js';
import { I as IDENTITY_MASKS, P as PHONE_MASKS } from './form-input-masks-CVaOFfrI.js';
import { u as updateFormValues, a as updateAddressFormValues, b as updateDateOfBirthFormValues } from './input-handlers-1lVyzImK.js';
import { C as CountryCode } from './Business-BcNb9bVO.js';
import { c as countryLabels } from './country-config-CEJVOOGe.js';
import { b as businessTitleOptions } from './business-form-options-DXjZp4Rl.js';

const FormControlNumber = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.formControlInput = createEvent(this, "formControlInput", 7);
        this.formControlBlur = createEvent(this, "formControlBlur", 7);
        this.isFocused = false;
        this.disabled = false;
        this.handleFormControlInput = (event) => {
            const target = event.target;
            const name = target.getAttribute('name');
            this.inputHandler(name, target.value);
            this.formControlInput.emit({ name, value: target.value });
        };
        this.updateInput = (newValue) => {
            const inputElement = this.el.querySelector('input');
            if (inputElement) {
                inputElement.value = newValue || '';
            }
        };
    }
    handleDefaultValueChange(newValue) {
        this.updateInput(newValue);
    }
    componentDidLoad() {
        this.updateInput(this.defaultValue);
    }
    get part() {
        if (this.isFocused && this.errorText) {
            return inputInvalidAndFocused;
        }
        if (this.isFocused) {
            return inputFocused;
        }
        if (this.errorText) {
            return inputInvalid;
        }
        return input;
    }
    render() {
        return (h(Host, { key: 'a47de1fbb4fbd97b47c4dc934d58a628c65f1dbf' }, h("div", { key: 'bbd063c3f0c68bdad5f1849fed8ac318ebb423ef', class: 'form-group d-flex flex-column' }, h("label", { key: '796cb0253dc523ceb21464f3ce528509abffecfa', part: label, class: "form-label", htmlFor: this.name }, this.label), h("input", { key: '8ceaf162d7db2c639b679a431dea7b962593eb09', id: this.name, name: this.name, onFocus: () => this.isFocused = true, onBlur: () => {
                this.isFocused = false;
                this.formControlBlur.emit();
            }, onInput: this.handleFormControlInput, part: this.part, class: this.errorText ? 'form-control is-invalid' : 'form-control', type: "number", disabled: this.disabled }), h(FormControlHelpText, { key: '6935e075c057a55f0af02051eb97310b187ae807', helpText: this.helpText, name: this.name }), h(FormControlErrorText, { key: '019b48db586768219622e657e121772e4f0203c5', errorText: this.errorText, name: this.name }))));
    }
    get el() { return getElement(this); }
    static get watchers() { return {
        "defaultValue": ["handleDefaultValueChange"]
    }; }
};

const OwnerFormInputs = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.isEditingIdentification = false;
        this.inputHandler = (name, value) => {
            updateFormValues(this.formController, { [name]: value });
        };
        this.onAddressFormUpdate = (values) => {
            updateAddressFormValues(this.formController, Object.assign(Object.assign({}, this.formController.values.getValue().address), values));
        };
    }
    render() {
        var _a, _b, _c;
        return (h("div", { key: '6f4bb241699db7c16cb99016363cbbc1a4484a4a', class: "row gy-3" }, h("div", { key: 'fc0317736a62ac34f98f2b7a43a5073d785dfa0d', class: "col-12 col-md-8" }, h("form-control-text", { key: '8123035dfd371841e0830d0019c425d25977c160', name: "name", label: "Full Name", defaultValue: this.ownerDefaultValue.name, errorText: this.errors.name, inputHandler: this.inputHandler })), h("div", { key: 'a16e9ecc81fd4965d3a42b2569a7ea0615ecbf97', class: "col-12 col-md-4" }, h("form-control-select", { key: 'bd9b0ee5c7cf45ac3d67da96f951f167c93033e0', name: "title", label: "Title", options: businessTitleOptions, defaultValue: this.ownerDefaultValue.title, errorText: this.errors.title, inputHandler: this.inputHandler })), h("div", { key: '5376a38a98ad715a3159ccf4e8c8e54b48fa1c7c', class: "col-12 col-md-6" }, h("form-control-text", { key: '7d08e58ae5fc15d5299c8646d5260602a51b9fbf', name: "email", label: "Email Address", defaultValue: this.ownerDefaultValue.email, errorText: this.errors.email, inputHandler: this.inputHandler })), h("div", { key: '6f80f898cb354b40d8d6784110abd5a1c49ff9d9', class: "col-12 col-md-6" }, h("form-control-number-masked", { key: '8a7d577c4c1c5b54f733ee51a1970c17de27d0b0', name: "phone", label: "Phone Number", defaultValue: this.ownerDefaultValue.phone, errorText: this.errors.phone, inputHandler: this.inputHandler, mask: PHONE_MASKS.US })), h("div", { key: '5ace697b3fb38b52dca74ccd49207498b779ade8', class: "col-12 col-md-3" }, h("form-control-date", { key: 'ec8d614b62fe2913c52fd228e7df1fef1b1d7d83', name: "dob_full", label: "Birth Date", defaultValue: this.ownerDefaultValue.dob_full, errorText: this.errors.dob_full, inputHandler: this.inputHandler, onFormControlInput: (e) => updateDateOfBirthFormValues(e, this.formController), helpText: "Must be 18 or older." })), h("div", { key: '8fad1824571295e3464d26191eb23d373591e47d', class: "col-12 col-md-3" }, h("form-control-number", { key: 'c0ffdbf26ea5d65de8c3e98c2cd7d03430d4a8c2', name: "ownership_percentage", label: "% of Ownership", defaultValue: (_a = this.ownerDefaultValue) === null || _a === void 0 ? void 0 : _a.ownership_percentage, errorText: this.errors.ownership_percentage, inputHandler: this.inputHandler })), h("div", { key: '94d93a03f2513bb69da43bd68c3fddc62dbc18d6', class: "col-12 col-md-6" }, (!((_b = this.ownerDefaultValue) === null || _b === void 0 ? void 0 : _b.ssn_last4) || this.isEditingIdentification) ? (h("form-control-number-masked", { name: "identification_number", label: this.country === CountryCode.CAN ? countryLabels[this.country].idNumberLabelOptional : countryLabels[this.country].idNumberLabel, defaultValue: this.isEditingIdentification ? '' : this.ownerDefaultValue.identification_number, errorText: this.errors.identification_number, inputHandler: this.inputHandler, mask: IDENTITY_MASKS[this.country], helpText: countryLabels[this.country].identityHelpText })) : (h("div", null, h("label", { class: "form-label", part: label }, this.country === CountryCode.CAN ? countryLabels[this.country].idNumberLabelOptional : countryLabels[this.country].idNumberLabel), h("div", { class: "input-group mb-3" }, h("input", { type: "text", class: "form-control", part: inputDisabled, value: `****${(_c = this.ownerDefaultValue) === null || _c === void 0 ? void 0 : _c.ssn_last4}`, disabled: true }), h("button", { class: "btn btn-secondary", type: "button", part: buttonSecondary, onClick: () => {
                this.isEditingIdentification = true;
                // Clear last4 and current value to force validation
                updateFormValues(this.formController, {
                    ssn_last4: null,
                    identification_number: ''
                });
            } }, "Change"))))), h("div", { key: '63d73015c84a1ab370b6686a643797b92096212f', class: "col-12" }, h("identity-address-form", { key: '4eff1f856b32e6d31cc18315b5b338c932723cf9', errors: this.errors.address, defaultValues: this.ownerDefaultValue.address, handleFormUpdate: this.onAddressFormUpdate, country: this.country }))));
    }
    ;
};

export { FormControlNumber as form_control_number, OwnerFormInputs as owner_form_inputs };
