/*
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 { ISupportsDataChangeNotifications_$type } from "./ISupportsDataChangeNotifications";
import { IDataSourceSupportsCount_$type } from "./IDataSourceSupportsCount";
import { IDataSourceDataProviderUpdateNotifier_$type } from "./IDataSourceDataProviderUpdateNotifier";
import { SortDescriptionCollection } from "./SortDescriptionCollection";
import { DataSourceSummaryScope_$type } from "./DataSourceSummaryScope";
import { Base, Type, markType, typeGetValue, PropertyChangedEventArgs, runOn, delegateCombine, typeCast, fromEnum, String_$type, delegateRemove, enumGetBox } from "./type";
import { SyncableObservableCollection$1 } from "./SyncableObservableCollection$1";
import { IDataSourceSupportsIndexedAccess_$type } from "./IDataSourceSupportsIndexedAccess";
import { DataSourceSectionHeaderDisplayMode_$type } from "./DataSourceSectionHeaderDisplayMode";
import { DataSourceSchemaChangedEventArgs } from "./DataSourceSchemaChangedEventArgs";
import { DataSourceRowExpansionChangedEventArgs } from "./DataSourceRowExpansionChangedEventArgs";
import { Convert } from "./Convert";
import { truncate, isNaN_ } from "./number";
import { toOADate, fromOADate } from "./dateExtended";
import { DefaultSummaryResult } from "./DefaultSummaryResult";
import { stringCompare } from "./string";
import { ArgumentNullException } from "./ArgumentNullException";
import { IEditableDataSource_$type } from "./IEditableDataSource";
import { TransactionService } from "./TransactionService";
import { TransactionKeyEqualityComparer } from "./TransactionKeyEqualityComparer";
import { Transaction } from "./Transaction";
import { DataSourceSpecialRow } from "./DataSourceSpecialRow";
import { List$1 } from "./List$1";
import { Dictionary$2 } from "./Dictionary$2";
import { DataSourceAggregatedResult } from "./DataSourceAggregatedResult";
import { DataSourceDataCommittedEventArgs } from "./DataSourceDataCommittedEventArgs";
import { Localization } from "./Localization";
import { TransactionType } from "./TransactionType";
import { stringFormat } from "./stringExtended";
/**
 * @hidden
 */
export let IDataSourceDataProvider_$type = new Type(null, 'IDataSourceDataProvider', null, [ISupportsDataChangeNotifications_$type, IDataSourceSupportsCount_$type]);
/**
 * @hidden
 */
export let IFilterExpression_$type = new Type(null, 'IFilterExpression');
/**
 * @hidden
 */
export let FilterExpressionCollection = /*@__PURE__*/ (() => {
    class FilterExpressionCollection extends Base {
        constructor() {
            super();
            this.a = null;
            this.f = null;
            this.f = new SyncableObservableCollection$1(IFilterExpression_$type);
        }
        get syncTarget() {
            return this.a;
        }
        set syncTarget(a) {
            if (a == null) {
                this.f.syncTarget = null;
                this.a = null;
                return;
            }
            this.a = a;
            this.f.syncTarget = this.a.f;
        }
        get shouldDetachOnTargetChange() {
            return this.f.shouldDetachOnTargetChange;
        }
        set shouldDetachOnTargetChange(a) {
            this.f.shouldDetachOnTargetChange = a;
        }
        add(a) {
            return this.f.add(a);
        }
        insert(a, b) {
            this.f.add1(a, b);
        }
        clear() {
            this.f.clear();
        }
        get(a) {
            return this.f.get(a);
        }
        indexOf(a) {
            return this.f.indexOf(a);
        }
        remove(a) {
            return this.f.remove1(a);
        }
        removeAt(a) {
            return this.f.remove(a);
        }
        set(a, b) {
            return this.f.set(a, b);
        }
        size() {
            return this.f.size();
        }
        get onChanged() {
            return this.f.f;
        }
        set onChanged(a) {
            this.f.f = a;
        }
        n(a) {
            this.f.addListener(a);
        }
        q(a) {
            this.f.removeListener(a);
        }
        get k() {
            return this.f.all;
        }
    }
    FilterExpressionCollection.$t = markType(FilterExpressionCollection, 'FilterExpressionCollection');
    return FilterExpressionCollection;
})();
/**
 * @hidden
 */
export let IDataSource_$type = new Type(null, 'IDataSource', null, [ISupportsDataChangeNotifications_$type, IDataSourceSupportsIndexedAccess_$type]);
/**
 * @hidden
 */
export let SummaryCalculator = /*@__PURE__*/ (() => {
    class SummaryCalculator extends Base {
        constructor() {
            super(...arguments);
            this._propertyName = null;
            this._propertyType = 0;
            this._dataSource = null;
            this._isSummaryDirty = false;
            this.b = 5;
        }
        get propertyName() {
            return this._propertyName;
        }
        set propertyName(a) {
            this._propertyName = a;
        }
        get propertyType() {
            return this._propertyType;
        }
        set propertyType(a) {
            this._propertyType = a;
        }
        get dataSource() {
            return this._dataSource;
        }
        set dataSource(a) {
            this._dataSource = a;
        }
        get isSummaryDirty() {
            return this._isSummaryDirty;
        }
        set isSummaryDirty(a) {
            this._isSummaryDirty = a;
        }
        get_operand() {
            return this.b;
        }
        get operand() {
            return this.get_operand();
        }
        beginCalculation(a, b) {
            this.dataSource = a;
            this.propertyName = b;
            if (this.propertyName != null) {
                this.propertyType = a.resolveSchemaPropertyType(this.propertyName);
            }
            this.isSummaryDirty = false;
        }
        endCalculation() {
            return null;
        }
        aggregate(a) {
        }
        itemAdded(a, b, c) {
            return b;
        }
        itemRemoved(a, b, c) {
            return b;
        }
        i(a) {
            if (this.dataSource == null) {
                return NaN;
            }
            let b = this.dataSource.getItemProperty(a, this.propertyName);
            if (b == null) {
                return NaN;
            }
            return this.j(b);
        }
        j(a) {
            if (a == null) {
                return NaN;
            }
            switch (this.propertyType) {
                case 6: return a;
                case 5: return a;
                case 1: return typeGetValue(a);
                case 3: return typeGetValue(a);
                case 4: return typeGetValue(a);
                case 7: return a;
                case 8: return toOADate(a);
                case 11: try {
                    return Convert.toDouble3(a);
                }
                catch (b) {
                    return NaN;
                }
            }
            return 0;
        }
        k(a) {
            switch (this.propertyType) {
                case 6: return a;
                case 5: return a;
                case 1: return truncate(a);
                case 3: return truncate(a);
                case 4: return truncate(a);
                case 7: return a;
                case 8: return fromOADate(a);
                default: return a;
            }
        }
    }
    SummaryCalculator.$t = markType(SummaryCalculator, 'SummaryCalculator');
    return SummaryCalculator;
})();
/**
 * @hidden
 */
export let SumSummaryCalculator = /*@__PURE__*/ (() => {
    class SumSummaryCalculator extends SummaryCalculator {
        constructor() {
            super(...arguments);
            this.p = 0;
        }
        get_displayName() {
            let a = BaseDataSource.ba("DataSource_Summary_Sum");
            return a != null ? a : "Sum";
        }
        get displayName() {
            return this.get_displayName();
        }
        get_operand() {
            return 2;
        }
        beginCalculation(a, b) {
            super.beginCalculation(a, b);
            this.p = 0;
        }
        endCalculation() {
            return new DefaultSummaryResult(this.propertyName, 2, this.k(this.p));
        }
        aggregate(a) {
            let b = this.i(a);
            if (!isNaN_(b)) {
                this.p += b;
            }
        }
        itemAdded(a, b, c) {
            let d = this.i(a);
            if (isNaN_(d)) {
                d = 0;
            }
            if (b == null) {
                return new DefaultSummaryResult(this.propertyName, 2, this.k(d));
            }
            let e = this.j(b.value) + d;
            return new DefaultSummaryResult(this.propertyName, 2, this.k(e));
        }
        itemRemoved(a, b, c) {
            let d = this.i(a);
            if (isNaN_(d)) {
                d = 0;
            }
            let e = this.j(b.value) - d;
            return new DefaultSummaryResult(this.propertyName, 2, this.k(e));
        }
    }
    SumSummaryCalculator.$t = markType(SumSummaryCalculator, 'SumSummaryCalculator', SummaryCalculator.$);
    return SumSummaryCalculator;
})();
/**
 * @hidden
 */
