'use strict';

var index = require('./index-p7cvUYAE.js');
var businessFormOptions = require('./business-form-options-CnlrfbQ6.js');
var formInputMasks = require('./form-input-masks-BnNFJ3IJ.js');
var parts = require('./parts-BXshb_S-.js');
var Business = require('./Business-oBifyXkW.js');
var countryConfig = require('./country-config-C1bWmF8P.js');

const AdditionalQuestions = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.errors = {};
        this.additional_questions = {};
        this.inputHandler = this.inputHandler.bind(this);
    }
    componentDidLoad() {
        this.formController.errors.subscribe(errors => (this.errors = Object.assign({}, errors)));
        this.formController.values.subscribe(values => (this.additional_questions = Object.assign({}, values.additional_questions)));
    }
    inputHandler(name, value) {
        this.formController.setValues(Object.assign(Object.assign({}, this.formController.values.getValue()), { additional_questions: Object.assign(Object.assign({}, this.formController.values.getValue().additional_questions), { [name]: value }) }));
    }
    render() {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
        const additionalQuestionsDefaultValue = this.formController.getInitialValues().additional_questions;
        return (index.h(index.Host, { key: '05b69febfcd1e3901109c2cf64d812ff766b81cc' }, index.h("fieldset", { key: '84f06779dff94622fc7d14fdca53efb84f11e8cd' }, index.h("legend", { key: '3079e5d172c833d8172660f2f66b4d9637bfdb21', part: parts.heading2 }, "Additional Questions"), index.h("div", { key: 'cf5155033143279316822237a84a0ad5e292a6cd', class: "row gy-3" }, index.h("div", { key: 'e28450dacb0d7040d62a4820c0252d95792d7e87', class: "col-12 col-md-6" }, index.h("form-control-monetary-provisioning", { key: 'e2ac8f211ffd9848fab123bc7826fd9f18e109a8', name: "business_revenue", label: "What is the business' estimated annual revenue from its primary business activities?", inputHandler: this.inputHandler, errorText: (_b = (_a = this.errors) === null || _a === void 0 ? void 0 : _a.additional_questions) === null || _b === void 0 ? void 0 : _b.business_revenue, defaultValue: additionalQuestionsDefaultValue === null || additionalQuestionsDefaultValue === void 0 ? void 0 : additionalQuestionsDefaultValue.business_revenue, maskOptions: formInputMasks.CURRENCY_MASK.WHOLE })), index.h("div", { key: 'c5de85cd5e7b1501a0667a49d8d4826971e93052', class: "col-12 col-md-6" }, index.h("form-control-monetary-provisioning", { key: '3da3805e4ddbc633f060d36487b46e76e4f6eb04', name: "business_payment_volume", label: "What is the business' annual credit card & ACH volume anticipated to process?", inputHandler: this.inputHandler, errorText: (_d = (_c = this.errors) === null || _c === void 0 ? void 0 : _c.additional_questions) === null || _d === void 0 ? void 0 : _d.business_payment_volume, defaultValue: additionalQuestionsDefaultValue === null || additionalQuestionsDefaultValue === void 0 ? void 0 : additionalQuestionsDefaultValue.business_payment_volume, maskOptions: formInputMasks.CURRENCY_MASK.WHOLE })), index.h("div", { key: 'ad62fecba837464fddba48273635bc8ae3a7d7ed', class: "col-12" }, index.h("form-control-select", { key: '9f09093b45c1c8eeb63065402f4b15e31c166d51', name: 'business_when_service_received', label: 'On average, how long after paying will your customers typically receive their goods or services?', inputHandler: this.inputHandler, errorText: (_f = (_e = this.errors) === null || _e === void 0 ? void 0 : _e.additional_questions) === null || _f === void 0 ? void 0 : _f.business_when_service_received, options: businessFormOptions.businessServiceReceivedOptions, defaultValue: additionalQuestionsDefaultValue === null || additionalQuestionsDefaultValue === void 0 ? void 0 : additionalQuestionsDefaultValue.business_when_service_received })), index.h("div", { key: 'e2a05cbb74138a554033817e3bb1372933e64b99', class: "col-12" }, index.h("form-control-select", { key: '8a95d74c02f2cf662f6cf0658faeae1a1a8f6a11', name: 'business_recurring_payments', label: 'Does your business offer recurring payments?', inputHandler: this.inputHandler, errorText: (_h = (_g = this.errors) === null || _g === void 0 ? void 0 : _g.additional_questions) === null || _h === void 0 ? void 0 : _h.business_recurring_payments, options: businessFormOptions.recurringPaymentsOptions, defaultValue: additionalQuestionsDefaultValue === null || additionalQuestionsDefaultValue === void 0 ? void 0 : additionalQuestionsDefaultValue.business_recurring_payments })), index.h("div", { key: '8d94059b0966237c980b1c1622e1ed3fd5bd8a58', class: "col-12" }, index.h("form-control-text", { key: '320fa784aef300393ddfcca4f2ef4798d207bf30', name: 'business_recurring_payments_percentage', label: 'What percent of revenue is generated from each recurring payment type offered?', inputHandler: this.inputHandler, errorText: (_k = (_j = this.errors) === null || _j === void 0 ? void 0 : _j.additional_questions) === null || _k === void 0 ? void 0 : _k.business_recurring_payments_percentage, defaultValue: additionalQuestionsDefaultValue === null || additionalQuestionsDefaultValue === void 0 ? void 0 : additionalQuestionsDefaultValue.business_recurring_payments_percentage })), index.h("div", { key: '8525c21ec91e652737455e7b093ff280800d97c2', class: "col-12" }, index.h("form-control-select", { key: 'c2cba23606b03f758ba704c074a65a212e111998', name: 'business_seasonal', label: 'Is this business seasonal?', inputHandler: this.inputHandler, errorText: (_m = (_l = this.errors) === null || _l === void 0 ? void 0 : _l.additional_questions) === null || _m === void 0 ? void 0 : _m.business_seasonal, options: businessFormOptions.seasonalBusinessOptions, defaultValue: additionalQuestionsDefaultValue === null || additionalQuestionsDefaultValue === void 0 ? void 0 : additionalQuestionsDefaultValue.business_seasonal })), index.h("div", { key: 'c047c43284fbe92952c487544bc8206c98433edc', class: "col-12" }, index.h("form-control-text", { key: '27348b1899f8b8f7f18a0618aa4dcb812a3bef04', name: 'business_other_payment_details', label: 'Is there anything else you would like us to know about how your customers pay the business?', inputHandler: this.inputHandler, errorText: (_p = (_o = this.errors) === null || _o === void 0 ? void 0 : _o.additional_questions) === null || _p === void 0 ? void 0 : _p.business_other_payment_details, defaultValue: additionalQuestionsDefaultValue === null || additionalQuestionsDefaultValue === void 0 ? void 0 : additionalQuestionsDefaultValue.business_other_payment_details }))))));
    }
};

