import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React from 'react';
import { observer } from 'mobx-react-lite';
import classNames from 'classnames';
import measureScrollbar from '../../_util/measureScrollbar';
import { columnWidth } from './utils';

var StickyShadow = function StickyShadow(props) {
  var _classNames;

  var position = props.position,
      children = props.children,
      columns = props.columns,
      prefixCls = props.prefixCls,
      scroll = props.scroll;

  if (!children && columns.length === 0) {
    return null;
  }

  var classString = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-sticky-shadow"), !children), _defineProperty(_classNames, "".concat(prefixCls, "-fixed-left"), children && position === 'left'), _defineProperty(_classNames, "".concat(prefixCls, "-fixed-right"), children && position === 'right'), _defineProperty(_classNames, "".concat(prefixCls, "-sticky-left"), position === 'left'), _defineProperty(_classNames, "".concat(prefixCls, "-sticky-right"), position === 'right'), _classNames));
  var style = {};

  if (!children) {
    var scrollBarWidth = measureScrollbar();

    if (position === 'left') {
      style.left = columns.reduce(function (sum, column) {
        return sum + columnWidth(column);
      }, 0);
    } else if (position === 'right') {
      style.right = columns.reduce(function (sum, column) {
        return sum + columnWidth(column);
      }, 0) + (scroll && scroll.y ? scrollBarWidth : 0);
    }

    style.bottom = scrollBarWidth;
  }

  return /*#__PURE__*/React.createElement("div", {
    className: classString,
    style: style
  }, children);
};

StickyShadow.displayName = 'StickyShadow';
export default observer(StickyShadow);
//# sourceMappingURL=StickyShadow.js.map
