/*
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, Point_$type, toNullable, String_$type, fromEnum, markType } from "igniteui-angular-core";
import { ISeriesInteractionManager_$type } from "./ISeriesInteractionManager";
import { Dictionary$2 } from "igniteui-angular-core";
import { SeriesView } from "./SeriesView";
import { ScalerParams } from "./ScalerParams";
import { List$1 } from "igniteui-angular-core";
import { GeometryUtil } from "igniteui-angular-core";
import { PolygonUtil } from "igniteui-angular-core";
import { RectUtil } from "igniteui-angular-core";
import { BrushUtil } from "igniteui-angular-core";
import { Color } from "igniteui-angular-core";
import { truncate, isNaN_ } from "igniteui-angular-core";
import { boxArray$1 } from "igniteui-angular-core";
import { stringIsNullOrEmpty } from "igniteui-angular-core";
/**
 * @hidden
 */
var SeriesInteractionManager = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(SeriesInteractionManager, _super);
    function SeriesInteractionManager() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.a = null;
        _this.b = null;
        _this.a$p = null;
        _this.a$c = false;
        _this.i = false;
        _this.c = false;
        _this.d = false;
        _this.e = true;
        _this.f = false;
        _this._toolTipObject = null;
        _this.p = null;
        _this.t = null;
        _this.o = null;
        _this.j = false;
        _this.k = new Dictionary$2(String_$type, SeriesView.$, 0);
        return _this;
    }
    SeriesInteractionManager.prototype.a$j = function (a, b, c, d, e, f, g, h) {
        if (d == null) {
            return Number.POSITIVE_INFINITY;
        }
        if (c < 0 || c > g - 1) {
            return Number.POSITIVE_INFINITY;
        }
        var i;
        var j = NaN;
        var k = NaN;
        var l = NaN;
        var m = NaN;
        if (d.cm) {
            var n = d;
            i = h(b);
            var o = truncate(Math.floor(i));
            var p = truncate(Math.ceil(i));
            m = i - o;
            if (o >= 0 && o < g) {
                var q = n.i$d(n.i$b._inner[o]);
                j = d.ei(q, e) + f;
            }
            else {
                j = NaN;
            }
            if (p >= 0 && p < g) {
                var r = n.i$d(n.i$b._inner[p]);
                k = d.ei(r, e) + f;
            }
            else {
                k = NaN;
            }
            if (isNaN_(j) && !isNaN_(k)) {
                j = k;
            }
            if (isNaN_(k) && !isNaN_(j)) {
                k = j;
            }
            if (c >= 0 && c < g) {
                var s = n.i$d(n.i$b._inner[c]);
                l = d.ei(s, e) + f;
            }
        }
        else {
            i = a.f9(b);
            var t = truncate(Math.floor(i));
            var u = truncate(Math.ceil(i));
            m = i - t;
            if (t >= 0 && t < g) {
                j = d.ei(t, e) + f;
            }
            else {
                j = NaN;
            }
            if (u > g - 1 && a.ed) {
                u = 0;
            }
            if (u >= 0 && u < g) {
                k = d.ei(u, e) + f;
            }
            else {
                k = NaN;
            }
            if (isNaN_(j) && !isNaN_(k)) {
                j = k;
            }
            if (isNaN_(k) && !isNaN_(j)) {
                k = j;
            }
            if (c >= 0 && c < g) {
                l = d.ei(c, e) + f;
            }
        }
        var v = j + m * (k - j);
        return Math.abs(l - v);
    };
    SeriesInteractionManager.prototype.a$l = function (a, b, c, d, e, f, g, h, i) {
        var j = NaN;
        if (d >= 0 && d < c.count) {
            j = c.item(d);
        }
        var k = NaN;
        if (e >= 0 && e < c.count) {
            k = c.item(e);
        }
        if (g == 0) {
            return k;
        }
        if (f == c.count - 1) {
            return j;
        }
        if (isNaN_(k) && h != 0 && b <= 0.5 && !i) {
            return j;
        }
        if (isNaN_(j) && h != 0 && b >= 0.5 && !i) {
            return k;
        }
        return j * (1 - b) + k * b;
    };
    SeriesInteractionManager.prototype.a$a = function (a, b, c, d, e, f, g) {
        if (b == null) {
            return null;
        }
        var h = -1;
        var i = -1;
        if (b.cm) {
            var j = a.pn(f);
            var k = -1;
            var l = b.cg;
            var m = a.b1.bu.right * 2;
            k = SeriesInteractionManager.n(c, j, l, m);
            if (k < 0) {
                k = ~k;
                k--;
            }
            if (k < 0) {
                k = 0;
            }
            if (k > c.count - 1) {
                k = c.count - 1;
            }
            var n = k;
            var o = k + 1;
            if (o > c.count - 1) {
                o = c.count - 1;
            }
            h = n;
            i = o;
        }
        else {
            var p = a.ho(f, g);
            var q = a.hm(f, g);
            var r = truncate(Math.floor(p / d));
            var s = truncate(Math.floor(q / d));
            h = r - e;
            i = s - e;
            if (i == h) {
                i++;
            }
        }
        if (h < 0) {
            h = 0;
        }
        if (h > c.count - 1) {
            h = c.count - 1;
        }
        if (i < 0) {
            i = 0;
        }
        if (i > c.count - 1) {
            i = c.count - 1;
        }
        if (h < 0 || i < 0) {
            return null;
        }
        var t = c._inner[h];
        var u = c._inner[i];
        var v = new Array(2);
        v[0] = t;
        v[1] = u;
        return v;
    };
    SeriesInteractionManager.n = function (a, b, c, d) {
        var e = 0;
        var f = a.count - 1;
        while (e <= f) {
            var g = (e + ((f - e) >> 1));
            var h = void 0;
            var i = a.item(g);
            if (c) {
                h = (d - b.x) < (d - i[0]) ? -1 : ((d - b.x) > (d - i[0]) ? 1 : 0);
            }
            else {
                h = b.x < i[0] ? -1 : (b.x > i[0] ? 1 : 0);
            }
            if (h < 0) {
                f = g - 1;
            }
            else if (h > 0) {
                e = g + 1;
            }
            else {
                return g;
            }
        }
        return ~e;
    };
    SeriesInteractionManager.prototype.a$o = function (a, b, c, d, e, f) {
        if (d == null) {
            return -1;
        }
        var g = d.cm;
        var h = a.fc;
        var i = null;
        if (g) {
            i = d;
        }
        var j = -1;
        var k = -1;
        var l = -1;
        if (g) {
            j = e(b);
            if (isNaN_(j)) {
                return -1;
            }
            k = truncate(Math.floor(j));
            l = truncate(Math.ceil(j));
        }
        else {
            j = a.f9(b);
            if (isNaN_(j)) {
                return -1;
            }
            k = truncate(Math.floor(j));
            l = truncate(Math.ceil(j));
        }
        if (f == null) {
            return -1;
        }
        if (k < 0 || k > f.count - 1) {
            return -1;
        }
        if (!c) {
            return k;
        }
        var m = NaN;
        if (g && !h) {
            if (k < i.i$b.count && i.i$b._inner[k] < f.count) {
                m = f.item(i.i$b._inner[k]);
            }
        }
        else {
            m = f.item(k);
        }
        while (isNaN_(m)) {
            k--;
            if (k < 0 || k > f.count - 1) {
                return -1;
            }
            if (g && !h) {
                m = f.item(i.i$b._inner[k]);
            }
            else {
                m = f.item(k);
            }
        }
        return k;
    };
    SeriesInteractionManager.prototype.a$m = function (a, b, c, d, e, f, g, h, i) {
        if (b == null) {
            return NaN;
        }
        var j = a.fc;
        var k = a.hp(c, i, d, g, b);
        var l = a.hn(c, i, d, g, b);
        var m = a.f7(c, k, d, e, f);
        var n = a.f7(c, l, d, e, f);
        var o = k;
        var p = l;
        var q = d.cm;
        if (q && !j) {
            var r = d;
            if (k >= 0 && k < r.i$b.count) {
                k = r.i$b._inner[k];
            }
            if (l >= 0 && k < r.i$b.count) {
                l = r.i$b._inner[l];
            }
        }
        var s = m / (n + m);
        if (m == 0) {
            s = 0;
        }
        if (n == 0) {
            s = 1;
        }
        if (!h) {
            if (n <= m) {
                if (l >= 0 && l < b.count) {
                    return b.item(l);
                }
            }
            else {
                if (k >= 0 && k < b.count) {
                    return b.item(k);
                }
            }
            return NaN;
        }
        return a.gd(s, b, k, l, o, p, f, q);
    };
    SeriesInteractionManager.prototype.a$d = function (a, b, c) {
        var d = a.ai(b);
        var e = a.ah(b);
        if (d == null) {
            return false;
        }
        for (var f = 0; f < d.length; f++) {
            var g = d[f];
            if (g == null || g.length != 2) {
                continue;
            }
            if (GeometryUtil.a(b, g[0], g[1], a.fy / 2 + a.gc(c))) {
                return true;
            }
            if (e != null && f < e.length) {
                var h = e[f];
                if (h == null || h.length != 2) {
                    continue;
                }
                if (GeometryUtil.a(b, h[0], h[1], a.fy / 2 + a.gc(c))) {
                    return true;
                }
                if (GeometryUtil.a(b, g[0], h[0], a.fy / 2 + a.gc(c))) {
                    return true;
                }
                if (GeometryUtil.a(b, g[1], h[1], a.fy / 2 + a.gc(c))) {
                    return true;
                }
                var i = new Array(5);
                i[0] = h[0];
                i[1] = h[1];
                i[2] = g[1];
                i[3] = g[0];
                i[4] = h[0];
                if (PolygonUtil.b(boxArray$1(i), b)) {
                    return true;
                }
            }
        }
        return false;
    };
    SeriesInteractionManager.prototype.a$e = function (a, b, c, d) {
        if (d == null) {
            return false;
        }
        for (var e = 0; e < d.c.count; e++) {
            var f = d.c._inner[e];
            for (var g = 0; g < f._segments.count; g++) {
                var h = f._segments._inner[g];
                if (GeometryUtil.b(b, f._startPoint, h._points, a.gc(c))) {
                    return true;
                }
            }
        }
        return false;
    };
    SeriesInteractionManager.prototype.a$f = function (a, b, c) {
        if (c == null) {
            return false;
        }
        if (c.c.count > 0) {
            var d = c.c._inner[0];
            if (d._segments.count > 0) {
                var e = d._segments._inner[0];
                if (PolygonUtil.b(e._points, b)) {
                    return true;
                }
            }
        }
        return false;
    };
    SeriesInteractionManager.prototype.a$n = function (a, b, c, d, e, f) {
        var g = a.fc;
        var h = d.cm;
        var i = null;
        if (h) {
            i = d;
        }
        var j = -1;
        var k = -1;
        var l = -1;
        if (h) {
            j = e(b);
            if (isNaN_(j)) {
                return -1;
            }
            k = truncate(Math.floor(j));
            l = truncate(Math.ceil(j));
        }
        else {
            j = a.f9(b);
            if (isNaN_(j)) {
                return -1;
            }
            k = truncate(Math.floor(j));
            l = truncate(Math.ceil(j));
        }
        if (f == null) {
            return -1;
        }
        if (l < 0 || l > f.count - 1) {
            if (a.ed) {
                if (l > f.count - 1) {
                    return 0;
                }
            }
            return -1;
        }
        if (!c) {
            return l;
        }
        var m = NaN;
        if (h && !g) {
            if (l < i.i$b.count && i.i$b._inner[l] < f.count) {
                m = f.item(i.i$b._inner[l]);
            }
        }
        else {
            m = f.item(l);
        }
        while (isNaN_(m)) {
            l++;
            if (l < 0 || l > f.count - 1) {
                return -1;
            }
            if (h && !g) {
                m = f.item(i.i$b._inner[l]);
            }
            else {
                m = f.item(l);
            }
        }
        return l;
    };
    SeriesInteractionManager.prototype.a$k = function (a, b, c) {
        var d = a.b1.bv;
        var e = a.b1.bu;
        if (d.isEmpty || e.isEmpty || c == null) {
            return -1;
        }
        var f = a.getEffectiveViewport1(a.b1);
        var g = null;
        if (c.cm) {
            g = c;
        }
        var h = new ScalerParams(0, d, e, c.cg, f);
        if (a.ce == null) {
            return -1;
        }
        h.c = a.getEffectiveViewport1(a.b1);
        var i = a.pz(a.b1);
        var j = 0;
        if (c.co) {
            var k = c.el(i.top, h);
            var l = c.el(i.bottom, h);
            var m = (b.y - d.top) / d.height;
            j = k + ((l - k) * m);
        }
        else {
            if (c.cb) {
                var n = c.el(i.left, h);
                var o = c.el(i.right, h);
                var p = (b.x - d.left) / d.width;
                j = n + ((o - n) * p);
            }
            else {
                var q = a.pn(b);
                j = c.el(q.x, h);
            }
        }
        if (c.cd) {
        }
        var r = g.i$c(j);
        return r;
    };
    SeriesInteractionManager.prototype.a$g = function (a, b, c) {
        var d = a.p4(b);
        if (d.isEmpty) {
            return false;
        }
        var e = RectUtil.r(d, a.gc(c));
        return e.containsPoint(b);
    };
    SeriesInteractionManager.prototype.a$al = function (a, b, c, d, e, f, g, h, i, j) {
        if (f == null || g == null || a.b1 == null || a.b1.bv.isEmpty || a.b1.bu.isEmpty) {
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        var k = a.getEffectiveViewport1(a.b1);
        var l = new ScalerParams(0, a.b1.bv, a.b1.bu, f.cg, k);
        if (f.co) {
            l.b = a.gg();
        }
        l.c = a.getEffectiveViewport1(a.b1);
        var m = a.b1;
        var n = a.pz(m);
        var o;
        if (g.co) {
            o = b.y;
            o = n.top + n.height * (o - m.bv.top) / m.bv.height;
        }
        else {
            o = b.x;
            o = n.left + n.width * (o - m.bv.left) / m.bv.width;
        }
        if (!c && g != null) {
            var p = void 0;
            var q = void 0;
            if (i != null) {
                p = i(b, d);
            }
            else {
                p = a.ho(b, d);
            }
            if (j != null) {
                q = j(b, d);
            }
            else {
                q = a.hm(b, d);
            }
            if (p == -1 && q == -1) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            var r = new ScalerParams(0, m.bv, m.bu, g.cg, k);
            r.c = a.ce.te;
            var s = a.f7(b, p, g, r, e);
            var t = a.f7(b, q, g, r, e);
            var u = q;
            var v = p;
            if (g.cm) {
                var w = g;
                if (u >= 0 && u < w.i$b.count) {
                    u = w.i$d(w.i$b._inner[truncate(u)]);
                }
                if (v >= 0 && v < w.i$b.count) {
                    v = w.i$d(w.i$b._inner[truncate(v)]);
                }
            }
            if ((t + s) != 0) {
                var x = t / (s + t);
                if (Math.abs(x - 0.5) < 1E-07) {
                    t = s;
                }
            }
            if (t <= s) {
                o = g.ei(u, r) + e;
            }
            else {
                o = g.ei(v, r) + e;
            }
        }
        else {
            if (g.ca && !g.cd && g.categoryMode != 0) {
                var y = 0.5 * g.getCategorySize(m.bv, m.bu, a.getEffectiveViewport1(m));
                if (a.isVertical) {
                    y = y * -1;
                }
                if (g.cg) {
                    y = y * -1;
                }
                o -= y;
                o += e;
            }
        }
        var z;
        if (h != null) {
            z = h(b, c, d);
        }
        else {
            z = a.gn(b, c, d);
        }
        var aa = f.ei(z, l);
        if (g.co) {
            return { $type: Point_$type, x: aa, y: o };
        }
        else {
            return { $type: Point_$type, x: o, y: aa };
        }
    };
    SeriesInteractionManager.prototype.a$s = function () {
        this.a = null;
        this.b = null;
    };
    SeriesInteractionManager.prototype.a$v = function (a, b, c, d, e, f, g, h, i) {
        if (d) {
            return;
        }
        if (a.ce.et() && !f) {
            return;
        }
        if (a.bl == 1) {
            return;
        }
        if (a.ce == null) {
            return;
        }
        var j = a.ce.bs;
        var k = j == 2 || j == 3 || j == 4;
        var l = j == 2 || j == 4;
        if (!g) {
            if (k) {
                e = false;
            }
        }
        if ((a.c3 && a.c6) || g) {
            l = false;
        }
        if (j == 2) {
            h = false;
        }
        if (j == 3) {
            h = true;
        }
        var m = null;
        var n = null;
        var o = a.ce.a7;
        var p = a.ce.cv;
        var q = (f && g) || (f && !k) || i || (l && !h);
        var r = !q && (g || e || (k && !l) || (k && l && h));
        var s = (f && (!k || g)) || i || (!a.c6 && k && l && !h);
        var t = !s && (e || (k && a.c6) || (!a.c6 && k && !l) || (!a.c6 && k && l && h));
        if (q && this.a != null) {
            m = this.a;
        }
        else {
            m = a.ax(b, c, g);
            if (this.a != null && this.a != m) {
                if (a.ce != null) {
                    o.endHighlight(this.a);
                }
            }
            this.a = m;
        }
        if (a.hasMarkers) {
            if (s && this.b != null) {
                n = this.b;
            }
            else {
                n = a.ay(b, c, g);
                if (this.b != null && this.b != n) {
                    o.endHighlight(this.b);
                }
                this.b = n;
            }
        }
        if (q) {
            o.endHighlight(m);
        }
        else {
            if (r) {
                if (m != null && m.d) {
                    m.c = g || !k;
                }
                o.startHighlight(m);
            }
        }
        if (s) {
            if (n != null) {
                o.endHighlight(n);
            }
        }
        else {
            if (t) {
                if (n != null) {
                    o.startHighlight(n);
                }
            }
        }
        this.q(a);
    };
    SeriesInteractionManager.prototype.q = function (a) {
        if (a.ce != null) {
            var b = a.ce.cv;
            if (!b.f() && b.r > 0) {
                b.v();
            }
            if (b.r == 0) {
                a.ce.o9(1);
            }
        }
    };
    SeriesInteractionManager.prototype.a$i = function (a, b, c, d, e, f, g) {
        if (a.bl == 3 || a.bl == 2) {
            return c;
        }
        else if (a.bl == 5 || a.bl == 4) {
            var h = 0;
            if (b != null) {
                h = b.f;
            }
            if (h > 1) {
                h = 1;
            }
            if (d > 1) {
                d = 1;
            }
            if (e > 1) {
                e = 1;
            }
            h = h - Math.max(d, e);
            c = f + (1 + h) * (1 - f);
            return c;
        }
        else {
            return c;
        }
    };
    SeriesInteractionManager.prototype.a$ak = function (a, b, c) {
        if (a.bl == 3 || a.bl == 2) {
            var d = 0;
            if (b != null) {
                d = b.f;
            }
            var e = d;
            e = e * 0.5;
            return this.s(c, e);
        }
        else if (a.bl == 5 || a.bl == 4) {
            return c;
        }
        else {
            return c;
        }
    };
    SeriesInteractionManager.prototype.s = function (a, b) {
        if (a == null) {
            return a;
        }
        if (b == 0) {
            return a;
        }
        return BrushUtil.l(a, b);
    };
    SeriesInteractionManager.prototype.a$y = function (a, b, c, d, e) {
        var f = a.b1;
        f.am();
        this.a$c = true;
        var g = a.h4(c, b);
        this.a$p = g;
        if (!e && a.ce != null && !a.at.c) {
            this.r(a, b, g, d);
        }
        this.c = false;
        if (a.es && g == null) {
            this.c = true;
        }
        if (a.ce != null && !this.c) {
            if (a.es) {
                this.d = true;
            }
            this.a$v(a, g, a.px(b), e, true, false, false, a == a.ce.bo, false);
            a.ce.nk(a, g, d);
        }
    };
    SeriesInteractionManager.prototype.a$ai = function (a, b) {
        var c = null;
        var d = null;
        var e;
        var f = ((function () { var g = a.ce.cu.f(b, false, e, false); e = g.p2; return g.ret; })());
        if (f != a) {
            if (this.a$c) {
                this.a$z(a, b, null, null, false);
            }
            if (a.ce != null) {
                a.ce.o1(b);
            }
            return;
        }
        c = e;
        if (a.ce != null) {
            a.ce.o1(b);
        }
        if (!this.a$c) {
            this.a$y(a, b, c, d, false);
        }
        this.a$ab(a, b, c, d, false);
    };
    SeriesInteractionManager.prototype.a$ab = function (a, b, c, d, e) {
        this.a$c = true;
        var f = a.h4(c, b);
        if (!e) {
            this.r(a, b, f, d);
        }
        if (f != null) {
            this.a$p = f;
        }
        if (a.ce != null && f != null && this.c) {
            this.c = false;
            this.d = true;
            this.a$v(a, f, a.px(b), e, true, false, false, a == a.ce.bo, false);
            a.ce.nk(a, f, d);
        }
        if (a.ce != null && (!a.es || f != null) && !this.c) {
            this.a$v(a, f, a.px(b), e, true, false, false, a == a.ce.bo, false);
            a.ce.no(a, f, d);
        }
        if (f == null && !this.c && a.es) {
            this.a$v(a, f, a.px(b), e, false, true, false, a == a.ce.bo, false);
            a.ce.nl(a, this.a$p, d);
            this.d = false;
            this.c = true;
        }
    };
    SeriesInteractionManager.prototype.a$z = function (a, b, c, d, e) {
        a.b1.an();
        this.a$c = false;
        var f = this.a$p;
        a.b1.ap();
        if (a.ce != null && (this.d || !a.es)) {
            this.d = false;
            this.c = false;
            this.a$v(a, f, a.px(b), e, false, true, false, a == a.ce.bo, false);
            a.ce.nl(a, f, d);
        }
    };
    SeriesInteractionManager.prototype.a$w = function (a, b, c, d) {
        this.i = true;
        if (a.ce != null) {
            a.ce.nm(a, a.h4(c, b), d);
        }
    };
    SeriesInteractionManager.prototype.a$aa = function (a, b, c, d) {
        this.i = false;
        if (a.ce != null) {
            a.ce.nn(a, a.h4(c, b), d);
        }
    };
    SeriesInteractionManager.prototype.a$x = function (a, b, c, d) {
        if (a.b1.s) {
            return;
        }
        if (this.i) {
            this.a$aa(a, b, c, d);
        }
        if (this.a$c) {
            this.a$z(a, b, c, d, false);
        }
    };
    SeriesInteractionManager.prototype.a$ac = function (a, b, c, d) {
        if (a.ce != null) {
            a.ce.np(a, a.h4(c, b), d);
        }
    };
    SeriesInteractionManager.prototype.a$ad = function (a, b, c, d) {
        if (a.ce != null) {
            a.ce.nq(a, a.h4(c, b), d);
        }
    };
    Object.defineProperty(SeriesInteractionManager.prototype, "g", {
        get: function () {
            return this.c;
        },
        set: function (a) {
            this.c = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SeriesInteractionManager.prototype, "a$b", {
        get: function () {
            return this.d;
        },
        set: function (a) {
            this.d = a;
        },
        enumerable: false,
        configurable: true
    });
    SeriesInteractionManager.prototype.r = function (a, b, c, d) {
        var e = false;
        if (a.ce != null) {
            e = a.ce.ec;
        }
        if (e) {
            return;
        }
        if (a.ce == null || a.ce.d2) {
            return;
        }
        this.j = true;
        this.t = b;
        this.o = c;
        a.b1.d.item = c;
        a.b1.d.itemLabel = a.h0(c);
        var f = a.ce.s3();
        var pos_ = { $type: Point_$type, x: b.x + 15 + f.x, y: b.y + 15 + f.y };
        var context_ = a.b1.d;
        var g = false;
        if (this._toolTipObject != null) {
            g = (this._toolTipObject._inPointer);
            this._toolTipObject._inPointer = false;
        }
        if (this._toolTipObject != null) {
            if (this.f || g) {
                this.f = false;
                this._toolTipObject.remove();
                this._toolTipObject.setStyleProperty("position", "absolute");
                this._toolTipObject.addClass(a.ce.kr);
                a.ce.lk(this._toolTipObject);
                this._toolTipObject.hide();
            }
            if (this.e) {
                a.ce.lk(this._toolTipObject);
                this.e = false;
            }
            context_.hideOthers = true;
            if ((this._toolTipObject.updateToolTip && !this._toolTipObject.updateToolTip(context_))) {
                this.a$u(a);
            }
            var h = window.pageXOffset;
            var i = window.pageYOffset;
            var j = document.documentElement.clientWidth;
            var k = document.documentElement.clientHeight;
            var l = this._toolTipObject.outerWidthWithMargin();
            var m = this._toolTipObject.outerHeightWithMargin();
            var n = pos_.x;
            var o = pos_.y;
            var p = 5;
            var q = 30;
            if (l + n - h + p > j) {
                pos_.x -= q;
                pos_.x -= l;
            }
            if (m + o - i + p > k) {
                pos_.y -= q;
                pos_.y -= m;
            }
            this._toolTipObject.setOffset(pos_.x, pos_.y);
        }
    };
    SeriesInteractionManager.prototype.a$ah = function (a, b, c) {
        this.j = true;
        var d = { $type: Point_$type, x: b.x + a.b1.bu.left, y: b.y + a.b1.bu.top };
        var e = a.h4(null, d);
        if (a.b1.d != null) {
            a.b1.d.series = a;
            a.b1.d.item = e;
        }
        var tooltip_ = this._toolTipObject;
        var context_ = a.b1.d;
        var f = false;
        if (this._toolTipObject != null) {
            f = (this._toolTipObject._inPointer);
            this._toolTipObject._inPointer = false;
        }
        if (context_ != null) {
            context_.hideOthers = false;
        }
        if ((!this.f || f) && tooltip_ != null) {
            this.f = true;
            tooltip_.remove();
            tooltip_.setStyleProperty("position", "relative");
            tooltip_.setStyleProperty("top", "");
            tooltip_.setStyleProperty("left", "");
            tooltip_.removeClass(a.ce.kr);
        }
        if (this._toolTipObject != null) {
            if (tooltip_.updateToolTip) {
                tooltip_.updateToolTip(context_);
            }
            ;
        }
        if (tooltip_ != null) {
            c(tooltip_);
        }
    };
    SeriesInteractionManager.prototype.a$q = function (a) {
        var b = "<div class='ui-chart-default-tooltip-content'><span";
        var c = this.a$r(a);
        if (!stringIsNullOrEmpty(c)) {
            b += " style='color:" + c + "'";
        }
        b += ">" + a.title + "</span></div>";
        return b;
    };
    SeriesInteractionManager.prototype.h = function (a, b) {
        var c = a != null && Color.e(toNullable(Color.$, a.color), toNullable(Color.$, null));
        c = c && a.color.l > 0;
        c = c && Color.d(a.color, b);
        return !c;
    };
    SeriesInteractionManager.prototype.a$r = function (a) {
        var b = new Color();
        var c = a != null && a.ce != null && a.ce.cu != null && a.ce.cu.j != null ? a.ce.cu.j.ae : null;
        c.startCSSQuery();
        b.colorString = c.getCssDefaultPropertyValue("ui-chart-pointer-tooltip", "background-color");
        c.endCSSQuery();
        if (!this.h(a.o8, b)) {
            return a.o8._fill;
        }
        if (!this.h(a.o5, b)) {
            return a.o5._fill;
        }
        return null;
    };
    SeriesInteractionManager.prototype.a$u = function (a) {
        if (this._toolTipObject != null && this.j) {
            this.j = false;
            var context_ = a.b1.d;
            if (this._toolTipObject.hideToolTip) {
                this._toolTipObject.hideToolTip(context_);
            }
            ;
        }
    };
    SeriesInteractionManager.prototype.a$aj = function (a, b) {
        var c = this._toolTipObject;
        this.p = null;
        this._toolTipObject = null;
        if (typeof b === 'string') {
            this.p = b;
        }
        else {
            this._toolTipObject = b;
            if (this._toolTipObject != null) {
                this._toolTipObject.setStyleProperty("position", "absolute");
                this._toolTipObject.setStyleProperty("top", "0px");
                this._toolTipObject.setStyleProperty("left", "0px");
                this._toolTipObject.setStyleProperty("z-index", "10000");
                this._toolTipObject.setStyleProperty("pointer-events", "none");
                var d = a.o8 != null && Color.e(toNullable(Color.$, a.o8.color), toNullable(Color.$, null)) && a.o8.color.l > 0;
                if (d) {
                    this._toolTipObject.setStyleProperty("border-color", a.o8._fill);
                }
            }
            else {
                if (!this.e && c != null) {
                    a.ce.os(c);
                    this.e = true;
                }
            }
        }
    };
    SeriesInteractionManager.prototype.a$ag = function (a) {
    };
    Object.defineProperty(SeriesInteractionManager.prototype, "a$h", {
        get: function () {
            return this.k;
        },
        enumerable: false,
        configurable: true
    });
    SeriesInteractionManager.prototype.a$t = function (a, b, c, d, e) {
        var _this = this;
        var f;
        if (!((function () { var g = _this.k.tryGetValue(d, f); f = g.p1; return g.ret; })())) {
            f = a.bz();
            f.q = true;
            f.p = true;
            if (a.ce != null) {
                f.a = a.ce.ak;
                a.ce.ak.l(f);
            }
            f.as();
            f.ad = d;
            this.k.item(d, f);
        }
        f.v = e;
        f.bu = b;
        f.bt = c;
    };
    SeriesInteractionManager.prototype.a$af = function (a, b, c) {
        var _this = this;
        var d;
        var e = c;
        if (e == null) {
            e = a.ce;
        }
        if (((function () { var f = _this.k.tryGetValue(b, d); d = f.p1; return f.ret; })())) {
            if (e != null) {
                d.a = null;
                e.ak.r(d);
            }
            this.k.removeItem(b);
        }
    };
    SeriesInteractionManager.prototype.a$ae = function (a, b) {
        var e_1, _a;
        var c = new List$1(String_$type, 0);
        try {
            for (var _b = __values(fromEnum(this.k.keys)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var d = _c.value;
                c.add(d);
            }
        }
        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;
            }
        }
        for (var e = 0; e < c.count; e++) {
            this.a$af(a, c._inner[e], b);
        }
    };
    SeriesInteractionManager.$t = markType(SeriesInteractionManager, 'SeriesInteractionManager', Base.$, [ISeriesInteractionManager_$type]);
    return SeriesInteractionManager;
}(Base));
export { SeriesInteractionManager };