const BusinessCoreInfo = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.errors = {};
        this.coreInfo = {};
        this.isEditingTaxId = false;
        this.inputHandler = this.inputHandler.bind(this);
    }
    componentDidLoad() {
        this.formController.values.subscribe(values => (this.coreInfo = Object.assign({}, new Business.CoreBusinessInfo(values))));
        this.formController.errors.subscribe(errors => {
            this.errors = Object.assign({}, errors);
        });
    }
    inputHandler(name, value) {
        this.formController.setValues(Object.assign(Object.assign({}, this.formController.values.getValue()), { [name]: value }));
    }
    render() {
        var _a, _b;
        const coreInfoDefaultValue = this.formController.getInitialValues();
        return (index.h(index.Host, { key: '9c73706505c1fa0a56d7eb68fc1c4c0a6fffd1dc' }, index.h("fieldset", { key: 'd30bae9bab7ffd0e385ce276e7797cfd606e5a42' }, index.h("legend", { key: '5792db95cbbc080f3c990b4b9cea84484f374ec3', part: parts.heading2 }, "General Info"), index.h("div", { key: 'ae7fa3c788d625d60cfc83b270312946dce97f0b', class: "row gy-3" }, index.h("div", { key: 'f7e5ab1ec57a8ce8de5ef8591ecad8b2fbd2f030', class: "col-12" }, index.h("form-control-text", { key: 'fa96501ceca053263029489a74bddd31222b1462', name: "legal_name", label: "Legal Name", defaultValue: coreInfoDefaultValue.legal_name, errorText: this.errors.legal_name, inputHandler: this.inputHandler })), index.h("div", { key: '21e14d0c13017376d7e74e84169f30fe05fa13af', class: "col-12" }, index.h("form-control-text", { key: '266187ec2209299a4b0ebc4c7d600c670de3b21f', name: "doing_business_as", label: "Doing Business As (DBA)", defaultValue: coreInfoDefaultValue.doing_business_as, errorText: this.errors.doing_business_as, inputHandler: this.inputHandler })), index.h("div", { key: 'd9bbb19b4ec15a18a0467444e964512114e74031', class: "col-12 col-md-8" }, index.h("form-control-select", { key: 'fe490b4abb4a1e07392db9ad4e4c15b02d928f4c', name: "classification", label: "Business Classification", options: businessFormOptions.businessClassificationOptions, defaultValue: coreInfoDefaultValue.classification, errorText: this.errors.classification, inputHandler: this.inputHandler })), index.h("div", { key: 'fc5dafdace199fd34d22f22d629d87fc8ff7cc3e', class: "col-12 col-md-4" }, index.h("form-control-date", { key: '0263cdef27d1b36c22bde16dbdb3777ad9ef62e3', name: "date_of_incorporation", label: "Date of Incorporation", defaultValue: coreInfoDefaultValue.date_of_incorporation, errorText: this.errors.date_of_incorporation, inputHandler: this.inputHandler })), index.h("div", { key: '2ae2b710d615e5314d4b836b9a498fc9140b749a', class: "col-12 col-md-6" }, index.h("form-control-text", { key: 'f6e738254ff7ead5680b895b6df77dc58efbc393', name: "industry", label: "Industry", defaultValue: coreInfoDefaultValue.industry, errorText: this.errors.industry, inputHandler: this.inputHandler })), index.h("div", { key: '8a01de0514d495b103aa43070d268070f57af62a', class: "col-12 col-md-6" }, (!((_a = this.coreInfo) === null || _a === void 0 ? void 0 : _a.tax_id_last4) || this.isEditingTaxId) ? (index.h("form-control-number-masked", { name: "tax_id", label: countryConfig.countryLabels[this.country].taxIdLabelOptional || countryConfig.countryLabels[this.country].taxIdLabel, defaultValue: this.isEditingTaxId ? '' : coreInfoDefaultValue.tax_id, errorText: this.errors.tax_id, inputHandler: this.inputHandler, mask: formInputMasks.IDENTITY_MASKS[this.country], helpText: countryConfig.countryLabels[this.country].taxIdHelpText })) : (index.h("div", null, index.h("label", { class: "form-label", part: parts.label }, countryConfig.countryLabels[this.country].taxIdLabel), index.h("div", { class: "input-group mb-3" }, index.h("input", { type: "text", class: "form-control", part: parts.inputDisabled, value: `****${(_b = this.coreInfo) === null || _b === void 0 ? void 0 : _b.tax_id_last4}`, disabled: true }), index.h("button", { class: "btn btn-secondary", type: "button", part: parts.buttonSecondary, onClick: () => {
                this.isEditingTaxId = true;
                this.formController.setValues(Object.assign(Object.assign({}, this.formController.values.getValue()), { tax_id: '' }));
            } }, "Change"))))), index.h("div", { key: 'a82eb6e652eb36fd57cd4a6c413e896aebfefce6', class: "col-12" }, index.h("form-control-text", { key: '930f882235d7c4902ae6daf54d644a0cd9d23daf', name: "website_url", label: "Website URL", defaultValue: coreInfoDefaultValue.website_url, errorText: this.errors.website_url, inputHandler: this.inputHandler })), index.h("div", { key: 'b2e819e6dfd97229e81e1860e1debe3ab95e3dc0', class: "col-12 col-md-6" }, index.h("form-control-text", { key: '7a4a158a1c64adfe90b825ff54c9f1f607c25bb7', name: "email", label: "Email Address", defaultValue: coreInfoDefaultValue.email, errorText: this.errors.email, inputHandler: this.inputHandler })), index.h("div", { key: '948c4f98a4a7a8b898058adb0957b7251d8c9fe4', class: "col-12 col-md-6" }, index.h("form-control-number-masked", { key: 'dc5804f3c9254c859f5e6a78487dae423c9689f1', name: "phone", label: "Phone Number", defaultValue: coreInfoDefaultValue.phone, errorText: this.errors.phone, inputHandler: this.inputHandler, mask: formInputMasks.PHONE_MASKS.US }))))));
    }
};

