"use strict";
var lodash_1 = require("lodash");
var rxjs_1 = require("rxjs");
exports.defaultPageSize = 10;
var DataPager = (function () {
    function DataPager() {
        this._pageNumber = new rxjs_1.BehaviorSubject(1);
        this._pageSize = new rxjs_1.BehaviorSubject(exports.defaultPageSize);
    }
    DataPager.prototype.setPage = function (page) {
        this._pageNumber.next(page);
    };
    DataPager.prototype.setPageSize = function (size) {
        this._pageSize.next(size);
    };
    Object.defineProperty(DataPager.prototype, "pageNumber$", {
        get: function () {
            return this._pageNumber.asObservable();
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(DataPager.prototype, "pageSize$", {
        get: function () {
            return this._pageSize.asObservable();
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(DataPager.prototype, "startItem$", {
        get: function () {
            return this.pageNumber$.combineLatest(this.pageSize$)
                .map(function (_a) {
                var pageNumber = _a[0], pageSize = _a[1];
                return (pageNumber - 1) * pageSize;
            });
        },
        enumerable: true,
        configurable: true
    });
    DataPager.prototype.filter = function (dataSet$) {
        return dataSet$.combineLatest(this.startItem$, this.pageSize$)
            .map(function (_a) {
            var dataSet = _a[0], startItem = _a[1], pageSize = _a[2];
            return lodash_1.take(lodash_1.drop(dataSet, startItem), pageSize);
        });
    };
    return DataPager;
}());
exports.DataPager = DataPager;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0YVBhZ2VyLnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJkYXRhUGFnZXIuc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsaUNBQW9DO0FBQ3BDLDZCQUFtRDtBQUV0QyxRQUFBLGVBQWUsR0FBVyxFQUFFLENBQUM7QUFZMUM7SUFJQztRQUNDLElBQUksQ0FBQyxXQUFXLEdBQUcsSUFBSSxzQkFBZSxDQUFTLENBQUMsQ0FBQyxDQUFDO1FBQ2xELElBQUksQ0FBQyxTQUFTLEdB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