/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import * as tslib_1 from "tslib";
import { 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
 */
var ScatterBase = /** @class */ (function (_super) {
    tslib_1.__extends(ScatterBase, _super);
    function ScatterBase() {
        var _this = _super.call(this) || this;
        _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;
        return _this;
    }
    ScatterBase.prototype.bf = function () {
        return new ScatterBaseView(this);
    };
    ScatterBase.prototype.ht = function () {
        _super.prototype.ht.call(this);
        this.xAxis = null;
        this.yAxis = null;
    };
    ScatterBase.prototype.iu = function (a) {
        _super.prototype.iu.call(this, a);
        this.m5 = a;
    };
    ScatterBase.prototype.get_c4 = function () {
        return true;
    };
    ScatterBase.prototype.ag = function () {
        return [this.xAxis, this.yAxis];
    };
    ScatterBase.prototype.fs = function (a, b) {
        var 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;
    };
    ScatterBase.prototype.ch = function (a, b, c) {
        var _this = this;
        if (!this.hasMarkers) {
            return false;
        }
        var d = this.xAxis;
        var e = new ScalerParams(1, this.bs.mq, this.ly, d.b8);
        e.c = this.getEffectiveViewport1(this.bi);
        var f = this.yAxis;
        var g = new ScalerParams(1, this.bs.mq, this.ly, f.b8);
        g.c = this.getEffectiveViewport1(this.bi);
        a.clear();
        this.l0.cc(function (h) {
            if (h._visibility == 0) {
                var i = new SeriesPointOfInterest();
                var j = h.n;
                var 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;
    };
    ScatterBase.prototype.bd = function () {
        if (this.be == 0) {
            if (this.nk <= 2000) {
                return 1;
            }
            else {
                return _super.prototype.bd.call(this);
            }
        }
        else {
            return _super.prototype.bd.call(this);
        }
    };
    ScatterBase.prototype.lw = function (a) {
        if (!this.hasMarkers || !this.l3()) {
            return Rect.empty;
        }
        var b = this.l0.bv(this.lg(a));
        if (b != null) {
            return this.l0.cm(b);
        }
        return Rect.empty;
    };
    ScatterBase.prototype.dh = function (a, b) {
        if (this.l4(a, b)) {
            return true;
        }
        return false;
    };
    Object.defineProperty(ScatterBase.prototype, "nd", {
        get: function () {
            return this.nc;
        },
        set: function (a) {
            if (this.nc != a) {
                var b = this.nd;
                this.nc = a;
                this.raisePropertyChanged("XColumn", b, this.nd);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScatterBase.prototype, "nf", {
        get: function () {
            return this.ne;
        },
        set: function (a) {
            if (this.ne != a) {
                var b = this.nf;
                this.ne = a;
                this.raisePropertyChanged("YColumn", b, this.nf);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScatterBase.prototype, "os", {
        get: function () {
            return this.c(ScatterBase.od);
        },
        set: function (a) {
            this.h(ScatterBase.od, a);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScatterBase.prototype, "GetErrorBarsXAxis", {
        get: function () {
            return this.xAxis;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScatterBase.prototype, "GetErrorBarsYAxis", {
        get: function () {
            return this.yAxis;
        },
        enumerable: true,
        configurable: true
    });
    ScatterBase.prototype.ib = function () {
        _super.prototype.ib.call(this);
        if (this.xAxis != null) {
            this.xAxis.g6(false);
        }
        if (this.yAxis != null) {
            this.yAxis.g6(false);
        }
    };
    ScatterBase.prototype.iz = function (a, b, c, d) {
        _super.prototype.iz.call(this, 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;
        }
    };
    ScatterBase.prototype.nh = function (a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterBase.prototype.ng = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterBase.prototype.oc = function () {
        this.ov = Rect.empty;
        this.ow = Rect.empty;
    };
    ScatterBase.prototype.nx = function () {
        var a = this.getViewInfo(this.ov, this.ow);
        this.ov = a.p0;
        this.ow = a.p1;
    };
    ScatterBase.prototype.ni = function (a, b) {
        if (b != 3) {
            return true;
        }
        if (a == null) {
            return true;
        }
        if (this.nr == a || this.nv == a) {
            return true;
        }
        return false;
    };
    ScatterBase.prototype.hy = function (a, b, c, d) {
        var 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);
        }
    };
    ScatterBase.prototype.n5 = function (a) {
        this.n6(a, null);
    };
    ScatterBase.prototype.n6 = function (a, b) {
        var e_1, _a, e_2, _b;
        var c = this.nd != null ? this.nd.count : 0;
        var d = this.nf != null ? this.nf.count : 0;
        var e = Math.min(c, d);
        if (e <= this.nk) {
            a.m.clear();
            var f = new List$1(OwnedPoint.$, 0);
            try {
                for (var _c = tslib_1.__values(fromEnum(a.u.values)), _d = _c.next(); !_d.done; _d = _c.next()) {
                    var g = _d.value;
                    f.add(g);
                }
            }
            catch (e_1_1) { e_1 = { error: e_1_1 }; }
            finally {
                try {
                    if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
                }
                finally { if (e_1) throw e_1.error; }
            }
            var h_1 = this.bz;
            f.aa(function (i, j) {
                var k = h_1.indexOf(i.a);
                var l = h_1.indexOf(j.a);
                if (k < l) {
                    return -1;
                }
                if (k > l) {
                    return 1;
                }
                return 0;
            });
            if (b != null) {
                b.i = a.m;
            }
            try {
                for (var _e = tslib_1.__values(fromEnum(f)), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var i = _f.value;
                    if (h_1.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 });
                        }
                    }
                }
            }
            catch (e_2_1) { e_2 = { error: e_2_1 }; }
            finally {
                try {
                    if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
                }
                finally { if (e_2) throw e_2.error; }
            }
        }
    };
    ScatterBase.prototype.an = function (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;
    };
    ScatterBase.prototype.fp = function (a) {
        return null;
    };
    ScatterBase.prototype.e8 = function (a) {
        return -1;
    };
    ScatterBase.prototype.c9 = function (a) {
        var _this = this;
        var b = this.bs != null ? this.bs.mq : Rect.empty;
        b = b.copy();
        var c = this.bs != null ? this.bs.m3 : Rect.empty;
        var d = new Rect(0, 0, 0, 1, 1);
        var e = this.ls(this.bi);
        var f = new ScalerParams(0, d, d, this.xAxis.b8, e);
        var g = ((function () {
            var $ret = new ScalerParams(0, d, d, _this.yAxis.b8, e);
            $ret.b = _this.eh();
            return $ret;
        })());
        var h = !b.isEmpty && !c.isEmpty && this.bz != null ? this.bz.indexOf(a) : -1;
        var i = this.xAxis != null && this.nd != null && h < this.nd.count ? this.xAxis.dw(this.nd.item(h), f) : NaN;
        var 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;
    };
    ScatterBase.prototype.js = function (a, b) {
        this.jd(false);
    };
    ScatterBase.prototype.jt = function (a, b) {
        this.jd(false);
    };
    ScatterBase.prototype.ny = function (a, b, c, d, e) {
        var _this = this;
        b.g = new Dictionary$2(Base.$, OwnedPoint.$, 1, c);
        var f = this.getEffectiveViewport1(a);
        var g = this.bz;
        var h;
        var i;
        var j = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.m4.d, f);
            $ret.c = _this.getEffectiveViewport1(a);
            return $ret;
        })());
        var k = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.m4.e, f);
            $ret.c = _this.getEffectiveViewport1(a);
            $ret.b = _this.eh();
            return $ret;
        })());
        var _loop_1 = function (l) {
            h = this_1.nd.item(l);
            i = this_1.nf.item(l);
            var m = { $type: Point_$type, x: this_1.m4.a.dw(h, j), y: this_1.m4.b.dw(i, k) };
            if (!isInfinity(m.x) && !isInfinity(m.y)) {
                var n_1 = g.item(l);
                if (!b.g.containsKey(n_1)) {
                    var o_1 = { $type: Point_$type, x: h, y: i };
                    var p_1 = { $type: Point_$type, x: m.x, y: m.y };
                    b.g.addItem(n_1, ((function () {
                        var $ret = new OwnedPoint();
                        $ret.a = n_1;
                        $ret.b = o_1;
                        $ret.c = p_1;
                        return $ret;
                    })()));
                }
            }
        };
        var this_1 = this;
        for (var l = 0; l < c; l++) {
            _loop_1(l);
        }
    };
    ScatterBase.prototype.n2 = function (a, b) {
        var _this = this;
        a.j.clear();
        a.n.clear();
        a.h.clear();
        a.l.clear();
        a.i.clear();
        a.k.clear();
        var c = Math.min(this.nd != null ? this.nd.count : 0, this.nf != null ? this.nf.count : 0);
        var d = b.bs;
        var e = b.br;
        var f = this.getEffectiveViewport1(b);
        var g = new ScalerParams(0, d, e, this.xAxis.b8, f);
        g.c = this.getEffectiveViewport1(b);
        var h = ((function () {
            var $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 = ((function () {
            var $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;
        })());
        var 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);
        }
        var j = ((function () {
            var $ret = new Clipper(0, e, false);
            $ret.i = a.n;
            return $ret;
        })());
        var k = this.lq(b);
        var l = this.xAxis.dz(k.left, g);
        var m = this.xAxis.dz(k.right, g);
        b.ct.p(a.n, this.trendLineType, this.nd, this.nf, this.trendLinePeriod, function (n) { return _this.xAxis.dw(n, g); }, function (n) { return _this.yAxis.dw(n, h); }, ((function () {
            var $ret = new TrendResolutionParams();
            $ret.b = _this.eu;
            $ret.f = e;
            $ret.g = d;
            return $ret;
        })()), j, l, m);
        this.n0(a, b);
    };
    ScatterBase.prototype.hv = function (a, b) {
        _super.prototype.hv.call(this, a, b);
        var c = b;
        c.c0(a);
    };
    ScatterBase.prototype.ob = function (a, b) {
        var _this = this;
        var c = b.br;
        this.m4 = ((function () {
            var $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();
        var d = ((function () {
            var $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);
    };
    ScatterBase.prototype.n0 = function (a, b) {
        var e_3, _a;
        var c = new ErrorBarsHelper(this, b);
        if (this.m6 == null) {
            return;
        }
        var d = this.m6.u;
        var e = this.m6.v;
        var f = 0;
        var g = 0;
        var h = 0;
        var i = 0;
        try {
            for (var _b = tslib_1.__values(fromEnum(a.j.keys)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var j = _c.value;
                var k = a.j.item(j);
                if (d != null) {
                    switch (d.getCalculatorType()) {
                        case 1:
                            var l = this.n3(k, c, d, h, i, true);
                            h = l.p3;
                            i = l.p4;
                            break;
                        case 0:
                            var m = this.n1(k, c, d, h, i, true);
                            h = m.p3;
                            i = m.p4;
                            break;
                        case 2:
                            var n = this.nz(k, c, d, j, h, i, true);
                            h = n.p4;
                            i = n.p5;
                            break;
                        case 3:
                            var o = this.n4(c, d, f, h, i, true);
                            f = o.p2;
                            h = o.p3;
                            i = o.p4;
                            break;
                        case 4:
                            var p = this.n1(k, c, d, h, i, true);
                            h = p.p3;
                            i = p.p4;
                            break;
                    }
                    ;
                    var 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:
                            var r = this.n3(k, c, e, h, i, false);
                            h = r.p3;
                            i = r.p4;
                            break;
                        case 0:
                            var s = this.n1(k, c, e, h, i, false);
                            h = s.p3;
                            i = s.p4;
                            break;
                        case 2:
                            var t = this.nz(k, c, e, j, h, i, false);
                            h = t.p4;
                            i = t.p5;
                            break;
                        case 3:
                            var u = this.n4(c, e, g, h, i, false);
                            g = u.p2;
                            h = u.p3;
                            i = u.p4;
                            break;
                        case 4:
                            var v = this.n1(k, c, e, h, i, false);
                            h = v.p3;
                            i = v.p4;
                            break;
                    }
                    ;
                    var 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]);
                }
            }
        }
        catch (e_3_1) { e_3 = { error: e_3_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
            }
            finally { if (e_3) throw e_3.error; }
        }
    };
    ScatterBase.prototype.n3 = function (a, b, c, d, e, f) {
        if (f) {
            var g = void 0;
            var h = void 0, i = void 0;
            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;
            }
            var j = b.f(g, c, h, i, d, e);
            d = j.p4;
            e = j.p5;
        }
        else {
            var k = void 0;
            var l = void 0, m = void 0;
            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;
            }
            var n = b.f(k, c, l, m, d, e);
            d = n.p4;
            e = n.p5;
        }
        return {
            p3: d,
            p4: e
        };
    };
    ScatterBase.prototype.n1 = function (a, b, c, d, e, f) {
        if (f) {
            var g = b.j(a.c.x, c, this.m4.a, d, e);
            d = g.p3;
            e = g.p4;
        }
        else {
            var h = b.j(a.c.y, c, this.m4.b, d, e);
            d = h.p3;
            e = h.p4;
        }
        return {
            p3: d,
            p4: e
        };
    };
    ScatterBase.prototype.nz = function (a, b, c, d, e, f, g) {
        var h = c.getItemColumn();
        var i = this.bz.indexOf(d);
        if (h != null && i < h.count) {
            var j = h.item(i);
            if (g) {
                var k = b.h(a.c.x, j, this.m4.a, e, f);
                e = k.p3;
                f = k.p4;
            }
            else {
                var 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
        };
    };
    ScatterBase.prototype.n4 = function (a, b, c, d, e, f) {
        var g = a.i(b, c);
        c = g.p1;
        if (f) {
            var h = a.k(c, b, this.m4.a, d, e);
            d = h.p3;
            e = h.p4;
        }
        else {
            var i = a.k(c, b, this.m4.b, d, e);
            d = i.p3;
            e = i.p4;
        }
        return {
            p2: c,
            p3: d,
            p4: e
        };
    };
    ScatterBase.prototype.n8 = function (a, b) {
        if (!b.l() || this.m6 == null) {
            b.c1();
            return;
        }
        this.n9(a, b);
        this.oa(a, b);
    };
    ScatterBase.prototype.n9 = function (a, b) {
        var e_4, _a;
        b.cy();
        var c = new ErrorBarsHelper(this, b);
        var d = new PathGeometry();
        var e = this.m6.u;
        try {
            for (var _b = tslib_1.__values(fromEnum(a.j.keys)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var f = _c.value;
                if (e != null && a.i.containsKey(f)) {
                    var g = a.i.item(f)[0];
                    var h = a.i.item(f)[1];
                    if (!isNaN_(g) && !isNaN_(h)) {
                        var 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);
                        }
                    }
                }
            }
        }
        catch (e_4_1) { e_4 = { error: e_4_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
            }
            finally { if (e_4) throw e_4.error; }
        }
        b.c2(d);
    };
    ScatterBase.prototype.oa = function (a, b) {
        var e_5, _a;
        b.cz();
        var c = new ErrorBarsHelper(this, b);
        var d = new PathGeometry();
        var e = this.m6.v;
        try {
            for (var _b = tslib_1.__values(fromEnum(a.j.keys)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var f = _c.value;
                if (e != null && a.k.containsKey(f)) {
                    var g = a.k.item(f)[0];
                    var h = a.k.item(f)[1];
                    if (!isNaN_(g) && !isNaN_(h)) {
                        var 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);
                        }
                    }
                }
            }
        }
        catch (e_5_1) { e_5 = { error: e_5_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
            }
            finally { if (e_5) throw e_5.error; }
        }
    };
    ScatterBase.prototype.dw = function (a, b, c) {
        var d = true;
        if (!_super.prototype.dw.call(this, 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;
    };
    ScatterBase.prototype.getViewInfo = function (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
        };
    };
    ScatterBase.prototype.je = function (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) {
                var 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();
        }
    };
    ScatterBase.prototype.jo = function () {
        _super.prototype.jo.call(this);
        if (this.fh < 0) {
            return;
        }
        this.m5.c5();
    };
    ScatterBase.prototype.jf = function (a, b) {
        _super.prototype.jf.call(this, a, b);
        if (!this.dl) {
            this.bi.az(b);
            return;
        }
        this.bi.az(b);
        if (this.cc(this.bh)) {
            return;
        }
        var 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;
    };
    ScatterBase.prototype.jc = function (a, b, c, d, e) {
        _super.prototype.jc.call(this, a, b, c, d, e);
        var f = this.a0.a$h.item(d);
        var 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);
    };
    ScatterBase.prototype.n7 = function (a, b) {
        var e_6, _a, e_7, _b;
        var c = new List$1(Base.$, 0);
        try {
            for (var _c = tslib_1.__values(fromEnum(b.c)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var d = _d.value;
                if (!a.containsKey(d)) {
                    c.add1(d);
                }
            }
        }
        catch (e_6_1) { e_6 = { error: e_6_1 }; }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
            }
            finally { if (e_6) throw e_6.error; }
        }
        try {
            for (var _e = tslib_1.__values(fromEnum(c)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var e = _f.value;
                b.g(e);
            }
        }
        catch (e_7_1) { e_7 = { error: e_7_1 }; }
        finally {
            try {
                if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
            }
            finally { if (e_7) throw e_7.error; }
        }
    };
    ScatterBase.prototype.m0 = function (a, b, c, d, e) {
        var _this = this;
        if (c == null || c.length != this.m4.c.count) {
            c = new Array(this.m4.c.count);
            for (var f = 0; f < this.m4.c.count; f++) {
                c[f] = PointUtil.create();
            }
        }
        var g = this.getEffectiveViewport1(a);
        var h = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.xAxis.b8, g);
            $ret.c = _this.getEffectiveViewport1(a);
            return $ret;
        })());
        var i = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.yAxis.b8, g);
            $ret.c = _this.getEffectiveViewport1(a);
            $ret.b = _this.eh();
            return $ret;
        })());
        var j = this.lq(a);
        var k = this.m4.a.dz(j.left, h);
        var l = this.m4.a.dz(j.right, h);
        var m = this.m4.b.dz(j.bottom, i);
        var n = this.m4.b.dz(j.top, i);
        if (this.m4.d) {
            var o = k;
            k = l;
            l = o;
        }
        if (this.m4.e) {
            var p = m;
            m = n;
            n = p;
        }
        var q = this.m4;
        var r = q.a;
        var s = q.b;
        var t;
        var u;
        var v = this.nd;
        var w = this.nf;
        for (var 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;
    };
    ScatterBase.prototype.nj = function (a, b) {
        var e_8, _a;
        if (b == null) {
            b = new List$1(Number_$type, 2, a.e);
        }
        else {
            b.clear();
        }
        var c = 0;
        var d = this.bz;
        try {
            for (var _b = tslib_1.__values(fromEnum(a.c)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var e = _c.value;
                b.add(d.indexOf(e));
            }
        }
        catch (e_8_1) { e_8 = { error: e_8_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
            }
            finally { if (e_8) throw e_8.error; }
        }
        return b;
    };
    ScatterBase.prototype.h4 = function (a) {
        _super.prototype.h4.call(this, a);
        this.a2.exportTrendlineData(this, a, this.m5.ct.g$j);
    };
    ScatterBase.prototype.eh = function () {
        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, function (a, b) { return 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)]]);
    return ScatterBase;
}(MarkerSeries));
export { ScatterBase };
/**
 * @hidden
 */
