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$4 } from './custom-popper2.js';
import { d as defineCustomElement$3 } from './form-control-file-v22.js';
import { d as defineCustomElement$2 } from './form-control-text2.js';
import { d as defineCustomElement$1 } from './form-control-tooltip2.js';

const ElectronicEvidenceSchema = create$3({
    customer_purchase_ip_address: create$6().nullable(),
});

const ElectronicEvidence = /*@__PURE__*/ proxyCustomElement(class ElectronicEvidence extends HTMLElement {
    constructor(registerHost) {
        super();
        if (registerHost !== false) {
            this.__registerHost();
        }
        this.documentErrors = {};
        this.errors = {};
        this.documents = { activity_log: [] };
        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.electronicEvidence));
    }
    ;
    componentWillLoad() {
        this.form = new FormController(ElectronicEvidenceSchema);
    }
    componentDidLoad() {
        this.form.errors.subscribe(errors => {
            this.errors = Object.assign({}, errors);
        });
    }
    render() {
        var _a, _b;
        return (h("div", { key: 'cf4615613589be984c7d5b6b50f0b5239895d81d' }, h("div", { key: '1f96c50146d009cc4d0d0ccbee41c31144e7f746', class: "row gy-3" }, h("div", { key: '3a671ff5c959efaee8dc57dda073de113489f0a6', class: "col-12" }, h("h2", { key: '3b73879b357d3465c6c76b27db17b6dbdce7c538', class: "h5", part: heading5 }, "Electronic Evidence")), h("div", { key: '35c0ff43bc1dcdba8916b51da636347395c98901', class: "col-12" }, h("form-control-text", { key: 'cdabf70034babf41ba227f66936f8b340f104ca3', label: "Purchase IP Address", name: "customer_purchase_ip_address", helpText: "The IP address used by the customer during the purchase.", defaultValue: (_a = this.disputeResponse) === null || _a === void 0 ? void 0 : _a.customer_purchase_ip_address, inputHandler: this.inputHandler, errorText: this.errors.customer_purchase_ip_address })), h("div", { key: 'd9920bf1548e14c6adadbc63dc41a1a90cc1a3cc', class: "col-12" }, h("form-control-file-v2", { key: '8eec5b79872eeeda77702d9f4cc9003a627e6682', label: "Activity Logs", name: "activity_log", helpText: "Any server or activity logs that provide evidence of the customer's access to or download of the purchased digital product. This information should encompass IP addresses, relevant timestamps, and any detailed records of activity.", onChange: (e) => fileInputHandler(e, this.documents), errorText: (_b = this.documentErrors) === null || _b === void 0 ? void 0 : _b.activity_log })))));
    }
}, [256, "electronic-evidence", {
        "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 = ["electronic-evidence", "custom-popper", "form-control-file-v2", "form-control-text", "form-control-tooltip"];
    components.forEach(tagName => { switch (tagName) {
        case "electronic-evidence":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, ElectronicEvidence);
            }
            break;
        case "custom-popper":
            if (!customElements.get(tagName)) {
                defineCustomElement$4();
            }
            break;
        case "form-control-file-v2":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "form-control-text":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "form-control-tooltip":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}
defineCustomElement();

export { ElectronicEvidence as E, defineCustomElement as d };