export let CountSummaryCalculator = /*@__PURE__*/ (() => {
    class CountSummaryCalculator extends SummaryCalculator {
        constructor() {
            super(...arguments);
            this.p = 0;
        }
        get_displayName() {
            let a = BaseDataSource.ba("DataSource_Summary_Count");
            return a != null ? a : "Count";
        }
        get displayName() {
            return this.get_displayName();
        }
        get_operand() {
            return 4;
        }
        beginCalculation(a, b) {
            super.beginCalculation(a, b);
            this.propertyType = 1;
            this.p = 0;
        }
        endCalculation() {
            return new DefaultSummaryResult(this.propertyName, 4, this.p);
        }
        aggregate(a) {
            this.p++;
        }
        itemAdded(a, b, c) {
            if (b == null) {
                return new DefaultSummaryResult(this.propertyName, 4, 1);
            }
            return new DefaultSummaryResult(this.propertyName, 4, typeGetValue(b.value) + 1);
        }
        itemRemoved(a, b, c) {
            return new DefaultSummaryResult(this.propertyName, 4, typeGetValue(b.value) - 1);
        }
    }
    CountSummaryCalculator.$t = markType(CountSummaryCalculator, 'CountSummaryCalculator', SummaryCalculator.$);
    return CountSummaryCalculator;
})();
/**
 * @hidden
 */
export let AverageSummaryCalculator = /*@__PURE__*/ (() => {
    class AverageSummaryCalculator extends SummaryCalculator {
        constructor() {
            super(...arguments);
            this.p = 0;
            this.q = 0;
        }
        get_displayName() {
            let a = BaseDataSource.ba("DataSource_Summary_Avg");
            return a != null ? a : "Avg";
        }
        get displayName() {
            return this.get_displayName();
        }
        get_operand() {
            return 3;
        }
        beginCalculation(a, b) {
            super.beginCalculation(a, b);
            this.p = 0;
            this.q = 0;
        }
        endCalculation() {
            let a = this.q > 0 ? this.p / this.q : 0;
            return new DefaultSummaryResult(this.propertyName, 3, this.k(a));
        }
        aggregate(a) {
            let b = this.i(a);
            if (!isNaN_(b)) {
                this.p += b;
                this.q++;
            }
        }
        itemAdded(a, b, c) {
            let d = this.i(a);
            if (isNaN_(d)) {
                d = 0;
            }
            if (b == null) {
                return new DefaultSummaryResult(this.propertyName, 3, this.k(d));
            }
            let e = this.j(b.value) * (c - 1);
            let f = (e + d) / c;
            return new DefaultSummaryResult(this.propertyName, 3, this.k(f));
        }
        itemRemoved(a, b, c) {
            let d = this.i(a);
            if (isNaN_(d)) {
                d = 0;
            }
            let e = this.j(b.value) * (c + 1);
            let f = (e - d) / c;
            return new DefaultSummaryResult(this.propertyName, 3, this.k(f));
        }
    }
    AverageSummaryCalculator.$t = markType(AverageSummaryCalculator, 'AverageSummaryCalculator', SummaryCalculator.$);
    return AverageSummaryCalculator;
})();
/**
 * @hidden
 */
export let MaxSummaryCalculator = /*@__PURE__*/ (() => {
    class MaxSummaryCalculator extends SummaryCalculator {
        constructor() {
            super(...arguments);
            this.p = null;
        }
        get_displayName() {
            let a = BaseDataSource.ba("DataSource_Summary_Max");
            return a != null ? a : "Max";
        }
        get displayName() {
            return this.get_displayName();
        }
        get_operand() {
            return 1;
        }
        beginCalculation(a, b) {
            super.beginCalculation(a, b);
            this.p = null;
        }
        endCalculation() {
            return new DefaultSummaryResult(this.propertyName, 1, this.p);
        }
        aggregate(a) {
            this.p = this.q(a, this.p);
        }
        itemAdded(a, b, c) {
            if (b == null) {
                return new DefaultSummaryResult(this.propertyName, 1, this.q(a, null));
            }
            let d = this.q(a, b.value);
            return new DefaultSummaryResult(this.propertyName, 1, d);
        }
        itemRemoved(a, b, c) {
            let d = this.dataSource.getItemProperty(a, this.propertyName);
            if (Base.equalsStatic(d, b.value)) {
                this.isSummaryDirty = true;
            }
            return b;
        }
        q(a, b) {
            let c = this.dataSource.getItemProperty(a, this.propertyName);
            if (b == null) {
                return c;
            }
            if (c == null) {
                return b;
            }
            switch (this.propertyType) {
                case 0:
                    b = stringCompare(c, b) > 0 ? c : b;
                    break;
                case 6:
                    b = c > b ? c : b;
                    break;
                case 5:
                    b = c > b ? c : b;
                    break;
                case 1:
                    b = typeGetValue(c) > typeGetValue(b) ? c : b;
                    break;
                case 3:
                    b = typeGetValue(c) > typeGetValue(b) ? c : b;
                    break;
                case 4:
                    b = typeGetValue(c) > typeGetValue(b) ? c : b;
                    break;
                case 7:
                    b = c > b ? c : b;
                    break;
                case 2:
                    b = c ? c : b;
                    break;
                case 10:
                    b = typeGetValue(c) > typeGetValue(b) ? c : b;
                    break;
                case 8:
                    let xVal_ = c;
                    let yVal_ = b;
                    xVal_ = +xVal_;
                    yVal_ = +yVal_;
                    let d = typeGetValue(xVal_);
                    let e = typeGetValue(yVal_);
                    b = Base.compareSimple(d, e) > 0 ? c : b;
                    break;
            }
            return b;
        }
    }
    MaxSummaryCalculator.$t = markType(MaxSummaryCalculator, 'MaxSummaryCalculator', SummaryCalculator.$);
    return MaxSummaryCalculator;
})();
/**
 * @hidden
 */
export let MinSummaryCalculator = /*@__PURE__*/ (() => {
    class MinSummaryCalculator extends SummaryCalculator {
        constructor() {
            super(...arguments);
            this.p = null;
        }
        get_displayName() {
            let a = BaseDataSource.ba("DataSource_Summary_Min");
            return a != null ? a : "Min";
        }
        get displayName() {
            return this.get_displayName();
        }
        get_operand() {
            return 0;
        }
        beginCalculation(a, b) {
            super.beginCalculation(a, b);
            this.p = null;
        }
        endCalculation() {
            return new DefaultSummaryResult(this.propertyName, 0, this.p);
        }
        aggregate(a) {
            this.p = this.q(a, this.p);
        }
        itemAdded(a, b, c) {
            if (b == null) {
                return new DefaultSummaryResult(this.propertyName, 0, this.q(a, null));
            }
            let d = this.q(a, b.value);
            return new DefaultSummaryResult(this.propertyName, 0, d);
        }
        itemRemoved(a, b, c) {
            let d = this.dataSource.getItemProperty(a, this.propertyName);
            if (Base.equalsStatic(d, b.value)) {
                this.isSummaryDirty = true;
            }
            return b;
        }
        q(a, b) {
            let c = this.dataSource.getItemProperty(a, this.propertyName);
            if (b == null) {
                return c;
            }
            if (c == null) {
                return b;
            }
            switch (this.propertyType) {
                case 0:
                    b = stringCompare(c, b) < 0 ? c : b;
                    break;
                case 6:
                    b = c < b ? c : b;
                    break;
                case 5:
                    b = c < b ? c : b;
                    break;
                case 1:
                    b = typeGetValue(c) < typeGetValue(b) ? c : b;
                    break;
                case 3:
                    b = typeGetValue(c) < typeGetValue(b) ? c : b;
                    break;
                case 4:
                    b = typeGetValue(c) < typeGetValue(b) ? c : b;
                    break;
                case 7:
                    b = c < b ? c : b;
                    break;
                case 2:
                    b = !c ? c : b;
                    break;
                case 10:
                    b = typeGetValue(c) < typeGetValue(b) ? c : b;
                    break;
                case 8:
                    let xVal_ = c;
                    let yVal_ = b;
                    xVal_ = +xVal_;
                    yVal_ = +yVal_;
                    let d = typeGetValue(xVal_);
                    let e = typeGetValue(yVal_);
                    b = Base.compareSimple(d, e) < 0 ? c : b;
                    break;
            }
            return b;
        }
    }
    MinSummaryCalculator.$t = markType(MinSummaryCalculator, 'MinSummaryCalculator', SummaryCalculator.$);
    return MinSummaryCalculator;
})();
/**
 * @hidden
 */
