/*
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-angular-core";
import { NumericYAxis } from "./NumericYAxis";
import { Series } from "./Series";
import { TrendLineType_$type } from "igniteui-angular-core";
import { Brush } from "igniteui-angular-core";
import { PenLineCap_$type } from "igniteui-angular-core";
import { DoubleCollection } from "igniteui-angular-core";
import { CollisionAvoidanceType_$type } from "./CollisionAvoidanceType";
import { ScatterErrorBarSettings } from "./ScatterErrorBarSettings";
import { ScatterFrame } from "./ScatterFrame";
import { Base, enumGetBox, Number_$type, typeCast, fromEnum, Point_$type, markType, markDep, PointUtil, runOn } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { ScalerParams } from "./ScalerParams";
import { Rect } from "igniteui-angular-core";
import { Marker } from "./Marker";
import { MarkerSeriesView } from "./MarkerSeriesView";
import { IFastItemsSource_$type } from "igniteui-angular-core";
import { Clipper } from "igniteui-angular-core";
import { OwnedPoint } from "./OwnedPoint";
import { Dictionary$2 } from "igniteui-angular-core";
import { AxisRange } from "./AxisRange";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { ScatterTrendLineManager } from "./ScatterTrendLineManager";
import { ErrorBarsHelper } from "./ErrorBarsHelper";
import { PathGeometry } from "igniteui-angular-core";
import { HashPool$2 } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_, isInfinity } from "igniteui-angular-core";
import { Path } from "igniteui-angular-core";
import { DataTemplateMeasureInfo } from "igniteui-angular-core";
import { Size } from "igniteui-angular-core";
import { NumericMarkerManager } from "./NumericMarkerManager";
import { stringIsNullOrEmpty } from "igniteui-angular-core";
/**
 * @hidden
 */
