import { getPropertyByString as l } from "@m4l/core";
import { ColumnChipStatusFormatter as n } from "./formatter.js";
import { ColumnChipStatusGroupFormatter as a } from "./ColumnChipStatusGroupFormatter.js";
import { deepEqual as f } from "fast-equals";
import { useState as m, useRef as s, useEffect as S, useMemo as c } from "react";
import { getColumnKey as o } from "../../helpers/shared/getColumnKey/getColumnKey.js";
const d = (t) => {
  const { fieldLabel: e } = t;
  return (r, u) => (typeof e == "string" ? l(r, o(e), "") : e(r, t.fieldStatus)).includes(u.toString());
}, C = (t) => (e, r) => {
  const u = typeof t.fieldLabel == "string" ? l(e, o(t.fieldLabel), "") : t.fieldLabel(e, t.fieldStatus), i = typeof t.fieldLabel == "string" ? l(r, o(t.fieldLabel), "") : t.fieldLabel(r, t.fieldStatus);
  return u > i ? 1 : u < i ? -1 : 0;
}, F = (t) => {
  const [e, r] = m(t), u = s({ ...t });
  return S(() => {
    f(u.current, t) || (u.current = t, r(t));
  }, [t]), c(() => ({
    formatter: n(e),
    renderGroupCell: a(e),
    customFilter: d(e),
    customSort: C(e)
  }), [e]);
};
export {
  F as useColumnChipStatus
};
