/*
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 { 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 { KDTree2D } from "./KDTree2D";
import { typeGetValue, runOn, delegateRemove, typeCast, delegateCombine, markType, markDep, toNullable } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { SeriesView } from "./SeriesView";
import { List$1 } from "igniteui-react-core";
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) {
    tslib_1.__extends(HighDensityScatterSeries, _super);
    function HighDensityScatterSeries() {
        var _this = _super.call(this) || this;
        _this.mn = null;
        _this.mp = null;
        _this.nv = 0;
        _this.mr = false;
        _this.nb = 0;
        _this.na = 0;
        _this.m9 = 0;
        _this.m8 = 255;
        _this.m7 = 0;
        _this.m6 = 0;
        _this.ne = 255;
        _this.nd = 0;
        _this.nc = 0;
        _this.mf = null;
        _this.mk = null;
        _this.ml = null;
        _this.mg = null;
        _this.mi = null;
        _this.mt = false;
        _this.nw = 0;
        _this.ny = 0;
        _this.ns = 0;
        _this.nr = 0;
        _this.progressiveLoadStatusChanged = null;
        _this.my = null;
        _this.m4 = 0;
        _this.m3 = 0;
        _this.m5 = 0;
        _this.nh = 0;
        _this.nf = 0;
        _this.ng = 0;
        _this.ni = 0;
        _this.nk = 0;
        _this.nm = 0;
        _this.nl = 0;
        _this.nj = 0;
        _this.m0 = 0;
        _this.m1 = 0;
        _this.m2 = 0;
        _this.mz = 0;
        _this.nu = 0;
        _this.nt = 0;
        _this.mc = null;
        _this.nx = 0;
        _this.ms = false;
        _this._itemIndexes = null;
        _this.md = null;
        _this.ma = null;
        _this.mm = null;
        _this.ab = HighDensityScatterSeries.$;
        _this.c7 = false;
        return _this;
    }
    HighDensityScatterSeries.prototype.get_c4 = function () {
        return true;
    };
    Object.defineProperty(HighDensityScatterSeries.prototype, "mo", {
        get: function () {
            return this.mn;
        },
        set: function (a) {
            if (this.mn != a) {
                var b = this.mo;
                this.mn = a;
                this.raisePropertyChanged("XColumn", b, this.mo);
            }
        },
        enumerable: true,
        configurable: true
    });
    HighDensityScatterSeries.prototype.fs = function (a, b) {
        var c = this.g2(b);
        if (c == HighDensityScatterSeries.$$p[8]) {
            return this.ft(a, b, this.od);
        }
        if (c == HighDensityScatterSeries.$$p[10]) {
            return this.ft(a, b, this.oh);
        }
        return _super.prototype.fs.call(this, a, b);
    };
    Object.defineProperty(HighDensityScatterSeries.prototype, "mq", {
        get: function () {
            return this.mp;
        },
        set: function (a) {
            if (this.mp != a) {
                var b = this.mq;
                this.mp = a;
                this.raisePropertyChanged("YColumn", b, this.mq);
            }
        },
        enumerable: true,
        configurable: true
    });
    HighDensityScatterSeries.prototype.ov = function () {
        if (this.mf == null) {
            return;
        }
        this.mf.s();
        var a = this.mf;
        a.progressiveThunkCompleted = delegateRemove(a.progressiveThunkCompleted, runOn(this, this.oj));
        this.mf = null;
    };
    HighDensityScatterSeries.prototype.i7 = function (a, b, c, d) {
        _super.prototype.i7.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                if (this.bs != null) {
                    var e = this.getEffectiveViewport1(this.bi);
                    this.ms = !e.isEmpty;
                }
                break;
            case "FastItemsSource":
                this.ov();
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.mo);
                    c.deregisterColumn(this.mq);
                    this.mo = null;
                    this.mq = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.mo = this.bw(this.od);
                    this.mq = this.bw(this.oh);
                }
                if ((this.mj != null && !this.mj.cn()) || (this.mh != null && !this.mh.cn())) {
                    this.jl(false);
                }
                this.iu();
                break;
            case HighDensityScatterSeries.$$p[7]:
                var f = this.mg;
                this.mg = this.mh;
                this.ov();
                if (f != null) {
                    f.rangeChanged = delegateRemove(f.rangeChanged, runOn(this, this.om));
                }
                if (this.mg != null) {
                    var g = this.mg;
                    g.rangeChanged = delegateCombine(g.rangeChanged, runOn(this, this.om));
                }
                if (c != null) {
                    c.bx(this);
                }
                if (d != null) {
                    d.ck(this);
                }
                if ((this.mh != null && !this.mh.cn()) || (d == null && c != null)) {
                    this.jl(false);
                }
                break;
            case HighDensityScatterSeries.$$p[9]:
                var h = this.mi;
                this.mi = this.mj;
                this.ov();
                if (h != null) {
                    h.rangeChanged = delegateRemove(h.rangeChanged, runOn(this, this.om));
                }
                if (this.mi != null) {
                    var i = this.mi;
                    i.rangeChanged = delegateCombine(i.rangeChanged, runOn(this, this.om));
                }
                if (c != null) {
                    c.bx(this);
                }
                if (d != null) {
                    d.ck(this);
                }
                if ((this.mj != null && !this.mj.cn()) || (d == null && c != null)) {
                    this.jl(false);
                }
                break;
            case "MouseOverEnabled":
                this.mt = this.c7;
                this.jl(false);
                break;
            case HighDensityScatterSeries.$$p[8]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.mo);
                    this.mo = this.bw(this.od);
                }
                break;
            case "XColumn":
                this.ov();
                if (this.mh != null && !this.mh.cn()) {
                    this.jl(false);
                }
                this.iu();
                break;
            case HighDensityScatterSeries.$$p[10]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.mq);
                    this.mq = this.bw(this.oh);
                }
                break;
            case "YColumn":
                this.ov();
                if (this.mj != null && !this.mj.cn()) {
                    this.jl(false);
                }
                this.iu();
                break;
            case HighDensityScatterSeries.$$p[6]:
                this.ov();
                this.jl(false);
                this.it();
                break;
            case HighDensityScatterSeries.$$p[3]:
                this.jl(false);
                this.it();
                break;
            case HighDensityScatterSeries.$$p[1]:
                this.jl(false);
                this.it();
                break;
            case HighDensityScatterSeries.$$p[0]:
            case HighDensityScatterSeries.$$p[2]:
                if (!this.me.by(this.pa, this.o9)) {
                    return;
                }
                this.nb = this.pa.o;
                this.na = this.pa.n;
                this.m9 = this.pa.m;
                this.m8 = this.o9.o;
                this.m7 = this.o9.n;
                this.m6 = this.o9.m;
                this.ne = this.m8 - this.nb;
                this.nd = this.m7 - this.na;
                this.nc = this.m6 - this.m9;
                this.jl(false);
                this.it();
                break;
            case HighDensityScatterSeries.$$p[4]:
                this.nv = Math.max(typeGetValue(d) - 1, 0);
                this.mr = this.nv > 0;
                this.jl(false);
                this.it();
                break;
            case HighDensityScatterSeries.$$p[5]:
                this.jl(false);
                this.it();
                break;
        }
    };
    HighDensityScatterSeries.prototype.mv = function (a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    HighDensityScatterSeries.prototype.mu = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    HighDensityScatterSeries.prototype.om = function (a, b) {
        this.ov();
        this.jl(false);
    };
    HighDensityScatterSeries.prototype.dw = function (a, b, c) {
        var d = _super.prototype.dw.call(this, a, b, c);
        if (this.mj == null || this.mh == null || this.mh.bh == null || this.mj.bh == null || this.mq == null || this.mo == null || this.mq.count < 1 || this.mo.count < 1 || this.mq.count != this.mo.count || this.mh.kc == this.mh.kb || this.mj.kc == this.mj.kb || this.l8.isEmpty) {
            d = false;
        }
        return d;
    };
    Object.defineProperty(HighDensityScatterSeries.prototype, "n2", {
        get: function () {
            return this.nw;
        },
        set: function (a) {
            var b = this.nw;
            this.nw = a;
            this.raisePropertyChanged("ProgressiveStatus", b, this.nw);
        },
        enumerable: true,
        configurable: true
    });
    HighDensityScatterSeries.prototype.jm = function (a) {
        _super.prototype.jm.call(this, a);
        this.oo(a, this.bi);
    };
    HighDensityScatterSeries.prototype.oo = function (a, b) {
        if (this.cc(b)) {
            return;
        }
        if (this.mf == null && !this.mx) {
            var c = new List$1(KDPointData.$, 2, this.mo.count);
            var d = this.mh;
            var e = this.mj;
            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.ca);
            var i = new ScalerParams(1, f, g, e.ca);
            var j_1;
            var k_1;
            var _loop_1 = function (l) {
                j_1 = d.dy(this_1.mo.item(l), h);
                k_1 = e.dy(this_1.mq.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.mo.count; l++) {
                _loop_1(l);
            }
            if (this.mw) {
                this.nr = 1;
                this.ns = truncate(logBase(c.count, 2)) + 3;
                this.n2 = truncate(((this.nr / this.ns) * 100));
                if (this.progressiveLoadStatusChanged != null) {
                    this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.n2));
                }
                this.mf = KDTree2D.b(c.toArray(), 1);
                var m = this.mf;
                m.progressiveThunkCompleted = delegateCombine(m.progressiveThunkCompleted, runOn(this, this.oj));
                if (!this.mf.f(this.e4)) {
                    var n = this.mf;
                    n.progressiveThunkCompleted = delegateRemove(n.progressiveThunkCompleted, runOn(this, this.oj));
                }
                this.it();
            }
            else {
                var o = dateNow();
                this.mf = new KDTree2D(0, c.toArray(), 1);
                var p = dateNow();
            }
        }
        if (this.mw && !this.mx) {
            this.op(b);
        }
        else {
            this.oq(b);
        }
    };
    HighDensityScatterSeries.prototype.h6 = function (a, b, c, d) {
        _super.prototype.h6.call(this, a, b, c, d);
        this.ov();
        var e = false;
        if (this.mh != null && !this.mh.cn()) {
            e = true;
        }
        if (this.mj != null && !this.mj.cn()) {
            e = true;
        }
        if (e) {
            this.jl(false);
        }
        this.iu();
    };
    HighDensityScatterSeries.prototype.ol = function (a) {
        var b = a;
        var c = this.nu * this.nt;
        if (this.mt) {
            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.oq = function (a) {
        var b;
        var c;
        var d = null;
        if (a.n) {
            d = this._itemIndexes;
        }
        var e = a.getViewInfo(c, b);
        c = e.p0;
        b = e.p1;
        var f = a;
        var g = this.getEffectiveViewport1(a);
        this.mk = new ScalerParams(0, b, c, this.mg.ca, g);
        this.ml = new ScalerParams(0, b, c, this.mi.ca, g);
        this.ok(a);
        this.ol(a);
        var h = this.nu * this.nt;
        if (this.md == null || this.md.length != h) {
            this.md = new Array(h);
            this.ma = new Array(h);
        }
        var i = this.md.length;
        var j = this.md;
        var k = this.ma;
        for (var l = 0; l < i; l++) {
            j[l] = 0;
            k[l] = 0;
        }
        this.ny = truncate(Math.round(this.eu));
        this.mc = f.bv();
        var m = this.mc.length;
        var n = this.mc;
        for (var o = 0; o < m; o++) {
            n[o] = 0;
        }
        var p = this.np;
        var q = this.no;
        if (isNaN_(p) || isInfinity(p)) {
            p = 0;
        }
        if (isNaN_(q) || isInfinity(q)) {
            q = 50;
        }
        this.m4 = Math.min(p, q);
        this.m3 = Math.max(p, q);
        if (this.m4 < 0) {
            this.m4 = 0;
        }
        if (this.m3 < 0) {
            this.m3 = 0;
        }
        this.m5 = this.m3 - this.m4;
        if (this.mx) {
            this.on(a);
        }
        else {
            this.ox(a);
        }
        f.b6();
        if (a.n) {
            this._itemIndexes = d;
            this.me.b7();
        }
    };
    HighDensityScatterSeries.prototype.op = function (a) {
        if (this.mf == null) {
            return;
        }
        this.oq(a);
    };
    HighDensityScatterSeries.prototype.oj = function (a, b) {
        var _this = this;
        this.me.b5(function () {
            if (_this.nr < _this.ns - 1) {
                _this.nr++;
            }
            _this.n2 = truncate(((_this.nr / _this.ns) * 100));
            if (_this.progressiveLoadStatusChanged != null) {
                _this.progressiveLoadStatusChanged(_this, new ProgressiveLoadStatusEventArgs(_this.n2));
            }
            _this.op(_this.bi);
            _this.it();
            if (_this.mf != null) {
                if (!_this.mf.f(_this.e4)) {
                    var c = _this.mf;
                    c.progressiveThunkCompleted = delegateRemove(c.progressiveThunkCompleted, runOn(_this, _this.oj));
                    _this.n2 = 100;
                    if (_this.progressiveLoadStatusChanged != null) {
                        _this.progressiveLoadStatusChanged(_this, new ProgressiveLoadStatusEventArgs(_this.n2));
                    }
                }
            }
        });
    };
    HighDensityScatterSeries.prototype.on = function (a) {
        var b = arrayShallowClone(this.mo.asArray());
        this.mh.gs(boxArray$1(b), 0, b.length, this.mk);
        var c = arrayShallowClone(this.mq.asArray());
        this.nx = 0;
        var d = this.nv;
        var e = this.mr;
        var f = this.md.length;
        this.mj.gs(boxArray$1(c), 0, c.length, this.ml);
        var g = 255 << 24 | truncate(this.nb) << 16 | truncate(this.na) << 8 | truncate(this.m9);
        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.nu || j < 0 || j >= this.nt) {
                continue;
            }
            if (e) {
                var k = i - d;
                var l = i + d;
                l = l > (this.nu - 1) ? (this.nu - 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.nu) + o;
                        if (q < 0 || q > f - 1) {
                            continue;
                        }
                        this.md[q] = this.md[q] + 1;
                        this.ma[q] = 1;
                        this.nx++;
                        if (this.mt) {
                            this._itemIndexes[q] = h + 1;
                        }
                    }
                }
            }
            else {
                var r = (j * this.nu) + i;
                this.md[r] = this.md[r] + 1;
                this.ma[r] = 1;
                this.nx++;
                if (this.mt) {
                    this._itemIndexes[r] = h + 1;
                }
            }
        }
        this.or();
    };
    HighDensityScatterSeries.prototype.ox = function (a) {
        var b;
        var c;
        var d = a.getViewInfo(b, c);
        b = d.p0;
        c = d.p1;
        if (this.mf == null) {
            return;
        }
        if (this.my == null) {
            this.my = new List$1(KDTreeNode2D.$, 2, truncate(Math.round(b.width * b.height)));
        }
        else {
            this.my.clear();
        }
        var e = c.left;
        var f = c.right;
        var g = c.top;
        var h = c.bottom;
        this.nl = c.top;
        this.nj = c.height;
        this.nk = c.left;
        this.nm = c.width;
        this.nh = b.top;
        this.nf = b.height;
        this.ng = b.left;
        this.ni = b.width;
        var i = this.getEffectiveViewport1(a);
        this.m0 = (i.left - this.ng) / this.ni;
        this.m1 = (i.top - this.nh) / this.nf;
        var j = (i.right - this.ng) / this.ni;
        this.m2 = j - this.m0;
        var k = (i.bottom - this.nh) / this.nf;
        this.mz = k - this.m1;
        if (this.ms) {
            e = (e - this.m0) / this.m2;
            f = (f - this.m0) / this.m2;
            g = (g - this.m1) / this.mz;
            h = (h - this.m1) / this.mz;
        }
        var l = this.eu / b.width * c.width;
        var m = this.eu / 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.mf.t(this.my, o, 0, 1, 0, 1);
        var p;
        this.nx = 0;
        for (var q = 0; q < this.my.count; q++) {
            p = this.my._inner[q];
            this.os(p);
        }
        this.or();
    };
    HighDensityScatterSeries.prototype.os = 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.ou(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.ou(e, d, false, a.e);
            }
        }
        if (a.e != null) {
            a.e.a = false;
        }
    };
    HighDensityScatterSeries.prototype.c9 = function (a) {
        var b = this.bs != null ? this.bs.n2 : Rect.empty;
        var c = this.bs != null ? this.bs.oh : Rect.empty;
        var d = new Rect(0, 0, 0, 1, 1);
        var e = this.l2(this.bi);
        var f = new ScalerParams(0, d, d, this.mh.ca, e);
        var g = new ScalerParams(0, d, d, this.mj.ca, e);
        var h = !b.isEmpty && !c.isEmpty && this.bz != null ? this.bz.indexOf(a) : -1;
        var i = this.mh != null && this.mo != null && h < this.mo.count ? this.mh.dy(this.mo.item(h), f) : NaN;
        var j = this.mj != null && this.mq != null && h < this.mq.count ? this.mj.dy(this.mq.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;
    };
    HighDensityScatterSeries.prototype.ou = function (a, b, c, d) {
        var e = this.n0(b);
        var f = a.c;
        var g = this.nv;
        if (c) {
            var h = d.d;
            var i = d.b;
            var j = d.e;
            var k = d.c;
            if (this.ms) {
                h = this.m0 + this.m2 * h;
                i = this.m0 + this.m2 * i;
                j = this.m1 + this.mz * j;
                k = this.m1 + this.mz * k;
            }
            var l = truncate((this.ng + this.ni * (h - this.nk) / this.nm));
            var m = truncate((this.ng + this.ni * (i - this.nk) / this.nm));
            var n = truncate((this.nh + this.nf * (j - this.nl) / this.nj));
            var o = truncate((this.nh + this.nf * (k - this.nl) / this.nj));
            l = truncate(Math.floor(l));
            m = truncate(Math.floor(m));
            n = truncate(Math.floor(n));
            o = truncate(Math.floor(o));
            if (this.mr) {
                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.ot(f, s, t, q, r);
                }
            }
        }
        else {
            var u = a.a;
            var v = a.b;
            if (this.ms) {
                u = this.m0 + this.m2 * u;
                v = this.m1 + this.mz * v;
            }
            var w = truncate((this.ng + this.ni * (u - this.nk) / this.nm));
            var x = truncate((this.nh + this.nf * (v - this.nl) / this.nj));
            w = truncate(Math.floor(w));
            x = truncate(Math.floor(x));
            if (this.mr) {
                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.ot(f, af, ag, ad, ae);
                    }
                }
            }
            else {
                this.ot(f, w, x, b, 1);
            }
        }
    };
    HighDensityScatterSeries.prototype.nz = function (a, b) {
        return truncate((Math.floor(255 * b))) << 24 | truncate(Math.floor(b * (this.nb + a * this.ne))) << 16 | truncate(Math.floor(b * (this.na + a * this.nd))) << 8 | truncate(Math.floor(b * (this.m9 + a * this.nc)));
    };
    HighDensityScatterSeries.prototype.n0 = function (a) {
        return 255 << 24 | truncate(Math.floor((this.nb + a * this.ne))) << 16 | truncate(Math.floor((this.na + a * this.nd))) << 8 | truncate(Math.floor((this.m9 + a * this.nc)));
    };
    HighDensityScatterSeries.prototype.nn = function (a) {
        return (a >> 24 & 255) / 255;
    };
    HighDensityScatterSeries.prototype.ot = function (a, b, c, d, e) {
        if (b < 0 || b >= this.nu || c < 0 || c >= this.nt) {
            return;
        }
        var f = (c * this.nu) + b;
        this.md[f] = this.md[f] + d;
        this.ma[f] = this.ma[f] + e;
        if (this.mt) {
            this._itemIndexes[f] = a + 1;
        }
        this.nx += truncate(d);
    };
    HighDensityScatterSeries.prototype.or = function () {
        var a = 0;
        var b = 0;
        var c = this.m5;
        var d = this.m4;
        var e = this.m3;
        var f = this.md.length;
        var g = this.md;
        var h = this.ma;
        var i = this.mc;
        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.nz(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.ok = function (a) {
        var b = a;
        b.b3();
    };
    HighDensityScatterSeries.prototype.bf = function () {
        return new HighDensityScatterSeriesView(this);
    };
    HighDensityScatterSeries.prototype.i2 = function (a) {
        _super.prototype.i2.call(this, a);
        this.me = a;
    };
    HighDensityScatterSeries.prototype.an = function (a) {
        if (a != null && a == this.mh && this.mo != null) {
            return new AxisRange(this.mo.minimum, this.mo.maximum);
        }
        if (a != null && a == this.mj && this.mq != null) {
            return new AxisRange(this.mq.minimum, this.mq.maximum);
        }
        return null;
    };
    HighDensityScatterSeries.prototype.j0 = function (a, b) {
        if (this.bs != null) {
            var c = this.getEffectiveViewport1(this.bi);
            this.ms = !c.isEmpty;
        }
        this.jl(false);
    };
    HighDensityScatterSeries.prototype.j1 = function (a, b) {
        this.jl(false);
    };
    HighDensityScatterSeries.prototype.fp = function (a) {
        if (!this.mt || this._itemIndexes == null || this.bs == null || this.bz == null || this._itemIndexes.length != (this.nu * this.nt)) {
            return null;
        }
        var b = this.bs.n2;
        var c = (a.x - b.left) / b.width;
        var d = (a.y - b.top) / b.height;
        var e = truncate(Math.round(this.l8.left + (this.l8.width * c)));
        var f = truncate(Math.round(this.l8.top + (this.l8.height * d)));
        var g = this.n3(e, f);
        if (g < 0 || g > this._itemIndexes.length - 1) {
            return null;
        }
        var h = this._itemIndexes[g] - 1;
        if (h < 0 || h > this.bz.count) {
            return null;
        }
        return this.bz.item(h);
    };
    HighDensityScatterSeries.prototype.n3 = function (a, b) {
        var c = (this.nu * b) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        var d = 1;
        c = (this.nu * (b - d)) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nu * (b + d)) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nu * (b)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nu * (b)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nu * (b - d)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nu * (b + d)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nu * (b - d)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nu * (b + d)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        return 0;
    };
    HighDensityScatterSeries.prototype.ow = function (a, b, c) {
        this.mc = a;
        this.nu = b;
        this.nt = c;
    };
    HighDensityScatterSeries.prototype.get_dq = function () {
        return true;
    };
    HighDensityScatterSeries.prototype.set_dq = function (a) {
        _super.prototype.set_dq.call(this, a);
    };
    HighDensityScatterSeries.prototype.h3 = function (a, b) {
        _super.prototype.h3.call(this, a, b);
        this.me.b4();
        if (this.bh != null) {
            this.bh.b4();
        }
        this.it();
    };
    HighDensityScatterSeries.prototype.jn = function (a, b) {
        _super.prototype.jn.call(this, a, b);
        if (!this.dl) {
            this.bi.az(b);
            return;
        }
        this.bi.az(b);
        if (this.cc(this.bh)) {
            return;
        }
        var c = typeCast(HighDensityScatterSeriesView.$, this.bh);
        var d = new ScatterFrame();
        this.oo(false, c);
        this.dl = false;
    };
    HighDensityScatterSeries.prototype.jk = function (a, b, c, d, e) {
        _super.prototype.jk.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.mm == null) {
            this.mm = new ScatterFrame();
        }
        this.oo(false, f);
    };
    HighDensityScatterSeries.prototype.h1 = function () {
        _super.prototype.h1.call(this);
        this.mh = null;
        this.mj = null;
    };
    HighDensityScatterSeries.$t = markType(HighDensityScatterSeries, 'HighDensityScatterSeries', Series.$);
    HighDensityScatterSeries.$$p = markDep(DependencyProperty, PropertyMetadata, HighDensityScatterSeries, 'raisePropertyChanged', ['HeatMaximumColor:o9:oy', [Color.$, null], 'HeatMaximum:no:oz', [1, 50], 'HeatMinimumColor:pa:o0', [Color.$, null], 'HeatMinimum:np:o1', [1, 0], 'PointExtent:n1:o2', [1, 1], 'ProgressiveLoad:mw:o3', [0, true], 'UseBruteForce:mx:o4', [0, false], 'XAxis:mh:o5', [NumericXAxis.$, null], 'XMemberPath:od:o6', [2, null], 'YAxis:mj:o7', [NumericYAxis.$, null], 'YMemberPath:oh:o8', [2, null]]);
    return HighDensityScatterSeries;
}(Series));
export { HighDensityScatterSeries };
/**
 * @hidden
 */
