/*
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 { Base, Point_$type, runOn, fromEnum, markType, PointUtil } from "igniteui-react-core";
import { ISeriesViewerInteractionManager_$type } from "./ISeriesViewerInteractionManager";
import { HighlightingManager } from "./HighlightingManager";
import { SeriesViewerScrollbarManager } from "./SeriesViewerScrollbarManager";
import { Rect } from "igniteui-react-core";
import { TileZoomManager } from "./TileZoomManager";
import { Size } from "igniteui-react-core";
import { MathUtil } from "igniteui-react-core";
import { MouseEventArgs } from "igniteui-react-core";
import { MouseButtonEventArgs } from "igniteui-react-core";
import { truncate, intDivide, isNaN_ } from "igniteui-react-core";
/**
 * @hidden
 */
export let SeriesViewerInteractionManager = /*@__PURE__*/ (() => {
    class SeriesViewerInteractionManager extends Base {
        constructor() {
            super();
            this.t = 0;
            this.u = 0;
            this.ai = null;
            this.q = 0;
            this.r = 0;
            this.p = 0;
            this.s = 0;
            this.i = false;
            this.aj = null;
            this.al = null;
            this.j = false;
            this.l = false;
            this.f = null;
            this.b = null;
            this.e = null;
            this.ak = null;
            this.am = null;
            this.d = null;
            this.a = null;
            this.h = false;
            this.ak = Rect.empty;
            this.aj = Rect.empty;
        }
        get f$b() {
            if (this.b == null) {
                this.b = new HighlightingManager();
            }
            return this.b;
        }
        get f$c() {
            if (this.e == null) {
                this.e = new SeriesViewerScrollbarManager();
            }
            return this.e;
        }
        f$ao(a, b) {
            let c = null;
            let d = null;
            let e = null;
            e = a.cv.e();
            let f;
            let g = ((() => { let h = a.cv.f(b, false, f, false); f = h.p2; return h.ret; })());
            if (g != e) {
                if (e != null && e.a7.a$c) {
                    e.a7.a$z(e, b, null, null, false);
                }
            }
            c = f;
            if (a != null) {
                a.pd(b);
            }
            if (g != null && !g.a7.a$c) {
                g.a7.a$y(g, b, c, d, false);
            }
        }
        f$a(a) {
            if (a.av != 0) {
                return a.av;
            }
            let b = 1;
            let c = false;
            let d = false;
            for (let e = 0; e < a.series.count; e++) {
                let f = a.series._inner[e];
                if (f.isStacked) {
                    f.n5((g) => {
                        if (g.bw == 2) {
                            c = true;
                        }
                        if (g.bw == 1) {
                            d = true;
                        }
                        return true;
                    });
                }
                else {
                    if (f.bw == 2) {
                        c = true;
                    }
                    if (f.bw == 1) {
                        d = true;
                    }
                }
            }
            if (d) {
                b = 1;
            }
            if (c) {
                b = 2;
            }
            if (c && d) {
                b = 3;
            }
            return b;
        }
        f$an(a) {
            let b = a.te;
            let c = b;
            let d = a.cv;
            let e = a.dt();
            let f = a.dw;
            let g = a.e7;
            let h = a.fg;
            if (!e) {
                c = { $type: Point_$type, x: NaN, y: NaN };
            }
            if (c.x < 0 || c.x > 1 || c.y < 0 || c.y > 1) {
                c = { $type: Point_$type, x: NaN, y: NaN };
            }
            for (let i = 0; i < a.series.count; i++) {
                let j = a.series._inner[i];
                j.od(c);
            }
            a.mn(c);
            let k = a.cm == 0 && !a.ee && (a.d2 || f) && !g && !h;
            let l = a.t2;
            if (k && !isNaN_(b.x) && !l.isEmpty) {
                let m = l.width * (b.x - a.tn.left) / a.tn.width;
                d.eo(l.left + m, l.top, l.left + m, l.bottom);
                d.ed();
                d.ei(m);
            }
            else {
                d.cl();
            }
            if (k && !isNaN_(b.y) && !l.isEmpty) {
                let n = l.height * (b.y - a.tn.top) / a.tn.height;
                d.eh(l.left, l.top + n, l.right, l.top + n);
                d.d9();
            }
            else {
                d.cg();
            }
        }
        f$ag(a) {
            switch (a.cm) {
                case 0:
                    a.cv.d5();
                    this.f$an(a);
                    a.cv.cd();
                    break;
                case 1:
                    a.cv.d7();
                    a.cv.ck();
                    this.f$an(a);
                    a.cv.cc();
                    break;
                case 2:
                    a.cv.d7();
                    a.cv.ck();
                    this.f$an(a);
                    a.cv.ce();
                    break;
            }
        }
        f$q(a, b) {
            if (b.x >= 0 && b.y >= 0 && b.x <= a.t2.width && b.y <= a.t2.height) {
                this.ae(a, b);
            }
            else {
                a.l9();
            }
        }
        ae(a, b) {
            let c = a.cv;
            let d = a.t2;
            if (a.ef || a.ee) {
                return;
            }
            if (a.dw && a.d2) {
                let e = d.height > d.width;
                c.bv(e);
                for (let f of fromEnum(a.series)) {
                    if (f.isStacked) {
                        f.n5((g) => {
                            if (g._visibility == 0) {
                                g.p1(b, runOn(c, c.bm));
                            }
                            if (g.dv) {
                                g.n3((h) => {
                                    if (h._visibility == 0) {
                                        h.p1(b, runOn(c, c.bm));
                                    }
                                    return true;
                                });
                            }
                            return true;
                        });
                    }
                    else if (f.dv) {
                        if (f._visibility == 0) {
                            if (f._visibility == 0) {
                                f.p1(b, runOn(c, c.bm));
                            }
                        }
                        f.n3((g) => {
                            if (g._visibility == 0) {
                                g.p1(b, runOn(c, c.bm));
                            }
                            return true;
                        });
                    }
                    else {
                        if (f._visibility == 0) {
                            f.p1(b, runOn(c, c.bm));
                        }
                    }
                }
                c.ea();
            }
        }
        ad(a, b) {
            if (a.d2 || a.ec) {
                a.dw = true;
                a.n8();
                this.aj = new Rect(0, b.x, b.y, 0, 0);
                this.al = new Rect(0, b.x, b.y, 0, 0);
                a.cm = 0;
                a.l0(a.th(b));
            }
        }
        f$ae(a, b) {
            this.ad(a, b);
            this.ae(a, b);
            this.f$an(a);
        }
        f$r(a, b, c) {
            if (!a.dw) {
                this.ag(a, b, c);
            }
        }
        f$p(a, b) {
            this.ak = Rect.empty;
            a.l9();
        }
        f$al(a) {
            if (this.j) {
                this.f$c.onScrollbarDragCancel();
                this.j = false;
            }
            let b = a.cv;
            this.s = 1;
            this.ac(a);
            a.cm = 0;
            this.i = true;
            a.e7 = true;
            a.n9();
        }
        ac(a) {
            let b = a.cv;
            a.dw = false;
            b.cj();
            b.cf();
            b.ch();
            a.l0({ $type: Point_$type, x: NaN, y: NaN });
            b.cg();
            b.cl();
            b.ck();
        }
        f$ad(a, b) {
            this.f$al(a);
        }
        f$am(a, b, c, d, e) {
            this.t = b.x;
            this.u = b.y;
            this.q = c;
            this.r = d;
            this.p = e;
            this.ai = a.tn;
            this.f$al(a);
        }
        f$ac(a, b) {
            let c = a.cv;
            c.cg();
            c.cl();
            if (c.av) {
                this.y(a, b);
            }
            else {
                this.aa(a, b);
                this.s = b;
            }
        }
        f$ai(a, b, c, d, e) {
            let f = a.cv;
            f.cg();
            f.cl();
            this.q = this.q * c;
            this.r = this.r * d;
            this.p = this.p * e;
            if (a.el) {
                this.q = this.p;
                this.r = this.p;
            }
            let g = a.tn;
            let h = a.t2;
            let i = b.x - this.t;
            let j = b.y - this.u;
            this.t = b.x;
            this.u = b.y;
            let k = g.width;
            let l = g.height;
            let m = this.ai.width / this.q;
            let n = this.ai.height / this.r;
            if (m > 1) {
                m = 1;
            }
            if (n > 1) {
                n = 1;
            }
            let o = { $type: Point_$type, x: b.x, y: b.y };
            let 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 };
            let q = new Rect(0, g.left, g.top, m, n);
            let 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 };
            let s = (r.x - o.x) - i;
            let t = (r.y - o.y) - j;
            let u = s / h.width * q.width;
            let v = t / h.height * q.height;
            q = new Rect(0, q.left + u, q.top + v, q.width, q.height);
            g = q;
            a.pu(g, true);
        }
        f$z(a, b) {
            this.aj = new Rect(0, b.x, b.y, 0, 0);
            this.al = new Rect(0, b.x, b.y, 0, 0);
        }
        z(a, b, c) {
            let d = a.tn.width;
            let e = a.tn.height;
            let f = a.tn.left + d / 2;
            let g = a.tn.top + e / 2;
            d = d / b;
            e = e / b;
            let h = f - d / 2;
            let i = g - e / 2;
            a.pu(new Rect(0, h, i, d, e), true);
        }
        f$ab(a, b) {
            let c = a.cv;
            if (c.av) {
                this.y(a, b);
            }
            else {
                this.aa(a, b);
            }
            this.aj = Rect.empty;
            a.e7 = false;
        }
        f$s(a, b) {
            a.e7 = false;
            this.aj = Rect.empty;
            a.l9();
        }
        f$y(a, b) {
            a.lt();
        }
        f$ah(a, b, c, d, e) {
            a.e7 = false;
            this.aj = Rect.empty;
            a.l9();
        }
        y(a, b) {
            let c = a.t3;
            let d = 1 / b;
            let e = { $type: Point_$type, x: c.x + c.width / 2, y: c.y + c.height / 2 };
            let f = { $type: Point_$type, x: c.x - e.x, y: c.y - e.y };
            let g = new Rect(0, f.x * d + e.x, f.y * d + e.y, c.width * d, c.height * d);
            a.pu(g, true);
        }
        aa(a, b) {
            let c = a.t2;
            let d = a.t3;
            let e = b - this.s;
            if (e != 0) {
                let f = 0.03;
                let g = e < 0 ? 1 + f : 1 - f;
                let h = { $type: Point_$type, x: d.x + d.width / 2, y: d.y + d.height / 2 };
                let i = { $type: Point_$type, x: d.x - h.x, y: d.y - h.y };
                let j = new Rect(0, i.x * g + h.x, i.y * g + h.y, d.width * g, d.height * g);
                a.pu(j, true);
            }
        }
        f$n(a, b, c) {
            if (!a.e7) {
                this.i = false;
            }
            let d = false;
            if (a.dx) {
                if (this.f$c.shouldHandleInteraction(b, c)) {
                    this.j = true;
                    d = true;
                    this.ac(a);
                    a.cv.dr();
                    return;
                }
            }
            this.ag(a, b, c);
            a.nr(b, c);
        }
        ag(a, b, c) {
            let d;
            let e = a.cv;
            let f = a.ck(c);
            if (e.ez == 0) {
                switch (f) {
                    case 1:
                        d = a.et() ? f : 0;
                        break;
                    default:
                        d = f;
                        break;
                }
            }
            else {
                if (e.ez == a.sn) {
                    d = 1;
                }
                else if (e.ez == a.so) {
                    d = 2;
                }
                else {
                    d = 0;
                }
            }
            switch (d) {
                case 1:
                case 2:
                    a.cv.ca();
                    a.cv.dr();
                    break;
            }
            a.cm = d;
            switch (a.cm) {
                case 1:
                    a.l0({ $type: Point_$type, x: NaN, y: NaN });
                    this.aj = new Rect(0, b.x, b.y, 0, 0);
                    this.al = new Rect(0, b.x, b.y, 0, 0);
                    this.ak = new Rect(0, b.x, b.y, 0, 0);
                    e.d8();
                    e.eg(this.aj);
                    a.oe(Rect.empty, true);
                    break;
                case 2:
                    this.aj = new Rect(0, b.x, b.y, 0, 0);
                    this.ak = new Rect(0, b.x, b.y, 0, 0);
                    break;
            }
            this.am = a.tn;
            a.t4 = a.tn;
        }
        f$ak(a) {
            a.pe();
            a.cv.dl();
        }
        f$aj(a) {
            a.l4();
            a.cv.dk();
        }
        f$ap(a) {
            if (a.ds && !this.l) {
                this.l = true;
                this.af(a);
            }
        }
        f$k(a) {
            if (this.l) {
                this.ab(a);
                this.l = false;
            }
        }
        f$h(a) {
            if (this.f == null) {
                return;
            }
            this.g.ab();
        }
        get g() {
            return this.f;
        }
        af(a) {
            if (this.f == null) {
                this.f = new TileZoomManager(a, true, a.hx);
                this.f.h = !a.e8;
            }
            a.eb = true;
            a.od();
            this.f.al();
            a.cv.br();
            a.cv.bs();
        }
        ab(a) {
            if (this.f == null) {
                return;
            }
            a.eb = false;
            a.cv.dg();
            this.f.ah();
            a.oy();
            a.cv.by();
        }
        f$j(a) {
            a.ly();
            a.o0();
        }
        n(a) {
            return a.cm == 2;
        }
        o(a, b) {
            return a.cc == 1 || b || a.ds;
        }
        m(a) {
            return a.cm == 1;
        }
        f$m(a, b, c) {
            let d = a.cv;
            if (this.j) {
                a.ba.onScrollbarDrag(b, c);
                return;
            }
            if (this.aj.isEmpty && c) {
                this.ag(a, b, c);
            }
            let e = 2;
            if (c) {
                e = 10;
            }
            let f = false;
            let g = new Rect(2, { $type: Point_$type, x: this.aj.x, y: this.aj.y }, b);
            let h = new Rect(0, 0, 0, 0, 0);
            if (!this.ak.isEmpty) {
                h = new Rect(2, { $type: Point_$type, x: this.ak.x, y: this.ak.y }, b);
            }
            if (h.width > e && h.height > e) {
                f = true;
            }
            if (!a.e7) {
                if (f) {
                    this.i = false;
                }
            }
            if (!a.e7 && (a.dw || !c)) {
                a.l0(a.th(b));
            }
            if (this.m(a)) {
                if (f) {
                    let i = a.t1(g);
                    a.oe(i, true);
                }
                else {
                    a.oe(Rect.empty, true);
                }
                a.m0();
                d.eg(g);
            }
            let j = a.t2;
            let k = a.tn;
            if (this.n(a)) {
                let l = j;
                let m = k.left + k.width * (this.aj.x - b.x) / l.width;
                let n = k.top + k.height * (this.aj.y - b.y) / l.height;
                let o = new Rect(0, m, n, k.width, k.height);
                if (this.o(a, c)) {
                    if (h.width != 0 || h.height != 0) {
                        a.n9();
                    }
                    a.oe(Rect.empty, true);
                    let p = a.tn;
                    a.pu(o, true);
                    let q = a.tn;
                    if (p.equals1(q) && a.cv.k.ac) {
                        a.cv.k.au();
                    }
                    this.aj = new Rect(3, b, new Size(1, 0, 0));
                    this.al = new Rect(3, b, new Size(1, 0, 0));
                }
                else {
                    a.oe(o, true);
                }
            }
            this.al = new Rect(3, b, new Size(1, 0, 0));
            d.bu(b);
        }
        f$l(a, b, c, d) {
            let e = a.cv;
            let f = 2;
            if (c) {
                f = 10;
            }
            let g = a.t2;
            let h = a.tn;
            if (!d) {
                if (this.j) {
                    this.f$c.onScrollbarDragComplete(b, c);
                    this.j = false;
                    e.bw();
                    return;
                }
            }
            if (!this.i) {
                let i = false;
                let j = new Rect(2, { $type: Point_$type, x: this.aj.x, y: this.aj.y }, b);
                if (j.width > f && j.height > f) {
                    i = true;
                }
                if (a.cm == 1) {
                    a.mz();
                    e.cf();
                    if (i) {
                        a.pu(a.t1(j), true);
                    }
                }
                if (a.cm == 2) {
                    let k = g;
                    let l = h.left + h.width * (this.aj.x - b.x) / k.width;
                    let m = h.top + h.height * (this.aj.y - b.y) / k.height;
                    a.pu(new Rect(0, l, m, h.width, h.height), true);
                }
            }
            let n = false;
            let o = new Rect(2, { $type: Point_$type, x: this.ak.x, y: this.ak.y }, b);
            if (o.width > f || o.height > f) {
                n = true;
            }
            if (n) {
                a.fg = true;
            }
            a.cm = 0;
            a.oe(Rect.empty, true);
            e.bw();
            a.fg = false;
            e.cg();
            e.cl();
            if (c) {
                e.ck();
                e.cg();
                e.cl();
                e.ch();
            }
            a.l9();
            a.n8();
            a.ns(b, c, d);
        }
        f$af(a) {
            if (this.g != null) {
                this.g.h = !a.e8;
            }
        }
        f$e(a, b) {
            let c = a.cv;
            let d = a.tn;
            if (a.cm == 2 && b == 8) {
                c.bt();
                a.cm = 0;
                a.n8();
                a.oe(Rect.empty, true);
                if (a.cc == 1) {
                    a.pu(this.am, true);
                }
                return true;
            }
            if (a.cm == 1 && b == 8) {
                c.bt();
                a.cm = 0;
                a.n8();
                c.cf();
                a.oe(Rect.empty, true);
                return true;
            }
            let e = Rect.empty;
            let 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.pu(e, true);
            }
            return f;
        }
        f$f(a, b, c) {
            let d = a.cv;
            let e = a.tn;
            let f = e.left + e.width * b.x / a.t2.width;
            let g = e.top + e.height * b.y / a.t2.height;
            let h = 1 - MathUtil.d(c, -0.5, 0.5);
            let i = Math.max(0, f - h * (f - e.left));
            let j = Math.min(1, g + h * (e.bottom - g));
            let k = Math.min(1, f + h * (e.right - f));
            let l = Math.max(0, g - h * (g - e.top));
            a.n9();
            this.x(a, 1000);
            a.pu(new Rect(0, i, l, k - i, j - l), true);
            return a.et();
        }
        x(a, b) {
            a.cv.bz(b);
        }
        f$o(a, b) {
            let c = a.tn;
            let d = c.left + c.width * b.x / a.t2.width;
            let e = c.top + c.height * b.y / a.t2.height;
            let f = 0.7;
            let g = Math.max(0, d - f * (d - c.left));
            let h = Math.min(1, e + f * (c.bottom - e));
            let i = Math.min(1, d + f * (c.right - d));
            let j = Math.max(0, e - f * (e - c.top));
            a.pu(new Rect(0, g, j, i - g, h - j), true);
        }
        f$i(a) {
            this.g.ac();
        }
        f$d(a, b, c, d, e, f, g) {
            let h = true;
            let i = false;
            let j = false;
            let k = a;
            if (k.au == 1) {
                h = false;
                i = true;
            }
            if (k.au == 3 || k.au == 4) {
                i = true;
            }
            if (k.au == 4) {
                j = true;
            }
            let l = truncate(Math.round(d.x));
            let m = truncate(Math.round(d.y));
            f = null;
            let n = -1;
            if (h && c != null) {
                let o = l;
                let p = m;
                if (a.gh != 1) {
                    o = truncate(Math.round(d.x * a.gh));
                    p = truncate(Math.round(d.y * a.gh));
                }
                let 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) {
                    let num2_ = q[2];
                    if (num2_ % 4 != 0) {
                        num2_ = num2_ + (4 - (num2_ % 4));
                    }
                    let num1_ = q[1];
                    if (num1_ % 4 != 0) {
                        num1_ = num1_ + (4 - (num1_ % 4));
                    }
                    let num0_ = q[0];
                    if (num0_ % 4 != 0) {
                        num0_ = num0_ + (4 - (num0_ % 4));
                    }
                    let 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--;
                }
            }
            let r = null;
            let s = -1;
            if (n >= 0) {
                let t = false;
                let u = 0;
                for (let v of fromEnum(b)) {
                    if (!v.fk) {
                        continue;
                    }
                    if (t) {
                        break;
                    }
                    if (v.isStacked) {
                        v.n5((w) => {
                            if (w.jl == n) {
                                r = w;
                                s = u;
                                t = true;
                                return false;
                            }
                            return true;
                        });
                    }
                    else if (v.jl == n) {
                        r = v;
                        s = u;
                        break;
                    }
                    u++;
                }
            }
            let w = null;
            if (i) {
                let x = false;
                for (let y = b.count - 1; y >= 0; y--) {
                    let z = b._inner[y];
                    if (!z.fk) {
                        continue;
                    }
                    let aa = z.cj;
                    if (!z.gl(aa.bx, aa.by, aa)) {
                        continue;
                    }
                    if (!x && y < s && h && !j) {
                        if (r != null) {
                            w = r;
                            x = true;
                            break;
                        }
                    }
                    if (z != null && z.bw == 1) {
                        if (z.f4(d, g)) {
                            w = z;
                            break;
                        }
                    }
                }
                if (h && !x) {
                    if (r != null) {
                        w = r;
                        x = true;
                    }
                }
            }
            else {
                w = r;
            }
            if (w != null) {
                let ab = w.au({ $type: Point_$type, x: l, y: m }, g);
                if (ab != null) {
                    f = ab;
                }
                return {
                    ret: w,
                    p5: f
                };
            }
            return {
                ret: null,
                p5: f
            };
        }
        f$g(a, b) {
            if (PointUtil.equals(b, null)) {
                return false;
            }
            let c = b.x;
            let d = b.y;
            if (this.j) {
                return true;
            }
            if (c >= a.t2.left && d >= a.t2.top && c <= a.t2.left + a.t2.width && d <= a.t2.top + a.t2.height) {
                let e = a.co;
                if (e != null && e.viewShouldInteract(b)) {
                    return false;
                }
                return true;
            }
            return false;
        }
        c(a) {
            if (a != null) {
                return a.bk();
            }
            else {
                return null;
            }
        }
        f$w(a, b, c, d, e, f) {
            if (!f && a.dr) {
                this.ah(a, false);
            }
            let g = new MouseEventArgs();
            g.position = d;
            if (a.cm == 2 || a.cm == 1 || a.e7 || (a.co != null && a.co.isPinching)) {
                if (this.d != null) {
                    this.d.a7.a$z(this.d, g.position, this.a, g, f);
                    this.d = null;
                }
                return;
            }
            let h = null;
            let i = ((() => { let j = this.f$d(a, b, c, d, !e, h, f); h = j.p5; return j.ret; })());
            this.a = h;
            let j = this.c(i);
            if (i != null) {
                let k = false;
                let 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.a7.a$z(this.d, g.position, h, g, f);
                            if (j != null) {
                                j.a7.a$z(j, g.position, h, g, f);
                            }
                        }
                    }
                    this.d = i;
                    i.ot(g.position, h, g, f);
                    if (j != null) {
                        j.ot(g.position, h, g, f);
                    }
                }
                else {
                    this.d = i;
                    i.a7.a$ab(i, g.position, h, g, f);
                    if (j != null) {
                        j.a7.a$ab(j, g.position, h, g, f);
                    }
                }
            }
            else {
                if (this.d != null) {
                    j = this.c(this.d);
                    this.d.a7.a$z(this.d, g.position, h, g, f);
                    if (j != null) {
                        j.a7.a$z(j, g.position, h, g, f);
                    }
                    this.d = null;
                }
                for (let m = 0; m < a.series.count; m++) {
                    let n = a.series._inner[m];
                    if (n.a7.a$b) {
                        j = this.c(n);
                        n.a7.a$z(n, g.position, n.a7.a$p, g, f);
                        if (j != null) {
                            j.a7.a$z(j, g.position, n.a7.a$p, g, f);
                        }
                    }
                }
            }
        }
        f$v(a, b) {
            if (this.d != null) {
                let c = this.c(this.d);
                let d = new MouseEventArgs();
                d.position = b;
                this.d.a7.a$z(this.d, d.position, null, d, false);
                if (c != null) {
                    c.a7.a$z(c, d.position, null, d, false);
                }
                this.d = null;
            }
            a.nm(b, a.cm != 0 || a.ey);
        }
        f$u(a, b, c) {
            if (this.d != null) {
                let d = new MouseButtonEventArgs();
                d.position = c;
                if (b.al) {
                    this.d.a7.a$ac(this.d, d.position, this.a, d);
                }
                else {
                    this.d.a7.a$w(this.d, d.position, this.a, d);
                }
            }
        }
        f$x(a, b, c) {
            let d;
            let e = (this.d != null) ? this.d : ((() => { let f = a.cv.f(c, false, d, false); d = f.p2; return f.ret; })());
            if (e != null) {
                let f = new MouseButtonEventArgs();
                f.position = c;
                if (b.al) {
                    e.a7.a$ad(e, f.position, this.a, f);
                }
                else {
                    e.a7.a$aa(e, f.position, this.a, f);
                }
            }
        }
        f$t(a, b, c) {
            if (!c && a.e0) {
                this.ah(a, false);
            }
            if (c && !a.e0) {
                this.ah(a, true);
            }
            a.m4(b, c);
        }
        ah(a, b) {
            if (a != null) {
                if (!this.k) {
                    a.dr = b;
                }
            }
        }
        f$aa(a, b) {
            this.h = true;
        }
        get k() {
            return this.h;
        }
    }
    SeriesViewerInteractionManager.$t = /*@__PURE__*/ markType(SeriesViewerInteractionManager, 'SeriesViewerInteractionManager', Base.$, [ISeriesViewerInteractionManager_$type]);
    return SeriesViewerInteractionManager;
})();
