/*
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 } from "tslib";
import { Series } from "./Series";
import { NumericXAxis } from "./NumericXAxis";
import { DependencyProperty } from "igniteui-react-core";
import { NumericYAxis } from "./NumericYAxis";
import { Color } from "igniteui-react-core";
import { ScatterFrame } from "./ScatterFrame";
import { Defaults } from "./Defaults";
import { KDTree2D } from "./KDTree2D";
import { Point_$type, typeGetValue, runOn, delegateRemove, typeCast, delegateCombine, markType, markDep, toNullable } from "igniteui-react-core";
import { DataLegendSeriesValueInfo } from "igniteui-react-core";
import { DataLegendSeriesContext } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { BrushUtil } from "igniteui-react-core";
import { SeriesView } from "./SeriesView";
import { KDPointData } from "./KDPointData";
import { ScalerParams } from "./ScalerParams";
import { ProgressiveLoadStatusEventArgs } from "./ProgressiveLoadStatusEventArgs";
import { SearchArgs } from "./SearchArgs";
import { KDTreeNode2D } from "./KDTreeNode2D";
import { AxisRange } from "./AxisRange";
import { PropertyMetadata } from "igniteui-react-core";
import { truncate, isNaN_, isInfinity, logBase, intDivide } from "igniteui-react-core";
import { boxArray$1, arrayShallowClone } from "igniteui-react-core";
import { dateNow } from "igniteui-react-core";
import { RenderingContext } from "igniteui-react-core";
import { CanvasViewRenderer } from "igniteui-react-core";
import { Rectangle } from "igniteui-react-core";
/**
 * @hidden
 */
var HighDensityScatterSeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(HighDensityScatterSeries, _super);
    function HighDensityScatterSeries() {
        var _this = _super.call(this) || this;
        _this.w3 = null;
        _this.w5 = null;
        _this.ye = 0;
        _this.w7 = false;
        _this.xt = Defaults.aq.o;
        _this.xs = Defaults.aq.n;
        _this.xr = Defaults.aq.m;
        _this.xq = Defaults.aq.l;
        _this.xp = Defaults.ap.o;
        _this.xo = Defaults.ap.n;
        _this.xn = Defaults.ap.m;
        _this.xm = Defaults.ap.l;
        _this.wv = null;
        _this.w0 = null;
        _this.w1 = null;
        _this.ww = null;
        _this.wy = null;
        _this.w9 = false;
        _this.yf = 0;
        _this.yh = 0;
        _this.yb = 0;
        _this.ya = 0;
        _this.progressiveLoadStatusChanged = null;
        _this.xe = null;
        _this.xk = 0;
        _this.xj = 0;
        _this.xl = 0;
        _this.x0 = 0;
        _this.xy = 0;
        _this.xz = 0;
        _this.x1 = 0;
        _this.x3 = 0;
        _this.x5 = 0;
        _this.x4 = 0;
        _this.x2 = 0;
        _this.xg = 0;
        _this.xh = 0;
        _this.xi = 0;
        _this.xf = 0;
        _this.yd = 0;
        _this.yc = 0;
        _this.ws = null;
        _this.yg = 0;
        _this.w8 = false;
        _this._itemIndexes = null;
        _this.wt = null;
        _this.wq = null;
        _this.w2 = null;
        _this.ab = HighDensityScatterSeries.$;
        _this.f6 = false;
        return _this;
    }
    HighDensityScatterSeries.prototype.bi = function () {
        return new HighDensityScatterSeries();
    };
    HighDensityScatterSeries.prototype.get_fm = function () {
        return true;
    };
    HighDensityScatterSeries.prototype.ji = function () {
        if (!isNaN_(this.jh)) {
            return _super.prototype.ji.call(this);
        }
        return Defaults.q;
    };
    HighDensityScatterSeries.prototype.get_fu = function () {
        return true;
    };
    Object.defineProperty(HighDensityScatterSeries.prototype, "w4", {
        get: function () {
            return this.w3;
        },
        set: function (a) {
            if (this.w3 != a) {
                var b = this.w4;
                this.w3 = a;
                this.raisePropertyChanged("XColumn", b, this.w4);
            }
        },
        enumerable: false,
        configurable: true
    });
    HighDensityScatterSeries.prototype.getDataLegendSeriesContextAt = function (a, b) {
        var c = { $type: Point_$type, x: a, y: b };
        var d = this.kl(c);
        var e = d == null ? NaN : this.iv(d, "XMemberPath");
        var f = d == null ? NaN : this.iv(d, "YMemberPath");
        var g = new DataLegendSeriesValueInfo();
        g.l = e;
        g.a = 13;
        g.q = "X";
        g.r = this.y0 != null ? this.y0 : "X";
        g.s = this.yw != null ? this.yw : "X:";
        g.t = this.yy != null ? this.yy : "";
        var h = new DataLegendSeriesValueInfo();
        h.l = f;
        h.a = 14;
        h.q = "Y";
        h.r = this.y8 != null ? this.y8 : "Y";
        h.s = this.y4 != null ? this.y4 : "Y:";
        h.t = this.y6 != null ? this.y6 : "";
        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.ma();
        return i;
    };
    HighDensityScatterSeries.prototype.ko = function (a, b) {
        var c = this.nb(b);
        if (c == HighDensityScatterSeries.$$p[10]) {
            return this.kp(a, b, this.y0);
        }
        if (c == HighDensityScatterSeries.$$p[14]) {
            return this.kp(a, b, this.y8);
        }
        return _super.prototype.ko.call(this, a, b);
    };
    HighDensityScatterSeries.prototype.mb = function (a) {
        var b = this.nb(a);
        if (b == HighDensityScatterSeries.$$p[10]) {
            return this.y0;
        }
        if (b == HighDensityScatterSeries.$$p[14]) {
            return this.y8;
        }
        return _super.prototype.mb.call(this, a);
    };
    Object.defineProperty(HighDensityScatterSeries.prototype, "w6", {
        get: function () {
            return this.w5;
        },
        set: function (a) {
            if (this.w5 != a) {
                var b = this.w6;
                this.w5 = a;
                this.raisePropertyChanged("YColumn", b, this.w6);
            }
        },
        enumerable: false,
        configurable: true
    });
    HighDensityScatterSeries.prototype.zn = function () {
        if (this.wv == null) {
            return;
        }
        this.wv.s();
        var a = this.wv;
        a.progressiveThunkCompleted = delegateRemove(a.progressiveThunkCompleted, runOn(this, this.za));
        this.wv = null;
    };
    HighDensityScatterSeries.prototype.q5 = function (a, b, c, d) {
        _super.prototype.q5.call(this, a, b, c, d);
        switch (b) {
            case HighDensityScatterSeries.$$p[8]:
            case HighDensityScatterSeries.$$p[12]:
            case HighDensityScatterSeries.$$p[9]:
            case HighDensityScatterSeries.$$p[13]:
                this.qb();
                break;
            case "SeriesViewer":
                if (this.c9 != null) {
                    var e = this.getEffectiveViewport1(this.ct);
                    this.w8 = !e.isEmpty;
                }
                break;
            case "FastItemsSource":
                this.zn();
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.w4);
                    c.deregisterColumn(this.w6);
                    this.w4 = null;
                    this.w6 = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.w4 = this.di(this.y0);
                    this.w6 = this.di(this.y8);
                }
                if ((this.wz != null && !this.wz.c1()) || (this.wx != null && !this.wx.c1())) {
                    this.rn(this.ge && c != null);
                }
                this.qi();
                break;
            case HighDensityScatterSeries.$$p[7]:
                var f = this.ww;
                this.ww = this.wx;
                this.zn();
                if (f != null) {
                    f.rangeChanged = delegateRemove(f.rangeChanged, runOn(this, this.zd));
                }
                if (this.ww != null) {
                    var g = this.ww;
                    g.rangeChanged = delegateCombine(g.rangeChanged, runOn(this, this.zd));
                }
                if (c != null) {
                    c.b0(this);
                }
                if (d != null) {
                    d.ct(this);
                }
                if ((this.wx != null && !this.wx.c1()) || (d == null && c != null)) {
                    this.rn(false);
                }
                break;
            case HighDensityScatterSeries.$$p[11]:
                var h = this.wy;
                this.wy = this.wz;
                this.zn();
                if (h != null) {
                    h.rangeChanged = delegateRemove(h.rangeChanged, runOn(this, this.zd));
                }
                if (this.wy != null) {
                    var i = this.wy;
                    i.rangeChanged = delegateCombine(i.rangeChanged, runOn(this, this.zd));
                }
                if (c != null) {
                    c.b0(this);
                }
                if (d != null) {
                    d.ct(this);
                }
                if ((this.wz != null && !this.wz.c1()) || (d == null && c != null)) {
                    this.rn(false);
                }
                break;
            case "MouseOverEnabled":
                this.w9 = this.f6;
                this.rn(false);
                break;
            case HighDensityScatterSeries.$$p[10]:
                if (this.dl != null) {
                    this.dl.deregisterColumn(this.w4);
                    this.w4 = this.di(this.y0);
                }
                break;
            case "XColumn":
                this.zn();
                if (this.wx != null && !this.wx.c1()) {
                    this.rn(false);
                }
                this.qi();
                break;
            case HighDensityScatterSeries.$$p[14]:
                if (this.dl != null) {
                    this.dl.deregisterColumn(this.w6);
                    this.w6 = this.di(this.y8);
                }
                break;
            case "YColumn":
                this.zn();
                if (this.wz != null && !this.wz.c1()) {
                    this.rn(false);
                }
                this.qi();
                break;
            case HighDensityScatterSeries.$$p[6]:
                this.zn();
                this.rn(false);
                this.qh();
                break;
            case HighDensityScatterSeries.$$p[3]:
                this.rn(false);
                this.qh();
                break;
            case HighDensityScatterSeries.$$p[1]:
                this.rn(false);
                this.qh();
                break;
            case HighDensityScatterSeries.$$p[0]:
            case HighDensityScatterSeries.$$p[2]:
                if (!this.wu.b4(this.z6, this.z5)) {
                    return;
                }
                this.zh();
                this.rn(false);
                this.qh();
                break;
            case HighDensityScatterSeries.$$p[4]:
                this.ye = Math.max(typeGetValue(d) - 1, 0);
                this.w7 = this.ye > 0;
                this.rn(false);
                this.qh();
                break;
            case HighDensityScatterSeries.$$p[5]:
                this.rn(false);
                this.qh();
                break;
        }
    };
    HighDensityScatterSeries.prototype.zh = function () {
        this.xq = this.z6.l;
        this.xt = this.z6.o;
        this.xs = this.z6.n;
        this.xr = this.z6.m;
        this.xm = this.z5.l;
        this.xp = this.z5.o;
        this.xo = this.z5.n;
        this.xn = this.z5.m;
        this.vp = BrushUtil.h(truncate(this.xq), truncate(this.xt), truncate(this.xs), truncate(this.xr));
        this.u9 = BrushUtil.h(truncate(this.xm), truncate(this.xp), truncate(this.xo), truncate(this.xn));
    };
    HighDensityScatterSeries.prototype.xb = function (a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    HighDensityScatterSeries.prototype.xa = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    HighDensityScatterSeries.prototype.zd = function (a, b) {
        this.zn();
        this.rn(false);
    };
    Object.defineProperty(HighDensityScatterSeries.prototype, "xx", {
        get: function () {
            return this.xp - this.xt;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(HighDensityScatterSeries.prototype, "xw", {
        get: function () {
            return this.xo - this.xs;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(HighDensityScatterSeries.prototype, "xv", {
        get: function () {
            return this.xn - this.xr;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(HighDensityScatterSeries.prototype, "xu", {
        get: function () {
            return this.xm - this.xq;
        },
        enumerable: false,
        configurable: true
    });
    HighDensityScatterSeries.prototype.hc = function (a, b, c) {
        var d = _super.prototype.hc.call(this, a, b, c);
        if (this.wz == null || this.wx == null || this.wx.bi == null || this.wz.bi == null || this.w6 == null || this.w4 == null || this.w6.count < 1 || this.w4.count < 1 || this.w6.count != this.w4.count || this.wx.ly == this.wx.lx || this.wz.ly == this.wz.lx || this.wl.isEmpty) {
            d = false;
        }
        return d;
    };
    Object.defineProperty(HighDensityScatterSeries.prototype, "yl", {
        get: function () {
            return this.yf;
        },
        set: function (a) {
            var b = this.yf;
            this.yf = a;
            this.raisePropertyChanged("ProgressiveStatus", b, this.yf);
        },
        enumerable: false,
        configurable: true
    });
    HighDensityScatterSeries.prototype.ro = function (a) {
        _super.prototype.ro.call(this, a);
        this.zf(a, this.ct);
    };
    HighDensityScatterSeries.prototype.zf = function (a, b) {
        if (this.d3(b)) {
            return;
        }
        if (this.wv == null && !this.xd) {
            var c = new List$1(KDPointData.$, 2, this.w4.count);
            var d = this.wx;
            var e = this.wz;
            var f = new Rect(0, 0, 0, 1, 1);
            var g = new Rect(0, 0, 0, 1, 1);
            var h = new ScalerParams(1, f, g, d.ch);
            var i = new ScalerParams(1, f, g, e.ch);
            var j_1;
            var k_1;
            var _loop_1 = function (l) {
                j_1 = d.ek(this_1.w4.item(l), h);
                k_1 = e.ek(this_1.w6.item(l), i);
                if (!isNaN_(j_1) && !isNaN_(k_1) && !isInfinity(j_1) && !isInfinity(k_1)) {
                    c.add(((function () {
                        var $ret = new KDPointData();
                        $ret.a = j_1;
                        $ret.b = k_1;
                        $ret.c = l;
                        return $ret;
                    })()));
                }
            };
            var this_1 = this;
            for (var l = 0; l < this.w4.count; l++) {
                _loop_1(l);
            }
            if (this.xc) {
                this.ya = 1;
                this.yb = truncate(logBase(c.count, 2)) + 3;
                this.yl = truncate(((this.ya / this.yb) * 100));
                if (this.progressiveLoadStatusChanged != null) {
                    this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.yl));
                }
                this.wv = KDTree2D.b(c.toArray(), 1);
                var m = this.wv;
                m.progressiveThunkCompleted = delegateCombine(m.progressiveThunkCompleted, runOn(this, this.za));
                if (!this.wv.f(this.jx)) {
                    var n = this.wv;
                    n.progressiveThunkCompleted = delegateRemove(n.progressiveThunkCompleted, runOn(this, this.za));
                }
                this.qh();
            }
            else {
                var o = dateNow();
                this.wv = new KDTree2D(0, c.toArray(), 1);
                var p = dateNow();
            }
        }
        if (this.xc && !this.xd) {
            this.zg(b);
        }
        else {
            this.zi(b);
        }
    };
    HighDensityScatterSeries.prototype.o9 = function (a, b, c, d) {
        _super.prototype.o9.call(this, a, b, c, d);
        this.zn();
        var e = false;
        if (this.wx != null && !this.wx.c1()) {
            e = true;
        }
        if (this.wz != null && !this.wz.c1()) {
            e = true;
        }
        if (e) {
            this.rn(false);
        }
        this.qi();
    };
    HighDensityScatterSeries.prototype.zc = function (a) {
        var b = a;
        var c = this.yd * this.yc;
        if (this.w9) {
            if (this._itemIndexes == null || this._itemIndexes.length != c) {
                this._itemIndexes = new Array(c);
                for (var d = 0; d < c; d++) {
                    this._itemIndexes[d] = 0;
                }
            }
            else {
                for (var e = 0; e < c; e++) {
                    this._itemIndexes[e] = 0;
                }
            }
        }
    };
    HighDensityScatterSeries.prototype.zi = function (a) {
        var b;
        var c;
        var d = null;
        if (a.q) {
            d = this._itemIndexes;
        }
        var e = a.getViewInfo(c, b);
        c = e.p0;
        b = e.p1;
        var f = a;
        var g = this.getEffectiveViewport1(a);
        this.w0 = new ScalerParams(0, b, c, this.ww.ch, g);
        this.w1 = new ScalerParams(0, b, c, this.wy.ch, g);
        this.zb(a);
        this.zc(a);
        var h = this.yd * this.yc;
        if (this.wt == null || this.wt.length != h) {
            this.wt = new Array(h);
            this.wq = new Array(h);
        }
        var i = this.wt.length;
        var j = this.wt;
        var k = this.wq;
        for (var l = 0; l < i; l++) {
            j[l] = 0;
            k[l] = 0;
        }
        this.yh = truncate(Math.round(this.ib));
        this.ws = f.b1();
        var m = this.ws.length;
        var n = this.ws;
        for (var o = 0; o < m; o++) {
            n[o] = 0;
        }
        var p = this.x8;
        var q = this.x7;
        if (isNaN_(p) || isInfinity(p)) {
            p = 0;
        }
        if (isNaN_(q) || isInfinity(q)) {
            q = 50;
        }
        this.xk = Math.min(p, q);
        this.xj = Math.max(p, q);
        if (this.xk < 0) {
            this.xk = 0;
        }
        if (this.xj < 0) {
            this.xj = 0;
        }
        this.xl = this.xj - this.xk;
        if (this.xd) {
            this.ze(a);
        }
        else {
            this.zp(a);
        }
        f.cc();
        if (a.q) {
            this._itemIndexes = d;
            this.wu.cd();
        }
    };
    HighDensityScatterSeries.prototype.zg = function (a) {
        if (this.wv == null) {
            return;
        }
        this.zi(a);
    };
    HighDensityScatterSeries.prototype.za = function (a, b) {
        var _this = this;
        this.wu.cb(function () {
            if (_this.ya < _this.yb - 1) {
                _this.ya++;
            }
            _this.yl = truncate(((_this.ya / _this.yb) * 100));
            if (_this.progressiveLoadStatusChanged != null) {
                _this.progressiveLoadStatusChanged(_this, new ProgressiveLoadStatusEventArgs(_this.yl));
            }
            _this.zg(_this.ct);
            _this.qh();
            if (_this.wv != null) {
                if (!_this.wv.f(_this.jx)) {
                    var c = _this.wv;
                    c.progressiveThunkCompleted = delegateRemove(c.progressiveThunkCompleted, runOn(_this, _this.za));
                    _this.yl = 100;
                    if (_this.progressiveLoadStatusChanged != null) {
                        _this.progressiveLoadStatusChanged(_this, new ProgressiveLoadStatusEventArgs(_this.yl));
                    }
                }
            }
        });
    };
    HighDensityScatterSeries.prototype.ze = function (a) {
        var b = arrayShallowClone(this.w4.asArray());
        this.wx.ho(boxArray$1(b), 0, b.length, this.w0);
        var c = arrayShallowClone(this.w6.asArray());
        this.yg = 0;
        var d = this.ye;
        var e = this.w7;
        var f = this.wt.length;
        this.wz.ho(boxArray$1(c), 0, c.length, this.w1);
        var g = 255 << 24 | truncate(this.xt) << 16 | truncate(this.xs) << 8 | truncate(this.xr);
        for (var h = 0; h < b.length; h++) {
            var i = truncate(b[h]);
            var j = truncate(c[h]);
            i = truncate(Math.floor(i));
            j = truncate(Math.floor(j));
            if (i < 0 || i >= this.yd || j < 0 || j >= this.yc) {
                continue;
            }
            if (e) {
                var k = i - d;
                var l = i + d;
                l = l > (this.yd - 1) ? (this.yd - 1) : l;
                k = k < 0 ? 0 : k;
                var m = j + d;
                var n = j - d;
                for (var o = k; o <= l; o++) {
                    for (var p = n; p <= m; p++) {
                        var q = (p * this.yd) + o;
                        if (q < 0 || q > f - 1) {
                            continue;
                        }
                        this.wt[q] = this.wt[q] + 1;
                        this.wq[q] = 1;
                        this.yg++;
                        if (this.w9) {
                            this._itemIndexes[q] = h + 1;
                        }
                    }
                }
            }
            else {
                var r = (j * this.yd) + i;
                this.wt[r] = this.wt[r] + 1;
                this.wq[r] = 1;
                this.yg++;
                if (this.w9) {
                    this._itemIndexes[r] = h + 1;
                }
            }
        }
        this.zj();
    };
    HighDensityScatterSeries.prototype.zp = function (a) {
        var b;
        var c;
        var d = a.getViewInfo(b, c);
        b = d.p0;
        c = d.p1;
        if (this.wv == null) {
            return;
        }
        if (this.xe == null) {
            this.xe = new List$1(KDTreeNode2D.$, 2, truncate(Math.round(b.width * b.height)));
        }
        else {
            this.xe.clear();
        }
        var e = c.left;
        var f = c.right;
        var g = c.top;
        var h = c.bottom;
        this.x4 = c.top;
        this.x2 = c.height;
        this.x3 = c.left;
        this.x5 = c.width;
        this.x0 = b.top;
        this.xy = b.height;
        this.xz = b.left;
        this.x1 = b.width;
        var i = this.getEffectiveViewport1(a);
        this.xg = (i.left - this.xz) / this.x1;
        this.xh = (i.top - this.x0) / this.xy;
        var j = (i.right - this.xz) / this.x1;
        this.xi = j - this.xg;
        var k = (i.bottom - this.x0) / this.xy;
        this.xf = k - this.xh;
        if (this.w8) {
            e = (e - this.xg) / this.xi;
            f = (f - this.xg) / this.xi;
            g = (g - this.xh) / this.xf;
            h = (h - this.xh) / this.xf;
        }
        var l = this.ib / b.width * c.width;
        var m = this.ib / b.height * c.height;
        var n = Math.min(l, m);
        var o = ((function () {
            var $ret = new SearchArgs();
            $ret.c = e;
            $ret.a = f;
            $ret.d = g;
            $ret.b = h;
            $ret.e = l;
            $ret.f = m;
            $ret.g = 0x7FFFFFFF;
            return $ret;
        })());
        this.wv.t(this.xe, o, 0, 1, 0, 1);
        var p;
        this.yg = 0;
        for (var q = 0; q < this.xe.count; q++) {
            p = this.xe._inner[q];
            this.zk(p);
        }
        this.zj();
    };
    HighDensityScatterSeries.prototype.zk = function (a) {
        if (a.g) {
            return;
        }
        var b = a.e != null && a.e.a;
        var c = a.a == null ? 0 : a.a.length;
        var d = (a.h - c) + 1;
        if (b && d > 0) {
        }
        else {
            d = 1;
        }
        this.zm(a.b, d, b, a.e);
        if (c > 0 && !b) {
            var e = void 0;
            for (var f = 0; f < c; f++) {
                e = a.a[f];
                this.zm(e, d, false, a.e);
            }
        }
        if (a.e != null) {
            a.e.a = false;
        }
    };
    HighDensityScatterSeries.prototype.gb = function (a) {
        var b = this.c9 != null ? this.c9.vl : Rect.empty;
        var c = this.c9 != null ? this.c9.v0 : Rect.empty;
        var d = new Rect(0, 0, 0, 1, 1);
        var e = this.wf(this.ct);
        var f = new ScalerParams(0, d, d, this.wx.ch, e);
        var g = new ScalerParams(0, d, d, this.wz.ch, e);
        var h = !b.isEmpty && !c.isEmpty && this.dl != null ? this.dl.indexOf(a) : -1;
        var i = this.wx != null && this.w4 != null && h < this.w4.count ? this.wx.ek(this.w4.item(h), f) : NaN;
        var j = this.wz != null && this.w6 != null && h < this.w6.count ? this.wz.ek(this.w6.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.c1 != null) {
            this.c1.au(this.c9, b, true);
        }
        return h >= 0;
    };
    HighDensityScatterSeries.prototype.zm = function (a, b, c, d) {
        var e = this.yj(b);
        var f = a.c;
        var g = this.ye;
        if (c) {
            var h = d.d;
            var i = d.b;
            var j = d.e;
            var k = d.c;
            if (this.w8) {
                h = this.xg + this.xi * h;
                i = this.xg + this.xi * i;
                j = this.xh + this.xf * j;
                k = this.xh + this.xf * k;
            }
            var l = truncate((this.xz + this.x1 * (h - this.x3) / this.x5));
            var m = truncate((this.xz + this.x1 * (i - this.x3) / this.x5));
            var n = truncate((this.x0 + this.xy * (j - this.x4) / this.x2));
            var o = truncate((this.x0 + this.xy * (k - this.x4) / this.x2));
            l = truncate(Math.floor(l));
            m = truncate(Math.floor(m));
            n = truncate(Math.floor(n));
            o = truncate(Math.floor(o));
            if (this.w7) {
                l -= g;
                m += g;
                n -= g;
                o += g;
            }
            var p = ((m - l) + 1) * ((o - n) + 1);
            var q = b / p;
            var r = q;
            for (var s = l; s <= m; s++) {
                for (var t = n; t <= o; t++) {
                    this.zl(f, s, t, q, r);
                }
            }
        }
        else {
            var u = a.a;
            var v = a.b;
            if (this.w8) {
                u = this.xg + this.xi * u;
                v = this.xh + this.xf * v;
            }
            var w = truncate((this.xz + this.x1 * (u - this.x3) / this.x5));
            var x = truncate((this.x0 + this.xy * (v - this.x4) / this.x2));
            w = truncate(Math.floor(w));
            x = truncate(Math.floor(x));
            if (this.w7) {
                var y = w - g;
                var z = w + g;
                var aa = x + g;
                var ab = x - g;
                var ac = ((z - y) + 1) * ((aa - ab) + 1);
                var ad = b / ac;
                var ae = ad;
                for (var af = y; af <= z; af++) {
                    for (var ag = ab; ag <= aa; ag++) {
                        this.zl(f, af, ag, ad, ae);
                    }
                }
            }
            else {
                this.zl(f, w, x, b, 1);
            }
        }
    };
    HighDensityScatterSeries.prototype.yi = function (a, b) {
        return truncate((Math.floor(255 * b))) << 24 | truncate(Math.floor(b * (this.xt + a * this.xx))) << 16 | truncate(Math.floor(b * (this.xs + a * this.xw))) << 8 | truncate(Math.floor(b * (this.xr + a * this.xv)));
    };
    HighDensityScatterSeries.prototype.yj = function (a) {
        return 255 << 24 | truncate(Math.floor((this.xt + a * this.xx))) << 16 | truncate(Math.floor((this.xs + a * this.xw))) << 8 | truncate(Math.floor((this.xr + a * this.xv)));
    };
    HighDensityScatterSeries.prototype.x6 = function (a) {
        return (a >> 24 & 255) / 255;
    };
    HighDensityScatterSeries.prototype.zl = function (a, b, c, d, e) {
        if (b < 0 || b >= this.yd || c < 0 || c >= this.yc) {
            return;
        }
        var f = (c * this.yd) + b;
        this.wt[f] = this.wt[f] + d;
        this.wq[f] = this.wq[f] + e;
        if (this.w9) {
            this._itemIndexes[f] = a + 1;
        }
        this.yg += truncate(d);
    };
    HighDensityScatterSeries.prototype.zj = function () {
        var a = 0;
        var b = 0;
        var c = this.xl;
        var d = this.xk;
        var e = this.xj;
        var f = this.wt.length;
        var g = this.wt;
        var h = this.wq;
        var i = this.ws;
        var j = NaN;
        var k = NaN;
        var l = 0;
        var m = 0;
        for (var n = 0; n < f; n++) {
            a = g[n];
            if (a != 0) {
                b = h[n];
                if (a >= e) {
                    a = 1;
                }
                else if (a <= d) {
                    a = 0;
                }
                else {
                    a = (a - d) / (c);
                }
                if (b > 1) {
                    b = 1;
                }
                if (b < 0.2) {
                    b = 0.2;
                }
                if (j != a || k != b) {
                    l = this.yi(a, b);
                    j = a;
                    k = b;
                }
                i[m] = l >> 16 & 255;
                i[m + 1] = l >> 8 & 255;
                i[m + 2] = l & 255;
                i[m + 3] = l >> 24 & 255;
            }
            m += 4;
        }
    };
    HighDensityScatterSeries.prototype.zb = function (a) {
        var b = a;
        b.b9();
    };
    HighDensityScatterSeries.prototype.cq = function () {
        return new HighDensityScatterSeriesView(this);
    };
    HighDensityScatterSeries.prototype.qx = function (a) {
        _super.prototype.qx.call(this, a);
        this.wu = a;
    };
    HighDensityScatterSeries.prototype.ax = function (a) {
        if (a != null && a == this.wx && this.w4 != null) {
            return new AxisRange(this.w4.minimum, this.w4.maximum);
        }
        if (a != null && a == this.wz && this.w6 != null) {
            return new AxisRange(this.w6.minimum, this.w6.maximum);
        }
        return null;
    };
    HighDensityScatterSeries.prototype.sk = function (a, b) {
        if (this.c9 != null) {
            var c = this.getEffectiveViewport1(this.ct);
            this.w8 = !c.isEmpty;
        }
        this.rn(false);
    };
    HighDensityScatterSeries.prototype.sl = function (a, b) {
        this.rn(false);
    };
    HighDensityScatterSeries.prototype.kl = function (a) {
        if (!this.w9 || this._itemIndexes == null || this.c9 == null || this.dl == null || this._itemIndexes.length != (this.yd * this.yc)) {
            return null;
        }
        var b = this.c9.vl;
        var c = (a.x - b.left) / b.width;
        var d = (a.y - b.top) / b.height;
        var e = truncate(Math.round(this.wl.left + (this.wl.width * c)));
        var f = truncate(Math.round(this.wl.top + (this.wl.height * d)));
        var g = this.ym(e, f);
        if (g < 0 || g > this._itemIndexes.length - 1) {
            return null;
        }
        var h = this._itemIndexes[g] - 1;
        if (h < 0 || h > this.dl.count) {
            return null;
        }
        return this.dl.item(h);
    };
    HighDensityScatterSeries.prototype.ym = function (a, b) {
        var c = (this.yd * b) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        var d = 1;
        c = (this.yd * (b - d)) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.yd * (b + d)) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.yd * (b)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.yd * (b)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.yd * (b - d)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.yd * (b + d)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.yd * (b - d)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.yd * (b + d)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        return 0;
    };
    HighDensityScatterSeries.prototype.zo = function (a, b, c) {
        this.ws = a;
        this.yd = b;
        this.yc = c;
    };
    HighDensityScatterSeries.prototype.get_g5 = function () {
        return true;
    };
    HighDensityScatterSeries.prototype.set_g5 = function (a) {
        _super.prototype.set_g5.call(this, a);
    };
    HighDensityScatterSeries.prototype.o3 = function (a, b) {
        _super.prototype.o3.call(this, a, b);
        this.wu.ca();
        if (this.cs != null) {
            this.cs.ca();
        }
        this.qh();
    };
    HighDensityScatterSeries.prototype.rp = function (a, b) {
        _super.prototype.rp.call(this, a, b);
        if (!this.gy) {
            this.ct.a4(b);
            return;
        }
        this.ct.a4(b);
        if (this.d3(this.cs)) {
            return;
        }
        var c = typeCast(HighDensityScatterSeriesView.$, this.cs);
        var d = new ScatterFrame();
        this.zf(false, c);
        this.gy = false;
    };
    HighDensityScatterSeries.prototype.rm = function (a, b, c, d, e) {
        _super.prototype.rm.call(this, a, b, c, d, e);
        var f = this.a9.a$j.item(d);
        var g = f;
        f.a3(c);
        if (this.d3(g)) {
            return;
        }
        if (this.w2 == null) {
            this.w2 = new ScatterFrame();
        }
        this.zf(false, f);
    };
    HighDensityScatterSeries.prototype.o0 = function () {
        _super.prototype.o0.call(this);
        this.wx = null;
        this.wz = null;
    };
    HighDensityScatterSeries.$t = markType(HighDensityScatterSeries, 'HighDensityScatterSeries', Series.$);
    HighDensityScatterSeries.$$p = markDep(DependencyProperty, PropertyMetadata, HighDensityScatterSeries, 'raisePropertyChanged', ['HeatMaximumColor:z5:zq', [Color.$, Defaults.ap], 'HeatMaximum:x7:zr', [1, 50], 'HeatMinimumColor:z6:zs', [Color.$, Defaults.aq], 'HeatMinimum:x8:zt', [1, 0], 'PointExtent:yk:zu', [1, 1], 'ProgressiveLoad:xc:zv', [0, true], 'UseBruteForce:xd:zw', [0, false], 'XAxis:wx:zx', [NumericXAxis.$, null], 'XMemberAsLegendLabel:yw:zy', [2, null], 'XMemberAsLegendUnit:yy:zz', [2, null], 'XMemberPath:y0:z0', [2, null], 'YAxis:wz:z1', [NumericYAxis.$, null], 'YMemberAsLegendLabel:y4:z2', [2, null], 'YMemberAsLegendUnit:y6:z3', [2, null], 'YMemberPath:y8:z4', [2, null]]);
    return HighDensityScatterSeries;
}(Series));
export { HighDensityScatterSeries };
/**
 * @hidden
 */
var HighDensityScatterSeriesView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(HighDensityScatterSeriesView, _super);
    function HighDensityScatterSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.b2 = null;
        _this.b0 = null;
        _this.b8 = 0;
        _this.b7 = 0;
        _this.b5 = null;
        _this.b6 = null;
        _this.b3 = null;
        _this.b2 = a;
        return _this;
    }
    HighDensityScatterSeriesView.prototype.au = function () {
        _super.prototype.au.call(this);
        if (!this.q) {
            this.b2.z6 = Defaults.aq;
            this.b2.z5 = Defaults.ap;
            this.b2.u9 = Defaults.al;
            this.b2.vp = Defaults.ak;
        }
    };
    HighDensityScatterSeriesView.prototype.cd = function () {
        this.b2.zo(this.b0, this.b8, this.b7);
    };
    HighDensityScatterSeriesView.prototype.b9 = function () {
        if (this.b5 == null) {
            this.b5 = this.e.jx.createElement("canvas");
            var a = this.e.jx.get2DCanvasContext(this.b5);
            this.b3 = new RenderingContext(new CanvasViewRenderer(), a);
        }
        var b;
        if (this.p) {
            b = this.bx;
        }
        else {
            b = this.e.c9.vq();
        }
        var c = truncate(Math.round(b.left));
        var d = truncate(Math.round(b.top));
        var e = truncate(Math.round(b.width));
        var f = truncate(Math.round(b.height));
        var g = this.b8;
        var h = this.b7;
        this.b8 = e;
        this.b7 = f;
        if (g != this.b8 || h != this.b7 || this.b0 == null) {
            this.b5.setAttribute("width", e.toString());
            this.b5.setAttribute("height", f.toString());
            this.b6 = this.b3.h().getImageData(0, 0, e, f);
            var imageDataArray_ = this.b6.data;
            this.b0 = imageDataArray_;
        }
        this.b2.zo(this.b0, this.b8, this.b7);
    };
    HighDensityScatterSeriesView.prototype.b1 = function () {
        return this.b0;
    };
    HighDensityScatterSeriesView.prototype.cc = function () {
        var a = truncate(Math.round(this.bx.left));
        var b = truncate(Math.round(this.bx.left));
        var c = truncate(Math.round(this.bx.width));
        var d = truncate(Math.round(this.bx.height));
        this.b3.h().putImageData(this.b6, 0, 0);
        this.as();
    };
    HighDensityScatterSeriesView.prototype.cb = function (a) {
        if (this.e.jx != null) {
            this.e.jx.setTimeout(a, 0);
        }
        else {
            window.setTimeout(a, 0);
        }
    };
    HighDensityScatterSeriesView.prototype.a8 = function (a, b) {
        _super.prototype.a8.call(this, a, b);
        if (b) {
            if (!this.b2.f6) {
                return;
            }
            var c = new Rectangle();
            c.n = this.bx.left;
            c.o = this.bx.top;
            c.width = this.bx.width;
            c.height = this.bx.height;
            c._fill = this.br();
            a.w(c);
            return;
        }
        if (this.b5 == null) {
            return;
        }
        var d = truncate(Math.round(this.bx.left));
        var e = truncate(Math.round(this.bx.top));
        var f = truncate(Math.round(this.bx.width));
        var g = truncate(Math.round(this.bx.height));
        this.k.o(this.b5.getNativeElement(), this.e._opacity, d, e, f, g, d, e, f, g);
    };
    HighDensityScatterSeriesView.prototype.b4 = function (a, b) {
        return Color.e(toNullable(Color.$, a), toNullable(Color.$, null)) && Color.e(toNullable(Color.$, b), toNullable(Color.$, null));
    };
    HighDensityScatterSeriesView.prototype.ca = function () {
        if (this.b0 != null) {
            for (var a = 0; a < this.b0.length; a++) {
                this.b0[a] = 0;
            }
            this.cc();
        }
    };
    HighDensityScatterSeriesView.prototype.an = function (a) {
        _super.prototype.an.call(this, a);
        if (this.b0 == null) {
            this.e.bb.exportSeriesPixelsData(a, null, this.b8, this.b7);
            return;
        }
        var b = new Array(intDivide(this.b0.length, 4));
        var c;
        for (var d = 0; d < intDivide(this.b0.length, 4); d++) {
            c = d * 4;
            b[d] = this.b0[c + 3] << 24 | this.b0[c] << 16 | this.b0[c + 1] << 8 | this.b0[c + 2];
        }
        this.e.bb.exportSeriesPixelsData(a, b, this.b8, this.b7);
    };
    HighDensityScatterSeriesView.$t = markType(HighDensityScatterSeriesView, 'HighDensityScatterSeriesView', SeriesView.$);
    return HighDensityScatterSeriesView;
}(SeriesView));
export { HighDensityScatterSeriesView };