const BusinessRepresentative = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.errors = {};
        this.representative = {};
        this.isEditingIdentification = false;
        this.inputHandler = (name, value) => {
            this.formController.setValues(Object.assign(Object.assign({}, this.formController.values.getValue()), { representative: Object.assign(Object.assign({}, this.formController.values.getValue().representative), { [name]: value }) }));
        };
        this.onAddressFormUpdate = (values) => {
            this.formController.setValues(Object.assign(Object.assign({}, this.formController.values.getValue()), { representative: Object.assign(Object.assign({}, this.formController.values.getValue().representative), { address: Object.assign(Object.assign({}, this.formController.values.getValue().representative.address), values) }) }));
        };
        this.onDateOfBirthUpdate = (event) => {
            const dob_values = Business.deconstructDate(event.detail);
            this.formController.setValues(Object.assign(Object.assign({}, this.formController.values.getValue()), { representative: Object.assign(Object.assign({}, this.formController.values.getValue().representative), { dob_day: dob_values.dob_day, dob_month: dob_values.dob_month, dob_year: dob_values.dob_year }) }));
        };
    }
    get identificationNumberLabel() {
        var _a;
        const label = countryConfig.countryLabels[this.country].idNumberLabel;
        const labelOptional = countryConfig.countryLabels[this.country].idNumberLabelOptional;
        return (((_a = this.representative) === null || _a === void 0 ? void 0 : _a.ssn_last4) || this.country === Business.CountryCode.CAN) ? labelOptional : label;
    }
    componentDidLoad() {
        this.formController.errors.subscribe(errors => (this.errors = Object.assign({}, errors.representative)));
        this.formController.values.subscribe(values => (this.representative = Object.assign({}, values.representative)));
    }
    render() {
        var _a, _b;
        const representativeDefaultValue = this.formController.getInitialValues().representative;
        return (index.h(index.Host, { key: '9045242989e4d43d1e7b0770d0c5421005db78fa' }, index.h("fieldset", { key: '6643f8bd8e81bbc64ae8a0e9bcf317e16f91bab9' }, index.h("legend", { key: '20b897584a059ad98c109a37a3ea74c8be4b407c', part: parts.heading2 }, "Representative"), index.h("div", { key: '37da5bfb73a7606c6180c151761aaf13dcc819c4', class: "row gy-3" }, index.h("div", { key: '8d76accd442d9fda35ae4d3e1c47b65e17f098a0', class: "col-12 col-md-8" }, index.h("form-control-text", { key: '2eadd087eac463e851192d8ee1c30390a29ee8b2', name: "name", label: "Full Name", defaultValue: representativeDefaultValue === null || representativeDefaultValue === void 0 ? void 0 : representativeDefaultValue.name, errorText: this.errors.name, inputHandler: this.inputHandler })), index.h("div", { key: 'f495a8cb3c6a0e9b4a00aac3e8c77f66da84b9e2', class: "col-12 col-md-4" }, index.h("form-control-select", { key: '4b7669b96b7df9a387cf3c4f9638ea9ada9f37ee', name: "title", label: "Title", options: businessFormOptions.businessTitleOptions, defaultValue: representativeDefaultValue === null || representativeDefaultValue === void 0 ? void 0 : representativeDefaultValue.title, errorText: this.errors.title, inputHandler: this.inputHandler })), index.h("div", { key: '3e10f464a7e26a9518b4ce6d37c6f4a968514f98', class: "col-12 col-md-6" }, index.h("form-control-text", { key: 'a0d51c6999295428bfdcb43ef4b0ec15194eb077', name: "email", label: "Email Address", defaultValue: representativeDefaultValue === null || representativeDefaultValue === void 0 ? void 0 : representativeDefaultValue.email, errorText: this.errors.email, inputHandler: this.inputHandler })), index.h("div", { key: 'a8e1a4c8e4fa5a50d436c18e41a5b77f23bc53cf', class: "col-12 col-md-6" }, index.h("form-control-number-masked", { key: 'a72115bf51fc97a25add717c208e820c7e9e5495', name: "phone", label: "Phone Number", defaultValue: representativeDefaultValue === null || representativeDefaultValue === void 0 ? void 0 : representativeDefaultValue.phone, errorText: this.errors.phone, inputHandler: this.inputHandler, mask: formInputMasks.PHONE_MASKS.US })), index.h("div", { key: 'db04f552f1757b6ac4e10539e4a148f399a75192', class: "col-12 col-md-4" }, index.h("form-control-date", { key: 'cb07a2cc4e6fc242d643f9caea01db380a9ff366', name: "dob_full", label: "Birth Date", defaultValue: representativeDefaultValue === null || representativeDefaultValue === void 0 ? void 0 : representativeDefaultValue.dob_full, errorText: this.errors.dob_full, inputHandler: this.inputHandler, onFormControlInput: this.onDateOfBirthUpdate })), index.h("div", { key: '95348511ba3b1582053f754249b15efe4d707252', class: "col-12 col-md-8" }, (!((_a = this.representative) === null || _a === void 0 ? void 0 : _a.ssn_last4) || this.isEditingIdentification) ? (index.h("form-control-number-masked", { name: "identification_number", label: this.identificationNumberLabel, defaultValue: this.isEditingIdentification ? '' : representativeDefaultValue === null || representativeDefaultValue === void 0 ? void 0 : representativeDefaultValue.identification_number, errorText: this.errors.identification_number, inputHandler: this.inputHandler, mask: formInputMasks.IDENTITY_MASKS[this.country], helpText: countryConfig.countryLabels[this.country].identityHelpText })) : (index.h("div", null, index.h("label", { class: "form-label", part: parts.label }, this.identificationNumberLabel), index.h("div", { class: "input-group mb-3" }, index.h("input", { type: "text", class: "form-control", part: parts.inputDisabled, value: `****${(_b = this.representative) === null || _b === void 0 ? void 0 : _b.ssn_last4}`, disabled: true }), index.h("button", { class: "btn btn-secondary", type: "button", part: parts.buttonSecondary, onClick: () => {
                this.isEditingIdentification = true;
                // Clear last4 and current value to force validation
                this.formController.setValues(Object.assign(Object.assign({}, this.formController.values.getValue()), { representative: Object.assign(Object.assign({}, this.formController.values.getValue().representative), { ssn_last4: null, identification_number: '' }) }));
            } }, "Change"))))), index.h("div", { key: '57dcdaad0ec89f94d82236bfc8e093b68b7ec478', class: "col-12" }, index.h("identity-address-form", { key: '0ea02562077d352c5d3a1d0903dee1e8b69fa6f1', errors: this.errors.address, defaultValues: representativeDefaultValue === null || representativeDefaultValue === void 0 ? void 0 : representativeDefaultValue.address, handleFormUpdate: this.onAddressFormUpdate, country: this.country }))))));
    }
};

