/*
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 { Base, Point_$type, runOn, fromEnum, markType, PointUtil } from "igniteui-react-core/ES5/type";
import { ISeriesViewerInteractionManager_$type } from "./ISeriesViewerInteractionManager";
import { HighlightingManager } from "./HighlightingManager";
import { Rect } from "igniteui-react-core/ES5/Rect";
import { TileZoomManager } from "./TileZoomManager";
import { Size } from "igniteui-react-core/ES5/Size";
import { MathUtil } from "igniteui-react-core/ES5/MathUtil";
import { MouseEventArgs } from "igniteui-react-core/ES5/MouseEventArgs";
import { MouseButtonEventArgs } from "igniteui-react-core/ES5/MouseButtonEventArgs";
import { truncate, intDivide, isNaN_ } from "igniteui-react-core/ES5/number";
var SeriesViewerInteractionManager = /** @class */ (function (_super) {
    tslib_1.__extends(SeriesViewerInteractionManager, _super);
    function SeriesViewerInteractionManager() {
        var _this = _super.call(this) || this;
        _this.r = 0;
        _this.s = 0;
        _this.af = null;
        _this.o = 0;
        _this.p = 0;
        _this.n = 0;
        _this.q = 0;
        _this.h = false;
        _this.ag = null;
        _this.ai = null;
        _this.j = false;
        _this.e = null;
        _this.b = null;
        _this.ah = null;
        _this.ak = null;
        _this.d = null;
        _this.a = null;
        _this.g = false;
        _this.ah = Rect.empty;
        _this.ag = Rect.empty;
        return _this;
    }
    Object.defineProperty(SeriesViewerInteractionManager.prototype, "f$b", {
        get: function () {
            if (this.b == null) {
                this.b = new HighlightingManager();
            }
            return this.b;
        },
        enumerable: true,
        configurable: true
    });
    SeriesViewerInteractionManager.prototype.f$a = function (a) {
        if (a.ap != 0) {
            return a.ap;
        }
        var b = 1;
        var c = false;
        var d = false;
        for (var e = 0; e < a.series.count; e++) {
            var f = a.series._inner[e];
            if (f.isStacked) {
                f.h0(function (g) {
                    if (g.bc == 2) {
                        c = true;
                    }
                    if (g.bc == 1) {
                        d = true;
                    }
                    return true;
                });
            }
            else {
                if (f.bc == 2) {
                    c = true;
                }
                if (f.bc == 1) {
                    d = true;
                }
            }
        }
        if (d) {
            b = 1;
        }
        if (c) {
            b = 2;
        }
        if (c && d) {
            b = 3;
        }
        return b;
    };
    SeriesViewerInteractionManager.prototype.f$al = function (a) {
        var b = a.mf;
        var c = b;
        var d = a.bm;
        var e = a.cb();
        var f = a.cd;
        var g = a.c9;
        var h = a.de;
        if (!e) {
            c = { $type: Point_$type, x: NaN, y: NaN };
        }
        for (var i = 0; i < a.series.count; i++) {
            var j = a.series._inner[i];
            j.h4(c);
        }
        var k = a.bf == 0 && !a.cp && (a.cg || f) && !g && !h;
        var l = a.m0;
        if (k && !isNaN_(b.x) && !l.isEmpty) {
            var m = l.width * (b.x - a.mn.left) / a.mn.width;
            d.ee(l.left + m, l.top, l.left + m, l.bottom);
            d.d3();
            d.d8(m);
        }
        else {
            d.ce();
        }
        if (k && !isNaN_(b.y) && !l.isEmpty) {
            var n = l.height * (b.y - a.mn.top) / a.mn.height;
            d.d7(l.left, l.top + n, l.right, l.top + n);
            d.dz();
        }
        else {
            d.b9();
        }
    };
    SeriesViewerInteractionManager.prototype.f$ae = function (a) {
        switch (a.bf) {
            case 0:
                a.bm.dv();
                this.f$al(a);
                a.bm.b6();
                break;
            case 1:
                a.bm.dx();
                a.bm.cd();
                this.f$al(a);
                a.bm.b5();
                break;
            case 2:
                a.bm.dx();
                a.bm.cd();
                this.f$al(a);
                a.bm.b7();
                break;
        }
    };
    SeriesViewerInteractionManager.prototype.f$p = function (a, b) {
        if (b.x >= 0 && b.y >= 0 && b.x <= a.m0.width && b.y <= a.m0.height) {
            this.ab(a, b);
        }
        else {
            a.hl();
        }
    };
    SeriesViewerInteractionManager.prototype.ab = function (a, b) {
        var e_1, _a;
        var c = a.bm;
        var d = a.m0;
        if (a.cq || a.cp) {
            return;
        }
        if (a.cd && a.cg) {
            var e = d.height > d.width;
            c.bs(e);
            try {
                for (var _b = tslib_1.__values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var f = _c.value;
                    if (f.isStacked) {
                        f.h0(function (g) {
                            if (g._visibility == 0) {
                                g.ja(b, runOn(c, c.bj));
                            }
                            return true;
                        });
                    }
                    else {
                        if (f._visibility == 0) {
                            f.ja(b, runOn(c, c.bj));
                        }
                    }
                }
            }
            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; }
            }
            c.d0();
        }
    };
    SeriesViewerInteractionManager.prototype.aa = function (a, b) {
        if (a.cg || a.cn) {
            a.cd = true;
            a.i3();
            this.ag = new Rect(0, b.x, b.y, 0, 0);
            this.ai = new Rect(0, b.x, b.y, 0, 0);
            a.bf = 0;
            a.hd(a.mh(b));
        }
    };
    SeriesViewerInteractionManager.prototype.f$ac = function (a, b) {
        this.aa(a, b);
        this.ab(a, b);
        this.f$al(a);
    };
    SeriesViewerInteractionManager.prototype.f$q = function (a, b, c) {
        if (!a.cd) {
            this.ad(a, b, c);
        }
    };
    SeriesViewerInteractionManager.prototype.f$o = function (a, b) {
        this.ah = Rect.empty;
        a.hl();
    };
    SeriesViewerInteractionManager.prototype.f$aj = function (a) {
        var b = a.bm;
        this.q = 1;
        a.cd = false;
        b.cc();
        b.b8();
        b.ca();
        a.hd({ $type: Point_$type, x: NaN, y: NaN });
        b.b9();
        b.ce();
        b.cd();
        a.bf = 0;
        this.h = true;
        a.c9 = true;
        a.i4();
    };
    SeriesViewerInteractionManager.prototype.f$ab = function (a, b) {
        this.f$aj(a);
    };
    SeriesViewerInteractionManager.prototype.f$ak = function (a, b, c, d, e) {
        this.r = b.x;
        this.s = b.y;
        this.o = c;
        this.p = d;
        this.n = e;
        this.af = a.mn;
        this.f$aj(a);
    };
    SeriesViewerInteractionManager.prototype.f$aa = function (a, b) {
        var c = a.bm;
        c.b9();
        c.ce();
        if (c.at) {
            this.w(a, b);
        }
        else {
            this.y(a, b);
            this.q = b;
        }
    };
    SeriesViewerInteractionManager.prototype.f$ag = function (a, b, c, d, e) {
        var f = a.bm;
        f.b9();
        f.ce();
        this.o = this.o * c;
        this.p = this.p * d;
        this.n = this.n * e;
        if (a.cv) {
            this.o = this.n;
            this.p = this.n;
        }
        var g = a.mn;
        var h = a.m0;
        var i = b.x - this.r;
        var j = b.y - this.s;
        this.r = b.x;
        this.s = b.y;
        var k = g.width;
        var l = g.height;
        var m = this.af.width / this.o;
        var n = this.af.height / this.p;
        if (m > 1) {
            m = 1;
        }
        if (n > 1) {
            n = 1;
        }
        var o = { $type: Point_$type, x: b.x, y: b.y };
        var p = { $type: Point_$type, x: (o.x - h.left) / h.width * g.width + g.left, y: (o.y - h.top) / h.height * g.height + g.top };
        var q = new Rect(0, g.left, g.top, m, n);
        var r = { $type: Point_$type, x: (p.x - q.left) / q.width * h.width + h.left, y: (p.y - q.top) / q.height * h.height + h.top };
        var s = (r.x - o.x) - i;
        var t = (r.y - o.y) - j;
        var u = s / h.width * q.width;
        var v = t / h.height * q.height;
        q = new Rect(0, q.left + u, q.top + v, q.width, q.height);
        g = q;
        a.kj(g, true);
    };
    SeriesViewerInteractionManager.prototype.f$x = function (a, b) {
        this.ag = new Rect(0, b.x, b.y, 0, 0);
        this.ai = new Rect(0, b.x, b.y, 0, 0);
    };
    SeriesViewerInteractionManager.prototype.x = function (a, b, c) {
        var d = a.mn.width;
        var e = a.mn.height;
        var f = a.mn.left + d / 2;
        var g = a.mn.top + e / 2;
        d = d / b;
        e = e / b;
        var h = f - d / 2;
        var i = g - e / 2;
        a.kj(new Rect(0, h, i, d, e), true);
    };
    SeriesViewerInteractionManager.prototype.f$z = function (a, b) {
        var c = a.bm;
        if (c.at) {
            this.w(a, b);
        }
        else {
            this.y(a, b);
        }
        this.ag = Rect.empty;
        a.c9 = false;
    };
    SeriesViewerInteractionManager.prototype.f$r = function (a, b) {
        a.c9 = false;
        this.ag = Rect.empty;
        a.hl();
    };
    SeriesViewerInteractionManager.prototype.f$af = function (a, b, c, d, e) {
        a.c9 = false;
        this.ag = Rect.empty;
        a.hl();
    };
    SeriesViewerInteractionManager.prototype.w = function (a, b) {
        var c = a.m1;
        var d = 1 / b;
        var e = { $type: Point_$type, x: c.x + c.width / 2, y: c.y + c.height / 2 };
        var f = { $type: Point_$type, x: c.x - e.x, y: c.y - e.y };
        var g = new Rect(0, f.x * d + e.x, f.y * d + e.y, c.width * d, c.height * d);
        a.kj(g, true);
    };
    SeriesViewerInteractionManager.prototype.y = function (a, b) {
        var c = a.m0;
        var d = a.m1;
        var e = b - this.q;
        if (e != 0) {
            var f = 0.03;
            var g = e < 0 ? 1 + f : 1 - f;
            var h = { $type: Point_$type, x: d.x + d.width / 2, y: d.y + d.height / 2 };
            var i = { $type: Point_$type, x: d.x - h.x, y: d.y - h.y };
            var j = new Rect(0, i.x * g + h.x, i.y * g + h.y, d.width * g, d.height * g);
            a.kj(j, true);
        }
    };
    SeriesViewerInteractionManager.prototype.f$m = function (a, b, c) {
        if (!a.c9) {
            this.h = false;
        }
        this.ad(a, b, c);
    };
    SeriesViewerInteractionManager.prototype.ad = function (a, b, c) {
        var d;
        var e = a.bm;
        var f = a.bd(c);
        if (e.eo == 0) {
            switch (f) {
                case 1:
                    d = a.c1() ? f : 0;
                    break;
                default:
                    d = f;
                    break;
            }
        }
        else {
            if (e.eo == a.lx) {
                d = 1;
            }
            else if (e.eo == a.ly) {
                d = 2;
            }
            else {
                d = 0;
            }
        }
        switch (d) {
            case 1:
            case 2:
                a.bm.b3();
                a.bm.dg();
                break;
        }
        a.bf = d;
        switch (a.bf) {
            case 1:
                a.hd({ $type: Point_$type, x: NaN, y: NaN });
                this.ag = new Rect(0, b.x, b.y, 0, 0);
                this.ai = new Rect(0, b.x, b.y, 0, 0);
                this.ah = new Rect(0, b.x, b.y, 0, 0);
                e.dy();
                e.d6(this.ag);
                a.i9(Rect.empty, true);
                break;
            case 2:
                this.ag = new Rect(0, b.x, b.y, 0, 0);
                this.ah = new Rect(0, b.x, b.y, 0, 0);
                break;
        }
        this.ak = a.mn;
    };
    SeriesViewerInteractionManager.prototype.f$ai = function (a) {
        a.j5();
        a.bm.db();
    };
    SeriesViewerInteractionManager.prototype.f$ah = function (a) {
        a.hh();
        a.bm.da();
    };
    SeriesViewerInteractionManager.prototype.f$am = function (a) {
        if (a.ca && !this.j) {
            this.j = true;
            this.ac(a);
        }
    };
    SeriesViewerInteractionManager.prototype.f$j = function (a) {
        if (this.j) {
            this.z(a);
            this.j = false;
        }
    };
    SeriesViewerInteractionManager.prototype.f$g = function (a) {
        if (this.e == null) {
            return;
        }
        this.f.ab();
    };
    Object.defineProperty(SeriesViewerInteractionManager.prototype, "f", {
        get: function () {
            return this.e;
        },
        enumerable: true,
        configurable: true
    });
    SeriesViewerInteractionManager.prototype.ac = function (a) {
        if (this.e == null) {
            this.e = new TileZoomManager(a, true, a.e1);
            this.e.h = !a.da;
        }
        a.cm = true;
        a.i8();
        this.e.al();
        a.bm.bo();
        a.bm.bp();
    };
    SeriesViewerInteractionManager.prototype.z = function (a) {
        if (this.e == null) {
            return;
        }
        a.cm = false;
        a.bm.c6();
        this.e.ah();
        a.jr();
        a.bm.bv();
    };
    SeriesViewerInteractionManager.prototype.f$i = function (a) {
        a.hb();
        a.jt();
    };
    SeriesViewerInteractionManager.prototype.l = function (a) {
        return a.bf == 2;
    };
    SeriesViewerInteractionManager.prototype.m = function (a, b) {
        return a.ba == 1 || b || a.ca;
    };
    SeriesViewerInteractionManager.prototype.k = function (a) {
        return a.bf == 1;
    };
    SeriesViewerInteractionManager.prototype.f$l = function (a, b, c) {
        var d = a.bm;
        if (this.ag.isEmpty && c) {
            this.ad(a, b, c);
        }
        var e = 2;
        if (c) {
            e = 10;
        }
        var f = false;
        var g = new Rect(2, { $type: Point_$type, x: this.ag.x, y: this.ag.y }, b);
        var h = new Rect(0, 0, 0, 0, 0);
        if (!this.ah.isEmpty) {
            h = new Rect(2, { $type: Point_$type, x: this.ah.x, y: this.ah.y }, b);
        }
        if (h.width > e && h.height > e) {
            f = true;
        }
        if (!a.c9) {
            if (f) {
                this.h = false;
            }
        }
        if (!a.c9 && (a.cd || !c)) {
            a.hd(a.mh(b));
        }
        if (this.k(a)) {
            if (f) {
                var i = a.mz(g);
                a.i9(i, true);
            }
            else {
                a.i9(Rect.empty, true);
            }
            d.d6(g);
        }
        var j = a.m0;
        var k = a.mn;
        if (this.l(a)) {
            var l = j;
            var m = k.left + k.width * (this.ag.x - b.x) / l.width;
            var n = k.top + k.height * (this.ag.y - b.y) / l.height;
            var o = new Rect(0, m, n, k.width, k.height);
            if (this.m(a, c)) {
                a.i4();
                a.i9(Rect.empty, true);
                a.kj(o, true);
                this.ag = new Rect(3, b, new Size(1, 0, 0));
                this.ai = new Rect(3, b, new Size(1, 0, 0));
            }
            else {
                a.i9(o, true);
            }
        }
        this.ai = new Rect(3, b, new Size(1, 0, 0));
        d.br(b);
    };
    SeriesViewerInteractionManager.prototype.f$k = function (a, b, c) {
        var d = a.bm;
        var e = 2;
        if (c) {
            e = 10;
        }
        var f = a.m0;
        var g = a.mn;
        if (!this.h) {
            var h = false;
            var i = new Rect(2, { $type: Point_$type, x: this.ag.x, y: this.ag.y }, b);
            if (i.width > e && i.height > e) {
                h = true;
            }
            if (a.bf == 1) {
                d.b8();
                if (h) {
                    a.kj(a.mz(i), true);
                }
            }
            if (a.bf == 2) {
                var j = f;
                var k = g.left + g.width * (this.ag.x - b.x) / j.width;
                var l = g.top + g.height * (this.ag.y - b.y) / j.height;
                a.kj(new Rect(0, k, l, g.width, g.height), true);
            }
        }
        var m = false;
        var n = new Rect(2, { $type: Point_$type, x: this.ah.x, y: this.ah.y }, b);
        if (n.width > e || n.height > e) {
            m = true;
        }
        if (m) {
            a.de = true;
        }
        a.bf = 0;
        a.i9(Rect.empty, true);
        d.bt();
        a.de = false;
        d.b9();
        d.ce();
        if (c) {
            d.cd();
            d.b9();
            d.ce();
            d.ca();
        }
        a.hl();
        a.i3();
    };
    SeriesViewerInteractionManager.prototype.f$ad = function (a) {
        if (this.f != null) {
            this.f.h = !a.da;
        }
    };
    SeriesViewerInteractionManager.prototype.f$d = function (a, b) {
        var c = a.bm;
        var d = a.mn;
        if (a.bf == 2 && b == 8) {
            c.bq();
            a.bf = 0;
            a.i3();
            a.i9(Rect.empty, true);
            if (a.ba == 1) {
                a.kj(this.ak, true);
            }
            return true;
        }
        if (a.bf == 1 && b == 8) {
            c.bq();
            a.bf = 0;
            a.i3();
            c.b8();
            a.i9(Rect.empty, true);
            return true;
        }
        var e = Rect.empty;
        var f = false;
        switch (b) {
            case 13:
                f = true;
                e = new Rect(0, 0, 0, 1, 1);
                break;
            case 11:
                f = true;
                e = new Rect(0, d.left - 0.1 * d.width, d.top - 0.1 * d.height, 1.2 * d.width, 1.2 * d.height);
                break;
            case 10:
                f = true;
                e = new Rect(0, d.left + 0.1 * d.width, d.top + 0.1 * d.height, 0.8 * d.width, 0.8 * d.height);
                break;
            case 14:
                f = true;
                e = new Rect(0, d.left - 0.1 * d.width, d.top, d.width, d.height);
                e.x = e.x - Math.min(e.left, 0);
                break;
            case 16:
                f = true;
                e = new Rect(0, d.left + 0.1 * d.width, d.top, d.width, d.height);
                e.x = e.x - Math.max(e.right - 1, 0);
                break;
            case 15:
                f = true;
                e = new Rect(0, d.left, d.top - 0.1 * d.height, d.width, d.height);
                e.y = e.y - Math.min(e.top, 0);
                break;
            case 17:
                f = true;
                e = new Rect(0, d.left, d.top + 0.1 * d.height, d.width, d.height);
                e.y = e.y - Math.max(e.bottom - 1, 0);
                break;
        }
        if (!e.isEmpty && Rect.l_op_Inequality(e, d)) {
            a.kj(e, true);
        }
        return f;
    };
    SeriesViewerInteractionManager.prototype.f$e = function (a, b, c) {
        var d = a.bm;
        var e = a.mn;
        var f = e.left + e.width * b.x / a.m0.width;
        var g = e.top + e.height * b.y / a.m0.height;
        var h = 1 - MathUtil.b(c, -0.5, 0.5);
        var i = Math.max(0, f - h * (f - e.left));
        var j = Math.min(1, g + h * (e.bottom - g));
        var k = Math.min(1, f + h * (e.right - f));
        var l = Math.max(0, g - h * (g - e.top));
        a.i4();
        this.v(a, 1000);
        a.kj(new Rect(0, i, l, k - i, j - l), true);
        return a.c1();
    };
    SeriesViewerInteractionManager.prototype.v = function (a, b) {
        a.bm.bw(b);
    };
    SeriesViewerInteractionManager.prototype.f$n = function (a, b) {
        var c = a.mn;
        var d = c.left + c.width * b.x / a.m0.width;
        var e = c.top + c.height * b.y / a.m0.height;
        var f = 0.7;
        var g = Math.max(0, d - f * (d - c.left));
        var h = Math.min(1, e + f * (c.bottom - e));
        var i = Math.min(1, d + f * (c.right - d));
        var j = Math.max(0, e - f * (e - c.top));
        a.kj(new Rect(0, g, j, i - g, h - j), true);
    };
    SeriesViewerInteractionManager.prototype.f$h = function (a) {
        this.f.ac();
    };
    SeriesViewerInteractionManager.prototype.aj = function () {
        return this.ai;
    };
    SeriesViewerInteractionManager.prototype.f$c = function (a, b, c, d, e, f, g) {
        var e_2, _a;
        var h = true;
        var i = false;
        var j = false;
        var k = a;
        if (k.ao == 1) {
            h = false;
            i = true;
        }
        if (k.ao == 3 || k.ao == 4) {
            i = true;
        }
        if (k.ao == 4) {
            j = true;
        }
        var l = truncate(Math.round(d.x));
        var m = truncate(Math.round(d.y));
        f = null;
        var n = -1;
        if (h && c != null) {
            var o = l;
            var p = m;
            if (a.d9 != 1) {
                o = truncate(Math.round(d.x * a.d9));
                p = truncate(Math.round(d.y * a.d9));
            }
            var q = c.a(o, p);
            if (q == null || q.length == 0) {
                f = null;
                return {
                    ret: null,
                    p5: f
                };
            }
            if ((q[0] > 0 || q[1] > 0 || q[2] > 0) && q[3] == 255) {
                var num2_ = q[2];
                if (num2_ % 4 != 0) {
                    num2_ = num2_ + (4 - (num2_ % 4));
                }
                var num1_ = q[1];
                if (num1_ % 4 != 0) {
                    num1_ = num1_ + (4 - (num1_ % 4));
                }
                var num0_ = q[0];
                if (num0_ % 4 != 0) {
                    num0_ = num0_ + (4 - (num0_ % 4));
                }
                var num_ = 0;
                num_ = (num2_ >> 2);
                num_ = (num_ << 6);
                num_ = (num_ | (num1_ >> 2));
                num_ = (num_ << 6);
                num_ = (num_ | (num0_ >> 2));
                n = truncate(Math.floor((intDivide(num_, 1000))));
                n--;
            }
        }
        var r = null;
        var s = -1;
        if (n >= 0) {
            var t_1 = false;
            var u_1 = 0;
            try {
                for (var _b = tslib_1.__values(fromEnum(b)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var v = _c.value;
                    if (!v.c5) {
                        continue;
                    }
                    if (t_1) {
                        break;
                    }
                    if (v.isStacked) {
                        v.h0(function (w) {
                            if (w.fg == n) {
                                r = w;
                                s = u_1;
                                t_1 = true;
                                return false;
                            }
                            return true;
                        });
                    }
                    else if (v.fg == n) {
                        r = v;
                        s = u_1;
                        break;
                    }
                    u_1++;
                }
            }
            catch (e_2_1) { e_2 = { error: e_2_1 }; }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
                }
                finally { if (e_2) throw e_2.error; }
            }
        }
        var w = null;
        if (i) {
            var x = false;
            for (var y = b.count - 1; y >= 0; y--) {
                var z = b._inner[y];
                if (!x && y < s && h && !j) {
                    if (r != null) {
                        w = r;
                        x = true;
                        break;
                    }
                }
                if (z != null && z.bc == 1) {
                    if (z.df(d, g)) {
                        w = z;
                        break;
                    }
                }
            }
            if (h && !x) {
                if (r != null) {
                    w = r;
                    x = true;
                }
            }
        }
        else {
            w = r;
        }
        if (w != null) {
            var aa = w.ar({ $type: Point_$type, x: l, y: m }, g);
            if (aa != null) {
                f = aa;
            }
            return {
                ret: w,
                p5: f
            };
        }
        return {
            ret: null,
            p5: f
        };
    };
    SeriesViewerInteractionManager.prototype.f$f = function (a, b) {
        if (PointUtil.equals(b, null)) {
            return false;
        }
        var c = b.x;
        var d = b.y;
        if (c >= a.m0.left && d >= a.m0.top && c <= a.m0.left + a.m0.width && d <= a.m0.top + a.m0.height) {
            var e = a.bh;
            if (e != null && e.viewShouldInteract(b)) {
                return false;
            }
            return true;
        }
        return false;
    };
    SeriesViewerInteractionManager.prototype.c = function (a) {
        if (a != null) {
            return a.a6();
        }
        else {
            return null;
        }
    };
    SeriesViewerInteractionManager.prototype.f$v = function (a, b, c, d, e, f) {
        var _this = this;
        if (!f && a.b9) {
            this.ae(a, false);
        }
        var g = new MouseEventArgs();
        g.position = d;
        if (a.bf == 2 || a.bf == 1 || a.c9 || (a.bh != null && a.bh.isPinching)) {
            if (this.d != null) {
                this.d.a0.a$x(this.d, g.position, this.a, g);
                this.d = null;
            }
            return;
        }
        var h = null;
        var i = ((function () { var j = _this.f$c(a, b, c, d, !e, h, f); h = j.p5; return j.ret; })());
        this.a = h;
        var j = this.c(i);
        if (i != null) {
            var k = false;
            var l = false;
            if (this.d != i) {
                l = true;
            }
            if (this.d == null || l) {
                k = true;
            }
            if (k) {
                if (l) {
                    if (this.d != null) {
                        j = this.c(this.d);
                        this.d.a0.a$x(this.d, g.position, h, g);
                        if (j != null) {
                            j.a0.a$x(j, g.position, h, g);
                        }
                    }
                }
                this.d = i;
                i.ii(g.position, h, g);
                if (j != null) {
                    j.ii(g.position, h, g);
                }
            }
            else {
                this.d = i;
                i.a0.a$z(i, g.position, h, g);
                if (j != null) {
                    j.a0.a$z(j, g.position, h, g);
                }
            }
        }
        else {
            if (this.d != null) {
                j = this.c(this.d);
                this.d.a0.a$x(this.d, g.position, h, g);
                if (j != null) {
                    j.a0.a$x(j, g.position, h, g);
                }
                this.d = null;
            }
            for (var m = 0; m < a.series.count; m++) {
                var n = a.series._inner[m];
                if (n.a0.a$b) {
                    j = this.c(n);
                    n.a0.a$x(n, g.position, n.a0.a$o, g);
                    if (j != null) {
                        j.a0.a$x(j, g.position, n.a0.a$o, g);
                    }
                }
            }
        }
    };
    SeriesViewerInteractionManager.prototype.f$u = function (a, b) {
        if (this.d != null) {
            var c = this.c(this.d);
            var d = new MouseEventArgs();
            d.position = b;
            this.d.a0.a$x(this.d, d.position, null, d);
            if (c != null) {
                c.a0.a$x(c, d.position, null, d);
            }
            this.d = null;
        }
        a.ik(b);
    };
    SeriesViewerInteractionManager.prototype.f$t = function (a, b, c) {
        if (this.d != null) {
            var d = new MouseButtonEventArgs();
            d.position = c;
            if (b.ag) {
                this.d.a0.a$aa(this.d, d.position, this.a, d);
            }
            else {
                this.d.a0.a$u(this.d, d.position, this.a, d);
            }
        }
    };
    SeriesViewerInteractionManager.prototype.f$w = function (a, b, c) {
        if (this.d != null) {
            var d = new MouseButtonEventArgs();
            d.position = c;
            if (b.ag) {
                this.d.a0.a$ab(this.d, d.position, this.a, d);
            }
            else {
                this.d.a0.a$y(this.d, d.position, this.a, d);
            }
        }
    };
    SeriesViewerInteractionManager.prototype.f$s = function (a, b, c) {
        if (!c && a.c6) {
            this.ae(a, false);
        }
        if (c && !a.c6) {
            this.ae(a, true);
        }
        a.h5(b, c);
    };
    SeriesViewerInteractionManager.prototype.ae = function (a, b) {
        if (a != null) {
            if (!this.i) {
                a.b9 = b;
            }
        }
    };
    SeriesViewerInteractionManager.prototype.f$y = function (a, b) {
        this.g = true;
    };
    Object.defineProperty(SeriesViewerInteractionManager.prototype, "i", {
        get: function () {
            return this.g;
        },
        enumerable: true,
        configurable: true
    });
    SeriesViewerInteractionManager.$t = markType(SeriesViewerInteractionManager, 'SeriesViewerInteractionManager', Base.$, [ISeriesViewerInteractionManager_$type]);
    return SeriesViewerInteractionManager;
}(Base));
export { SeriesViewerInteractionManager };
