/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import * as tslib_1 from "tslib";
import { MarkerSeries } from "./MarkerSeries";
import { ISupportsErrorBars_$type } from "./ISupportsErrorBars";
import { ITrendLineSeries_$type } from "./ITrendLineSeries";
import { ScatterAxisInfoCache } from "./ScatterAxisInfoCache";
import { NumericXAxis } from "./NumericXAxis";
import { DependencyProperty } from "igniteui-react-core/ES5/DependencyProperty";
import { NumericYAxis } from "./NumericYAxis";
import { Series } from "./Series";
import { TrendLineType_$type } from "igniteui-react-core/ES5/TrendLineType";
import { Brush } from "igniteui-react-core/ES5/Brush";
import { PenLineCap_$type } from "igniteui-react-core/ES5/PenLineCap";
import { DoubleCollection } from "igniteui-react-core/ES5/DoubleCollection";
import { CollisionAvoidanceType_$type } from "./CollisionAvoidanceType";
import { ScatterErrorBarSettings } from "./ScatterErrorBarSettings";
import { ScatterFrame } from "./ScatterFrame";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { ScalerParams } from "./ScalerParams";
import { Rect } from "igniteui-react-core/ES5/Rect";
import { Base, Type, enumGetBox, Number_$type, typeCast, fromEnum, Point_$type, markType, PointUtil, runOn } from "igniteui-react-core/ES5/type";
import { Marker } from "./Marker";
import { MarkerSeriesView } from "./MarkerSeriesView";
import { IFastItemsSource_$type } from "igniteui-react-core/ES5/IFastItemsSource";
import { Clipper } from "igniteui-react-core/ES5/Clipper";
import { OwnedPoint } from "./OwnedPoint";
import { Dictionary$2 } from "igniteui-react-core/ES5/Dictionary$2";
import { AxisRange } from "./AxisRange";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { ScatterTrendLineManager } from "./ScatterTrendLineManager";
import { ErrorBarsHelper } from "./ErrorBarsHelper";
import { PathGeometry } from "igniteui-react-core/ES5/PathGeometry";
import { HashPool$2 } from "igniteui-react-core/ES5/HashPool$2";
import { PropertyMetadata } from "igniteui-react-core/ES5/PropertyMetadata";
import { isNaN_, isInfinity } from "igniteui-react-core/ES5/number";
import { Path } from "igniteui-react-core/ES5/Path";
import { DataTemplateMeasureInfo } from "igniteui-react-core/ES5/DataTemplateMeasureInfo";
import { Size } from "igniteui-react-core/ES5/Size";
import { NumericMarkerManager } from "./NumericMarkerManager";
import { stringIsNullOrEmpty } from "igniteui-react-core/ES5/string";
/**
 * @hidden
 */
