/*
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 { IFlattener_$type } from "./IFlattener";
import { Base, Number_$type, Point_$type, markType } from "igniteui-react-core/ES5/type";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { Flattener } from "igniteui-react-core/ES5/Flattener";
import { FastFlattener } from "igniteui-react-core/ES5/FastFlattener";
import { RearrangedList$1 } from "igniteui-react-core/ES5/RearrangedList$1";
var DefaultFlattener = /** @class */ (function (_super) {
    tslib_1.__extends(DefaultFlattener, _super);
    function DefaultFlattener() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    DefaultFlattener.prototype.a = function (a, b, c, d, e, f) {
        var g = new List$1(Number_$type, 0);
        var h = d;
        var i = e;
        var j = i - h + 1;
        while (j > 0) {
            if (j <= 512) {
                Flattener.c(g, b, c, h, i, f);
                h = i + 1;
            }
            else {
                var k = h + 512 - 1;
                Flattener.c(g, b, c, h, k, f);
                h = k + 1;
            }
            j = i - h + 1;
        }
        return g;
    };
    DefaultFlattener.prototype.d = function (a, b, c, d, e) {
        var f = new List$1(Number_$type, 0);
        var g = c;
        var h = d;
        var i = h - g + 1;
        while (i > 0) {
            if (i <= 512) {
                FastFlattener.e(f, a, b, g, h, e);
                g = h + 1;
            }
            else {
                var j = g + 512 - 1;
                FastFlattener.e(f, a, b, g, j, e);
                g = j + 1;
            }
            i = h - g + 1;
        }
        return f;
    };
    DefaultFlattener.prototype.flatten = function (a, b) {
        var _this = this;
        var c = function (d) { return _this.f(a, d); };
        var d = function (e) { return _this.g(a, e); };
        return this.b(a, b, c, d);
    };
    DefaultFlattener.prototype.c = function (a, b, c, d) {
        return this.e(a, b, c, d);
    };
    DefaultFlattener.prototype.b = function (a, b, c, d) {
        var e = this.a(new List$1(Number_$type, 0), c, d, 0, a.count - 1, b);
        var f = new RearrangedList$1(Point_$type, a, e);
        return f;
    };
    DefaultFlattener.prototype.e = function (a, b, c, d) {
        var e = this.d(a, b, 0, c - 1, d);
        var f = new List$1(Point_$type, 0);
        for (var g = 0; g < e.count; g++) {
            f.add({ $type: Point_$type, x: a[e._inner[g]], y: b[e._inner[g]] });
        }
        return f;
    };
    DefaultFlattener.prototype.f = function (a, b) {
        return a.item(b).x;
    };
    DefaultFlattener.prototype.g = function (a, b) {
        return a.item(b).y;
    };
    DefaultFlattener.$t = markType(DefaultFlattener, 'DefaultFlattener', Base.$, [IFlattener_$type]);
    return DefaultFlattener;
}(Base));
export { DefaultFlattener };
