/*
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 { __extends, __values } 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-react-core";
import { NumericYAxis } from "./NumericYAxis";
import { Series } from "./Series";
import { TrendLineType_$type } from "igniteui-react-core";
import { Brush } from "igniteui-react-core";
import { PenLineCap_$type } from "igniteui-react-core";
import { DoubleCollection } from "igniteui-react-core";
import { CollisionAvoidanceType_$type } from "./CollisionAvoidanceType";
import { ScatterItemSearchMode_$type } from "./ScatterItemSearchMode";
import { ScatterErrorBarSettings } from "./ScatterErrorBarSettings";
import { HighlightingInfo } from "igniteui-react-core";
import { ScatterFrame } from "./ScatterFrame";
import { Base, runOn, delegateCombine, enumGetBox, Number_$type, typeCast, fromEnum, Point_$type, markType, markDep, PointUtil } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { ScalerParams } from "./ScalerParams";
import { Rect } from "igniteui-react-core";
import { Marker } from "./Marker";
import { MarkerSeriesView } from "./MarkerSeriesView";
import { SeriesLayerPropertyOverlay } from "./SeriesLayerPropertyOverlay";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { Clipper } from "igniteui-react-core";
import { OwnedPoint } from "./OwnedPoint";
import { Dictionary$2 } from "igniteui-react-core";
import { AxisRange } from "./AxisRange";
import { GeometryUtil } from "igniteui-react-core";
import { HashPool$2 } from "igniteui-react-core";
import { DataContext } from "igniteui-react-core";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { ScatterTrendLineManager } from "./ScatterTrendLineManager";
import { Thickness } from "igniteui-react-core";
import { Size } from "igniteui-react-core";
import { AssigningScatterStyleEventArgs } from "./AssigningScatterStyleEventArgs";
import { AssigningScatterMarkerStyleEventArgs } from "./AssigningScatterMarkerStyleEventArgs";
import { SeriesRenderManager } from "./SeriesRenderManager";
import { ErrorBarsHelper } from "./ErrorBarsHelper";
import { PathGeometry } from "igniteui-react-core";
import { DataLegendSeriesValueInfo } from "igniteui-react-core";
import { DataLegendSeriesContext } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { truncate, isNaN_, isInfinity } from "igniteui-react-core";
import { boxArray$1, arrayShallowClone } from "igniteui-react-core";
import { Path } from "igniteui-react-core";
import { DataTemplateMeasureInfo } from "igniteui-react-core";
import { NumericMarkerManager } from "./NumericMarkerManager";
import { stringIsNullOrEmpty } from "igniteui-react-core";
/**
 * @hidden
 */