export let SummaryDescription = /*@__PURE__*/ (() => {
    class SummaryDescription extends Base {
        constructor(a, ..._rest) {
            super();
            this.h = false;
            this.k = null;
            this.a = 0;
            this._alias = null;
            this.d = null;
            this.provideCalculator = null;
            a = (a == void 0) ? 0 : a;
            switch (a) {
                case 0: break;
                case 1:
                    {
                        let c = _rest[0];
                        this.propertyName = c;
                        this.operand = 4;
                    }
                    break;
                case 2:
                    {
                        let c = _rest[0];
                        let d = _rest[1];
                        this.propertyName = c;
                        this.operand = d;
                    }
                    break;
            }
        }
        get propertyName() {
            return this.k;
        }
        set propertyName(a) {
            this.k = a;
        }
        get operand() {
            return this.a;
        }
        set operand(a) {
            this.a = a;
            switch (this.a) {
                case 0:
                    this.calculator = new MinSummaryCalculator();
                    break;
                case 1:
                    this.calculator = new MaxSummaryCalculator();
                    break;
                case 2:
                    this.calculator = new SumSummaryCalculator();
                    break;
                case 3:
                    this.calculator = new AverageSummaryCalculator();
                    break;
                case 4:
                    this.calculator = new CountSummaryCalculator();
                    break;
            }
        }
        get alias() {
            return this._alias;
        }
        set alias(a) {
            this._alias = a;
        }
        get calculator() {
            return this.d;
        }
        set calculator(a) {
            this.d = a;
        }
        equals(a) {
            let b = a;
            if (b == null) {
                return super.equals(a);
            }
            return b.propertyName == this.propertyName && b.operand == this.operand;
        }
        getHashCode() {
            return Base.getHashCodeStatic(this.propertyName) * 17 + this.operand;
        }
        n() {
            this.h = true;
        }
        g() {
            if (this.provideCalculator != null) {
                let a = new ProvideCalculatorEventArgs();
                this.provideCalculator(this, a);
                return a.a;
            }
            return null;
        }
        f() {
            switch (this.a) {
                case 0: return new MinSummaryCalculator();
                case 1: return new MaxSummaryCalculator();
                case 2: return new SumSummaryCalculator();
                case 3: return new AverageSummaryCalculator();
                case 4: return new CountSummaryCalculator();
                case 5:
                    let a = this.g();
                    if (a == null) {
                        throw new ArgumentNullException(2, "Calculator", "No custom calculator was provided.");
                    }
                    return a;
            }
            return null;
        }
    }
    SummaryDescription.$t = markType(SummaryDescription, 'SummaryDescription');
    return SummaryDescription;
})();
/**
 * @hidden
 */
export let SummaryDescriptionCollection = /*@__PURE__*/ (() => {
    class SummaryDescriptionCollection extends Base {
        constructor() {
            super();
            this.d = null;
            this.f = null;
            this.f = new SyncableObservableCollection$1(SummaryDescription.$);
        }
        g() {
            return this.f;
        }
        get syncTarget() {
            return this.d;
        }
        set syncTarget(a) {
            if (a == null) {
                this.f.syncTarget = null;
                this.d = null;
                return;
            }
            this.d = a;
            this.f.syncTarget = this.d.f;
        }
        add(a) {
            return this.f.add(a);
        }
        insert(a, b) {
            this.f.add1(a, b);
        }
        clear() {
            this.f.clear();
        }
        get(a) {
            return this.f.get(a);
        }
        indexOf(a) {
            return this.f.indexOf(a);
        }
        remove(a) {
            return this.f.remove1(a);
        }
        removeAt(a) {
            return this.f.remove(a);
        }
        set(a, b) {
            return this.f.set(a, b);
        }
        size() {
            return this.f.size();
        }
        n(a) {
            this.f.addListener(a);
        }
        q(a) {
            this.f.removeListener(a);
        }
        get onChanged() {
            return this.f.f;
        }
        set onChanged(a) {
            this.f.f = a;
        }
        get k() {
            return this.f.all;
        }
    }
    SummaryDescriptionCollection.$t = markType(SummaryDescriptionCollection, 'SummaryDescriptionCollection');
    return SummaryDescriptionCollection;
})();
/**
 * @hidden
 */
export let ProvideCalculatorEventArgs = /*@__PURE__*/ (() => {
    class ProvideCalculatorEventArgs extends Base {
        constructor() {
            super(...arguments);
            this.a = null;
        }
    }
    ProvideCalculatorEventArgs.$t = markType(ProvideCalculatorEventArgs, 'ProvideCalculatorEventArgs');
    return ProvideCalculatorEventArgs;
})();
/**
 * @hidden
 */
