import { jsxs as x, jsx as o } from "react/jsx-runtime";
import { useState as I, useCallback as l, useMemo as u } from "react";
import { COMMAND_VARIANT as A } from "../../../command/constants/index.js";
import C from "../../hooks/useDataTableStaticContext.js";
import { Popover as D, PopoverTrigger as N, PopoverContent as O } from "../../../popover/PopoverPrimitive.js";
import f from "../../../button/Button.js";
import P from "../../../icon/Icon.js";
import T from "../../../command/Command.js";
import b from "../../../box/Box.js";
import { c as w } from "../../../../index-BtlgVD4m.js";
const H = ({ filterableColumns: a, selectedKeys: i, onSelectionChange: s }) => {
  const { columns: m } = C(), [c, h] = I(!1), p = l(
    (e) => {
      var r;
      return ((r = m.find((n) => n.key === e)) == null ? void 0 : r.title) ?? String(e);
    },
    [m]
  ), g = u(() => {
    const e = (t) => ({
      label: p(t),
      value: String(t)
    }), r = a.map((t) => e(t.columnKey)), n = [];
    return n.push({ heading: "Alle Werte", items: r }), n;
  }, [a, p]), v = u(() => i.map((e) => String(e)), [i]), d = l(
    (e) => {
      const r = new Set(e.filter((t) => t !== null)), n = a.filter((t) => r.has(String(t.columnKey))).map((t) => t.columnKey);
      s(n);
    },
    [a, s]
  ), S = l(() => {
    s([]);
  }, [s]);
  return /* @__PURE__ */ x(D, { open: c, onOpenChange: h, children: [
    /* @__PURE__ */ o(N, { asChild: !0, children: /* @__PURE__ */ o(
      f,
      {
        label: "Weitere Filter",
        variant: "outline",
        size: "sm",
        icon: /* @__PURE__ */ o(P, { name: "ChevronDown", className: w("transition-transform", c ? "rotate-180" : ""), size: 16 }),
        iconPosition: "right"
      }
    ) }),
    /* @__PURE__ */ o(O, { className: "p-0 w-[var(--spacing-64)]", align: "start", children: /* @__PURE__ */ o(
      T,
      {
        placeholder: "Suche Filtername",
        isPopover: !0,
        groups: g,
        variant: A.CHECKBOX,
        value: v,
        onItemSelect: d,
        footer: i.length > 0 ? /* @__PURE__ */ o(b, { className: "flex justify-center", children: /* @__PURE__ */ o(f, { label: "Auswahl aufheben", variant: "ghost", onClick: S }) }) : null
      }
    ) })
  ] });
};
export {
  H as default
};
//# sourceMappingURL=DataTableMoreFilter.js.map
