import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
import { c as create$3, a as create$6, F as FormController } from './form.js';
import { D as DisputeResponseFormStep, f as fileInputHandler } from './file-input-handler.js';
import { a2 as heading5 } from './parts.js';
import { d as defineCustomElement$5 } from './custom-popper2.js';
import { d as defineCustomElement$4 } from './form-control-file-v22.js';
import { d as defineCustomElement$3 } from './form-control-help-text3.js';
import { d as defineCustomElement$2 } from './form-control-textarea2.js';
import { d as defineCustomElement$1 } from './form-control-tooltip2.js';

const AdditionalStatementSchema = create$3({
    additional_statement: create$6().nullable(),
});

const AdditionalStatement = /*@__PURE__*/ proxyCustomElement(class AdditionalStatement extends HTMLElement {
    constructor(registerHost) {
        super();
        if (registerHost !== false) {
            this.__registerHost();
        }
        this.documentErrors = {};
        this.errors = {};
        this.acceptedTerms = false;
        this.documents = { uncategorized_file: [] };
        this.inputHandler = (name, value) => {
            this.form.setValues(Object.assign(Object.assign({}, this.form.values.getValue()), { [name]: value }));
        };
    }
    async validateAndSubmit(onSuccess) {
        const documentList = Object.values(this.documents).flat();
        this.form.validateAndSubmit((formData) => onSuccess(formData, documentList, DisputeResponseFormStep.additionalStatement));
    }
    ;
    componentWillLoad() {
        this.form = new FormController(AdditionalStatementSchema);
    }
    componentDidLoad() {
        this.form.errors.subscribe(errors => {
            this.errors = Object.assign({}, errors);
        });
    }
    render() {
        var _a, _b;
        return (h("div", { key: 'fc937111b48c5141d31085bb6282fb58cc2d000a' }, h("div", { key: 'c24bc0ce7a89b8c138abed0d7bcf8a81cc910a71', class: "row gy-3" }, h("div", { key: 'ec340664ce128f61c231e8545ae69b1561f704bb', class: "col-12" }, h("h2", { key: '37369432e8ab4d6d871127e8535a675f91f2b07e', class: "h5", part: heading5 }, "Additional Evidence")), h("div", { key: 'f96c72ebf7aaed5c757ca31c251abdbcf09684ae', class: "col-12" }, h("form-control-textarea", { key: '30f0bb97c38ed8782d23f72563d2c679640defea', label: "Is there anything else you would like to say about this dispute?", name: "additional_statement", defaultValue: (_a = this.disputeResponse) === null || _a === void 0 ? void 0 : _a.additional_statement, inputHandler: this.inputHandler, errorText: this.errors.additional_statement })), h("div", { key: '5fd9944de7b9bc0395dc8d791e0d138398162e45', class: "col-12" }, h("form-control-file-v2", { key: '37200d108ab06c455de1469746e122a125d57d75', label: "Additional files", name: "uncategorized_file", multiple: true, helpText: "Upload any additional pieces of evidence that have not already been provided.", onChange: (e) => fileInputHandler(e, this.documents), errorText: (_b = this.documentErrors) === null || _b === void 0 ? void 0 : _b.uncategorized_file })))));
    }
}, [256, "additional-statement", {
        "disputeResponse": [8, "dispute-response"],
        "documentErrors": [8, "document-errors"],
        "form": [32],
        "errors": [32],
        "acceptedTerms": [32],
        "acceptedTermsErrorText": [32],
        "documents": [32],
        "validateAndSubmit": [64]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["additional-statement", "custom-popper", "form-control-file-v2", "form-control-help-text", "form-control-textarea", "form-control-tooltip"];
    components.forEach(tagName => { switch (tagName) {
        case "additional-statement":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, AdditionalStatement);
            }
            break;
        case "custom-popper":
            if (!customElements.get(tagName)) {
                defineCustomElement$5();
            }
            break;
        case "form-control-file-v2":
            if (!customElements.get(tagName)) {
                defineCustomElement$4();
            }
            break;
        case "form-control-help-text":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "form-control-textarea":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "form-control-tooltip":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}
defineCustomElement();

export { AdditionalStatement as A, defineCustomElement as d };
