import { useCallback } from "react";
import { normalizeInitialHiddenColumnsState } from "./normalizeInitialHiddenColumnsState.js";
import { useSessionStorageState } from "@contember/react-utils";
const useHiddenColumnsState = (columns, dataGridKey) => {
  const [hiddenColumns, setHiddenColumns] = useSessionStorageState(`${dataGridKey}-hidden`, (val) => normalizeInitialHiddenColumnsState(val, columns));
  return [
    hiddenColumns,
    useCallback((columnKey, isToBeHidden) => {
      const column = columns.get(columnKey);
      if (column === void 0) {
        return;
      }
      setHiddenColumns((hiddenColumns2) => {
        return { ...hiddenColumns2, [columnKey]: isToBeHidden };
      });
    }, [columns, setHiddenColumns])
  ];
};
export { useHiddenColumnsState };
//# sourceMappingURL=useHiddenColumnsState.js.map