export class ScatterBase extends MarkerSeries {
    constructor() {
        super();
        this.m4 = null;
        this.nc = null;
        this.ne = null;
        this.ov = null;
        this.ow = null;
        this.m9 = null;
        this.nb = null;
        this.m8 = null;
        this.na = null;
        this.m7 = null;
        this.na = new ScatterFrame();
        this.ow = Rect.empty;
        this.ov = Rect.empty;
    }
    bf() {
        return new ScatterBaseView(this);
    }
    ht() {
        super.ht();
        this.xAxis = null;
        this.yAxis = null;
    }
    iu(a) {
        super.iu(a);
        this.m5 = a;
    }
    get_c4() {
        return true;
    }
    ag() {
        return [this.xAxis, this.yAxis];
    }
    fs(a, b) {
        let c = this.gu(b);
        if (c == ScatterBase.$$p[4]) {
            return this.ft(a, b, this.nr);
        }
        if (c == ScatterBase.$$p[6]) {
            return this.ft(a, b, this.nv);
        }
        return null;
    }
    ch(a, b, c) {
        if (!this.hasMarkers) {
            return false;
        }
        let d = this.xAxis;
        let e = new ScalerParams(1, this.bs.mq, this.ly, d.b8);
        e.c = this.getEffectiveViewport1(this.bi);
        let f = this.yAxis;
        let g = new ScalerParams(1, this.bs.mq, this.ly, f.b8);
        g.c = this.getEffectiveViewport1(this.bi);
        a.clear();
        this.l0.cc((h) => {
            if (h._visibility == 0) {
                let i = new SeriesPointOfInterest();
                let j = h.n;
                let k = h.o;
                if (j < this.ly.left || j > this.ly.right || k < this.ly.top || k > this.ly.bottom) {
                    return;
                }
                i.b = d.dz(j, e);
                i.c = f.dz(k, g);
                i.a = h.content;
                a.add(i);
            }
        });
        return true;
    }
    bd() {
        if (this.be == 0) {
            if (this.nk <= 2000) {
                return 1;
            }
            else {
                return super.bd();
            }
        }
        else {
            return super.bd();
        }
    }
    lw(a) {
        if (!this.hasMarkers || !this.l3()) {
            return Rect.empty;
        }
        let b = this.l0.bv(this.lg(a));
        if (b != null) {
            return this.l0.cm(b);
        }
        return Rect.empty;
    }
    dh(a, b) {
        if (this.l4(a, b)) {
            return true;
        }
        return false;
    }
    get nd() {
        return this.nc;
    }
    set nd(a) {
        if (this.nc != a) {
            let b = this.nd;
            this.nc = a;
            this.raisePropertyChanged("XColumn", b, this.nd);
        }
    }
    get nf() {
        return this.ne;
    }
    set nf(a) {
        if (this.ne != a) {
            let b = this.nf;
            this.ne = a;
            this.raisePropertyChanged("YColumn", b, this.nf);
        }
    }
    get os() {
        return this.c(ScatterBase.od);
    }
    set os(a) {
        this.h(ScatterBase.od, a);
    }
    get GetErrorBarsXAxis() {
        return this.xAxis;
    }
    get GetErrorBarsYAxis() {
        return this.yAxis;
    }
    ib() {
        super.ib();
        if (this.xAxis != null) {
            this.xAxis.g6(false);
        }
        if (this.yAxis != null) {
            this.yAxis.g6(false);
        }
    }
    iz(a, b, c, d) {
        super.iz(a, b, c, d);
        if (this.m5.ct.g$b(a, b, c, d)) {
            this.jd(false);
            this.ik();
        }
        switch (b) {
            case "FastItemsSource":
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.nd);
                    c.deregisterColumn(this.nf);
                    this.nd = null;
                    this.nf = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.nd = this.bw(this.nr);
                    this.nf = this.bw(this.nv);
                }
                if ((this.yAxis != null && !this.yAxis.cl()) || (this.xAxis != null && !this.xAxis.cl())) {
                    this.jd(false);
                }
                break;
            case ScatterBase.$$p[3]:
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ci(this);
                }
                if ((this.xAxis != null && !this.xAxis.cl()) || (d == null && c != null)) {
                    this.jd(false);
                }
                this.ik();
                break;
            case ScatterBase.$$p[5]:
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ci(this);
                }
                if ((this.yAxis != null && !this.yAxis.cl()) || (d == null && c != null)) {
                    this.jd(false);
                }
                this.ik();
                break;
            case ScatterBase.$$p[4]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.nd);
                    this.nd = this.bw(this.nr);
                }
                break;
            case "XColumn":
                this.m5.ct.g$i();
                if (this.xAxis != null && !this.xAxis.cl()) {
                    this.jd(false);
                }
                break;
            case ScatterBase.$$p[6]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.nf);
                    this.nf = this.bw(this.nv);
                }
                break;
            case "YColumn":
                this.m5.ct.g$i();
                if (this.yAxis != null && !this.yAxis.cl()) {
                    this.jd(false);
                }
                break;
            case ScatterBase.$$p[1]:
                this.jd(false);
                this.ik();
                break;
            case ScatterBase.$$p[2]:
                this.jd(false);
                this.ik();
                break;
            case "TransitionProgress":
                this.nb.c(this.ez, this.m9, this.m8);
                this.nx();
                try {
                    if (this.cc(this.bi)) {
                        return;
                    }
                    if ((Math.round(this.ez * 100000) / 100000) == 1) {
                        this.ob(this.m8, this.m5);
                    }
                    else {
                        this.ob(this.nb, this.m5);
                    }
                    if (this.bs != null) {
                        this.bs.jj(this);
                    }
                }
                finally {
                    this.oc();
                }
                break;
            case "TrendLineBrush":
                this.jo();
                break;
            case ScatterBase.$$p[0]:
                if (this.m6 != null) {
                    this.m6.r = this;
                }
                this.jd(false);
                this.ik();
                break;
            case "TrendLineType":
                this.ik();
                break;
        }
    }
    nh(a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    }
    ng(a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    }
    oc() {
        this.ov = Rect.empty;
        this.ow = Rect.empty;
    }
    nx() {
        let a = this.getViewInfo(this.ov, this.ow);
        this.ov = a.p0;
        this.ow = a.p1;
    }
    ni(a, b) {
        if (b != 3) {
            return true;
        }
        if (a == null) {
            return true;
        }
        if (this.nr == a || this.nv == a) {
            return true;
        }
        return false;
    }
    hy(a, b, c, d) {
        let e = false;
        if (!this.ni(d, a)) {
            return;
        }
        this.m5.ct.g$e(a, b, c, d);
        if (this.xAxis != null && !this.xAxis.cl()) {
            e = true;
        }
        if (this.yAxis != null && !this.yAxis.cl()) {
            e = true;
        }
        if (e) {
            this.jd(true);
        }
    }
    n5(a) {
        this.n6(a, null);
    }
    n6(a, b) {
        let c = this.nd != null ? this.nd.count : 0;
        let d = this.nf != null ? this.nf.count : 0;
        let e = Math.min(c, d);
        if (e <= this.nk) {
            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.nd != null) {
            return new AxisRange(this.nd.minimum, this.nd.maximum);
        }
        if (a != null && a == this.yAxis && this.nf != null) {
            return new AxisRange(this.nf.minimum, this.nf.maximum);
        }
        return null;
    }
    fp(a) {
        return null;
    }
    e8(a) {
        return -1;
    }
    c9(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.ls(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.eh();
            return $ret;
        })());
        let h = !b.isEmpty && !c.isEmpty && this.bz != null ? this.bz.indexOf(a) : -1;
        let i = this.xAxis != null && this.nd != null && h < this.nd.count ? this.xAxis.dw(this.nd.item(h), f) : NaN;
        let j = this.yAxis != null && this.nf != null && h < this.nf.count ? this.yAxis.dw(this.nf.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;
    }
    js(a, b) {
        this.jd(false);
    }
    jt(a, b) {
        this.jd(false);
    }
    ny(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.m4.d, f);
            $ret.c = this.getEffectiveViewport1(a);
            return $ret;
        })());
        let k = ((() => {
            let $ret = new ScalerParams(0, d, e, this.m4.e, f);
            $ret.c = this.getEffectiveViewport1(a);
            $ret.b = this.eh();
            return $ret;
        })());
        for (let l = 0; l < c; l++) {
            h = this.nd.item(l);
            i = this.nf.item(l);
            let m = { $type: Point_$type, x: this.m4.a.dw(h, j), y: this.m4.b.dw(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;
                    })()));
                }
            }
        }
    }
    n2(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.nd != null ? this.nd.count : 0, this.nf != null ? this.nf.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.eh();
            return $ret;
        })());
        ;
        h.c = this.getEffectiveViewport1(b);
        if (c < 1) {
            return;
        }
        this.m4 = ((() => {
            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.nk) {
            this.ny(i, a, c, d, e);
        }
        if (this.l3()) {
            b.cr.l(a.j, this.nk, d, e, this.eu);
        }
        let j = ((() => {
            let $ret = new Clipper(0, e, false);
            $ret.i = a.n;
            return $ret;
        })());
        let k = this.lq(b);
        let l = this.xAxis.dz(k.left, g);
        let m = this.xAxis.dz(k.right, g);
        b.ct.p(a.n, this.trendLineType, this.nd, this.nf, this.trendLinePeriod, (n) => this.xAxis.dw(n, g), (n) => this.yAxis.dw(n, h), ((() => {
            let $ret = new TrendResolutionParams();
            $ret.b = this.eu;
            $ret.f = e;
            $ret.g = d;
            return $ret;
        })()), j, l, m);
        this.n0(a, b);
    }
    hv(a, b) {
        super.hv(a, b);
        let c = b;
        c.c0(a);
    }
    ob(a, b) {
        let c = b.br;
        this.m4 = ((() => {
            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.l3()) {
            b.cr.j(a.j, this.l5);
        }
        b.cj();
        let d = ((() => {
            let $ret = new Clipper(1, NaN, c.bottom, NaN, c.top, false);
            $ret.i = b.ct.g$j.ak;
            return $ret;
        })());
        b.ct.g$h(a.n, d);
        this.n8(a, b);
    }
    n0(a, b) {
        let c = new ErrorBarsHelper(this, b);
        if (this.m6 == null) {
            return;
        }
        let d = this.m6.u;
        let e = this.m6.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.n3(k, c, d, h, i, true);
                        h = l.p3;
                        i = l.p4;
                        break;
                    case 0:
                        let m = this.n1(k, c, d, h, i, true);
                        h = m.p3;
                        i = m.p4;
                        break;
                    case 2:
                        let n = this.nz(k, c, d, j, h, i, true);
                        h = n.p4;
                        i = n.p5;
                        break;
                    case 3:
                        let o = this.n4(c, d, f, h, i, true);
                        f = o.p2;
                        h = o.p3;
                        i = o.p4;
                        break;
                    case 4:
                        let p = this.n1(k, c, d, h, i, true);
                        h = p.p3;
                        i = p.p4;
                        break;
                }
                ;
                let q = new OwnedPoint();
                q.c = c.l(d, this.m4.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.n3(k, c, e, h, i, false);
                        h = r.p3;
                        i = r.p4;
                        break;
                    case 0:
                        let s = this.n1(k, c, e, h, i, false);
                        h = s.p3;
                        i = s.p4;
                        break;
                    case 2:
                        let t = this.nz(k, c, e, j, h, i, false);
                        h = t.p4;
                        i = t.p5;
                        break;
                    case 3:
                        let u = this.n4(c, e, g, h, i, false);
                        g = u.p2;
                        h = u.p3;
                        i = u.p4;
                        break;
                    case 4:
                        let v = this.n1(k, c, e, h, i, false);
                        h = v.p3;
                        i = v.p4;
                        break;
                }
                ;
                let w = new OwnedPoint();
                w.c = c.m(e, this.m4.b, k.c, g);
                ;
                w.a = k.a;
                a.l.addItem(j, w);
                a.k.addItem(j, [h, i]);
            }
        }
    }
    n3(a, b, c, d, e, f) {
        if (f) {
            let g;
            let h, i;
            i = this.m4.a;
            if (this.m6.s == 0) {
                g = a.c.x;
                h = this.m4.a;
            }
            else {
                g = a.c.y;
                h = this.m4.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.m4.b;
            if (this.m6.t == 0) {
                k = a.c.x;
                l = this.m4.a;
            }
            else {
                k = a.c.y;
                l = this.m4.b;
            }
            let n = b.f(k, c, l, m, d, e);
            d = n.p4;
            e = n.p5;
        }
        return {
            p3: d,
            p4: e
        };
    }
    n1(a, b, c, d, e, f) {
        if (f) {
            let g = b.j(a.c.x, c, this.m4.a, d, e);
            d = g.p3;
            e = g.p4;
        }
        else {
            let h = b.j(a.c.y, c, this.m4.b, d, e);
            d = h.p3;
            e = h.p4;
        }
        return {
            p3: d,
            p4: e
        };
    }
    nz(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.m4.a, e, f);
                e = k.p3;
                f = k.p4;
            }
            else {
                let l = b.h(a.c.y, j, this.m4.b, e, f);
                e = l.p3;
                f = l.p4;
            }
        }
        else {
            e = f = NaN;
        }
        return {
            p4: e,
            p5: f
        };
    }
    n4(a, b, c, d, e, f) {
        let g = a.i(b, c);
        c = g.p1;
        if (f) {
            let h = a.k(c, b, this.m4.a, d, e);
            d = h.p3;
            e = h.p4;
        }
        else {
            let i = a.k(c, b, this.m4.b, d, e);
            d = i.p3;
            e = i.p4;
        }
        return {
            p2: c,
            p3: d,
            p4: e
        };
    }
    n8(a, b) {
        if (!b.l() || this.m6 == null) {
            b.c1();
            return;
        }
        this.n9(a, b);
        this.oa(a, b);
    }
    n9(a, b) {
        b.cy();
        let c = new ErrorBarsHelper(this, b);
        let d = new PathGeometry();
        let e = this.m6.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.m6.o == 1 || this.m6.o == 2) {
                        c.d(d, i, g, true);
                    }
                    if (this.m6.o == 1 || this.m6.o == 3) {
                        c.d(d, i, h, false);
                    }
                }
            }
        }
        b.c2(d);
    }
    oa(a, b) {
        b.cz();
        let c = new ErrorBarsHelper(this, b);
        let d = new PathGeometry();
        let e = this.m6.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.m6.p == 1 || this.m6.p == 2) {
                        c.e(d, i, g, true);
                    }
                    if (this.m6.p == 1 || this.m6.p == 3) {
                        c.e(d, i, h, false);
                    }
                }
            }
        }
    }
    dw(a, b, c) {
        let d = true;
        if (!super.dw(a, b, c) || b.isEmpty || a.isEmpty || this.xAxis == null || this.yAxis == null || this.xAxis.bf == null || this.yAxis.bf == null || this.nd == null || this.nf == null || this.nd.count == 0 || this.nf.count == 0 || this.bz == null || this.bz.count != this.nd.count || this.bz.count != this.nf.count || this.xAxis.bf == null || this.yAxis.bf == null || this.xAxis.j4 == this.xAxis.j3 || this.yAxis.j4 == this.yAxis.j3) {
            d = false;
        }
        return d;
    }
    getViewInfo(a, b) {
        if (!this.ov.isEmpty && !this.ow.isEmpty) {
            a = this.ov;
            b = this.ow;
            return {
                p0: a,
                p1: b
            };
        }
        a = this.bi.br;
        b = this.bi.bs;
        return {
            p0: a,
            p1: b
        };
    }
    je(a) {
        this.nx();
        try {
            if (this.cc(this.bi)) {
                return;
            }
            if (this.bz != null && this.bz.count > this.nk) {
                a = false;
            }
            if (this.da(a) && !this.de) {
                let b = this.m9;
                if (this.ca()) {
                    if (this.bt.g) {
                        this.bt.t();
                    }
                    this.m9 = this.nb;
                    this.nb = b;
                }
                else {
                    this.m9 = this.m8;
                    this.m8 = b;
                }
                this.n2(this.m8, this.m5);
                this.jl();
            }
            else {
                if (!this.de) {
                    this.n2(this.m8, this.m5);
                }
                this.ob(this.m8, this.m5);
            }
        }
        finally {
            this.oc();
        }
    }
    jo() {
        super.jo();
        if (this.fh < 0) {
            return;
        }
        this.m5.c5();
    }
    jf(a, b) {
        super.jf(a, b);
        if (!this.dl) {
            this.bi.az(b);
            return;
        }
        this.bi.az(b);
        if (this.cc(this.bh)) {
            return;
        }
        let c = typeCast(ScatterBaseView.$, this.bh);
        if (!this.df) {
            this.na = new ScatterFrame();
            this.n2(this.na, c);
        }
        this.df = false;
        this.ob(this.na, c);
        this.dl = false;
    }
    jc(a, b, c, d, e) {
        super.jc(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.m7 == null) {
            this.m7 = new ScatterFrame();
        }
        this.n2(this.m7, g);
        this.ob(this.m7, g);
    }
    n7(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);
        }
    }
    m0(a, b, c, d, e) {
        if (c == null || c.length != this.m4.c.count) {
            c = new Array(this.m4.c.count);
            for (let f = 0; f < this.m4.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.eh();
            return $ret;
        })());
        let j = this.lq(a);
        let k = this.m4.a.dz(j.left, h);
        let l = this.m4.a.dz(j.right, h);
        let m = this.m4.b.dz(j.bottom, i);
        let n = this.m4.b.dz(j.top, i);
        if (this.m4.d) {
            let o = k;
            k = l;
            l = o;
        }
        if (this.m4.e) {
            let p = m;
            m = n;
            n = p;
        }
        let q = this.m4;
        let r = q.a;
        let s = q.b;
        let t;
        let u;
        let v = this.nd;
        let w = this.nf;
        for (let x = 0; x < this.m4.c.count; x++) {
            t = v.item(x);
            u = w.item(x);
            if (t >= k && t <= l && u >= m && u <= n) {
                c[x].x = r.dw(t, h);
                c[x].y = s.dw(u, i);
            }
            else {
                c[x].x = NaN;
                c[x].y = NaN;
            }
        }
        return c;
    }
    nj(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;
    }
    h4(a) {
        super.h4(a);
        this.a2.exportTrendlineData(this, a, this.m5.ct.g$j);
    }
    eh() {
        return Series.ei(this.nf, null);
    }
}
ScatterBase.$t = markType(ScatterBase, 'ScatterBase', MarkerSeries.$, [ISupportsErrorBars_$type, ITrendLineSeries_$type]);
ScatterBase.od = DependencyProperty.i("ActualTrendLineBrush", Brush.$, ScatterBase.$, new PropertyMetadata(2, null, (a, b) => a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue)));
ScatterBase.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterBase, 'raisePropertyChanged', ['ErrorBarSettings:m6:oe', [ScatterErrorBarSettings.$, null], 'MarkerCollisionAvoidance:m1:of', [CollisionAvoidanceType_$type, enumGetBox(CollisionAvoidanceType_$type, 0)], 'MaximumMarkers:nk:og', [1, 400], 'XAxis::oo', [NumericXAxis.$, null], 'XMemberPath:nr:op', [2, null], 'YAxis::oq', [NumericYAxis.$, null], 'YMemberPath:nv:or', [2, null], 'TrendLineType::om', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::ol', [1, 1.5], 'TrendLinePeriod::ok', [1, 7], 'TrendLineBrush::oh', [Brush.$, null], 'TrendLineZIndex:nl:on', [1, 1001], 'TrendLineDashArray:ot:oi', [DoubleCollection.$], 'TrendLineDashCap:ou:oj', [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.nk = 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.m4.c.item(b), runOn(this, this.c4), runOn(this, this.cn), runOn(this, this.cv), () => this.cs.m1);
        a.q = runOn(this, this.c9);
        return a;
    }
    c4(a) {
        this.cs.n7(a, this.cu);
    }
    cw() {
        return this.b1;
    }
    co() {
        return this.cp;
    }
    cn() {
        this.cp = this.cs.m0(this, this.cu, this.cp, this.bs, this.br);
        return this.cp;
    }
    cv() {
        this.cx = this.cs.nj(this.cu, this.cx);
        return this.cx;
    }
    cy() {
    }
    c2(a) {
    }
    cz() {
    }
    c3(a) {
    }
    c5() {
        if (this.cs.trendLineBrush != null) {
            this.cs.os = this.cs.trendLineBrush;
        }
        else {
            this.cs.os = this.cs.k3;
        }
    }
    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.os;
                c.ai = this.cs.ot;
                c.ad = this.cs.ou;
                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.fx + "</span><br/><span>" + "x: </span><span class='ui-priority-primary'>${item." + this.cs.nr + "}</span><br/><span>" + "y: </span><span class='ui-priority-primary'>${item." + this.cs.nv + "}</span></div>";
        return a;
    }
}
ScatterBaseView.$t = markType(ScatterBaseView, 'ScatterBaseView', MarkerSeriesView.$);
//# sourceMappingURL=ScatterBase_combined.js.map