/*
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 { ChartSelection } from "./ChartSelection";
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.yu = null;
        _this.zd = null;
        _this.ze = null;
        _this.acj = null;
        _this.ack = null;
        _this.y3 = 1;
        _this.yk = null;
        _this.yl = null;
        _this.y0 = null;
        _this.y2 = null;
        _this.yy = null;
        _this.zj = false;
        _this.zi = false;
        _this.zb = null;
        _this.zc = null;
        _this.assigningScatterStyle = null;
        _this.assigningScatterMarkerStyle = null;
        _this.y7 = null;
        _this.y1 = null;
        _this.yx = null;
        _this.zh = true;
        _this.zw = 0;
        _this.zx = 0;
        _this.zy = 0;
        _this.zz = 0;
        _this.y4 = _this.y5();
        _this.y7 = new ScatterSeriesRenderManager();
        _this.y1 = new ScatterFrame();
        _this.ack = Rect.empty;
        _this.acj = Rect.empty;
        return _this;
    }
    ScatterBase.prototype.cs = function () {
        return new ScatterBaseView(this);
    };
    ScatterBase.prototype.o2 = function () {
        _super.prototype.o2.call(this);
        this.xAxis = null;
        this.yAxis = null;
    };
    ScatterBase.prototype.qz = function (a) {
        _super.prototype.qz.call(this, a);
        this.yv = a;
    };
    ScatterBase.prototype.get_fw = function () {
        return true;
    };
    ScatterBase.prototype.ai = function () {
        return [this.xAxis, this.yAxis];
    };
    ScatterBase.prototype.kq = function (a, b) {
        var c = this.nd(b);
        if (c == ScatterBase.$$p[12]) {
            return this.kr(a, b, this.aar);
        }
        if (c == ScatterBase.$$p[16]) {
            return this.kr(a, b, this.aaz);
        }
        if (c == ScatterBase.$$p[1]) {
            return this.kr(a, b, this.aab);
        }
        if (c == ScatterBase.$$p[2]) {
            return this.kr(a, b, this.aad);
        }
        return null;
    };
    ScatterBase.prototype.md = function (a) {
        var b = this.nd(a);
        if (b == ScatterBase.$$p[12]) {
            return this.aar;
        }
        if (b == ScatterBase.$$p[16]) {
            return this.aaz;
        }
        if (b == ScatterBase.$$p[1]) {
            return this.aab;
        }
        if (b == ScatterBase.$$p[2]) {
            return this.aad;
        }
        return _super.prototype.md.call(this, a);
    };
    ScatterBase.prototype.eb = function (a, b, c, d, e) {
        var _this = this;
        if (!this.hasMarkers) {
            return false;
        }
        var f = this.xAxis;
        var g = new ScalerParams(1, this.db.v4, this.wq, f.ch);
        g.c = this.getEffectiveViewport1(this.cv);
        var h = this.yAxis;
        var i = new ScalerParams(1, this.db.v4, this.wq, h.ch);
        i.c = this.getEffectiveViewport1(this.cv);
        a.clear();
        this.w4.cj(function (j) {
            if (j._visibility == 0) {
                var k = new SeriesPointOfInterest();
                var l = j.n;
                var m = j.o;
                if (l < _this.wq.left || l > _this.wq.right || m < _this.wq.top || m > _this.wq.bottom) {
                    return;
                }
                k.d = f.eo(l, g);
                k.e = h.eo(m, i);
                k.b = j.content;
                k.g = _this.ve;
                k.c = j.ak;
                if (_this.g9) {
                    k.g = _this.vl(j.ak);
                }
                a.add(k);
            }
        });
        return true;
    };
    ScatterBase.prototype.b2 = function () {
        if (this.b3 == 0) {
            if (this.z7 <= 2000) {
                return 1;
            }
            else {
                return _super.prototype.b2.call(this);
            }
        }
        else {
            return _super.prototype.b2.call(this);
        }
    };
    ScatterBase.prototype.wn = function (a) {
        if (!this.hasMarkers || !this.xe()) {
            return Rect.empty;
        }
        var b = this.w4.b1(this.v5(a));
        if (b != null) {
            return this.w4.cu(b);
        }
        return Rect.empty;
    };
    ScatterBase.prototype.gw = function (a, b) {
        if (this.xf(a, b)) {
            return true;
        }
        return false;
    };
    Object.defineProperty(ScatterBase.prototype, "zf", {
        get: function () {
            return this.zd;
        },
        set: function (a) {
            if (this.zd != a) {
                var b = this.zf;
                this.zd = a;
                this.raisePropertyChanged("XColumn", b, this.zf);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ScatterBase.prototype, "zg", {
        get: function () {
            return this.ze;
        },
        set: function (a) {
            if (this.ze != a) {
                var b = this.zg;
                this.ze = a;
                this.raisePropertyChanged("YColumn", b, this.zg);
            }
        },
        enumerable: false,
        configurable: true
    });
    ScatterBase.prototype.gb = function () {
        return this.highlightedItemsSource != null || (this.aab != null && this.aad != null);
    };
    ScatterBase.prototype.zu = function () {
        return false;
    };
    ScatterBase.prototype.ht = function () {
        var a = _super.prototype.ht.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.aa7));
            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.aa6));
            a.add(c);
        }
        if (this.zu()) {
            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.zu()) {
            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.ry));
            a.add(e);
        }
        if (!this.zu()) {
            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.ry));
            a.add(f);
        }
        return a;
    };
    ScatterBase.prototype.aa6 = function (a, b) {
        if (this.aab != null) {
            b.value = this.aab;
            return;
        }
        b.value = this.aar;
    };
    ScatterBase.prototype.aa7 = function (a, b) {
        if (this.aad != null) {
            b.value = this.aad;
            return;
        }
        b.value = this.aaz;
    };
    Object.defineProperty(ScatterBase.prototype, "acg", {
        get: function () {
            return this.c(ScatterBase.abr);
        },
        set: function (a) {
            this.h(ScatterBase.abr, 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.p9 = function () {
        _super.prototype.p9.call(this);
        if (this.xAxis != null) {
            this.xAxis.ib(false);
        }
        if (this.yAxis != null) {
            this.yAxis.ib(false);
        }
    };
    ScatterBase.prototype.q7 = function (a, b, c, d) {
        _super.prototype.q7.call(this, a, b, c, d);
        if (this.yv.c2.g$b(a, b, c, d)) {
            this.rp(false);
            this.qj();
        }
        switch (b) {
            case ScatterBase.$$p[10]:
            case ScatterBase.$$p[14]:
            case ScatterBase.$$p[11]:
            case ScatterBase.$$p[15]:
                this.qd();
                break;
            case "FastItemsSource":
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.zf);
                    c.deregisterColumn(this.zg);
                    this.zf = null;
                    this.zg = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.zf = this.dk(this.aar);
                    this.zg = this.dk(this.aaz);
                }
                if ((this.yAxis != null && !this.yAxis.c1()) || (this.xAxis != null && !this.xAxis.c1())) {
                    this.rp(this.gg && 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.rp(false);
                }
                this.qj();
                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.rp(false);
                }
                this.qj();
                break;
            case ScatterBase.$$p[12]:
                if (this.dn != null) {
                    this.dn.deregisterColumn(this.zf);
                    this.zf = this.dk(this.aar);
                }
                break;
            case "XColumn":
                this.yv.c2.g$i();
                if (this.xAxis != null && !this.xAxis.c1()) {
                    this.rp(this.gg && this.d7);
                }
                break;
            case ScatterBase.$$p[16]:
                if (this.dn != null) {
                    this.dn.deregisterColumn(this.zg);
                    this.zg = this.dk(this.aaz);
                }
                break;
            case "YColumn":
                this.yv.c2.g$i();
                if (this.yAxis != null && !this.yAxis.c1()) {
                    this.rp(this.gg && this.d7);
                }
                break;
            case ScatterBase.$$p[7]:
                this.rp(false);
                this.qj();
                break;
            case ScatterBase.$$p[8]:
                this.rp(false);
                this.qj();
                break;
            case "TransitionProgress":
                this.y2.c(this.jq, this.y0, this.yy);
                this.aa1();
                try {
                    if (this.d5(this.cv)) {
                        return;
                    }
                    if ((Math.round(this.jq * 100000) / 100000) == 1) {
                        this.abo(this.yy, this.yv);
                    }
                    else {
                        this.abo(this.y2, this.yv);
                    }
                    if (this.db != null) {
                        this.db.qo(this);
                    }
                }
                finally {
                    this.abp();
                }
                break;
            case "TrendLineBrush":
                this.rd(b);
                break;
            case ScatterBase.$$p[0]:
                if (this.yw != null) {
                    this.yw.r = this;
                }
                this.rp(false);
                this.qj();
                break;
            case "TrendLineType":
                this.qj();
                break;
            case ScatterBase.$$p[4]:
                this.zj = this.zr();
                this.rp(false);
                break;
            case ScatterBase.$$p[3]:
                this.zi = this.zq();
                this.rp(false);
                break;
            case ScatterBase.$$p[5]:
                this.y4 = this.y5();
                break;
        }
    };
    ScatterBase.prototype.zr = function () {
        return this.zn;
    };
    ScatterBase.prototype.zq = function () {
        return this.zm;
    };
    ScatterBase.prototype.zl = function (a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterBase.prototype.zk = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterBase.prototype.abp = function () {
        this.acj = Rect.empty;
        this.ack = Rect.empty;
    };
    ScatterBase.prototype.aa1 = function () {
        var a = this.getViewInfo(this.acj, this.ack);
        this.acj = a.p0;
        this.ack = a.p1;
    };
    ScatterBase.prototype.zp = function (a, b) {
        if (b != 3) {
            return true;
        }
        if (a == null) {
            return true;
        }
        if (this.aar == a || this.aaz == a) {
            return true;
        }
        return false;
    };
    ScatterBase.prototype.pb = function (a, b, c, d) {
        var e = false;
        if (!this.zp(d, a)) {
            return;
        }
        this.yv.c2.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.zh = true;
        }
        else if (a == 1) {
            for (var f = b; f < b + c; f++) {
                this.zw += this.zf.item(f);
                this.zx += this.zg.item(f);
            }
            this.zy = this.zw / this.zf.count;
            this.zz = this.zx / this.zg.count;
        }
        if (e) {
            this.rp(true);
        }
    };
    ScatterBase.prototype.abg = function (a) {
        this.abh(a, null);
    };
    ScatterBase.prototype.abh = function (a, b) {
        var e_1, _a, e_2, _b;
        var c = this.zf != null ? this.zf.count : 0;
        var d = this.zg != null ? this.zg.count : 0;
        var e = Math.min(c, d);
        if (e <= this.z7) {
            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.dn;
            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.ay = function (a) {
        if (a != null && a == this.xAxis && this.zf != null) {
            return new AxisRange(this.zf.minimum, this.zf.maximum);
        }
        if (a != null && a == this.yAxis && this.zg != null) {
            return new AxisRange(this.zg.minimum, this.zg.maximum);
        }
        return null;
    };
    ScatterBase.prototype.kn = function (a) {
        var b = this.j3(a);
        if (this.dn != null && b >= 0 && b < this.dn.count) {
            return this.dn.item(b);
        }
        return null;
    };
    Object.defineProperty(ScatterBase.prototype, "y4", {
        get: function () {
            return this.y3;
        },
        set: function (a) {
            var b = this.y3;
            this.y3 = a;
            if (b != this.y3) {
                this.raisePropertyChanged("ActualItemSearchMode", enumGetBox(ScatterItemSearchMode_$type, b), enumGetBox(ScatterItemSearchMode_$type, this.y3));
            }
        },
        enumerable: false,
        configurable: true
    });
    ScatterBase.prototype.y5 = function () {
        if (this.y6 != 0) {
            return this.y6;
        }
        return this.zo ? 4 : 1;
    };
    ScatterBase.prototype.j3 = function (a) {
        var b = truncate(Math.round(this.ir(a)));
        return b;
    };
    ScatterBase.prototype.ir = function (a) {
        switch (this.y4) {
            case 1: return this.z3(a);
            case 3: return this.z4(a);
            case 2: return this.z1(a);
            case 4: return this.z2(a);
            case 5: return this.z0(a);
        }
        return -1;
    };
    ScatterBase.prototype.z2 = function (a) {
        return this.z5(a, false);
    };
    ScatterBase.prototype.z1 = function (a) {
        var b = this.v5(a);
        var c = b.x;
        var d = b.y;
        if (this.dn == null || this.xAxis == null || this.yAxis == null || this.zf == null || this.zg == null) {
            return -1;
        }
        if (this.dn.count > this.z6) {
            return -1;
        }
        this.aa4();
        var e = this.yk;
        var f = this.yl;
        if (e == null || f == null) {
            return -1;
        }
        var g = 1.7976931348623157E+308;
        var h = -1;
        for (var i = 0; i < this.zf.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.aa4 = function () {
        var _this = this;
        var a = this.cv.by;
        var b = this.cv.bx;
        var c = this.getEffectiveViewport();
        if (this.yu == null) {
            return;
        }
        var d = new ScalerParams(0, a, b, this.yu.d, c);
        var e = ((function () {
            var $ret = new ScalerParams(0, a, b, _this.yu.e, c);
            $ret.b = _this.iy();
            return $ret;
        })());
        if (this.yk == null || this.yl == null) {
            var f = arrayShallowClone(this.zf.asArray());
            var g = arrayShallowClone(this.zg.asArray());
            this.xAxis.hq(boxArray$1(f), 0, f.length, d);
            this.yAxis.hq(boxArray$1(g), 0, g.length, e);
            this.yk = f;
            this.yl = g;
        }
    };
    ScatterBase.prototype.get_zo = function () {
        return false;
    };
    Object.defineProperty(ScatterBase.prototype, "zo", {
        get: function () {
            return this.get_zo();
        },
        enumerable: false,
        configurable: true
    });
    ScatterBase.prototype.z5 = function (a, b) {
        if (!this.zo) {
            return -1;
        }
        var c = { $type: Point_$type, x: 0, y: 0 };
        var d = true;
        var e = this.yz();
        if (e == null) {
            return -1;
        }
        if (e.m == null) {
            return -1;
        }
        if (this.dn == null || this.dn.count > this.z6) {
            return -1;
        }
        this.aa4();
        var f = this.yk;
        var g = this.yl;
        if (f == null || g == null) {
            return -1;
        }
        var h = this.v5(a);
        var i = 1.7976931348623157E+308;
        var j = -1;
        for (var k = 0; k < this.yk.length; k++) {
            var l = { $type: Point_$type, x: this.yk[k], y: this.yl[k] };
            if (k > 0) {
                if (!b || e.j.containsKey(this.dn.item(k)) || e.j.containsKey(this.dn.item(k - 1))) {
                    var m = GeometryUtil.h(h, c, l);
                    if (m < i) {
                        i = m;
                        j = k;
                    }
                }
            }
            c = l;
        }
        if (j >= 0) {
            var n = { $type: Point_$type, x: this.yk[j], y: this.yl[j] };
            var o = { $type: Point_$type, x: this.yk[j - 1], y: this.yl[j - 1] };
            if (!b || (e.j.containsKey(this.dn.item(j)) && e.j.containsKey(this.dn.item(j - 1)))) {
                var p = GeometryUtil.m(h, o, n);
                return (j - 1) + p;
            }
            else if (e.j.containsKey(this.dn.item(j))) {
                return j;
            }
            else {
                return j - 1;
            }
        }
        return -1;
    };
    ScatterBase.prototype.z4 = function (a) {
        return this.z5(a, true);
    };
    ScatterBase.prototype.z0 = function (a) {
        var _this = this;
        var b = this.v5(a);
        var c = b.x;
        var d = b.y;
        if (this.yv.c3.e > this.z6) {
            return -1;
        }
        var e = -1;
        this.w4.ck(function (f) {
            var g = _this.yv.cu(f);
            var h = g.left;
            var i = g.top;
            var j = g.width;
            var k = g.height;
            if (_this.xb) {
                var l = h + j / 2;
                var m = i + k / 2;
                var n = (j / 2) * (j / 2);
                var o = (c - l) * (c - l) + (d - m) * (d - m);
                if (o < n) {
                    if (e == -1) {
                        e = f.ak;
                    }
                }
            }
            else {
                if (c > h && c < h + j && d > i && d < i + k) {
                    if (e == -1) {
                        e = f.ak;
                    }
                }
            }
        });
        return e;
    };
    ScatterBase.prototype.z3 = function (a) {
        var _this = this;
        var b = null;
        var c = 1.7976931348623157E+308;
        var d = this.v5(a);
        var e = d.x;
        var f = d.y;
        if (this.yv.c3.e > this.z6) {
            return -1;
        }
        this.yv.da(function (g) {
            if (g._visibility == 0) {
                var h = _this.yv.cu(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.wa = function (a, b, c) {
        var _this = this;
        if (this.xAxis == null || this.yAxis == null || this.zf == null || this.zg == null) {
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        var d = this.cv.by;
        var e = this.cv.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.iy();
            return $ret;
        })());
        if (b) {
            var i = this.ir(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.dn.count - 1) {
                k = this.dn.count - 1;
            }
            if (j > this.dn.count - 1) {
                j = this.dn.count - 1;
            }
            if (k == j) {
                var l = this.xAxis.el(this.zf.item(j), g);
                var m = this.yAxis.el(this.zg.item(j), h);
                return { $type: Point_$type, x: l, y: m };
            }
            var n = i - Math.floor(i);
            var o = this.xAxis.el(this.zf.item(j), g);
            var p = this.yAxis.el(this.zg.item(j), h);
            var q = this.xAxis.el(this.zf.item(k), g);
            var r = this.yAxis.el(this.zg.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.j3(a);
            if (u == -1) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            var v = this.xAxis.el(this.zf.item(u), g);
            var w = this.yAxis.el(this.zg.item(u), h);
            return { $type: Point_$type, x: v, y: w };
        }
    };
    ScatterBase.prototype.gd = function (a) {
        var _this = this;
        var b = this.db != null ? this.db.v4 : Rect.empty;
        b = b.copy();
        var c = this.db != null ? this.db.wj : Rect.empty;
        var d = new Rect(0, 0, 0, 1, 1);
        var e = this.wj(this.cv);
        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.iy();
            return $ret;
        })());
        var h = !b.isEmpty && !c.isEmpty && this.dn != null ? this.dn.indexOf(a) : -1;
        var i = this.xAxis != null && this.zf != null && h < this.zf.count ? this.xAxis.el(this.zf.item(h), f) : NaN;
        var j = this.yAxis != null && this.zg != null && h < this.zg.count ? this.yAxis.el(this.zg.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.c3 != null) {
            this.c3.au(this.db, b, true);
        }
        return h >= 0;
    };
    ScatterBase.prototype.so = function (a, b) {
        this.rp(false);
    };
    ScatterBase.prototype.sp = function (a, b) {
        this.rp(false);
    };
    ScatterBase.prototype.yz = function () {
        var a = this.yy;
        if (this.d3()) {
            if (this.dc.g) {
                this.dc.t();
            }
            a = this.y2;
        }
        return a;
    };
    ScatterBase.prototype.aa2 = 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.dn;
        var h;
        var i;
        var j = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.yu.d, f);
            $ret.c = _this.getEffectiveViewport1(a);
            return $ret;
        })());
        var k = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.yu.e, f);
            $ret.c = _this.getEffectiveViewport1(a);
            $ret.b = _this.iy();
            return $ret;
        })());
        var l = false;
        var m = 0;
        if (this.db != null) {
            if (this.db.f4()) {
                var n = this.db.m4(d, j);
                l = n.c;
                m = n.d;
            }
        }
        var _loop_1 = function (o) {
            h = this_1.zf.item(o);
            i = this_1.zg.item(o);
            var p = { $type: Point_$type, x: this_1.yu.a.el(h, j), y: this_1.yu.b.el(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.abd = function (a, b) {
        var _this = this;
        this.yk = null;
        this.yl = null;
        a.j.clear();
        a.n.clear();
        a.h.clear();
        a.l.clear();
        a.i.clear();
        a.k.clear();
        var c = Math.min(this.zf != null ? this.zf.count : 0, this.zg != null ? this.zg.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.iy();
            return $ret;
        })());
        h.c = this.getEffectiveViewport1(b);
        if (c < 1) {
            return;
        }
        this.yu = ((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.dn;
            return $ret;
        })());
        var i = b;
        if (c <= this.z7) {
            this.aa2(i, a, c, d, e);
        }
        if (this.xe()) {
            b.c0.l(a.j, this.z7, d, e, this.id);
        }
        var j = ((function () {
            var $ret = new Clipper(0, e, false);
            $ret.i = a.n;
            return $ret;
        })());
        var k = this.wh(b);
        var l = this.xAxis.eo(k.left, g);
        var m = this.xAxis.eo(k.right, g);
        b.c2.h(a.n, this.trendLineType, this.zf, this.zg, this.trendLinePeriod, function (n) { return _this.xAxis.el(n, g); }, function (n) { return _this.yAxis.el(n, h); }, ((function () {
            var $ret = new TrendResolutionParams();
            $ret.d = _this.id;
            $ret.i = e;
            $ret.h = f;
            $ret.j = d;
            return $ret;
        })()), j, l, m);
        this.abb(a, b);
    };
    ScatterBase.prototype.o5 = function (a, b) {
        _super.prototype.o5.call(this, a, b);
        var c = b;
        c.c9(a);
    };
    ScatterBase.prototype.get_fe = function () {
        return true;
    };
    ScatterBase.prototype.y9 = function (a, b, c) {
        return null;
    };
    ScatterBase.prototype.za = function (a, b, c) {
        if (this.dn == null) {
            return null;
        }
        var d = this.yz();
        var e = this.yv.b1(this.v5(b));
        var f = -1;
        if (e == null) {
            if (a != null) {
                f = this.dn.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.wt = function (a, b) {
        if (this.w6 != 1 && this.w6 != 13) {
            var c = this.w4.cv();
            var d = (c.width / 2) + (this.xh / 2);
            var e = (c.height / 2) + (this.xh / 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.y8 = function (a, b, c) {
        var d = new HighlightingInfo();
        d.i = this;
        d.g = 0;
        d.f = this.dn.count - 1;
        d.c = true;
        if (c != null && c.g == d.g && c.f == d.f) {
            return c;
        }
        return d;
    };
    ScatterBase.prototype.dg = function (a, b, c) {
        if (this.ed && this.fz(this.bx) && !c) {
            var d = this.y9(a, b, this.zb);
            this.zb = d;
            return d;
        }
        else {
            var e = this.y8(a, b, this.zb);
            this.zb = e;
            return e;
        }
    };
    ScatterBase.prototype.dh = function (a, b, c) {
        if (this.fz(this.bx) && !c) {
            var d = this.za(a, b, this.zc);
            this.zc = d;
            return d;
        }
        else {
            var e = this.y8(a, b, this.zc);
            e.d = true;
            this.zc = e;
            return e;
        }
    };
    ScatterBase.prototype.zt = function () {
        return (this.assigningScatterStyle != null && this.zj) || this.d2 || (this.bx != 1) || (this.cp != 1) || (this.co != 1);
    };
    ScatterBase.prototype.zs = function () {
        return (this.assigningScatterMarkerStyle != null && this.zi) || this.d2 || (this.bx != 1) || (this.cp != 1) || (this.co != 1);
    };
    ScatterBase.prototype.abo = function (a, b) {
        var _this = this;
        this.qv();
        var c = b.bx;
        this.yu = ((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.xe()) {
            b.c0.j(a.j, this.xg);
            if (this.zs()) {
                this.aa3(b, a);
            }
        }
        b.cr();
        var d = ((function () {
            var $ret = new Clipper(1, NaN, c.bottom, NaN, c.top, false);
            $ret.i = b.c2.g$j.an;
            return $ret;
        })());
        b.c2.g$h(a.n, d);
        this.abl(a, b);
    };
    ScatterBase.prototype.ak = function (a, b) {
        var c = new List$1(ChartSelection.$, 0);
        this.p2(a, c, b);
        return c.toArray();
    };
    ScatterBase.prototype.p2 = function (a, b, c) {
        this.aa5(a, b, c, 0, null);
    };
    ScatterBase.prototype.aa5 = function (a, b, c, d, e) {
        var _this = this;
        var f = this.wp(a);
        var g = this.dn.count;
        var h = this.yu.a;
        var i = this.yu.b;
        var j = this.wh(this.cv);
        var k = new ScalerParams(0, f, this.db.wj, h.ch, this.getEffectiveViewport());
        var l = new ScalerParams(0, f, this.db.wj, i.ch, this.getEffectiveViewport());
        if (d == 0) {
            var _loop_2 = function (m) {
                var n = h.el(this_2.zf.item(m), k);
                var o = i.el(this_2.zg.item(m), l);
                if (n < j.width && n > 0 && o < j.height && o > 0) {
                    if (c == 7 || c == 6) {
                        b.add(((function () {
                            var $ret = new ChartSelection();
                            $ret.series = _this;
                            return $ret;
                        })()));
                        return { value: void 0 };
                    }
                    else if (c == 2 || c == 1) {
                        b.add(((function () {
                            var $ret = new ChartSelection();
                            $ret.item = _this.dn.item(m);
                            return $ret;
                        })()));
                    }
                    else {
                        b.add(((function () {
                            var $ret = new ChartSelection();
                            $ret.item = _this.dn.item(m);
                            $ret.series = _this;
                            return $ret;
                        })()));
                    }
                }
            };
            var this_2 = this;
            for (var m = 0; m < g; m++) {
                var state_1 = _loop_2(m);
                if (typeof state_1 === "object")
                    return state_1.value;
            }
        }
        else {
            var _loop_3 = function (p) {
                var q = h.el(this_3.zf.item(p), k);
                var r = i.el(this_3.zg.item(p), l);
                var s = e.item(p) / f.height;
                var t = e.item(p) / f.width;
                var u = new Rect(0, q - t / 2, r - s / 2, t, s);
                if (j.intersectsWith(u)) {
                    if (c == 7 || c == 6) {
                        b.add(((function () {
                            var $ret = new ChartSelection();
                            $ret.series = _this;
                            return $ret;
                        })()));
                        return { value: void 0 };
                    }
                    else if (c == 2 || c == 1) {
                        b.add(((function () {
                            var $ret = new ChartSelection();
                            $ret.item = _this.dn.item(p);
                            return $ret;
                        })()));
                    }
                    else {
                        b.add(((function () {
                            var $ret = new ChartSelection();
                            $ret.item = _this.dn.item(p);
                            $ret.series = _this;
                            return $ret;
                        })()));
                    }
                }
            };
            var this_3 = this;
            for (var p = 0; p < g; p++) {
                var state_2 = _loop_3(p);
                if (typeof state_2 === "object")
                    return state_2.value;
            }
        }
    };
    ScatterBase.prototype.yn = function (a, b) {
        return this.yo(a, b);
    };
    ScatterBase.prototype.yo = function (a, b) {
        if (b < a || a < 0 || a > this.zf.count || b < 0 || b > this.zf.count) {
            return null;
        }
        var c = new Array((b - a) + 1);
        for (var d = a; d <= b; d++) {
            var e = d;
            c[d - a] = this.dn.item(d);
        }
        return c;
    };
    ScatterBase.prototype.aa3 = function (a, b) {
        var _this = this;
        a.b7 = true;
        this.y7.ay(this, this.zs(), runOn(this, this.yn));
        var c = this.y7.d;
        var d = c != null;
        var e = this.getEffectiveViewport1(a);
        var f = this.dn == null ? 0 : this.dn.count;
        this.yv.cj(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.aa8(h, f, a.q);
                }
                _this.y7.ac(g, i);
            }
        });
    };
    ScatterBase.prototype.aa9 = function (a, b, c) {
        var d = this.bx != 1;
        var e = this.cp != 1;
        var f = this.co != 1;
        this.y7.a0(this.y7.b, a, b, false);
        this.y7.ab(this.ib);
        var g = this.y7.ax;
        var h = null;
        var i = null;
        var j = null;
        var k = this.dn;
        if (d && this.db != null) {
            h = this.db.dl.getHighlightingInfo(this, k, g.z, g.y, false);
            g.c = h;
        }
        if (e && this.db != null) {
            h = this.db.dm.getHighlightingInfo(this, k, g.z, g.y, false);
            g.d = h;
        }
        if (f && this.db != null) {
            h = this.db.dk.getHighlightingInfo(this, k, g.z, g.y, false);
            g.b = h;
        }
        g.h = c;
        this.abj(g);
        this.y7.z(this, h, i, j, c, d, e, f, a < 0);
    };
    ScatterBase.prototype.aa8 = function (a, b, c) {
        var d = this.bx != 1;
        var e = this.cp != 1;
        var f = this.co != 1;
        this.y7.a0(this.y7.d, a, b, true);
        this.y7.aa(this.ib);
        var g = this.y7.aw;
        var h = null;
        var i = null;
        var j = null;
        var k = this.dn;
        var l = null;
        var m = null;
        var n = null;
        if (d && this.db != null) {
            h = this.db.dl.getHighlightingInfo(this, k, g.z, g.y, true);
            if (this.db.dl.isCrossContextHighlight(this)) {
                l = this.db.dl.getHighlightingInfo(this, k, g.z, g.y, true);
            }
            g.c = h;
        }
        if (e && this.db != null) {
            i = this.db.dm.getHighlightingInfo(this, k, g.z, g.y, true);
            if (i == null && this.bn != null) {
                i = this.db.dm.getHighlightingInfo(this.bn, this.bn.dn, g.z, g.y, true);
            }
            if (i == null && this.bk != null) {
                i = this.db.dm.getHighlightingInfo(this.bk, this.bk.dn, g.z, g.y, true);
            }
            if (this.db.dm.isCrossContextHighlight(this)) {
                m = this.db.dm.getHighlightingInfo(this, k, g.z, g.y, true);
            }
            g.d = i;
        }
        if (f && this.db != null) {
            j = this.db.dk.getHighlightingInfo(this, k, g.z, g.y, true);
            if (this.db.dk.isCrossContextHighlight(this)) {
                n = this.db.dk.getHighlightingInfo(this, k, g.z, g.y, true);
            }
            g.d = i;
        }
        g.h = c;
        this.abi(g);
        this.y7.y(this, h, i, j, c, d, e, f, g.v, this.db.dl.totalHighWaterMark, g.x, this.db.dm.totalHighWaterMark, g.t, this.db.dk.totalHighWaterMark);
    };
    ScatterBase.prototype.abj = function (a) {
        if (this.assigningScatterStyle != null && this.zj) {
            this.assigningScatterStyle(this, a);
        }
    };
    ScatterBase.prototype.abi = function (a) {
        if (this.assigningScatterMarkerStyle != null && this.zi) {
            this.assigningScatterMarkerStyle(this, a);
        }
    };
    ScatterBase.prototype.abb = function (a, b) {
        var e_3, _a;
        var c = new ErrorBarsHelper(this, b);
        if (this.yw == null) {
            return;
        }
        var d = this.yw.u;
        var e = this.yw.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.abe(k, c, d, h, i, true);
                            h = l.p3;
                            i = l.p4;
                            break;
                        case 0:
                            var m = this.abc(k, c, d, h, i, true);
                            h = m.p3;
                            i = m.p4;
                            break;
                        case 2:
                            var n = this.aba(k, c, d, j, h, i, true);
                            h = n.p4;
                            i = n.p5;
                            break;
                        case 3:
                            var o = this.abf(c, d, f, h, i, true);
                            f = o.p2;
                            h = o.p3;
                            i = o.p4;
                            break;
                        case 4:
                            var p = this.abc(k, c, d, h, i, true);
                            h = p.p3;
                            i = p.p4;
                            break;
                    }
                    ;
                    var q = new OwnedPoint();
                    q.c = c.l(d, this.yu.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.abe(k, c, e, h, i, false);
                            h = r.p3;
                            i = r.p4;
                            break;
                        case 0:
                            var s = this.abc(k, c, e, h, i, false);
                            h = s.p3;
                            i = s.p4;
                            break;
                        case 2:
                            var t = this.aba(k, c, e, j, h, i, false);
                            h = t.p4;
                            i = t.p5;
                            break;
                        case 3:
                            var u = this.abf(c, e, g, h, i, false);
                            g = u.p2;
                            h = u.p3;
                            i = u.p4;
                            break;
                        case 4:
                            var v = this.abc(k, c, e, h, i, false);
                            h = v.p3;
                            i = v.p4;
                            break;
                    }
                    ;
                    var w = new OwnedPoint();
                    w.c = c.m(e, this.yu.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.abe = function (a, b, c, d, e, f) {
        if (f) {
            var g = void 0;
            var h = void 0, i = void 0;
            i = this.yu.a;
            if (this.yw.s == 0) {
                g = a.c.x;
                h = this.yu.a;
            }
            else {
                g = a.c.y;
                h = this.yu.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.yu.b;
            if (this.yw.t == 0) {
                k = a.c.x;
                l = this.yu.a;
            }
            else {
                k = a.c.y;
                l = this.yu.b;
            }
            var n = b.f(k, c, l, m, d, e);
            d = n.p4;
            e = n.p5;
        }
        return {
            p3: d,
            p4: e
        };
    };
    ScatterBase.prototype.abc = function (a, b, c, d, e, f) {
        if (f) {
            var g = b.j(a.c.x, c, this.yu.a, d, e);
            d = g.p3;
            e = g.p4;
        }
        else {
            var h = b.j(a.c.y, c, this.yu.b, d, e);
            d = h.p3;
            e = h.p4;
        }
        return {
            p3: d,
            p4: e
        };
    };
    ScatterBase.prototype.aba = function (a, b, c, d, e, f, g) {
        var h = c.getItemColumn();
        var i = this.dn.indexOf(d);
        if (h != null && i < h.count) {
            var j = h.item(i);
            if (g) {
                var k = b.h(a.c.x, j, this.yu.a, e, f);
                e = k.p3;
                f = k.p4;
            }
            else {
                var l = b.h(a.c.y, j, this.yu.b, e, f);
                e = l.p3;
                f = l.p4;
            }
        }
        else {
            e = NaN;
            f = NaN;
        }
        return {
            p4: e,
            p5: f
        };
    };
    ScatterBase.prototype.abf = 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.yu.a, d, e);
            d = h.p3;
            e = h.p4;
        }
        else {
            var i = a.k(c, b, this.yu.b, d, e);
            d = i.p3;
            e = i.p4;
        }
        return {
            p2: c,
            p3: d,
            p4: e
        };
    };
    ScatterBase.prototype.abl = function (a, b) {
        if (!b.o() || this.yw == null) {
            b.db();
            return;
        }
        this.abm(a, b);
        this.abn(a, b);
    };
    ScatterBase.prototype.abm = function (a, b) {
        var e_4, _a;
        b.c7();
        var c = new ErrorBarsHelper(this, b);
        var d = new PathGeometry();
        var e = this.yw.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.yw.o == 1 || this.yw.o == 2) {
                            c.d(d, i, g, true);
                        }
                        if (this.yw.o == 1 || this.yw.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.dc(d);
    };
    ScatterBase.prototype.abn = function (a, b) {
        var e_5, _a;
        b.c8();
        var c = new ErrorBarsHelper(this, b);
        var d = new PathGeometry();
        var e = this.yw.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.yw.p == 1 || this.yw.p == 2) {
                            c.e(d, i, g, true);
                        }
                        if (this.yw.p == 1 || this.yw.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.he = function (a, b, c) {
        var d = true;
        if (!_super.prototype.he.call(this, a, b, c) || b.isEmpty || a.isEmpty || this.xAxis == null || this.yAxis == null || this.xAxis.bi == null || this.yAxis.bi == null || this.zf == null || this.zg == null || this.zf.count == 0 || this.zg.count == 0 || this.dn == null || this.dn.count != this.zf.count || this.dn.count != this.zg.count || this.xAxis.bi == null || this.yAxis.bi == null || this.xAxis.l4 == this.xAxis.l3 || this.yAxis.l4 == this.yAxis.l3) {
            d = false;
        }
        return d;
    };
    ScatterBase.prototype.getViewInfo = function (a, b) {
        if (!this.acj.isEmpty && !this.ack.isEmpty) {
            a = this.acj;
            b = this.ack;
            return {
                p0: a,
                p1: b
            };
        }
        a = this.cv.bx;
        b = this.cv.by;
        return {
            p0: a,
            p1: b
        };
    };
    ScatterBase.prototype.rq = function (a) {
        _super.prototype.rq.call(this, a);
        this.aa1();
        try {
            if (this.d5(this.cv)) {
                return;
            }
            if (this.dn != null && this.dn.count > this.z7) {
                a = false;
            }
            if (this.gf(a) && !this.gr) {
                var b = this.y0;
                if (this.d3()) {
                    if (this.dc.g) {
                        this.dc.t();
                    }
                    this.y0 = this.y2;
                    this.y2 = b;
                }
                else {
                    this.y0 = this.yy;
                    this.yy = b;
                }
                this.abd(this.yy, this.yv);
                this.r5();
            }
            else {
                if (!this.gr) {
                    this.abd(this.yy, this.yv);
                }
                this.abo(this.yy, this.yv);
            }
        }
        finally {
            this.abp();
        }
    };
    ScatterBase.prototype.sf = function () {
        _super.prototype.sf.call(this);
        if (this.index < 0) {
            return;
        }
        this.yv.df();
    };
    ScatterBase.prototype.rr = function (a, b) {
        _super.prototype.rr.call(this, a, b);
        if (!this.g0) {
            this.cv.a4(b);
            return;
        }
        this.cv.a4(b);
        if (this.d5(this.cu)) {
            return;
        }
        var c = typeCast(ScatterBaseView.$, this.cu);
        if (!this.gs) {
            this.y1 = new ScatterFrame();
            this.abd(this.y1, c);
        }
        this.gs = false;
        this.abo(this.y1, c);
        this.g0 = false;
    };
    ScatterBase.prototype.ro = function (a, b, c, d, e) {
        _super.prototype.ro.call(this, a, b, c, d, e);
        var f = this.ba.a$j.item(d);
        var g = f;
        f.a3(c);
        if (this.d5(g)) {
            return;
        }
        if (this.yx == null) {
            this.yx = new ScatterFrame();
        }
        this.abd(this.yx, g);
        this.abo(this.yx, g);
    };
    ScatterBase.prototype.abk = 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.ym = function (a, b, c, d, e) {
        var _this = this;
        if (c == null || c.length != this.yu.c.count) {
            c = new Array(this.yu.c.count);
            for (var f = 0; f < this.yu.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.iy();
            return $ret;
        })());
        var j = this.wh(a);
        var k = this.yu.a.eo(j.left, h);
        var l = this.yu.a.eo(j.right, h);
        var m = this.yu.b.eo(j.bottom, i);
        var n = this.yu.b.eo(j.top, i);
        if (this.yu.d) {
            var o = k;
            k = l;
            l = o;
        }
        if (this.yu.e) {
            var p = m;
            m = n;
            n = p;
        }
        var q = this.yu;
        var r = q.a;
        var s = q.b;
        var t;
        var u;
        var v = this.zf;
        var w = this.zg;
        var x = false;
        var y = 0;
        var z = 0;
        if (this.db != null) {
            if (this.db.f4()) {
                var aa = this.db.m4(d, h);
                x = aa.c;
                y = aa.d;
                z = r.eo(0 + y, h);
                var ab = r.eo(0, h);
                z -= ab;
            }
        }
        for (var ac = 0; ac < this.yu.c.count; ac++) {
            t = v.item(ac);
            u = w.item(ac);
            var ad = 1E-10;
            if (x) {
                if (t >= k - ad && t <= l + ad && u >= m - ad && u <= n + ad) {
                    c[ac].x = r.el(t, h);
                    c[ac].y = s.el(u, i);
                }
                else {
                    if ((t + z) >= k && (t + z) <= l && u >= m && u <= n) {
                        c[ac].x = r.el(t, h) + y;
                        c[ac].y = s.el(u, i);
                    }
                    else {
                        c[ac].x = NaN;
                        c[ac].y = NaN;
                    }
                }
            }
            else {
                if (t >= k - ad && t <= l + ad && u >= m - ad && u <= n + ad) {
                    c[ac].x = r.el(t, h);
                    c[ac].y = s.el(u, i);
                }
                else {
                    c[ac].x = NaN;
                    c[ac].y = NaN;
                }
            }
        }
        return c;
    };
    ScatterBase.prototype.zv = 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.dn;
        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.px = function (a) {
        _super.prototype.px.call(this, a);
        this.bc.exportTrendlineData(this, a, this.yv.c2.g$j);
    };
    ScatterBase.prototype.iy = function () {
        return Series.iz(this.zg, null);
    };
    ScatterBase.prototype.getDataLegendSeriesContextAt = function (a, b) {
        var c = { $type: Point_$type, x: a, y: b };
        var d = this.kn(c);
        var e = d == null ? NaN : this.ix(d, "XMemberPath");
        var f = d == null ? NaN : this.ix(d, "YMemberPath");
        var g = new DataLegendSeriesValueInfo();
        g.l = e;
        g.a = 13;
        g.q = "X";
        g.r = this.aar != null ? this.aar : "X";
        g.s = this.aan != null ? this.aan : "X:";
        g.t = this.aap != null ? this.aap : "";
        var h = new DataLegendSeriesValueInfo();
        h.l = f;
        h.a = 14;
        h.q = "Y";
        h.r = this.aaz != null ? this.aaz : "Y";
        h.s = this.aav != null ? this.aav : "Y:";
        h.t = this.aax != null ? this.aax : "";
        var i = new DataLegendSeriesContext();
        i.e = ((function () {
            var $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
            $ret.add(g);
            $ret.add(h);
            return $ret;
        })());
        i.h = this.mc();
        return i;
    };
    ScatterBase.prototype.abq = function () {
        if (this.zh) {
            this.zw = 0;
            this.zx = 0;
            for (var a = 0; a < this.zf.count; a++) {
                this.zw += this.zf.item(a);
                this.zx += this.zg.item(a);
            }
            this.zy = this.zw / this.zf.count;
            this.zz = this.zx / this.zg.count;
            this.zh = false;
        }
    };
    ScatterBase.prototype.i8 = function (a, b) {
        if (b == null || !b.cj) {
            return NaN;
        }
        if (b != this.xAxis && b != this.yAxis) {
            return NaN;
        }
        var c = this.aq(a);
        if (b.cp) {
            return c[1];
        }
        else {
            return c[0];
        }
    };
    ScatterBase.prototype.aq = function (a) {
        var b = NaN;
        var c = NaN;
        switch (a) {
            case 5:
            case 2:
                b = this.zf.maximum;
                c = this.zg.maximum;
                break;
            case 4:
            case 1:
                b = this.zf.minimum;
                c = this.zg.minimum;
                break;
            case 6:
            case 3:
                if (this.zh) {
                    this.abq();
                }
                b = this.zy;
                c = this.zz;
                break;
        }
        return [b, c];
    };
    ScatterBase.prototype.we = function (a) {
        var b = this.getEffectiveViewport1(this.cv);
        var c = new ScalerParams(0, this.cv.by, this.cv.bx, this.xAxis.ch, b);
        c.c = b;
        var d = isNaN_(a[0]) ? NaN : this.xAxis.el(a[0], c);
        c = new ScalerParams(0, this.cv.by, this.cv.bx, this.yAxis.ch, b);
        c.b = this.iy();
        c.c = b;
        var e = isNaN_(a[1]) ? NaN : this.yAxis.el(a[1], c);
        return { $type: Point_$type, x: d, y: e };
    };
    ScatterBase.prototype.wd = function (a) {
        var b = this.aq(a);
        return this.we(b);
    };
    ScatterBase.$t = markType(ScatterBase, 'ScatterBase', MarkerSeries.$, [ISupportsErrorBars_$type, ITrendLineSeries_$type]);
    ScatterBase.abr = 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:yw:abs', [ScatterErrorBarSettings.$, null], 'HighlightedXMemberPath:aab:abt', [2, null], 'HighlightedYMemberPath:aad:abu', [2, null], 'IsCustomScatterMarkerStyleAllowed:zm:abv', [0, false], 'IsCustomScatterStyleAllowed:zn:abw', [0, false], 'ItemSearchMode:y6:abx', [ScatterItemSearchMode_$type, enumGetBox(ScatterItemSearchMode_$type, 0)], 'ItemSearchThreshold:z6:aby', [1, 10000], 'MarkerCollisionAvoidance:yr:abz', [CollisionAvoidanceType_$type, enumGetBox(CollisionAvoidanceType_$type, 0)], 'MaximumMarkers:z7:ab0', [1, 400], 'XAxis::ab8', [NumericXAxis.$, null], 'XMemberAsLegendLabel:aan:ab9', [2, null], 'XMemberAsLegendUnit:aap:aca', [2, null], 'XMemberPath:aar:acb', [2, null], 'YAxis::acc', [NumericYAxis.$, null], 'YMemberAsLegendLabel:aav:acd', [2, null], 'YMemberAsLegendUnit:aax:ace', [2, null], 'YMemberPath:aaz:acf', [2, null], 'TrendLineType::ab6', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::ab5', [1, 1.5], 'TrendLinePeriod::ab4', [1, 7], 'TrendLineBrush::ab1', [Brush.$, null], 'TrendLineZIndex:z8:ab7', [1, 1001], 'TrendLineDashArray:ach:ab2', [DoubleCollection.$], 'TrendLineDashCap:aci:ab3', [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.e = false;
            a.z = 0;
            a.y = c - 1;
        }
        else {
            if (d) {
                a.z = b;
                a.y = b;
            }
            else {
                a.e = false;
                a.z = b;
                a.y = 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.c0 = null;
        _this.cy = null;
        _this.c1 = null;
        _this.c6 = null;
        _this.dh = null;
        _this.di = null;
        _this.c2 = null;
        _this.dg = null;
        _this.c3 = null;
        _this.c1 = a;
        _this.c3 = new HashPool$2(Base.$, Marker.$);
        _this.cm(_this.c3);
        _this.c2 = new ScatterTrendLineManager();
        return _this;
    }
    ScatterBaseView.prototype.au = function () {
        _super.prototype.au.call(this);
        this.c0 = this.cz();
        this.dh = new Path();
        this.di = new Path();
        if (!this.q) {
            this.c1.z7 = 2000;
        }
    };
    ScatterBaseView.prototype.dj = function (a) {
        if (this.dg == null) {
            this.dg = new DataTemplateMeasureInfo();
            this.dg.context = this.k.h();
        }
        this.dg.width = a.width;
        this.dg.height = a.height;
        this.dg.data = a.content;
        var b = a.ah;
        if (b.measure != null) {
            b.measure(this.dg);
        }
        return new Size(1, this.dg.width, this.dg.height);
    };
    ScatterBaseView.prototype.cz = function () {
        var _this = this;
        var a = new NumericMarkerManager(1, function (b) { return _this.c3.item(b); }, function (b) { return _this.c1.yu.c.item(b); }, runOn(this, this.de), runOn(this, this.cw), runOn(this, this.c4), function () { return _this.c1.yr; });
        a.q = runOn(this, this.dj);
        return a;
    };
    ScatterBaseView.prototype.de = function (a) {
        this.c1.abk(a, this.c3);
    };
    ScatterBaseView.prototype.c5 = function () {
        return this.b8;
    };
    ScatterBaseView.prototype.cx = function () {
        return this.cy;
    };
    ScatterBaseView.prototype.cw = function () {
        this.cy = this.c1.ym(this, this.c3, this.cy, this.by, this.bx);
        return this.cy;
    };
    ScatterBaseView.prototype.c4 = function () {
        this.c6 = this.c1.zv(this.c3, this.c6);
        return this.c6;
    };
    ScatterBaseView.prototype.c7 = function () {
    };
    ScatterBaseView.prototype.dc = function (a) {
    };
    ScatterBaseView.prototype.c8 = function () {
    };
    ScatterBaseView.prototype.dd = function (a) {
    };
    ScatterBaseView.prototype.df = function () {
        if (this.c1.trendLineBrush != null) {
            this.c1.acg = this.c1.trendLineBrush;
        }
        else {
            this.c1.acg = this.c1.u7;
        }
    };
    ScatterBaseView.prototype.cj = function (a) {
        this.c3.f(a);
    };
    ScatterBaseView.prototype.da = function (a) {
        this.c3.g(a);
    };
    ScatterBaseView.prototype.db = function () {
    };
    ScatterBaseView.prototype.a7 = function (a, b) {
        _super.prototype.a7.call(this, a, b);
        if (a.d) {
            if (this.c1.trendLineType != 0 && !b) {
                var c = this.c2.g$j;
                c.ad = this.c1.trendLineThickness;
                c._stroke = this.c1.acg;
                c.ai = this.c1.ach;
                c.aj = this.c1.aci;
                a.v(c);
            }
        }
    };
    ScatterBaseView.prototype.c9 = function (a) {
        if (a) {
            this.db();
            this.c3.clear();
        }
        this.c2.g$d();
        this.as();
    };
    ScatterBaseView.prototype.getDefaultTooltipTemplate = function () {
        var a = "<div class='ui-chart-default-tooltip-content'><span";
        var b = this.e.ba.a$u(this.e);
        if (!stringIsNullOrEmpty(b)) {
            a += " style='color:" + b + "'";
        }
        a += ">" + this.c1.title + "</span><br/><span>" + "x: </span><span class='ui-priority-primary'>${item." + this.c1.aar + "}</span><br/><span>" + "y: </span><span class='ui-priority-primary'>${item." + this.c1.aaz + "}</span></div>";
        return a;
    };
    ScatterBaseView.$t = markType(ScatterBaseView, 'ScatterBaseView', MarkerSeriesView.$);
    return ScatterBaseView;
}(MarkerSeriesView));
export { ScatterBaseView };
