/*
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 { MarkerManagerBase } from "./MarkerManagerBase";
import { Base, Point_$type, Number_$type, fromEnum, markType } from "igniteui-react-core/ES5/type";
import { Marker } from "./Marker";
import { OwnedPoint } from "./OwnedPoint";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { SmartPlacer } from "igniteui-react-core/ES5/SmartPlacer";
import { SmartPlaceableWrapper$1 } from "igniteui-react-core/ES5/SmartPlaceableWrapper$1";
import { boxArray$1 } from "igniteui-react-core/ES5/array";
import { CompareUtil } from "igniteui-react-core/ES5/compareUtil";
/**
 * @hidden
 */
var NumericMarkerManager = /** @class */ (function (_super) {
    tslib_1.__extends(NumericMarkerManager, _super);
    function NumericMarkerManager(a) {
        var _rest = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            _rest[_i - 1] = arguments[_i];
        }
        var _this = this;
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0:
                {
                    var c = _rest[0];
                    var d = _rest[1];
                    var e = _rest[2];
                    var f = _rest[3];
                    var g = _rest[4];
                    var h = [c, d, e, f, g, function () { return 0; }];
                    {
                        var j = h[0];
                        var k = h[1];
                        var l = h[2];
                        var m = h[3];
                        var n = h[4];
                        var o = h[5];
                        _this = _super.call(this, j, k, l, m, n) || this;
                        _this.n = false;
                        _this.p = null;
                        _this.o = null;
                        _this.q = null;
                        _this.m = null;
                        _this.n = false;
                        _this.p = function (p) { return ({ $type: Point_$type, x: 0, y: 0 }); };
                        _this.o = o;
                    }
                }
                break;
            case 1:
                {
                    var c = _rest[0];
                    var d = _rest[1];
                    var e = _rest[2];
                    var f = _rest[3];
                    var g = _rest[4];
                    var h = _rest[5];
                    _this = _super.call(this, c, d, e, f, g) || this;
                    _this.n = false;
                    _this.p = null;
                    _this.o = null;
                    _this.q = null;
                    _this.m = null;
                    _this.n = false;
                    _this.p = function (i) { return ({ $type: Point_$type, x: 0, y: 0 }); };
                    _this.o = h;
                }
                break;
        }
        return _this;
    }
    NumericMarkerManager.prototype.l = function (a, b, c, d, e) {
        var f = this.f();
        a.clear();
        var g = new List$1(Number_$type, 0);
        b = Math.max(0, b);
        var h = null;
        this.i(c, d, boxArray$1(f), g);
        if (b >= g.count) {
            h = g;
        }
        else {
            h = new List$1(Number_$type, 0);
            var i = Math.max(8, e);
            var j = this.c(d, g, i, boxArray$1(f));
            var k = new List$1(Number_$type, 1, j.keys);
            if (MarkerManagerBase.b) {
                k.y();
            }
            this.k(b, j, k, h);
        }
        this.r(a, f, h);
    };
    NumericMarkerManager.prototype.r = function (a, b, c) {
        for (var d = 0; d < c.count; ++d) {
            var e = c._inner[d];
            var f = b[e];
            var g = this.g(e);
            var h = this.h(g);
            if (h.content != null) {
                h.content.item = g;
            }
            var i = new OwnedPoint();
            if (this.n) {
                i.b = this.p(e);
            }
            i.a = g;
            i.c = { $type: Point_$type, x: f.x, y: f.y };
            if (!a.containsKey(g)) {
                a.addItem(g, i);
            }
        }
    };
    NumericMarkerManager.prototype.j = function (a, b) {
        var e_1, _a;
        var c = a.keys;
        if (MarkerManagerBase.b) {
            var d = new List$1(Base.$, 1, a.keys);
            d.aa(function (e, f) {
                var g = a.item(e);
                var h = a.item(f);
                var i = Math.pow(g.c.x, 2) + Math.pow(g.c.y, 2);
                var j = Math.pow(h.c.x, 2) + Math.pow(h.c.y, 2);
                return CompareUtil.compareToObject(i, j);
            });
            c = d;
        }
        var e = null;
        var f = null;
        switch (this.o()) {
            case 0: break;
            case 1:
                e = ((function () {
                    var $ret = new SmartPlacer();
                    $ret.c = 0.3;
                    $ret.b = 0;
                    return $ret;
                })());
                f = new SmartPlaceableWrapper$1(Marker.$);
                f.f = true;
                break;
            case 2:
                e = ((function () {
                    var $ret = new SmartPlacer();
                    $ret.c = 0.6;
                    $ret.b = 2;
                    return $ret;
                })());
                f = new SmartPlaceableWrapper$1(Marker.$);
                f.f = true;
                break;
            case 3:
                e = ((function () {
                    var $ret = new SmartPlacer();
                    $ret.c = 0.3;
                    $ret.b = 0;
                    return $ret;
                })());
                f = new SmartPlaceableWrapper$1(Marker.$);
                break;
            case 4:
                e = ((function () {
                    var $ret = new SmartPlacer();
                    $ret.c = 0.6;
                    $ret.b = 2;
                    return $ret;
                })());
                f = new SmartPlaceableWrapper$1(Marker.$);
                break;
        }
        try {
            for (var _b = tslib_1.__values(fromEnum(c)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var g = _c.value;
                var h = a.item(g);
                var i = this.h(h.a);
                if (e != null && f != null) {
                    f.d = i;
                    f.j = this.q(i);
                    f.i = h.c;
                    e.d(f);
                    if (f.opacity == 0) {
                        f.smartPosition = f.smartPosition;
                    }
                    h.c = f.g;
                }
                else {
                    i._opacity = 1;
                    i._visibility = 0;
                }
                this.s(i, h, b);
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
            }
            finally { if (e_1) throw e_1.error; }
        }
        this.a(a);
    };
    NumericMarkerManager.prototype.s = function (a, b, c) {
        a.n = b.c.x;
        a.o = b.c.y;
    };
    NumericMarkerManager.$t = markType(NumericMarkerManager, 'NumericMarkerManager', MarkerManagerBase.$);
    return NumericMarkerManager;
}(MarkerManagerBase));
export { NumericMarkerManager };
