import { useState as c, useRef as a, useEffect as s, useMemo as d } from "react";
import { deepEqual as y } from "fast-equals";
import { getUncertaintyFormat as m } from "../../../formatters/UncertaintyFormatter/UncertaintyFormatter.js";
import { ColumnUncertaintyGroupFormatter as U } from "./ColumnUncertaintyGroupFormatter.js";
import { ColumnUncertaintyFormatter as S } from "./formatter.js";
import { getColumnKey as n } from "../../helpers/shared/getColumnKey/getColumnKey.js";
const C = (t) => (e, o) => {
  const r = n(t.fieldValue), i = n(t.fieldSymbol), l = n(t.fieldUnit);
  return m(
    e,
    r,
    i,
    l
  ).includes(o);
}, F = (t) => (e, o) => {
  const r = n(t.fieldValue), i = n(t.fieldSymbol), l = n(t.fieldUnit), u = m(e, r, i, l), f = m(o, r, i, l);
  return u > f ? 1 : u < f ? -1 : 0;
}, G = (t) => {
  const [e, o] = c(t), r = a({ ...t });
  return s(() => {
    y(r.current, t) || (r.current = t, o(t));
  }, [t]), d(() => ({
    formatter: S(e),
    renderGroupCell: U(e),
    customFilter: C(e),
    customSort: F(e)
  }), [e]);
};
export {
  G as useColumnUncertanity
};
