/*
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.om = null;
        _this.oo = null;
        _this.pu = 0;
        _this.oq = false;
        _this.pa = 0;
        _this.o9 = 0;
        _this.o8 = 0;
        _this.o7 = 255;
        _this.o6 = 0;
        _this.o5 = 0;
        _this.pd = 255;
        _this.pc = 0;
        _this.pb = 0;
        _this.oe = null;
        _this.oj = null;
        _this.ok = null;
        _this.of = null;
        _this.oh = null;
        _this.os = false;
        _this.pv = 0;
        _this.px = 0;
        _this.pr = 0;
        _this.pq = 0;
        _this.progressiveLoadStatusChanged = null;
        _this.ox = null;
        _this.o3 = 0;
        _this.o2 = 0;
        _this.o4 = 0;
        _this.pg = 0;
        _this.pe = 0;
        _this.pf = 0;
        _this.ph = 0;
        _this.pj = 0;
        _this.pl = 0;
        _this.pk = 0;
        _this.pi = 0;
        _this.oz = 0;
        _this.o0 = 0;
        _this.o1 = 0;
        _this.oy = 0;
        _this.pt = 0;
        _this.ps = 0;
        _this.ob = null;
        _this.pw = 0;
        _this.or = false;
        _this._itemIndexes = null;
        _this.oc = null;
        _this.n9 = null;
        _this.ol = null;
        _this.ab = HighDensityScatterSeries.$;
        _this.dn = false;
        return _this;
    }
    HighDensityScatterSeries.prototype.get_dj = function () {
        return true;
    };
    Object.defineProperty(HighDensityScatterSeries.prototype, "on", {
        get: function () {
            return this.om;
        },
        set: function (a) {
            if (this.om != a) {
                var b = this.on;
                this.om = a;
                this.raisePropertyChanged("XColumn", b, this.on);
            }
        },
        enumerable: true,
        configurable: true
    });
    HighDensityScatterSeries.prototype.gt = function (a, b) {
        var c = this.ic(b);
        if (c == HighDensityScatterSeries.$$p[8]) {
            return this.gu(a, b, this.qc);
        }
        if (c == HighDensityScatterSeries.$$p[10]) {
            return this.gu(a, b, this.qg);
        }
        return _super.prototype.gt.call(this, a, b);
    };
    Object.defineProperty(HighDensityScatterSeries.prototype, "op", {
        get: function () {
            return this.oo;
        },
        set: function (a) {
            if (this.oo != a) {
                var b = this.op;
                this.oo = a;
                this.raisePropertyChanged("YColumn", b, this.op);
            }
        },
        enumerable: true,
        configurable: true
    });
    HighDensityScatterSeries.prototype.qu = function () {
        if (this.oe == null) {
            return;
        }
        this.oe.s();
        var a = this.oe;
        a.progressiveThunkCompleted = delegateRemove(a.progressiveThunkCompleted, runOn(this, this.qi));
        this.oe = null;
    };
    HighDensityScatterSeries.prototype.kp = function (a, b, c, d) {
        _super.prototype.kp.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                if (this.b6 != null) {
                    var e = this.getEffectiveViewport1(this.bs);
                    this.or = !e.isEmpty;
                }
                break;
            case "FastItemsSource":
                this.qu();
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.on);
                    c.deregisterColumn(this.op);
                    this.on = null;
                    this.op = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.on = this.ca(this.qc);
                    this.op = this.ca(this.qg);
                }
                if ((this.oi != null && !this.oi.cn()) || (this.og != null && !this.og.cn())) {
                    this.k3(false);
                }
                this.kb();
                break;
            case HighDensityScatterSeries.$$p[7]:
                var f = this.of;
                this.of = this.og;
                this.qu();
                if (f != null) {
                    f.rangeChanged = delegateRemove(f.rangeChanged, runOn(this, this.ql));
                }
                if (this.of != null) {
                    var g = this.of;
                    g.rangeChanged = delegateCombine(g.rangeChanged, runOn(this, this.ql));
                }
                if (c != null) {
                    c.bx(this);
                }
                if (d != null) {
                    d.ck(this);
                }
                if ((this.og != null && !this.og.cn()) || (d == null && c != null)) {
                    this.k3(false);
                }
                break;
            case HighDensityScatterSeries.$$p[9]:
                var h = this.oh;
                this.oh = this.oi;
                this.qu();
                if (h != null) {
                    h.rangeChanged = delegateRemove(h.rangeChanged, runOn(this, this.ql));
                }
                if (this.oh != null) {
                    var i = this.oh;
                    i.rangeChanged = delegateCombine(i.rangeChanged, runOn(this, this.ql));
                }
                if (c != null) {
                    c.bx(this);
                }
                if (d != null) {
                    d.ck(this);
                }
                if ((this.oi != null && !this.oi.cn()) || (d == null && c != null)) {
                    this.k3(false);
                }
                break;
            case "MouseOverEnabled":
                this.os = this.dn;
                this.k3(false);
                break;
            case HighDensityScatterSeries.$$p[8]:
                if (this.cd != null) {
                    this.cd.deregisterColumn(this.on);
                    this.on = this.ca(this.qc);
                }
                break;
            case "XColumn":
                this.qu();
                if (this.og != null && !this.og.cn()) {
                    this.k3(false);
                }
                this.kb();
                break;
            case HighDensityScatterSeries.$$p[10]:
                if (this.cd != null) {
                    this.cd.deregisterColumn(this.op);
                    this.op = this.ca(this.qg);
                }
                break;
            case "YColumn":
                this.qu();
                if (this.oi != null && !this.oi.cn()) {
                    this.k3(false);
                }
                this.kb();
                break;
            case HighDensityScatterSeries.$$p[6]:
                this.qu();
                this.k3(false);
                this.ka();
                break;
            case HighDensityScatterSeries.$$p[3]:
                this.k3(false);
                this.ka();
                break;
            case HighDensityScatterSeries.$$p[1]:
                this.k3(false);
                this.ka();
                break;
            case HighDensityScatterSeries.$$p[0]:
            case HighDensityScatterSeries.$$p[2]:
                if (!this.od.b1(this.q9, this.q8)) {
                    return;
                }
                this.pa = this.q9.o;
                this.o9 = this.q9.n;
                this.o8 = this.q9.m;
                this.o7 = this.q8.o;
                this.o6 = this.q8.n;
                this.o5 = this.q8.m;
                this.pd = this.o7 - this.pa;
                this.pc = this.o6 - this.o9;
                this.pb = this.o5 - this.o8;
                this.k3(false);
                this.ka();
                break;
            case HighDensityScatterSeries.$$p[4]:
                this.pu = Math.max(typeGetValue(d) - 1, 0);
                this.oq = this.pu > 0;
                this.k3(false);
                this.ka();
                break;
            case HighDensityScatterSeries.$$p[5]:
                this.k3(false);
                this.ka();
                break;
        }
    };
    HighDensityScatterSeries.prototype.ou = function (a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    HighDensityScatterSeries.prototype.ot = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    HighDensityScatterSeries.prototype.ql = function (a, b) {
        this.qu();
        this.k3(false);
    };
    HighDensityScatterSeries.prototype.ec = function (a, b, c) {
        var d = _super.prototype.ec.call(this, a, b, c);
        if (this.oi == null || this.og == null || this.og.bh == null || this.oi.bh == null || this.op == null || this.on == null || this.op.count < 1 || this.on.count < 1 || this.op.count != this.on.count || this.og.kd == this.og.kc || this.oi.kd == this.oi.kc || this.n6.isEmpty) {
            d = false;
        }
        return d;
    };
    Object.defineProperty(HighDensityScatterSeries.prototype, "p1", {
        get: function () {
            return this.pv;
        },
        set: function (a) {
            var b = this.pv;
            this.pv = a;
            this.raisePropertyChanged("ProgressiveStatus", b, this.pv);
        },
        enumerable: true,
        configurable: true
    });
    HighDensityScatterSeries.prototype.k4 = function (a) {
        _super.prototype.k4.call(this, a);
        this.qn(a, this.bs);
    };
    HighDensityScatterSeries.prototype.qn = function (a, b) {
        if (this.cp(b)) {
            return;
        }
        if (this.oe == null && !this.ow) {
            var c = new List$1(KDPointData.$, 2, this.on.count);
            var d = this.og;
            var e = this.oi;
            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.dz(this_1.on.item(l), h);
                k_1 = e.dz(this_1.op.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.on.count; l++) {
                _loop_1(l);
            }
            if (this.ov) {
                this.pq = 1;
                this.pr = truncate(logBase(c.count, 2)) + 3;
                this.p1 = truncate(((this.pq / this.pr) * 100));
                if (this.progressiveLoadStatusChanged != null) {
                    this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.p1));
                }
                this.oe = KDTree2D.b(c.toArray(), 1);
                var m = this.oe;
                m.progressiveThunkCompleted = delegateCombine(m.progressiveThunkCompleted, runOn(this, this.qi));
                if (!this.oe.f(this.f5)) {
                    var n = this.oe;
                    n.progressiveThunkCompleted = delegateRemove(n.progressiveThunkCompleted, runOn(this, this.qi));
                }
                this.ka();
            }
            else {
                var o = dateNow();
                this.oe = new KDTree2D(0, c.toArray(), 1);
                var p = dateNow();
            }
        }
        if (this.ov && !this.ow) {
            this.qo(b);
        }
        else {
            this.qp(b);
        }
    };
    HighDensityScatterSeries.prototype.jo = function (a, b, c, d) {
        _super.prototype.jo.call(this, a, b, c, d);
        this.qu();
        var e = false;
        if (this.og != null && !this.og.cn()) {
            e = true;
        }
        if (this.oi != null && !this.oi.cn()) {
            e = true;
        }
        if (e) {
            this.k3(false);
        }
        this.kb();
    };
    HighDensityScatterSeries.prototype.qk = function (a) {
        var b = a;
        var c = this.pt * this.ps;
        if (this.os) {
            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.qp = 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.oj = new ScalerParams(0, b, c, this.of.ca, g);
        this.ok = new ScalerParams(0, b, c, this.oh.ca, g);
        this.qj(a);
        this.qk(a);
        var h = this.pt * this.ps;
        if (this.oc == null || this.oc.length != h) {
            this.oc = new Array(h);
            this.n9 = new Array(h);
        }
        var i = this.oc.length;
        var j = this.oc;
        var k = this.n9;
        for (var l = 0; l < i; l++) {
            j[l] = 0;
            k[l] = 0;
        }
        this.px = truncate(Math.round(this.fq));
        this.ob = f.by();
        var m = this.ob.length;
        var n = this.ob;
        for (var o = 0; o < m; o++) {
            n[o] = 0;
        }
        var p = this.po;
        var q = this.pn;
        if (isNaN_(p) || isInfinity(p)) {
            p = 0;
        }
        if (isNaN_(q) || isInfinity(q)) {
            q = 50;
        }
        this.o3 = Math.min(p, q);
        this.o2 = Math.max(p, q);
        if (this.o3 < 0) {
            this.o3 = 0;
        }
        if (this.o2 < 0) {
            this.o2 = 0;
        }
        this.o4 = this.o2 - this.o3;
        if (this.ow) {
            this.qm(a);
        }
        else {
            this.qw(a);
        }
        f.b9();
        if (a.q) {
            this._itemIndexes = d;
            this.od.ca();
        }
    };
    HighDensityScatterSeries.prototype.qo = function (a) {
        if (this.oe == null) {
            return;
        }
        this.qp(a);
    };
    HighDensityScatterSeries.prototype.qi = function (a, b) {
        var _this = this;
        this.od.b8(function () {
            if (_this.pq < _this.pr - 1) {
                _this.pq++;
            }
            _this.p1 = truncate(((_this.pq / _this.pr) * 100));
            if (_this.progressiveLoadStatusChanged != null) {
                _this.progressiveLoadStatusChanged(_this, new ProgressiveLoadStatusEventArgs(_this.p1));
            }
            _this.qo(_this.bs);
            _this.ka();
            if (_this.oe != null) {
                if (!_this.oe.f(_this.f5)) {
                    var c = _this.oe;
                    c.progressiveThunkCompleted = delegateRemove(c.progressiveThunkCompleted, runOn(_this, _this.qi));
                    _this.p1 = 100;
                    if (_this.progressiveLoadStatusChanged != null) {
                        _this.progressiveLoadStatusChanged(_this, new ProgressiveLoadStatusEventArgs(_this.p1));
                    }
                }
            }
        });
    };
    HighDensityScatterSeries.prototype.qm = function (a) {
        var b = arrayShallowClone(this.on.asArray());
        this.og.gt(boxArray$1(b), 0, b.length, this.oj);
        var c = arrayShallowClone(this.op.asArray());
        this.pw = 0;
        var d = this.pu;
        var e = this.oq;
        var f = this.oc.length;
        this.oi.gt(boxArray$1(c), 0, c.length, this.ok);
        var g = 255 << 24 | truncate(this.pa) << 16 | truncate(this.o9) << 8 | truncate(this.o8);
        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.pt || j < 0 || j >= this.ps) {
                continue;
            }
            if (e) {
                var k = i - d;
                var l = i + d;
                l = l > (this.pt - 1) ? (this.pt - 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.pt) + o;
                        if (q < 0 || q > f - 1) {
                            continue;
                        }
                        this.oc[q] = this.oc[q] + 1;
                        this.n9[q] = 1;
                        this.pw++;
                        if (this.os) {
                            this._itemIndexes[q] = h + 1;
                        }
                    }
                }
            }
            else {
                var r = (j * this.pt) + i;
                this.oc[r] = this.oc[r] + 1;
                this.n9[r] = 1;
                this.pw++;
                if (this.os) {
                    this._itemIndexes[r] = h + 1;
                }
            }
        }
        this.qq();
    };
    HighDensityScatterSeries.prototype.qw = function (a) {
        var b;
        var c;
        var d = a.getViewInfo(b, c);
        b = d.p0;
        c = d.p1;
        if (this.oe == null) {
            return;
        }
        if (this.ox == null) {
            this.ox = new List$1(KDTreeNode2D.$, 2, truncate(Math.round(b.width * b.height)));
        }
        else {
            this.ox.clear();
        }
        var e = c.left;
        var f = c.right;
        var g = c.top;
        var h = c.bottom;
        this.pk = c.top;
        this.pi = c.height;
        this.pj = c.left;
        this.pl = c.width;
        this.pg = b.top;
        this.pe = b.height;
        this.pf = b.left;
        this.ph = b.width;
        var i = this.getEffectiveViewport1(a);
        this.oz = (i.left - this.pf) / this.ph;
        this.o0 = (i.top - this.pg) / this.pe;
        var j = (i.right - this.pf) / this.ph;
        this.o1 = j - this.oz;
        var k = (i.bottom - this.pg) / this.pe;
        this.oy = k - this.o0;
        if (this.or) {
            e = (e - this.oz) / this.o1;
            f = (f - this.oz) / this.o1;
            g = (g - this.o0) / this.oy;
            h = (h - this.o0) / this.oy;
        }
        var l = this.fq / b.width * c.width;
        var m = this.fq / 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.oe.t(this.ox, o, 0, 1, 0, 1);
        var p;
        this.pw = 0;
        for (var q = 0; q < this.ox.count; q++) {
            p = this.ox._inner[q];
            this.qr(p);
        }
        this.qq();
    };
    HighDensityScatterSeries.prototype.qr = 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.qt(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.qt(e, d, false, a.e);
            }
        }
        if (a.e != null) {
            a.e.a = false;
        }
    };
    HighDensityScatterSeries.prototype.dq = function (a) {
        var b = this.b6 != null ? this.b6.os : Rect.empty;
        var c = this.b6 != null ? this.b6.o7 : Rect.empty;
        var d = new Rect(0, 0, 0, 1, 1);
        var e = this.n0(this.bs);
        var f = new ScalerParams(0, d, d, this.og.ca, e);
        var g = new ScalerParams(0, d, d, this.oi.ca, e);
        var h = !b.isEmpty && !c.isEmpty && this.cd != null ? this.cd.indexOf(a) : -1;
        var i = this.og != null && this.on != null && h < this.on.count ? this.og.dz(this.on.item(h), f) : NaN;
        var j = this.oi != null && this.op != null && h < this.op.count ? this.oi.dz(this.op.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.b1 != null) {
            this.b1.ap(this.b6, b, true);
        }
        return h >= 0;
    };
    HighDensityScatterSeries.prototype.qt = function (a, b, c, d) {
        var e = this.pz(b);
        var f = a.c;
        var g = this.pu;
        if (c) {
            var h = d.d;
            var i = d.b;
            var j = d.e;
            var k = d.c;
            if (this.or) {
                h = this.oz + this.o1 * h;
                i = this.oz + this.o1 * i;
                j = this.o0 + this.oy * j;
                k = this.o0 + this.oy * k;
            }
            var l = truncate((this.pf + this.ph * (h - this.pj) / this.pl));
            var m = truncate((this.pf + this.ph * (i - this.pj) / this.pl));
            var n = truncate((this.pg + this.pe * (j - this.pk) / this.pi));
            var o = truncate((this.pg + this.pe * (k - this.pk) / this.pi));
            l = truncate(Math.floor(l));
            m = truncate(Math.floor(m));
            n = truncate(Math.floor(n));
            o = truncate(Math.floor(o));
            if (this.oq) {
                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.qs(f, s, t, q, r);
                }
            }
        }
        else {
            var u = a.a;
            var v = a.b;
            if (this.or) {
                u = this.oz + this.o1 * u;
                v = this.o0 + this.oy * v;
            }
            var w = truncate((this.pf + this.ph * (u - this.pj) / this.pl));
            var x = truncate((this.pg + this.pe * (v - this.pk) / this.pi));
            w = truncate(Math.floor(w));
            x = truncate(Math.floor(x));
            if (this.oq) {
                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.qs(f, af, ag, ad, ae);
                    }
                }
            }
            else {
                this.qs(f, w, x, b, 1);
            }
        }
    };
    HighDensityScatterSeries.prototype.py = function (a, b) {
        return truncate((Math.floor(255 * b))) << 24 | truncate(Math.floor(b * (this.pa + a * this.pd))) << 16 | truncate(Math.floor(b * (this.o9 + a * this.pc))) << 8 | truncate(Math.floor(b * (this.o8 + a * this.pb)));
    };
    HighDensityScatterSeries.prototype.pz = function (a) {
        return 255 << 24 | truncate(Math.floor((this.pa + a * this.pd))) << 16 | truncate(Math.floor((this.o9 + a * this.pc))) << 8 | truncate(Math.floor((this.o8 + a * this.pb)));
    };
    HighDensityScatterSeries.prototype.pm = function (a) {
        return (a >> 24 & 255) / 255;
    };
    HighDensityScatterSeries.prototype.qs = function (a, b, c, d, e) {
        if (b < 0 || b >= this.pt || c < 0 || c >= this.ps) {
            return;
        }
        var f = (c * this.pt) + b;
        this.oc[f] = this.oc[f] + d;
        this.n9[f] = this.n9[f] + e;
        if (this.os) {
            this._itemIndexes[f] = a + 1;
        }
        this.pw += truncate(d);
    };
    HighDensityScatterSeries.prototype.qq = function () {
        var a = 0;
        var b = 0;
        var c = this.o4;
        var d = this.o3;
        var e = this.o2;
        var f = this.oc.length;
        var g = this.oc;
        var h = this.n9;
        var i = this.ob;
        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.py(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.qj = function (a) {
        var b = a;
        b.b6();
    };
    HighDensityScatterSeries.prototype.bp = function () {
        return new HighDensityScatterSeriesView(this);
    };
    HighDensityScatterSeries.prototype.kk = function (a) {
        _super.prototype.kk.call(this, a);
        this.od = a;
    };
    HighDensityScatterSeries.prototype.ao = function (a) {
        if (a != null && a == this.og && this.on != null) {
            return new AxisRange(this.on.minimum, this.on.maximum);
        }
        if (a != null && a == this.oi && this.op != null) {
            return new AxisRange(this.op.minimum, this.op.maximum);
        }
        return null;
    };
    HighDensityScatterSeries.prototype.ln = function (a, b) {
        if (this.b6 != null) {
            var c = this.getEffectiveViewport1(this.bs);
            this.or = !c.isEmpty;
        }
        this.k3(false);
    };
    HighDensityScatterSeries.prototype.lo = function (a, b) {
        this.k3(false);
    };
    HighDensityScatterSeries.prototype.gq = function (a) {
        if (!this.os || this._itemIndexes == null || this.b6 == null || this.cd == null || this._itemIndexes.length != (this.pt * this.ps)) {
            return null;
        }
        var b = this.b6.os;
        var c = (a.x - b.left) / b.width;
        var d = (a.y - b.top) / b.height;
        var e = truncate(Math.round(this.n6.left + (this.n6.width * c)));
        var f = truncate(Math.round(this.n6.top + (this.n6.height * d)));
        var g = this.p2(e, f);
        if (g < 0 || g > this._itemIndexes.length - 1) {
            return null;
        }
        var h = this._itemIndexes[g] - 1;
        if (h < 0 || h > this.cd.count) {
            return null;
        }
        return this.cd.item(h);
    };
    HighDensityScatterSeries.prototype.p2 = function (a, b) {
        var c = (this.pt * b) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        var d = 1;
        c = (this.pt * (b - d)) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.pt * (b + d)) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.pt * (b)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.pt * (b)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.pt * (b - d)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.pt * (b + d)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.pt * (b - d)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.pt * (b + d)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        return 0;
    };
    HighDensityScatterSeries.prototype.qv = function (a, b, c) {
        this.ob = a;
        this.pt = b;
        this.ps = c;
    };
    HighDensityScatterSeries.prototype.get_d6 = function () {
        return true;
    };
    HighDensityScatterSeries.prototype.set_d6 = function (a) {
        _super.prototype.set_d6.call(this, a);
    };
    HighDensityScatterSeries.prototype.jl = function (a, b) {
        _super.prototype.jl.call(this, a, b);
        this.od.b7();
        if (this.br != null) {
            this.br.b7();
        }
        this.ka();
    };
    HighDensityScatterSeries.prototype.k5 = function (a, b) {
        _super.prototype.k5.call(this, a, b);
        if (!this.d2) {
            this.bs.a2(b);
            return;
        }
        this.bs.a2(b);
        if (this.cp(this.br)) {
            return;
        }
        var c = typeCast(HighDensityScatterSeriesView.$, this.br);
        var d = new ScatterFrame();
        this.qn(false, c);
        this.d2 = false;
    };
    HighDensityScatterSeries.prototype.k2 = function (a, b, c, d, e) {
        _super.prototype.k2.call(this, a, b, c, d, e);
        var f = this.a3.a$h.item(d);
        var g = f;
        f.a1(c);
        if (this.cp(g)) {
            return;
        }
        if (this.ol == null) {
            this.ol = new ScatterFrame();
        }
        this.qn(false, f);
    };
    HighDensityScatterSeries.prototype.ji = function () {
        _super.prototype.ji.call(this);
        this.og = null;
        this.oi = null;
    };
    HighDensityScatterSeries.$t = markType(HighDensityScatterSeries, 'HighDensityScatterSeries', Series.$);
    HighDensityScatterSeries.$$p = markDep(DependencyProperty, PropertyMetadata, HighDensityScatterSeries, 'raisePropertyChanged', ['HeatMaximumColor:q8:qx', [Color.$, null], 'HeatMaximum:pn:qy', [1, 50], 'HeatMinimumColor:q9:qz', [Color.$, null], 'HeatMinimum:po:q0', [1, 0], 'PointExtent:p0:q1', [1, 1], 'ProgressiveLoad:ov:q2', [0, true], 'UseBruteForce:ow:q3', [0, false], 'XAxis:og:q4', [NumericXAxis.$, null], 'XMemberPath:qc:q5', [2, null], 'YAxis:oi:q6', [NumericYAxis.$, null], 'YMemberPath:qg:q7', [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.bz = null;
        _this.bx = null;
        _this.b5 = 0;
        _this.b4 = 0;
        _this.b2 = null;
        _this.b3 = null;
        _this.b0 = null;
        _this.bz = a;
        return _this;
    }
    HighDensityScatterSeriesView.prototype.as = function () {
        _super.prototype.as.call(this);
        if (!this.q) {
            this.e.fq = 4;
            this.bz.q9 = Color.u(255, 238, 88, 121);
            this.bz.q8 = Color.u(255, 139, 91, 177);
        }
    };
    HighDensityScatterSeriesView.prototype.ca = function () {
        this.bz.qv(this.bx, this.b5, this.b4);
    };
    HighDensityScatterSeriesView.prototype.b6 = function () {
        if (this.b2 == null) {
            this.b2 = this.e.f5.createElement("canvas");
            var a = this.e.f5.get2DCanvasContext(this.b2);
            this.b0 = new RenderingContext(new CanvasViewRenderer(), a);
        }
        var b;
        if (this.p) {
            b = this.bu;
        }
        else {
            b = this.e.b6.ox();
        }
        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.b5;
        var h = this.b4;
        this.b5 = e;
        this.b4 = f;
        if (g != this.b5 || h != this.b4 || this.bx == null) {
            this.b2.setAttribute("width", e.toString());
            this.b2.setAttribute("height", f.toString());
            this.b3 = this.b0.g().getImageData(0, 0, e, f);
            var imageDataArray_ = this.b3.data;
            this.bx = imageDataArray_;
        }
        this.bz.qv(this.bx, this.b5, this.b4);
    };
    HighDensityScatterSeriesView.prototype.by = function () {
        return this.bx;
    };
    HighDensityScatterSeriesView.prototype.b9 = function () {
        var a = truncate(Math.round(this.bu.left));
        var b = truncate(Math.round(this.bu.left));
        var c = truncate(Math.round(this.bu.width));
        var d = truncate(Math.round(this.bu.height));
        this.b0.g().putImageData(this.b3, 0, 0);
        this.aq();
    };
    HighDensityScatterSeriesView.prototype.b8 = function (a) {
        if (this.e.f5 != null) {
            this.e.f5.setTimeout(a, 0);
        }
        else {
            window.setTimeout(a, 0);
        }
    };
    HighDensityScatterSeriesView.prototype.a6 = function (a, b) {
        _super.prototype.a6.call(this, a, b);
        if (b) {
            if (!this.bz.dn) {
                return;
            }
            var c = new Rectangle();
            c.n = this.bu.left;
            c.o = this.bu.top;
            c.width = this.bu.width;
            c.height = this.bu.height;
            c._fill = this.bo();
            a.v(c);
            return;
        }
        if (this.b2 == null) {
            return;
        }
        var d = truncate(Math.round(this.bu.left));
        var e = truncate(Math.round(this.bu.top));
        var f = truncate(Math.round(this.bu.width));
        var g = truncate(Math.round(this.bu.height));
        this.k.n(this.b2.getNativeElement(), this.e._opacity, d, e, f, g, d, e, f, g);
    };
    HighDensityScatterSeriesView.prototype.b1 = function (a, b) {
        return Color.e(toNullable(Color.$, a), toNullable(Color.$, null)) && Color.e(toNullable(Color.$, b), toNullable(Color.$, null));
    };
    HighDensityScatterSeriesView.prototype.b7 = function () {
        if (this.bx != null) {
            for (var a = 0; a < this.bx.length; a++) {
                this.bx[a] = 0;
            }
            this.b9();
        }
    };
    HighDensityScatterSeriesView.prototype.al = function (a) {
        _super.prototype.al.call(this, a);
        if (this.bx == null) {
            this.e.a5.exportSeriesPixelsData(a, null, this.b5, this.b4);
            return;
        }
        var b = new Array(intDivide(this.bx.length, 4));
        var c;
        for (var d = 0; d < intDivide(this.bx.length, 4); d++) {
            c = d * 4;
            b[d] = this.bx[c + 3] << 24 | this.bx[c] << 16 | this.bx[c + 1] << 8 | this.bx[c + 2];
        }
        this.e.a5.exportSeriesPixelsData(a, b, this.b5, this.b4);
    };
    HighDensityScatterSeriesView.$t = markType(HighDensityScatterSeriesView, 'HighDensityScatterSeriesView', SeriesView.$);
    return HighDensityScatterSeriesView;
}(SeriesView));
export { HighDensityScatterSeriesView };
//# sourceMappingURL=HighDensityScatterSeries_combined.js.map
