"use strict";

exports.__esModule = true;
exports.useCollectionTableResize = useCollectionTableResize;
var _react = require("react");
var _useIsMobile = require("./useIsMobile");
function useCollectionTableResize({
  columns,
  horizontalScroll,
  userResizeProps,
  columnSizesState,
  isVirtualized
}) {
  const experimentEnabled = (columnSizesState == null ? void 0 : columnSizesState.isResizeExperimentEnabled) ?? false;
  const isMobile = (0, _useIsMobile.useIsMobile)();
  const areAllColumnsPixelWidth = (0, _react.useMemo)(() => columns.every(col => {
    var _col$width;
    return (_col$width = col.width) == null ? void 0 : _col$width.toString().match(/^\d+px$/);
  }), [columns]);
  const isResizable = experimentEnabled && !isMobile && !isVirtualized && !!horizontalScroll && areAllColumnsPixelWidth;
  const resizePlaceholderColumn = (0, _react.useMemo)(() => ({
    title: '',
    width: '100%',
    render: () => null
  }), []);
  const tableResizeProps = isResizable ? {
    ...userResizeProps,
    minColumnWidth: (userResizeProps == null ? void 0 : userResizeProps.minColumnWidth) ?? 74,
    onColumnResizeEnd(columnId, endWidth, event) {
      columnSizesState == null || columnSizesState.updateColumnWidth(columnId, Number(endWidth));
      userResizeProps == null || userResizeProps.onColumnResizeEnd == null || userResizeProps.onColumnResizeEnd(columnId, endWidth, event);
    }
  } : undefined;
  return {
    isResizable,
    tableResizeProps,
    resizePlaceholderColumn
  };
}
//# sourceMappingURL=useCollectionTableResize.js.map