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 CancellationPolicySchema = create$3({
    cancellation_policy_disclosure: create$6().nullable(),
    cancellation_rebuttal: create$6().nullable(),
});

const CancellationPolicy = /*@__PURE__*/ proxyCustomElement(class CancellationPolicy extends HTMLElement {
    constructor(registerHost) {
        super();
        if (registerHost !== false) {
            this.__registerHost();
        }
        this.documentErrors = {};
        this.errors = {};
        this.documents = { cancellation_policy: [] };
        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.cancellationPolicy));
    }
    ;
    componentWillLoad() {
        this.form = new FormController(CancellationPolicySchema);
    }
    componentDidLoad() {
        this.form.errors.subscribe(errors => {
            this.errors = Object.assign({}, errors);
        });
    }
    render() {
        var _a, _b, _c;
        return (h("div", { key: '8812e04b5497b1b75d4afcc18084ff224efe11e0' }, h("div", { key: 'fd414b2ebd443b490ec68bb1788efce0824877e6', class: "row gy-3" }, h("div", { key: '300e7b1afa78dac54bd3240af7ad1bdd6f386134', class: "col-12" }, h("h2", { key: 'c85c78cf40224ad06db9746c929d312d6ac53613', class: "h5", part: heading5 }, "Cancellation Policy")), h("div", { key: 'fab79ca4fb6f343674698b87fd5e713c6028ce8b', class: "col-12" }, h("form-control-textarea", { key: '106094d74237d258091a60d14e0bdeecf1106584', label: "Cancellation Policy Disclosure", name: "cancellation_policy_disclosure", defaultValue: (_a = this.disputeResponse) === null || _a === void 0 ? void 0 : _a.cancellation_policy_disclosure, inputHandler: this.inputHandler, errorText: this.errors.cancellation_policy_disclosure })), h("div", { key: 'ac5d1d534d30176483fc490947e3bf65fe41afa3', class: "col-12" }, h("form-control-textarea", { key: 'd0972bf1837f9f23de6925517756ec18e1fac3fe', label: "Cancellation Rebuttal", name: "cancellation_rebuttal", defaultValue: (_b = this.disputeResponse) === null || _b === void 0 ? void 0 : _b.cancellation_rebuttal, inputHandler: this.inputHandler, errorText: this.errors.cancellation_rebuttal })), h("div", { key: '135463253e19c6a2d5ff86b04413e6838f824a89', class: "col-12" }, h("form-control-file-v2", { key: 'ef0a3a1d1113f5cb4e97bbf1017841b75463f690', label: "Upload Cancellation Policy", name: "cancellation_policy", onChange: (e) => fileInputHandler(e, this.documents), errorText: (_c = this.documentErrors) === null || _c === void 0 ? void 0 : _c.cancellation_policy })))));
    }
}, [256, "cancellation-policy", {
        "disputeResponse": [8, "dispute-response"],
        "documentErrors": [8, "document-errors"],
        "form": [32],
        "errors": [32],
        "documents": [32],
        "validateAndSubmit": [64]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["cancellation-policy", "custom-popper", "form-control-file-v2", "form-control-help-text", "form-control-textarea", "form-control-tooltip"];
    components.forEach(tagName => { switch (tagName) {
        case "cancellation-policy":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, CancellationPolicy);
            }
            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 { CancellationPolicy as C, defineCustomElement as d };
