"use strict";

exports.__esModule = true;
exports.useCreateWSRColumnBase = useCreateWSRColumnBase;
var _react = require("react");
function useCreateWSRColumnBase({
  horizontalScroll
}) {
  return (0, _react.useCallback)((column, index, length) => {
    const {
      id,
      title,
      width,
      sortable,
      infoTooltipProps
    } = column;
    const lastColumn = index === length - 1;
    const lastColumnStyleNoHorizontalScroll = width != null ? {
      flexBasis: width,
      flexGrow: 1
    } : {
      flex: 1
    };
    const lastColumnStyle = horizontalScroll ? {
      flexBasis: width ?? 0,
      flexShrink: 0,
      flexGrow: 1
    } : lastColumnStyleNoHorizontalScroll;
    const columnStyle = width == null ? {
      flex: 1
    } : undefined;
    const style = lastColumn ? lastColumnStyle : columnStyle;
    return {
      id,
      key: id ?? index,
      title,
      style,
      width: lastColumn && !horizontalScroll ? undefined : width,
      sortable: id && sortable ? true : undefined,
      infoTooltipProps: infoTooltipProps != null && infoTooltipProps.content ? infoTooltipProps : undefined
    };
  }, [horizontalScroll]);
}
//# sourceMappingURL=useCreateWSRColumnBase.js.map