import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
import { l as lodashExports } from './lodash.js';
import { e as convertToUTC, h as convertToLocal } from './utils2.js';
import { f as filterParams, p as propsParams, c as clearParams } from './terminals-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 './config-state.js';
import { k as ITerminalStatus } from './Plaid.js';
import './Pagination.js';
import './Business.js';
import './ApplePay.js';
import { d as defineCustomElement$7 } from './custom-popper2.js';
import { d as defineCustomElement$6 } from './form-control-date2.js';
import { d as defineCustomElement$5 } from './form-control-select2.js';
import { d as defineCustomElement$4 } from './form-control-text2.js';
import { d as defineCustomElement$3 } from './form-control-tooltip2.js';
import { d as defineCustomElement$2 } from './table-filters-menu2.js';

const JustifiTerminalsListFilters$1 = /*@__PURE__*/ proxyCustomElement(class JustifiTerminalsListFilters 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, { setExactTime: true });
            this.setParamsOnChange(name, utcDate);
        };
    }
    componentWillLoad() {
        // debounced input handler for text input
        this.debouncedSetParamsOnChange = lodashExports.debounce(this.setParamsOnChange, 300);
        const propsToSet = {
            terminal_id: this.terminalId,
            status: this.terminalStatus,
            terminal_order_id: this.terminalOrderId,
            provider_id: this.providerId,
            serial_number: this.serialNumber,
            created_after: this.createdAfter,
            created_before: this.createdBefore
        };
        Object.entries(propsToSet).forEach(([key, value]) => {
            if (value) {
                propsParams[key] = value;
            }
        });
    }
    get terminalStatusOptions() {
        return [
            { label: 'All', value: '' },
            { label: 'Connected', value: ITerminalStatus.connected },
            { label: 'Disconnected', value: ITerminalStatus.disconnected },
            { label: 'Unknown', value: ITerminalStatus.unknown },
            { label: 'Pending Configuration', value: ITerminalStatus.pending_configuration },
            { label: 'Archived', value: ITerminalStatus.archived }
        ];
    }
    render() {
        const filterMenuParams = Object.assign({}, filterParams);
        return (h(StyledHost, { key: '525d0f21fd86348f6fa6f54177f0ad119cf91bf2' }, h("table-filters-menu", { key: '70599c95318b14012ca78d108e1e766d1a8c6459', params: filterMenuParams, clearParams: clearParams, part: filterMenu }, h("div", { key: '32c1c355e6a8ac09431f4954484e60670dcc5ff5', class: "grid-cols-2 gap-3 p-1" }, h("div", { key: 'ee88118d7a04042cd7f55caaf8cc3aea64fe1760', class: "p-2" }, h("form-control-text", { key: 'e56a6496c6fb4263ae571d8ed0f63a9d0a1629da', name: "terminal_id", label: "Terminal ID", inputHandler: this.debouncedSetParamsOnChange, defaultValue: this.terminalId || filterParams.terminal_id, disabled: !!this.terminalId, part: filterParam })), h("div", { key: '2c76c1e127d9cf79b9ed508e6266c33a034597b0', class: "p-2" }, h("form-control-text", { key: '75917f144ab87008533d7e2c59c984b6468c36c0', name: "terminal_order_id", label: "Terminal Order ID", inputHandler: this.debouncedSetParamsOnChange, defaultValue: this.terminalOrderId || filterParams.terminal_order_id, disabled: !!this.terminalOrderId, part: filterParam })), h("div", { key: '38162c73f48f3bb2e5f6745c7cf215154fddcbbb', class: "p-2" }, h("form-control-text", { key: '096c325deecea07554f5cc8d59a690c8321b6a05', name: "provider_id", label: "Device ID", inputHandler: this.debouncedSetParamsOnChange, defaultValue: this.providerId || filterParams.provider_id, disabled: !!this.providerId, part: filterParam })), h("div", { key: '403264eb68429594acee6a5d97781eafbdb33c81', class: "p-2" }, h("form-control-text", { key: 'd39ae5201f328985d72b3a79c65848a49adbbe45', name: "serial_number", label: "Serial Number", inputHandler: this.debouncedSetParamsOnChange, defaultValue: this.serialNumber || filterParams.serial_number, disabled: !!this.serialNumber, part: filterParam })), h("div", { key: 'f609fa409e36463b9e1cd4dc68a6be4d22122553', class: "p-2" }, h("form-control-select", { key: 'c19b381e48f030b865003187e470d55b0fcbe373', name: "status", label: "Status", options: this.terminalStatusOptions, inputHandler: this.setParamsOnChange, defaultValue: this.terminalStatus || filterParams.status || '', disabled: !!this.terminalStatus, part: filterParam })), h("div", { key: '12e30437276bf2d7764a61af0a399ea519794904', class: "p-2" }, h("form-control-date", { key: 'aa30f779b70a96d9327a2adabdebe5330d453ada', name: "created_after", label: "Created After", inputHandler: this.handleDateInput, defaultValue: convertToLocal(this.createdAfter || filterParams.created_after, { showInputDateTime: true }), showTime: true, disabled: !!this.createdAfter, part: filterParam })), h("div", { key: 'e972337331bb18cdbf1ee40a241ac8de9f7b0553', class: "p-2" }, h("form-control-date", { key: 'e76864998f47a37d7fef5b1241a6dd8bc8e8a1a8', name: "created_before", label: "Created Before", inputHandler: this.handleDateInput, defaultValue: convertToLocal(this.createdBefore || filterParams.created_before, { showInputDateTime: true }), showTime: true, disabled: !!this.createdBefore, part: filterParam }))))));
    }
}, [257, "justifi-terminals-list-filters", {
        "terminalId": [1, "terminal-id"],
        "terminalOrderId": [1, "terminal-order-id"],
        "providerId": [1, "provider-id"],
        "serialNumber": [1, "serial-number"],
        "terminalStatus": [1, "terminal-status"],
        "createdAfter": [1, "created-after"],
        "createdBefore": [1, "created-before"]
    }]);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["justifi-terminals-list-filters", "custom-popper", "form-control-date", "form-control-select", "form-control-text", "form-control-tooltip", "table-filters-menu"];
    components.forEach(tagName => { switch (tagName) {
        case "justifi-terminals-list-filters":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, JustifiTerminalsListFilters$1);
            }
            break;
        case "custom-popper":
            if (!customElements.get(tagName)) {
                defineCustomElement$7();
            }
            break;
        case "form-control-date":
            if (!customElements.get(tagName)) {
                defineCustomElement$6();
            }
            break;
        case "form-control-select":
            if (!customElements.get(tagName)) {
                defineCustomElement$5();
            }
            break;
        case "form-control-text":
            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 JustifiTerminalsListFilters = JustifiTerminalsListFilters$1;
const defineCustomElement = defineCustomElement$1;

export { JustifiTerminalsListFilters, defineCustomElement };
