import { useCallback as k, useEffect as H } from "react";
import c from "../../../deprecated/advanced-filter/types/FilterConditionOperator.js";
const B = ({
  columnKey: u,
  internalOperator: f,
  internalValue: L,
  searchText: s,
  isSingleMode: m,
  popoverContentRef: d,
  popoverTriggerRef: t,
  setSelectedValue: E,
  setSelectedOperator: F,
  onChange: r
}) => {
  const q = k(
    (i) => {
      E(i), r == null || r({ [u]: { value: i, operator: f } });
    },
    [u, f, r, E]
  ), A = k(
    (i) => {
      F(i), r == null || r({ [u]: { value: L, operator: i } });
    },
    [u, L, r, F]
  ), b = k(() => {
    E([]), F(c.Equals), r == null || r({ [u]: null });
  }, [u, r, F, E]), w = k(() => {
    E([s]), s.trim() !== "" ? r == null || r({ [u]: { value: [s], operator: f } }) : b(), d.current && t.current && t.current.click();
  }, [s, u, r, b, f, d, t, E]), D = k(
    (i) => {
      !d.current || !d.current.contains(i.target) || i.key === "Enter" && m && (i.preventDefault(), w());
    },
    [m, d, w]
  );
  return H(() => (document.addEventListener("keydown", D), () => {
    document.removeEventListener("keydown", D);
  }), [D]), {
    handleChangeValue: q,
    handleChangeOperator: A,
    handleClearFilter: b,
    handleApplySingleFilter: w
  };
};
export {
  B as default
};
//# sourceMappingURL=useDataTableFilterHandlers.js.map
