1. 'use strict';
    
  2. 
    
  3. Object.defineProperty(exports, '__esModule', { value: true });
    
  4. 
    
  5. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
    
  6. 
    
  7. var _extends = _interopDefault(require('@babel/runtime/helpers/extends'));
    
  8. var _inheritsLoose = _interopDefault(require('@babel/runtime/helpers/inheritsLoose'));
    
  9. var _assertThisInitialized = _interopDefault(require('@babel/runtime/helpers/assertThisInitialized'));
    
  10. var memoizeOne = _interopDefault(require('memoize-one'));
    
  11. var react = require('react');
    
  12. var _objectWithoutPropertiesLoose = _interopDefault(require('@babel/runtime/helpers/objectWithoutPropertiesLoose'));
    
  13. 
    
  14. // Animation frame based implementation of setTimeout.
    
  15. // Inspired by Joe Lambert, https://gist.github.com/joelambert/1002116#file-requesttimeout-js
    
  16. var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
    
  17. var now = hasNativePerformanceNow ? function () {
    
  18.   return performance.now();
    
  19. } : function () {
    
  20.   return Date.now();
    
  21. };
    
  22. function cancelTimeout(timeoutID) {
    
  23.   cancelAnimationFrame(timeoutID.id);
    
  24. }
    
  25. function requestTimeout(callback, delay) {
    
  26.   var start = now();
    
  27. 
    
  28.   function tick() {
    
  29.     if (now() - start >= delay) {
    
  30.       callback.call(null);
    
  31.     } else {
    
  32.       timeoutID.id = requestAnimationFrame(tick);
    
  33.     }
    
  34.   }
    
  35. 
    
  36.   var timeoutID = {
    
  37.     id: requestAnimationFrame(tick)
    
  38.   };
    
  39.   return timeoutID;
    
  40. }
    
  41. 
    
  42. var size = -1; // This utility copied from "dom-helpers" package.
    
  43. 
    
  44. function getScrollbarSize(recalculate) {
    
  45.   if (recalculate === void 0) {
    
  46.     recalculate = false;
    
  47.   }
    
  48. 
    
  49.   if (size === -1 || recalculate) {
    
  50.     var div = document.createElement('div');
    
  51.     var style = div.style;
    
  52.     style.width = '50px';
    
  53.     style.height = '50px';
    
  54.     style.overflow = 'scroll';
    
  55.     document.body.appendChild(div);
    
  56.     size = div.offsetWidth - div.clientWidth;
    
  57.     document.body.removeChild(div);
    
  58.   }
    
  59. 
    
  60.   return size;
    
  61. }
    
  62. var cachedRTLResult = null; // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
    
  63. // Chrome does not seem to adhere; its scrollLeft values are positive (measured relative to the left).
    
  64. // Safari's elastic bounce makes detecting this even more complicated wrt potential false positives.
    
  65. // The safest way to check this is to intentionally set a negative offset,
    
  66. // and then verify that the subsequent "scroll" event matches the negative offset.
    
  67. // If it does not match, then we can assume a non-standard RTL scroll implementation.
    
  68. 
    
  69. function getRTLOffsetType(recalculate) {
    
  70.   if (recalculate === void 0) {
    
  71.     recalculate = false;
    
  72.   }
    
  73. 
    
  74.   if (cachedRTLResult === null || recalculate) {
    
  75.     var outerDiv = document.createElement('div');
    
  76.     var outerStyle = outerDiv.style;
    
  77.     outerStyle.width = '50px';
    
  78.     outerStyle.height = '50px';
    
  79.     outerStyle.overflow = 'scroll';
    
  80.     outerStyle.direction = 'rtl';
    
  81.     var innerDiv = document.createElement('div');
    
  82.     var innerStyle = innerDiv.style;
    
  83.     innerStyle.width = '100px';
    
  84.     innerStyle.height = '100px';
    
  85.     outerDiv.appendChild(innerDiv);
    
  86.     document.body.appendChild(outerDiv);
    
  87. 
    
  88.     if (outerDiv.scrollLeft > 0) {
    
  89.       cachedRTLResult = 'positive-descending';
    
  90.     } else {
    
  91.       outerDiv.scrollLeft = 1;
    
  92. 
    
  93.       if (outerDiv.scrollLeft === 0) {
    
  94.         cachedRTLResult = 'negative';
    
  95.       } else {
    
  96.         cachedRTLResult = 'positive-ascending';
    
  97.       }
    
  98.     }
    
  99. 
    
  100.     document.body.removeChild(outerDiv);
    
  101.     return cachedRTLResult;
    
  102.   }
    
  103. 
    
  104.   return cachedRTLResult;
    
  105. }
    
  106. 
    
  107. var IS_SCROLLING_DEBOUNCE_INTERVAL = 150;
    
  108. 
    
  109. var defaultItemKey = function defaultItemKey(_ref) {
    
  110.   var columnIndex = _ref.columnIndex,
    
  111.       data = _ref.data,
    
  112.       rowIndex = _ref.rowIndex;
    
  113.   return rowIndex + ":" + columnIndex;
    
  114. }; // In DEV mode, this Set helps us only log a warning once per component instance.
    
  115. // This avoids spamming the console every time a render happens.
    
  116. 
    
  117. 
    
  118. var devWarningsOverscanCount = null;
    
  119. var devWarningsOverscanRowsColumnsCount = null;
    
  120. var devWarningsTagName = null;
    
  121. 
    
  122. if (process.env.NODE_ENV !== 'production') {
    
  123.   if (typeof window !== 'undefined' && typeof window.WeakSet !== 'undefined') {
    
  124.     devWarningsOverscanCount =
    
  125.     /*#__PURE__*/
    
  126.     new WeakSet();
    
  127.     devWarningsOverscanRowsColumnsCount =
    
  128.     /*#__PURE__*/
    
  129.     new WeakSet();
    
  130.     devWarningsTagName =
    
  131.     /*#__PURE__*/
    
  132.     new WeakSet();
    
  133.   }
    
  134. }
    
  135. 
    
  136. function createGridComponent(_ref2) {
    
  137.   var _class, _temp;
    
  138. 
    
  139.   var getColumnOffset = _ref2.getColumnOffset,
    
  140.       getColumnStartIndexForOffset = _ref2.getColumnStartIndexForOffset,
    
  141.       getColumnStopIndexForStartIndex = _ref2.getColumnStopIndexForStartIndex,
    
  142.       getColumnWidth = _ref2.getColumnWidth,
    
  143.       getEstimatedTotalHeight = _ref2.getEstimatedTotalHeight,
    
  144.       getEstimatedTotalWidth = _ref2.getEstimatedTotalWidth,
    
  145.       getOffsetForColumnAndAlignment = _ref2.getOffsetForColumnAndAlignment,
    
  146.       getOffsetForRowAndAlignment = _ref2.getOffsetForRowAndAlignment,
    
  147.       getRowHeight = _ref2.getRowHeight,
    
  148.       getRowOffset = _ref2.getRowOffset,
    
  149.       getRowStartIndexForOffset = _ref2.getRowStartIndexForOffset,
    
  150.       getRowStopIndexForStartIndex = _ref2.getRowStopIndexForStartIndex,
    
  151.       initInstanceProps = _ref2.initInstanceProps,
    
  152.       shouldResetStyleCacheOnItemSizeChange = _ref2.shouldResetStyleCacheOnItemSizeChange,
    
  153.       validateProps = _ref2.validateProps;
    
  154.   return _temp = _class =
    
  155.   /*#__PURE__*/
    
  156.   function (_PureComponent) {
    
  157.     _inheritsLoose(Grid, _PureComponent);
    
  158. 
    
  159.     // Always use explicit constructor for React components.
    
  160.     // It produces less code after transpilation. (#26)
    
  161.     // eslint-disable-next-line no-useless-constructor
    
  162.     function Grid(props) {
    
  163.       var _this;
    
  164. 
    
  165.       _this = _PureComponent.call(this, props) || this;
    
  166.       _this._instanceProps = initInstanceProps(_this.props, _assertThisInitialized(_assertThisInitialized(_this)));
    
  167.       _this._resetIsScrollingTimeoutId = null;
    
  168.       _this._outerRef = void 0;
    
  169.       _this.state = {
    
  170.         instance: _assertThisInitialized(_assertThisInitialized(_this)),
    
  171.         isScrolling: false,
    
  172.         horizontalScrollDirection: 'forward',
    
  173.         scrollLeft: typeof _this.props.initialScrollLeft === 'number' ? _this.props.initialScrollLeft : 0,
    
  174.         scrollTop: typeof _this.props.initialScrollTop === 'number' ? _this.props.initialScrollTop : 0,
    
  175.         scrollUpdateWasRequested: false,
    
  176.         verticalScrollDirection: 'forward'
    
  177.       };
    
  178.       _this._callOnItemsRendered = void 0;
    
  179.       _this._callOnItemsRendered = memoizeOne(function (overscanColumnStartIndex, overscanColumnStopIndex, overscanRowStartIndex, overscanRowStopIndex, visibleColumnStartIndex, visibleColumnStopIndex, visibleRowStartIndex, visibleRowStopIndex) {
    
  180.         return _this.props.onItemsRendered({
    
  181.           overscanColumnStartIndex: overscanColumnStartIndex,
    
  182.           overscanColumnStopIndex: overscanColumnStopIndex,
    
  183.           overscanRowStartIndex: overscanRowStartIndex,
    
  184.           overscanRowStopIndex: overscanRowStopIndex,
    
  185.           visibleColumnStartIndex: visibleColumnStartIndex,
    
  186.           visibleColumnStopIndex: visibleColumnStopIndex,
    
  187.           visibleRowStartIndex: visibleRowStartIndex,
    
  188.           visibleRowStopIndex: visibleRowStopIndex
    
  189.         });
    
  190.       });
    
  191.       _this._callOnScroll = void 0;
    
  192.       _this._callOnScroll = memoizeOne(function (scrollLeft, scrollTop, horizontalScrollDirection, verticalScrollDirection, scrollUpdateWasRequested) {
    
  193.         return _this.props.onScroll({
    
  194.           horizontalScrollDirection: horizontalScrollDirection,
    
  195.           scrollLeft: scrollLeft,
    
  196.           scrollTop: scrollTop,
    
  197.           verticalScrollDirection: verticalScrollDirection,
    
  198.           scrollUpdateWasRequested: scrollUpdateWasRequested
    
  199.         });
    
  200.       });
    
  201.       _this._getItemStyle = void 0;
    
  202. 
    
  203.       _this._getItemStyle = function (rowIndex, columnIndex) {
    
  204.         var _this$props = _this.props,
    
  205.             columnWidth = _this$props.columnWidth,
    
  206.             direction = _this$props.direction,
    
  207.             rowHeight = _this$props.rowHeight;
    
  208. 
    
  209.         var itemStyleCache = _this._getItemStyleCache(shouldResetStyleCacheOnItemSizeChange && columnWidth, shouldResetStyleCacheOnItemSizeChange && direction, shouldResetStyleCacheOnItemSizeChange && rowHeight);
    
  210. 
    
  211.         var key = rowIndex + ":" + columnIndex;
    
  212.         var style;
    
  213. 
    
  214.         if (itemStyleCache.hasOwnProperty(key)) {
    
  215.           style = itemStyleCache[key];
    
  216.         } else {
    
  217.           var _style;
    
  218. 
    
  219.           itemStyleCache[key] = style = (_style = {
    
  220.             position: 'absolute'
    
  221.           }, _style[direction === 'rtl' ? 'right' : 'left'] = getColumnOffset(_this.props, columnIndex, _this._instanceProps), _style.top = getRowOffset(_this.props, rowIndex, _this._instanceProps), _style.height = getRowHeight(_this.props, rowIndex, _this._instanceProps), _style.width = getColumnWidth(_this.props, columnIndex, _this._instanceProps), _style);
    
  222.         }
    
  223. 
    
  224.         return style;
    
  225.       };
    
  226. 
    
  227.       _this._getItemStyleCache = void 0;
    
  228.       _this._getItemStyleCache = memoizeOne(function (_, __, ___) {
    
  229.         return {};
    
  230.       });
    
  231. 
    
  232.       _this._onScroll = function (event) {
    
  233.         var _event$currentTarget = event.currentTarget,
    
  234.             clientHeight = _event$currentTarget.clientHeight,
    
  235.             clientWidth = _event$currentTarget.clientWidth,
    
  236.             scrollLeft = _event$currentTarget.scrollLeft,
    
  237.             scrollTop = _event$currentTarget.scrollTop,
    
  238.             scrollHeight = _event$currentTarget.scrollHeight,
    
  239.             scrollWidth = _event$currentTarget.scrollWidth;
    
  240. 
    
  241.         _this.setState(function (prevState) {
    
  242.           if (prevState.scrollLeft === scrollLeft && prevState.scrollTop === scrollTop) {
    
  243.             // Scroll position may have been updated by cDM/cDU,
    
  244.             // In which case we don't need to trigger another render,
    
  245.             // And we don't want to update state.isScrolling.
    
  246.             return null;
    
  247.           }
    
  248. 
    
  249.           var direction = _this.props.direction; // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
    
  250.           // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
    
  251.           // It's also easier for this component if we convert offsets to the same format as they would be in for ltr.
    
  252.           // So the simplest solution is to determine which browser behavior we're dealing with, and convert based on it.
    
  253. 
    
  254.           var calculatedScrollLeft = scrollLeft;
    
  255. 
    
  256.           if (direction === 'rtl') {
    
  257.             switch (getRTLOffsetType()) {
    
  258.               case 'negative':
    
  259.                 calculatedScrollLeft = -scrollLeft;
    
  260.                 break;
    
  261. 
    
  262.               case 'positive-descending':
    
  263.                 calculatedScrollLeft = scrollWidth - clientWidth - scrollLeft;
    
  264.                 break;
    
  265.             }
    
  266.           } // Prevent Safari's elastic scrolling from causing visual shaking when scrolling past bounds.
    
  267. 
    
  268. 
    
  269.           calculatedScrollLeft = Math.max(0, Math.min(calculatedScrollLeft, scrollWidth - clientWidth));
    
  270.           var calculatedScrollTop = Math.max(0, Math.min(scrollTop, scrollHeight - clientHeight));
    
  271.           return {
    
  272.             isScrolling: true,
    
  273.             horizontalScrollDirection: prevState.scrollLeft < scrollLeft ? 'forward' : 'backward',
    
  274.             scrollLeft: calculatedScrollLeft,
    
  275.             scrollTop: calculatedScrollTop,
    
  276.             verticalScrollDirection: prevState.scrollTop < scrollTop ? 'forward' : 'backward',
    
  277.             scrollUpdateWasRequested: false
    
  278.           };
    
  279.         }, _this._resetIsScrollingDebounced);
    
  280.       };
    
  281. 
    
  282.       _this._outerRefSetter = function (ref) {
    
  283.         var outerRef = _this.props.outerRef;
    
  284.         _this._outerRef = ref;
    
  285. 
    
  286.         if (typeof outerRef === 'function') {
    
  287.           outerRef(ref);
    
  288.         } else if (outerRef != null && typeof outerRef === 'object' && outerRef.hasOwnProperty('current')) {
    
  289.           outerRef.current = ref;
    
  290.         }
    
  291.       };
    
  292. 
    
  293.       _this._resetIsScrollingDebounced = function () {
    
  294.         if (_this._resetIsScrollingTimeoutId !== null) {
    
  295.           cancelTimeout(_this._resetIsScrollingTimeoutId);
    
  296.         }
    
  297. 
    
  298.         _this._resetIsScrollingTimeoutId = requestTimeout(_this._resetIsScrolling, IS_SCROLLING_DEBOUNCE_INTERVAL);
    
  299.       };
    
  300. 
    
  301.       _this._resetIsScrolling = function () {
    
  302.         _this._resetIsScrollingTimeoutId = null;
    
  303. 
    
  304.         _this.setState({
    
  305.           isScrolling: false
    
  306.         }, function () {
    
  307.           // Clear style cache after state update has been committed.
    
  308.           // This way we don't break pure sCU for items that don't use isScrolling param.
    
  309.           _this._getItemStyleCache(-1);
    
  310.         });
    
  311.       };
    
  312. 
    
  313.       return _this;
    
  314.     }
    
  315. 
    
  316.     Grid.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
    
  317.       validateSharedProps(nextProps, prevState);
    
  318.       validateProps(nextProps);
    
  319.       return null;
    
  320.     };
    
  321. 
    
  322.     var _proto = Grid.prototype;
    
  323. 
    
  324.     _proto.scrollTo = function scrollTo(_ref3) {
    
  325.       var scrollLeft = _ref3.scrollLeft,
    
  326.           scrollTop = _ref3.scrollTop;
    
  327. 
    
  328.       if (scrollLeft !== undefined) {
    
  329.         scrollLeft = Math.max(0, scrollLeft);
    
  330.       }
    
  331. 
    
  332.       if (scrollTop !== undefined) {
    
  333.         scrollTop = Math.max(0, scrollTop);
    
  334.       }
    
  335. 
    
  336.       this.setState(function (prevState) {
    
  337.         if (scrollLeft === undefined) {
    
  338.           scrollLeft = prevState.scrollLeft;
    
  339.         }
    
  340. 
    
  341.         if (scrollTop === undefined) {
    
  342.           scrollTop = prevState.scrollTop;
    
  343.         }
    
  344. 
    
  345.         if (prevState.scrollLeft === scrollLeft && prevState.scrollTop === scrollTop) {
    
  346.           return null;
    
  347.         }
    
  348. 
    
  349.         return {
    
  350.           horizontalScrollDirection: prevState.scrollLeft < scrollLeft ? 'forward' : 'backward',
    
  351.           scrollLeft: scrollLeft,
    
  352.           scrollTop: scrollTop,
    
  353.           scrollUpdateWasRequested: true,
    
  354.           verticalScrollDirection: prevState.scrollTop < scrollTop ? 'forward' : 'backward'
    
  355.         };
    
  356.       }, this._resetIsScrollingDebounced);
    
  357.     };
    
  358. 
    
  359.     _proto.scrollToItem = function scrollToItem(_ref4) {
    
  360.       var _ref4$align = _ref4.align,
    
  361.           align = _ref4$align === void 0 ? 'auto' : _ref4$align,
    
  362.           columnIndex = _ref4.columnIndex,
    
  363.           rowIndex = _ref4.rowIndex;
    
  364.       var _this$props2 = this.props,
    
  365.           columnCount = _this$props2.columnCount,
    
  366.           height = _this$props2.height,
    
  367.           rowCount = _this$props2.rowCount,
    
  368.           width = _this$props2.width;
    
  369.       var _this$state = this.state,
    
  370.           scrollLeft = _this$state.scrollLeft,
    
  371.           scrollTop = _this$state.scrollTop;
    
  372.       var scrollbarSize = getScrollbarSize();
    
  373. 
    
  374.       if (columnIndex !== undefined) {
    
  375.         columnIndex = Math.max(0, Math.min(columnIndex, columnCount - 1));
    
  376.       }
    
  377. 
    
  378.       if (rowIndex !== undefined) {
    
  379.         rowIndex = Math.max(0, Math.min(rowIndex, rowCount - 1));
    
  380.       }
    
  381. 
    
  382.       var estimatedTotalHeight = getEstimatedTotalHeight(this.props, this._instanceProps);
    
  383.       var estimatedTotalWidth = getEstimatedTotalWidth(this.props, this._instanceProps); // The scrollbar size should be considered when scrolling an item into view,
    
  384.       // to ensure it's fully visible.
    
  385.       // But we only need to account for its size when it's actually visible.
    
  386. 
    
  387.       var horizontalScrollbarSize = estimatedTotalWidth > width ? scrollbarSize : 0;
    
  388.       var verticalScrollbarSize = estimatedTotalHeight > height ? scrollbarSize : 0;
    
  389.       this.scrollTo({
    
  390.         scrollLeft: columnIndex !== undefined ? getOffsetForColumnAndAlignment(this.props, columnIndex, align, scrollLeft, this._instanceProps, verticalScrollbarSize) : scrollLeft,
    
  391.         scrollTop: rowIndex !== undefined ? getOffsetForRowAndAlignment(this.props, rowIndex, align, scrollTop, this._instanceProps, horizontalScrollbarSize) : scrollTop
    
  392.       });
    
  393.     };
    
  394. 
    
  395.     _proto.componentDidMount = function componentDidMount() {
    
  396.       var _this$props3 = this.props,
    
  397.           initialScrollLeft = _this$props3.initialScrollLeft,
    
  398.           initialScrollTop = _this$props3.initialScrollTop;
    
  399. 
    
  400.       if (this._outerRef != null) {
    
  401.         var outerRef = this._outerRef;
    
  402. 
    
  403.         if (typeof initialScrollLeft === 'number') {
    
  404.           outerRef.scrollLeft = initialScrollLeft;
    
  405.         }
    
  406. 
    
  407.         if (typeof initialScrollTop === 'number') {
    
  408.           outerRef.scrollTop = initialScrollTop;
    
  409.         }
    
  410.       }
    
  411. 
    
  412.       this._callPropsCallbacks();
    
  413.     };
    
  414. 
    
  415.     _proto.componentDidUpdate = function componentDidUpdate() {
    
  416.       var direction = this.props.direction;
    
  417.       var _this$state2 = this.state,
    
  418.           scrollLeft = _this$state2.scrollLeft,
    
  419.           scrollTop = _this$state2.scrollTop,
    
  420.           scrollUpdateWasRequested = _this$state2.scrollUpdateWasRequested;
    
  421. 
    
  422.       if (scrollUpdateWasRequested && this._outerRef != null) {
    
  423.         // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
    
  424.         // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
    
  425.         // So we need to determine which browser behavior we're dealing with, and mimic it.
    
  426.         var outerRef = this._outerRef;
    
  427. 
    
  428.         if (direction === 'rtl') {
    
  429.           switch (getRTLOffsetType()) {
    
  430.             case 'negative':
    
  431.               outerRef.scrollLeft = -scrollLeft;
    
  432.               break;
    
  433. 
    
  434.             case 'positive-ascending':
    
  435.               outerRef.scrollLeft = scrollLeft;
    
  436.               break;
    
  437. 
    
  438.             default:
    
  439.               var clientWidth = outerRef.clientWidth,
    
  440.                   scrollWidth = outerRef.scrollWidth;
    
  441.               outerRef.scrollLeft = scrollWidth - clientWidth - scrollLeft;
    
  442.               break;
    
  443.           }
    
  444.         } else {
    
  445.           outerRef.scrollLeft = Math.max(0, scrollLeft);
    
  446.         }
    
  447. 
    
  448.         outerRef.scrollTop = Math.max(0, scrollTop);
    
  449.       }
    
  450. 
    
  451.       this._callPropsCallbacks();
    
  452.     };
    
  453. 
    
  454.     _proto.componentWillUnmount = function componentWillUnmount() {
    
  455.       if (this._resetIsScrollingTimeoutId !== null) {
    
  456.         cancelTimeout(this._resetIsScrollingTimeoutId);
    
  457.       }
    
  458.     };
    
  459. 
    
  460.     _proto.render = function render() {
    
  461.       var _this$props4 = this.props,
    
  462.           children = _this$props4.children,
    
  463.           className = _this$props4.className,
    
  464.           columnCount = _this$props4.columnCount,
    
  465.           direction = _this$props4.direction,
    
  466.           height = _this$props4.height,
    
  467.           innerRef = _this$props4.innerRef,
    
  468.           innerElementType = _this$props4.innerElementType,
    
  469.           innerTagName = _this$props4.innerTagName,
    
  470.           itemData = _this$props4.itemData,
    
  471.           _this$props4$itemKey = _this$props4.itemKey,
    
  472.           itemKey = _this$props4$itemKey === void 0 ? defaultItemKey : _this$props4$itemKey,
    
  473.           outerElementType = _this$props4.outerElementType,
    
  474.           outerTagName = _this$props4.outerTagName,
    
  475.           rowCount = _this$props4.rowCount,
    
  476.           style = _this$props4.style,
    
  477.           useIsScrolling = _this$props4.useIsScrolling,
    
  478.           width = _this$props4.width;
    
  479.       var isScrolling = this.state.isScrolling;
    
  480. 
    
  481.       var _this$_getHorizontalR = this._getHorizontalRangeToRender(),
    
  482.           columnStartIndex = _this$_getHorizontalR[0],
    
  483.           columnStopIndex = _this$_getHorizontalR[1];
    
  484. 
    
  485.       var _this$_getVerticalRan = this._getVerticalRangeToRender(),
    
  486.           rowStartIndex = _this$_getVerticalRan[0],
    
  487.           rowStopIndex = _this$_getVerticalRan[1];
    
  488. 
    
  489.       var items = [];
    
  490. 
    
  491.       if (columnCount > 0 && rowCount) {
    
  492.         for (var _rowIndex = rowStartIndex; _rowIndex <= rowStopIndex; _rowIndex++) {
    
  493.           for (var _columnIndex = columnStartIndex; _columnIndex <= columnStopIndex; _columnIndex++) {
    
  494.             items.push(react.createElement(children, {
    
  495.               columnIndex: _columnIndex,
    
  496.               data: itemData,
    
  497.               isScrolling: useIsScrolling ? isScrolling : undefined,
    
  498.               key: itemKey({
    
  499.                 columnIndex: _columnIndex,
    
  500.                 data: itemData,
    
  501.                 rowIndex: _rowIndex
    
  502.               }),
    
  503.               rowIndex: _rowIndex,
    
  504.               style: this._getItemStyle(_rowIndex, _columnIndex)
    
  505.             }));
    
  506.           }
    
  507.         }
    
  508.       } // Read this value AFTER items have been created,
    
  509.       // So their actual sizes (if variable) are taken into consideration.
    
  510. 
    
  511. 
    
  512.       var estimatedTotalHeight = getEstimatedTotalHeight(this.props, this._instanceProps);
    
  513.       var estimatedTotalWidth = getEstimatedTotalWidth(this.props, this._instanceProps);
    
  514.       return react.createElement(outerElementType || outerTagName || 'div', {
    
  515.         className: className,
    
  516.         onScroll: this._onScroll,
    
  517.         ref: this._outerRefSetter,
    
  518.         style: _extends({
    
  519.           position: 'relative',
    
  520.           height: height,
    
  521.           width: width,
    
  522.           overflow: 'auto',
    
  523.           WebkitOverflowScrolling: 'touch',
    
  524.           willChange: 'transform',
    
  525.           direction: direction
    
  526.         }, style)
    
  527.       }, react.createElement(innerElementType || innerTagName || 'div', {
    
  528.         children: items,
    
  529.         ref: innerRef,
    
  530.         style: {
    
  531.           height: estimatedTotalHeight,
    
  532.           pointerEvents: isScrolling ? 'none' : undefined,
    
  533.           width: estimatedTotalWidth
    
  534.         }
    
  535.       }));
    
  536.     };
    
  537. 
    
  538.     _proto._callPropsCallbacks = function _callPropsCallbacks() {
    
  539.       var _this$props5 = this.props,
    
  540.           columnCount = _this$props5.columnCount,
    
  541.           onItemsRendered = _this$props5.onItemsRendered,
    
  542.           onScroll = _this$props5.onScroll,
    
  543.           rowCount = _this$props5.rowCount;
    
  544. 
    
  545.       if (typeof onItemsRendered === 'function') {
    
  546.         if (columnCount > 0 && rowCount > 0) {
    
  547.           var _this$_getHorizontalR2 = this._getHorizontalRangeToRender(),
    
  548.               _overscanColumnStartIndex = _this$_getHorizontalR2[0],
    
  549.               _overscanColumnStopIndex = _this$_getHorizontalR2[1],
    
  550.               _visibleColumnStartIndex = _this$_getHorizontalR2[2],
    
  551.               _visibleColumnStopIndex = _this$_getHorizontalR2[3];
    
  552. 
    
  553.           var _this$_getVerticalRan2 = this._getVerticalRangeToRender(),
    
  554.               _overscanRowStartIndex = _this$_getVerticalRan2[0],
    
  555.               _overscanRowStopIndex = _this$_getVerticalRan2[1],
    
  556.               _visibleRowStartIndex = _this$_getVerticalRan2[2],
    
  557.               _visibleRowStopIndex = _this$_getVerticalRan2[3];
    
  558. 
    
  559.           this._callOnItemsRendered(_overscanColumnStartIndex, _overscanColumnStopIndex, _overscanRowStartIndex, _overscanRowStopIndex, _visibleColumnStartIndex, _visibleColumnStopIndex, _visibleRowStartIndex, _visibleRowStopIndex);
    
  560.         }
    
  561.       }
    
  562. 
    
  563.       if (typeof onScroll === 'function') {
    
  564.         var _this$state3 = this.state,
    
  565.             _horizontalScrollDirection = _this$state3.horizontalScrollDirection,
    
  566.             _scrollLeft = _this$state3.scrollLeft,
    
  567.             _scrollTop = _this$state3.scrollTop,
    
  568.             _scrollUpdateWasRequested = _this$state3.scrollUpdateWasRequested,
    
  569.             _verticalScrollDirection = _this$state3.verticalScrollDirection;
    
  570. 
    
  571.         this._callOnScroll(_scrollLeft, _scrollTop, _horizontalScrollDirection, _verticalScrollDirection, _scrollUpdateWasRequested);
    
  572.       }
    
  573.     }; // Lazily create and cache item styles while scrolling,
    
  574.     // So that pure component sCU will prevent re-renders.
    
  575.     // We maintain this cache, and pass a style prop rather than index,
    
  576.     // So that List can clear cached styles and force item re-render if necessary.
    
  577. 
    
  578. 
    
  579.     _proto._getHorizontalRangeToRender = function _getHorizontalRangeToRender() {
    
  580.       var _this$props6 = this.props,
    
  581.           columnCount = _this$props6.columnCount,
    
  582.           overscanColumnCount = _this$props6.overscanColumnCount,
    
  583.           overscanColumnsCount = _this$props6.overscanColumnsCount,
    
  584.           overscanCount = _this$props6.overscanCount,
    
  585.           rowCount = _this$props6.rowCount;
    
  586.       var _this$state4 = this.state,
    
  587.           horizontalScrollDirection = _this$state4.horizontalScrollDirection,
    
  588.           isScrolling = _this$state4.isScrolling,
    
  589.           scrollLeft = _this$state4.scrollLeft;
    
  590.       var overscanCountResolved = overscanColumnCount || overscanColumnsCount || overscanCount || 1;
    
  591. 
    
  592.       if (columnCount === 0 || rowCount === 0) {
    
  593.         return [0, 0, 0, 0];
    
  594.       }
    
  595. 
    
  596.       var startIndex = getColumnStartIndexForOffset(this.props, scrollLeft, this._instanceProps);
    
  597.       var stopIndex = getColumnStopIndexForStartIndex(this.props, startIndex, scrollLeft, this._instanceProps); // Overscan by one item in each direction so that tab/focus works.
    
  598.       // If there isn't at least one extra item, tab loops back around.
    
  599. 
    
  600.       var overscanBackward = !isScrolling || horizontalScrollDirection === 'backward' ? Math.max(1, overscanCountResolved) : 1;
    
  601.       var overscanForward = !isScrolling || horizontalScrollDirection === 'forward' ? Math.max(1, overscanCountResolved) : 1;
    
  602.       return [Math.max(0, startIndex - overscanBackward), Math.max(0, Math.min(columnCount - 1, stopIndex + overscanForward)), startIndex, stopIndex];
    
  603.     };
    
  604. 
    
  605.     _proto._getVerticalRangeToRender = function _getVerticalRangeToRender() {
    
  606.       var _this$props7 = this.props,
    
  607.           columnCount = _this$props7.columnCount,
    
  608.           overscanCount = _this$props7.overscanCount,
    
  609.           overscanRowCount = _this$props7.overscanRowCount,
    
  610.           overscanRowsCount = _this$props7.overscanRowsCount,
    
  611.           rowCount = _this$props7.rowCount;
    
  612.       var _this$state5 = this.state,
    
  613.           isScrolling = _this$state5.isScrolling,
    
  614.           verticalScrollDirection = _this$state5.verticalScrollDirection,
    
  615.           scrollTop = _this$state5.scrollTop;
    
  616.       var overscanCountResolved = overscanRowCount || overscanRowsCount || overscanCount || 1;
    
  617. 
    
  618.       if (columnCount === 0 || rowCount === 0) {
    
  619.         return [0, 0, 0, 0];
    
  620.       }
    
  621. 
    
  622.       var startIndex = getRowStartIndexForOffset(this.props, scrollTop, this._instanceProps);
    
  623.       var stopIndex = getRowStopIndexForStartIndex(this.props, startIndex, scrollTop, this._instanceProps); // Overscan by one item in each direction so that tab/focus works.
    
  624.       // If there isn't at least one extra item, tab loops back around.
    
  625. 
    
  626.       var overscanBackward = !isScrolling || verticalScrollDirection === 'backward' ? Math.max(1, overscanCountResolved) : 1;
    
  627.       var overscanForward = !isScrolling || verticalScrollDirection === 'forward' ? Math.max(1, overscanCountResolved) : 1;
    
  628.       return [Math.max(0, startIndex - overscanBackward), Math.max(0, Math.min(rowCount - 1, stopIndex + overscanForward)), startIndex, stopIndex];
    
  629.     };
    
  630. 
    
  631.     return Grid;
    
  632.   }(react.PureComponent), _class.defaultProps = {
    
  633.     direction: 'ltr',
    
  634.     itemData: undefined,
    
  635.     useIsScrolling: false
    
  636.   }, _temp;
    
  637. }
    
  638. 
    
  639. var validateSharedProps = function validateSharedProps(_ref5, _ref6) {
    
  640.   var children = _ref5.children,
    
  641.       direction = _ref5.direction,
    
  642.       height = _ref5.height,
    
  643.       innerTagName = _ref5.innerTagName,
    
  644.       outerTagName = _ref5.outerTagName,
    
  645.       overscanColumnsCount = _ref5.overscanColumnsCount,
    
  646.       overscanCount = _ref5.overscanCount,
    
  647.       overscanRowsCount = _ref5.overscanRowsCount,
    
  648.       width = _ref5.width;
    
  649.   var instance = _ref6.instance;
    
  650. 
    
  651.   if (process.env.NODE_ENV !== 'production') {
    
  652.     if (typeof overscanCount === 'number') {
    
  653.       if (devWarningsOverscanCount && !devWarningsOverscanCount.has(instance)) {
    
  654.         devWarningsOverscanCount.add(instance);
    
  655.         console.warn('The overscanCount prop has been deprecated. ' + 'Please use the overscanColumnCount and overscanRowCount props instead.');
    
  656.       }
    
  657.     }
    
  658. 
    
  659.     if (typeof overscanColumnsCount === 'number' || typeof overscanRowsCount === 'number') {
    
  660.       if (devWarningsOverscanRowsColumnsCount && !devWarningsOverscanRowsColumnsCount.has(instance)) {
    
  661.         devWarningsOverscanRowsColumnsCount.add(instance);
    
  662.         console.warn('The overscanColumnsCount and overscanRowsCount props have been deprecated. ' + 'Please use the overscanColumnCount and overscanRowCount props instead.');
    
  663.       }
    
  664.     }
    
  665. 
    
  666.     if (innerTagName != null || outerTagName != null) {
    
  667.       if (devWarningsTagName && !devWarningsTagName.has(instance)) {
    
  668.         devWarningsTagName.add(instance);
    
  669.         console.warn('The innerTagName and outerTagName props have been deprecated. ' + 'Please use the innerElementType and outerElementType props instead.');
    
  670.       }
    
  671.     }
    
  672. 
    
  673.     if (children == null) {
    
  674.       throw Error('An invalid "children" prop has been specified. ' + 'Value should be a React component. ' + ("\"" + (children === null ? 'null' : typeof children) + "\" was specified."));
    
  675.     }
    
  676. 
    
  677.     switch (direction) {
    
  678.       case 'ltr':
    
  679.       case 'rtl':
    
  680.         // Valid values
    
  681.         break;
    
  682. 
    
  683.       default:
    
  684.         throw Error('An invalid "direction" prop has been specified. ' + 'Value should be either "ltr" or "rtl". ' + ("\"" + direction + "\" was specified."));
    
  685.     }
    
  686. 
    
  687.     if (typeof width !== 'number') {
    
  688.       throw Error('An invalid "width" prop has been specified. ' + 'Grids must specify a number for width. ' + ("\"" + (width === null ? 'null' : typeof width) + "\" was specified."));
    
  689.     }
    
  690. 
    
  691.     if (typeof height !== 'number') {
    
  692.       throw Error('An invalid "height" prop has been specified. ' + 'Grids must specify a number for height. ' + ("\"" + (height === null ? 'null' : typeof height) + "\" was specified."));
    
  693.     }
    
  694.   }
    
  695. };
    
  696. 
    
  697. var DEFAULT_ESTIMATED_ITEM_SIZE = 50;
    
  698. 
    
  699. var getEstimatedTotalHeight = function getEstimatedTotalHeight(_ref, _ref2) {
    
  700.   var rowCount = _ref.rowCount;
    
  701.   var rowMetadataMap = _ref2.rowMetadataMap,
    
  702.       estimatedRowHeight = _ref2.estimatedRowHeight,
    
  703.       lastMeasuredRowIndex = _ref2.lastMeasuredRowIndex;
    
  704.   var totalSizeOfMeasuredRows = 0; // Edge case check for when the number of items decreases while a scroll is in progress.
    
  705.   // https://github.com/bvaughn/react-window/pull/138
    
  706. 
    
  707.   if (lastMeasuredRowIndex >= rowCount) {
    
  708.     lastMeasuredRowIndex = rowCount - 1;
    
  709.   }
    
  710. 
    
  711.   if (lastMeasuredRowIndex >= 0) {
    
  712.     var itemMetadata = rowMetadataMap[lastMeasuredRowIndex];
    
  713.     totalSizeOfMeasuredRows = itemMetadata.offset + itemMetadata.size;
    
  714.   }
    
  715. 
    
  716.   var numUnmeasuredItems = rowCount - lastMeasuredRowIndex - 1;
    
  717.   var totalSizeOfUnmeasuredItems = numUnmeasuredItems * estimatedRowHeight;
    
  718.   return totalSizeOfMeasuredRows + totalSizeOfUnmeasuredItems;
    
  719. };
    
  720. 
    
  721. var getEstimatedTotalWidth = function getEstimatedTotalWidth(_ref3, _ref4) {
    
  722.   var columnCount = _ref3.columnCount;
    
  723.   var columnMetadataMap = _ref4.columnMetadataMap,
    
  724.       estimatedColumnWidth = _ref4.estimatedColumnWidth,
    
  725.       lastMeasuredColumnIndex = _ref4.lastMeasuredColumnIndex;
    
  726.   var totalSizeOfMeasuredRows = 0; // Edge case check for when the number of items decreases while a scroll is in progress.
    
  727.   // https://github.com/bvaughn/react-window/pull/138
    
  728. 
    
  729.   if (lastMeasuredColumnIndex >= columnCount) {
    
  730.     lastMeasuredColumnIndex = columnCount - 1;
    
  731.   }
    
  732. 
    
  733.   if (lastMeasuredColumnIndex >= 0) {
    
  734.     var itemMetadata = columnMetadataMap[lastMeasuredColumnIndex];
    
  735.     totalSizeOfMeasuredRows = itemMetadata.offset + itemMetadata.size;
    
  736.   }
    
  737. 
    
  738.   var numUnmeasuredItems = columnCount - lastMeasuredColumnIndex - 1;
    
  739.   var totalSizeOfUnmeasuredItems = numUnmeasuredItems * estimatedColumnWidth;
    
  740.   return totalSizeOfMeasuredRows + totalSizeOfUnmeasuredItems;
    
  741. };
    
  742. 
    
  743. var getItemMetadata = function getItemMetadata(itemType, props, index, instanceProps) {
    
  744.   var itemMetadataMap, itemSize, lastMeasuredIndex;
    
  745. 
    
  746.   if (itemType === 'column') {
    
  747.     itemMetadataMap = instanceProps.columnMetadataMap;
    
  748.     itemSize = props.columnWidth;
    
  749.     lastMeasuredIndex = instanceProps.lastMeasuredColumnIndex;
    
  750.   } else {
    
  751.     itemMetadataMap = instanceProps.rowMetadataMap;
    
  752.     itemSize = props.rowHeight;
    
  753.     lastMeasuredIndex = instanceProps.lastMeasuredRowIndex;
    
  754.   }
    
  755. 
    
  756.   if (index > lastMeasuredIndex) {
    
  757.     var offset = 0;
    
  758. 
    
  759.     if (lastMeasuredIndex >= 0) {
    
  760.       var itemMetadata = itemMetadataMap[lastMeasuredIndex];
    
  761.       offset = itemMetadata.offset + itemMetadata.size;
    
  762.     }
    
  763. 
    
  764.     for (var i = lastMeasuredIndex + 1; i <= index; i++) {
    
  765.       var size = itemSize(i);
    
  766.       itemMetadataMap[i] = {
    
  767.         offset: offset,
    
  768.         size: size
    
  769.       };
    
  770.       offset += size;
    
  771.     }
    
  772. 
    
  773.     if (itemType === 'column') {
    
  774.       instanceProps.lastMeasuredColumnIndex = index;
    
  775.     } else {
    
  776.       instanceProps.lastMeasuredRowIndex = index;
    
  777.     }
    
  778.   }
    
  779. 
    
  780.   return itemMetadataMap[index];
    
  781. };
    
  782. 
    
  783. var findNearestItem = function findNearestItem(itemType, props, instanceProps, offset) {
    
  784.   var itemMetadataMap, lastMeasuredIndex;
    
  785. 
    
  786.   if (itemType === 'column') {
    
  787.     itemMetadataMap = instanceProps.columnMetadataMap;
    
  788.     lastMeasuredIndex = instanceProps.lastMeasuredColumnIndex;
    
  789.   } else {
    
  790.     itemMetadataMap = instanceProps.rowMetadataMap;
    
  791.     lastMeasuredIndex = instanceProps.lastMeasuredRowIndex;
    
  792.   }
    
  793. 
    
  794.   var lastMeasuredItemOffset = lastMeasuredIndex > 0 ? itemMetadataMap[lastMeasuredIndex].offset : 0;
    
  795. 
    
  796.   if (lastMeasuredItemOffset >= offset) {
    
  797.     // If we've already measured items within this range just use a binary search as it's faster.
    
  798.     return findNearestItemBinarySearch(itemType, props, instanceProps, lastMeasuredIndex, 0, offset);
    
  799.   } else {
    
  800.     // If we haven't yet measured this high, fallback to an exponential search with an inner binary search.
    
  801.     // The exponential search avoids pre-computing sizes for the full set of items as a binary search would.
    
  802.     // The overall complexity for this approach is O(log n).
    
  803.     return findNearestItemExponentialSearch(itemType, props, instanceProps, Math.max(0, lastMeasuredIndex), offset);
    
  804.   }
    
  805. };
    
  806. 
    
  807. var findNearestItemBinarySearch = function findNearestItemBinarySearch(itemType, props, instanceProps, high, low, offset) {
    
  808.   while (low <= high) {
    
  809.     var middle = low + Math.floor((high - low) / 2);
    
  810.     var currentOffset = getItemMetadata(itemType, props, middle, instanceProps).offset;
    
  811. 
    
  812.     if (currentOffset === offset) {
    
  813.       return middle;
    
  814.     } else if (currentOffset < offset) {
    
  815.       low = middle + 1;
    
  816.     } else if (currentOffset > offset) {
    
  817.       high = middle - 1;
    
  818.     }
    
  819.   }
    
  820. 
    
  821.   if (low > 0) {
    
  822.     return low - 1;
    
  823.   } else {
    
  824.     return 0;
    
  825.   }
    
  826. };
    
  827. 
    
  828. var findNearestItemExponentialSearch = function findNearestItemExponentialSearch(itemType, props, instanceProps, index, offset) {
    
  829.   var itemCount = itemType === 'column' ? props.columnCount : props.rowCount;
    
  830.   var interval = 1;
    
  831. 
    
  832.   while (index < itemCount && getItemMetadata(itemType, props, index, instanceProps).offset < offset) {
    
  833.     index += interval;
    
  834.     interval *= 2;
    
  835.   }
    
  836. 
    
  837.   return findNearestItemBinarySearch(itemType, props, instanceProps, Math.min(index, itemCount - 1), Math.floor(index / 2), offset);
    
  838. };
    
  839. 
    
  840. var getOffsetForIndexAndAlignment = function getOffsetForIndexAndAlignment(itemType, props, index, align, scrollOffset, instanceProps, scrollbarSize) {
    
  841.   var size = itemType === 'column' ? props.width : props.height;
    
  842.   var itemMetadata = getItemMetadata(itemType, props, index, instanceProps); // Get estimated total size after ItemMetadata is computed,
    
  843.   // To ensure it reflects actual measurements instead of just estimates.
    
  844. 
    
  845.   var estimatedTotalSize = itemType === 'column' ? getEstimatedTotalWidth(props, instanceProps) : getEstimatedTotalHeight(props, instanceProps);
    
  846.   var maxOffset = Math.max(0, Math.min(estimatedTotalSize - size, itemMetadata.offset));
    
  847.   var minOffset = Math.max(0, itemMetadata.offset - size + scrollbarSize + itemMetadata.size);
    
  848. 
    
  849.   if (align === 'smart') {
    
  850.     if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
    
  851.       align = 'auto';
    
  852.     } else {
    
  853.       align = 'center';
    
  854.     }
    
  855.   }
    
  856. 
    
  857.   switch (align) {
    
  858.     case 'start':
    
  859.       return maxOffset;
    
  860. 
    
  861.     case 'end':
    
  862.       return minOffset;
    
  863. 
    
  864.     case 'center':
    
  865.       return Math.round(minOffset + (maxOffset - minOffset) / 2);
    
  866. 
    
  867.     case 'auto':
    
  868.     default:
    
  869.       if (scrollOffset >= minOffset && scrollOffset <= maxOffset) {
    
  870.         return scrollOffset;
    
  871.       } else if (minOffset > maxOffset) {
    
  872.         // Because we only take into account the scrollbar size when calculating minOffset
    
  873.         // this value can be larger than maxOffset when at the end of the list
    
  874.         return minOffset;
    
  875.       } else if (scrollOffset < minOffset) {
    
  876.         return minOffset;
    
  877.       } else {
    
  878.         return maxOffset;
    
  879.       }
    
  880. 
    
  881.   }
    
  882. };
    
  883. 
    
  884. var VariableSizeGrid =
    
  885. /*#__PURE__*/
    
  886. createGridComponent({
    
  887.   getColumnOffset: function getColumnOffset(props, index, instanceProps) {
    
  888.     return getItemMetadata('column', props, index, instanceProps).offset;
    
  889.   },
    
  890.   getColumnStartIndexForOffset: function getColumnStartIndexForOffset(props, scrollLeft, instanceProps) {
    
  891.     return findNearestItem('column', props, instanceProps, scrollLeft);
    
  892.   },
    
  893.   getColumnStopIndexForStartIndex: function getColumnStopIndexForStartIndex(props, startIndex, scrollLeft, instanceProps) {
    
  894.     var columnCount = props.columnCount,
    
  895.         width = props.width;
    
  896.     var itemMetadata = getItemMetadata('column', props, startIndex, instanceProps);
    
  897.     var maxOffset = scrollLeft + width;
    
  898.     var offset = itemMetadata.offset + itemMetadata.size;
    
  899.     var stopIndex = startIndex;
    
  900. 
    
  901.     while (stopIndex < columnCount - 1 && offset < maxOffset) {
    
  902.       stopIndex++;
    
  903.       offset += getItemMetadata('column', props, stopIndex, instanceProps).size;
    
  904.     }
    
  905. 
    
  906.     return stopIndex;
    
  907.   },
    
  908.   getColumnWidth: function getColumnWidth(props, index, instanceProps) {
    
  909.     return instanceProps.columnMetadataMap[index].size;
    
  910.   },
    
  911.   getEstimatedTotalHeight: getEstimatedTotalHeight,
    
  912.   getEstimatedTotalWidth: getEstimatedTotalWidth,
    
  913.   getOffsetForColumnAndAlignment: function getOffsetForColumnAndAlignment(props, index, align, scrollOffset, instanceProps, scrollbarSize) {
    
  914.     return getOffsetForIndexAndAlignment('column', props, index, align, scrollOffset, instanceProps, scrollbarSize);
    
  915.   },
    
  916.   getOffsetForRowAndAlignment: function getOffsetForRowAndAlignment(props, index, align, scrollOffset, instanceProps, scrollbarSize) {
    
  917.     return getOffsetForIndexAndAlignment('row', props, index, align, scrollOffset, instanceProps, scrollbarSize);
    
  918.   },
    
  919.   getRowOffset: function getRowOffset(props, index, instanceProps) {
    
  920.     return getItemMetadata('row', props, index, instanceProps).offset;
    
  921.   },
    
  922.   getRowHeight: function getRowHeight(props, index, instanceProps) {
    
  923.     return instanceProps.rowMetadataMap[index].size;
    
  924.   },
    
  925.   getRowStartIndexForOffset: function getRowStartIndexForOffset(props, scrollTop, instanceProps) {
    
  926.     return findNearestItem('row', props, instanceProps, scrollTop);
    
  927.   },
    
  928.   getRowStopIndexForStartIndex: function getRowStopIndexForStartIndex(props, startIndex, scrollTop, instanceProps) {
    
  929.     var rowCount = props.rowCount,
    
  930.         height = props.height;
    
  931.     var itemMetadata = getItemMetadata('row', props, startIndex, instanceProps);
    
  932.     var maxOffset = scrollTop + height;
    
  933.     var offset = itemMetadata.offset + itemMetadata.size;
    
  934.     var stopIndex = startIndex;
    
  935. 
    
  936.     while (stopIndex < rowCount - 1 && offset < maxOffset) {
    
  937.       stopIndex++;
    
  938.       offset += getItemMetadata('row', props, stopIndex, instanceProps).size;
    
  939.     }
    
  940. 
    
  941.     return stopIndex;
    
  942.   },
    
  943.   initInstanceProps: function initInstanceProps(props, instance) {
    
  944.     var _ref5 = props,
    
  945.         estimatedColumnWidth = _ref5.estimatedColumnWidth,
    
  946.         estimatedRowHeight = _ref5.estimatedRowHeight;
    
  947.     var instanceProps = {
    
  948.       columnMetadataMap: {},
    
  949.       estimatedColumnWidth: estimatedColumnWidth || DEFAULT_ESTIMATED_ITEM_SIZE,
    
  950.       estimatedRowHeight: estimatedRowHeight || DEFAULT_ESTIMATED_ITEM_SIZE,
    
  951.       lastMeasuredColumnIndex: -1,
    
  952.       lastMeasuredRowIndex: -1,
    
  953.       rowMetadataMap: {}
    
  954.     };
    
  955. 
    
  956.     instance.resetAfterColumnIndex = function (columnIndex, shouldForceUpdate) {
    
  957.       if (shouldForceUpdate === void 0) {
    
  958.         shouldForceUpdate = true;
    
  959.       }
    
  960. 
    
  961.       instance.resetAfterIndices({
    
  962.         columnIndex: columnIndex,
    
  963.         shouldForceUpdate: shouldForceUpdate
    
  964.       });
    
  965.     };
    
  966. 
    
  967.     instance.resetAfterRowIndex = function (rowIndex, shouldForceUpdate) {
    
  968.       if (shouldForceUpdate === void 0) {
    
  969.         shouldForceUpdate = true;
    
  970.       }
    
  971. 
    
  972.       instance.resetAfterIndices({
    
  973.         rowIndex: rowIndex,
    
  974.         shouldForceUpdate: shouldForceUpdate
    
  975.       });
    
  976.     };
    
  977. 
    
  978.     instance.resetAfterIndices = function (_ref6) {
    
  979.       var columnIndex = _ref6.columnIndex,
    
  980.           rowIndex = _ref6.rowIndex,
    
  981.           _ref6$shouldForceUpda = _ref6.shouldForceUpdate,
    
  982.           shouldForceUpdate = _ref6$shouldForceUpda === void 0 ? true : _ref6$shouldForceUpda;
    
  983. 
    
  984.       if (typeof columnIndex === 'number') {
    
  985.         instanceProps.lastMeasuredColumnIndex = Math.min(instanceProps.lastMeasuredColumnIndex, columnIndex - 1);
    
  986.       }
    
  987. 
    
  988.       if (typeof rowIndex === 'number') {
    
  989.         instanceProps.lastMeasuredRowIndex = Math.min(instanceProps.lastMeasuredRowIndex, rowIndex - 1);
    
  990.       } // We could potentially optimize further by only evicting styles after this index,
    
  991.       // But since styles are only cached while scrolling is in progress-
    
  992.       // It seems an unnecessary optimization.
    
  993.       // It's unlikely that resetAfterIndex() will be called while a user is scrolling.
    
  994. 
    
  995. 
    
  996.       instance._getItemStyleCache(-1);
    
  997. 
    
  998.       if (shouldForceUpdate) {
    
  999.         instance.forceUpdate();
    
  1000.       }
    
  1001.     };
    
  1002. 
    
  1003.     return instanceProps;
    
  1004.   },
    
  1005.   shouldResetStyleCacheOnItemSizeChange: false,
    
  1006.   validateProps: function validateProps(_ref7) {
    
  1007.     var columnWidth = _ref7.columnWidth,
    
  1008.         rowHeight = _ref7.rowHeight;
    
  1009. 
    
  1010.     if (process.env.NODE_ENV !== 'production') {
    
  1011.       if (typeof columnWidth !== 'function') {
    
  1012.         throw Error('An invalid "columnWidth" prop has been specified. ' + 'Value should be a function. ' + ("\"" + (columnWidth === null ? 'null' : typeof columnWidth) + "\" was specified."));
    
  1013.       } else if (typeof rowHeight !== 'function') {
    
  1014.         throw Error('An invalid "rowHeight" prop has been specified. ' + 'Value should be a function. ' + ("\"" + (rowHeight === null ? 'null' : typeof rowHeight) + "\" was specified."));
    
  1015.       }
    
  1016.     }
    
  1017.   }
    
  1018. });
    
  1019. 
    
  1020. var IS_SCROLLING_DEBOUNCE_INTERVAL$1 = 150;
    
  1021. 
    
  1022. var defaultItemKey$1 = function defaultItemKey(index, data) {
    
  1023.   return index;
    
  1024. }; // In DEV mode, this Set helps us only log a warning once per component instance.
    
  1025. // This avoids spamming the console every time a render happens.
    
  1026. 
    
  1027. 
    
  1028. var devWarningsDirection = null;
    
  1029. var devWarningsTagName$1 = null;
    
  1030. 
    
  1031. if (process.env.NODE_ENV !== 'production') {
    
  1032.   if (typeof window !== 'undefined' && typeof window.WeakSet !== 'undefined') {
    
  1033.     devWarningsDirection =
    
  1034.     /*#__PURE__*/
    
  1035.     new WeakSet();
    
  1036.     devWarningsTagName$1 =
    
  1037.     /*#__PURE__*/
    
  1038.     new WeakSet();
    
  1039.   }
    
  1040. }
    
  1041. 
    
  1042. function createListComponent(_ref) {
    
  1043.   var _class, _temp;
    
  1044. 
    
  1045.   var getItemOffset = _ref.getItemOffset,
    
  1046.       getEstimatedTotalSize = _ref.getEstimatedTotalSize,
    
  1047.       getItemSize = _ref.getItemSize,
    
  1048.       getOffsetForIndexAndAlignment = _ref.getOffsetForIndexAndAlignment,
    
  1049.       getStartIndexForOffset = _ref.getStartIndexForOffset,
    
  1050.       getStopIndexForStartIndex = _ref.getStopIndexForStartIndex,
    
  1051.       initInstanceProps = _ref.initInstanceProps,
    
  1052.       shouldResetStyleCacheOnItemSizeChange = _ref.shouldResetStyleCacheOnItemSizeChange,
    
  1053.       validateProps = _ref.validateProps;
    
  1054.   return _temp = _class =
    
  1055.   /*#__PURE__*/
    
  1056.   function (_PureComponent) {
    
  1057.     _inheritsLoose(List, _PureComponent);
    
  1058. 
    
  1059.     // Always use explicit constructor for React components.
    
  1060.     // It produces less code after transpilation. (#26)
    
  1061.     // eslint-disable-next-line no-useless-constructor
    
  1062.     function List(props) {
    
  1063.       var _this;
    
  1064. 
    
  1065.       _this = _PureComponent.call(this, props) || this;
    
  1066.       _this._instanceProps = initInstanceProps(_this.props, _assertThisInitialized(_assertThisInitialized(_this)));
    
  1067.       _this._outerRef = void 0;
    
  1068.       _this._resetIsScrollingTimeoutId = null;
    
  1069.       _this.state = {
    
  1070.         instance: _assertThisInitialized(_assertThisInitialized(_this)),
    
  1071.         isScrolling: false,
    
  1072.         scrollDirection: 'forward',
    
  1073.         scrollOffset: typeof _this.props.initialScrollOffset === 'number' ? _this.props.initialScrollOffset : 0,
    
  1074.         scrollUpdateWasRequested: false
    
  1075.       };
    
  1076.       _this._callOnItemsRendered = void 0;
    
  1077.       _this._callOnItemsRendered = memoizeOne(function (overscanStartIndex, overscanStopIndex, visibleStartIndex, visibleStopIndex) {
    
  1078.         return _this.props.onItemsRendered({
    
  1079.           overscanStartIndex: overscanStartIndex,
    
  1080.           overscanStopIndex: overscanStopIndex,
    
  1081.           visibleStartIndex: visibleStartIndex,
    
  1082.           visibleStopIndex: visibleStopIndex
    
  1083.         });
    
  1084.       });
    
  1085.       _this._callOnScroll = void 0;
    
  1086.       _this._callOnScroll = memoizeOne(function (scrollDirection, scrollOffset, scrollUpdateWasRequested) {
    
  1087.         return _this.props.onScroll({
    
  1088.           scrollDirection: scrollDirection,
    
  1089.           scrollOffset: scrollOffset,
    
  1090.           scrollUpdateWasRequested: scrollUpdateWasRequested
    
  1091.         });
    
  1092.       });
    
  1093.       _this._getItemStyle = void 0;
    
  1094. 
    
  1095.       _this._getItemStyle = function (index) {
    
  1096.         var _this$props = _this.props,
    
  1097.             direction = _this$props.direction,
    
  1098.             itemSize = _this$props.itemSize,
    
  1099.             layout = _this$props.layout;
    
  1100. 
    
  1101.         var itemStyleCache = _this._getItemStyleCache(shouldResetStyleCacheOnItemSizeChange && itemSize, shouldResetStyleCacheOnItemSizeChange && layout, shouldResetStyleCacheOnItemSizeChange && direction);
    
  1102. 
    
  1103.         var style;
    
  1104. 
    
  1105.         if (itemStyleCache.hasOwnProperty(index)) {
    
  1106.           style = itemStyleCache[index];
    
  1107.         } else {
    
  1108.           var _style;
    
  1109. 
    
  1110.           var _offset = getItemOffset(_this.props, index, _this._instanceProps);
    
  1111. 
    
  1112.           var size = getItemSize(_this.props, index, _this._instanceProps); // TODO Deprecate direction "horizontal"
    
  1113. 
    
  1114.           var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
    
  1115.           itemStyleCache[index] = style = (_style = {
    
  1116.             position: 'absolute'
    
  1117.           }, _style[direction === 'rtl' ? 'right' : 'left'] = isHorizontal ? _offset : 0, _style.top = !isHorizontal ? _offset : 0, _style.height = !isHorizontal ? size : '100%', _style.width = isHorizontal ? size : '100%', _style);
    
  1118.         }
    
  1119. 
    
  1120.         return style;
    
  1121.       };
    
  1122. 
    
  1123.       _this._getItemStyleCache = void 0;
    
  1124.       _this._getItemStyleCache = memoizeOne(function (_, __, ___) {
    
  1125.         return {};
    
  1126.       });
    
  1127. 
    
  1128.       _this._onScrollHorizontal = function (event) {
    
  1129.         var _event$currentTarget = event.currentTarget,
    
  1130.             clientWidth = _event$currentTarget.clientWidth,
    
  1131.             scrollLeft = _event$currentTarget.scrollLeft,
    
  1132.             scrollWidth = _event$currentTarget.scrollWidth;
    
  1133. 
    
  1134.         _this.setState(function (prevState) {
    
  1135.           if (prevState.scrollOffset === scrollLeft) {
    
  1136.             // Scroll position may have been updated by cDM/cDU,
    
  1137.             // In which case we don't need to trigger another render,
    
  1138.             // And we don't want to update state.isScrolling.
    
  1139.             return null;
    
  1140.           }
    
  1141. 
    
  1142.           var direction = _this.props.direction;
    
  1143.           var scrollOffset = scrollLeft;
    
  1144. 
    
  1145.           if (direction === 'rtl') {
    
  1146.             // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
    
  1147.             // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
    
  1148.             // It's also easier for this component if we convert offsets to the same format as they would be in for ltr.
    
  1149.             // So the simplest solution is to determine which browser behavior we're dealing with, and convert based on it.
    
  1150.             switch (getRTLOffsetType()) {
    
  1151.               case 'negative':
    
  1152.                 scrollOffset = -scrollLeft;
    
  1153.                 break;
    
  1154. 
    
  1155.               case 'positive-descending':
    
  1156.                 scrollOffset = scrollWidth - clientWidth - scrollLeft;
    
  1157.                 break;
    
  1158.             }
    
  1159.           } // Prevent Safari's elastic scrolling from causing visual shaking when scrolling past bounds.
    
  1160. 
    
  1161. 
    
  1162.           scrollOffset = Math.max(0, Math.min(scrollOffset, scrollWidth - clientWidth));
    
  1163.           return {
    
  1164.             isScrolling: true,
    
  1165.             scrollDirection: prevState.scrollOffset < scrollLeft ? 'forward' : 'backward',
    
  1166.             scrollOffset: scrollOffset,
    
  1167.             scrollUpdateWasRequested: false
    
  1168.           };
    
  1169.         }, _this._resetIsScrollingDebounced);
    
  1170.       };
    
  1171. 
    
  1172.       _this._onScrollVertical = function (event) {
    
  1173.         var _event$currentTarget2 = event.currentTarget,
    
  1174.             clientHeight = _event$currentTarget2.clientHeight,
    
  1175.             scrollHeight = _event$currentTarget2.scrollHeight,
    
  1176.             scrollTop = _event$currentTarget2.scrollTop;
    
  1177. 
    
  1178.         _this.setState(function (prevState) {
    
  1179.           if (prevState.scrollOffset === scrollTop) {
    
  1180.             // Scroll position may have been updated by cDM/cDU,
    
  1181.             // In which case we don't need to trigger another render,
    
  1182.             // And we don't want to update state.isScrolling.
    
  1183.             return null;
    
  1184.           } // Prevent Safari's elastic scrolling from causing visual shaking when scrolling past bounds.
    
  1185. 
    
  1186. 
    
  1187.           var scrollOffset = Math.max(0, Math.min(scrollTop, scrollHeight - clientHeight));
    
  1188.           return {
    
  1189.             isScrolling: true,
    
  1190.             scrollDirection: prevState.scrollOffset < scrollOffset ? 'forward' : 'backward',
    
  1191.             scrollOffset: scrollOffset,
    
  1192.             scrollUpdateWasRequested: false
    
  1193.           };
    
  1194.         }, _this._resetIsScrollingDebounced);
    
  1195.       };
    
  1196. 
    
  1197.       _this._outerRefSetter = function (ref) {
    
  1198.         var outerRef = _this.props.outerRef;
    
  1199.         _this._outerRef = ref;
    
  1200. 
    
  1201.         if (typeof outerRef === 'function') {
    
  1202.           outerRef(ref);
    
  1203.         } else if (outerRef != null && typeof outerRef === 'object' && outerRef.hasOwnProperty('current')) {
    
  1204.           outerRef.current = ref;
    
  1205.         }
    
  1206.       };
    
  1207. 
    
  1208.       _this._resetIsScrollingDebounced = function () {
    
  1209.         if (_this._resetIsScrollingTimeoutId !== null) {
    
  1210.           cancelTimeout(_this._resetIsScrollingTimeoutId);
    
  1211.         }
    
  1212. 
    
  1213.         _this._resetIsScrollingTimeoutId = requestTimeout(_this._resetIsScrolling, IS_SCROLLING_DEBOUNCE_INTERVAL$1);
    
  1214.       };
    
  1215. 
    
  1216.       _this._resetIsScrolling = function () {
    
  1217.         _this._resetIsScrollingTimeoutId = null;
    
  1218. 
    
  1219.         _this.setState({
    
  1220.           isScrolling: false
    
  1221.         }, function () {
    
  1222.           // Clear style cache after state update has been committed.
    
  1223.           // This way we don't break pure sCU for items that don't use isScrolling param.
    
  1224.           _this._getItemStyleCache(-1, null);
    
  1225.         });
    
  1226.       };
    
  1227. 
    
  1228.       return _this;
    
  1229.     }
    
  1230. 
    
  1231.     List.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
    
  1232.       validateSharedProps$1(nextProps, prevState);
    
  1233.       validateProps(nextProps);
    
  1234.       return null;
    
  1235.     };
    
  1236. 
    
  1237.     var _proto = List.prototype;
    
  1238. 
    
  1239.     _proto.scrollTo = function scrollTo(scrollOffset) {
    
  1240.       scrollOffset = Math.max(0, scrollOffset);
    
  1241.       this.setState(function (prevState) {
    
  1242.         if (prevState.scrollOffset === scrollOffset) {
    
  1243.           return null;
    
  1244.         }
    
  1245. 
    
  1246.         return {
    
  1247.           scrollDirection: prevState.scrollOffset < scrollOffset ? 'forward' : 'backward',
    
  1248.           scrollOffset: scrollOffset,
    
  1249.           scrollUpdateWasRequested: true
    
  1250.         };
    
  1251.       }, this._resetIsScrollingDebounced);
    
  1252.     };
    
  1253. 
    
  1254.     _proto.scrollToItem = function scrollToItem(index, align) {
    
  1255.       if (align === void 0) {
    
  1256.         align = 'auto';
    
  1257.       }
    
  1258. 
    
  1259.       var itemCount = this.props.itemCount;
    
  1260.       var scrollOffset = this.state.scrollOffset;
    
  1261.       index = Math.max(0, Math.min(index, itemCount - 1));
    
  1262.       this.scrollTo(getOffsetForIndexAndAlignment(this.props, index, align, scrollOffset, this._instanceProps));
    
  1263.     };
    
  1264. 
    
  1265.     _proto.componentDidMount = function componentDidMount() {
    
  1266.       var _this$props2 = this.props,
    
  1267.           direction = _this$props2.direction,
    
  1268.           initialScrollOffset = _this$props2.initialScrollOffset,
    
  1269.           layout = _this$props2.layout;
    
  1270. 
    
  1271.       if (typeof initialScrollOffset === 'number' && this._outerRef != null) {
    
  1272.         var outerRef = this._outerRef; // TODO Deprecate direction "horizontal"
    
  1273. 
    
  1274.         if (direction === 'horizontal' || layout === 'horizontal') {
    
  1275.           outerRef.scrollLeft = initialScrollOffset;
    
  1276.         } else {
    
  1277.           outerRef.scrollTop = initialScrollOffset;
    
  1278.         }
    
  1279.       }
    
  1280. 
    
  1281.       this._callPropsCallbacks();
    
  1282.     };
    
  1283. 
    
  1284.     _proto.componentDidUpdate = function componentDidUpdate() {
    
  1285.       var _this$props3 = this.props,
    
  1286.           direction = _this$props3.direction,
    
  1287.           layout = _this$props3.layout;
    
  1288.       var _this$state = this.state,
    
  1289.           scrollOffset = _this$state.scrollOffset,
    
  1290.           scrollUpdateWasRequested = _this$state.scrollUpdateWasRequested;
    
  1291. 
    
  1292.       if (scrollUpdateWasRequested && this._outerRef != null) {
    
  1293.         var outerRef = this._outerRef; // TODO Deprecate direction "horizontal"
    
  1294. 
    
  1295.         if (direction === 'horizontal' || layout === 'horizontal') {
    
  1296.           if (direction === 'rtl') {
    
  1297.             // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
    
  1298.             // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
    
  1299.             // So we need to determine which browser behavior we're dealing with, and mimic it.
    
  1300.             switch (getRTLOffsetType()) {
    
  1301.               case 'negative':
    
  1302.                 outerRef.scrollLeft = -scrollOffset;
    
  1303.                 break;
    
  1304. 
    
  1305.               case 'positive-ascending':
    
  1306.                 outerRef.scrollLeft = scrollOffset;
    
  1307.                 break;
    
  1308. 
    
  1309.               default:
    
  1310.                 var clientWidth = outerRef.clientWidth,
    
  1311.                     scrollWidth = outerRef.scrollWidth;
    
  1312.                 outerRef.scrollLeft = scrollWidth - clientWidth - scrollOffset;
    
  1313.                 break;
    
  1314.             }
    
  1315.           } else {
    
  1316.             outerRef.scrollLeft = scrollOffset;
    
  1317.           }
    
  1318.         } else {
    
  1319.           outerRef.scrollTop = scrollOffset;
    
  1320.         }
    
  1321.       }
    
  1322. 
    
  1323.       this._callPropsCallbacks();
    
  1324.     };
    
  1325. 
    
  1326.     _proto.componentWillUnmount = function componentWillUnmount() {
    
  1327.       if (this._resetIsScrollingTimeoutId !== null) {
    
  1328.         cancelTimeout(this._resetIsScrollingTimeoutId);
    
  1329.       }
    
  1330.     };
    
  1331. 
    
  1332.     _proto.render = function render() {
    
  1333.       var _this$props4 = this.props,
    
  1334.           children = _this$props4.children,
    
  1335.           className = _this$props4.className,
    
  1336.           direction = _this$props4.direction,
    
  1337.           height = _this$props4.height,
    
  1338.           innerRef = _this$props4.innerRef,
    
  1339.           innerElementType = _this$props4.innerElementType,
    
  1340.           innerTagName = _this$props4.innerTagName,
    
  1341.           itemCount = _this$props4.itemCount,
    
  1342.           itemData = _this$props4.itemData,
    
  1343.           _this$props4$itemKey = _this$props4.itemKey,
    
  1344.           itemKey = _this$props4$itemKey === void 0 ? defaultItemKey$1 : _this$props4$itemKey,
    
  1345.           layout = _this$props4.layout,
    
  1346.           outerElementType = _this$props4.outerElementType,
    
  1347.           outerTagName = _this$props4.outerTagName,
    
  1348.           style = _this$props4.style,
    
  1349.           useIsScrolling = _this$props4.useIsScrolling,
    
  1350.           width = _this$props4.width;
    
  1351.       var isScrolling = this.state.isScrolling; // TODO Deprecate direction "horizontal"
    
  1352. 
    
  1353.       var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
    
  1354.       var onScroll = isHorizontal ? this._onScrollHorizontal : this._onScrollVertical;
    
  1355. 
    
  1356.       var _this$_getRangeToRend = this._getRangeToRender(),
    
  1357.           startIndex = _this$_getRangeToRend[0],
    
  1358.           stopIndex = _this$_getRangeToRend[1];
    
  1359. 
    
  1360.       var items = [];
    
  1361. 
    
  1362.       if (itemCount > 0) {
    
  1363.         for (var _index = startIndex; _index <= stopIndex; _index++) {
    
  1364.           items.push(react.createElement(children, {
    
  1365.             data: itemData,
    
  1366.             key: itemKey(_index, itemData),
    
  1367.             index: _index,
    
  1368.             isScrolling: useIsScrolling ? isScrolling : undefined,
    
  1369.             style: this._getItemStyle(_index)
    
  1370.           }));
    
  1371.         }
    
  1372.       } // Read this value AFTER items have been created,
    
  1373.       // So their actual sizes (if variable) are taken into consideration.
    
  1374. 
    
  1375. 
    
  1376.       var estimatedTotalSize = getEstimatedTotalSize(this.props, this._instanceProps);
    
  1377.       return react.createElement(outerElementType || outerTagName || 'div', {
    
  1378.         className: className,
    
  1379.         onScroll: onScroll,
    
  1380.         ref: this._outerRefSetter,
    
  1381.         style: _extends({
    
  1382.           position: 'relative',
    
  1383.           height: height,
    
  1384.           width: width,
    
  1385.           overflow: 'auto',
    
  1386.           WebkitOverflowScrolling: 'touch',
    
  1387.           willChange: 'transform',
    
  1388.           direction: direction
    
  1389.         }, style)
    
  1390.       }, react.createElement(innerElementType || innerTagName || 'div', {
    
  1391.         children: items,
    
  1392.         ref: innerRef,
    
  1393.         style: {
    
  1394.           height: isHorizontal ? '100%' : estimatedTotalSize,
    
  1395.           pointerEvents: isScrolling ? 'none' : undefined,
    
  1396.           width: isHorizontal ? estimatedTotalSize : '100%'
    
  1397.         }
    
  1398.       }));
    
  1399.     };
    
  1400. 
    
  1401.     _proto._callPropsCallbacks = function _callPropsCallbacks() {
    
  1402.       if (typeof this.props.onItemsRendered === 'function') {
    
  1403.         var itemCount = this.props.itemCount;
    
  1404. 
    
  1405.         if (itemCount > 0) {
    
  1406.           var _this$_getRangeToRend2 = this._getRangeToRender(),
    
  1407.               _overscanStartIndex = _this$_getRangeToRend2[0],
    
  1408.               _overscanStopIndex = _this$_getRangeToRend2[1],
    
  1409.               _visibleStartIndex = _this$_getRangeToRend2[2],
    
  1410.               _visibleStopIndex = _this$_getRangeToRend2[3];
    
  1411. 
    
  1412.           this._callOnItemsRendered(_overscanStartIndex, _overscanStopIndex, _visibleStartIndex, _visibleStopIndex);
    
  1413.         }
    
  1414.       }
    
  1415. 
    
  1416.       if (typeof this.props.onScroll === 'function') {
    
  1417.         var _this$state2 = this.state,
    
  1418.             _scrollDirection = _this$state2.scrollDirection,
    
  1419.             _scrollOffset = _this$state2.scrollOffset,
    
  1420.             _scrollUpdateWasRequested = _this$state2.scrollUpdateWasRequested;
    
  1421. 
    
  1422.         this._callOnScroll(_scrollDirection, _scrollOffset, _scrollUpdateWasRequested);
    
  1423.       }
    
  1424.     }; // Lazily create and cache item styles while scrolling,
    
  1425.     // So that pure component sCU will prevent re-renders.
    
  1426.     // We maintain this cache, and pass a style prop rather than index,
    
  1427.     // So that List can clear cached styles and force item re-render if necessary.
    
  1428. 
    
  1429. 
    
  1430.     _proto._getRangeToRender = function _getRangeToRender() {
    
  1431.       var _this$props5 = this.props,
    
  1432.           itemCount = _this$props5.itemCount,
    
  1433.           overscanCount = _this$props5.overscanCount;
    
  1434.       var _this$state3 = this.state,
    
  1435.           isScrolling = _this$state3.isScrolling,
    
  1436.           scrollDirection = _this$state3.scrollDirection,
    
  1437.           scrollOffset = _this$state3.scrollOffset;
    
  1438. 
    
  1439.       if (itemCount === 0) {
    
  1440.         return [0, 0, 0, 0];
    
  1441.       }
    
  1442. 
    
  1443.       var startIndex = getStartIndexForOffset(this.props, scrollOffset, this._instanceProps);
    
  1444.       var stopIndex = getStopIndexForStartIndex(this.props, startIndex, scrollOffset, this._instanceProps); // Overscan by one item in each direction so that tab/focus works.
    
  1445.       // If there isn't at least one extra item, tab loops back around.
    
  1446. 
    
  1447.       var overscanBackward = !isScrolling || scrollDirection === 'backward' ? Math.max(1, overscanCount) : 1;
    
  1448.       var overscanForward = !isScrolling || scrollDirection === 'forward' ? Math.max(1, overscanCount) : 1;
    
  1449.       return [Math.max(0, startIndex - overscanBackward), Math.max(0, Math.min(itemCount - 1, stopIndex + overscanForward)), startIndex, stopIndex];
    
  1450.     };
    
  1451. 
    
  1452.     return List;
    
  1453.   }(react.PureComponent), _class.defaultProps = {
    
  1454.     direction: 'ltr',
    
  1455.     itemData: undefined,
    
  1456.     layout: 'vertical',
    
  1457.     overscanCount: 2,
    
  1458.     useIsScrolling: false
    
  1459.   }, _temp;
    
  1460. } // NOTE: I considered further wrapping individual items with a pure ListItem component.
    
  1461. // This would avoid ever calling the render function for the same index more than once,
    
  1462. // But it would also add the overhead of a lot of components/fibers.
    
  1463. // I assume people already do this (render function returning a class component),
    
  1464. // So my doing it would just unnecessarily double the wrappers.
    
  1465. 
    
  1466. var validateSharedProps$1 = function validateSharedProps(_ref2, _ref3) {
    
  1467.   var children = _ref2.children,
    
  1468.       direction = _ref2.direction,
    
  1469.       height = _ref2.height,
    
  1470.       layout = _ref2.layout,
    
  1471.       innerTagName = _ref2.innerTagName,
    
  1472.       outerTagName = _ref2.outerTagName,
    
  1473.       width = _ref2.width;
    
  1474.   var instance = _ref3.instance;
    
  1475. 
    
  1476.   if (process.env.NODE_ENV !== 'production') {
    
  1477.     if (innerTagName != null || outerTagName != null) {
    
  1478.       if (devWarningsTagName$1 && !devWarningsTagName$1.has(instance)) {
    
  1479.         devWarningsTagName$1.add(instance);
    
  1480.         console.warn('The innerTagName and outerTagName props have been deprecated. ' + 'Please use the innerElementType and outerElementType props instead.');
    
  1481.       }
    
  1482.     } // TODO Deprecate direction "horizontal"
    
  1483. 
    
  1484. 
    
  1485.     var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
    
  1486. 
    
  1487.     switch (direction) {
    
  1488.       case 'horizontal':
    
  1489.       case 'vertical':
    
  1490.         if (devWarningsDirection && !devWarningsDirection.has(instance)) {
    
  1491.           devWarningsDirection.add(instance);
    
  1492.           console.warn('The direction prop should be either "ltr" (default) or "rtl". ' + 'Please use the layout prop to specify "vertical" (default) or "horizontal" orientation.');
    
  1493.         }
    
  1494. 
    
  1495.         break;
    
  1496. 
    
  1497.       case 'ltr':
    
  1498.       case 'rtl':
    
  1499.         // Valid values
    
  1500.         break;
    
  1501. 
    
  1502.       default:
    
  1503.         throw Error('An invalid "direction" prop has been specified. ' + 'Value should be either "ltr" or "rtl". ' + ("\"" + direction + "\" was specified."));
    
  1504.     }
    
  1505. 
    
  1506.     switch (layout) {
    
  1507.       case 'horizontal':
    
  1508.       case 'vertical':
    
  1509.         // Valid values
    
  1510.         break;
    
  1511. 
    
  1512.       default:
    
  1513.         throw Error('An invalid "layout" prop has been specified. ' + 'Value should be either "horizontal" or "vertical". ' + ("\"" + layout + "\" was specified."));
    
  1514.     }
    
  1515. 
    
  1516.     if (children == null) {
    
  1517.       throw Error('An invalid "children" prop has been specified. ' + 'Value should be a React component. ' + ("\"" + (children === null ? 'null' : typeof children) + "\" was specified."));
    
  1518.     }
    
  1519. 
    
  1520.     if (isHorizontal && typeof width !== 'number') {
    
  1521.       throw Error('An invalid "width" prop has been specified. ' + 'Horizontal lists must specify a number for width. ' + ("\"" + (width === null ? 'null' : typeof width) + "\" was specified."));
    
  1522.     } else if (!isHorizontal && typeof height !== 'number') {
    
  1523.       throw Error('An invalid "height" prop has been specified. ' + 'Vertical lists must specify a number for height. ' + ("\"" + (height === null ? 'null' : typeof height) + "\" was specified."));
    
  1524.     }
    
  1525.   }
    
  1526. };
    
  1527. 
    
  1528. var DEFAULT_ESTIMATED_ITEM_SIZE$1 = 50;
    
  1529. 
    
  1530. var getItemMetadata$1 = function getItemMetadata(props, index, instanceProps) {
    
  1531.   var _ref = props,
    
  1532.       itemSize = _ref.itemSize;
    
  1533.   var itemMetadataMap = instanceProps.itemMetadataMap,
    
  1534.       lastMeasuredIndex = instanceProps.lastMeasuredIndex;
    
  1535. 
    
  1536.   if (index > lastMeasuredIndex) {
    
  1537.     var offset = 0;
    
  1538. 
    
  1539.     if (lastMeasuredIndex >= 0) {
    
  1540.       var itemMetadata = itemMetadataMap[lastMeasuredIndex];
    
  1541.       offset = itemMetadata.offset + itemMetadata.size;
    
  1542.     }
    
  1543. 
    
  1544.     for (var i = lastMeasuredIndex + 1; i <= index; i++) {
    
  1545.       var size = itemSize(i);
    
  1546.       itemMetadataMap[i] = {
    
  1547.         offset: offset,
    
  1548.         size: size
    
  1549.       };
    
  1550.       offset += size;
    
  1551.     }
    
  1552. 
    
  1553.     instanceProps.lastMeasuredIndex = index;
    
  1554.   }
    
  1555. 
    
  1556.   return itemMetadataMap[index];
    
  1557. };
    
  1558. 
    
  1559. var findNearestItem$1 = function findNearestItem(props, instanceProps, offset) {
    
  1560.   var itemMetadataMap = instanceProps.itemMetadataMap,
    
  1561.       lastMeasuredIndex = instanceProps.lastMeasuredIndex;
    
  1562.   var lastMeasuredItemOffset = lastMeasuredIndex > 0 ? itemMetadataMap[lastMeasuredIndex].offset : 0;
    
  1563. 
    
  1564.   if (lastMeasuredItemOffset >= offset) {
    
  1565.     // If we've already measured items within this range just use a binary search as it's faster.
    
  1566.     return findNearestItemBinarySearch$1(props, instanceProps, lastMeasuredIndex, 0, offset);
    
  1567.   } else {
    
  1568.     // If we haven't yet measured this high, fallback to an exponential search with an inner binary search.
    
  1569.     // The exponential search avoids pre-computing sizes for the full set of items as a binary search would.
    
  1570.     // The overall complexity for this approach is O(log n).
    
  1571.     return findNearestItemExponentialSearch$1(props, instanceProps, Math.max(0, lastMeasuredIndex), offset);
    
  1572.   }
    
  1573. };
    
  1574. 
    
  1575. var findNearestItemBinarySearch$1 = function findNearestItemBinarySearch(props, instanceProps, high, low, offset) {
    
  1576.   while (low <= high) {
    
  1577.     var middle = low + Math.floor((high - low) / 2);
    
  1578.     var currentOffset = getItemMetadata$1(props, middle, instanceProps).offset;
    
  1579. 
    
  1580.     if (currentOffset === offset) {
    
  1581.       return middle;
    
  1582.     } else if (currentOffset < offset) {
    
  1583.       low = middle + 1;
    
  1584.     } else if (currentOffset > offset) {
    
  1585.       high = middle - 1;
    
  1586.     }
    
  1587.   }
    
  1588. 
    
  1589.   if (low > 0) {
    
  1590.     return low - 1;
    
  1591.   } else {
    
  1592.     return 0;
    
  1593.   }
    
  1594. };
    
  1595. 
    
  1596. var findNearestItemExponentialSearch$1 = function findNearestItemExponentialSearch(props, instanceProps, index, offset) {
    
  1597.   var itemCount = props.itemCount;
    
  1598.   var interval = 1;
    
  1599. 
    
  1600.   while (index < itemCount && getItemMetadata$1(props, index, instanceProps).offset < offset) {
    
  1601.     index += interval;
    
  1602.     interval *= 2;
    
  1603.   }
    
  1604. 
    
  1605.   return findNearestItemBinarySearch$1(props, instanceProps, Math.min(index, itemCount - 1), Math.floor(index / 2), offset);
    
  1606. };
    
  1607. 
    
  1608. var getEstimatedTotalSize = function getEstimatedTotalSize(_ref2, _ref3) {
    
  1609.   var itemCount = _ref2.itemCount;
    
  1610.   var itemMetadataMap = _ref3.itemMetadataMap,
    
  1611.       estimatedItemSize = _ref3.estimatedItemSize,
    
  1612.       lastMeasuredIndex = _ref3.lastMeasuredIndex;
    
  1613.   var totalSizeOfMeasuredItems = 0; // Edge case check for when the number of items decreases while a scroll is in progress.
    
  1614.   // https://github.com/bvaughn/react-window/pull/138
    
  1615. 
    
  1616.   if (lastMeasuredIndex >= itemCount) {
    
  1617.     lastMeasuredIndex = itemCount - 1;
    
  1618.   }
    
  1619. 
    
  1620.   if (lastMeasuredIndex >= 0) {
    
  1621.     var itemMetadata = itemMetadataMap[lastMeasuredIndex];
    
  1622.     totalSizeOfMeasuredItems = itemMetadata.offset + itemMetadata.size;
    
  1623.   }
    
  1624. 
    
  1625.   var numUnmeasuredItems = itemCount - lastMeasuredIndex - 1;
    
  1626.   var totalSizeOfUnmeasuredItems = numUnmeasuredItems * estimatedItemSize;
    
  1627.   return totalSizeOfMeasuredItems + totalSizeOfUnmeasuredItems;
    
  1628. };
    
  1629. 
    
  1630. var VariableSizeList =
    
  1631. /*#__PURE__*/
    
  1632. createListComponent({
    
  1633.   getItemOffset: function getItemOffset(props, index, instanceProps) {
    
  1634.     return getItemMetadata$1(props, index, instanceProps).offset;
    
  1635.   },
    
  1636.   getItemSize: function getItemSize(props, index, instanceProps) {
    
  1637.     return instanceProps.itemMetadataMap[index].size;
    
  1638.   },
    
  1639.   getEstimatedTotalSize: getEstimatedTotalSize,
    
  1640.   getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(props, index, align, scrollOffset, instanceProps) {
    
  1641.     var direction = props.direction,
    
  1642.         height = props.height,
    
  1643.         layout = props.layout,
    
  1644.         width = props.width; // TODO Deprecate direction "horizontal"
    
  1645. 
    
  1646.     var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
    
  1647.     var size = isHorizontal ? width : height;
    
  1648.     var itemMetadata = getItemMetadata$1(props, index, instanceProps); // Get estimated total size after ItemMetadata is computed,
    
  1649.     // To ensure it reflects actual measurements instead of just estimates.
    
  1650. 
    
  1651.     var estimatedTotalSize = getEstimatedTotalSize(props, instanceProps);
    
  1652.     var maxOffset = Math.max(0, Math.min(estimatedTotalSize - size, itemMetadata.offset));
    
  1653.     var minOffset = Math.max(0, itemMetadata.offset - size + itemMetadata.size);
    
  1654. 
    
  1655.     if (align === 'smart') {
    
  1656.       if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
    
  1657.         align = 'auto';
    
  1658.       } else {
    
  1659.         align = 'center';
    
  1660.       }
    
  1661.     }
    
  1662. 
    
  1663.     switch (align) {
    
  1664.       case 'start':
    
  1665.         return maxOffset;
    
  1666. 
    
  1667.       case 'end':
    
  1668.         return minOffset;
    
  1669. 
    
  1670.       case 'center':
    
  1671.         return Math.round(minOffset + (maxOffset - minOffset) / 2);
    
  1672. 
    
  1673.       case 'auto':
    
  1674.       default:
    
  1675.         if (scrollOffset >= minOffset && scrollOffset <= maxOffset) {
    
  1676.           return scrollOffset;
    
  1677.         } else if (scrollOffset < minOffset) {
    
  1678.           return minOffset;
    
  1679.         } else {
    
  1680.           return maxOffset;
    
  1681.         }
    
  1682. 
    
  1683.     }
    
  1684.   },
    
  1685.   getStartIndexForOffset: function getStartIndexForOffset(props, offset, instanceProps) {
    
  1686.     return findNearestItem$1(props, instanceProps, offset);
    
  1687.   },
    
  1688.   getStopIndexForStartIndex: function getStopIndexForStartIndex(props, startIndex, scrollOffset, instanceProps) {
    
  1689.     var direction = props.direction,
    
  1690.         height = props.height,
    
  1691.         itemCount = props.itemCount,
    
  1692.         layout = props.layout,
    
  1693.         width = props.width; // TODO Deprecate direction "horizontal"
    
  1694. 
    
  1695.     var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
    
  1696.     var size = isHorizontal ? width : height;
    
  1697.     var itemMetadata = getItemMetadata$1(props, startIndex, instanceProps);
    
  1698.     var maxOffset = scrollOffset + size;
    
  1699.     var offset = itemMetadata.offset + itemMetadata.size;
    
  1700.     var stopIndex = startIndex;
    
  1701. 
    
  1702.     while (stopIndex < itemCount - 1 && offset < maxOffset) {
    
  1703.       stopIndex++;
    
  1704.       offset += getItemMetadata$1(props, stopIndex, instanceProps).size;
    
  1705.     }
    
  1706. 
    
  1707.     return stopIndex;
    
  1708.   },
    
  1709.   initInstanceProps: function initInstanceProps(props, instance) {
    
  1710.     var _ref4 = props,
    
  1711.         estimatedItemSize = _ref4.estimatedItemSize;
    
  1712.     var instanceProps = {
    
  1713.       itemMetadataMap: {},
    
  1714.       estimatedItemSize: estimatedItemSize || DEFAULT_ESTIMATED_ITEM_SIZE$1,
    
  1715.       lastMeasuredIndex: -1
    
  1716.     };
    
  1717. 
    
  1718.     instance.resetAfterIndex = function (index, shouldForceUpdate) {
    
  1719.       if (shouldForceUpdate === void 0) {
    
  1720.         shouldForceUpdate = true;
    
  1721.       }
    
  1722. 
    
  1723.       instanceProps.lastMeasuredIndex = Math.min(instanceProps.lastMeasuredIndex, index - 1); // We could potentially optimize further by only evicting styles after this index,
    
  1724.       // But since styles are only cached while scrolling is in progress-
    
  1725.       // It seems an unnecessary optimization.
    
  1726.       // It's unlikely that resetAfterIndex() will be called while a user is scrolling.
    
  1727. 
    
  1728.       instance._getItemStyleCache(-1);
    
  1729. 
    
  1730.       if (shouldForceUpdate) {
    
  1731.         instance.forceUpdate();
    
  1732.       }
    
  1733.     };
    
  1734. 
    
  1735.     return instanceProps;
    
  1736.   },
    
  1737.   shouldResetStyleCacheOnItemSizeChange: false,
    
  1738.   validateProps: function validateProps(_ref5) {
    
  1739.     var itemSize = _ref5.itemSize;
    
  1740. 
    
  1741.     if (process.env.NODE_ENV !== 'production') {
    
  1742.       if (typeof itemSize !== 'function') {
    
  1743.         throw Error('An invalid "itemSize" prop has been specified. ' + 'Value should be a function. ' + ("\"" + (itemSize === null ? 'null' : typeof itemSize) + "\" was specified."));
    
  1744.       }
    
  1745.     }
    
  1746.   }
    
  1747. });
    
  1748. 
    
  1749. var FixedSizeGrid =
    
  1750. /*#__PURE__*/
    
  1751. createGridComponent({
    
  1752.   getColumnOffset: function getColumnOffset(_ref, index) {
    
  1753.     var columnWidth = _ref.columnWidth;
    
  1754.     return index * columnWidth;
    
  1755.   },
    
  1756.   getColumnWidth: function getColumnWidth(_ref2, index) {
    
  1757.     var columnWidth = _ref2.columnWidth;
    
  1758.     return columnWidth;
    
  1759.   },
    
  1760.   getRowOffset: function getRowOffset(_ref3, index) {
    
  1761.     var rowHeight = _ref3.rowHeight;
    
  1762.     return index * rowHeight;
    
  1763.   },
    
  1764.   getRowHeight: function getRowHeight(_ref4, index) {
    
  1765.     var rowHeight = _ref4.rowHeight;
    
  1766.     return rowHeight;
    
  1767.   },
    
  1768.   getEstimatedTotalHeight: function getEstimatedTotalHeight(_ref5) {
    
  1769.     var rowCount = _ref5.rowCount,
    
  1770.         rowHeight = _ref5.rowHeight;
    
  1771.     return rowHeight * rowCount;
    
  1772.   },
    
  1773.   getEstimatedTotalWidth: function getEstimatedTotalWidth(_ref6) {
    
  1774.     var columnCount = _ref6.columnCount,
    
  1775.         columnWidth = _ref6.columnWidth;
    
  1776.     return columnWidth * columnCount;
    
  1777.   },
    
  1778.   getOffsetForColumnAndAlignment: function getOffsetForColumnAndAlignment(_ref7, columnIndex, align, scrollLeft, instanceProps, scrollbarSize) {
    
  1779.     var columnCount = _ref7.columnCount,
    
  1780.         columnWidth = _ref7.columnWidth,
    
  1781.         width = _ref7.width;
    
  1782.     var lastColumnOffset = Math.max(0, columnCount * columnWidth - width);
    
  1783.     var maxOffset = Math.min(lastColumnOffset, columnIndex * columnWidth);
    
  1784.     var minOffset = Math.max(0, columnIndex * columnWidth - width + scrollbarSize + columnWidth);
    
  1785. 
    
  1786.     if (align === 'smart') {
    
  1787.       if (scrollLeft >= minOffset - width && scrollLeft <= maxOffset + width) {
    
  1788.         align = 'auto';
    
  1789.       } else {
    
  1790.         align = 'center';
    
  1791.       }
    
  1792.     }
    
  1793. 
    
  1794.     switch (align) {
    
  1795.       case 'start':
    
  1796.         return maxOffset;
    
  1797. 
    
  1798.       case 'end':
    
  1799.         return minOffset;
    
  1800. 
    
  1801.       case 'center':
    
  1802.         // "Centered" offset is usually the average of the min and max.
    
  1803.         // But near the edges of the list, this doesn't hold true.
    
  1804.         var middleOffset = Math.round(minOffset + (maxOffset - minOffset) / 2);
    
  1805. 
    
  1806.         if (middleOffset < Math.ceil(width / 2)) {
    
  1807.           return 0; // near the beginning
    
  1808.         } else if (middleOffset > lastColumnOffset + Math.floor(width / 2)) {
    
  1809.           return lastColumnOffset; // near the end
    
  1810.         } else {
    
  1811.           return middleOffset;
    
  1812.         }
    
  1813. 
    
  1814.       case 'auto':
    
  1815.       default:
    
  1816.         if (scrollLeft >= minOffset && scrollLeft <= maxOffset) {
    
  1817.           return scrollLeft;
    
  1818.         } else if (minOffset > maxOffset) {
    
  1819.           // Because we only take into account the scrollbar size when calculating minOffset
    
  1820.           // this value can be larger than maxOffset when at the end of the list
    
  1821.           return minOffset;
    
  1822.         } else if (scrollLeft < minOffset) {
    
  1823.           return minOffset;
    
  1824.         } else {
    
  1825.           return maxOffset;
    
  1826.         }
    
  1827. 
    
  1828.     }
    
  1829.   },
    
  1830.   getOffsetForRowAndAlignment: function getOffsetForRowAndAlignment(_ref8, rowIndex, align, scrollTop, instanceProps, scrollbarSize) {
    
  1831.     var rowHeight = _ref8.rowHeight,
    
  1832.         height = _ref8.height,
    
  1833.         rowCount = _ref8.rowCount;
    
  1834.     var lastRowOffset = Math.max(0, rowCount * rowHeight - height);
    
  1835.     var maxOffset = Math.min(lastRowOffset, rowIndex * rowHeight);
    
  1836.     var minOffset = Math.max(0, rowIndex * rowHeight - height + scrollbarSize + rowHeight);
    
  1837. 
    
  1838.     if (align === 'smart') {
    
  1839.       if (scrollTop >= minOffset - height && scrollTop <= maxOffset + height) {
    
  1840.         align = 'auto';
    
  1841.       } else {
    
  1842.         align = 'center';
    
  1843.       }
    
  1844.     }
    
  1845. 
    
  1846.     switch (align) {
    
  1847.       case 'start':
    
  1848.         return maxOffset;
    
  1849. 
    
  1850.       case 'end':
    
  1851.         return minOffset;
    
  1852. 
    
  1853.       case 'center':
    
  1854.         // "Centered" offset is usually the average of the min and max.
    
  1855.         // But near the edges of the list, this doesn't hold true.
    
  1856.         var middleOffset = Math.round(minOffset + (maxOffset - minOffset) / 2);
    
  1857. 
    
  1858.         if (middleOffset < Math.ceil(height / 2)) {
    
  1859.           return 0; // near the beginning
    
  1860.         } else if (middleOffset > lastRowOffset + Math.floor(height / 2)) {
    
  1861.           return lastRowOffset; // near the end
    
  1862.         } else {
    
  1863.           return middleOffset;
    
  1864.         }
    
  1865. 
    
  1866.       case 'auto':
    
  1867.       default:
    
  1868.         if (scrollTop >= minOffset && scrollTop <= maxOffset) {
    
  1869.           return scrollTop;
    
  1870.         } else if (minOffset > maxOffset) {
    
  1871.           // Because we only take into account the scrollbar size when calculating minOffset
    
  1872.           // this value can be larger than maxOffset when at the end of the list
    
  1873.           return minOffset;
    
  1874.         } else if (scrollTop < minOffset) {
    
  1875.           return minOffset;
    
  1876.         } else {
    
  1877.           return maxOffset;
    
  1878.         }
    
  1879. 
    
  1880.     }
    
  1881.   },
    
  1882.   getColumnStartIndexForOffset: function getColumnStartIndexForOffset(_ref9, scrollLeft) {
    
  1883.     var columnWidth = _ref9.columnWidth,
    
  1884.         columnCount = _ref9.columnCount;
    
  1885.     return Math.max(0, Math.min(columnCount - 1, Math.floor(scrollLeft / columnWidth)));
    
  1886.   },
    
  1887.   getColumnStopIndexForStartIndex: function getColumnStopIndexForStartIndex(_ref10, startIndex, scrollLeft) {
    
  1888.     var columnWidth = _ref10.columnWidth,
    
  1889.         columnCount = _ref10.columnCount,
    
  1890.         width = _ref10.width;
    
  1891.     var left = startIndex * columnWidth;
    
  1892.     var numVisibleColumns = Math.ceil((width + scrollLeft - left) / columnWidth);
    
  1893.     return Math.max(0, Math.min(columnCount - 1, startIndex + numVisibleColumns - 1 // -1 is because stop index is inclusive
    
  1894.     ));
    
  1895.   },
    
  1896.   getRowStartIndexForOffset: function getRowStartIndexForOffset(_ref11, scrollTop) {
    
  1897.     var rowHeight = _ref11.rowHeight,
    
  1898.         rowCount = _ref11.rowCount;
    
  1899.     return Math.max(0, Math.min(rowCount - 1, Math.floor(scrollTop / rowHeight)));
    
  1900.   },
    
  1901.   getRowStopIndexForStartIndex: function getRowStopIndexForStartIndex(_ref12, startIndex, scrollTop) {
    
  1902.     var rowHeight = _ref12.rowHeight,
    
  1903.         rowCount = _ref12.rowCount,
    
  1904.         height = _ref12.height;
    
  1905.     var top = startIndex * rowHeight;
    
  1906.     var numVisibleRows = Math.ceil((height + scrollTop - top) / rowHeight);
    
  1907.     return Math.max(0, Math.min(rowCount - 1, startIndex + numVisibleRows - 1 // -1 is because stop index is inclusive
    
  1908.     ));
    
  1909.   },
    
  1910.   initInstanceProps: function initInstanceProps(props) {// Noop
    
  1911.   },
    
  1912.   shouldResetStyleCacheOnItemSizeChange: true,
    
  1913.   validateProps: function validateProps(_ref13) {
    
  1914.     var columnWidth = _ref13.columnWidth,
    
  1915.         rowHeight = _ref13.rowHeight;
    
  1916. 
    
  1917.     if (process.env.NODE_ENV !== 'production') {
    
  1918.       if (typeof columnWidth !== 'number') {
    
  1919.         throw Error('An invalid "columnWidth" prop has been specified. ' + 'Value should be a number. ' + ("\"" + (columnWidth === null ? 'null' : typeof columnWidth) + "\" was specified."));
    
  1920.       }
    
  1921. 
    
  1922.       if (typeof rowHeight !== 'number') {
    
  1923.         throw Error('An invalid "rowHeight" prop has been specified. ' + 'Value should be a number. ' + ("\"" + (rowHeight === null ? 'null' : typeof rowHeight) + "\" was specified."));
    
  1924.       }
    
  1925.     }
    
  1926.   }
    
  1927. });
    
  1928. 
    
  1929. var FixedSizeList =
    
  1930. /*#__PURE__*/
    
  1931. createListComponent({
    
  1932.   getItemOffset: function getItemOffset(_ref, index) {
    
  1933.     var itemSize = _ref.itemSize;
    
  1934.     return index * itemSize;
    
  1935.   },
    
  1936.   getItemSize: function getItemSize(_ref2, index) {
    
  1937.     var itemSize = _ref2.itemSize;
    
  1938.     return itemSize;
    
  1939.   },
    
  1940.   getEstimatedTotalSize: function getEstimatedTotalSize(_ref3) {
    
  1941.     var itemCount = _ref3.itemCount,
    
  1942.         itemSize = _ref3.itemSize;
    
  1943.     return itemSize * itemCount;
    
  1944.   },
    
  1945.   getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(_ref4, index, align, scrollOffset) {
    
  1946.     var direction = _ref4.direction,
    
  1947.         height = _ref4.height,
    
  1948.         itemCount = _ref4.itemCount,
    
  1949.         itemSize = _ref4.itemSize,
    
  1950.         layout = _ref4.layout,
    
  1951.         width = _ref4.width;
    
  1952.     // TODO Deprecate direction "horizontal"
    
  1953.     var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
    
  1954.     var size = isHorizontal ? width : height;
    
  1955.     var lastItemOffset = Math.max(0, itemCount * itemSize - size);
    
  1956.     var maxOffset = Math.min(lastItemOffset, index * itemSize);
    
  1957.     var minOffset = Math.max(0, index * itemSize - size + itemSize);
    
  1958. 
    
  1959.     if (align === 'smart') {
    
  1960.       if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
    
  1961.         align = 'auto';
    
  1962.       } else {
    
  1963.         align = 'center';
    
  1964.       }
    
  1965.     }
    
  1966. 
    
  1967.     switch (align) {
    
  1968.       case 'start':
    
  1969.         return maxOffset;
    
  1970. 
    
  1971.       case 'end':
    
  1972.         return minOffset;
    
  1973. 
    
  1974.       case 'center':
    
  1975.         {
    
  1976.           // "Centered" offset is usually the average of the min and max.
    
  1977.           // But near the edges of the list, this doesn't hold true.
    
  1978.           var middleOffset = Math.round(minOffset + (maxOffset - minOffset) / 2);
    
  1979. 
    
  1980.           if (middleOffset < Math.ceil(size / 2)) {
    
  1981.             return 0; // near the beginning
    
  1982.           } else if (middleOffset > lastItemOffset + Math.floor(size / 2)) {
    
  1983.             return lastItemOffset; // near the end
    
  1984.           } else {
    
  1985.             return middleOffset;
    
  1986.           }
    
  1987.         }
    
  1988. 
    
  1989.       case 'auto':
    
  1990.       default:
    
  1991.         if (scrollOffset >= minOffset && scrollOffset <= maxOffset) {
    
  1992.           return scrollOffset;
    
  1993.         } else if (scrollOffset < minOffset) {
    
  1994.           return minOffset;
    
  1995.         } else {
    
  1996.           return maxOffset;
    
  1997.         }
    
  1998. 
    
  1999.     }
    
  2000.   },
    
  2001.   getStartIndexForOffset: function getStartIndexForOffset(_ref5, offset) {
    
  2002.     var itemCount = _ref5.itemCount,
    
  2003.         itemSize = _ref5.itemSize;
    
  2004.     return Math.max(0, Math.min(itemCount - 1, Math.floor(offset / itemSize)));
    
  2005.   },
    
  2006.   getStopIndexForStartIndex: function getStopIndexForStartIndex(_ref6, startIndex, scrollOffset) {
    
  2007.     var direction = _ref6.direction,
    
  2008.         height = _ref6.height,
    
  2009.         itemCount = _ref6.itemCount,
    
  2010.         itemSize = _ref6.itemSize,
    
  2011.         layout = _ref6.layout,
    
  2012.         width = _ref6.width;
    
  2013.     // TODO Deprecate direction "horizontal"
    
  2014.     var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
    
  2015.     var offset = startIndex * itemSize;
    
  2016.     var size = isHorizontal ? width : height;
    
  2017.     var numVisibleItems = Math.ceil((size + scrollOffset - offset) / itemSize);
    
  2018.     return Math.max(0, Math.min(itemCount - 1, startIndex + numVisibleItems - 1 // -1 is because stop index is inclusive
    
  2019.     ));
    
  2020.   },
    
  2021.   initInstanceProps: function initInstanceProps(props) {// Noop
    
  2022.   },
    
  2023.   shouldResetStyleCacheOnItemSizeChange: true,
    
  2024.   validateProps: function validateProps(_ref7) {
    
  2025.     var itemSize = _ref7.itemSize;
    
  2026. 
    
  2027.     if (process.env.NODE_ENV !== 'production') {
    
  2028.       if (typeof itemSize !== 'number') {
    
  2029.         throw Error('An invalid "itemSize" prop has been specified. ' + 'Value should be a number. ' + ("\"" + (itemSize === null ? 'null' : typeof itemSize) + "\" was specified."));
    
  2030.       }
    
  2031.     }
    
  2032.   }
    
  2033. });
    
  2034. 
    
  2035. // Pulled from react-compat
    
  2036. // https://github.com/developit/preact-compat/blob/7c5de00e7c85e2ffd011bf3af02899b63f699d3a/src/index.js#L349
    
  2037. function shallowDiffers(prev, next) {
    
  2038.   for (var attribute in prev) {
    
  2039.     if (!(attribute in next)) {
    
  2040.       return true;
    
  2041.     }
    
  2042.   }
    
  2043. 
    
  2044.   for (var _attribute in next) {
    
  2045.     if (prev[_attribute] !== next[_attribute]) {
    
  2046.       return true;
    
  2047.     }
    
  2048.   }
    
  2049. 
    
  2050.   return false;
    
  2051. }
    
  2052. 
    
  2053. // It knows to compare individual style props and ignore the wrapper object.
    
  2054. // See https://reactjs.org/docs/react-api.html#reactmemo
    
  2055. 
    
  2056. function areEqual(prevProps, nextProps) {
    
  2057.   var prevStyle = prevProps.style,
    
  2058.       prevRest = _objectWithoutPropertiesLoose(prevProps, ["style"]);
    
  2059. 
    
  2060.   var nextStyle = nextProps.style,
    
  2061.       nextRest = _objectWithoutPropertiesLoose(nextProps, ["style"]);
    
  2062. 
    
  2063.   return !shallowDiffers(prevStyle, nextStyle) && !shallowDiffers(prevRest, nextRest);
    
  2064. }
    
  2065. 
    
  2066. // It knows to compare individual style props and ignore the wrapper object.
    
  2067. // See https://reactjs.org/docs/react-component.html#shouldcomponentupdate
    
  2068. 
    
  2069. function shouldComponentUpdate(nextProps, nextState) {
    
  2070.   return !areEqual(this.props, nextProps) || shallowDiffers(this.state, nextState);
    
  2071. }
    
  2072. 
    
  2073. exports.VariableSizeGrid = VariableSizeGrid;
    
  2074. exports.VariableSizeList = VariableSizeList;
    
  2075. exports.FixedSizeGrid = FixedSizeGrid;
    
  2076. exports.FixedSizeList = FixedSizeList;
    
  2077. exports.areEqual = areEqual;
    
  2078. exports.shouldComponentUpdate = shouldComponentUpdate;
    
  2079. //# sourceMappingURL=index.cjs.js.map