var ScatterBase = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(ScatterBase, _super);
    function ScatterBase() {
        var _this = _super.call(this) || this;
        _this.vr = null;
        _this.wa = null;
        _this.wb = null;
        _this.ze = null;
        _this.zf = null;
        _this.v0 = 1;
        _this.vh = null;
        _this.vi = null;
        _this.vx = null;
        _this.vz = null;
        _this.vv = null;
        _this.wg = false;
        _this.wf = false;
        _this.v8 = null;
        _this.v9 = null;
        _this.assigningScatterStyle = null;
        _this.assigningScatterMarkerStyle = null;
        _this.v4 = null;
        _this.vy = null;
        _this.vu = null;
        _this.we = true;
        _this.wt = 0;
        _this.wu = 0;
        _this.wv = 0;
        _this.ww = 0;
        _this.v1 = _this.v2();
        _this.v4 = new ScatterSeriesRenderManager();
        _this.vy = new ScatterFrame();
        _this.zf = Rect.empty;
        _this.ze = Rect.empty;
        return _this;
    }
    ScatterBase.prototype.cd = function () {
        return new ScatterBaseView(this);
    };
    ScatterBase.prototype.nh = function () {
        _super.prototype.nh.call(this);
        this.xAxis = null;
        this.yAxis = null;
    };
    ScatterBase.prototype.o2 = function (a) {
        _super.prototype.o2.call(this, a);
        this.vs = a;
    };
    ScatterBase.prototype.get_fa = function () {
        return true;
    };
    ScatterBase.prototype.ag = function () {
        return [this.xAxis, this.yAxis];
    };
    ScatterBase.prototype.jv = function (a, b) {
        var c = this.lw(b);
        if (c == ScatterBase.$$p[12]) {
            return this.jw(a, b, this.xn);
        }
        if (c == ScatterBase.$$p[16]) {
            return this.jw(a, b, this.xv);
        }
        return null;
    };
    ScatterBase.prototype.dt = function (a, b, c, d) {
        var _this = this;
        if (!this.hasMarkers) {
            return false;
        }
        var e = this.xAxis;
        var f = new ScalerParams(1, this.cv.tr, this.ty, e.ch);
        f.c = this.getEffectiveViewport1(this.cg);
        var g = this.yAxis;
        var h = new ScalerParams(1, this.cv.tr, this.ty, g.ch);
        h.c = this.getEffectiveViewport1(this.cg);
        a.clear();
        this.ub.ci(function (i) {
            if (i._visibility == 0) {
                var j = new SeriesPointOfInterest();
                var k = i.n;
                var l = i.o;
                if (k < _this.ty.left || k > _this.ty.right || l < _this.ty.top || l > _this.ty.bottom) {
                    return;
                }
                j.b = e.em(k, f);
                j.c = g.em(l, h);
                j.a = i.content;
                a.add(j);
            }
        });
        return true;
    };
    ScatterBase.prototype.bu = function () {
        if (this.bv == 0) {
            if (this.w3 <= 2000) {
                return 1;
            }
            else {
                return _super.prototype.bu.call(this);
            }
        }
        else {
            return _super.prototype.bu.call(this);
        }
    };
    ScatterBase.prototype.tw = function (a) {
        if (!this.hasMarkers || !this.ue()) {
            return Rect.empty;
        }
        var b = this.ub.b1(this.te(a));
        if (b != null) {
            return this.ub.cs(b);
        }
        return Rect.empty;
    };
    ScatterBase.prototype.f5 = function (a, b) {
        if (this.uf(a, b)) {
            return true;
        }
        return false;
    };
    Object.defineProperty(ScatterBase.prototype, "wc", {
        get: function () {
            return this.wa;
        },
        set: function (a) {
            if (this.wa != a) {
                var b = this.wc;
                this.wa = a;
                this.raisePropertyChanged("XColumn", b, this.wc);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ScatterBase.prototype, "wd", {
        get: function () {
            return this.wb;
        },
        set: function (a) {
            if (this.wb != a) {
                var b = this.wd;
                this.wb = a;
                this.raisePropertyChanged("YColumn", b, this.wd);
            }
        },
        enumerable: false,
        configurable: true
    });
    ScatterBase.prototype.fo = function () {
        return this.highlightedItemsSource != null || (this.w7 != null && this.w9 != null);
    };
    ScatterBase.prototype.wr = function () {
        return false;
    };
    ScatterBase.prototype.g1 = function () {
        var a = _super.prototype.g1.call(this);
        {
            var b = ((function () {
                var $ret = new SeriesLayerPropertyOverlay();
                $ret.ad = "YMemberPath";
                $ret.p = true;
                $ret.y = "HighlightedYMemberPath";
                $ret.q = true;
                return $ret;
            })());
            b.valueResolving = delegateCombine(b.valueResolving, runOn(this, this.x2));
            a.add(b);
        }
        {
            var c = ((function () {
                var $ret = new SeriesLayerPropertyOverlay();
                $ret.ad = "XMemberPath";
                $ret.p = true;
                $ret.y = "HighlightedXMemberPath";
                $ret.q = true;
                return $ret;
            })());
            c.valueResolving = delegateCombine(c.valueResolving, runOn(this, this.x1));
            a.add(c);
        }
        if (this.wr()) {
            var d = ((function () {
                var $ret = new SeriesLayerPropertyOverlay();
                $ret.r = true;
                $ret.ad = "DashArray";
                $ret.p = true;
                $ret.x = ((function () {
                    var $ret = new DoubleCollection();
                    $ret.add(5);
                    $ret.add(5);
                    return $ret;
                })());
                $ret.q = true;
                return $ret;
            })());
            a.add(d);
        }
        if (!this.wr()) {
            var e = ((function () {
                var $ret = new SeriesLayerPropertyOverlay();
                $ret.r = true;
                $ret.ad = "Brush";
                $ret.p = true;
                $ret.y = "ActualBrush";
                $ret.q = true;
                return $ret;
            })());
            e.valueResolving = delegateCombine(e.valueResolving, runOn(this, this.pz));
            a.add(e);
        }
        if (!this.wr()) {
            var f = ((function () {
                var $ret = new SeriesLayerPropertyOverlay();
                $ret.r = true;
                $ret.ad = "Outline";
                $ret.p = true;
                $ret.y = "ActualOutline";
                $ret.q = true;
                return $ret;
            })());
            f.valueResolving = delegateCombine(f.valueResolving, runOn(this, this.pz));
            a.add(f);
        }
        return a;
    };
    ScatterBase.prototype.x1 = function (a, b) {
        if (this.w7 != null) {
            b.value = this.w7;
            return;
        }
        b.value = this.xn;
    };
    ScatterBase.prototype.x2 = function (a, b) {
        if (this.w9 != null) {
            b.value = this.w9;
            return;
        }
        b.value = this.xv;
    };
    Object.defineProperty(ScatterBase.prototype, "zb", {
        get: function () {
            return this.c(ScatterBase.ym);
        },
        set: function (a) {
            this.h(ScatterBase.ym, a);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ScatterBase.prototype, "GetErrorBarsXAxis", {
        get: function () {
            return this.xAxis;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ScatterBase.prototype, "GetErrorBarsYAxis", {
        get: function () {
            return this.yAxis;
        },
        enumerable: false,
        configurable: true
    });
    ScatterBase.prototype.oc = function () {
        _super.prototype.oc.call(this);
        if (this.xAxis != null) {
            this.xAxis.h8(false);
        }
        if (this.yAxis != null) {
            this.yAxis.h8(false);
        }
    };
    ScatterBase.prototype.pa = function (a, b, c, d) {
        _super.prototype.pa.call(this, a, b, c, d);
        if (this.vs.c0.g$b(a, b, c, d)) {
            this.pr(false);
            this.om();
        }
        switch (b) {
            case "FastItemsSource":
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.wc);
                    c.deregisterColumn(this.wd);
                    this.wc = null;
                    this.wd = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.wc = this.c4(this.xn);
                    this.wd = this.c4(this.xv);
                }
                if ((this.yAxis != null && !this.yAxis.c1()) || (this.xAxis != null && !this.xAxis.c1())) {
                    this.pr(this.fr && c != null);
                }
                break;
            case ScatterBase.$$p[9]:
                if (c != null) {
                    c.b0(this);
                }
                if (d != null) {
                    d.ct(this);
                }
                if ((this.xAxis != null && !this.xAxis.c1()) || (d == null && c != null)) {
                    this.pr(false);
                }
                this.om();
                break;
            case ScatterBase.$$p[13]:
                if (c != null) {
                    c.b0(this);
                }
                if (d != null) {
                    d.ct(this);
                }
                if ((this.yAxis != null && !this.yAxis.c1()) || (d == null && c != null)) {
                    this.pr(false);
                }
                this.om();
                break;
            case ScatterBase.$$p[12]:
                if (this.c7 != null) {
                    this.c7.deregisterColumn(this.wc);
                    this.wc = this.c4(this.xn);
                }
                break;
            case "XColumn":
                this.vs.c0.g$i();
                if (this.xAxis != null && !this.xAxis.c1()) {
                    this.pr(this.fr && this.dp);
                }
                break;
            case ScatterBase.$$p[16]:
                if (this.c7 != null) {
                    this.c7.deregisterColumn(this.wd);
                    this.wd = this.c4(this.xv);
                }
                break;
            case "YColumn":
                this.vs.c0.g$i();
                if (this.yAxis != null && !this.yAxis.c1()) {
                    this.pr(this.fr && this.dp);
                }
                break;
            case ScatterBase.$$p[7]:
                this.pr(false);
                this.om();
                break;
            case ScatterBase.$$p[8]:
                this.pr(false);
                this.om();
                break;
            case "TransitionProgress":
                this.vz.c(this.iw, this.vx, this.vv);
                this.xx();
                try {
                    if (this.dm(this.cg)) {
                        return;
                    }
                    if ((Math.round(this.iw * 100000) / 100000) == 1) {
                        this.yj(this.vv, this.vs);
                    }
                    else {
                        this.yj(this.vz, this.vs);
                    }
                    if (this.cv != null) {
                        this.cv.or(this);
                    }
                }
                finally {
                    this.yk();
                }
                break;
            case "TrendLineBrush":
                this.pg(b);
                break;
            case ScatterBase.$$p[0]:
                if (this.vt != null) {
                    this.vt.r = this;
                }
                this.pr(false);
                this.om();
                break;
            case "TrendLineType":
                this.om();
                break;
            case ScatterBase.$$p[4]:
                this.wg = this.wo();
                this.pr(false);
                break;
            case ScatterBase.$$p[3]:
                this.wf = this.wn();
                this.pr(false);
                break;
            case ScatterBase.$$p[5]:
                this.v1 = this.v2();
                break;
        }
    };
    ScatterBase.prototype.wo = function () {
        return this.wk;
    };
    ScatterBase.prototype.wn = function () {
        return this.wj;
    };
    ScatterBase.prototype.wi = function (a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterBase.prototype.wh = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterBase.prototype.yk = function () {
        this.ze = Rect.empty;
        this.zf = Rect.empty;
    };
    ScatterBase.prototype.xx = function () {
        var a = this.getViewInfo(this.ze, this.zf);
        this.ze = a.p0;
        this.zf = a.p1;
    };
    ScatterBase.prototype.wm = function (a, b) {
        if (b != 3) {
            return true;
        }
        if (a == null) {
            return true;
        }
        if (this.xn == a || this.xv == a) {
            return true;
        }
        return false;
    };
    ScatterBase.prototype.np = function (a, b, c, d) {
        var e = false;
        if (!this.wm(d, a)) {
            return;
        }
        this.vs.c0.g$e(a, b, c, d);
        if (this.xAxis != null && !this.xAxis.c1()) {
            e = true;
        }
        if (this.yAxis != null && !this.yAxis.c1()) {
            e = true;
        }
        if (a == 0 || a == 2 || a == 3 || a == 4) {
            this.we = true;
        }
        else if (a == 1) {
            for (var f = b; f < b + c; f++) {
                this.wt += this.wc.item(f);
                this.wu += this.wd.item(f);
            }
            this.wv = this.wt / this.wc.count;
            this.ww = this.wu / this.wd.count;
        }
        if (e) {
            this.pr(true);
        }
    };
    ScatterBase.prototype.yb = function (a) {
        this.yc(a, null);
    };
    ScatterBase.prototype.yc = function (a, b) {
        var e_1, _a, e_2, _b;
        var c = this.wc != null ? this.wc.count : 0;
        var d = this.wd != null ? this.wd.count : 0;
        var e = Math.min(c, d);
        if (e <= this.w3) {
            a.m.clear();
            var f = new List$1(OwnedPoint.$, 0);
            try {
                for (var _c = __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.c7;
            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 = __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.aq = function (a) {
        if (a != null && a == this.xAxis && this.wc != null) {
            return new AxisRange(this.wc.minimum, this.wc.maximum);
        }
        if (a != null && a == this.yAxis && this.wd != null) {
            return new AxisRange(this.wd.minimum, this.wd.maximum);
        }
        return null;
    };
    ScatterBase.prototype.js = function (a) {
        var b = this.i9(a);
        if (this.c7 != null && b >= 0 && b < this.c7.count) {
            return this.c7.item(b);
        }
        return null;
    };
    Object.defineProperty(ScatterBase.prototype, "v1", {
        get: function () {
            return this.v0;
        },
        set: function (a) {
            var b = this.v0;
            this.v0 = a;
            if (b != this.v0) {
                this.raisePropertyChanged("ActualItemSearchMode", enumGetBox(ScatterItemSearchMode_$type, b), enumGetBox(ScatterItemSearchMode_$type, this.v0));
            }
        },
        enumerable: false,
        configurable: true
    });
    ScatterBase.prototype.v2 = function () {
        if (this.v3 != 0) {
            return this.v3;
        }
        return this.wl ? 4 : 1;
    };
    ScatterBase.prototype.i9 = function (a) {
        var b = truncate(Math.round(this.hw(a)));
        return b;
    };
    ScatterBase.prototype.hw = function (a) {
        switch (this.v1) {
            case 1: return this.wz(a);
            case 3: return this.w0(a);
            case 2: return this.wx(a);
            case 4: return this.wy(a);
        }
        return -1;
    };
    ScatterBase.prototype.wy = function (a) {
        return this.w1(a, false);
    };
    ScatterBase.prototype.wx = function (a) {
        var b = this.te(a);
        var c = b.x;
        var d = b.y;
        if (this.c7 == null || this.xAxis == null || this.yAxis == null || this.wc == null || this.wd == null) {
            return -1;
        }
        if (this.c7.count > this.w2) {
            return -1;
        }
        this.x0();
        var e = this.vh;
        var f = this.vi;
        if (e == null || f == null) {
            return -1;
        }
        var g = 1.7976931348623157E+308;
        var h = -1;
        for (var i = 0; i < this.wc.count; i++) {
            var j = e[i];
            var k = f[i];
            var l = (c - j) * (c - j) + (d - k) * (d - k);
            if (l < g) {
                g = l;
                h = i;
            }
        }
        return h;
    };
    ScatterBase.prototype.x0 = function () {
        var _this = this;
        var a = this.cg.by;
        var b = this.cg.bx;
        var c = this.getEffectiveViewport();
        if (this.vr == null) {
            return;
        }
        var d = new ScalerParams(0, a, b, this.vr.d, c);
        var e = ((function () {
            var $ret = new ScalerParams(0, a, b, _this.vr.e, c);
            $ret.b = _this.h3();
            return $ret;
        })());
        if (this.vh == null || this.vi == null) {
            var f = arrayShallowClone(this.wc.asArray());
            var g = arrayShallowClone(this.wd.asArray());
            this.xAxis.hn(boxArray$1(f), 0, f.length, d);
            this.yAxis.hn(boxArray$1(g), 0, g.length, e);
            this.vh = f;
            this.vi = g;
        }
    };
    ScatterBase.prototype.get_wl = function () {
        return false;
    };
    Object.defineProperty(ScatterBase.prototype, "wl", {
        get: function () {
            return this.get_wl();
        },
        enumerable: false,
        configurable: true
    });
    ScatterBase.prototype.w1 = function (a, b) {
        if (!this.wl) {
            return -1;
        }
        var c = { $type: Point_$type, x: 0, y: 0 };
        var d = true;
        var e = this.vw();
        if (e == null) {
            return -1;
        }
        if (e.m == null) {
            return -1;
        }
        if (this.c7 == null || this.c7.count > this.w2) {
            return -1;
        }
        this.x0();
        var f = this.vh;
        var g = this.vi;
        if (f == null || g == null) {
            return -1;
        }
        var h = this.te(a);
        var i = 1.7976931348623157E+308;
        var j = -1;
        for (var k = 0; k < this.vh.length; k++) {
            var l = { $type: Point_$type, x: this.vh[k], y: this.vi[k] };
            if (k > 0) {
                if (!b || e.j.containsKey(this.c7.item(k)) || e.j.containsKey(this.c7.item(k - 1))) {
                    var m = GeometryUtil.d(h, c, l);
                    if (m < i) {
                        i = m;
                        j = k;
                    }
                }
            }
            c = l;
        }
        if (j >= 0) {
            var n = { $type: Point_$type, x: this.vh[j], y: this.vi[j] };
            var o = { $type: Point_$type, x: this.vh[j - 1], y: this.vi[j - 1] };
            if (!b || (e.j.containsKey(this.c7.item(j)) && e.j.containsKey(this.c7.item(j - 1)))) {
                var p = GeometryUtil.i(h, o, n);
                return (j - 1) + p;
            }
            else if (e.j.containsKey(this.c7.item(j))) {
                return j;
            }
            else {
                return j - 1;
            }
        }
        return -1;
    };
    ScatterBase.prototype.w0 = function (a) {
        return this.w1(a, true);
    };
    ScatterBase.prototype.wz = function (a) {
        var _this = this;
        var b = null;
        var c = 1.7976931348623157E+308;
        var d = this.te(a);
        var e = d.x;
        var f = d.y;
        if (this.vs.c1.e > this.w2) {
            return -1;
        }
        this.vs.c8(function (g) {
            if (g._visibility == 0) {
                var h = _this.vs.cs(g);
                var i = h.left + h.width / 2;
                var j = h.top + h.height / 2;
                var k = (e - i) * (e - i) + (f - j) * (f - j);
                if (k < c) {
                    c = k;
                    b = g;
                }
            }
        });
        if (b != null) {
            return b.ak;
        }
        return -1;
    };
    ScatterBase.prototype.tj = function (a, b, c) {
        var _this = this;
        if (this.xAxis == null || this.yAxis == null || this.wc == null || this.wd == null) {
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        var d = this.cg.by;
        var e = this.cg.bx;
        var f = this.getEffectiveViewport();
        var g = new ScalerParams(0, d, e, this.xAxis.ch, f);
        var h = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.yAxis.ch, f);
            $ret.b = _this.h3();
            return $ret;
        })());
        if (b) {
            var i = this.hw(a);
            if (i == -1) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            var j = truncate(Math.floor(i));
            var k = truncate(Math.ceil(i));
            if (j < 0) {
                j = 0;
            }
            if (k < 0) {
                k = 0;
            }
            if (k > this.c7.count - 1) {
                k = this.c7.count - 1;
            }
            if (j > this.c7.count - 1) {
                j = this.c7.count - 1;
            }
            if (k == j) {
                var l = this.xAxis.ej(this.wc.item(j), g);
                var m = this.yAxis.ej(this.wd.item(j), h);
                return { $type: Point_$type, x: l, y: m };
            }
            var n = i - Math.floor(i);
            var o = this.xAxis.ej(this.wc.item(j), g);
            var p = this.yAxis.ej(this.wd.item(j), h);
            var q = this.xAxis.ej(this.wc.item(k), g);
            var r = this.yAxis.ej(this.wd.item(k), h);
            var s = q - o;
            var t = r - p;
            return { $type: Point_$type, x: o + s * n, y: p + t * n };
        }
        else {
            var u = this.i9(a);
            if (u == -1) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            var v = this.xAxis.ej(this.wc.item(u), g);
            var w = this.yAxis.ej(this.wd.item(u), h);
            return { $type: Point_$type, x: v, y: w };
        }
    };
    ScatterBase.prototype.fp = function (a) {
        var _this = this;
        var b = this.cv != null ? this.cv.tr : Rect.empty;
        b = b.copy();
        var c = this.cv != null ? this.cv.t6 : Rect.empty;
        var d = new Rect(0, 0, 0, 1, 1);
        var e = this.ts(this.cg);
        var f = new ScalerParams(0, d, d, this.xAxis.ch, e);
        var g = ((function () {
            var $ret = new ScalerParams(0, d, d, _this.yAxis.ch, e);
            $ret.b = _this.h3();
            return $ret;
        })());
        var h = !b.isEmpty && !c.isEmpty && this.c7 != null ? this.c7.indexOf(a) : -1;
        var i = this.xAxis != null && this.wc != null && h < this.wc.count ? this.xAxis.ej(this.wc.item(h), f) : NaN;
        var j = this.yAxis != null && this.wd != null && h < this.wd.count ? this.yAxis.ej(this.wd.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.co != null) {
            this.co.au(this.cv, b, true);
        }
        return h >= 0;
    };
    ScatterBase.prototype.qo = function (a, b) {
        this.pr(false);
    };
    ScatterBase.prototype.qp = function (a, b) {
        this.pr(false);
    };
    ScatterBase.prototype.vw = function () {
        var a = this.vv;
        if (this.dk()) {
            if (this.cw.g) {
                this.cw.t();
            }
            a = this.vz;
        }
        return a;
    };
    ScatterBase.prototype.xy = 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.c7;
        var h;
        var i;
        var j = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.vr.d, f);
            $ret.c = _this.getEffectiveViewport1(a);
            return $ret;
        })());
        var k = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.vr.e, f);
            $ret.c = _this.getEffectiveViewport1(a);
            $ret.b = _this.h3();
            return $ret;
        })());
        var l = false;
        var m = 0;
        if (this.cv != null) {
            if (this.cv.fc()) {
                var n = this.cv.lp(d, j);
                l = n.c;
                m = n.d;
            }
        }
        var _loop_1 = function (o) {
            h = this_1.wc.item(o);
            i = this_1.wd.item(o);
            var p = { $type: Point_$type, x: this_1.vr.a.ej(h, j), y: this_1.vr.b.ej(i, k) };
            if (l) {
                if (p.x < e.left || p.x > e.right) {
                    if (p.x + m >= e.left && p.x + m <= e.right) {
                        p = { $type: Point_$type, x: p.x + m, y: i };
                    }
                }
            }
            if (!isInfinity(p.x) && !isInfinity(p.y)) {
                var q_1 = g.item(o);
                if (!b.g.containsKey(q_1)) {
                    var r_1 = { $type: Point_$type, x: h, y: i };
                    var s_1 = { $type: Point_$type, x: p.x, y: p.y };
                    b.g.addItem(q_1, ((function () {
                        var $ret = new OwnedPoint();
                        $ret.a = q_1;
                        $ret.b = r_1;
                        $ret.c = s_1;
                        return $ret;
                    })()));
                }
            }
        };
        var this_1 = this;
        for (var o = 0; o < c; o++) {
            _loop_1(o);
        }
    };
    ScatterBase.prototype.x8 = function (a, b) {
        var _this = this;
        this.vh = null;
        this.vi = null;
        a.j.clear();
        a.n.clear();
        a.h.clear();
        a.l.clear();
        a.i.clear();
        a.k.clear();
        var c = Math.min(this.wc != null ? this.wc.count : 0, this.wd != null ? this.wd.count : 0);
        var d = b.by;
        var e = b.bx;
        var f = this.getEffectiveViewport1(b);
        var g = new ScalerParams(0, d, e, this.xAxis.ch, f);
        g.c = this.getEffectiveViewport1(b);
        var h = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.yAxis.ch, f);
            $ret.b = _this.h3();
            return $ret;
        })());
        h.c = this.getEffectiveViewport1(b);
        if (c < 1) {
            return;
        }
        this.vr = ((function () {
            var $ret = new ScatterAxisInfoCache();
            $ret.a = _this.xAxis;
            $ret.b = _this.yAxis;
            $ret.d = _this.xAxis.ch;
            $ret.e = _this.yAxis.ch;
            $ret.c = _this.c7;
            return $ret;
        })());
        var i = b;
        if (c <= this.w3) {
            this.xy(i, a, c, d, e);
        }
        if (this.ue()) {
            b.cy.l(a.j, this.w3, d, e, this.hk);
        }
        var j = ((function () {
            var $ret = new Clipper(0, e, false);
            $ret.i = a.n;
            return $ret;
        })());
        var k = this.tq(b);
        var l = this.xAxis.em(k.left, g);
        var m = this.xAxis.em(k.right, g);
        b.c0.h(a.n, this.trendLineType, this.wc, this.wd, this.trendLinePeriod, function (n) { return _this.xAxis.ej(n, g); }, function (n) { return _this.yAxis.ej(n, h); }, ((function () {
            var $ret = new TrendResolutionParams();
            $ret.d = _this.hk;
            $ret.h = e;
            $ret.i = d;
            return $ret;
        })()), j, l, m);
        this.x6(a, b);
    };
    ScatterBase.prototype.nk = function (a, b) {
        _super.prototype.nk.call(this, a, b);
        var c = b;
        c.c7(a);
    };
    ScatterBase.prototype.get_et = function () {
        return true;
    };
    ScatterBase.prototype.v6 = function (a, b, c) {
        return null;
    };
    ScatterBase.prototype.v7 = function (a, b, c) {
        var d = this.vw();
        var e = this.vs.b1(this.te(b));
        var f = -1;
        if (e == null) {
            if (a != null) {
                f = this.c7.indexOf(a);
            }
            else {
                return null;
            }
        }
        else {
            f = e.ak;
        }
        if (f == -1) {
            return null;
        }
        var g = new HighlightingInfo();
        g.i = this;
        g.g = f;
        g.f = f;
        g.c = false;
        g.d = true;
        if (c != null && c.g == g.g && c.f == g.f) {
            return c;
        }
        return g;
    };
    ScatterBase.prototype.t0 = function (a, b) {
        if (this.uc != 1 && this.uc != 13) {
            var c = this.ub.ct();
            var d = (c.width / 2) + (this.uh / 2);
            var e = (c.height / 2) + (this.uh / 2);
            var f = d;
            var g = d;
            var h = e;
            var i = e;
            if (a == 2 || a == 4) {
                f = 0;
            }
            if (a == 2 || a == 3) {
                g = 0;
            }
            if (b == 2 || b == 3) {
                h = 0;
            }
            if (b == 2 || b == 4) {
                i = 0;
            }
            return new Thickness(1, f, h, g, i);
        }
        return new Thickness(1, 0, 0, 0, 0);
    };
    ScatterBase.prototype.v5 = function (a, b, c) {
        var d = new HighlightingInfo();
        d.i = this;
        d.g = 0;
        d.f = this.c7.count - 1;
        d.c = true;
        if (c != null && c.g == d.g && c.f == d.f) {
            return c;
        }
        return d;
    };
    ScatterBase.prototype.c0 = function (a, b, c) {
        if (this.dv && this.fd(this.bp) && !c) {
            var d = this.v6(a, b, this.v8);
            this.v8 = d;
            return d;
        }
        else {
            var e = this.v5(a, b, this.v8);
            this.v8 = e;
            return e;
        }
    };
    ScatterBase.prototype.c1 = function (a, b, c) {
        if (this.fd(this.bp) && !c) {
            var d = this.v7(a, b, this.v9);
            this.v9 = d;
            return d;
        }
        else {
            var e = this.v5(a, b, this.v9);
            e.d = true;
            this.v9 = e;
            return e;
        }
    };
    ScatterBase.prototype.wq = function () {
        return (this.assigningScatterStyle != null && this.wg) || (this.bp != 1);
    };
    ScatterBase.prototype.wp = function () {
        return (this.assigningScatterMarkerStyle != null && this.wf) || (this.bp != 1);
    };
    ScatterBase.prototype.yj = function (a, b) {
        var _this = this;
        this.oy();
        var c = b.bx;
        this.vr = ((function () {
            var $ret = new ScatterAxisInfoCache();
            $ret.a = _this.xAxis;
            $ret.b = _this.yAxis;
            $ret.d = _this.xAxis.ch;
            $ret.e = _this.yAxis.ch;
            return $ret;
        })());
        if (this.ue()) {
            b.cy.j(a.j, this.ug);
            if (this.wp()) {
                this.xz(b, a);
            }
        }
        b.cp();
        var d = ((function () {
            var $ret = new Clipper(1, NaN, c.bottom, NaN, c.top, false);
            $ret.i = b.c0.g$j.an;
            return $ret;
        })());
        b.c0.g$h(a.n, d);
        this.yg(a, b);
    };
    ScatterBase.prototype.vk = function (a, b) {
        return this.vl(a, b);
    };
    ScatterBase.prototype.vl = function (a, b) {
        if (b < a || a < 0 || a > this.wc.count || b < 0 || b > this.wc.count) {
            return null;
        }
        var c = new Array((b - a) + 1);
        for (var d = a; d <= b; d++) {
            var e = d;
            c[d - a] = this.c7.item(d);
        }
        return c;
    };
    ScatterBase.prototype.xz = function (a, b) {
        var _this = this;
        a.b6 = true;
        this.v4.ay(this, this.wp(), runOn(this, this.vk));
        var c = this.v4.d;
        var d = c != null;
        var e = this.getEffectiveViewport1(a);
        var f = this.c7 == null ? 0 : this.c7.count;
        this.vs.ci(function (g) {
            if (g._visibility == 0) {
                var h = g.ak;
                var i = g.content;
                if (i == null) {
                    i = new DataContext();
                    g.content = i;
                }
                if (d) {
                    _this.x3(h, f, a.q);
                }
                _this.v4.ac(g, i);
            }
        });
    };
    ScatterBase.prototype.x4 = function (a, b, c) {
        var d = this.bp != 1;
        this.v4.a0(this.v4.b, a, b, false);
        this.v4.ab(this.hi);
        var e = this.v4.ax;
        var f = null;
        var g = this.c7;
        if (d && this.cv != null) {
            f = this.cv.c2.getHighlightingInfo(this, g, e.o, e.n, false);
            e.b = f;
        }
        e.f = c;
        this.ye(e);
        this.v4.z(this, f, c, d, a < 0);
    };
    ScatterBase.prototype.x3 = function (a, b, c) {
        var d = this.bp != 1;
        this.v4.a0(this.v4.d, a, b, true);
        this.v4.aa(this.hi);
        var e = this.v4.aw;
        var f = null;
        var g = this.c7;
        var h = null;
        if (d && this.cv != null) {
            f = this.cv.c2.getHighlightingInfo(this, g, e.o, e.n, true);
            if (this.cv.c2.isCrossContextHighlight(this)) {
                h = this.cv.c2.getHighlightingInfo(this, g, e.o, e.n, true);
            }
            e.b = f;
        }
        e.f = c;
        this.yd(e);
        this.v4.y(this, f, c, d, e.m, this.cv.c2.totalHighlightingProgress);
    };
    ScatterBase.prototype.ye = function (a) {
        if (this.assigningScatterStyle != null && this.wg) {
            this.assigningScatterStyle(this, a);
        }
    };
    ScatterBase.prototype.yd = function (a) {
        if (this.assigningScatterMarkerStyle != null && this.wf) {
            this.assigningScatterMarkerStyle(this, a);
        }
    };
    ScatterBase.prototype.x6 = function (a, b) {
        var e_3, _a;
        var c = new ErrorBarsHelper(this, b);
        if (this.vt == null) {
            return;
        }
        var d = this.vt.u;
        var e = this.vt.v;
        var f = 0;
        var g = 0;
        var h = 0;
        var i = 0;
        try {
            for (var _b = __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.x9(k, c, d, h, i, true);
                            h = l.p3;
                            i = l.p4;
                            break;
                        case 0:
                            var m = this.x7(k, c, d, h, i, true);
                            h = m.p3;
                            i = m.p4;
                            break;
                        case 2:
                            var n = this.x5(k, c, d, j, h, i, true);
                            h = n.p4;
                            i = n.p5;
                            break;
                        case 3:
                            var o = this.ya(c, d, f, h, i, true);
                            f = o.p2;
                            h = o.p3;
                            i = o.p4;
                            break;
                        case 4:
                            var p = this.x7(k, c, d, h, i, true);
                            h = p.p3;
                            i = p.p4;
                            break;
                    }
                    ;
                    var q = new OwnedPoint();
                    q.c = c.l(d, this.vr.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.x9(k, c, e, h, i, false);
                            h = r.p3;
                            i = r.p4;
                            break;
                        case 0:
                            var s = this.x7(k, c, e, h, i, false);
                            h = s.p3;
                            i = s.p4;
                            break;
                        case 2:
                            var t = this.x5(k, c, e, j, h, i, false);
                            h = t.p4;
                            i = t.p5;
                            break;
                        case 3:
                            var u = this.ya(c, e, g, h, i, false);
                            g = u.p2;
                            h = u.p3;
                            i = u.p4;
                            break;
                        case 4:
                            var v = this.x7(k, c, e, h, i, false);
                            h = v.p3;
                            i = v.p4;
                            break;
                    }
                    ;
                    var w = new OwnedPoint();
                    w.c = c.m(e, this.vr.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.x9 = function (a, b, c, d, e, f) {
        if (f) {
            var g = void 0;
            var h = void 0, i = void 0;
            i = this.vr.a;
            if (this.vt.s == 0) {
                g = a.c.x;
                h = this.vr.a;
            }
            else {
                g = a.c.y;
                h = this.vr.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.vr.b;
            if (this.vt.t == 0) {
                k = a.c.x;
                l = this.vr.a;
            }
            else {
                k = a.c.y;
                l = this.vr.b;
            }
            var n = b.f(k, c, l, m, d, e);
            d = n.p4;
            e = n.p5;
        }
        return {
            p3: d,
            p4: e
        };
    };
    ScatterBase.prototype.x7 = function (a, b, c, d, e, f) {
        if (f) {
            var g = b.j(a.c.x, c, this.vr.a, d, e);
            d = g.p3;
            e = g.p4;
        }
        else {
            var h = b.j(a.c.y, c, this.vr.b, d, e);
            d = h.p3;
            e = h.p4;
        }
        return {
            p3: d,
            p4: e
        };
    };
    ScatterBase.prototype.x5 = function (a, b, c, d, e, f, g) {
        var h = c.getItemColumn();
        var i = this.c7.indexOf(d);
        if (h != null && i < h.count) {
            var j = h.item(i);
            if (g) {
                var k = b.h(a.c.x, j, this.vr.a, e, f);
                e = k.p3;
                f = k.p4;
            }
            else {
                var l = b.h(a.c.y, j, this.vr.b, e, f);
                e = l.p3;
                f = l.p4;
            }
        }
        else {
            e = NaN;
            f = NaN;
        }
        return {
            p4: e,
            p5: f
        };
    };
    ScatterBase.prototype.ya = 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.vr.a, d, e);
            d = h.p3;
            e = h.p4;
        }
        else {
            var i = a.k(c, b, this.vr.b, d, e);
            d = i.p3;
            e = i.p4;
        }
        return {
            p2: c,
            p3: d,
            p4: e
        };
    };
    ScatterBase.prototype.yg = function (a, b) {
        if (!b.o() || this.vt == null) {
            b.c9();
            return;
        }
        this.yh(a, b);
        this.yi(a, b);
    };
    ScatterBase.prototype.yh = function (a, b) {
        var e_4, _a;
        b.c5();
        var c = new ErrorBarsHelper(this, b);
        var d = new PathGeometry();
        var e = this.vt.u;
        try {
            for (var _b = __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.vt.o == 1 || this.vt.o == 2) {
                            c.d(d, i, g, true);
                        }
                        if (this.vt.o == 1 || this.vt.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.da(d);
    };
    ScatterBase.prototype.yi = function (a, b) {
        var e_5, _a;
        b.c6();
        var c = new ErrorBarsHelper(this, b);
        var d = new PathGeometry();
        var e = this.vt.v;
        try {
            for (var _b = __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.vt.p == 1 || this.vt.p == 2) {
                            c.e(d, i, g, true);
                        }
                        if (this.vt.p == 1 || this.vt.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.gm = function (a, b, c) {
        var d = true;
        if (!_super.prototype.gm.call(this, a, b, c) || b.isEmpty || a.isEmpty || this.xAxis == null || this.yAxis == null || this.xAxis.bi == null || this.yAxis.bi == null || this.wc == null || this.wd == null || this.wc.count == 0 || this.wd.count == 0 || this.c7 == null || this.c7.count != this.wc.count || this.c7.count != this.wd.count || this.xAxis.bi == null || this.yAxis.bi == null || this.xAxis.lx == this.xAxis.lw || this.yAxis.lx == this.yAxis.lw) {
            d = false;
        }
        return d;
    };
    ScatterBase.prototype.getViewInfo = function (a, b) {
        if (!this.ze.isEmpty && !this.zf.isEmpty) {
            a = this.ze;
            b = this.zf;
            return {
                p0: a,
                p1: b
            };
        }
        a = this.cg.bx;
        b = this.cg.by;
        return {
            p0: a,
            p1: b
        };
    };
    ScatterBase.prototype.ps = function (a) {
        _super.prototype.ps.call(this, a);
        this.xx();
        try {
            if (this.dm(this.cg)) {
                return;
            }
            if (this.c7 != null && this.c7.count > this.w3) {
                a = false;
            }
            if (this.fq(a) && !this.f1) {
                var b = this.vx;
                if (this.dk()) {
                    if (this.cw.g) {
                        this.cw.t();
                    }
                    this.vx = this.vz;
                    this.vz = b;
                }
                else {
                    this.vx = this.vv;
                    this.vv = b;
                }
                this.x8(this.vv, this.vs);
                this.p5();
            }
            else {
                if (!this.f1) {
                    this.x8(this.vv, this.vs);
                }
                this.yj(this.vv, this.vs);
            }
        }
        finally {
            this.yk();
        }
    };
    ScatterBase.prototype.qf = function () {
        _super.prototype.qf.call(this);
        if (this.index < 0) {
            return;
        }
        this.vs.dd();
    };
    ScatterBase.prototype.pt = function (a, b) {
        _super.prototype.pt.call(this, a, b);
        if (!this.f9) {
            this.cg.a4(b);
            return;
        }
        this.cg.a4(b);
        if (this.dm(this.cf)) {
            return;
        }
        var c = typeCast(ScatterBaseView.$, this.cf);
        if (!this.f2) {
            this.vy = new ScatterFrame();
            this.x8(this.vy, c);
        }
        this.f2 = false;
        this.yj(this.vy, c);
        this.f9 = false;
    };
    ScatterBase.prototype.pq = function (a, b, c, d, e) {
        _super.prototype.pq.call(this, a, b, c, d, e);
        var f = this.a3.a$h.item(d);
        var g = f;
        f.a3(c);
        if (this.dm(g)) {
            return;
        }
        if (this.vu == null) {
            this.vu = new ScatterFrame();
        }
        this.x8(this.vu, g);
        this.yj(this.vu, g);
    };
    ScatterBase.prototype.yf = function (a, b) {
        var e_6, _a, e_7, _b;
        var c = new List$1(Base.$, 0);
        try {
            for (var _c = __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 = __values(fromEnum(c)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var e = _f.value;
                b.h(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.vj = function (a, b, c, d, e) {
        var _this = this;
        if (c == null || c.length != this.vr.c.count) {
            c = new Array(this.vr.c.count);
            for (var f = 0; f < this.vr.c.count; f++) {
                c[f] = PointUtil.create();
            }
        }
        var g = this.getEffectiveViewport1(a);
        var h = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.xAxis.ch, g);
            $ret.c = _this.getEffectiveViewport1(a);
            return $ret;
        })());
        var i = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.yAxis.ch, g);
            $ret.c = _this.getEffectiveViewport1(a);
            $ret.b = _this.h3();
            return $ret;
        })());
        var j = this.tq(a);
        var k = this.vr.a.em(j.left, h);
        var l = this.vr.a.em(j.right, h);
        var m = this.vr.b.em(j.bottom, i);
        var n = this.vr.b.em(j.top, i);
        if (this.vr.d) {
            var o = k;
            k = l;
            l = o;
        }
        if (this.vr.e) {
            var p = m;
            m = n;
            n = p;
        }
        var q = this.vr;
        var r = q.a;
        var s = q.b;
        var t;
        var u;
        var v = this.wc;
        var w = this.wd;
        var x = false;
        var y = 0;
        var z = 0;
        if (this.cv != null) {
            if (this.cv.fc()) {
                var aa = this.cv.lp(d, h);
                x = aa.c;
                y = aa.d;
                z = r.em(0 + y, h);
                var ab = r.em(0, h);
                z -= ab;
            }
        }
        for (var ac = 0; ac < this.vr.c.count; ac++) {
            t = v.item(ac);
            u = w.item(ac);
            if (x) {
                if (t >= k && t <= l && u >= m && u <= n) {
                    c[ac].x = r.ej(t, h);
                    c[ac].y = s.ej(u, i);
                }
                else {
                    if ((t + z) >= k && (t + z) <= l && u >= m && u <= n) {
                        c[ac].x = r.ej(t, h) + y;
                        c[ac].y = s.ej(u, i);
                    }
                    else {
                        c[ac].x = NaN;
                        c[ac].y = NaN;
                    }
                }
            }
            else {
                if (t >= k && t <= l && u >= m && u <= n) {
                    c[ac].x = r.ej(t, h);
                    c[ac].y = s.ej(u, i);
                }
                else {
                    c[ac].x = NaN;
                    c[ac].y = NaN;
                }
            }
        }
        return c;
    };
    ScatterBase.prototype.ws = 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.c7;
        try {
            for (var _b = __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.n2 = function (a) {
        _super.prototype.n2.call(this, a);
        this.a5.exportTrendlineData(this, a, this.vs.c0.g$j);
    };
    ScatterBase.prototype.h3 = function () {
        return Series.h4(this.wd, null);
    };
    ScatterBase.prototype.getDataLegendSeriesContextAt = function (a, b) {
        var c = { $type: Point_$type, x: a, y: b };
        var d = this.js(c);
        var e = d == null ? NaN : this.h2(d, "XMemberPath");
        var f = d == null ? NaN : this.h2(d, "YMemberPath");
        var g = new DataLegendSeriesValueInfo();
        g.l = e;
        g.a = 13;
        g.p = "X";
        g.q = this.xn != null ? this.xn : "X";
        g.r = this.xj != null ? this.xj : "X:";
        g.s = this.xl != null ? this.xl : "";
        var h = new DataLegendSeriesValueInfo();
        h.l = f;
        h.a = 14;
        h.p = "Y";
        h.q = this.xv != null ? this.xv : "Y";
        h.r = this.xr != null ? this.xr : "Y:";
        h.s = this.xt != null ? this.xt : "";
        var i = new DataLegendSeriesContext();
        i.f = ((function () {
            var $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
            $ret.add(g);
            $ret.add(h);
            return $ret;
        })());
        i.b = this.aw();
        return i;
    };
    ScatterBase.prototype.yl = function () {
        if (this.we) {
            this.wt = 0;
            this.wu = 0;
            for (var a = 0; a < this.wc.count; a++) {
                this.wt += this.wc.item(a);
                this.wu += this.wd.item(a);
            }
            this.wv = this.wt / this.wc.count;
            this.ww = this.wu / this.wd.count;
            this.we = false;
        }
    };
    ScatterBase.prototype.id = function (a, b) {
        if (b == null || !b.cj) {
            return NaN;
        }
        if (b != this.xAxis && b != this.yAxis) {
            return NaN;
        }
        var c = this.am(a);
        if (b.cp) {
            return c[1];
        }
        else {
            return c[0];
        }
    };
    ScatterBase.prototype.am = function (a) {
        var b = NaN;
        var c = NaN;
        switch (a) {
            case 5:
            case 2:
                b = this.wc.maximum;
                c = this.wd.maximum;
                break;
            case 4:
            case 1:
                b = this.wc.minimum;
                c = this.wd.minimum;
                break;
            case 6:
            case 3:
                if (this.we) {
                    this.yl();
                }
                b = this.wv;
                c = this.ww;
                break;
        }
        return [b, c];
    };
    ScatterBase.prototype.tn = function (a) {
        var b = this.getEffectiveViewport1(this.cg);
        var c = new ScalerParams(0, this.cg.by, this.cg.bx, this.xAxis.ch, b);
        c.c = b;
        var d = isNaN_(a[0]) ? NaN : this.xAxis.ej(a[0], c);
        c = new ScalerParams(0, this.cg.by, this.cg.bx, this.yAxis.ch, b);
        c.b = this.h3();
        c.c = b;
        var e = isNaN_(a[1]) ? NaN : this.yAxis.ej(a[1], c);
        return { $type: Point_$type, x: d, y: e };
    };
    ScatterBase.prototype.tm = function (a) {
        var b = this.am(a);
        return this.tn(b);
    };
    ScatterBase.$t = markType(ScatterBase, 'ScatterBase', MarkerSeries.$, [ISupportsErrorBars_$type, ITrendLineSeries_$type]);
    ScatterBase.ym = 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:vt:yn', [ScatterErrorBarSettings.$, null], 'HighlightedXMemberPath:w7:yo', [2, null], 'HighlightedYMemberPath:w9:yp', [2, null], 'IsCustomScatterMarkerStyleAllowed:wj:yq', [0, false], 'IsCustomScatterStyleAllowed:wk:yr', [0, false], 'ItemSearchMode:v3:ys', [ScatterItemSearchMode_$type, enumGetBox(ScatterItemSearchMode_$type, 0)], 'ItemSearchThreshold:w2:yt', [1, 10000], 'MarkerCollisionAvoidance:vo:yu', [CollisionAvoidanceType_$type, enumGetBox(CollisionAvoidanceType_$type, 0)], 'MaximumMarkers:w3:yv', [1, 400], 'XAxis::y3', [NumericXAxis.$, null], 'XMemberAsLegendLabel:xj:y4', [2, null], 'XMemberAsLegendUnit:xl:y5', [2, null], 'XMemberPath:xn:y6', [2, null], 'YAxis::y7', [NumericYAxis.$, null], 'YMemberAsLegendLabel:xr:y8', [2, null], 'YMemberAsLegendUnit:xt:y9', [2, null], 'YMemberPath:xv:za', [2, null], 'TrendLineType::y1', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::y0', [1, 1.5], 'TrendLinePeriod::yz', [1, 7], 'TrendLineBrush::yw', [Brush.$, null], 'TrendLineZIndex:w4:y2', [1, 1001], 'TrendLineDashArray:zc:yx', [DoubleCollection.$], 'TrendLineDashCap:zd:yy', [PenLineCap_$type, enumGetBox(PenLineCap_$type, 0)]]);
    return ScatterBase;
}(MarkerSeries));
export { ScatterBase };
/**
 * @hidden
 */
var ScatterSeriesRenderManager = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(ScatterSeriesRenderManager, _super);
    function ScatterSeriesRenderManager() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.aw = null;
        _this.ax = null;
        return _this;
    }
    ScatterSeriesRenderManager.prototype.c = function () {
        this.aw = new AssigningScatterMarkerStyleEventArgs();
        return this.aw;
    };
    ScatterSeriesRenderManager.prototype.a = function () {
        this.ax = new AssigningScatterStyleEventArgs();
        return this.ax;
    };
    ScatterSeriesRenderManager.prototype.ay = function (a, b, c) {
        this.w(a, b, c);
    };
    ScatterSeriesRenderManager.prototype.az = function (a, b, c) {
        this.x(a, b, c);
    };
    ScatterSeriesRenderManager.prototype.a0 = function (a, b, c, d) {
        if (b == -1) {
            a.c = false;
            a.o = 0;
            a.n = c - 1;
        }
        else {
            if (d) {
                a.o = b;
                a.n = b;
            }
            else {
                a.c = false;
                a.o = b;
                a.n = b;
            }
        }
    };
    ScatterSeriesRenderManager.$t = markType(ScatterSeriesRenderManager, 'ScatterSeriesRenderManager', SeriesRenderManager.$);
    return ScatterSeriesRenderManager;
}(SeriesRenderManager));
export { ScatterSeriesRenderManager };
/**
 * @hidden
 */
