import { useMemo as C } from "react";
import { SELECT_COLUMN_KEY as y } from "react-data-grid";
import { DATAGRID_ACTIONS_COLUMN_KEY as p } from "../../../../constants.js";
import { useDataGrid as k } from "../../../../hooks/shared/useDataGrid/useDataGrid.js";
function A(s, u = {}) {
  const { applyVisibilityFilter: d = !0 } = u, { getConfigColumns: f } = k(), t = C(
    () => f("list"),
    [f]
  );
  return C(() => {
    const l = s.filter((r) => {
      if (r.key === y || r.key === p)
        return !1;
      if (!d)
        return !r.hidden;
      const e = t.find((i) => i.key === r.key), n = e ? e.visible : !0;
      return !r.hidden && n;
    }).map((r) => {
      const e = { ...r };
      return e.formatter && !e.renderCell && (e.renderCell = e.formatter), e.editor && !e.renderEditCell && (e.renderEditCell = e.editor), e;
    });
    return l.sort((r, e) => {
      const n = t.findIndex((o) => o.key === r.key), i = t.findIndex((o) => o.key === e.key), m = n === -1 ? t.length : n, c = i === -1 ? t.length : i;
      return m - c;
    }), l;
  }, [s, t, d]);
}
export {
  A as useProcessedColumns
};
