/*
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 { MarkerSeries } from "./MarkerSeries";
import { ISupportsErrorBars_$type } from "./ISupportsErrorBars";
import { ITrendLineSeries_$type } from "./ITrendLineSeries";
import { ScatterAxisInfoCache } from "./ScatterAxisInfoCache";
import { NumericXAxis } from "./NumericXAxis";
import { DependencyProperty } from "igniteui-react-core/ES2015/DependencyProperty";
import { NumericYAxis } from "./NumericYAxis";
import { Series } from "./Series";
import { TrendLineType_$type } from "igniteui-react-core/ES2015/TrendLineType";
import { Brush } from "igniteui-react-core/ES2015/Brush";
import { PenLineCap_$type } from "igniteui-react-core/ES2015/PenLineCap";
import { DoubleCollection } from "igniteui-react-core/ES2015/DoubleCollection";
import { CollisionAvoidanceType_$type } from "./CollisionAvoidanceType";
import { ScatterErrorBarSettings } from "./ScatterErrorBarSettings";
import { ScatterFrame } from "./ScatterFrame";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { ScalerParams } from "./ScalerParams";
import { Rect } from "igniteui-react-core/ES2015/Rect";
import { Base, Type, enumGetBox, Number_$type, typeCast, fromEnum, Point_$type, markType, PointUtil, runOn } from "igniteui-react-core/ES2015/type";
import { Marker } from "./Marker";
import { MarkerSeriesView } from "./MarkerSeriesView";
import { IFastItemsSource_$type } from "igniteui-react-core/ES2015/IFastItemsSource";
import { Clipper } from "igniteui-react-core/ES2015/Clipper";
import { OwnedPoint } from "./OwnedPoint";
import { Dictionary$2 } from "igniteui-react-core/ES2015/Dictionary$2";
import { AxisRange } from "./AxisRange";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { ScatterTrendLineManager } from "./ScatterTrendLineManager";
import { ErrorBarsHelper } from "./ErrorBarsHelper";
import { PathGeometry } from "igniteui-react-core/ES2015/PathGeometry";
import { HashPool$2 } from "igniteui-react-core/ES2015/HashPool$2";
import { PropertyMetadata } from "igniteui-react-core/ES2015/PropertyMetadata";
import { isNaN_, isInfinity } from "igniteui-react-core/ES2015/number";
import { Path } from "igniteui-react-core/ES2015/Path";
import { DataTemplateMeasureInfo } from "igniteui-react-core/ES2015/DataTemplateMeasureInfo";
import { Size } from "igniteui-react-core/ES2015/Size";
import { NumericMarkerManager } from "./NumericMarkerManager";
import { stringIsNullOrEmpty } from "igniteui-react-core/ES2015/string";
/**
 * @hidden
 */
