"use client";
import { jsx as a, jsxs as s } from "react/jsx-runtime";
import { AppSelect as d } from "../../../app-select.js";
import { Button as m } from "../../../button.js";
import { Popover as v, PopoverTrigger as h, PopoverContent as g } from "../../../popover.js";
import { getStringFilterOptions as x, getNumberFilterOptions as T, getBooleanFilterOptions as b, getDateFilterOptions as y, getDateTimeFilterOptions as C, getListSingleSelectFilterOptions as D, getListMultiSelectFilterOptions as w } from "../data-table-constants.js";
import { FilterValueInput as l } from "./data-table-filter-inputs.js";
function p({
  filter: e,
  setFilterBadges: n,
  options: t,
  content: r,
  i18n: i
}) {
  return /* @__PURE__ */ s("div", { className: "flex flex-col gap-2", children: [
    /* @__PURE__ */ s("div", { className: "flex max-w-full flex-row items-center justify-between gap-2", children: [
      /* @__PURE__ */ s("div", { className: "flex min-w-0 flex-1 flex-row items-center gap-2", children: [
        /* @__PURE__ */ a("div", { className: "text-d-foreground max-w-[40%] overflow-hidden text-xs text-ellipsis whitespace-nowrap", children: e.columnLabel }),
        /* @__PURE__ */ a(
          d,
          {
            size: "sm",
            wrpClassName: "flex flex-1",
            options: t,
            value: e.operator ?? "eq",
            onValueChange: (o) => n(
              (u) => u.map(
                (c) => c.id === e.id ? { ...c, operator: String(o) } : c
              )
            )
          }
        )
      ] }),
      /* @__PURE__ */ s(v, { children: [
        /* @__PURE__ */ a(h, { asChild: !0, children: /* @__PURE__ */ a(m, { variant: "ghost", iconLeft: "Ellipsis", size: "sm" }) }),
        /* @__PURE__ */ a(g, { side: "right", className: "flex w-auto", children: /* @__PURE__ */ a(
          m,
          {
            variant: "ghost-destructive",
            iconLeft: "Trash2",
            size: "sm",
            onClick: () => n(
              (o) => o.filter((u) => u.id !== e.id)
            ),
            children: i.filters.deleteFilter
          }
        ) })
      ] })
    ] }),
    /* @__PURE__ */ a("div", { children: r })
  ] });
}
function _({
  filter: e,
  setFilterBadges: n,
  i18n: t
}) {
  return /* @__PURE__ */ a(
    p,
    {
      filter: e,
      setFilterBadges: n,
      options: x(t),
      content: /* @__PURE__ */ a(
        l,
        {
          columnType: "string",
          operator: e.operator,
          value: e.value,
          onChange: (r) => n(
            (i) => i.map((o) => o.id === e.id ? { ...o, value: r } : o)
          ),
          i18n: t
        }
      ),
      i18n: t
    }
  );
}
function j({
  filter: e,
  setFilterBadges: n,
  i18n: t
}) {
  return /* @__PURE__ */ a(
    p,
    {
      filter: e,
      setFilterBadges: n,
      options: T(t),
      content: /* @__PURE__ */ a(
        l,
        {
          columnType: "number",
          operator: e.operator,
          value: e.value,
          onChange: (r) => n(
            (i) => i.map((o) => o.id === e.id ? { ...o, value: r } : o)
          ),
          i18n: t
        }
      ),
      i18n: t
    }
  );
}
function z({
  filter: e,
  setFilterBadges: n,
  i18n: t
}) {
  return /* @__PURE__ */ a(
    p,
    {
      filter: e,
      setFilterBadges: n,
      options: b(t),
      content: /* @__PURE__ */ a(
        l,
        {
          columnType: "boolean",
          operator: e.operator,
          value: e.value,
          onChange: (r) => n(
            (i) => i.map((o) => o.id === e.id ? { ...o, value: r } : o)
          ),
          i18n: t
        }
      ),
      i18n: t
    }
  );
}
function P({
  filter: e,
  setFilterBadges: n,
  i18n: t
}) {
  return /* @__PURE__ */ a(
    p,
    {
      filter: e,
      setFilterBadges: n,
      options: D(t),
      content: /* @__PURE__ */ a(
        l,
        {
          columnType: "list_single_select",
          operator: e.operator,
          value: e.value,
          onChange: (r) => n(
            (i) => i.map(
              (o) => o.id === e.id ? {
                ...o,
                value: Array.isArray(r) && r.length === 0 ? void 0 : r
              } : o
            )
          ),
          listOptions: e.listOptions ?? [],
          i18n: t
        }
      ),
      i18n: t
    }
  );
}
function M({
  filter: e,
  setFilterBadges: n,
  i18n: t
}) {
  return /* @__PURE__ */ a(
    p,
    {
      filter: e,
      setFilterBadges: n,
      options: w(t),
      content: /* @__PURE__ */ a(
        l,
        {
          columnType: "list_multi_select",
          operator: e.operator,
          value: e.value,
          onChange: (r) => n(
            (i) => i.map(
              (o) => o.id === e.id ? {
                ...o,
                value: Array.isArray(r) && r.length === 0 ? void 0 : r
              } : o
            )
          ),
          listOptions: e.listOptions ?? [],
          i18n: t
        }
      ),
      i18n: t
    }
  );
}
function V({
  filter: e,
  setFilterBadges: n,
  i18n: t
}) {
  return /* @__PURE__ */ a(
    p,
    {
      filter: e,
      setFilterBadges: n,
      options: y(t),
      content: /* @__PURE__ */ a(
        l,
        {
          columnType: "date",
          operator: e.operator,
          value: e.value,
          onChange: (r) => n(
            (i) => i.map((o) => o.id === e.id ? { ...o, value: r } : o)
          ),
          i18n: t
        }
      ),
      i18n: t
    }
  );
}
function k({
  filter: e,
  setFilterBadges: n,
  i18n: t
}) {
  return /* @__PURE__ */ a(
    p,
    {
      filter: e,
      setFilterBadges: n,
      options: C(t),
      content: /* @__PURE__ */ a(
        l,
        {
          columnType: "datetime",
          operator: e.operator,
          value: e.value,
          onChange: (r) => n(
            (i) => i.map((o) => o.id === e.id ? { ...o, value: r } : o)
          ),
          i18n: t
        }
      ),
      i18n: t
    }
  );
}
export {
  z as DataTableBooleanFilter,
  V as DataTableDateFilter,
  k as DataTableDateTimeFilter,
  p as DataTableFilter,
  M as DataTableListMultiSelectFilter,
  P as DataTableListSingleSelectFilter,
  j as DataTableNumberFilter,
  _ as DataTableStringFilter
};