var HighDensityScatterSeriesView = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(HighDensityScatterSeriesView, _super);
    function HighDensityScatterSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.bw = null;
        _this.bu = null;
        _this.b2 = 0;
        _this.b1 = 0;
        _this.bz = null;
        _this.b0 = null;
        _this.bx = null;
        _this.bw = a;
        return _this;
    }
    HighDensityScatterSeriesView.prototype.ap = function () {
        _super.prototype.ap.call(this);
        if (!this.n) {
            this.e.eu = 4;
            this.bw.pa = Color.u(255, 0, 0, 0);
            this.bw.o9 = Color.u(255, 255, 0, 0);
        }
    };
    HighDensityScatterSeriesView.prototype.b7 = function () {
        this.bw.ow(this.bu, this.b2, this.b1);
    };
    HighDensityScatterSeriesView.prototype.b3 = function () {
        if (this.bz == null) {
            this.bz = this.e.e4.createElement("canvas");
            var a = this.e.e4.get2DCanvasContext(this.bz);
            this.bx = new RenderingContext(new CanvasViewRenderer(), a);
        }
        var b;
        if (this.m) {
            b = this.br;
        }
        else {
            b = this.e.bs.n7();
        }
        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.b2;
        var h = this.b1;
        this.b2 = e;
        this.b1 = f;
        if (g != this.b2 || h != this.b1 || this.bu == null) {
            this.bz.setAttribute("width", e.toString());
            this.bz.setAttribute("height", f.toString());
            this.b0 = this.bx.g().getImageData(0, 0, e, f);
            var imageDataArray_ = this.b0.data;
            this.bu = imageDataArray_;
        }
        this.bw.ow(this.bu, this.b2, this.b1);
    };
    HighDensityScatterSeriesView.prototype.bv = function () {
        return this.bu;
    };
    HighDensityScatterSeriesView.prototype.b6 = function () {
        var a = truncate(Math.round(this.br.left));
        var b = truncate(Math.round(this.br.left));
        var c = truncate(Math.round(this.br.width));
        var d = truncate(Math.round(this.br.height));
        this.bx.g().putImageData(this.b0, 0, 0);
        this.an();
    };
    HighDensityScatterSeriesView.prototype.b5 = function (a) {
        if (this.e.e4 != null) {
            this.e.e4.setTimeout(a, 0);
        }
        else {
            window.setTimeout(a, 0);
        }
    };
    HighDensityScatterSeriesView.prototype.a3 = function (a, b) {
        _super.prototype.a3.call(this, a, b);
        if (b) {
            if (!this.bw.c7) {
                return;
            }
            var c = new Rectangle();
            c.n = this.br.left;
            c.o = this.br.top;
            c.width = this.br.width;
            c.height = this.br.height;
            c._fill = this.bl();
            a.v(c);
            return;
        }
        if (this.bz == null) {
            return;
        }
        var d = truncate(Math.round(this.br.left));
        var e = truncate(Math.round(this.br.top));
        var f = truncate(Math.round(this.br.width));
        var g = truncate(Math.round(this.br.height));
        this.h.n(this.bz.getNativeElement(), this.e._opacity, d, e, f, g, d, e, f, g);
    };
    HighDensityScatterSeriesView.prototype.by = function (a, b) {
        return Color.e(toNullable(Color.$, a), toNullable(Color.$, null)) && Color.e(toNullable(Color.$, b), toNullable(Color.$, null));
    };
    HighDensityScatterSeriesView.prototype.b4 = function () {
        if (this.bu != null) {
            for (var a = 0; a < this.bu.length; a++) {
                this.bu[a] = 0;
            }
            this.b6();
        }
    };
    HighDensityScatterSeriesView.prototype.ai = function (a) {
        _super.prototype.ai.call(this, a);
        if (this.bu == null) {
            this.e.a2.exportSeriesPixelsData(a, null, this.b2, this.b1);
            return;
        }
        var b = new Array(intDivide(this.bu.length, 4));
        var c;
        for (var d = 0; d < intDivide(this.bu.length, 4); d++) {
            c = d * 4;
            b[d] = this.bu[c + 3] << 24 | this.bu[c] << 16 | this.bu[c + 1] << 8 | this.bu[c + 2];
        }
        this.e.a2.exportSeriesPixelsData(a, b, this.b2, this.b1);
    };
    HighDensityScatterSeriesView.$t = markType(HighDensityScatterSeriesView, 'HighDensityScatterSeriesView', SeriesView.$);
    return HighDensityScatterSeriesView;
}(SeriesView));
export { HighDensityScatterSeriesView };
//# sourceMappingURL=HighDensityScatterSeries_combined.js.map