const FormAlert = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
    }
    render() {
        if (!this.text) {
            return null;
        }
        if (this.hideAlert) {
            return null;
        }
        return (index.h("div", { class: 'alert alert-danger d-flex align-items-center', role: 'alert', part: parts.alertDanger }, index.h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", fill: "currentColor", class: "bi bi-exclamation-triangle-fill flex-shrink-0 me-2", viewBox: "0 0 16 16", role: "img", "aria-label": "Warning:" }, index.h("path", { d: "M8.982 1.566a1.13 1.13 0 0 0-1.96 0L.165 13.233c-.457.778.091 1.767.98 1.767h13.713c.889 0 1.438-.99.98-1.767L8.982 1.566zM8 5c.535 0 .954.462.9.995l-.35 3.507a.552.552 0 0 1-1.1 0L7.1 5.995A.905.905 0 0 1 8 5zm.002 6a1 1 0 1 1 0 2 1 1 0 0 1 0-2z" })), index.h("div", null, this.text)));
    }
};

const LegalAddressForm = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        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 (index.h(index.Host, { key: '856cd25caef521b651b9dd8a40dc6f9f0c727706' }, index.h("fieldset", { key: '150ad1f56747aae80ae8d2610fa08fcabee27c87' }, index.h("legend", { key: '565a46bd0977680e400663ef0590d65e977135be', part: parts.heading2 }, "Business Legal Address"), index.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 }))));
    }
};

exports.additional_questions = AdditionalQuestions;
exports.business_core_info = BusinessCoreInfo;
exports.business_representative = BusinessRepresentative;
exports.form_alert = FormAlert;
exports.legal_address_form = LegalAddressForm;
