/*
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-angular-core";
import { NumericYAxis } from "./NumericYAxis";
import { Color } from "igniteui-angular-core";
import { ScatterFrame } from "./ScatterFrame";
import { KDTree2D } from "./KDTree2D";
import { typeGetValue, runOn, delegateRemove, typeCast, delegateCombine, markType, markDep, toNullable } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { IFastItemsSource_$type } from "igniteui-angular-core";
import { SeriesView } from "./SeriesView";
import { List$1 } from "igniteui-angular-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-angular-core";
import { truncate, isNaN_, isInfinity, logBase, intDivide } from "igniteui-angular-core";
import { boxArray$1, arrayShallowClone } from "igniteui-angular-core";
import { dateNow } from "igniteui-angular-core";
import { RenderingContext } from "igniteui-angular-core";
import { CanvasViewRenderer } from "igniteui-angular-core";
import { Rectangle } from "igniteui-angular-core";
/**
 * @hidden
 */
var HighDensityScatterSeries = /** @class */ (function (_super) {
    tslib_1.__extends(HighDensityScatterSeries, _super);
    function HighDensityScatterSeries() {
        var _this = _super.call(this) || this;
        _this.md = null;
        _this.mf = null;
        _this.nl = 0;
        _this.mh = false;
        _this.m1 = 0;
        _this.m0 = 0;
        _this.mz = 0;
        _this.my = 255;
        _this.mx = 0;
        _this.mw = 0;
        _this.m4 = 255;
        _this.m3 = 0;
        _this.m2 = 0;
        _this.l5 = null;
        _this.ma = null;
        _this.mb = null;
        _this.l6 = null;
        _this.l8 = null;
        _this.mj = false;
        _this.nm = 0;
        _this.no = 0;
        _this.ni = 0;
        _this.nh = 0;
        _this.progressiveLoadStatusChanged = null;
        _this.mo = null;
        _this.mu = 0;
        _this.mt = 0;
        _this.mv = 0;
        _this.m7 = 0;
        _this.m5 = 0;
        _this.m6 = 0;
        _this.m8 = 0;
        _this.na = 0;
        _this.nc = 0;
        _this.nb = 0;
        _this.m9 = 0;
        _this.mq = 0;
        _this.mr = 0;
        _this.ms = 0;
        _this.mp = 0;
        _this.nk = 0;
        _this.nj = 0;
        _this.l2 = null;
        _this.nn = 0;
        _this.mi = false;
        _this._itemIndexes = null;
        _this.l3 = null;
        _this.l0 = null;
        _this.mc = null;
        _this.ab = HighDensityScatterSeries.$;
        _this.c7 = false;
        return _this;
    }
    HighDensityScatterSeries.prototype.get_c4 = function () {
        return true;
    };
    Object.defineProperty(HighDensityScatterSeries.prototype, "me", {
        get: function () {
            return this.md;
        },
        set: function (a) {
            if (this.md != a) {
                var b = this.me;
                this.md = a;
                this.raisePropertyChanged("XColumn", b, this.me);
            }
        },
        enumerable: true,
        configurable: true
    });
    HighDensityScatterSeries.prototype.fs = function (a, b) {
        var c = this.gu(b);
        if (c == HighDensityScatterSeries.$$p[8]) {
            return this.ft(a, b, this.n3);
        }
        if (c == HighDensityScatterSeries.$$p[10]) {
            return this.ft(a, b, this.n7);
        }
        return _super.prototype.fs.call(this, a, b);
    };
    Object.defineProperty(HighDensityScatterSeries.prototype, "mg", {
        get: function () {
            return this.mf;
        },
        set: function (a) {
            if (this.mf != a) {
                var b = this.mg;
                this.mf = a;
                this.raisePropertyChanged("YColumn", b, this.mg);
            }
        },
        enumerable: true,
        configurable: true
    });
    HighDensityScatterSeries.prototype.ol = function () {
        if (this.l5 == null) {
            return;
        }
        this.l5.s();
        var a = this.l5;
        a.progressiveThunkCompleted = delegateRemove(a.progressiveThunkCompleted, runOn(this, this.n9));
        this.l5 = null;
    };
    HighDensityScatterSeries.prototype.iz = function (a, b, c, d) {
        _super.prototype.iz.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                if (this.bs != null) {
                    var e = this.getEffectiveViewport1(this.bi);
                    this.mi = !e.isEmpty;
                }
                break;
            case "FastItemsSource":
                this.ol();
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.me);
                    c.deregisterColumn(this.mg);
                    this.me = null;
                    this.mg = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.me = this.bw(this.n3);
                    this.mg = this.bw(this.n7);
                }
                if ((this.l9 != null && !this.l9.cl()) || (this.l7 != null && !this.l7.cl())) {
                    this.jd(false);
                }
                this.il();
                break;
            case HighDensityScatterSeries.$$p[7]:
                var f = this.l6;
                this.l6 = this.l7;
                this.ol();
                if (f != null) {
                    f.rangeChanged = delegateRemove(f.rangeChanged, runOn(this, this.oc));
                }
                if (this.l6 != null) {
                    var g = this.l6;
                    g.rangeChanged = delegateCombine(g.rangeChanged, runOn(this, this.oc));
                }
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ci(this);
                }
                if ((this.l7 != null && !this.l7.cl()) || (d == null && c != null)) {
                    this.jd(false);
                }
                break;
            case HighDensityScatterSeries.$$p[9]:
                var h = this.l8;
                this.l8 = this.l9;
                this.ol();
                if (h != null) {
                    h.rangeChanged = delegateRemove(h.rangeChanged, runOn(this, this.oc));
                }
                if (this.l8 != null) {
                    var i = this.l8;
                    i.rangeChanged = delegateCombine(i.rangeChanged, runOn(this, this.oc));
                }
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ci(this);
                }
                if ((this.l9 != null && !this.l9.cl()) || (d == null && c != null)) {
                    this.jd(false);
                }
                break;
            case "MouseOverEnabled":
                this.mj = this.c7;
                this.jd(false);
                break;
            case HighDensityScatterSeries.$$p[8]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.me);
                    this.me = this.bw(this.n3);
                }
                break;
            case "XColumn":
                this.ol();
                if (this.l7 != null && !this.l7.cl()) {
                    this.jd(false);
                }
                this.il();
                break;
            case HighDensityScatterSeries.$$p[10]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.mg);
                    this.mg = this.bw(this.n7);
                }
                break;
            case "YColumn":
                this.ol();
                if (this.l9 != null && !this.l9.cl()) {
                    this.jd(false);
                }
                this.il();
                break;
            case HighDensityScatterSeries.$$p[6]:
                this.ol();
                this.jd(false);
                this.ik();
                break;
            case HighDensityScatterSeries.$$p[3]:
                this.jd(false);
                this.ik();
                break;
            case HighDensityScatterSeries.$$p[1]:
                this.jd(false);
                this.ik();
                break;
            case HighDensityScatterSeries.$$p[0]:
            case HighDensityScatterSeries.$$p[2]:
                if (!this.l4.by(this.o0, this.oz)) {
                    return;
                }
                this.m1 = this.o0.o;
                this.m0 = this.o0.n;
                this.mz = this.o0.m;
                this.my = this.oz.o;
                this.mx = this.oz.n;
                this.mw = this.oz.m;
                this.m4 = this.my - this.m1;
                this.m3 = this.mx - this.m0;
                this.m2 = this.mw - this.mz;
                this.jd(false);
                this.ik();
                break;
            case HighDensityScatterSeries.$$p[4]:
                this.nl = Math.max(typeGetValue(d) - 1, 0);
                this.mh = this.nl > 0;
                this.jd(false);
                this.ik();
                break;
            case HighDensityScatterSeries.$$p[5]:
                this.jd(false);
                this.ik();
                break;
        }
    };
    HighDensityScatterSeries.prototype.ml = function (a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    HighDensityScatterSeries.prototype.mk = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    HighDensityScatterSeries.prototype.oc = function (a, b) {
        this.ol();
        this.jd(false);
    };
    HighDensityScatterSeries.prototype.dw = function (a, b, c) {
        var d = _super.prototype.dw.call(this, a, b, c);
        if (this.l9 == null || this.l7 == null || this.l7.bf == null || this.l9.bf == null || this.mg == null || this.me == null || this.mg.count < 1 || this.me.count < 1 || this.mg.count != this.me.count || this.l7.j4 == this.l7.j3 || this.l9.j4 == this.l9.j3 || this.ly.isEmpty) {
            d = false;
        }
        return d;
    };
    Object.defineProperty(HighDensityScatterSeries.prototype, "ns", {
        get: function () {
            return this.nm;
        },
        set: function (a) {
            var b = this.nm;
            this.nm = a;
            this.raisePropertyChanged("ProgressiveStatus", b, this.nm);
        },
        enumerable: true,
        configurable: true
    });
    HighDensityScatterSeries.prototype.je = function (a) {
        _super.prototype.je.call(this, a);
        this.oe(a, this.bi);
    };
    HighDensityScatterSeries.prototype.oe = function (a, b) {
        if (this.cc(b)) {
            return;
        }
        if (this.l5 == null && !this.mn) {
            var c = new List$1(KDPointData.$, 2, this.me.count);
            var d = this.l7;
            var e = this.l9;
            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.b8);
            var i = new ScalerParams(1, f, g, e.b8);
            var j_1;
            var k_1;
            var _loop_1 = function (l) {
                j_1 = d.dw(this_1.me.item(l), h);
                k_1 = e.dw(this_1.mg.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.me.count; l++) {
                _loop_1(l);
            }
            if (this.mm) {
                this.nh = 1;
                this.ni = truncate(logBase(c.count, 2)) + 3;
                this.ns = truncate(((this.nh / this.ni) * 100));
                if (this.progressiveLoadStatusChanged != null) {
                    this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.ns));
                }
                this.l5 = KDTree2D.b(c.toArray(), 1);
                var m = this.l5;
                m.progressiveThunkCompleted = delegateCombine(m.progressiveThunkCompleted, runOn(this, this.n9));
                if (!this.l5.f(this.e4)) {
                    var n = this.l5;
                    n.progressiveThunkCompleted = delegateRemove(n.progressiveThunkCompleted, runOn(this, this.n9));
                }
                this.ik();
            }
            else {
                var o = dateNow();
                this.l5 = new KDTree2D(0, c.toArray(), 1);
                var p = dateNow();
            }
        }
        if (this.mm && !this.mn) {
            this.of(b);
        }
        else {
            this.og(b);
        }
    };
    HighDensityScatterSeries.prototype.hy = function (a, b, c, d) {
        _super.prototype.hy.call(this, a, b, c, d);
        this.ol();
        var e = false;
        if (this.l7 != null && !this.l7.cl()) {
            e = true;
        }
        if (this.l9 != null && !this.l9.cl()) {
            e = true;
        }
        if (e) {
            this.jd(false);
        }
        this.il();
    };
    HighDensityScatterSeries.prototype.ob = function (a) {
        var b = a;
        var c = this.nk * this.nj;
        if (this.mj) {
            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.og = 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.ma = new ScalerParams(0, b, c, this.l6.b8, g);
        this.mb = new ScalerParams(0, b, c, this.l8.b8, g);
        this.oa(a);
        this.ob(a);
        var h = this.nk * this.nj;
        if (this.l3 == null || this.l3.length != h) {
            this.l3 = new Array(h);
            this.l0 = new Array(h);
        }
        var i = this.l3.length;
        var j = this.l3;
        var k = this.l0;
        for (var l = 0; l < i; l++) {
            j[l] = 0;
            k[l] = 0;
        }
        this.no = truncate(Math.round(this.eu));
        this.l2 = f.bv();
        var m = this.l2.length;
        var n = this.l2;
        for (var o = 0; o < m; o++) {
            n[o] = 0;
        }
        var p = this.nf;
        var q = this.ne;
        if (isNaN_(p) || isInfinity(p)) {
            p = 0;
        }
        if (isNaN_(q) || isInfinity(q)) {
            q = 50;
        }
        this.mu = Math.min(p, q);
        this.mt = Math.max(p, q);
        if (this.mu < 0) {
            this.mu = 0;
        }
        if (this.mt < 0) {
            this.mt = 0;
        }
        this.mv = this.mt - this.mu;
        if (this.mn) {
            this.od(a);
        }
        else {
            this.on(a);
        }
        f.b6();
        if (a.n) {
            this._itemIndexes = d;
            this.l4.b7();
        }
    };
    HighDensityScatterSeries.prototype.of = function (a) {
        if (this.l5 == null) {
            return;
        }
        this.og(a);
    };
    HighDensityScatterSeries.prototype.n9 = function (a, b) {
        var _this = this;
        this.l4.b5(function () {
            if (_this.nh < _this.ni - 1) {
                _this.nh++;
            }
            _this.ns = truncate(((_this.nh / _this.ni) * 100));
            if (_this.progressiveLoadStatusChanged != null) {
                _this.progressiveLoadStatusChanged(_this, new ProgressiveLoadStatusEventArgs(_this.ns));
            }
            _this.of(_this.bi);
            _this.ik();
            if (_this.l5 != null) {
                if (!_this.l5.f(_this.e4)) {
                    var c = _this.l5;
                    c.progressiveThunkCompleted = delegateRemove(c.progressiveThunkCompleted, runOn(_this, _this.n9));
                    _this.ns = 100;
                    if (_this.progressiveLoadStatusChanged != null) {
                        _this.progressiveLoadStatusChanged(_this, new ProgressiveLoadStatusEventArgs(_this.ns));
                    }
                }
            }
        });
    };
    HighDensityScatterSeries.prototype.od = function (a) {
        var b = arrayShallowClone(this.me.asArray());
        this.l7.gn(boxArray$1(b), 0, b.length, this.ma);
        var c = arrayShallowClone(this.mg.asArray());
        this.nn = 0;
        var d = this.nl;
        var e = this.mh;
        var f = this.l3.length;
        this.l9.gn(boxArray$1(c), 0, c.length, this.mb);
        var g = 255 << 24 | truncate(this.m1) << 16 | truncate(this.m0) << 8 | truncate(this.mz);
        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.nk || j < 0 || j >= this.nj) {
                continue;
            }
            if (e) {
                var k = i - d;
                var l = i + d;
                l = l > (this.nk - 1) ? (this.nk - 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.nk) + o;
                        if (q < 0 || q > f - 1) {
                            continue;
                        }
                        this.l3[q] = this.l3[q] + 1;
                        this.l0[q] = 1;
                        this.nn++;
                        if (this.mj) {
                            this._itemIndexes[q] = h + 1;
                        }
                    }
                }
            }
            else {
                var r = (j * this.nk) + i;
                this.l3[r] = this.l3[r] + 1;
                this.l0[r] = 1;
                this.nn++;
                if (this.mj) {
                    this._itemIndexes[r] = h + 1;
                }
            }
        }
        this.oh();
    };
    HighDensityScatterSeries.prototype.on = function (a) {
        var b;
        var c;
        var d = a.getViewInfo(b, c);
        b = d.p0;
        c = d.p1;
        if (this.l5 == null) {
            return;
        }
        if (this.mo == null) {
            this.mo = new List$1(KDTreeNode2D.$, 2, truncate(Math.round(b.width * b.height)));
        }
        else {
            this.mo.clear();
        }
        var e = c.left;
        var f = c.right;
        var g = c.top;
        var h = c.bottom;
        this.nb = c.top;
        this.m9 = c.height;
        this.na = c.left;
        this.nc = c.width;
        this.m7 = b.top;
        this.m5 = b.height;
        this.m6 = b.left;
        this.m8 = b.width;
        var i = this.getEffectiveViewport1(a);
        this.mq = (i.left - this.m6) / this.m8;
        this.mr = (i.top - this.m7) / this.m5;
        var j = (i.right - this.m6) / this.m8;
        this.ms = j - this.mq;
        var k = (i.bottom - this.m7) / this.m5;
        this.mp = k - this.mr;
        if (this.mi) {
            e = (e - this.mq) / this.ms;
            f = (f - this.mq) / this.ms;
            g = (g - this.mr) / this.mp;
            h = (h - this.mr) / this.mp;
        }
        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.l5.t(this.mo, o, 0, 1, 0, 1);
        var p;
        this.nn = 0;
        for (var q = 0; q < this.mo.count; q++) {
            p = this.mo._inner[q];
            this.oi(p);
        }
        this.oh();
    };
    HighDensityScatterSeries.prototype.oi = 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.ok(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.ok(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.mq : Rect.empty;
        var c = this.bs != null ? this.bs.m3 : Rect.empty;
        var d = new Rect(0, 0, 0, 1, 1);
        var e = this.ls(this.bi);
        var f = new ScalerParams(0, d, d, this.l7.b8, e);
        var g = new ScalerParams(0, d, d, this.l9.b8, e);
        var h = !b.isEmpty && !c.isEmpty && this.bz != null ? this.bz.indexOf(a) : -1;
        var i = this.l7 != null && this.me != null && h < this.me.count ? this.l7.dw(this.me.item(h), f) : NaN;
        var j = this.l9 != null && this.mg != null && h < this.mg.count ? this.l9.dw(this.mg.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.ok = function (a, b, c, d) {
        var e = this.nq(b);
        var f = a.c;
        var g = this.nl;
        if (c) {
            var h = d.d;
            var i = d.b;
            var j = d.e;
            var k = d.c;
            if (this.mi) {
                h = this.mq + this.ms * h;
                i = this.mq + this.ms * i;
                j = this.mr + this.mp * j;
                k = this.mr + this.mp * k;
            }
            var l = truncate((this.m6 + this.m8 * (h - this.na) / this.nc));
            var m = truncate((this.m6 + this.m8 * (i - this.na) / this.nc));
            var n = truncate((this.m7 + this.m5 * (j - this.nb) / this.m9));
            var o = truncate((this.m7 + this.m5 * (k - this.nb) / this.m9));
            l = truncate(Math.floor(l));
            m = truncate(Math.floor(m));
            n = truncate(Math.floor(n));
            o = truncate(Math.floor(o));
            if (this.mh) {
                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.oj(f, s, t, q, r);
                }
            }
        }
        else {
            var u = a.a;
            var v = a.b;
            if (this.mi) {
                u = this.mq + this.ms * u;
                v = this.mr + this.mp * v;
            }
            var w = truncate((this.m6 + this.m8 * (u - this.na) / this.nc));
            var x = truncate((this.m7 + this.m5 * (v - this.nb) / this.m9));
            w = truncate(Math.floor(w));
            x = truncate(Math.floor(x));
            if (this.mh) {
                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.oj(f, af, ag, ad, ae);
                    }
                }
            }
            else {
                this.oj(f, w, x, b, 1);
            }
        }
    };
    HighDensityScatterSeries.prototype.np = function (a, b) {
        return truncate((Math.floor(255 * b))) << 24 | truncate(Math.floor(b * (this.m1 + a * this.m4))) << 16 | truncate(Math.floor(b * (this.m0 + a * this.m3))) << 8 | truncate(Math.floor(b * (this.mz + a * this.m2)));
    };
    HighDensityScatterSeries.prototype.nq = function (a) {
        return 255 << 24 | truncate(Math.floor((this.m1 + a * this.m4))) << 16 | truncate(Math.floor((this.m0 + a * this.m3))) << 8 | truncate(Math.floor((this.mz + a * this.m2)));
    };
    HighDensityScatterSeries.prototype.nd = function (a) {
        return (a >> 24 & 255) / 255;
    };
    HighDensityScatterSeries.prototype.oj = function (a, b, c, d, e) {
        if (b < 0 || b >= this.nk || c < 0 || c >= this.nj) {
            return;
        }
        var f = (c * this.nk) + b;
        this.l3[f] = this.l3[f] + d;
        this.l0[f] = this.l0[f] + e;
        if (this.mj) {
            this._itemIndexes[f] = a + 1;
        }
        this.nn += truncate(d);
    };
    HighDensityScatterSeries.prototype.oh = function () {
        var a = 0;
        var b = 0;
        var c = this.mv;
        var d = this.mu;
        var e = this.mt;
        var f = this.l3.length;
        var g = this.l3;
        var h = this.l0;
        var i = this.l2;
        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.np(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.oa = function (a) {
        var b = a;
        b.b3();
    };
    HighDensityScatterSeries.prototype.bf = function () {
        return new HighDensityScatterSeriesView(this);
    };
    HighDensityScatterSeries.prototype.iu = function (a) {
        _super.prototype.iu.call(this, a);
        this.l4 = a;
    };
    HighDensityScatterSeries.prototype.an = function (a) {
        if (a != null && a == this.l7 && this.me != null) {
            return new AxisRange(this.me.minimum, this.me.maximum);
        }
        if (a != null && a == this.l9 && this.mg != null) {
            return new AxisRange(this.mg.minimum, this.mg.maximum);
        }
        return null;
    };
    HighDensityScatterSeries.prototype.js = function (a, b) {
        if (this.bs != null) {
            var c = this.getEffectiveViewport1(this.bi);
            this.mi = !c.isEmpty;
        }
        this.jd(false);
    };
    HighDensityScatterSeries.prototype.jt = function (a, b) {
        this.jd(false);
    };
    HighDensityScatterSeries.prototype.fp = function (a) {
        if (!this.mj || this._itemIndexes == null || this.bs == null || this.bz == null || this._itemIndexes.length != (this.nk * this.nj)) {
            return null;
        }
        var b = this.bs.mq;
        var c = (a.x - b.left) / b.width;
        var d = (a.y - b.top) / b.height;
        var e = truncate(Math.round(this.ly.left + (this.ly.width * c)));
        var f = truncate(Math.round(this.ly.top + (this.ly.height * d)));
        var g = this.nt(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.nt = function (a, b) {
        var c = (this.nk * b) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        var d = 1;
        c = (this.nk * (b - d)) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nk * (b + d)) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nk * (b)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nk * (b)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nk * (b - d)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nk * (b + d)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nk * (b - d)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nk * (b + d)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        return 0;
    };
    HighDensityScatterSeries.prototype.om = function (a, b, c) {
        this.l2 = a;
        this.nk = b;
        this.nj = c;
    };
    HighDensityScatterSeries.prototype.get_dq = function () {
        return true;
    };
    HighDensityScatterSeries.prototype.set_dq = function (a) {
        _super.prototype.set_dq.call(this, a);
    };
    HighDensityScatterSeries.prototype.hv = function (a, b) {
        _super.prototype.hv.call(this, a, b);
        this.l4.b4();
        if (this.bh != null) {
            this.bh.b4();
        }
        this.ik();
    };
    HighDensityScatterSeries.prototype.jf = function (a, b) {
        _super.prototype.jf.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.oe(false, c);
        this.dl = false;
    };
    HighDensityScatterSeries.prototype.jc = function (a, b, c, d, e) {
        _super.prototype.jc.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.mc == null) {
            this.mc = new ScatterFrame();
        }
        this.oe(false, f);
    };
    HighDensityScatterSeries.prototype.ht = function () {
        _super.prototype.ht.call(this);
        this.l7 = null;
        this.l9 = null;
    };
    HighDensityScatterSeries.$t = markType(HighDensityScatterSeries, 'HighDensityScatterSeries', Series.$);
    HighDensityScatterSeries.$$p = markDep(DependencyProperty, PropertyMetadata, HighDensityScatterSeries, 'raisePropertyChanged', ['HeatMaximumColor:oz:oo', [Color.$, null], 'HeatMaximum:ne:op', [1, 50], 'HeatMinimumColor:o0:oq', [Color.$, null], 'HeatMinimum:nf:or', [1, 0], 'PointExtent:nr:os', [1, 1], 'ProgressiveLoad:mm:ot', [0, true], 'UseBruteForce:mn:ou', [0, false], 'XAxis:l7:ov', [NumericXAxis.$, null], 'XMemberPath:n3:ow', [2, null], 'YAxis:l9:ox', [NumericYAxis.$, null], 'YMemberPath:n7:oy', [2, null]]);
    return HighDensityScatterSeries;
}(Series));
export { HighDensityScatterSeries };
/**
 * @hidden
 */
var HighDensityScatterSeriesView = /** @class */ (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.o0 = Color.u(255, 0, 0, 0);
            this.bw.oz = Color.u(255, 255, 0, 0);
        }
    };
    HighDensityScatterSeriesView.prototype.b7 = function () {
        this.bw.om(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.mv();
        }
        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.om(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