export class ScatterBase extends MarkerSeries {
    constructor() {
        super();
        this.mx = null;
        this.m5 = null;
        this.m7 = null;
        this.oo = null;
        this.op = null;
        this.m2 = null;
        this.m4 = null;
        this.m1 = null;
        this.m3 = null;
        this.m0 = null;
        this.m3 = new ScatterFrame();
        this.op = Rect.empty;
        this.oo = Rect.empty;
    }
    bf() {
        return new ScatterBaseView(this);
    }
    hn() {
        super.hn();
        this.xAxis = null;
        this.yAxis = null;
    }
    im(a) {
        super.im(a);
        this.my = a;
    }
    get_c4() {
        return true;
    }
    ag() {
        return [this.xAxis, this.yAxis];
    }
    ch(a, b, c) {
        if (!this.hasMarkers) {
            return false;
        }
        let d = this.xAxis;
        let e = new ScalerParams(1, this.bs.mq, this.lr, d.b8);
        e.c = this.getEffectiveViewport1(this.bi);
        let f = this.yAxis;
        let g = new ScalerParams(1, this.bs.mq, this.lr, f.b8);
        g.c = this.getEffectiveViewport1(this.bi);
        a.clear();
        this.lt.cc((h) => {
            if (h._visibility == 0) {
                let i = new SeriesPointOfInterest();
                let j = h.n;
                let k = h.o;
                if (j < this.lr.left || j > this.lr.right || k < this.lr.top || k > this.lr.bottom) {
                    return;
                }
                i.b = d.dw(j, e);
                i.c = f.dw(k, g);
                i.a = h.content;
                a.add(i);
            }
        });
        return true;
    }
    bd() {
        if (this.be == 0) {
            if (this.nd <= 2000) {
                return 1;
            }
            else {
                return super.bd();
            }
        }
        else {
            return super.bd();
        }
    }
    lp(a) {
        if (!this.hasMarkers || !this.lw()) {
            return Rect.empty;
        }
        let b = this.lt.bv(this.k9(a));
        if (b != null) {
            return this.lt.cm(b);
        }
        return Rect.empty;
    }
    dg(a, b) {
        if (this.lx(a, b)) {
            return true;
        }
        return false;
    }
    get m6() {
        return this.m5;
    }
    set m6(a) {
        if (this.m5 != a) {
            let b = this.m6;
            this.m5 = a;
            this.raisePropertyChanged("XColumn", b, this.m6);
        }
    }
    get m8() {
        return this.m7;
    }
    set m8(a) {
        if (this.m7 != a) {
            let b = this.m8;
            this.m7 = a;
            this.raisePropertyChanged("YColumn", b, this.m8);
        }
    }
    get ol() {
        return this.c(ScatterBase.n6);
    }
    set ol(a) {
        this.h(ScatterBase.n6, a);
    }
    get GetErrorBarsXAxis() {
        return this.xAxis;
    }
    get GetErrorBarsYAxis() {
        return this.yAxis;
    }
    h4() {
        super.h4();
        if (this.xAxis != null) {
            this.xAxis.g0(false);
        }
        if (this.yAxis != null) {
            this.yAxis.g0(false);
        }
    }
    is(a, b, c, d) {
        super.is(a, b, c, d);
        if (this.my.ct.g$b(a, b, c, d)) {
            this.i6(false);
            this.ic();
        }
        switch (b) {
            case "FastItemsSource":
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.m6);
                    c.deregisterColumn(this.m8);
                    this.m6 = null;
                    this.m8 = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.m6 = this.bw(this.nk);
                    this.m8 = this.bw(this.no);
                }
                if ((this.yAxis != null && !this.yAxis.ck()) || (this.xAxis != null && !this.xAxis.ck())) {
                    this.i6(false);
                }
                break;
            case ScatterBase.$$p[3]:
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ch(this);
                }
                if ((this.xAxis != null && !this.xAxis.ck()) || (d == null && c != null)) {
                    this.i6(false);
                }
                this.ic();
                break;
            case ScatterBase.$$p[5]:
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ch(this);
                }
                if ((this.yAxis != null && !this.yAxis.ck()) || (d == null && c != null)) {
                    this.i6(false);
                }
                this.ic();
                break;
            case ScatterBase.$$p[4]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.m6);
                    this.m6 = this.bw(this.nk);
                }
                break;
            case "XColumn":
                this.my.ct.g$i();
                if (this.xAxis != null && !this.xAxis.ck()) {
                    this.i6(false);
                }
                break;
            case ScatterBase.$$p[6]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.m8);
                    this.m8 = this.bw(this.no);
                }
                break;
            case "YColumn":
                this.my.ct.g$i();
                if (this.yAxis != null && !this.yAxis.ck()) {
                    this.i6(false);
                }
                break;
            case ScatterBase.$$p[1]:
                this.i6(false);
                this.ic();
                break;
            case ScatterBase.$$p[2]:
                this.i6(false);
                this.ic();
                break;
            case "TransitionProgress":
                this.m4.c(this.ew, this.m2, this.m1);
                this.nq();
                try {
                    if (this.cc(this.bi)) {
                        return;
                    }
                    if ((Math.round(this.ew * 100000) / 100000) == 1) {
                        this.n4(this.m1, this.my);
                    }
                    else {
                        this.n4(this.m4, this.my);
                    }
                    if (this.bs != null) {
                        this.bs.jj(this);
                    }
                }
                finally {
                    this.n5();
                }
                break;
            case "TrendLineBrush":
                this.jh();
                break;
            case ScatterBase.$$p[0]:
                if (this.mz != null) {
                    this.mz.r = this;
                }
                this.i6(false);
                this.ic();
                break;
            case "TrendLineType":
                this.ic();
                break;
        }
    }
    na(a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    }
    m9(a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    }
    n5() {
        this.oo = Rect.empty;
        this.op = Rect.empty;
    }
    nq() {
        let a = this.getViewInfo(this.oo, this.op);
        this.oo = a.p0;
        this.op = a.p1;
    }
    nb(a, b) {
        if (b != 3) {
            return true;
        }
        if (a == null) {
            return true;
        }
        if (this.nk == a || this.no == a) {
            return true;
        }
        return false;
    }
    hs(a, b, c, d) {
        let e = false;
        if (!this.nb(d, a)) {
            return;
        }
        this.my.ct.g$e(a, b, c, d);
        if (this.xAxis != null && !this.xAxis.ck()) {
            e = true;
        }
        if (this.yAxis != null && !this.yAxis.ck()) {
            e = true;
        }
        if (e) {
            this.i6(true);
        }
    }
    ny(a) {
        this.nz(a, null);
    }
    nz(a, b) {
        let c = this.m6 != null ? this.m6.count : 0;
        let d = this.m8 != null ? this.m8.count : 0;
        let e = Math.min(c, d);
        if (e <= this.nd) {
            a.m.clear();
            let f = new List$1(OwnedPoint.$, 0);
            for (let g of fromEnum(a.u.values)) {
                f.add(g);
            }
            let h = this.bz;
            f.aa((i, j) => {
                let k = h.indexOf(i.a);
                let l = h.indexOf(j.a);
                if (k < l) {
                    return -1;
                }
                if (k > l) {
                    return 1;
                }
                return 0;
            });
            if (b != null) {
                b.i = a.m;
            }
            for (let i of fromEnum(f)) {
                if (h.indexOf(i.a) >= 0) {
                    if (b != null) {
                        b.j(i.c);
                    }
                    else {
                        a.m.add({ $type: Point_$type, x: i.c.x, y: i.c.y });
                    }
                }
            }
        }
    }
    an(a) {
        if (a != null && a == this.xAxis && this.m6 != null) {
            return new AxisRange(this.m6.minimum, this.m6.maximum);
        }
        if (a != null && a == this.yAxis && this.m8 != null) {
            return new AxisRange(this.m8.minimum, this.m8.maximum);
        }
        return null;
    }
    fm(a) {
        return null;
    }
    e5(a) {
        return -1;
    }
    c8(a) {
        let b = this.bs != null ? this.bs.mq : Rect.empty;
        b = b.copy();
        let c = this.bs != null ? this.bs.m3 : Rect.empty;
        let d = new Rect(0, 0, 0, 1, 1);
        let e = this.ll(this.bi);
        let f = new ScalerParams(0, d, d, this.xAxis.b8, e);
        let g = ((() => {
            let $ret = new ScalerParams(0, d, d, this.yAxis.b8, e);
            $ret.b = this.ee();
            return $ret;
        })());
        let h = !b.isEmpty && !c.isEmpty && this.bz != null ? this.bz.indexOf(a) : -1;
        let i = this.xAxis != null && this.m6 != null && h < this.m6.count ? this.xAxis.dt(this.m6.item(h), f) : NaN;
        let j = this.yAxis != null && this.m8 != null && h < this.m8.count ? this.yAxis.dt(this.m8.item(h), g) : NaN;
        if (!isNaN_(i)) {
            if (i < b.left + 0.1 * b.width) {
                i = i + 0.4 * b.width;
                b.x = i - 0.5 * b.width;
            }
            if (i > b.right - 0.1 * b.width) {
                i = i - 0.4 * b.width;
                b.x = i - 0.5 * b.width;
            }
        }
        if (!isNaN_(j)) {
            if (j < b.top + 0.1 * b.height) {
                j = j + 0.4 * b.height;
                b.y = j - 0.5 * b.height;
            }
            if (j > b.bottom - 0.1 * b.height) {
                j = j - 0.4 * b.height;
                b.y = j - 0.5 * b.height;
            }
        }
        if (this.bn != null) {
            this.bn.ap(this.bs, b, true);
        }
        return h >= 0;
    }
    jl(a, b) {
        this.i6(false);
    }
    jm(a, b) {
        this.i6(false);
    }
    nr(a, b, c, d, e) {
        b.g = new Dictionary$2(Base.$, OwnedPoint.$, 1, c);
        let f = this.getEffectiveViewport1(a);
        let g = this.bz;
        let h;
        let i;
        let j = ((() => {
            let $ret = new ScalerParams(0, d, e, this.mx.d, f);
            $ret.c = this.getEffectiveViewport1(a);
            return $ret;
        })());
        let k = ((() => {
            let $ret = new ScalerParams(0, d, e, this.mx.e, f);
            $ret.c = this.getEffectiveViewport1(a);
            $ret.b = this.ee();
            return $ret;
        })());
        for (let l = 0; l < c; l++) {
            h = this.m6.item(l);
            i = this.m8.item(l);
            let m = { $type: Point_$type, x: this.mx.a.dt(h, j), y: this.mx.b.dt(i, k) };
            if (!isInfinity(m.x) && !isInfinity(m.y)) {
                let n = g.item(l);
                if (!b.g.containsKey(n)) {
                    let o = { $type: Point_$type, x: h, y: i };
                    let p = { $type: Point_$type, x: m.x, y: m.y };
                    b.g.addItem(n, ((() => {
                        let $ret = new OwnedPoint();
                        $ret.a = n;
                        $ret.b = o;
                        $ret.c = p;
                        return $ret;
                    })()));
                }
            }
        }
    }
    nv(a, b) {
        a.j.clear();
        a.n.clear();
        a.h.clear();
        a.l.clear();
        a.i.clear();
        a.k.clear();
        let c = Math.min(this.m6 != null ? this.m6.count : 0, this.m8 != null ? this.m8.count : 0);
        let d = b.bs;
        let e = b.br;
        let f = this.getEffectiveViewport1(b);
        let g = new ScalerParams(0, d, e, this.xAxis.b8, f);
        g.c = this.getEffectiveViewport1(b);
        let h = ((() => {
            let $ret = new ScalerParams(0, d, e, this.yAxis.b8, f);
            $ret.b = this.ee();
            return $ret;
        })());
        ;
        h.c = this.getEffectiveViewport1(b);
        if (c < 1) {
            return;
        }
        this.mx = ((() => {
            let $ret = new ScatterAxisInfoCache();
            $ret.a = this.xAxis;
            $ret.b = this.yAxis;
            $ret.d = this.xAxis.b8;
            $ret.e = this.yAxis.b8;
            $ret.c = this.bz;
            return $ret;
        })());
        let i = b;
        if (c <= this.nd) {
            this.nr(i, a, c, d, e);
        }
        if (this.lw()) {
            b.cr.l(a.j, this.nd, d, e, this.er);
        }
        let j = ((() => {
            let $ret = new Clipper(0, e, false);
            $ret.i = a.n;
            return $ret;
        })());
        let k = this.lj(b);
        let l = this.xAxis.dw(k.left, g);
        let m = this.xAxis.dw(k.right, g);
        b.ct.p(a.n, this.trendLineType, this.m6, this.m8, this.trendLinePeriod, (n) => this.xAxis.dt(n, g), (n) => this.yAxis.dt(n, h), ((() => {
            let $ret = new TrendResolutionParams();
            $ret.b = this.er;
            $ret.f = e;
            $ret.g = d;
            return $ret;
        })()), j, l, m);
        this.nt(a, b);
    }
    hp(a, b) {
        super.hp(a, b);
        let c = b;
        c.c0(a);
    }
    n4(a, b) {
        let c = b.br;
        this.mx = ((() => {
            let $ret = new ScatterAxisInfoCache();
            $ret.a = this.xAxis;
            $ret.b = this.yAxis;
            $ret.d = this.xAxis.b8;
            $ret.e = this.yAxis.b8;
            return $ret;
        })());
        if (this.lw()) {
            b.cr.j(a.j, this.ly);
        }
        b.cj();
        let d = ((() => {
            let $ret = new Clipper(1, NaN, c.bottom, NaN, c.top, false);
            $ret.i = b.ct.g$j.aj;
            return $ret;
        })());
        b.ct.g$h(a.n, d);
        this.n1(a, b);
    }
    nt(a, b) {
        let c = new ErrorBarsHelper(this, b);
        if (this.mz == null) {
            return;
        }
        let d = this.mz.u;
        let e = this.mz.v;
        let f = 0;
        let g = 0;
        let h = 0;
        let i = 0;
        for (let j of fromEnum(a.j.keys)) {
            let k = a.j.item(j);
            if (d != null) {
                switch (d.getCalculatorType()) {
                    case 1:
                        let l = this.nw(k, c, d, h, i, true);
                        h = l.p3;
                        i = l.p4;
                        break;
                    case 0:
                        let m = this.nu(k, c, d, h, i, true);
                        h = m.p3;
                        i = m.p4;
                        break;
                    case 2:
                        let n = this.ns(k, c, d, j, h, i, true);
                        h = n.p4;
                        i = n.p5;
                        break;
                    case 3:
                        let o = this.nx(c, d, f, h, i, true);
                        f = o.p2;
                        h = o.p3;
                        i = o.p4;
                        break;
                    case 4:
                        let p = this.nu(k, c, d, h, i, true);
                        h = p.p3;
                        i = p.p4;
                        break;
                }
                ;
                let q = new OwnedPoint();
                q.c = c.l(d, this.mx.a, k.c, f);
                ;
                q.a = k.a;
                a.h.addItem(j, q);
                a.i.addItem(j, [h, i]);
            }
            if (e != null) {
                switch (e.getCalculatorType()) {
                    case 1:
                        let r = this.nw(k, c, e, h, i, false);
                        h = r.p3;
                        i = r.p4;
                        break;
                    case 0:
                        let s = this.nu(k, c, e, h, i, false);
                        h = s.p3;
                        i = s.p4;
                        break;
                    case 2:
                        let t = this.ns(k, c, e, j, h, i, false);
                        h = t.p4;
                        i = t.p5;
                        break;
                    case 3:
                        let u = this.nx(c, e, g, h, i, false);
                        g = u.p2;
                        h = u.p3;
                        i = u.p4;
                        break;
                    case 4:
                        let v = this.nu(k, c, e, h, i, false);
                        h = v.p3;
                        i = v.p4;
                        break;
                }
                ;
                let w = new OwnedPoint();
                w.c = c.m(e, this.mx.b, k.c, g);
                ;
                w.a = k.a;
                a.l.addItem(j, w);
                a.k.addItem(j, [h, i]);
            }
        }
    }
    nw(a, b, c, d, e, f) {
        if (f) {
            let g;
            let h, i;
            i = this.mx.a;
            if (this.mz.s == 0) {
                g = a.c.x;
                h = this.mx.a;
            }
            else {
                g = a.c.y;
                h = this.mx.b;
            }
            let j = b.f(g, c, h, i, d, e);
            d = j.p4;
            e = j.p5;
        }
        else {
            let k;
            let l, m;
            m = this.mx.b;
            if (this.mz.t == 0) {
                k = a.c.x;
                l = this.mx.a;
            }
            else {
                k = a.c.y;
                l = this.mx.b;
            }
            let n = b.f(k, c, l, m, d, e);
            d = n.p4;
            e = n.p5;
        }
        return {
            p3: d,
            p4: e
        };
    }
    nu(a, b, c, d, e, f) {
        if (f) {
            let g = b.j(a.c.x, c, this.mx.a, d, e);
            d = g.p3;
            e = g.p4;
        }
        else {
            let h = b.j(a.c.y, c, this.mx.b, d, e);
            d = h.p3;
            e = h.p4;
        }
        return {
            p3: d,
            p4: e
        };
    }
    ns(a, b, c, d, e, f, g) {
        let h = c.getItemColumn();
        let i = this.bz.indexOf(d);
        if (h != null && i < h.count) {
            let j = h.item(i);
            if (g) {
                let k = b.h(a.c.x, j, this.mx.a, e, f);
                e = k.p3;
                f = k.p4;
            }
            else {
                let l = b.h(a.c.y, j, this.mx.b, e, f);
                e = l.p3;
                f = l.p4;
            }
        }
        else {
            e = f = NaN;
        }
        return {
            p4: e,
            p5: f
        };
    }
    nx(a, b, c, d, e, f) {
        let g = a.i(b, c);
        c = g.p1;
        if (f) {
            let h = a.k(c, b, this.mx.a, d, e);
            d = h.p3;
            e = h.p4;
        }
        else {
            let i = a.k(c, b, this.mx.b, d, e);
            d = i.p3;
            e = i.p4;
        }
        return {
            p2: c,
            p3: d,
            p4: e
        };
    }
    n1(a, b) {
        if (!b.l() || this.mz == null) {
            b.c1();
            return;
        }
        this.n2(a, b);
        this.n3(a, b);
    }
    n2(a, b) {
        b.cy();
        let c = new ErrorBarsHelper(this, b);
        let d = new PathGeometry();
        let e = this.mz.u;
        for (let f of fromEnum(a.j.keys)) {
            if (e != null && a.i.containsKey(f)) {
                let g = a.i.item(f)[0];
                let h = a.i.item(f)[1];
                if (!isNaN_(g) && !isNaN_(h)) {
                    let i = a.h.item(f).c;
                    if (this.mz.o == 1 || this.mz.o == 2) {
                        c.d(d, i, g, true);
                    }
                    if (this.mz.o == 1 || this.mz.o == 3) {
                        c.d(d, i, h, false);
                    }
                }
            }
        }
        b.c2(d);
    }
    n3(a, b) {
        b.cz();
        let c = new ErrorBarsHelper(this, b);
        let d = new PathGeometry();
        let e = this.mz.v;
        for (let f of fromEnum(a.j.keys)) {
            if (e != null && a.k.containsKey(f)) {
                let g = a.k.item(f)[0];
                let h = a.k.item(f)[1];
                if (!isNaN_(g) && !isNaN_(h)) {
                    let i = a.l.item(f).c;
                    if (this.mz.p == 1 || this.mz.p == 2) {
                        c.e(d, i, g, true);
                    }
                    if (this.mz.p == 1 || this.mz.p == 3) {
                        c.e(d, i, h, false);
                    }
                }
            }
        }
    }
    dv(a, b, c) {
        let d = true;
        if (!super.dv(a, b, c) || b.isEmpty || a.isEmpty || this.xAxis == null || this.yAxis == null || this.xAxis.bf == null || this.yAxis.bf == null || this.m6 == null || this.m8 == null || this.m6.count == 0 || this.m8.count == 0 || this.bz == null || this.bz.count != this.m6.count || this.bz.count != this.m8.count || this.xAxis.bf == null || this.yAxis.bf == null || this.xAxis.jx == this.xAxis.jw || this.yAxis.jx == this.yAxis.jw) {
            d = false;
        }
        return d;
    }
    getViewInfo(a, b) {
        if (!this.oo.isEmpty && !this.op.isEmpty) {
            a = this.oo;
            b = this.op;
            return {
                p0: a,
                p1: b
            };
        }
        a = this.bi.br;
        b = this.bi.bs;
        return {
            p0: a,
            p1: b
        };
    }
    i7(a) {
        this.nq();
        try {
            if (this.cc(this.bi)) {
                return;
            }
            if (this.bz != null && this.bz.count > this.nd) {
                a = false;
            }
            if (this.c9(a) && !this.dd) {
                let b = this.m2;
                if (this.ca()) {
                    if (this.bt.g) {
                        this.bt.t();
                    }
                    this.m2 = this.m4;
                    this.m4 = b;
                }
                else {
                    this.m2 = this.m1;
                    this.m1 = b;
                }
                this.nv(this.m1, this.my);
                this.je();
            }
            else {
                if (!this.dd) {
                    this.nv(this.m1, this.my);
                }
                this.n4(this.m1, this.my);
            }
        }
        finally {
            this.n5();
        }
    }
    jh() {
        super.jh();
        if (this.fe < 0) {
            return;
        }
        this.my.c5();
    }
    i8(a, b) {
        super.i8(a, b);
        if (!this.dk) {
            this.bi.az(b);
            return;
        }
        this.bi.az(b);
        if (this.cc(this.bh)) {
            return;
        }
        let c = typeCast(ScatterBaseView.$, this.bh);
        if (!this.de) {
            this.m3 = new ScatterFrame();
            this.nv(this.m3, c);
        }
        this.de = false;
        this.n4(this.m3, c);
        this.dk = false;
    }
    i5(a, b, c, d, e) {
        super.i5(a, b, c, d, e);
        let f = this.a0.a$h.item(d);
        let g = f;
        f.ay(c);
        if (this.cc(g)) {
            return;
        }
        if (this.m0 == null) {
            this.m0 = new ScatterFrame();
        }
        this.nv(this.m0, g);
        this.n4(this.m0, g);
    }
    n0(a, b) {
        let c = new List$1(Base.$, 0);
        for (let d of fromEnum(b.c)) {
            if (!a.containsKey(d)) {
                c.add1(d);
            }
        }
        for (let e of fromEnum(c)) {
            b.g(e);
        }
    }
    mt(a, b, c, d, e) {
        if (c == null || c.length != this.mx.c.count) {
            c = new Array(this.mx.c.count);
            for (let f = 0; f < this.mx.c.count; f++) {
                c[f] = PointUtil.create();
            }
        }
        let g = this.getEffectiveViewport1(a);
        let h = ((() => {
            let $ret = new ScalerParams(0, d, e, this.xAxis.b8, g);
            $ret.c = this.getEffectiveViewport1(a);
            return $ret;
        })());
        let i = ((() => {
            let $ret = new ScalerParams(0, d, e, this.yAxis.b8, g);
            $ret.c = this.getEffectiveViewport1(a);
            $ret.b = this.ee();
            return $ret;
        })());
        let j = this.lj(a);
        let k = this.mx.a.dw(j.left, h);
        let l = this.mx.a.dw(j.right, h);
        let m = this.mx.b.dw(j.bottom, i);
        let n = this.mx.b.dw(j.top, i);
        if (this.mx.d) {
            let o = k;
            k = l;
            l = o;
        }
        if (this.mx.e) {
            let p = m;
            m = n;
            n = p;
        }
        let q = this.mx;
        let r = q.a;
        let s = q.b;
        let t;
        let u;
        let v = this.m6;
        let w = this.m8;
        for (let x = 0; x < this.mx.c.count; x++) {
            t = v.item(x);
            u = w.item(x);
            if (t >= k && t <= l && u >= m && u <= n) {
                c[x].x = r.dt(t, h);
                c[x].y = s.dt(u, i);
            }
            else {
                c[x].x = NaN;
                c[x].y = NaN;
            }
        }
        return c;
    }
    nc(a, b) {
        if (b == null) {
            b = new List$1(Number_$type, 2, a.e);
        }
        else {
            b.clear();
        }
        let c = 0;
        let d = this.bz;
        for (let e of fromEnum(a.c)) {
            b.add(d.indexOf(e));
        }
        return b;
    }
    hy(a) {
        super.hy(a);
        this.a2.exportTrendlineData(this, a, this.my.ct.g$j);
    }
    ee() {
        return Series.ef(this.m8, null);
    }
}
ScatterBase.$t = markType(ScatterBase, 'ScatterBase', MarkerSeries.$, [ISupportsErrorBars_$type, ITrendLineSeries_$type]);
ScatterBase.n6 = DependencyProperty.i("ActualTrendLineBrush", Brush.$, ScatterBase.$, new PropertyMetadata(2, null, (a, b) => a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue)));
Type.dep(DependencyProperty, PropertyMetadata, ScatterBase, 'raisePropertyChanged', ['ErrorBarSettings:mz:n7', [ScatterErrorBarSettings.$, null], 'MarkerCollisionAvoidance:mu:n8', [CollisionAvoidanceType_$type, enumGetBox(CollisionAvoidanceType_$type, 0)], 'MaximumMarkers:nd:n9', [1, 400], 'XAxis::oh', [NumericXAxis.$, null], 'XMemberPath:nk:oi', [2, null], 'YAxis::oj', [NumericYAxis.$, null], 'YMemberPath:no:ok', [2, null], 'TrendLineType::of', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::oe', [1, 1.5], 'TrendLinePeriod::od', [1, 7], 'TrendLineBrush::oa', [Brush.$, null], 'TrendLineZIndex:ne:og', [1, 1001], 'TrendLineDashArray:om:ob', [DoubleCollection.$], 'TrendLineDashCap:on:oc', [PenLineCap_$type, enumGetBox(PenLineCap_$type, 0)]]);
/**
 * @hidden
 */
export class ScatterBaseView extends MarkerSeriesView {
    constructor(a) {
        super(a);
        this.cr = null;
        this.cp = null;
        this.cs = null;
        this.cx = null;
        this.c7 = null;
        this.c8 = null;
        this.ct = null;
        this.c6 = null;
        this.cu = null;
        this.cs = a;
        this.cu = new HashPool$2(Base.$, Marker.$);
        this.ce(this.cu);
        this.ct = new ScatterTrendLineManager();
    }
    ap() {
        super.ap();
        this.cr = this.cq();
        this.c7 = new Path();
        this.c8 = new Path();
        if (!this.n) {
            this.cs.nd = 2000;
        }
    }
    c9(a) {
        if (this.c6 == null) {
            this.c6 = new DataTemplateMeasureInfo();
            this.c6.context = this.h.g();
        }
        this.c6.width = a.width;
        this.c6.height = a.height;
        this.c6.data = a.content;
        let b = a.ah;
        if (b.measure != null) {
            b.measure(this.c6);
        }
        return new Size(1, this.c6.width, this.c6.height);
    }
    cq() {
        let a = new NumericMarkerManager(1, (b) => this.cu.item(b), (b) => this.cs.mx.c.item(b), runOn(this, this.c4), runOn(this, this.cn), runOn(this, this.cv), () => this.cs.mu);
        a.q = runOn(this, this.c9);
        return a;
    }
    c4(a) {
        this.cs.n0(a, this.cu);
    }
    cw() {
        return this.b1;
    }
    co() {
        return this.cp;
    }
    cn() {
        this.cp = this.cs.mt(this, this.cu, this.cp, this.bs, this.br);
        return this.cp;
    }
    cv() {
        this.cx = this.cs.nc(this.cu, this.cx);
        return this.cx;
    }
    cy() {
    }
    c2(a) {
    }
    cz() {
    }
    c3(a) {
    }
    c5() {
        if (this.cs.trendLineBrush != null) {
            this.cs.ol = this.cs.trendLineBrush;
        }
        else {
            this.cs.ol = this.cs.kw;
        }
    }
    cc(a) {
        this.cu.f(a);
    }
    c1() {
    }
    a2(a, b) {
        super.a2(a, b);
        if (a.d) {
            if (this.cs.trendLineType != 0 && !b) {
                let c = this.ct.g$j;
                c.ac = this.cs.trendLineThickness;
                c._stroke = this.cs.ol;
                c.ai = this.cs.om;
                c.ad = this.cs.on;
                a.u(c);
            }
        }
    }
    c0(a) {
        if (a) {
            this.c1();
            this.cu.clear();
        }
        this.ct.g$d();
        this.an();
    }
    getDefaultTooltipTemplate() {
        let a = "<div class='ui-chart-default-tooltip-content'><span";
        let b = this.e.a0.a$q(this.e);
        if (!stringIsNullOrEmpty(b)) {
            a += " style='color:" + b + "'";
        }
        a += ">" + this.cs.fs + "</span><br/><span>" + "x: </span><span class='ui-priority-primary'>${item." + this.cs.nk + "}</span><br/><span>" + "y: </span><span class='ui-priority-primary'>${item." + this.cs.no + "}</span></div>";
        return a;
    }
}
ScatterBaseView.$t = markType(ScatterBaseView, 'ScatterBaseView', MarkerSeriesView.$);
