"use strict";

exports.__esModule = true;
exports.command = void 0;
var command = {
  name: 'extendCellsSelectionDownByViewportHeight',
  callback: function callback(hot) {
    var _hot$getSelectedRange = hot.getSelectedRangeLast(),
      to = _hot$getSelectedRange.to;
    var nextRowIndexToSelect = Math.min(to.row + hot.countVisibleRows(), hot.countRows() - 1);
    var row = hot.rowIndexMapper.getNearestNotHiddenIndex(nextRowIndexToSelect, -1);
    if (row !== null) {
      var coords = hot._createCellCoords(row, to.col);
      var scrollPadding = to.row - hot.view.getFirstFullyVisibleRow();
      var nextVerticalScroll = Math.min(coords.row - scrollPadding, hot.countRows() - 1);
      hot.selection.setRangeEnd(coords);
      hot.scrollViewportTo(nextVerticalScroll);
    }
  }
};
exports.command = command;