/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import * as tslib_1 from "tslib";
import { BaseDataSource } from "./BaseDataSource";
import { Base, typeCast, Array_$type, Number_$type, fromEnum, markType } from "./type";
import { RearrangedListView } from "./RearrangedListView";
import { DataSourcePropertiesComparer } from "./DataSourcePropertiesComparer";
import { List$1 } from "./List$1";
import { DataSourceExecutionContext } from "./DataSourceExecutionContext";
import { DataSourceLocalDataProvider } from "./DataSourceLocalDataProvider";
import { DataSourceSpecialRow } from "./DataSourceSpecialRow";
import { ISupportsDataChangeNotifications_$type } from "./ISupportsDataChangeNotifications";
import { TransactionType, TransactionType_$type } from "./TransactionType";
import { ISupportsExpansionChangeNotifications_$type } from "./ISupportsExpansionChangeNotifications";
/**
 * @hidden
 */
var LocalDataSource = /** @class */ (function (_super) {
    tslib_1.__extends(LocalDataSource, _super);
    function LocalDataSource() {
        var _this = _super.call(this) || this;
        _this.cq = null;
        _this.cp = null;
        _this.dq = null;
        _this.cv = null;
        _this.cz = null;
        _this.c1 = null;
        _this.cx = null;
        _this.db = new List$1(Array_$type, 0);
        _this.c2 = false;
        _this.co = null;
        _this.dj = -1;
        _this.dc = -1;
        _this.dl = -1;
        _this.de = -1;
        _this.dm = -1;
        _this.df = -1;
        _this.dk = -1;
        _this.dd = -1;
        _this.dp = -1;
        _this.dn = -1;
        _this.dh = -1;
        _this.dg = -1;
        _this.di = -1;
        _this.executionContext = new DataSourceExecutionContext();
        _this.t.l = false;
        return _this;
    }
    LocalDataSource.prototype.get_actualBaseDataProvider = function () {
        return this.actualDataProvider;
    };
    Object.defineProperty(LocalDataSource.prototype, "actualBaseDataProvider", {
        get: function () {
            return this.get_actualBaseDataProvider();
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LocalDataSource.prototype, "dataProvider", {
        get: function () {
            return this.cq;
        },
        set: function (a) {
            var b = this.cq;
            this.cq = a;
            if (b != this.cq) {
                this.onPropertyUpdated("DataProvider", b, this.cq);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LocalDataSource.prototype, "actualDataProvider", {
        get: function () {
            if (this.cp == null) {
                this.actualDataProvider = this.resolveDataProvider();
            }
            return this.cp;
        },
        set: function (a) {
            var b = this.cp;
            this.cp = a;
            if (b != this.cp) {
                this.onPropertyUpdated("ActualDataProvider", b, this.cp);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(LocalDataSource.prototype, "dataSource", {
        get: function () {
            return this.dq;
        },
        set: function (a) {
            var b = this.dq;
            this.dq = a;
            if (b != this.dq) {
                this.onPropertyUpdated("ItemsSource", b, this.dq);
            }
        },
        enumerable: true,
        configurable: true
    });
    LocalDataSource.prototype.canInitialize = function () {
        var a = _super.prototype.canInitialize.call(this);
        if (!a) {
            return false;
        }
        return this.dataSource != null;
    };
    Object.defineProperty(LocalDataSource.prototype, "cw", {
        get: function () {
            return this.cv;
        },
        set: function (a) {
            this.cv = a;
            this.actualDataProvider = this.resolveDataProvider();
        },
        enumerable: true,
        configurable: true
    });
    LocalDataSource.prototype.resolveDataProvider = function () {
        var provider_ = new DataSourceLocalDataProvider();
        provider_.executionContext = new DataSourceExecutionContext();
        return provider_;
    };
    LocalDataSource.prototype.propertyUpdatedOverride = function (a, b, c) {
        _super.prototype.propertyUpdatedOverride.call(this, a, b, c);
        switch (a) {
            case "DataProvider":
                this.actualDataProvider = this.dataProvider;
                break;
            case "ActualDataProvider":
                if (this.actualDataProvider != null) {
                    this.actualDataProvider.dataSource = this.dataSource;
                    this.actualSchema = this.actualDataProvider.actualSchema;
                    this.actualCount = this.resolveFullCount(this.actualDataProvider.actualCount);
                }
                this.queueAutoRefresh();
                break;
            case "ItemsSource":
                if (this.actualDataProvider != null) {
                    this.actualDataProvider.dataSource = this.dataSource;
                    this.actualSchema = this.actualDataProvider.actualSchema;
                    this.actualCount = this.resolveFullCount(this.actualDataProvider.actualCount);
                }
                this.queueAutoRefresh();
                break;
        }
    };
    LocalDataSource.prototype.getItemAtIndex = function (a) {
        if (this.cz != null && this.cz.a6 != null) {
            return this.cz.a6.item(a);
        }
        else {
            return this.actualDataProvider.getItemAtIndex(a);
        }
    };
    LocalDataSource.prototype.getItemPropertyAtIndex = function (a, b) {
        var c;
        if (this.cz != null) {
            c = this.cz.a6.item(a);
        }
        else {
            c = this.actualDataProvider.getItemAtIndex(a);
        }
        var item_ = c;
        if ((item_ != null && item_.$$isSpecialRow !== undefined)) {
            return this.getSpecialRowItemValue(c, b);
        }
        if (this.an()) {
            var d = this.aw(c, b);
            if (d != null) {
                return d;
            }
        }
        return this.actualDataProvider.getItemValue(c, b);
    };
    LocalDataSource.prototype.cu = function () {
        return this.actualDataProvider;
    };
    LocalDataSource.prototype.c4 = function () {
        return this.db != null && this.db.count > 0;
    };
    LocalDataSource.prototype.refreshInternalOverride = function () {
        _super.prototype.refreshInternalOverride.call(this);
        if (this.actualDataProvider != null) {
            if (this.c5() || this.c6() || this.c7() || this.c8() || this.c4()) {
                if (this.cz == null) {
                    if (this.c1 == null) {
                        this.c1 = new LocalDataSourceViewUpdateNotifier(this);
                    }
                    this.cz = new RearrangedListView(this.actualDataProvider);
                    this.cz.ab = this.c1;
                    this.cz.ad = new LocalDataSourceViewExpansionNotifier(this);
                }
                this.ensureComparables(this.actualDataProvider.actualSchema);
                this.cz.av = this.shouldEmitSectionHeaders && this.am;
                this.cz.au = this.shouldEmitSectionFooters && this.am;
                this.cz.aw = this.shouldEmitShiftedRows;
                this.cz.cb(this.db);
                this.cz.a2 = this.da();
                this.cz.a1 = this.c9();
                this.cz.p = this.cy();
                this.cz.ae = this.groupDescriptions;
                this.cz.af = this.sortDescriptions;
                this.cz.ag = this.summaryDescriptions;
                this.cz.l = this.summaryScope;
                this.cz.am = this.includeSummaryRowsInSection;
                this.cz.as = this.isSectionSummaryRowsAtBottom;
                this.cz.j = this.sectionHeaderDisplayMode;
                this.cz.m = this;
                this.cz.ap = this.groupDescriptions != null && this.groupDescriptions.k.count > 0;
                this.cz.t = this.c0();
                this.cz.b6();
                this.actualSchema = this.actualDataProvider.actualSchema;
                this.actualCount = this.cz.a6.count;
            }
            else {
                var a = this.cu();
                this.actualSchema = this.actualDataProvider.actualSchema;
                if (a != null) {
                    this.actualCount = a.actualCount;
                }
                else {
                    this.actualCount = 0;
                }
                if (this.cz != null) {
                    this.cz.ab = null;
                    this.cz = null;
                    this.onBroadcastClearItems();
                }
            }
        }
        else {
            this.actualCount = 0;
            this.actualSchema = null;
        }
    };
    LocalDataSource.prototype.get_isItemIndexLookupSupported = function () {
        return true;
    };
    LocalDataSource.prototype.get_isKeyIndexLookupSupported = function () {
        return true;
    };
    LocalDataSource.prototype.indexOfItem = function (a) {
        if (this.cz != null) {
            return this.cz.a6.indexOf(a);
        }
        if (this.actualDataProvider != null && this.actualDataProvider.isItemIndexLookupSupported) {
            return this.actualDataProvider.indexOfItem(a);
        }
        if (this.actualDataProvider != null) {
            var b = this.actualDataProvider.actualCount;
            var c = void 0;
            for (var d = 0; d < b; d++) {
                c = this.actualDataProvider.getItemAtIndex(d);
                if (this.c3(c, a)) {
                    return d;
                }
            }
        }
        return -1;
    };
    LocalDataSource.prototype.c3 = function (a, b) {
        if (a == null && b == null) {
            return true;
        }
        if (a == null || b == null) {
            return false;
        }
        return Base.equalsStatic(a, b);
    };
    LocalDataSource.prototype.indexOfKey = function (a) {
        var b = this.actualPrimaryKey;
        if (b == null || b.length < 1 || this.actualBaseDataProvider == null) {
            return this.indexOfItem(a[0]);
        }
        var c = this.cy();
        var d;
        if (this.cz != null) {
            var e = this.cz.a6.count;
            for (var f = 0; f < e; f++) {
                d = this.cz.a6.item(f);
                if (typeCast(DataSourceSpecialRow.$, d) !== null) {
                    var g = d;
                    if (g.rowType == 1 && !this.isSectionContentVisible && this.isSectionHeaderNormalRow) {
                        if (c.i(d, a) == 0) {
                            return f;
                        }
                    }
                }
                else if (c.i(d, a) == 0) {
                    return f;
                }
            }
            return -1;
        }
        if (this.actualDataProvider != null && this.actualDataProvider.isKeyIndexLookupSupported) {
            return this.actualDataProvider.indexOfKey(a);
        }
        if (this.actualDataProvider != null) {
            var h = this.actualDataProvider.actualCount;
            for (var i = 0; i < h; i++) {
                d = this.actualDataProvider.getItemAtIndex(i);
                if (c.i(d, a) == 0) {
                    return i;
                }
            }
        }
        return -1;
    };
    LocalDataSource.prototype.onActualPrimaryKeyChangedOverrride = function (a, b) {
        _super.prototype.onActualPrimaryKeyChangedOverrride.call(this, a, b);
        this.cx = null;
    };
    LocalDataSource.prototype.cy = function () {
        if (this.cx != null) {
            return this.cx;
        }
        if (this.actualPrimaryKey == null) {
            this.cx = new DataSourcePropertiesComparer(null, null, null, this);
            return this.cx;
        }
        var a = new Array(this.actualPrimaryKey.length);
        for (var b = 0; b < a.length; b++) {
            a[b] = 0;
        }
        this.cx = new DataSourcePropertiesComparer(this.actualPrimaryKey, a, this.d, this);
        return this.cx;
    };
    LocalDataSource.prototype.c0 = function () {
        if (this.filterExpressions.j.count == 0) {
            return null;
        }
        var a = this.actualDataProvider;
        var b = this.actualDataProvider.actualSchema;
        var c = this.filterExpressions.j;
        var d = function (e) {
            for (var f = 0; f < c.count; f++) {
                if (!c.item(f).match(e, a, b)) {
                    return false;
                }
            }
            return true;
        };
        return d;
    };
    LocalDataSource.prototype.da = function () {
        var a = 0;
        if (this.sortDescriptions.k.count == 0 && (this.groupDescriptions == null || this.groupDescriptions.k.count == 0)) {
            return null;
        }
        a = this.sortDescriptions.k.count;
        if (this.groupDescriptions != null) {
            a += this.groupDescriptions.k.count;
        }
        var b = new Array(a);
        var c = new Array(a);
        var d = 0;
        if (this.groupDescriptions != null) {
            for (var e = 0; e < this.groupDescriptions.k.count; e++) {
                b[e] = this.groupDescriptions.k.item(e).propertyName;
                c[e] = this.groupDescriptions.k.item(e).direction;
                d++;
            }
        }
        for (var f = 0; f < this.sortDescriptions.k.count; f++) {
            b[f + d] = this.sortDescriptions.k.item(f).propertyName;
            c[f + d] = this.sortDescriptions.k.item(f).direction;
        }
        return new DataSourcePropertiesComparer(b, c, this.d, this);
    };
    LocalDataSource.prototype.c9 = function () {
        if (this.groupDescriptions == null || this.groupDescriptions.k.count < 1) {
            return null;
        }
        var a = 0;
        a = this.groupDescriptions.k.count;
        var b = new Array(a);
        var c = new Array(a);
        if (this.groupDescriptions != null) {
            for (var d = 0; d < this.groupDescriptions.k.count; d++) {
                b[d] = this.groupDescriptions.k.item(d).propertyName;
                c[d] = this.groupDescriptions.k.item(d).direction;
            }
        }
        return new DataSourcePropertiesComparer(b, c, this.d, this);
    };
    LocalDataSource.prototype.c6 = function () {
        if (this.groupDescriptions == null || this.groupDescriptions.k.count < 1) {
            return false;
        }
        if (this.actualDataProvider == null) {
            return false;
        }
        if (this.actualDataProvider.isGroupingSupported) {
            return false;
        }
        return true;
    };
    LocalDataSource.prototype.c7 = function () {
        if (this.sortDescriptions == null || this.sortDescriptions.k.count < 1) {
            return false;
        }
        if (this.actualDataProvider == null) {
            return false;
        }
        if (this.actualDataProvider.isSortingSupported) {
            return false;
        }
        return true;
    };
    LocalDataSource.prototype.c5 = function () {
        return this.filterExpressions != null && this.filterExpressions.j.count > 0;
    };
    LocalDataSource.prototype.c8 = function () {
        if (this.summaryDescriptions == null || this.summaryDescriptions.k.count < 1) {
            return false;
        }
        return true;
    };
    LocalDataSource.prototype.onClearItemsOverride = function () {
        if (this.cz != null) {
            this.cz.notifyClearItems();
            this.queueAutoRefresh();
        }
        else {
            _super.prototype.onClearItemsOverride.call(this);
        }
    };
    LocalDataSource.prototype.onSetItemOverride = function (a, b, c) {
        if (this.cz != null) {
            this.cz.notifySetItem(a, b, c);
        }
        else {
            _super.prototype.onSetItemOverride.call(this, a, b, c);
        }
    };
    LocalDataSource.prototype.onInsertItemOverride = function (a, b) {
        if (this.cz != null) {
            this.cz.notifyInsertItem(a, b);
        }
        else {
            _super.prototype.onInsertItemOverride.call(this, a, b);
        }
    };
    LocalDataSource.prototype.onRemoveItemOverride = function (a, b) {
        if (this.cz != null) {
            this.cz.notifyRemoveItem(a, b);
        }
        else {
            _super.prototype.onRemoveItemOverride.call(this, a, b);
        }
    };
    LocalDataSource.prototype.dv = function () {
        this.actualCount = this.cz.a6.count;
        this.onBroadcastClearItems();
    };
    LocalDataSource.prototype.dy = function (a, b, c) {
        this.actualCount = this.cz.a6.count;
        this.onBroadcastSetItem(a, b, c);
    };
    LocalDataSource.prototype.dw = function (a, b) {
        this.actualCount = this.cz.a6.count;
        this.onBroadcastInsertItem(a, b);
    };
    LocalDataSource.prototype.dx = function (a, b) {
        this.actualCount = this.cz.a6.count;
        this.onBroadcastRemoveItem(a, b);
    };
    LocalDataSource.prototype.pinRow = function (a) {
        _super.prototype.pinRow.call(this, a);
        this.dj = -1;
        this.dc = -1;
        if (this.cz != null) {
            this.db.add(a);
            this.cz.b5(a);
        }
        else {
            this.db.add(a);
            this.queueAutoRefresh();
        }
    };
    LocalDataSource.prototype.unpinRow = function (a) {
        _super.prototype.unpinRow.call(this, a);
        var b = this.cy();
        if (this.cz != null) {
            for (var c = this.db.count - 1; c >= 0; c--) {
                var d = this.db._inner[c];
                if (d.length != a.length) {
                    continue;
                }
                if (b.h(d, a) == 0) {
                    this.db.removeAt(c);
                    this.cz.cc(d);
                }
            }
        }
        else {
            for (var e = this.db.count - 1; e >= 0; e--) {
                var f = this.db._inner[e];
                if (f.length != a.length) {
                    continue;
                }
                if (b.h(f, a) == 0) {
                    this.db.removeAt(e);
                }
            }
            this.queueAutoRefresh();
        }
        this.dj = -1;
        this.dc = -1;
    };
    LocalDataSource.prototype.clearPinnedRows = function () {
        for (var a = this.db.count - 1; a >= 0; a--) {
            this.unpinRow(this.db._inner[a]);
        }
    };
    LocalDataSource.prototype.isRowPinned = function (a) {
        if (this.cz == null) {
            return false;
        }
        var b = this.getItemAtIndex(a);
        if (b == null) {
            return false;
        }
        var item_ = b;
        if ((item_ != null && item_.$$isSpecialRow !== undefined)) {
            if (item_.rowType == 3) {
                return true;
            }
        }
        var c = this.cy();
        var d;
        if (this.actualPrimaryKey == null) {
            d = new Array(1);
            d[0] = b;
        }
        else {
            var e = this.actualPrimaryKey;
            var f = e.length;
            d = new Array(f);
            for (var g = 0; g < f; g++) {
                d[g] = this.getItemProperty(b, e[g]);
            }
        }
        for (var h = 0; h < this.db.count; h++) {
            if (c.h(this.db._inner[h], d) == 0) {
                return true;
            }
        }
        return false;
    };
    LocalDataSource.prototype.get_isSortingSupported = function () {
        if (this.externalDataSource != null && !this.c2) {
            this.c2 = true;
            var a = this.externalDataSource.isSortingSupportedOverride;
            this.c2 = false;
            return a;
        }
        return true;
    };
    LocalDataSource.prototype.get_isFilteringSupported = function () {
        if (this.externalDataSource != null && !this.c2) {
            this.c2 = true;
            var a = this.externalDataSource.isFilteringSupportedOverride;
            this.c2 = false;
            return a;
        }
        return true;
    };
    LocalDataSource.prototype.get_isGroupingSupported = function () {
        if (this.externalDataSource != null && !this.c2) {
            this.c2 = true;
            var a = this.externalDataSource.isGroupingSupportedOverride;
            this.c2 = false;
            return a;
        }
        return true;
    };
    LocalDataSource.prototype.getStickyRowPriority = function (a) {
        var b = this.getRowType(a);
        switch (b) {
            case 1: return 100 - this.getRowLevel(a);
            case 2: return 99 - this.getRowLevel(a);
            case 3:
            case 5: return 2;
            case 4: return 3;
        }
        return 1;
    };
    LocalDataSource.prototype.getStickyRowsInRange = function (a, b) {
        if (this.cz == null || ((this.groupDescriptions == null || this.groupDescriptions.k.count == 0) && (this.summaryDescriptions == null || this.summaryDescriptions.k.count == 0) && !this.c4())) {
            return null;
        }
        var c = null;
        var d = null;
        if (this.cz.a5.count == 1) {
            c = this.cz.a5._inner[0];
            d = this.cz.a5._inner[0];
        }
        else {
            c = this.cz.w(a);
            if (c != null) {
                while (c.z != -1) {
                    c = this.cz.a5._inner[c.z];
                }
            }
            d = this.cz.w(b);
            if (b >= this.cz.a6.count - this.cz.bk) {
                d = this.cz.v();
            }
        }
        if (c == null || d == null) {
            return null;
        }
        if (c.ae == this.dj && c.aa == this.dl && c.af == this.dm && c.ad == this.dk && c.ah == this.dp && c.ag == this.dn && d.ae == this.dc && d.aa == this.de && d.af == this.df && d.ad == this.dd && d.ah == this.dh && d.ag == this.dg && this.cz.bk == this.di) {
            return this.co;
        }
        this.dj = c.ae;
        this.dc = d.ae;
        this.dl = c.aa;
        this.de = d.aa;
        this.dm = c.af;
        this.df = d.af;
        this.dk = c.ad;
        this.dd = d.ad;
        this.dp = c.ah;
        this.dn = c.ag;
        this.dh = d.ah;
        this.dg = d.ag;
        this.di = this.cz.bk;
        if (this.cz.a5.count == 1) {
            this.dc = d.ad;
        }
        var e = 0;
        if (this.shouldEmitSectionHeaders && this.am) {
            e = 1;
        }
        var f = this.cz.ba();
        var g = new List$1(Number_$type, 0);
        for (var h = c.ae; h <= d.ae; h++) {
            var i = this.cz.a5._inner[h];
            var j = this.cz.a5._inner[h].c.length;
            var k = this.cz.a5._inner[h].v();
            if (this.shouldEmitSectionHeaders && this.am) {
                for (var l = 0; l < j; l++) {
                    if (this.cz.a5._inner[h].a[l] != null) {
                        var m = i.af + i.b[l];
                        g.add(m);
                        if (this.summaryScope == 0 || this.summaryScope == 2) {
                            if (i.c[l] && this.includeSummaryRowsInSection && !this.isSectionSummaryRowsAtBottom) {
                                for (var n = 0; n < f; n++) {
                                    g.add(m + 1 + n);
                                }
                            }
                        }
                    }
                    if (!this.cz.a5._inner[h].c[l]) {
                        break;
                    }
                }
            }
            if (this.cz.a5._inner[h].p) {
                if (this.shouldEmitShiftedRows) {
                    for (var o = 0; o < this.cz.a5._inner[h].aa; o++) {
                        g.add(this.cz.a5._inner[h].af + this.cz.a5._inner[h].ah + o + k);
                    }
                }
            }
            if (this.summaryScope == 0 || this.summaryScope == 2) {
                if (this.includeSummaryRowsInSection && this.isSectionSummaryRowsAtBottom) {
                    for (var p = this.cz.a5._inner[h].ag - 1; p >= 0; p--) {
                        if (this.shouldEmitSectionFooters) {
                            g.add(this.cz.a5._inner[h].ad - k - p);
                        }
                        else {
                            g.add(this.cz.a5._inner[h].ad - p);
                        }
                    }
                }
            }
            if (this.shouldEmitSectionFooters && this.am) {
                for (var q = j - 1; q >= 0; q--) {
                    if (!this.cz.a5._inner[h].c[q]) {
                        break;
                    }
                    g.add(this.cz.a5._inner[h].ad - q);
                }
            }
        }
        for (var r = this.cz.a6.count - this.cz.bk; r < this.cz.a6.count; r++) {
            g.add(r);
        }
        this.co = g.toArray();
        return this.co;
    };
    LocalDataSource.prototype.isExclusivelySticky = function (a) {
        var b = this.getRowType(a);
        return b == 1 || b == 2 || b == 4 || (this.isSectionSummaryRowsAtBottom && b == 5);
    };
    LocalDataSource.prototype.getRowType = function (a) {
        if (a < 0) {
            return 0;
        }
        var b = this.getItemAtIndex(a);
        var item_ = b;
        if ((item_ != null && item_.$$isSpecialRow !== undefined)) {
            var c = b.rowType;
            if (this.isSectionHeaderNormalRow && c == 1) {
                return 0;
            }
            return c;
        }
        return 0;
    };
    LocalDataSource.prototype.setIsRowExpandedAtIndex = function (a, b) {
        if (this.isSectionCollapsable && this.cz != null && this.cz.a6.count > 0 && this.cz.a6.count > a) {
            this.cz.ca(a, b);
        }
    };
    LocalDataSource.prototype.getIsRowExpandedAtIndex = function (a) {
        if (this.cz != null && this.cz.a6.count > 0 && this.cz.a6.count > a) {
            return this.cz.ak(a);
        }
        return true;
    };
    LocalDataSource.prototype.getRowLevel = function (a) {
        if (a < 0) {
            return 0;
        }
        var b = this.getItemAtIndex(a);
        var item_ = b;
        if ((item_ != null && item_.$$isSpecialRow !== undefined)) {
            return b.level;
        }
        if (this.sectionHeaderDisplayMode == 1) {
            return this.groupDescriptions.k.count;
        }
        else if (this.groupDescriptions.k.count > 0) {
            return 1;
        }
        return 0;
    };
    LocalDataSource.prototype.getRootSummaryRowCount = function () {
        if (this.cz != null) {
            return this.cz.bk;
        }
        return 0;
    };
    LocalDataSource.prototype.getRootSummaryResults = function () {
        if (this.cz != null) {
            return this.cz.i;
        }
        return null;
    };
    LocalDataSource.prototype.getSectionSummaryResults = function (a) {
        if (this.cz != null && this.cz.a5.count > 0 && a >= 0 && a < this.cz.a5.count) {
            return this.cz.a5._inner[a].i;
        }
        return null;
    };
    LocalDataSource.prototype.clone = function () {
        var a = new LocalDataSource();
        a.dataSource = this.dataSource;
        _super.prototype.cloneProperties.call(this, a);
        return a;
    };
    LocalDataSource.prototype.an = function () {
        return !this.isReadOnly && this.actualBaseDataProvider != null && this.t != null;
    };
    LocalDataSource.prototype.ch = function (a, b) {
        var e_1, _a, e_2, _b;
        if (a == 5) {
            var c = new List$1(TransactionType_$type, 0);
            var d = new List$1(Base.$, 0);
            var e = b;
            var f = e.a;
            for (var g = 0; g < f.length; g++) {
                if (f[g].transactionType == 1) {
                    var h = f[g].id;
                    var i = this.indexOfKey(h);
                    if (i > -1) {
                        var j = this.getItemAtIndex(i);
                        var k = f[g].value;
                        try {
                            for (var _c = (e_1 = void 0, tslib_1.__values(fromEnum(k))), _d = _c.next(); !_d.done; _d = _c.next()) {
                                var l = _d.value;
                                this.actualDataProvider.setItemValue(j, l.key, l.value);
                            }
                        }
                        catch (e_1_1) { e_1 = { error: e_1_1 }; }
                        finally {
                            try {
                                if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
                            }
                            finally { if (e_1) throw e_1.error; }
                        }
                        this.onBroadcastSetItem(i, j, j);
                        d.add1(j);
                        c.add(1);
                        if (this.db.count > 0) {
                            var m = this.cy();
                            for (var n = 0; n < this.db.count; n++) {
                                if (m.h(this.db._inner[n], h) == 0) {
                                    var o = this.getStickyRows();
                                    for (var p = 0; p < o.length; p++) {
                                        var q = o[p];
                                        var r = typeCast(DataSourceSpecialRow.$, this.cz.a6.item(q));
                                        if (r != null && r.rowType == 3 && r.targetRow == j) {
                                            this.onBroadcastSetItem(q, r, r);
                                            break;
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
                else if (f[g].transactionType == TransactionType.Delete) {
                    var s = f[g].id;
                    var t = this.indexOfKey(s);
                    if (t > -1) {
                        var u = this.getItemAtIndex(t);
                        this.actualDataProvider.removeItem(u);
                        this.notifyRemoveItem(t, u);
                        d.add1(u);
                        c.add(TransactionType.Delete);
                    }
                }
                else if (f[g].transactionType == 0) {
                    var v = f[g].id[0];
                    if (f[g].value != null) {
                        var w = f[g].value;
                        try {
                            for (var _e = (e_2 = void 0, tslib_1.__values(fromEnum(w))), _f = _e.next(); !_f.done; _f = _e.next()) {
                                var x = _f.value;
                                this.actualDataProvider.setItemValue(v, x.key, x.value);
                            }
                        }
                        catch (e_2_1) { e_2 = { error: e_2_1 }; }
                        finally {
                            try {
                                if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
                            }
                            finally { if (e_2) throw e_2.error; }
                        }
                    }
                    this.actualDataProvider.addItem(v);
                    d.add1(v);
                    c.add(0);
                }
            }
            if (f.length > 0) {
                this.bt(e.id, this.getAggregatedChanges(e.id));
            }
        }
    };
    LocalDataSource.$t = markType(LocalDataSource, 'LocalDataSource', BaseDataSource.$);
    return LocalDataSource;
}(BaseDataSource));
export { LocalDataSource };
/**
 * @hidden
 */
var LocalDataSourceViewUpdateNotifier = /** @class */ (function (_super) {
    tslib_1.__extends(LocalDataSourceViewUpdateNotifier, _super);
    function LocalDataSourceViewUpdateNotifier(a) {
        var _this = _super.call(this) || this;
        _this.a = null;
        _this.a = a;
        return _this;
    }
    LocalDataSourceViewUpdateNotifier.prototype.notifyClearItems = function () {
        this.a.dv();
    };
    LocalDataSourceViewUpdateNotifier.prototype.notifyInsertItem = function (a, b) {
        this.a.dw(a, b);
    };
    LocalDataSourceViewUpdateNotifier.prototype.notifyRemoveItem = function (a, b) {
        this.a.dx(a, b);
    };
    LocalDataSourceViewUpdateNotifier.prototype.notifySetItem = function (a, b, c) {
        this.a.dy(a, b, c);
    };
    LocalDataSourceViewUpdateNotifier.$t = markType(LocalDataSourceViewUpdateNotifier, 'LocalDataSourceViewUpdateNotifier', Base.$, [ISupportsDataChangeNotifications_$type]);
    return LocalDataSourceViewUpdateNotifier;
}(Base));
export { LocalDataSourceViewUpdateNotifier };
/**
 * @hidden
 */
var LocalDataSourceViewExpansionNotifier = /** @class */ (function (_super) {
    tslib_1.__extends(LocalDataSourceViewExpansionNotifier, _super);
    function LocalDataSourceViewExpansionNotifier(a) {
        var _this = _super.call(this) || this;
        _this.a = null;
        _this.a = a;
        return _this;
    }
    LocalDataSourceViewExpansionNotifier.prototype.notifyRowExpansionChanged = function (a, b, c) {
        this.a.onRowExpansionChanged(a, b, c);
    };
    LocalDataSourceViewExpansionNotifier.$t = markType(LocalDataSourceViewExpansionNotifier, 'LocalDataSourceViewExpansionNotifier', Base.$, [ISupportsExpansionChangeNotifications_$type]);
    return LocalDataSourceViewExpansionNotifier;
}(Base));
export { LocalDataSourceViewExpansionNotifier };
//# sourceMappingURL=LocalDataSource_combined.js.map