/*
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 { __extends, __values } from "tslib";
import { Base, Number_$type, fromEnum, markType } from "igniteui-angular-core";
import { Dictionary$2 } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
/**
 * @hidden
 */
var SliceSelectionManager = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(SliceSelectionManager, _super);
    function SliceSelectionManager() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.e = new Dictionary$2(Number_$type, Base.$, 0);
        return _this;
    }
    SliceSelectionManager.prototype.k = function (a, b) {
        if (this.e.containsKey(a)) {
            this.e.removeItem(a);
        }
        else {
            this.e.item(a, b);
        }
    };
    SliceSelectionManager.prototype.c = function (a) {
        return this.e.containsKey(a);
    };
    SliceSelectionManager.prototype.b = function () {
        return this.e.count > 0;
    };
    SliceSelectionManager.prototype.d = function (a) {
        return !this.c(a) && this.b();
    };
    SliceSelectionManager.prototype.g = function (a, b) {
        switch (a.c) {
            case 3: break;
            case 1:
                this.j(a.g, a.f);
                break;
            case 0:
                this.h(a.g, a.f);
                break;
            case 2:
                for (var c = 0; c < a.f; c++) {
                    if (this.e.containsKey(c)) {
                        this.e.item(c, b.a.item(c));
                    }
                }
                break;
            case 4:
                this.f();
                break;
        }
    };
    SliceSelectionManager.prototype.h = function (a, b) {
        var e_1, _a, e_2, _b;
        var c = new List$1(Number_$type, 0);
        var d = new List$1(Base.$, 0);
        try {
            for (var _c = __values(fromEnum(this.e.keys)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var e = _d.value;
                if (e >= a) {
                    c.add(e);
                    d.add1(this.e.item(e));
                }
            }
        }
        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;
            }
        }
        var f = 0;
        try {
            for (var _e = __values(fromEnum(c)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var g = _f.value;
                this.e.removeItem(g);
                if (g - b > a) {
                    this.e.item(g - b, d._inner[f]);
                }
                f++;
            }
        }
        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;
            }
        }
    };
    SliceSelectionManager.prototype.j = function (a, b) {
        var e_3, _a, e_4, _b;
        var c = new List$1(Number_$type, 0);
        var d = new List$1(Base.$, 0);
        try {
            for (var _c = __values(fromEnum(this.e.keys)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var e = _d.value;
                if (e >= a) {
                    c.add(e);
                    d.add1(this.e.item(e));
                }
            }
        }
        catch (e_3_1) {
            e_3 = { error: e_3_1 };
        }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return))
                    _a.call(_c);
            }
            finally {
                if (e_3)
                    throw e_3.error;
            }
        }
        var f = 0;
        try {
            for (var _e = __values(fromEnum(c)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var g = _f.value;
                this.e.removeItem(g);
                this.e.item(g + b, d._inner[f]);
                f++;
            }
        }
        catch (e_4_1) {
            e_4 = { error: e_4_1 };
        }
        finally {
            try {
                if (_f && !_f.done && (_b = _e.return))
                    _b.call(_e);
            }
            finally {
                if (e_4)
                    throw e_4.error;
            }
        }
    };
    SliceSelectionManager.prototype.f = function () {
        this.e.clear();
    };
    SliceSelectionManager.prototype.a = function () {
        var e_5, _a;
        var a = new Array(this.e.count);
        var b = 0;
        try {
            for (var _b = __values(fromEnum(this.e.keys)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var c = _c.value;
                a[b] = c;
                b++;
            }
        }
        catch (e_5_1) {
            e_5 = { error: e_5_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_5)
                    throw e_5.error;
            }
        }
        return a;
    };
    SliceSelectionManager.prototype.i = function (a, b) {
        this.f();
        for (var d = 0; d < a.length; d++) {
            var c = a[d];
            this.k(c, b.a.item(c));
        }
    };
    SliceSelectionManager.$t = markType(SliceSelectionManager, 'SliceSelectionManager');
    return SliceSelectionManager;
}(Base));
export { SliceSelectionManager };
//# sourceMappingURL=SliceSelectionManager.js.map