export let BaseDataSource = /*@__PURE__*/ (() => {
    class BaseDataSource extends Base {
        constructor() {
            super();
            this.u = null;
            this._isReadOnly = false;
            this.z = false;
            this.dataCommitted = null;
            this.ap = false;
            this.az = null;
            this._externalDataSource = null;
            this.s = null;
            this.r = null;
            this.i = null;
            this.t = null;
            this.j = null;
            this.o = null;
            this.at = 0;
            this.au = 0;
            this.av = 0;
            this.p = null;
            this.propertyChanged = null;
            this.l = null;
            this.n = null;
            this.schemaChanged = null;
            this.rowExpansionChanged = null;
            this.aa = false;
            this.h = 0;
            this.x = false;
            this.b = null;
            this.a = null;
            this.c = null;
            this.ag = false;
            this.ah = false;
            this.v = false;
            this.g = 0;
            this.ab = true;
            this.ad = true;
            this.y = false;
            this.af = false;
            this.ae = false;
            this.ac = true;
            this.aj = true;
            this.ai = false;
            this.ak = true;
            this.al = true;
            this.w = false;
            this.d = null;
            this.l = new DefaultDataSourceDataProviderUpdateNotifier(this);
            this.s = new SortDescriptionCollection();
            this.r = new SortDescriptionCollection();
            this.t = new SummaryDescriptionCollection();
            this.s.n(runOn(this, this.ct));
            this.r.n(runOn(this, this.bx));
            this.t.n(runOn(this, this.cu));
            this.i = new FilterExpressionCollection();
            this.i.n(runOn(this, this.bv));
            this.u = new TransactionService(runOn(this, this.bz), runOn(this, this.clone1), new TransactionKeyEqualityComparer());
            let a = this.u;
            a.stateChanged = delegateCombine(a.stateChanged, runOn(this, this.cp));
        }
        cp(a, b) {
            if (a == 0 || a == 1) {
                if (this.updateNotifier != null) {
                    let c = b;
                    let d = c.transactions._inner[0];
                    if (d.type == 1 || d.type == TransactionType.Delete) {
                        let e = d.id;
                        let f = this.indexOfKey(e);
                        if (f > -1) {
                            let g = this.getItemAtIndex(f);
                            this.updateNotifier.notifySetItem(f, g, g);
                            let h = this.getStickyRows();
                            if (h != null) {
                                for (let i = 0; i < h.length; i++) {
                                    let j = h[i];
                                    let k = typeCast(DataSourceSpecialRow.$, this.getItemAtIndex(j));
                                    if (k != null && k.rowType == 3 && k.targetRow == g) {
                                        this.updateNotifier.notifySetItem(j, k, k);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else if (d.type == 0) {
                    }
                }
            }
            this.co(a, b);
        }
        co(a, b) {
        }
        aq() {
            return !this.isReadOnly && this.actualPrimaryKey != null && this.actualBaseDataProvider != null && this.u != null;
        }
        bz(a, b) {
            if (a != null && b != null) {
                let c = a;
                let d = b;
                for (let e of fromEnum(d)) {
                    if (c.containsKey(e.key)) {
                        c.item(e.key, e.value);
                    }
                    else {
                        c.addItem(e.key, e.value);
                    }
                }
            }
        }
        clone1(a) {
            if (a != null) {
                let b = a;
                let c = new Dictionary$2(String_$type, Base.$, 0);
                for (let d of fromEnum(b)) {
                    c.addItem(d.key, d.value);
                }
                return c;
            }
            return null;
        }
        get isReadOnly() {
            return this._isReadOnly;
        }
        set isReadOnly(a) {
            this._isReadOnly = a;
        }
        get_isBatchingEnabled() {
            return this.z;
        }
        set_isBatchingEnabled(a) {
            this.z = a;
        }
        get isBatchingEnabled() {
            return this.get_isBatchingEnabled();
        }
        set isBatchingEnabled(a) {
            this.set_isBatchingEnabled(a);
        }
        get canUndo() {
            return this.u.k;
        }
        get canRedo() {
            return this.u.j;
        }
        get canCommit() {
            return this.u.a(-1).length > 0;
        }
        updatePropertyAtKey(a, b, c, d = false) {
            if (this.aq()) {
                let e = null;
                if (a.length == 1 && typeCast(DataSourceSpecialRow.$, a[0]) !== null) {
                    let f = typeCast(DataSourceSpecialRow.$, a[0]);
                    if (f.rowType == 3) {
                        e = f;
                        if (this.actualPrimaryKey != null) {
                            a = new Array(this.actualPrimaryKey.length);
                            this.getPrimaryKeyValue(e.targetRow, a);
                        }
                        else {
                            a = [e.targetRow];
                        }
                    }
                }
                let g = new Dictionary$2(String_$type, Base.$, 0);
                g.addItem(b, c);
                let h = new Transaction();
                h.id = a;
                h.value = g;
                h.type = 1;
                this.u.v(h, d);
                if (this.isBatchingEnabled || d) {
                    if (this.updateNotifier != null) {
                        let i = this.indexOfKey(a);
                        if (i > -1) {
                            let j = this.getItemAtIndex(i);
                            this.updateNotifier.notifySetItem(i, j, j);
                        }
                        if (this.isRowPinned(i)) {
                            let k = -1;
                            if (e != null) {
                                k = this.indexOfItem(e);
                            }
                            else {
                                let l = this.getStickyRows();
                                if (l != null) {
                                    for (let m = 0; m < l.length; m++) {
                                        let n = typeCast(DataSourceSpecialRow.$, this.getItemAtIndex(l[m]));
                                        if (n != null && n.rowType == 3) {
                                            e = n;
                                            k = l[m];
                                            break;
                                        }
                                    }
                                }
                            }
                            if (k > -1) {
                                this.updateNotifier.notifySetItem(k, e, e);
                            }
                        }
                    }
                }
                return h.transactionID;
            }
            return -1;
        }
        removeItemByKey(a) {
            if (this.aq()) {
                let b = null;
                if (a.length == 1 && typeCast(DataSourceSpecialRow.$, a[0]) !== null) {
                    let c = typeCast(DataSourceSpecialRow.$, a[0]);
                    if (c.rowType == 3) {
                        b = c;
                        if (this.actualPrimaryKey != null) {
                            a = new Array(this.actualPrimaryKey.length);
                            this.getPrimaryKeyValue(b.targetRow, a);
                        }
                        else {
                            a = [b.targetRow];
                        }
                    }
                }
                let d = new Transaction();
                d.id = a;
                d.type = TransactionType.Delete;
                this.u.v(d, false);
                if (this.isBatchingEnabled) {
                    if (this.updateNotifier != null) {
                        let e = this.indexOfKey(a);
                        if (e > -1) {
                            let f = this.getItemAtIndex(e);
                            this.updateNotifier.notifySetItem(e, f, f);
                        }
                        if (this.isRowPinned(e)) {
                            let g = -1;
                            if (b != null) {
                                g = this.indexOfItem(b);
                            }
                            else {
                                let h = this.getStickyRows();
                                if (h != null) {
                                    for (let i = 0; i < h.length; i++) {
                                        let j = typeCast(DataSourceSpecialRow.$, this.getItemAtIndex(h[i]));
                                        if (j != null && j.rowType == 3) {
                                            b = j;
                                            g = h[i];
                                            break;
                                        }
                                    }
                                }
                            }
                            if (g > -1) {
                                this.updateNotifier.notifySetItem(g, b, b);
                            }
                        }
                    }
                }
            }
        }
        removeItem(a) {
            if (this.aq()) {
                let b;
                if (typeCast(DataSourceSpecialRow.$, a) !== null) {
                    b = [a];
                }
                else if (this.actualPrimaryKey == null || this.actualPrimaryKey.length < 1) {
                    b = [a];
                }
                else {
                    b = new Array(this.actualPrimaryKey.length);
                    this.getPrimaryKeyValue(a, b);
                }
                this.removeItemByKey(b);
            }
        }
        addItem(a) {
            if (this.aq()) {
                if (typeCast(DataSourceSpecialRow.$, a) !== null) {
                    return;
                }
                let b = new Transaction();
                b.id = [a];
                b.type = 0;
                this.u.v(b, false);
            }
        }
        acceptPendingTransaction(a) {
            if (this.aq()) {
                let b = this.u.d(a);
                if (b != null) {
                    this.u.ap(a);
                }
            }
        }
        rejectPendingTransaction(a) {
            if (this.aq()) {
                let b = this.u.d(a);
                if (b != null) {
                    this.u.x(a);
                    if (this.updateNotifier != null) {
                        if (b.type != 0) {
                            let c = b.id;
                            let d = this.indexOfKey(c);
                            if (d > -1) {
                                let e = this.getItemAtIndex(d);
                                this.updateNotifier.notifySetItem(d, e, e);
                                let f = this.getStickyRows();
                                if (f != null) {
                                    for (let g = 0; g < f.length; g++) {
                                        let h = typeCast(DataSourceSpecialRow.$, this.getItemAtIndex(f[g]));
                                        if (h != null && h.rowType == 3) {
                                            if (h.targetRow == e) {
                                                this.updateNotifier.notifySetItem(f[g], h, h);
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        commitEdits(a) {
            if (this.aq()) {
                let b = this.u.c(null).length > 0;
                let c = this.u.s(a, this.isBatchingEnabled);
                if (c == -1 && b) {
                    if (this.updateNotifier != null) {
                        this.updateNotifier.notifyClearItems();
                    }
                }
                return c;
            }
            return -1;
        }
        cancelEdits() {
            if (this.aq()) {
                this.u.w(true, null);
                if (this.updateNotifier != null) {
                    this.updateNotifier.notifyClearItems();
                }
            }
        }
        acceptPendingCommit(a) {
            if (this.aq()) {
                let b = this.u.e(a);
                if (b != null) {
                    this.u.u(a);
                    if (this.updateNotifier != null) {
                        for (let c = 0; c < b.a.length; c++) {
                            if (b.a[c].transactionType != 0) {
                                let d = b.a[c].id;
                                let e = this.indexOfKey(d);
                                if (e > -1) {
                                    let f = this.getItemAtIndex(e);
                                    this.updateNotifier.notifySetItem(e, f, f);
                                }
                            }
                        }
                    }
                }
            }
        }
        rejectPendingCommit(a) {
            if (this.aq()) {
                let b = this.u.e(a);
                if (b != null) {
                    this.u.ac(a);
                    if (this.updateNotifier != null) {
                        for (let c = 0; c < b.a.length; c++) {
                            if (b.a[c].transactionType != 0) {
                                let d = b.a[c].id;
                                let e = this.indexOfKey(d);
                                if (e > -1) {
                                    let f = this.getItemAtIndex(e);
                                    this.updateNotifier.notifySetItem(e, f, f);
                                }
                            }
                        }
                    }
                }
            }
        }
        undo() {
            if (this.aq()) {
                this.u.ae();
            }
        }
        redo() {
            if (this.aq()) {
                this.u.ab();
            }
        }
        hasEdit(a, b) {
            if (this.aq()) {
                a = this.f(a);
                let c = this.u.g(a);
                if (c != null) {
                    let d = typeCast(Dictionary$2.$.specialize(String_$type, Base.$), c.value);
                    if (d != null && d.containsKey(b)) {
                        return true;
                    }
                }
                c = this.u.ah(a);
                if (c != null) {
                    let e = typeCast(Dictionary$2.$.specialize(String_$type, Base.$), c.value);
                    if (e != null && e.containsKey(b)) {
                        return true;
                    }
                }
                c = this.u.ag(a);
                if (c != null) {
                    let f = typeCast(Dictionary$2.$.specialize(String_$type, Base.$), c.value);
                    if (f != null && f.containsKey(b)) {
                        return true;
                    }
                }
            }
            return false;
        }
        hasDelete(a) {
            if (this.aq()) {
                a = this.f(a);
                let b = this.u.g(a);
                if (b != null && b.transactionType == TransactionType.Delete) {
                    return true;
                }
                b = this.u.ah(a);
                if (b != null && b.transactionType == TransactionType.Delete) {
                    return true;
                }
                b = this.u.ag(a);
                if (b != null && b.transactionType == TransactionType.Delete) {
                    return true;
                }
            }
            return false;
        }
        hasAdd(a) {
            if (this.aq()) {
                let b = this.u.g(a);
                if (b != null && b.transactionType == 0) {
                    return true;
                }
                b = this.u.ah(a);
                if (b != null && b.transactionType == 0) {
                    return true;
                }
            }
            return false;
        }
        getAggregatedChanges(a) {
            if (this.aq()) {
                let b = this.u.a(a);
                let c = new List$1(DataSourceAggregatedResult.$, 0);
                for (let d = 0; d < b.length; d++) {
                    let e = b[d].id;
                    let f = new DataSourceAggregatedResult();
                    if (b[d].transactionType == 0) {
                        f.transactionType = 0;
                        f.item = e[0];
                    }
                    else if (b[d].transactionType == TransactionType.Delete) {
                        f.transactionType = TransactionType.Delete;
                        let g = this.indexOfKey(e);
                        if (g > -1) {
                            f.item = this.getItemAtIndex(g);
                        }
                        else {
                            f.item = e;
                        }
                    }
                    else if (b[d].transactionType == 1) {
                        f.transactionType = 1;
                        let h = b[d].value;
                        f.keys = new Array(h.count);
                        f.values = new Array(h.count);
                        let i = 0;
                        for (let j of fromEnum(h)) {
                            f.keys[i] = j.key;
                            f.values[i] = j.value;
                            i++;
                        }
                        let k = this.getItemFromKey(e);
                        if (k != null) {
                            f.item = k;
                        }
                        else {
                            f.item = e;
                        }
                    }
                    c.add(f);
                }
                return c.toArray();
            }
            return new Array(0);
        }
        isPendingTransaction(a) {
            return this.u.d(a) != null;
        }
        isPendingCommit(a) {
            return this.u.e(a) != null;
        }
        setTransactionError(a, b) {
            let c = this.u.d(a);
            if (c != null) {
                c.error = b;
                if (this.updateNotifier != null) {
                    let d = c.id;
                    let e = this.indexOfKey(d);
                    if (e > -1) {
                        let f = this.getItemAtIndex(e);
                        this.updateNotifier.notifySetItem(e, f, f);
                    }
                }
            }
        }
        getTransactionErrorByKey(a, b) {
            a = this.f(a);
            let c = this.u.c(a);
            for (let d = 0; d < c.length; d++) {
                if (c[d].error != null) {
                    if (c[d].type == 1) {
                        let e = c[d].value;
                        if (e.containsKey(b)) {
                            return c[d].error;
                        }
                    }
                }
            }
            return null;
        }
        getTransactionErrorByID(a) {
            let b = this.u.d(a);
            if (b != null) {
                return b.error;
            }
            return null;
        }
        getTransactionID(a, b) {
            a = this.f(a);
            let c = this.u.c(a);
            for (let d = 0; d < c.length; d++) {
                if (c[d].type == 1) {
                    let e = c[d].value;
                    if (e.containsKey(b)) {
                        return c[d].transactionID;
                    }
                }
            }
            return -1;
        }
        f(a) {
            if (a.length == 1 && typeCast(DataSourceSpecialRow.$, a[0]) !== null) {
                let b = typeCast(DataSourceSpecialRow.$, a[0]);
                if (b.rowType == 3) {
                    if (this.actualPrimaryKey != null) {
                        a = new Array(this.actualPrimaryKey.length);
                        this.getPrimaryKeyValue(b.targetRow, a);
                    }
                    else {
                        a = [b.targetRow];
                    }
                }
            }
            return a;
        }
        b0(a, b) {
            if (this.dataCommitted != null) {
                this.dataCommitted(this, new DataSourceDataCommittedEventArgs(a, b));
            }
        }
        static ba(a) {
            let b = Localization.d("DataVisualization");
            let c = stringFormat("DataVisualization-{0}", b);
            return Localization.isRegistered(c) ? Localization.getString(c, a) : null;
        }
        ct(a, b) {
            this.onSortDescriptionsChanged(b);
        }
        bx(a, b) {
            this.onGroupDescriptionsChanged(b);
        }
        cu(a, b) {
            this.onSummaryDescriptionsChanged(b);
        }
        bv(a, b) {
            this.onFilterExpressionsChanged(b);
        }
        onSortDescriptionsChanged(a) {
            this.queueAutoRefresh();
        }
        onGroupDescriptionsChanged(a) {
            if (this.isGroupingSupported) {
                if (this.groupDescriptions != null && this.groupDescriptions.k.count > 0) {
                    this.ap = true;
                }
                else {
                    this.ap = false;
                }
                this.queueAutoRefresh();
            }
        }
        onSummaryDescriptionsChanged(a) {
            this.queueAutoRefresh();
        }
        onFilterExpressionsChanged(a) {
            this.queueAutoRefresh();
        }
        onRowExpansionChanged(a, b, c) {
            if (this.rowExpansionChanged != null) {
                this.rowExpansionChanged(this, new DataSourceRowExpansionChangedEventArgs(a, b, c));
            }
        }
        isPlaceholderItem(a) {
            return false;
        }
        get externalDataSource() {
            return this._externalDataSource;
        }
        set externalDataSource(a) {
            this._externalDataSource = a;
        }
        get actualSchema() {
            return this.o;
        }
        set actualSchema(a) {
            let b = this.o;
            this.o = a;
            if (b != this.o) {
                this.onPropertyUpdated("ActualSchema", b, this.o);
            }
        }
        get actualCount() {
            return this.at;
        }
        set actualCount(a) {
            let b = this.at;
            this.at = a;
            if (b != this.at) {
                this.onPropertyUpdated("ActualCount", b, this.at);
            }
        }
        get firstVisibleIndexRequested() {
            return this.au;
        }
        set firstVisibleIndexRequested(a) {
            let b = this.au;
            this.au = a;
            if (b != this.au) {
                this.onPropertyUpdated("FirstVisibleIndexRequested", b, this.au);
            }
        }
        get lastVisibleIndexRequested() {
            return this.av;
        }
        set lastVisibleIndexRequested(a) {
            let b = this.av;
            this.av = a;
            if (b != this.av) {
                this.onPropertyUpdated("LastVisibleIndexRequested", b, this.av);
            }
        }
        get updateNotifier() {
            return this.p;
        }
        set updateNotifier(a) {
            let b = this.p;
            this.p = a;
            if (b != this.p) {
                this.onPropertyUpdated("UpdateNotifier", b, this.p);
            }
        }
        getItemAtIndex(a) {
            return null;
        }
        getItemFromKey(a) {
            return null;
        }
        getItemProperty(a, b) {
            if (this.actualBaseDataProvider != null) {
                let item_ = a;
                if ((item_ != null && item_.$$isSpecialRow !== undefined)) {
                    return this.getSpecialRowItemValue(a, b);
                }
                return this.actualBaseDataProvider.getItemValue(a, b);
            }
            return null;
        }
        getSpecialRowItemValue(a, b) {
            if (a.rowType == 3) {
                if (this.aq()) {
                    let c = this.a1(a.targetRow, b);
                    if (c != null) {
                        return c;
                    }
                }
                return this.getItemProperty(a.targetRow, b);
            }
            return a.getSectionValue(b);
        }
        a1(a, b) {
            let c;
            if (this.actualPrimaryKey == null || this.actualPrimaryKey.length < 1) {
                c = [a];
            }
            else {
                c = new Array(this.actualPrimaryKey.length);
                this.getPrimaryKeyValue(a, c);
            }
            let d = this.u.g(c);
            if (d != null && d.transactionType == 1) {
                let e = d.value;
                if (e.containsKey(b)) {
                    return e.item(b);
                }
            }
            d = this.u.ah(c);
            if (d != null && d.transactionType == 1) {
                let f = d.value;
                if (f.containsKey(b)) {
                    return f.item(b);
                }
            }
            d = this.u.ag(c);
            if (d != null && d.transactionType == 1) {
                let g = d.value;
                if (g.containsKey(b)) {
                    return g.item(b);
                }
            }
            return null;
        }
        an(a, b) {
            let c;
            if (this.actualPrimaryKey == null || this.actualPrimaryKey.length < 1) {
                c = [a];
            }
            else {
                c = new Array(this.actualPrimaryKey.length);
                this.getPrimaryKeyValue(a, c);
            }
            let d = this.u.g(c);
            if (d != null && d.transactionType == 1) {
                let e = d.value;
                if (e.containsKey(b)) {
                    return true;
                }
            }
            d = this.u.ah(c);
            if (d != null && d.transactionType == 1) {
                let f = d.value;
                if (f.containsKey(b)) {
                    return true;
                }
            }
            d = this.u.ag(c);
            if (d != null && d.transactionType == 1) {
                let g = d.value;
                if (g.containsKey(b)) {
                    return true;
                }
            }
            return false;
        }
        getItemPropertyAtIndex(a, b) {
            return null;
        }
        get_fullSectionInformationWillForceLoad() {
            return false;
        }
        get fullSectionInformationWillForceLoad() {
            return this.get_fullSectionInformationWillForceLoad();
        }
        onPropertyUpdated(a, b, c) {
            if (this.propertyChanged != null) {
                this.propertyChanged(this, new PropertyChangedEventArgs(a));
            }
            this.propertyUpdatedOverride(a, b, c);
        }
        propertyUpdatedOverride(a, b, c) {
            switch (a) {
                case "PrimaryKey":
                    this.actualPrimaryKey = this.primaryKey;
                    break;
                case "ActualPrimaryKey":
                    this.onActualPrimaryKeyChanged(b, c);
                    break;
                case "ExecutionContext":
                    if (this.actualBaseDataProvider != null) {
                        this.actualBaseDataProvider.executionContext = this.executionContext;
                    }
                    this.queueAutoRefresh();
                    break;
                case "LastVisibleIndexRequested":
                case "FirstVisibleIndexRequested":
                    this.onRequestedVisibleRangeChanged();
                    break;
                case "ActualDataProvider":
                    this.onActualDataProviderChanged(b, c);
                    break;
                case "DeferAutoRefresh":
                    if (this.actualBaseDataProvider != null) {
                        this.actualBaseDataProvider.deferAutoRefresh = this.deferAutoRefresh;
                    }
                    if (!c) {
                        this.queueAutoRefresh();
                    }
                    break;
                case "PropertiesRequested":
                    if (this.actualBaseDataProvider != null) {
                        this.actualBaseDataProvider.propertiesRequested = this.propertiesRequested;
                    }
                    break;
                case "ShouldEmitSectionFooters":
                case "ShouldEmitSectionHeaders":
                case "ShouldEmitShiftedRows":
                case "SectionHeaderDisplayMode":
                case "IsSectionCollapsable":
                case "IncludeSummaryRowsInSection":
                case "IsSectionSummaryRowsAtBottom":
                case "IsSectionContentVisible":
                    this.queueAutoRefresh();
                    break;
                case "SummaryScope":
                    if (this.actualBaseDataProvider != null) {
                        this.actualBaseDataProvider.summaryScope = this.summaryScope;
                    }
                    this.queueAutoRefresh();
                    break;
            }
        }
        onActualPrimaryKeyChanged(a, b) {
            this.onActualPrimaryKeyChangedOverrride(a, b);
        }
        onActualPrimaryKeyChangedOverrride(a, b) {
        }
        get_isVirtual() {
            return false;
        }
        get isVirtual() {
            return this.get_isVirtual();
        }
        get dataProviderUpdateNotifier() {
            return this.l;
        }
        onActualDataProviderChanged(a, b) {
            let c = a;
            let d = b;
            if (c != null) {
                c.updateNotifier = null;
            }
            if (d != null) {
                d.updateNotifier = this.l;
            }
            if (c != null) {
                c.schemaChanged = delegateRemove(c.schemaChanged, runOn(this, this.br));
            }
            if (d != null) {
                d.schemaChanged = delegateCombine(d.schemaChanged, runOn(this, this.br));
                d.executionContext = this.executionContext;
                this.notifyUsingSourceIndexes = this.actualBaseDataProvider.notifyUsingSourceIndexes;
            }
            else {
                this.notifyUsingSourceIndexes = false;
            }
            if (c != null) {
                this.sortDescriptions.syncTarget = null;
                this.groupDescriptions.syncTarget = null;
                this.filterExpressions.syncTarget = null;
                this.summaryDescriptions.syncTarget = null;
            }
            if (d != null) {
                this.sortDescriptions.syncTarget = d.sortDescriptions;
                this.groupDescriptions.syncTarget = d.groupDescriptions;
                this.filterExpressions.syncTarget = d.filterExpressions;
                this.summaryDescriptions.syncTarget = d.summaryDescriptions;
                if (this.propertiesRequested != null) {
                    d.propertiesRequested = this.propertiesRequested;
                }
                d.summaryScope = this.summaryScope;
            }
            this.queueAutoRefresh();
        }
        onRequestedVisibleRangeChanged() {
        }
        get executionContext() {
            return this.n;
        }
        set executionContext(a) {
            let b = this.n;
            this.n = a;
            if (this.n != b) {
                this.onPropertyUpdated("ExecutionContext", b, this.n);
            }
        }
        canInitialize() {
            if (this.n != null && this.actualBaseDataProvider != null) {
                return true;
            }
            return false;
        }
        get isInitializing() {
            return this.aa;
        }
        get_isSortingSupported() {
            return false;
        }
        get isSortingSupported() {
            return this.get_isSortingSupported();
        }
        get_isFilteringSupported() {
            return false;
        }
        get isFilteringSupported() {
            return this.get_isFilteringSupported();
        }
        get sortDescriptions() {
            return this.s;
        }
        get groupDescriptions() {
            return this.r;
        }
        get filterExpressions() {
            return this.i;
        }
        get summaryDescriptions() {
            return this.t;
        }
        get summaryScope() {
            return this.h;
        }
        set summaryScope(a) {
            let b = this.h;
            this.h = a;
            if (this.h != b) {
                this.onPropertyUpdated("SummaryScope", enumGetBox(DataSourceSummaryScope_$type, b), enumGetBox(DataSourceSummaryScope_$type, this.h));
            }
        }
        get deferAutoRefresh() {
            return this.x;
        }
        set deferAutoRefresh(a) {
            let b = this.x;
            this.x = a;
            if (this.x != b) {
                this.onPropertyUpdated("DeferAutoRefresh", b, this.x);
            }
        }
        get primaryKey() {
            return this.b;
        }
        set primaryKey(a) {
            let b = this.b;
            this.b = a;
            if (this.b != b) {
                this.onPropertyUpdated("PrimaryKey", b, this.b);
            }
        }
        get actualPrimaryKey() {
            return this.a;
        }
        set actualPrimaryKey(a) {
            let b = this.a;
            this.a = a;
            if (this.a != b) {
                this.onPropertyUpdated("ActualPrimaryKey", b, this.a);
            }
        }
        get propertiesRequested() {
            return this.c;
        }
        set propertiesRequested(a) {
            let b = this.c;
            this.c = a;
            if (this.c != b) {
                this.onPropertyUpdated("PropertiesRequested", b, this.c);
            }
        }
        get notifyUsingSourceIndexes() {
            return this.ag;
        }
        set notifyUsingSourceIndexes(a) {
            let b = this.ag;
            this.ag = a;
            if (this.ag != b) {
                this.onPropertyUpdated("NotifyUsingSourceIndexes", b, this.ag);
            }
        }
        get_isItemIndexLookupSupported() {
            return false;
        }
        get isItemIndexLookupSupported() {
            return this.get_isItemIndexLookupSupported();
        }
        get_isKeyIndexLookupSupported() {
            return false;
        }
        get isKeyIndexLookupSupported() {
            return this.get_isKeyIndexLookupSupported();
        }
        initializeOverride() {
        }
        resolveFullCount(a) {
            return a;
        }
        br(a, b) {
            let c = this.executionContext;
            c.execute(() => {
                this.ah = true;
                this.w = true;
                this.queueAutoRefresh();
                if (this.deferAutoRefresh) {
                    this.actualSchema = b.schema;
                    this.actualCount = this.resolveFullCount(b.count);
                    this.b1();
                }
            });
        }
        b1() {
            if (this.schemaChanged != null) {
                this.schemaChanged(this, new DataSourceSchemaChangedEventArgs(this.actualSchema, this.actualCount));
            }
        }
        onSetItem(a, b, c) {
            this.onSetItemOverride(a, b, c);
        }
        onBroadcastSetItem(a, b, c) {
            if (this.updateNotifier != null) {
                this.updateNotifier.notifySetItem(a, b, c);
            }
        }
        onSetItemOverride(a, b, c) {
            if (this.actualBaseDataProvider != null) {
                this.actualCount = this.resolveFullCount(this.actualBaseDataProvider.actualCount);
            }
            this.onBroadcastSetItem(a, b, c);
        }
        onClearItems() {
            this.onClearItemsOverride();
        }
        onBroadcastClearItems() {
            if (this.updateNotifier != null) {
                this.updateNotifier.notifyClearItems();
            }
        }
        onClearItemsOverride() {
            if (this.actualBaseDataProvider != null) {
                this.actualCount = this.resolveFullCount(this.actualBaseDataProvider.actualCount);
            }
            this.onBroadcastClearItems();
        }
        onInsertItem(a, b) {
            this.onInsertItemOverride(a, b);
        }
        onBroadcastInsertItem(a, b) {
            if (this.updateNotifier != null) {
                this.updateNotifier.notifyInsertItem(a, b);
            }
        }
        onInsertItemOverride(a, b) {
            if (this.actualBaseDataProvider != null) {
                this.actualCount = this.resolveFullCount(this.actualBaseDataProvider.actualCount);
            }
            this.onBroadcastInsertItem(a, b);
        }
        onRemoveItem(a, b) {
            this.onRemoveItemOverride(a, b);
        }
        onBroadcastRemoveItem(a, b) {
            if (this.updateNotifier != null) {
                this.updateNotifier.notifyRemoveItem(a, b);
            }
        }
        onRemoveItemOverride(a, b) {
            if (this.actualBaseDataProvider != null) {
                this.actualCount = this.resolveFullCount(this.actualBaseDataProvider.actualCount);
            }
            this.onBroadcastRemoveItem(a, b);
        }
        notifySetItem(a, b, c) {
            if (this.actualBaseDataProvider != null) {
                this.actualBaseDataProvider.notifySetItem(a, b, c);
            }
        }
        notifyClearItems() {
            if (this.actualBaseDataProvider != null) {
                this.actualBaseDataProvider.notifyClearItems();
            }
        }
        notifyInsertItem(a, b) {
            if (this.actualBaseDataProvider != null) {
                this.actualBaseDataProvider.notifyInsertItem(a, b);
            }
            ;
        }
        notifyRemoveItem(a, b) {
            if (this.actualBaseDataProvider != null) {
                this.actualBaseDataProvider.notifyRemoveItem(a, b);
            }
            ;
        }
        queueAutoRefresh() {
            if (this.deferAutoRefresh) {
                return;
            }
            if (this.actualBaseDataProvider != null) {
                this.actualBaseDataProvider.queueAutoRefresh();
            }
            if (this.v) {
                return;
            }
            if (this.executionContext != null) {
                this.v = true;
                this.executionContext.enqueueAction(runOn(this, this.bt));
            }
        }
        bt() {
            if (this.deferAutoRefresh) {
                this.v = false;
                return;
            }
            if (this.actualBaseDataProvider != null) {
                this.actualBaseDataProvider.flushAutoRefresh();
            }
            if (!this.v) {
                return;
            }
            this.v = false;
            this.cr();
        }
        cr() {
            if (this.actualBaseDataProvider != null) {
                this.actualSchema = this.actualBaseDataProvider.actualSchema;
                this.actualCount = this.resolveFullCount(this.actualBaseDataProvider.actualCount);
            }
            if (this.actualSchema != null && this.primaryKey == null) {
                this.actualPrimaryKey = this.actualSchema.primaryKey;
            }
            this.refreshInternalOverride();
            if (this.ah) {
                this.ah = false;
                this.b1();
            }
        }
        refreshInternalOverride() {
        }
        flushAutoRefresh() {
            this.bt();
        }
        refresh() {
            if (this.actualBaseDataProvider != null) {
                this.actualBaseDataProvider.refresh();
            }
            this.cr();
        }
        indexOfItem(a) {
            return -1;
        }
        indexOfKey(a) {
            return -1;
        }
        getPrimaryKeyValue(a, b) {
            let c = this.actualPrimaryKey;
            if (c == null || c.length < 1 || this.actualBaseDataProvider == null) {
                return;
            }
            for (let d = 0; d < c.length; d++) {
                b[d] = this.actualBaseDataProvider.getItemValue(a, c[d]);
            }
        }
        getRowType(a) {
            return 0;
        }
        getMainValuePath(a) {
            return "SectionInformation";
        }
        getStickyRows() {
            return this.getStickyRowsInRange(this.firstVisibleIndexRequested, this.lastVisibleIndexRequested);
        }
        getStickyRowsInRange(a, b) {
            return null;
        }
        isRowSpanning(a) {
            return a == 1 || a == 2;
        }
        getStickyRowPriority(a) {
            return -1;
        }
        isExclusivelySticky(a) {
            return false;
        }
        pinRow(a) {
        }
        unpinRow(a) {
        }
        clearPinnedRows() {
        }
        isRowPinned(a) {
            return false;
        }
        get_isGroupingSupported() {
            return false;
        }
        get isGroupingSupported() {
            return this.get_isGroupingSupported();
        }
        get_sectionHeaderDisplayMode() {
            return this.g;
        }
        set_sectionHeaderDisplayMode(a) {
            let b = this.g;
            this.g = a;
            if (b != this.g) {
                this.onPropertyUpdated("SectionHeaderDisplayMode", enumGetBox(DataSourceSectionHeaderDisplayMode_$type, b), enumGetBox(DataSourceSectionHeaderDisplayMode_$type, this.g));
            }
        }
        get sectionHeaderDisplayMode() {
            return this.get_sectionHeaderDisplayMode();
        }
        set sectionHeaderDisplayMode(a) {
            this.set_sectionHeaderDisplayMode(a);
        }
        get_isSectionCollapsable() {
            return this.ab;
        }
        set_isSectionCollapsable(a) {
            let b = this.ab;
            this.ab = a;
            if (this.ab != b) {
                this.onPropertyUpdated("IsSectionCollapsable", b, this.ab);
            }
        }
        get isSectionCollapsable() {
            return this.get_isSectionCollapsable();
        }
        set isSectionCollapsable(a) {
            this.set_isSectionCollapsable(a);
        }
        get_isSectionExpandedDefault() {
            return this.ad;
        }
        set_isSectionExpandedDefault(a) {
            this.ad = a;
        }
        get isSectionExpandedDefault() {
            return this.get_isSectionExpandedDefault();
        }
        set isSectionExpandedDefault(a) {
            this.set_isSectionExpandedDefault(a);
        }
        get_includeSummaryRowsInSection() {
            return this.y;
        }
        set_includeSummaryRowsInSection(a) {
            let b = this.y;
            this.y = a;
            if (this.y != b) {
                this.onPropertyUpdated("IncludeSummaryRowsInSection", b, this.y);
            }
        }
        get includeSummaryRowsInSection() {
            return this.get_includeSummaryRowsInSection();
        }
        set includeSummaryRowsInSection(a) {
            this.set_includeSummaryRowsInSection(a);
        }
        get_isSectionSummaryRowsAtBottom() {
            return this.af;
        }
        set_isSectionSummaryRowsAtBottom(a) {
            let b = this.af;
            this.af = a;
            if (this.af != b) {
                this.onPropertyUpdated("IsSectionSummaryRowsAtBottom", b, this.af);
            }
        }
        get isSectionSummaryRowsAtBottom() {
            return this.get_isSectionSummaryRowsAtBottom();
        }
        set isSectionSummaryRowsAtBottom(a) {
            this.set_isSectionSummaryRowsAtBottom(a);
        }
        get_isSectionHeaderNormalRow() {
            return this.ae;
        }
        set_isSectionHeaderNormalRow(a) {
            let b = this.ae;
            this.ae = a;
            if (this.ae != b) {
                this.onPropertyUpdated("IsSectionHeaderNormalRow", b, this.ae);
            }
        }
        get isSectionHeaderNormalRow() {
            return this.get_isSectionHeaderNormalRow();
        }
        set isSectionHeaderNormalRow(a) {
            this.set_isSectionHeaderNormalRow(a);
        }
        get_isSectionContentVisible() {
            return this.ac;
        }
        set_isSectionContentVisible(a) {
            let b = this.ac;
            this.ac = a;
            if (this.ac != b) {
                this.onPropertyUpdated("IsSectionContentVisible", b, this.ac);
            }
        }
        get isSectionContentVisible() {
            return this.get_isSectionContentVisible();
        }
        set isSectionContentVisible(a) {
            this.set_isSectionContentVisible(a);
        }
        get shouldEmitSectionHeaders() {
            return this.aj;
        }
        set shouldEmitSectionHeaders(a) {
            let b = this.aj;
            this.aj = a;
            if (this.aj != b) {
                this.onPropertyUpdated("ShouldEmitSectionHeaders", b, this.aj);
            }
        }
        get shouldEmitSectionFooters() {
            return this.ai;
        }
        set shouldEmitSectionFooters(a) {
            let b = this.ai;
            this.ai = a;
            if (this.ai != b) {
                this.onPropertyUpdated("ShouldEmitSectionFooters", b, this.ai);
            }
        }
        get shouldEmitShiftedRows() {
            return this.ak;
        }
        set shouldEmitShiftedRows(a) {
            let b = this.ak;
            this.ak = a;
            if (this.ak != b) {
                this.onPropertyUpdated("ShouldEmitShiftedRows", b, this.ak);
            }
        }
        get shouldEmitSummaryRows() {
            return this.al;
        }
        set shouldEmitSummaryRows(a) {
            let b = this.al;
            this.al = a;
            if (this.al != b) {
                this.onPropertyUpdated("ShouldEmitSummaryRows", b, this.al);
            }
        }
        ensureComparables(a) {
            if (this.w && this.actualCount > 0 && this.actualBaseDataProvider != null) {
                let b = null;
                this.d = this.e(a, b);
                this.w = false;
            }
        }
        e(a, b) {
            let c = new Array(a.propertyNames.length);
            return c;
        }
        resolveSchemaPropertyType(a) {
            return this.actualBaseDataProvider.resolveSchemaPropertyType(a);
        }
        setIsRowExpandedAtIndex(a, b) {
        }
        getIsRowExpandedAtIndex(a) {
            return true;
        }
        getRowLevel(a) {
            return 0;
        }
        getRootSummaryRowCount() {
            return 0;
        }
        getRootSummaryResults() {
            return null;
        }
        getSectionSummaryResults(a) {
            return null;
        }
        clone() {
            return null;
        }
        cloneProperties(a) {
            let b = typeCast(BaseDataSource.$, a);
            if (b != null) {
                b.executionContext = this.executionContext;
                b.includeSummaryRowsInSection = this.includeSummaryRowsInSection;
                b.isSectionCollapsable = this.isSectionCollapsable;
                b.isSectionExpandedDefault = this.isSectionExpandedDefault;
                b.isSectionHeaderNormalRow = this.isSectionHeaderNormalRow;
                b.isSectionSummaryRowsAtBottom = this.isSectionSummaryRowsAtBottom;
                b.isSectionContentVisible = this.isSectionContentVisible;
                b.primaryKey = this.primaryKey;
                b.propertiesRequested = this.propertiesRequested;
                b.sectionHeaderDisplayMode = this.sectionHeaderDisplayMode;
                b.shouldEmitSectionFooters = this.shouldEmitSectionFooters;
                b.shouldEmitSectionHeaders = this.shouldEmitSectionHeaders;
                b.shouldEmitShiftedRows = this.shouldEmitShiftedRows;
                b.summaryScope = this.summaryScope;
                for (let c = 0; c < this.groupDescriptions.k.count; c++) {
                    b.groupDescriptions.add(this.groupDescriptions.k.item(c));
                }
                for (let d = 0; d < this.sortDescriptions.k.count; d++) {
                    b.sortDescriptions.add(this.sortDescriptions.k.item(d));
                }
                for (let e = 0; e < this.filterExpressions.k.count; e++) {
                    b.filterExpressions.add(this.filterExpressions.k.item(e));
                }
                for (let f = 0; f < this.summaryDescriptions.k.count; f++) {
                    b.summaryDescriptions.add(this.summaryDescriptions.k.item(f));
                }
            }
        }
        getRowCount() {
            return this.actualCount;
        }
    }
    BaseDataSource.$t = markType(BaseDataSource, 'BaseDataSource', Base.$, [IDataSource_$type, IEditableDataSource_$type]);
    return BaseDataSource;
})();
/**
 * @hidden
 */
export let DefaultDataSourceDataProviderUpdateNotifier = /*@__PURE__*/ (() => {
    class DefaultDataSourceDataProviderUpdateNotifier extends Base {
        constructor(a) {
            super();
            this.a = null;
            this.a = a;
        }
        notifySetItem(a, b, c) {
            this.a.onSetItem(a, b, c);
        }
        notifyClearItems() {
            this.a.onClearItems();
        }
        notifyInsertItem(a, b) {
            this.a.onInsertItem(a, b);
        }
        notifyRemoveItem(a, b) {
            this.a.onRemoveItem(a, b);
        }
    }
    DefaultDataSourceDataProviderUpdateNotifier.$t = markType(DefaultDataSourceDataProviderUpdateNotifier, 'DefaultDataSourceDataProviderUpdateNotifier', Base.$, [IDataSourceDataProviderUpdateNotifier_$type]);
    return DefaultDataSourceDataProviderUpdateNotifier;
})();
