import { useMemo as u } from "react";
import { SELECT_COLUMN_KEY as p } from "react-data-grid";
import { DATAGRID_ACTIONS_COLUMN_KEY as a } from "../../../../constants.js";
import { useDataGrid as k } from "../../../../hooks/shared/useDataGrid/useDataGrid.js";
function _(s, m = {}) {
  const { applyVisibilityFilter: d = !0 } = m, { getConfigColumns: f, viewMode: l } = k(), t = u(
    () => f(l || "cards"),
    [f, l]
  );
  return u(() => {
    const C = s.filter((r) => {
      if (r.key === p || r.key === a)
        return !1;
      if (!d)
        return !r.hidden;
      const e = t.find((o) => o.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 C.sort((r, e) => {
      const n = t.findIndex((i) => i.key === r.key), o = t.findIndex((i) => i.key === e.key), c = n === -1 ? t.length : n, y = o === -1 ? t.length : o;
      return c - y;
    }), C;
  }, [s, t, d]);
}
export {
  _ as useProcessedColumns
};
