import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
import { f as filterParams, p as propsParams, c as clearParams } from './payouts-list-params-state.js';
import { ad as filterMenu, ae as filterParam } from './parts.js';
import { S as StyledHost } from './styled-host.js';
import './justifi-details2.js';
import './event-types.js';
import './justifi-radio-list-item2.js';
import { e as convertToUTC, h as convertToLocal } from './utils2.js';
import './config-state.js';
import { h as PayoutStatusesSafeNames } from './Plaid.js';
import './Pagination.js';
import './Business.js';
import './ApplePay.js';
import { d as defineCustomElement$6 } from './custom-popper2.js';
import { d as defineCustomElement$5 } from './form-control-date2.js';
import { d as defineCustomElement$4 } from './form-control-select2.js';
import { d as defineCustomElement$3 } from './form-control-tooltip2.js';
import { d as defineCustomElement$2 } from './table-filters-menu2.js';

const JustifiPayoutsListFilters$1 = /*@__PURE__*/ proxyCustomElement(class JustifiPayoutsListFilters extends HTMLElement {
    constructor(registerHost) {
        super();
        if (registerHost !== false) {
            this.__registerHost();
        }
        this.__attachShadow();
        this.setParamsOnChange = (name, value) => {
            filterParams[name] = value;
        };
        this.handleDateInput = (name, value) => {
            const utcDate = convertToUTC(value, { setEndOfDay: true });
            this.setParamsOnChange(name, utcDate);
        };
    }
    componentWillLoad() {
        const propsToSet = {
            status: this.status,
            created_after: this.createdAfter,
            created_before: this.createdBefore
        };
        Object.entries(propsToSet).forEach(([key, value]) => {
            if (value) {
                propsParams[key] = value;
            }
        });
    }
    get statusOptions() {
        return [
            { label: 'All', value: '' },
            { label: PayoutStatusesSafeNames.paid, value: 'paid' },
            { label: PayoutStatusesSafeNames.failed, value: 'failed' },
            { label: PayoutStatusesSafeNames.forwarded, value: 'forwarded' },
            { label: PayoutStatusesSafeNames.scheduled, value: 'scheduled' },
            { label: PayoutStatusesSafeNames.in_transit, value: 'in_transit' },
            { label: PayoutStatusesSafeNames.canceled, value: 'canceled' }
        ];
    }
    render() {
        const filterMenuParams = Object.assign({}, filterParams);
        return (h(StyledHost, { key: '4047a84518ef07a3e9d22f3d6866452dcdd7bab3' }, h("table-filters-menu", { key: 'a1db3d5c8c0bdc44ea7d9dc35f0c460b4b5930ab', params: filterMenuParams, clearParams: clearParams, part: filterMenu }, h("div", { key: '0d8e8244eb9516a97914942e1e0836dd8ab53639', class: "grid-cols-2 gap-3 p-1" }, h("div", { key: '47021850703e8ab104b287b4efa93693272c435b', class: "p-2" }, h("form-control-select", { key: 'f0312f36bc05c4fa6d4e7841624f8d977cdec6c1', name: "status", label: "Status", options: this.statusOptions, inputHandler: this.setParamsOnChange, defaultValue: this.status || filterParams.status || '', disabled: !!this.status, part: filterParam })), h("div", { key: '211ac119c8172aa4e626b7344b25a1df26019aa8', class: "p-2" }, h("form-control-date", { key: '168757bdc92bf54e076d4d5aff63f8a04de65464', name: "created_after", label: "Created After", inputHandler: this.handleDateInput, defaultValue: convertToLocal(this.createdAfter, { showInputDate: true }) ||
                convertToLocal(filterParams.created_after, { showInputDate: true }), disabled: !!this.createdAfter, part: filterParam })), h("div", { key: '43aa8054ba063b70eadfff7240908329f47d1c02', class: "p-2" }, h("form-control-date", { key: '16a86a41c301dd32a6d46067c32d1316c80ceb5d', name: "created_before", label: "Created Before", inputHandler: this.handleDateInput, defaultValue: convertToLocal(this.createdBefore, { showInputDate: true }) ||
                convertToLocal(filterParams.created_before, { showInputDate: true }), disabled: !!this.createdBefore, part: filterParam }))))));
    }
}, [257, "justifi-payouts-list-filters", {
        "status": [1],
        "createdAfter": [1, "created-after"],
        "createdBefore": [1, "created-before"]
    }]);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["justifi-payouts-list-filters", "custom-popper", "form-control-date", "form-control-select", "form-control-tooltip", "table-filters-menu"];
    components.forEach(tagName => { switch (tagName) {
        case "justifi-payouts-list-filters":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, JustifiPayoutsListFilters$1);
            }
            break;
        case "custom-popper":
            if (!customElements.get(tagName)) {
                defineCustomElement$6();
            }
            break;
        case "form-control-date":
            if (!customElements.get(tagName)) {
                defineCustomElement$5();
            }
            break;
        case "form-control-select":
            if (!customElements.get(tagName)) {
                defineCustomElement$4();
            }
            break;
        case "form-control-tooltip":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "table-filters-menu":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
    } });
}
defineCustomElement$1();

const JustifiPayoutsListFilters = JustifiPayoutsListFilters$1;
const defineCustomElement = defineCustomElement$1;

export { JustifiPayoutsListFilters, defineCustomElement };
