import { useRef as v, useState as f, useLayoutEffect as B, useCallback as M } from "react";
const h = (o) => `${o.kind}-${String(o.rowId)}`, S = [
  "id",
  "columnKey",
  "label",
  "width",
  "mobileLabel",
  "horizontalAlign",
  "verticalAlign",
  "headerClassName",
  "hideOnMobile",
  "sortable",
  "draggable",
  "resizeable",
  "minResizeWidth",
  "maxResizeWidth",
  "row",
  "colSpan",
  "rowSpan"
], E = ["rowId", "rowIndex", "kind", "disabled"], K = (o, r) => o.length === r.length && o.every((e, n) => {
  const t = r[n];
  return t !== void 0 && S.every((s) => e[s] === t[s]);
}), I = (o, r) => o.length === r.length && o.every((e, n) => {
  const t = r[n];
  return t !== void 0 && E.every((s) => e[s] === t[s]);
}), z = (o) => {
  const r = /* @__PURE__ */ new Set();
  return o.filter((e) => r.has(e.id) ? !1 : (r.add(e.id), !0));
}, H = (o) => {
  const r = /* @__PURE__ */ new Set();
  return o.filter((e) => {
    const n = `${e.kind}-${String(e.rowId)}`;
    return r.has(n) ? !1 : (r.add(n), !0);
  });
}, g = (o) => new Map(o.map((r) => [h(r), r.render])), k = (o) => {
  const r = v(/* @__PURE__ */ new Map()), [e, n] = f({
    headerColumns: [],
    bodyRows: [],
    bodyMaxHeight: void 0,
    hasFooter: !1,
    hasFooterCells: void 0,
    hasExpandableRows: void 0
  });
  B(() => {
    const s = o.current;
    if (!s)
      return;
    const d = z(s.headerColumns), a = H(s.bodyRows), l = a.map(({ render: $, ...F }) => F), p = g(a), R = s.bodyMaxHeight, i = s.hasFooter === !0, c = s.hasFooterCells, w = s.hasExpandableRows;
    r.current = p;
    const u = K(e.headerColumns, d) ? e.headerColumns : d, y = I(e.bodyRows, l) ? e.bodyRows : l, b = e.bodyMaxHeight === R ? e.bodyMaxHeight : R, x = e.hasFooter === i ? e.hasFooter : i, C = e.hasFooterCells === c ? e.hasFooterCells : c, m = e.hasExpandableRows === w ? e.hasExpandableRows : w;
    e.headerColumns === u && e.bodyRows === y && e.bodyMaxHeight === b && e.hasFooter === x && e.hasFooterCells === C && e.hasExpandableRows === m || n({
      headerColumns: u,
      bodyRows: y,
      bodyMaxHeight: b,
      hasFooter: x,
      hasFooterCells: C,
      hasExpandableRows: m
    });
  });
  const t = M(
    (s) => {
      const d = o.current;
      return ((d ? g(H(d.bodyRows)) : void 0)?.get(h(s)) ?? r.current.get(h(s)))?.() ?? null;
    },
    [o]
  );
  return {
    renderHeaderColumns: e.headerColumns,
    renderBodyRows: e.bodyRows,
    renderBodyMaxHeight: e.bodyMaxHeight,
    renderHasFooter: e.hasFooter,
    renderHasFooterCells: e.hasFooterCells,
    renderHasExpandableRows: e.hasExpandableRows,
    renderBodyRow: t
  };
};
export {
  k as default,
  k as useRenderDraftState
};
//# sourceMappingURL=useRenderDraftState.js.map