var ScatterBaseView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(ScatterBaseView, _super);
    function ScatterBaseView(a) {
        var _this = _super.call(this, a) || this;
        _this.cy = null;
        _this.cw = null;
        _this.cz = null;
        _this.c4 = null;
        _this.df = null;
        _this.dg = null;
        _this.c0 = null;
        _this.de = null;
        _this.c1 = null;
        _this.cz = a;
        _this.c1 = new HashPool$2(Base.$, Marker.$);
        _this.ck(_this.c1);
        _this.c0 = new ScatterTrendLineManager();
        return _this;
    }
    ScatterBaseView.prototype.au = function () {
        _super.prototype.au.call(this);
        this.cy = this.cx();
        this.df = new Path();
        this.dg = new Path();
        if (!this.q) {
            this.cz.w3 = 2000;
        }
    };
    ScatterBaseView.prototype.dh = function (a) {
        if (this.de == null) {
            this.de = new DataTemplateMeasureInfo();
            this.de.context = this.k.h();
        }
        this.de.width = a.width;
        this.de.height = a.height;
        this.de.data = a.content;
        var b = a.ah;
        if (b.measure != null) {
            b.measure(this.de);
        }
        return new Size(1, this.de.width, this.de.height);
    };
    ScatterBaseView.prototype.cx = function () {
        var _this = this;
        var a = new NumericMarkerManager(1, function (b) { return _this.c1.item(b); }, function (b) { return _this.cz.vr.c.item(b); }, runOn(this, this.dc), runOn(this, this.cu), runOn(this, this.c2), function () { return _this.cz.vo; });
        a.q = runOn(this, this.dh);
        return a;
    };
    ScatterBaseView.prototype.dc = function (a) {
        this.cz.yf(a, this.c1);
    };
    ScatterBaseView.prototype.c3 = function () {
        return this.b7;
    };
    ScatterBaseView.prototype.cv = function () {
        return this.cw;
    };
    ScatterBaseView.prototype.cu = function () {
        this.cw = this.cz.vj(this, this.c1, this.cw, this.by, this.bx);
        return this.cw;
    };
    ScatterBaseView.prototype.c2 = function () {
        this.c4 = this.cz.ws(this.c1, this.c4);
        return this.c4;
    };
    ScatterBaseView.prototype.c5 = function () {
    };
    ScatterBaseView.prototype.da = function (a) {
    };
    ScatterBaseView.prototype.c6 = function () {
    };
    ScatterBaseView.prototype.db = function (a) {
    };
    ScatterBaseView.prototype.dd = function () {
        if (this.cz.trendLineBrush != null) {
            this.cz.zb = this.cz.trendLineBrush;
        }
        else {
            this.cz.zb = this.cz.su;
        }
    };
    ScatterBaseView.prototype.ci = function (a) {
        this.c1.f(a);
    };
    ScatterBaseView.prototype.c8 = function (a) {
        this.c1.g(a);
    };
    ScatterBaseView.prototype.c9 = function () {
    };
    ScatterBaseView.prototype.a7 = function (a, b) {
        _super.prototype.a7.call(this, a, b);
        if (a.d) {
            if (this.cz.trendLineType != 0 && !b) {
                var c = this.c0.g$j;
                c.ad = this.cz.trendLineThickness;
                c._stroke = this.cz.zb;
                c.ai = this.cz.zc;
                c.aj = this.cz.zd;
                a.v(c);
            }
        }
    };
    ScatterBaseView.prototype.c7 = function (a) {
        if (a) {
            this.c9();
            this.c1.clear();
        }
        this.c0.g$d();
        this.as();
    };
    ScatterBaseView.prototype.getDefaultTooltipTemplate = function () {
        var a = "<div class='ui-chart-default-tooltip-content'><span";
        var b = this.e.a3.a$r(this.e);
        if (!stringIsNullOrEmpty(b)) {
            a += " style='color:" + b + "'";
        }
        a += ">" + this.cz.title + "</span><br/><span>" + "x: </span><span class='ui-priority-primary'>${item." + this.cz.xn + "}</span><br/><span>" + "y: </span><span class='ui-priority-primary'>${item." + this.cz.xv + "}</span></div>";
        return a;
    };
    ScatterBaseView.$t = markType(ScatterBaseView, 'ScatterBaseView', MarkerSeriesView.$);
    return ScatterBaseView;
}(MarkerSeriesView));
export { ScatterBaseView };
