/*
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 { MarkerManagerBase } from "./MarkerManagerBase";
import { Base, Point_$type, Number_$type, fromEnum, markType } from "igniteui-react-core/ES2015/type";
import { Marker } from "./Marker";
import { OwnedPoint } from "./OwnedPoint";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
import { SmartPlacer } from "igniteui-react-core/ES2015/SmartPlacer";
import { SmartPlaceableWrapper$1 } from "igniteui-react-core/ES2015/SmartPlaceableWrapper$1";
import { boxArray$1 } from "igniteui-react-core/ES2015/array";
import { CompareUtil } from "igniteui-react-core/ES2015/compareUtil";
export class NumericMarkerManager extends MarkerManagerBase {
    constructor(a, ..._rest) {
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0:
                {
                    let c = _rest[0];
                    let d = _rest[1];
                    let e = _rest[2];
                    let f = _rest[3];
                    let g = _rest[4];
                    let h = [c, d, e, f, g, () => 0];
                    {
                        let j = h[0];
                        let k = h[1];
                        let l = h[2];
                        let m = h[3];
                        let n = h[4];
                        let o = h[5];
                        super(j, k, l, m, n);
                        this.n = false;
                        this.p = null;
                        this.o = null;
                        this.q = null;
                        this.m = null;
                        this.n = false;
                        this.p = (p) => ({ $type: Point_$type, x: 0, y: 0 });
                        this.o = o;
                    }
                    this.n = false;
                    this.p = null;
                    this.o = null;
                    this.q = null;
                    this.m = null;
                }
                break;
            case 1:
                {
                    let c = _rest[0];
                    let d = _rest[1];
                    let e = _rest[2];
                    let f = _rest[3];
                    let g = _rest[4];
                    let h = _rest[5];
                    super(c, d, e, f, g);
                    this.n = false;
                    this.p = null;
                    this.o = null;
                    this.q = null;
                    this.m = null;
                    this.n = false;
                    this.p = (i) => ({ $type: Point_$type, x: 0, y: 0 });
                    this.o = h;
                }
                break;
        }
    }
    l(a, b, c, d, e) {
        let f = this.f();
        a.clear();
        let g = new List$1(Number_$type, 0);
        b = Math.max(0, b);
        let h = null;
        this.i(c, d, boxArray$1(f), g);
        if (b >= g.count) {
            h = g;
        }
        else {
            h = new List$1(Number_$type, 0);
            let i = Math.max(8, e);
            let j = this.c(d, g, i, boxArray$1(f));
            let 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);
    }
    r(a, b, c) {
        for (let d = 0; d < c.count; ++d) {
            let e = c._inner[d];
            let f = b[e];
            let g = this.g(e);
            let h = this.h(g);
            if (h.content != null) {
                h.content.item = g;
            }
            let 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);
            }
        }
    }
    j(a, b) {
        let c = a.keys;
        if (MarkerManagerBase.b) {
            let d = new List$1(Base.$, 1, a.keys);
            d.aa((e, f) => {
                let g = a.item(e);
                let h = a.item(f);
                let i = Math.pow(g.c.x, 2) + Math.pow(g.c.y, 2);
                let j = Math.pow(h.c.x, 2) + Math.pow(h.c.y, 2);
                return CompareUtil.compareToObject(i, j);
            });
            c = d;
        }
        let e = null;
        let f = null;
        switch (this.o()) {
            case 0: break;
            case 1:
                e = ((() => {
                    let $ret = new SmartPlacer();
                    $ret.c = 0.3;
                    $ret.b = 0;
                    return $ret;
                })());
                f = new SmartPlaceableWrapper$1(Marker.$);
                f.f = true;
                break;
            case 2:
                e = ((() => {
                    let $ret = new SmartPlacer();
                    $ret.c = 0.6;
                    $ret.b = 2;
                    return $ret;
                })());
                f = new SmartPlaceableWrapper$1(Marker.$);
                f.f = true;
                break;
            case 3:
                e = ((() => {
                    let $ret = new SmartPlacer();
                    $ret.c = 0.3;
                    $ret.b = 0;
                    return $ret;
                })());
                f = new SmartPlaceableWrapper$1(Marker.$);
                break;
            case 4:
                e = ((() => {
                    let $ret = new SmartPlacer();
                    $ret.c = 0.6;
                    $ret.b = 2;
                    return $ret;
                })());
                f = new SmartPlaceableWrapper$1(Marker.$);
                break;
        }
        for (let g of fromEnum(c)) {
            let h = a.item(g);
            let 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);
        }
        this.a(a);
    }
    s(a, b, c) {
        a.n = b.c.x;
        a.o = b.c.y;
    }
}
NumericMarkerManager.$t = markType(NumericMarkerManager, 'NumericMarkerManager', MarkerManagerBase.$);
