"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "ViewportRowsCalculator", {
    enumerable: true,
    get: function() {
        return ViewportRowsCalculator;
    }
});
const _axisCalculation = require("./axisCalculation");
const _viewportBase = require("./viewportBase");
class ViewportRowsCalculator extends _viewportBase.ViewportBaseCalculator {
    /**
   * Calculates viewport.
   */ calculate() {
        (0, _axisCalculation.calculateAxis)(this, {
            totalCount: this.totalRows,
            zeroBasedScrollOffset: this.zeroBasedScrollOffset,
            scrollEnd: this.innerViewportHeight,
            positionCache: this.positionCache,
            setSizeField: (ctx, size)=>{
                ctx.rowHeight = size;
            },
            setTotalCalculated: (ctx, v)=>{
                ctx.totalCalculatedHeight = v;
            },
            getTotalCalculated: (ctx)=>ctx.totalCalculatedHeight
        });
    }
    /**
   * Gets the row height at the specified row index.
   *
   * @param {number} row Row index.
   * @returns {number}
   */ getRowHeight(row) {
        return this.positionCache.getSizeAt(row);
    }
    /**
   * @param {ViewportRowsCalculatorOptions} options Object with all options specified for row viewport calculation.
   */ constructor({ calculationTypes, viewportHeight, scrollOffset, totalRows, overrideFn, horizontalScrollbarHeight, rowHeightCache }){
        super(calculationTypes), this.viewportHeight = 0, this.scrollOffset = 0, this.zeroBasedScrollOffset = 0, this.totalRows = 0, this.rowHeight = 0, this.overrideFn = null, this.horizontalScrollbarHeight = 0, this.innerViewportHeight = 0, this.totalCalculatedHeight = 0, this.needReverse = true;
        this.viewportHeight = viewportHeight;
        this.scrollOffset = scrollOffset;
        this.zeroBasedScrollOffset = Math.max(scrollOffset, 0);
        this.totalRows = totalRows;
        this.overrideFn = overrideFn;
        this.horizontalScrollbarHeight = horizontalScrollbarHeight ?? 0;
        this.innerViewportHeight = this.zeroBasedScrollOffset + this.viewportHeight - this.horizontalScrollbarHeight;
        this.positionCache = rowHeightCache;
        this.calculate();
    }
}