var ScatterBase = /** @class */ (function (_super) {
    tslib_1.__extends(ScatterBase, _super);
    function ScatterBase() {
        var _this = _super.call(this) || this;
        _this.mx = null;
        _this.m5 = null;
        _this.m7 = null;
        _this.oo = null;
        _this.op = null;
        _this.m2 = null;
        _this.m4 = null;
        _this.m1 = null;
        _this.m3 = null;
        _this.m0 = null;
        _this.m3 = new ScatterFrame();
        _this.op = Rect.empty;
        _this.oo = Rect.empty;
        return _this;
    }
    ScatterBase.prototype.bf = function () {
        return new ScatterBaseView(this);
    };
    ScatterBase.prototype.hn = function () {
        _super.prototype.hn.call(this);
        this.xAxis = null;
        this.yAxis = null;
    };
    ScatterBase.prototype.im = function (a) {
        _super.prototype.im.call(this, a);
        this.my = a;
    };
    ScatterBase.prototype.get_c4 = function () {
        return true;
    };
    ScatterBase.prototype.ag = function () {
        return [this.xAxis, this.yAxis];
    };
    ScatterBase.prototype.ch = function (a, b, c) {
        var _this = this;
        if (!this.hasMarkers) {
            return false;
        }
        var d = this.xAxis;
        var e = new ScalerParams(1, this.bs.mq, this.lr, d.b8);
        e.c = this.getEffectiveViewport1(this.bi);
        var f = this.yAxis;
        var g = new ScalerParams(1, this.bs.mq, this.lr, f.b8);
        g.c = this.getEffectiveViewport1(this.bi);
        a.clear();
        this.lt.cc(function (h) {
            if (h._visibility == 0) {
                var i = new SeriesPointOfInterest();
                var j = h.n;
                var k = h.o;
                if (j < _this.lr.left || j > _this.lr.right || k < _this.lr.top || k > _this.lr.bottom) {
                    return;
                }
                i.b = d.dw(j, e);
                i.c = f.dw(k, g);
                i.a = h.content;
                a.add(i);
            }
        });
        return true;
    };
    ScatterBase.prototype.bd = function () {
        if (this.be == 0) {
            if (this.nd <= 2000) {
                return 1;
            }
            else {
                return _super.prototype.bd.call(this);
            }
        }
        else {
            return _super.prototype.bd.call(this);
        }
    };
    ScatterBase.prototype.lp = function (a) {
        if (!this.hasMarkers || !this.lw()) {
            return Rect.empty;
        }
        var b = this.lt.bv(this.k9(a));
        if (b != null) {
            return this.lt.cm(b);
        }
        return Rect.empty;
    };
    ScatterBase.prototype.dg = function (a, b) {
        if (this.lx(a, b)) {
            return true;
        }
        return false;
    };
    Object.defineProperty(ScatterBase.prototype, "m6", {
        get: function () {
            return this.m5;
        },
        set: function (a) {
            if (this.m5 != a) {
                var b = this.m6;
                this.m5 = a;
                this.raisePropertyChanged("XColumn", b, this.m6);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScatterBase.prototype, "m8", {
        get: function () {
            return this.m7;
        },
        set: function (a) {
            if (this.m7 != a) {
                var b = this.m8;
                this.m7 = a;
                this.raisePropertyChanged("YColumn", b, this.m8);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScatterBase.prototype, "ol", {
        get: function () {
            return this.c(ScatterBase.n6);
        },
        set: function (a) {
            this.h(ScatterBase.n6, a);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScatterBase.prototype, "GetErrorBarsXAxis", {
        get: function () {
            return this.xAxis;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScatterBase.prototype, "GetErrorBarsYAxis", {
        get: function () {
            return this.yAxis;
        },
        enumerable: true,
        configurable: true
    });
    ScatterBase.prototype.h4 = function () {
        _super.prototype.h4.call(this);
        if (this.xAxis != null) {
            this.xAxis.g0(false);
        }
        if (this.yAxis != null) {
            this.yAxis.g0(false);
        }
    };
    ScatterBase.prototype.is = function (a, b, c, d) {
        _super.prototype.is.call(this, a, b, c, d);
        if (this.my.ct.g$b(a, b, c, d)) {
            this.i6(false);
            this.ic();
        }
        switch (b) {
            case "FastItemsSource":
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.m6);
                    c.deregisterColumn(this.m8);
                    this.m6 = null;
                    this.m8 = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.m6 = this.bw(this.nk);
                    this.m8 = this.bw(this.no);
                }
                if ((this.yAxis != null && !this.yAxis.ck()) || (this.xAxis != null && !this.xAxis.ck())) {
                    this.i6(false);
                }
                break;
            case ScatterBase.$$p[3]:
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ch(this);
                }
                if ((this.xAxis != null && !this.xAxis.ck()) || (d == null && c != null)) {
                    this.i6(false);
                }
                this.ic();
                break;
            case ScatterBase.$$p[5]:
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ch(this);
                }
                if ((this.yAxis != null && !this.yAxis.ck()) || (d == null && c != null)) {
                    this.i6(false);
                }
                this.ic();
                break;
            case ScatterBase.$$p[4]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.m6);
                    this.m6 = this.bw(this.nk);
                }
                break;
            case "XColumn":
                this.my.ct.g$i();
                if (this.xAxis != null && !this.xAxis.ck()) {
                    this.i6(false);
                }
                break;
            case ScatterBase.$$p[6]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.m8);
                    this.m8 = this.bw(this.no);
                }
                break;
            case "YColumn":
                this.my.ct.g$i();
                if (this.yAxis != null && !this.yAxis.ck()) {
                    this.i6(false);
                }
                break;
            case ScatterBase.$$p[1]:
                this.i6(false);
                this.ic();
                break;
            case ScatterBase.$$p[2]:
                this.i6(false);
                this.ic();
                break;
            case "TransitionProgress":
                this.m4.c(this.ew, this.m2, this.m1);
                this.nq();
                try {
                    if (this.cc(this.bi)) {
                        return;
                    }
                    if ((Math.round(this.ew * 100000) / 100000) == 1) {
                        this.n4(this.m1, this.my);
                    }
                    else {
                        this.n4(this.m4, this.my);
                    }
                    if (this.bs != null) {
                        this.bs.jj(this);
                    }
                }
                finally {
                    this.n5();
                }
                break;
            case "TrendLineBrush":
                this.jh();
                break;
            case ScatterBase.$$p[0]:
                if (this.mz != null) {
                    this.mz.r = this;
                }
                this.i6(false);
                this.ic();
                break;
            case "TrendLineType":
                this.ic();
                break;
        }
    };
    ScatterBase.prototype.na = function (a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterBase.prototype.m9 = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterBase.prototype.n5 = function () {
        this.oo = Rect.empty;
        this.op = Rect.empty;
    };
    ScatterBase.prototype.nq = function () {
        var a = this.getViewInfo(this.oo, this.op);
        this.oo = a.p0;
        this.op = a.p1;
    };
    ScatterBase.prototype.nb = function (a, b) {
        if (b != 3) {
            return true;
        }
        if (a == null) {
            return true;
        }
        if (this.nk == a || this.no == a) {
            return true;
        }
        return false;
    };
    ScatterBase.prototype.hs = function (a, b, c, d) {
        var e = false;
        if (!this.nb(d, a)) {
            return;
        }
        this.my.ct.g$e(a, b, c, d);
        if (this.xAxis != null && !this.xAxis.ck()) {
            e = true;
        }
        if (this.yAxis != null && !this.yAxis.ck()) {
            e = true;
        }
        if (e) {
            this.i6(true);
        }
    };
    ScatterBase.prototype.ny = function (a) {
        this.nz(a, null);
    };
    ScatterBase.prototype.nz = function (a, b) {
        var e_1, _a, e_2, _b;
        var c = this.m6 != null ? this.m6.count : 0;
        var d = this.m8 != null ? this.m8.count : 0;
        var e = Math.min(c, d);
        if (e <= this.nd) {
            a.m.clear();
            var f = new List$1(OwnedPoint.$, 0);
            try {
                for (var _c = tslib_1.__values(fromEnum(a.u.values)), _d = _c.next(); !_d.done; _d = _c.next()) {
                    var g = _d.value;
                    f.add(g);
                }
            }
            catch (e_1_1) { e_1 = { error: e_1_1 }; }
            finally {
                try {
                    if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
                }
                finally { if (e_1) throw e_1.error; }
            }
            var h_1 = this.bz;
            f.aa(function (i, j) {
                var k = h_1.indexOf(i.a);
                var l = h_1.indexOf(j.a);
                if (k < l) {
                    return -1;
                }
                if (k > l) {
                    return 1;
                }
                return 0;
            });
            if (b != null) {
                b.i = a.m;
            }
            try {
                for (var _e = tslib_1.__values(fromEnum(f)), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var i = _f.value;
                    if (h_1.indexOf(i.a) >= 0) {
                        if (b != null) {
                            b.j(i.c);
                        }
                        else {
                            a.m.add({ $type: Point_$type, x: i.c.x, y: i.c.y });
                        }
                    }
                }
            }
            catch (e_2_1) { e_2 = { error: e_2_1 }; }
            finally {
                try {
                    if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
                }
                finally { if (e_2) throw e_2.error; }
            }
        }
    };
    ScatterBase.prototype.an = function (a) {
        if (a != null && a == this.xAxis && this.m6 != null) {
            return new AxisRange(this.m6.minimum, this.m6.maximum);
        }
        if (a != null && a == this.yAxis && this.m8 != null) {
            return new AxisRange(this.m8.minimum, this.m8.maximum);
        }
        return null;
    };
    ScatterBase.prototype.fm = function (a) {
        return null;
    };
    ScatterBase.prototype.e5 = function (a) {
        return -1;
    };
    ScatterBase.prototype.c8 = function (a) {
        var _this = this;
        var b = this.bs != null ? this.bs.mq : Rect.empty;
        b = b.copy();
        var c = this.bs != null ? this.bs.m3 : Rect.empty;
        var d = new Rect(0, 0, 0, 1, 1);
        var e = this.ll(this.bi);
        var f = new ScalerParams(0, d, d, this.xAxis.b8, e);
        var g = ((function () {
            var $ret = new ScalerParams(0, d, d, _this.yAxis.b8, e);
            $ret.b = _this.ee();
            return $ret;
        })());
        var h = !b.isEmpty && !c.isEmpty && this.bz != null ? this.bz.indexOf(a) : -1;
        var i = this.xAxis != null && this.m6 != null && h < this.m6.count ? this.xAxis.dt(this.m6.item(h), f) : NaN;
        var j = this.yAxis != null && this.m8 != null && h < this.m8.count ? this.yAxis.dt(this.m8.item(h), g) : NaN;
        if (!isNaN_(i)) {
            if (i < b.left + 0.1 * b.width) {
                i = i + 0.4 * b.width;
                b.x = i - 0.5 * b.width;
            }
            if (i > b.right - 0.1 * b.width) {
                i = i - 0.4 * b.width;
                b.x = i - 0.5 * b.width;
            }
        }
        if (!isNaN_(j)) {
            if (j < b.top + 0.1 * b.height) {
                j = j + 0.4 * b.height;
                b.y = j - 0.5 * b.height;
            }
            if (j > b.bottom - 0.1 * b.height) {
                j = j - 0.4 * b.height;
                b.y = j - 0.5 * b.height;
            }
        }
        if (this.bn != null) {
            this.bn.ap(this.bs, b, true);
        }
        return h >= 0;
    };
    ScatterBase.prototype.jl = function (a, b) {
        this.i6(false);
    };
    ScatterBase.prototype.jm = function (a, b) {
        this.i6(false);
    };
    ScatterBase.prototype.nr = function (a, b, c, d, e) {
        var _this = this;
        b.g = new Dictionary$2(Base.$, OwnedPoint.$, 1, c);
        var f = this.getEffectiveViewport1(a);
        var g = this.bz;
        var h;
        var i;
        var j = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.mx.d, f);
            $ret.c = _this.getEffectiveViewport1(a);
            return $ret;
        })());
        var k = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.mx.e, f);
            $ret.c = _this.getEffectiveViewport1(a);
            $ret.b = _this.ee();
            return $ret;
        })());
        var _loop_1 = function (l) {
            h = this_1.m6.item(l);
            i = this_1.m8.item(l);
            var m = { $type: Point_$type, x: this_1.mx.a.dt(h, j), y: this_1.mx.b.dt(i, k) };
            if (!isInfinity(m.x) && !isInfinity(m.y)) {
                var n_1 = g.item(l);
                if (!b.g.containsKey(n_1)) {
                    var o_1 = { $type: Point_$type, x: h, y: i };
                    var p_1 = { $type: Point_$type, x: m.x, y: m.y };
                    b.g.addItem(n_1, ((function () {
                        var $ret = new OwnedPoint();
                        $ret.a = n_1;
                        $ret.b = o_1;
                        $ret.c = p_1;
                        return $ret;
                    })()));
                }
            }
        };
        var this_1 = this;
        for (var l = 0; l < c; l++) {
            _loop_1(l);
        }
    };
    ScatterBase.prototype.nv = function (a, b) {
        var _this = this;
        a.j.clear();
        a.n.clear();
        a.h.clear();
        a.l.clear();
        a.i.clear();
        a.k.clear();
        var c = Math.min(this.m6 != null ? this.m6.count : 0, this.m8 != null ? this.m8.count : 0);
        var d = b.bs;
        var e = b.br;
        var f = this.getEffectiveViewport1(b);
        var g = new ScalerParams(0, d, e, this.xAxis.b8, f);
        g.c = this.getEffectiveViewport1(b);
        var h = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.yAxis.b8, f);
            $ret.b = _this.ee();
            return $ret;
        })());
        ;
        h.c = this.getEffectiveViewport1(b);
        if (c < 1) {
            return;
        }
        this.mx = ((function () {
            var $ret = new ScatterAxisInfoCache();
            $ret.a = _this.xAxis;
            $ret.b = _this.yAxis;
            $ret.d = _this.xAxis.b8;
            $ret.e = _this.yAxis.b8;
            $ret.c = _this.bz;
            return $ret;
        })());
        var i = b;
        if (c <= this.nd) {
            this.nr(i, a, c, d, e);
        }
        if (this.lw()) {
            b.cr.l(a.j, this.nd, d, e, this.er);
        }
        var j = ((function () {
            var $ret = new Clipper(0, e, false);
            $ret.i = a.n;
            return $ret;
        })());
        var k = this.lj(b);
        var l = this.xAxis.dw(k.left, g);
        var m = this.xAxis.dw(k.right, g);
        b.ct.p(a.n, this.trendLineType, this.m6, this.m8, this.trendLinePeriod, function (n) { return _this.xAxis.dt(n, g); }, function (n) { return _this.yAxis.dt(n, h); }, ((function () {
            var $ret = new TrendResolutionParams();
            $ret.b = _this.er;
            $ret.f = e;
            $ret.g = d;
            return $ret;
        })()), j, l, m);
        this.nt(a, b);
    };
    ScatterBase.prototype.hp = function (a, b) {
        _super.prototype.hp.call(this, a, b);
        var c = b;
        c.c0(a);
    };
    ScatterBase.prototype.n4 = function (a, b) {
        var _this = this;
        var c = b.br;
        this.mx = ((function () {
            var $ret = new ScatterAxisInfoCache();
            $ret.a = _this.xAxis;
            $ret.b = _this.yAxis;
            $ret.d = _this.xAxis.b8;
            $ret.e = _this.yAxis.b8;
            return $ret;
        })());
        if (this.lw()) {
            b.cr.j(a.j, this.ly);
        }
        b.cj();
        var d = ((function () {
            var $ret = new Clipper(1, NaN, c.bottom, NaN, c.top, false);
            $ret.i = b.ct.g$j.aj;
            return $ret;
        })());
        b.ct.g$h(a.n, d);
        this.n1(a, b);
    };
    ScatterBase.prototype.nt = function (a, b) {
        var e_3, _a;
        var c = new ErrorBarsHelper(this, b);
        if (this.mz == null) {
            return;
        }
        var d = this.mz.u;
        var e = this.mz.v;
        var f = 0;
        var g = 0;
        var h = 0;
        var i = 0;
        try {
            for (var _b = tslib_1.__values(fromEnum(a.j.keys)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var j = _c.value;
                var k = a.j.item(j);
                if (d != null) {
                    switch (d.getCalculatorType()) {
                        case 1:
                            var l = this.nw(k, c, d, h, i, true);
                            h = l.p3;
                            i = l.p4;
                            break;
                        case 0:
                            var m = this.nu(k, c, d, h, i, true);
                            h = m.p3;
                            i = m.p4;
                            break;
                        case 2:
                            var n = this.ns(k, c, d, j, h, i, true);
                            h = n.p4;
                            i = n.p5;
                            break;
                        case 3:
                            var o = this.nx(c, d, f, h, i, true);
                            f = o.p2;
                            h = o.p3;
                            i = o.p4;
                            break;
                        case 4:
                            var p = this.nu(k, c, d, h, i, true);
                            h = p.p3;
                            i = p.p4;
                            break;
                    }
                    ;
                    var q = new OwnedPoint();
                    q.c = c.l(d, this.mx.a, k.c, f);
                    ;
                    q.a = k.a;
                    a.h.addItem(j, q);
                    a.i.addItem(j, [h, i]);
                }
                if (e != null) {
                    switch (e.getCalculatorType()) {
                        case 1:
                            var r = this.nw(k, c, e, h, i, false);
                            h = r.p3;
                            i = r.p4;
                            break;
                        case 0:
                            var s = this.nu(k, c, e, h, i, false);
                            h = s.p3;
                            i = s.p4;
                            break;
                        case 2:
                            var t = this.ns(k, c, e, j, h, i, false);
                            h = t.p4;
                            i = t.p5;
                            break;
                        case 3:
                            var u = this.nx(c, e, g, h, i, false);
                            g = u.p2;
                            h = u.p3;
                            i = u.p4;
                            break;
                        case 4:
                            var v = this.nu(k, c, e, h, i, false);
                            h = v.p3;
                            i = v.p4;
                            break;
                    }
                    ;
                    var w = new OwnedPoint();
                    w.c = c.m(e, this.mx.b, k.c, g);
                    ;
                    w.a = k.a;
                    a.l.addItem(j, w);
                    a.k.addItem(j, [h, i]);
                }
            }
        }
        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.nw = function (a, b, c, d, e, f) {
        if (f) {
            var g = void 0;
            var h = void 0, i = void 0;
            i = this.mx.a;
            if (this.mz.s == 0) {
                g = a.c.x;
                h = this.mx.a;
            }
            else {
                g = a.c.y;
                h = this.mx.b;
            }
            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.mx.b;
            if (this.mz.t == 0) {
                k = a.c.x;
                l = this.mx.a;
            }
            else {
                k = a.c.y;
                l = this.mx.b;
            }
            var n = b.f(k, c, l, m, d, e);
            d = n.p4;
            e = n.p5;
        }
        return {
            p3: d,
            p4: e
        };
    };
    ScatterBase.prototype.nu = function (a, b, c, d, e, f) {
        if (f) {
            var g = b.j(a.c.x, c, this.mx.a, d, e);
            d = g.p3;
            e = g.p4;
        }
        else {
            var h = b.j(a.c.y, c, this.mx.b, d, e);
            d = h.p3;
            e = h.p4;
        }
        return {
            p3: d,
            p4: e
        };
    };
    ScatterBase.prototype.ns = function (a, b, c, d, e, f, g) {
        var h = c.getItemColumn();
        var i = this.bz.indexOf(d);
        if (h != null && i < h.count) {
            var j = h.item(i);
            if (g) {
                var k = b.h(a.c.x, j, this.mx.a, e, f);
                e = k.p3;
                f = k.p4;
            }
            else {
                var l = b.h(a.c.y, j, this.mx.b, e, f);
                e = l.p3;
                f = l.p4;
            }
        }
        else {
            e = f = NaN;
        }
        return {
            p4: e,
            p5: f
        };
    };
    ScatterBase.prototype.nx = 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.mx.a, d, e);
            d = h.p3;
            e = h.p4;
        }
        else {
            var i = a.k(c, b, this.mx.b, d, e);
            d = i.p3;
            e = i.p4;
        }
        return {
            p2: c,
            p3: d,
            p4: e
        };
    };
    ScatterBase.prototype.n1 = function (a, b) {
        if (!b.l() || this.mz == null) {
            b.c1();
            return;
        }
        this.n2(a, b);
        this.n3(a, b);
    };
    ScatterBase.prototype.n2 = function (a, b) {
        var e_4, _a;
        b.cy();
        var c = new ErrorBarsHelper(this, b);
        var d = new PathGeometry();
        var e = this.mz.u;
        try {
            for (var _b = tslib_1.__values(fromEnum(a.j.keys)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var f = _c.value;
                if (e != null && a.i.containsKey(f)) {
                    var g = a.i.item(f)[0];
                    var h = a.i.item(f)[1];
                    if (!isNaN_(g) && !isNaN_(h)) {
                        var i = a.h.item(f).c;
                        if (this.mz.o == 1 || this.mz.o == 2) {
                            c.d(d, i, g, true);
                        }
                        if (this.mz.o == 1 || this.mz.o == 3) {
                            c.d(d, i, h, false);
                        }
                    }
                }
            }
        }
        catch (e_4_1) { e_4 = { error: e_4_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
            }
            finally { if (e_4) throw e_4.error; }
        }
        b.c2(d);
    };
    ScatterBase.prototype.n3 = function (a, b) {
        var e_5, _a;
        b.cz();
        var c = new ErrorBarsHelper(this, b);
        var d = new PathGeometry();
        var e = this.mz.v;
        try {
            for (var _b = tslib_1.__values(fromEnum(a.j.keys)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var f = _c.value;
                if (e != null && a.k.containsKey(f)) {
                    var g = a.k.item(f)[0];
                    var h = a.k.item(f)[1];
                    if (!isNaN_(g) && !isNaN_(h)) {
                        var i = a.l.item(f).c;
                        if (this.mz.p == 1 || this.mz.p == 2) {
                            c.e(d, i, g, true);
                        }
                        if (this.mz.p == 1 || this.mz.p == 3) {
                            c.e(d, i, h, false);
                        }
                    }
                }
            }
        }
        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.dv = function (a, b, c) {
        var d = true;
        if (!_super.prototype.dv.call(this, a, b, c) || b.isEmpty || a.isEmpty || this.xAxis == null || this.yAxis == null || this.xAxis.bf == null || this.yAxis.bf == null || this.m6 == null || this.m8 == null || this.m6.count == 0 || this.m8.count == 0 || this.bz == null || this.bz.count != this.m6.count || this.bz.count != this.m8.count || this.xAxis.bf == null || this.yAxis.bf == null || this.xAxis.jx == this.xAxis.jw || this.yAxis.jx == this.yAxis.jw) {
            d = false;
        }
        return d;
    };
    ScatterBase.prototype.getViewInfo = function (a, b) {
        if (!this.oo.isEmpty && !this.op.isEmpty) {
            a = this.oo;
            b = this.op;
            return {
                p0: a,
                p1: b
            };
        }
        a = this.bi.br;
        b = this.bi.bs;
        return {
            p0: a,
            p1: b
        };
    };
    ScatterBase.prototype.i7 = function (a) {
        this.nq();
        try {
            if (this.cc(this.bi)) {
                return;
            }
            if (this.bz != null && this.bz.count > this.nd) {
                a = false;
            }
            if (this.c9(a) && !this.dd) {
                var b = this.m2;
                if (this.ca()) {
                    if (this.bt.g) {
                        this.bt.t();
                    }
                    this.m2 = this.m4;
                    this.m4 = b;
                }
                else {
                    this.m2 = this.m1;
                    this.m1 = b;
                }
                this.nv(this.m1, this.my);
                this.je();
            }
            else {
                if (!this.dd) {
                    this.nv(this.m1, this.my);
                }
                this.n4(this.m1, this.my);
            }
        }
        finally {
            this.n5();
        }
    };
    ScatterBase.prototype.jh = function () {
        _super.prototype.jh.call(this);
        if (this.fe < 0) {
            return;
        }
        this.my.c5();
    };
    ScatterBase.prototype.i8 = function (a, b) {
        _super.prototype.i8.call(this, a, b);
        if (!this.dk) {
            this.bi.az(b);
            return;
        }
        this.bi.az(b);
        if (this.cc(this.bh)) {
            return;
        }
        var c = typeCast(ScatterBaseView.$, this.bh);
        if (!this.de) {
            this.m3 = new ScatterFrame();
            this.nv(this.m3, c);
        }
        this.de = false;
        this.n4(this.m3, c);
        this.dk = false;
    };
    ScatterBase.prototype.i5 = function (a, b, c, d, e) {
        _super.prototype.i5.call(this, a, b, c, d, e);
        var f = this.a0.a$h.item(d);
        var g = f;
        f.ay(c);
        if (this.cc(g)) {
            return;
        }
        if (this.m0 == null) {
            this.m0 = new ScatterFrame();
        }
        this.nv(this.m0, g);
        this.n4(this.m0, g);
    };
    ScatterBase.prototype.n0 = function (a, b) {
        var e_6, _a, e_7, _b;
        var c = new List$1(Base.$, 0);
        try {
            for (var _c = tslib_1.__values(fromEnum(b.c)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var d = _d.value;
                if (!a.containsKey(d)) {
                    c.add1(d);
                }
            }
        }
        catch (e_6_1) { e_6 = { error: e_6_1 }; }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
            }
            finally { if (e_6) throw e_6.error; }
        }
        try {
            for (var _e = tslib_1.__values(fromEnum(c)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var e = _f.value;
                b.g(e);
            }
        }
        catch (e_7_1) { e_7 = { error: e_7_1 }; }
        finally {
            try {
                if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
            }
            finally { if (e_7) throw e_7.error; }
        }
    };
    ScatterBase.prototype.mt = function (a, b, c, d, e) {
        var _this = this;
        if (c == null || c.length != this.mx.c.count) {
            c = new Array(this.mx.c.count);
            for (var f = 0; f < this.mx.c.count; f++) {
                c[f] = PointUtil.create();
            }
        }
        var g = this.getEffectiveViewport1(a);
        var h = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.xAxis.b8, g);
            $ret.c = _this.getEffectiveViewport1(a);
            return $ret;
        })());
        var i = ((function () {
            var $ret = new ScalerParams(0, d, e, _this.yAxis.b8, g);
            $ret.c = _this.getEffectiveViewport1(a);
            $ret.b = _this.ee();
            return $ret;
        })());
        var j = this.lj(a);
        var k = this.mx.a.dw(j.left, h);
        var l = this.mx.a.dw(j.right, h);
        var m = this.mx.b.dw(j.bottom, i);
        var n = this.mx.b.dw(j.top, i);
        if (this.mx.d) {
            var o = k;
            k = l;
            l = o;
        }
        if (this.mx.e) {
            var p = m;
            m = n;
            n = p;
        }
        var q = this.mx;
        var r = q.a;
        var s = q.b;
        var t;
        var u;
        var v = this.m6;
        var w = this.m8;
        for (var x = 0; x < this.mx.c.count; x++) {
            t = v.item(x);
            u = w.item(x);
            if (t >= k && t <= l && u >= m && u <= n) {
                c[x].x = r.dt(t, h);
                c[x].y = s.dt(u, i);
            }
            else {
                c[x].x = NaN;
                c[x].y = NaN;
            }
        }
        return c;
    };
    ScatterBase.prototype.nc = function (a, b) {
        var e_8, _a;
        if (b == null) {
            b = new List$1(Number_$type, 2, a.e);
        }
        else {
            b.clear();
        }
        var c = 0;
        var d = this.bz;
        try {
            for (var _b = tslib_1.__values(fromEnum(a.c)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var e = _c.value;
                b.add(d.indexOf(e));
            }
        }
        catch (e_8_1) { e_8 = { error: e_8_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
            }
            finally { if (e_8) throw e_8.error; }
        }
        return b;
    };
    ScatterBase.prototype.hy = function (a) {
        _super.prototype.hy.call(this, a);
        this.a2.exportTrendlineData(this, a, this.my.ct.g$j);
    };
    ScatterBase.prototype.ee = function () {
        return Series.ef(this.m8, null);
    };
    ScatterBase.$t = markType(ScatterBase, 'ScatterBase', MarkerSeries.$, [ISupportsErrorBars_$type, ITrendLineSeries_$type]);
    ScatterBase.n6 = DependencyProperty.i("ActualTrendLineBrush", Brush.$, ScatterBase.$, new PropertyMetadata(2, null, function (a, b) { return a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue); }));
    return ScatterBase;
}(MarkerSeries));
export { ScatterBase };
Type.dep(DependencyProperty, PropertyMetadata, ScatterBase, 'raisePropertyChanged', ['ErrorBarSettings:mz:n7', [ScatterErrorBarSettings.$, null], 'MarkerCollisionAvoidance:mu:n8', [CollisionAvoidanceType_$type, enumGetBox(CollisionAvoidanceType_$type, 0)], 'MaximumMarkers:nd:n9', [1, 400], 'XAxis::oh', [NumericXAxis.$, null], 'XMemberPath:nk:oi', [2, null], 'YAxis::oj', [NumericYAxis.$, null], 'YMemberPath:no:ok', [2, null], 'TrendLineType::of', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::oe', [1, 1.5], 'TrendLinePeriod::od', [1, 7], 'TrendLineBrush::oa', [Brush.$, null], 'TrendLineZIndex:ne:og', [1, 1001], 'TrendLineDashArray:om:ob', [DoubleCollection.$], 'TrendLineDashCap:on:oc', [PenLineCap_$type, enumGetBox(PenLineCap_$type, 0)]]);
/**
 * @hidden
 */
var ScatterBaseView = /** @class */ (function (_super) {
    tslib_1.__extends(ScatterBaseView, _super);
    function ScatterBaseView(a) {
        var _this = _super.call(this, a) || this;
        _this.cr = null;
        _this.cp = null;
        _this.cs = null;
        _this.cx = null;
        _this.c7 = null;
        _this.c8 = null;
        _this.ct = null;
        _this.c6 = null;
        _this.cu = null;
        _this.cs = a;
        _this.cu = new HashPool$2(Base.$, Marker.$);
        _this.ce(_this.cu);
        _this.ct = new ScatterTrendLineManager();
        return _this;
    }
    ScatterBaseView.prototype.ap = function () {
        _super.prototype.ap.call(this);
        this.cr = this.cq();
        this.c7 = new Path();
        this.c8 = new Path();
        if (!this.n) {
            this.cs.nd = 2000;
        }
    };
    ScatterBaseView.prototype.c9 = function (a) {
        if (this.c6 == null) {
            this.c6 = new DataTemplateMeasureInfo();
            this.c6.context = this.h.g();
        }
        this.c6.width = a.width;
        this.c6.height = a.height;
        this.c6.data = a.content;
        var b = a.ah;
        if (b.measure != null) {
            b.measure(this.c6);
        }
        return new Size(1, this.c6.width, this.c6.height);
    };
    ScatterBaseView.prototype.cq = function () {
        var _this = this;
        var a = new NumericMarkerManager(1, function (b) { return _this.cu.item(b); }, function (b) { return _this.cs.mx.c.item(b); }, runOn(this, this.c4), runOn(this, this.cn), runOn(this, this.cv), function () { return _this.cs.mu; });
        a.q = runOn(this, this.c9);
        return a;
    };
    ScatterBaseView.prototype.c4 = function (a) {
        this.cs.n0(a, this.cu);
    };
    ScatterBaseView.prototype.cw = function () {
        return this.b1;
    };
    ScatterBaseView.prototype.co = function () {
        return this.cp;
    };
    ScatterBaseView.prototype.cn = function () {
        this.cp = this.cs.mt(this, this.cu, this.cp, this.bs, this.br);
        return this.cp;
    };
    ScatterBaseView.prototype.cv = function () {
        this.cx = this.cs.nc(this.cu, this.cx);
        return this.cx;
    };
    ScatterBaseView.prototype.cy = function () {
    };
    ScatterBaseView.prototype.c2 = function (a) {
    };
    ScatterBaseView.prototype.cz = function () {
    };
    ScatterBaseView.prototype.c3 = function (a) {
    };
    ScatterBaseView.prototype.c5 = function () {
        if (this.cs.trendLineBrush != null) {
            this.cs.ol = this.cs.trendLineBrush;
        }
        else {
            this.cs.ol = this.cs.kw;
        }
    };
    ScatterBaseView.prototype.cc = function (a) {
        this.cu.f(a);
    };
    ScatterBaseView.prototype.c1 = function () {
    };
    ScatterBaseView.prototype.a2 = function (a, b) {
        _super.prototype.a2.call(this, a, b);
        if (a.d) {
            if (this.cs.trendLineType != 0 && !b) {
                var c = this.ct.g$j;
                c.ac = this.cs.trendLineThickness;
                c._stroke = this.cs.ol;
                c.ai = this.cs.om;
                c.ad = this.cs.on;
                a.u(c);
            }
        }
    };
    ScatterBaseView.prototype.c0 = function (a) {
        if (a) {
            this.c1();
            this.cu.clear();
        }
        this.ct.g$d();
        this.an();
    };
    ScatterBaseView.prototype.getDefaultTooltipTemplate = function () {
        var a = "<div class='ui-chart-default-tooltip-content'><span";
        var b = this.e.a0.a$q(this.e);
        if (!stringIsNullOrEmpty(b)) {
            a += " style='color:" + b + "'";
        }
        a += ">" + this.cs.fs + "</span><br/><span>" + "x: </span><span class='ui-priority-primary'>${item." + this.cs.nk + "}</span><br/><span>" + "y: </span><span class='ui-priority-primary'>${item." + this.cs.no + "}</span></div>";
        return a;
    };
    ScatterBaseView.$t = markType(ScatterBaseView, 'ScatterBaseView', MarkerSeriesView.$);
    return ScatterBaseView;
}(MarkerSeriesView));
export { ScatterBaseView };
