import { jsxs as k, Fragment as z, jsx as r } from "react/jsx-runtime";
import { useState as O, useCallback as l, useMemo as b } from "react";
import d from "../../../button/Button.js";
import v from "./components/advanced-filter-display/AdvancedFilterDisplay.js";
import x from "./components/advanced-filter-dialog/AdvancedFilterDialog.js";
const y = ({ value: i, columns: o, onChange: t }) => {
  const [m, c] = O(!1), F = l(() => {
    c(!0);
  }, []), p = l(() => {
    c(!1);
  }, []), f = l(
    (s) => {
      t == null || t(s);
    },
    [t]
  ), D = l(() => {
    t == null || t(void 0);
  }, [t]), n = l(
    (s) => {
      if (!i) return;
      const e = [...i];
      e.length === 0 ? t == null || t(void 0) : (e.splice(s, 1), t == null || t(e));
    },
    [i, t]
  ), A = b(() => i && i.length > 0, [i]);
  return /* @__PURE__ */ k(z, { children: [
    /* @__PURE__ */ r(d, { variant: "outline", size: "sm", onClick: F, label: "Filter", icon: "ListFilter", iconPosition: "right" }),
    i && /* @__PURE__ */ r(v, { columns: o, conditions: i, onRemoveCondition: n }),
    A && /* @__PURE__ */ r(d, { variant: "ghost", size: "sm", onClick: D, label: "alle Filter zurücksetzen" }),
    /* @__PURE__ */ r(
      x,
      {
        columns: o,
        value: i,
        onChange: f,
        isOpen: m,
        onClose: p
      }
    )
  ] });
};
export {
  y as default
};
//# sourceMappingURL=AdvancedFilter.js.map