var ScatterBaseView = /** @class */ (function (_super) {
    tslib_1.__extends(ScatterBaseView, _super);
    function ScatterBaseView(a) {
        var _this = _super.call(this, a) || this;
        _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();
        return _this;
    }
    ScatterBaseView.prototype.ap = function () {
        _super.prototype.ap.call(this);
        this.cr = this.cq();
        this.c7 = new Path();
        this.c8 = new Path();
        if (!this.n) {
            this.cs.nk = 2000;
        }
    };
    ScatterBaseView.prototype.c9 = function (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;
        var b = a.ah;
        if (b.measure != null) {
            b.measure(this.c6);
        }
        return new Size(1, this.c6.width, this.c6.height);
    };
    ScatterBaseView.prototype.cq = function () {
        var _this = this;
        var a = new NumericMarkerManager(1, function (b) { return _this.cu.item(b); }, function (b) { return _this.cs.m4.c.item(b); }, runOn(this, this.c4), runOn(this, this.cn), runOn(this, this.cv), function () { return _this.cs.m1; });
        a.q = runOn(this, this.c9);
        return a;
    };
    ScatterBaseView.prototype.c4 = function (a) {
        this.cs.n7(a, this.cu);
    };
    ScatterBaseView.prototype.cw = function () {
        return this.b1;
    };
    ScatterBaseView.prototype.co = function () {
        return this.cp;
    };
    ScatterBaseView.prototype.cn = function () {
        this.cp = this.cs.m0(this, this.cu, this.cp, this.bs, this.br);
        return this.cp;
    };
    ScatterBaseView.prototype.cv = function () {
        this.cx = this.cs.nj(this.cu, this.cx);
        return this.cx;
    };
    ScatterBaseView.prototype.cy = function () {
    };
    ScatterBaseView.prototype.c2 = function (a) {
    };
    ScatterBaseView.prototype.cz = function () {
    };
    ScatterBaseView.prototype.c3 = function (a) {
    };
    ScatterBaseView.prototype.c5 = function () {
        if (this.cs.trendLineBrush != null) {
            this.cs.os = this.cs.trendLineBrush;
        }
        else {
            this.cs.os = this.cs.k3;
        }
    };
    ScatterBaseView.prototype.cc = function (a) {
        this.cu.f(a);
    };
    ScatterBaseView.prototype.c1 = function () {
    };
    ScatterBaseView.prototype.a2 = function (a, b) {
        _super.prototype.a2.call(this, a, b);
        if (a.d) {
            if (this.cs.trendLineType != 0 && !b) {
                var 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);
            }
        }
    };
    ScatterBaseView.prototype.c0 = function (a) {
        if (a) {
            this.c1();
            this.cu.clear();
        }
        this.ct.g$d();
        this.an();
    };
    ScatterBaseView.prototype.getDefaultTooltipTemplate = function () {
        var a = "<div class='ui-chart-default-tooltip-content'><span";
        var 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.$);
    return ScatterBaseView;
}(MarkerSeriesView));
export { ScatterBaseView };
//# sourceMappingURL=ScatterBase_combined.js.map