/*
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 { 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 { Defaults } from "./Defaults";
import { KDTree2D } from "./KDTree2D";
import { Point_$type, typeGetValue, runOn, delegateRemove, typeCast, delegateCombine, markType, markDep, toNullable } from "igniteui-angular-core";
import { DataLegendSeriesValueInfo } from "igniteui-angular-core";
import { DataLegendSeriesContext } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { IFastItemsSource_$type } from "igniteui-angular-core";
import { BrushUtil } from "igniteui-angular-core";
import { SeriesView } from "./SeriesView";
import { TestRandomness } from "igniteui-angular-core";
import { DefaultRandomnessSource } 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
 */
export let HighDensityScatterSeries = /*@__PURE__*/ (() => {
    class HighDensityScatterSeries extends Series {
        constructor() {
            super();
            this.xl = null;
            this.xn = null;
            this.yx = 0;
            this.xq = false;
            this.yc = Defaults.bf.o;
            this.yb = Defaults.bf.n;
            this.ya = Defaults.bf.m;
            this.x9 = Defaults.bf.l;
            this.x8 = Defaults.be.o;
            this.x7 = Defaults.be.n;
            this.x6 = Defaults.be.m;
            this.x5 = Defaults.be.l;
            this.xd = null;
            this.xi = null;
            this.xj = null;
            this.xe = null;
            this.xg = null;
            this.xs = false;
            this.yy = 0;
            this.y0 = 0;
            this.yu = 0;
            this.yt = 0;
            this.progressiveLoadStatusChanged = null;
            this.xx = null;
            this.x3 = 0;
            this.x2 = 0;
            this.x4 = 0;
            this.yj = 0;
            this.yh = 0;
            this.yi = 0;
            this.yk = 0;
            this.ym = 0;
            this.yo = 0;
            this.yn = 0;
            this.yl = 0;
            this.xz = 0;
            this.x0 = 0;
            this.x1 = 0;
            this.xy = 0;
            this.yw = 0;
            this.yv = 0;
            this.xa = null;
            this.yz = 0;
            this.xr = false;
            this._itemIndexes = null;
            this.xb = null;
            this.w8 = null;
            this.xk = null;
            this.ab = HighDensityScatterSeries.$;
            this.f9 = false;
        }
        bk() {
            return new HighDensityScatterSeries();
        }
        get_fp() {
            return true;
        }
        jn() {
            if (!isNaN_(this.jm)) {
                return super.jn();
            }
            return Defaults.ad;
        }
        get_fx() {
            return true;
        }
        get xm() {
            return this.xl;
        }
        set xm(a) {
            if (this.xl != a) {
                let b = this.xm;
                this.xl = a;
                this.raisePropertyChanged("XColumn", b, this.xm);
            }
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.kr(c);
            let e = d == null ? NaN : this.iz(d, "XMemberPath");
            let f = d == null ? NaN : this.iz(d, "YMemberPath");
            let g = new DataLegendSeriesValueInfo();
            g.l = e;
            g.a = 13;
            g.q = "X";
            g.r = this.zj != null ? this.zj : "X";
            g.s = this.zf != null ? this.zf : "X:";
            g.t = this.zh != null ? this.zh : "";
            let h = new DataLegendSeriesValueInfo();
            h.l = f;
            h.a = 14;
            h.q = "Y";
            h.r = this.zr != null ? this.zr : "Y";
            h.s = this.zn != null ? this.zn : "Y:";
            h.t = this.zp != null ? this.zp : "";
            let i = new DataLegendSeriesContext();
            i.e = ((() => {
                let $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
                $ret.add(g);
                $ret.add(h);
                return $ret;
            })());
            i.h = this.mh();
            return i;
        }
        ku(a, b) {
            let c = this.ni(b);
            if (c == HighDensityScatterSeries.$$p[10]) {
                return this.kv(a, b, this.zj);
            }
            if (c == HighDensityScatterSeries.$$p[14]) {
                return this.kv(a, b, this.zr);
            }
            return super.ku(a, b);
        }
        mi(a) {
            let b = this.ni(a);
            if (b == HighDensityScatterSeries.$$p[10]) {
                return this.zj;
            }
            if (b == HighDensityScatterSeries.$$p[14]) {
                return this.zr;
            }
            return super.mi(a);
        }
        get xo() {
            return this.xn;
        }
        set xo(a) {
            if (this.xn != a) {
                let b = this.xo;
                this.xn = a;
                this.raisePropertyChanged("YColumn", b, this.xo);
            }
        }
        z6() {
            if (this.xd == null) {
                return;
            }
            this.xd.t();
            let a = this.xd;
            a.progressiveThunkCompleted = delegateRemove(a.progressiveThunkCompleted, runOn(this, this.zt));
            this.xd = null;
        }
        rg(a, b, c, d) {
            super.rg(a, b, c, d);
            switch (b) {
                case HighDensityScatterSeries.$$p[8]:
                case HighDensityScatterSeries.$$p[12]:
                case HighDensityScatterSeries.$$p[9]:
                case HighDensityScatterSeries.$$p[13]:
                    this.ql();
                    break;
                case "SeriesViewer":
                    if (this.dc != null) {
                        let e = this.getEffectiveViewport1(this.cw);
                        this.xr = !e.isEmpty;
                    }
                    break;
                case "FastItemsSource":
                    this.z6();
                    if (typeCast(IFastItemsSource_$type, c) != null) {
                        c.deregisterColumn(this.xm);
                        c.deregisterColumn(this.xo);
                        this.xm = null;
                        this.xo = null;
                    }
                    if (typeCast(IFastItemsSource_$type, d) != null) {
                        this.xm = this.dl(this.zj);
                        this.xo = this.dl(this.zr);
                    }
                    if ((this.xh != null && !this.xh.d2()) || (this.xf != null && !this.xf.d2())) {
                        this.ry(this.gh && c != null);
                    }
                    this.qs();
                    break;
                case HighDensityScatterSeries.$$p[7]:
                    let f = this.xe;
                    this.xe = this.xf;
                    this.z6();
                    if (f != null) {
                        f.rangeChanged = delegateRemove(f.rangeChanged, runOn(this, this.zw));
                    }
                    if (this.xe != null) {
                        let g = this.xe;
                        g.rangeChanged = delegateCombine(g.rangeChanged, runOn(this, this.zw));
                    }
                    if (c != null) {
                        c.cq(this);
                    }
                    if (d != null) {
                        d.du(this);
                    }
                    if ((this.xf != null && !this.xf.d2()) || (d == null && c != null)) {
                        this.ry(false);
                    }
                    break;
                case HighDensityScatterSeries.$$p[11]:
                    let h = this.xg;
                    this.xg = this.xh;
                    this.z6();
                    if (h != null) {
                        h.rangeChanged = delegateRemove(h.rangeChanged, runOn(this, this.zw));
                    }
                    if (this.xg != null) {
                        let i = this.xg;
                        i.rangeChanged = delegateCombine(i.rangeChanged, runOn(this, this.zw));
                    }
                    if (c != null) {
                        c.cq(this);
                    }
                    if (d != null) {
                        d.du(this);
                    }
                    if ((this.xh != null && !this.xh.d2()) || (d == null && c != null)) {
                        this.ry(false);
                    }
                    break;
                case "MouseOverEnabled":
                    this.xs = this.f9;
                    this.ry(false);
                    break;
                case HighDensityScatterSeries.$$p[10]:
                    if (this.dp != null) {
                        this.dp.deregisterColumn(this.xm);
                        this.xm = this.dl(this.zj);
                    }
                    break;
                case "XColumn":
                    this.z6();
                    if (this.xf != null && !this.xf.d2()) {
                        this.ry(false);
                    }
                    this.qs();
                    break;
                case HighDensityScatterSeries.$$p[14]:
                    if (this.dp != null) {
                        this.dp.deregisterColumn(this.xo);
                        this.xo = this.dl(this.zr);
                    }
                    break;
                case "YColumn":
                    this.z6();
                    if (this.xh != null && !this.xh.d2()) {
                        this.ry(false);
                    }
                    this.qs();
                    break;
                case HighDensityScatterSeries.$$p[6]:
                    this.z6();
                    this.ry(false);
                    this.qr();
                    break;
                case HighDensityScatterSeries.$$p[3]:
                    this.ry(false);
                    this.qr();
                    break;
                case HighDensityScatterSeries.$$p[1]:
                    this.ry(false);
                    this.qr();
                    break;
                case HighDensityScatterSeries.$$p[0]:
                case HighDensityScatterSeries.$$p[2]:
                    if (!this.xc.ch(this.aap, this.aao)) {
                        return;
                    }
                    this.z0();
                    this.ry(false);
                    this.qr();
                    break;
                case HighDensityScatterSeries.$$p[4]:
                    this.yx = Math.max(typeGetValue(d) - 1, 0);
                    this.xq = this.yx > 0;
                    this.ry(false);
                    this.qr();
                    break;
                case HighDensityScatterSeries.$$p[5]:
                    this.ry(false);
                    this.qr();
                    break;
            }
        }
        z0() {
            this.x9 = this.aap.l;
            this.yc = this.aap.o;
            this.yb = this.aap.n;
            this.ya = this.aap.m;
            this.x5 = this.aao.l;
            this.x8 = this.aao.o;
            this.x7 = this.aao.n;
            this.x6 = this.aao.m;
            this.v5 = BrushUtil.j(truncate(this.x9), truncate(this.yc), truncate(this.yb), truncate(this.ya));
            this.vp = BrushUtil.j(truncate(this.x5), truncate(this.x8), truncate(this.x7), truncate(this.x6));
        }
        xu(a) {
            if (typeCast(NumericYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        xt(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        zw(a, b) {
            this.z6();
            this.ry(false);
        }
        get yg() {
            return this.x8 - this.yc;
        }
        get yf() {
            return this.x7 - this.yb;
        }
        get ye() {
            return this.x6 - this.ya;
        }
        get yd() {
            return this.x5 - this.x9;
        }
        hf(a, b, c) {
            let d = super.hf(a, b, c);
            if (this.xh == null || this.xf == null || this.xf.b0 == null || this.xh.b0 == null || this.xo == null || this.xm == null || this.xo.count < 1 || this.xm.count < 1 || this.xo.count != this.xm.count || this.xf.pr == this.xf.pq || this.xh.pr == this.xh.pq || this.w2.isEmpty) {
                d = false;
            }
            return d;
        }
        get y4() {
            return this.yy;
        }
        set y4(a) {
            let b = this.yy;
            this.yy = a;
            this.raisePropertyChanged("ProgressiveStatus", b, this.yy);
        }
        rz(a) {
            super.rz(a);
            this.zy(a, this.cw);
        }
        xp() {
            if (TestRandomness.instance.testRandomnessSource != null) {
                return TestRandomness.instance.testRandomnessSource;
            }
            return new DefaultRandomnessSource(0);
        }
        zy(a, b) {
            if (this.d7(b)) {
                return;
            }
            if (this.xd == null && !this.xw) {
                let c = new List$1(KDPointData.$, 2, this.xm.count);
                let d = this.xf;
                let e = this.xh;
                let f = new Rect(0, 0, 0, 1, 1);
                let g = new Rect(0, 0, 0, 1, 1);
                let h = new ScalerParams(1, f, g, d.df);
                let i = new ScalerParams(1, f, g, e.df);
                let j;
                let k;
                for (let l = 0; l < this.xm.count; l++) {
                    j = d.ft(this.xm.item(l), h);
                    k = e.ft(this.xo.item(l), i);
                    if (!isNaN_(j) && !isNaN_(k) && !isInfinity(j) && !isInfinity(k)) {
                        c.add(((() => {
                            let $ret = new KDPointData();
                            $ret.a = j;
                            $ret.b = k;
                            $ret.c = l;
                            return $ret;
                        })()));
                    }
                }
                if (this.xv) {
                    this.yt = 1;
                    this.yu = truncate(logBase(c.count, 2)) + 3;
                    this.y4 = truncate(((this.yt / this.yu) * 100));
                    if (this.progressiveLoadStatusChanged != null) {
                        this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.y4));
                    }
                    this.xd = KDTree2D.b(c.toArray(), 1, this.xp());
                    let m = this.xd;
                    m.progressiveThunkCompleted = delegateCombine(m.progressiveThunkCompleted, runOn(this, this.zt));
                    if (!this.xd.h(this.j3)) {
                        let n = this.xd;
                        n.progressiveThunkCompleted = delegateRemove(n.progressiveThunkCompleted, runOn(this, this.zt));
                    }
                    this.qr();
                }
                else {
                    let o = dateNow();
                    this.xd = new KDTree2D(0, c.toArray(), 1, this.xp());
                    let p = dateNow();
                }
            }
            if (this.xv && !this.xw) {
                this.zz(b);
            }
            else {
                this.z1(b);
            }
        }
        ph(a, b, c, d) {
            super.ph(a, b, c, d);
            this.z6();
            let e = false;
            if (this.xf != null && !this.xf.d2()) {
                e = true;
            }
            if (this.xh != null && !this.xh.d2()) {
                e = true;
            }
            if (e) {
                this.ry(false);
            }
            this.qs();
        }
        zv(a) {
            let b = a;
            let c = this.yw * this.yv;
            if (this.xs) {
                if (this._itemIndexes == null || this._itemIndexes.length != c) {
                    this._itemIndexes = new Array(c);
                    for (let d = 0; d < c; d++) {
                        this._itemIndexes[d] = 0;
                    }
                }
                else {
                    for (let e = 0; e < c; e++) {
                        this._itemIndexes[e] = 0;
                    }
                }
            }
        }
        z1(a) {
            let b;
            let c;
            let d = null;
            if (a.t) {
                d = this._itemIndexes;
            }
            let e = a.getViewInfo(c, b);
            c = e.p0;
            b = e.p1;
            let f = a;
            let g = this.getEffectiveViewport1(a);
            this.xi = new ScalerParams(0, b, c, this.xe.df, g);
            this.xj = new ScalerParams(0, b, c, this.xg.df, g);
            this.zu(a);
            this.zv(a);
            let h = this.yw * this.yv;
            if (this.xb == null || this.xb.length != h) {
                this.xb = new Array(h);
                this.w8 = new Array(h);
            }
            let i = this.xb.length;
            let j = this.xb;
            let k = this.w8;
            for (let l = 0; l < i; l++) {
                j[l] = 0;
                k[l] = 0;
            }
            this.y0 = truncate(Math.round(this.ie));
            this.xa = f.ce();
            let m = this.xa.length;
            let n = this.xa;
            for (let o = 0; o < m; o++) {
                n[o] = 0;
            }
            let p = this.yr;
            let q = this.yq;
            if (isNaN_(p) || isInfinity(p)) {
                p = 0;
            }
            if (isNaN_(q) || isInfinity(q)) {
                q = 50;
            }
            this.x3 = Math.min(p, q);
            this.x2 = Math.max(p, q);
            if (this.x3 < 0) {
                this.x3 = 0;
            }
            if (this.x2 < 0) {
                this.x2 = 0;
            }
            this.x4 = this.x2 - this.x3;
            if (this.xw) {
                this.zx(a);
            }
            else {
                this.z8(a);
            }
            f.cp();
            if (a.t) {
                this._itemIndexes = d;
                this.xc.cq();
            }
        }
        zz(a) {
            if (this.xd == null) {
                return;
            }
            this.z1(a);
        }
        zt(a, b) {
            this.xc.co(() => {
                if (this.yt < this.yu - 1) {
                    this.yt++;
                }
                this.y4 = truncate(((this.yt / this.yu) * 100));
                if (this.progressiveLoadStatusChanged != null) {
                    this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.y4));
                }
                this.zz(this.cw);
                this.qr();
                if (this.xd != null) {
                    if (!this.xd.h(this.j3)) {
                        let c = this.xd;
                        c.progressiveThunkCompleted = delegateRemove(c.progressiveThunkCompleted, runOn(this, this.zt));
                        this.y4 = 100;
                        if (this.progressiveLoadStatusChanged != null) {
                            this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.y4));
                        }
                    }
                }
            });
        }
        zx(a) {
            let b = arrayShallowClone(this.xm.asArray());
            this.xf.j6(boxArray$1(b), 0, b.length, this.xi);
            let c = arrayShallowClone(this.xo.asArray());
            this.yz = 0;
            let d = this.yx;
            let e = this.xq;
            let f = this.xb.length;
            this.xh.j6(boxArray$1(c), 0, c.length, this.xj);
            let g = 255 << 24 | truncate(this.yc) << 16 | truncate(this.yb) << 8 | truncate(this.ya);
            for (let h = 0; h < b.length; h++) {
                let i = truncate(b[h]);
                let j = truncate(c[h]);
                i = truncate(Math.floor(i));
                j = truncate(Math.floor(j));
                if (i < 0 || i >= this.yw || j < 0 || j >= this.yv) {
                    continue;
                }
                if (e) {
                    let k = i - d;
                    let l = i + d;
                    l = l > (this.yw - 1) ? (this.yw - 1) : l;
                    k = k < 0 ? 0 : k;
                    let m = j + d;
                    let n = j - d;
                    for (let o = k; o <= l; o++) {
                        for (let p = n; p <= m; p++) {
                            let q = (p * this.yw) + o;
                            if (q < 0 || q > f - 1) {
                                continue;
                            }
                            this.xb[q] = this.xb[q] + 1;
                            this.w8[q] = 1;
                            this.yz++;
                            if (this.xs) {
                                this._itemIndexes[q] = h + 1;
                            }
                        }
                    }
                }
                else {
                    let r = (j * this.yw) + i;
                    this.xb[r] = this.xb[r] + 1;
                    this.w8[r] = 1;
                    this.yz++;
                    if (this.xs) {
                        this._itemIndexes[r] = h + 1;
                    }
                }
            }
            this.z2();
        }
        z8(a) {
            let b;
            let c;
            let d = a.getViewInfo(b, c);
            b = d.p0;
            c = d.p1;
            if (this.xd == null) {
                return;
            }
            if (this.xx == null) {
                this.xx = new List$1(KDTreeNode2D.$, 2, truncate(Math.round(b.width * b.height)));
            }
            else {
                this.xx.clear();
            }
            let e = c.left;
            let f = c.right;
            let g = c.top;
            let h = c.bottom;
            this.yn = c.top;
            this.yl = c.height;
            this.ym = c.left;
            this.yo = c.width;
            this.yj = b.top;
            this.yh = b.height;
            this.yi = b.left;
            this.yk = b.width;
            let i = this.getEffectiveViewport1(a);
            this.xz = (i.left - this.yi) / this.yk;
            this.x0 = (i.top - this.yj) / this.yh;
            let j = (i.right - this.yi) / this.yk;
            this.x1 = j - this.xz;
            let k = (i.bottom - this.yj) / this.yh;
            this.xy = k - this.x0;
            if (this.xr) {
                e = (e - this.xz) / this.x1;
                f = (f - this.xz) / this.x1;
                g = (g - this.x0) / this.xy;
                h = (h - this.x0) / this.xy;
            }
            let l = this.ie / b.width * c.width;
            let m = this.ie / b.height * c.height;
            let n = Math.min(l, m);
            let o = ((() => {
                let $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.xd.u(this.xx, o, 0, 1, 0, 1);
            let p;
            this.yz = 0;
            for (let q = 0; q < this.xx.count; q++) {
                p = this.xx._inner[q];
                this.z3(p);
            }
            this.z2();
        }
        z3(a) {
            if (a.g) {
                return;
            }
            let b = a.e != null && a.e.a;
            let c = a.a == null ? 0 : a.a.length;
            let d = (a.h - c) + 1;
            if (b && d > 0) {
            }
            else {
                d = 1;
            }
            this.z5(a.b, d, b, a.e);
            if (c > 0 && !b) {
                let e;
                for (let f = 0; f < c; f++) {
                    e = a.a[f];
                    this.z5(e, d, false, a.e);
                }
            }
            if (a.e != null) {
                a.e.a = false;
            }
        }
        ge(a) {
            let b = this.dc != null ? this.dc.xm : Rect.empty;
            let c = this.dc != null ? this.dc.x4 : Rect.empty;
            let d = new Rect(0, 0, 0, 1, 1);
            let e = this.wv(this.cw);
            let f = new ScalerParams(0, d, d, this.xf.df, e);
            let g = new ScalerParams(0, d, d, this.xh.df, e);
            let h = !b.isEmpty && !c.isEmpty && this.dp != null ? this.dp.indexOf(a) : -1;
            let i = this.xf != null && this.xm != null && h < this.xm.count ? this.xf.ft(this.xm.item(h), f) : NaN;
            let j = this.xh != null && this.xo != null && h < this.xo.count ? this.xh.ft(this.xo.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.c4 != null) {
                this.c4.au(this.dc, b, true);
            }
            return h >= 0;
        }
        z5(a, b, c, d) {
            let e = this.y2(b);
            let f = a.c;
            let g = this.yx;
            if (c) {
                let h = d.d;
                let i = d.b;
                let j = d.e;
                let k = d.c;
                if (this.xr) {
                    h = this.xz + this.x1 * h;
                    i = this.xz + this.x1 * i;
                    j = this.x0 + this.xy * j;
                    k = this.x0 + this.xy * k;
                }
                let l = truncate((this.yi + this.yk * (h - this.ym) / this.yo));
                let m = truncate((this.yi + this.yk * (i - this.ym) / this.yo));
                let n = truncate((this.yj + this.yh * (j - this.yn) / this.yl));
                let o = truncate((this.yj + this.yh * (k - this.yn) / this.yl));
                l = truncate(Math.floor(l));
                m = truncate(Math.floor(m));
                n = truncate(Math.floor(n));
                o = truncate(Math.floor(o));
                if (this.xq) {
                    l -= g;
                    m += g;
                    n -= g;
                    o += g;
                }
                let p = ((m - l) + 1) * ((o - n) + 1);
                let q = b / p;
                let r = q;
                for (let s = l; s <= m; s++) {
                    for (let t = n; t <= o; t++) {
                        this.z4(f, s, t, q, r);
                    }
                }
            }
            else {
                let u = a.a;
                let v = a.b;
                if (this.xr) {
                    u = this.xz + this.x1 * u;
                    v = this.x0 + this.xy * v;
                }
                let w = truncate((this.yi + this.yk * (u - this.ym) / this.yo));
                let x = truncate((this.yj + this.yh * (v - this.yn) / this.yl));
                w = truncate(Math.floor(w));
                x = truncate(Math.floor(x));
                if (this.xq) {
                    let y = w - g;
                    let z = w + g;
                    let aa = x + g;
                    let ab = x - g;
                    let ac = ((z - y) + 1) * ((aa - ab) + 1);
                    let ad = b / ac;
                    let ae = ad;
                    for (let af = y; af <= z; af++) {
                        for (let ag = ab; ag <= aa; ag++) {
                            this.z4(f, af, ag, ad, ae);
                        }
                    }
                }
                else {
                    this.z4(f, w, x, b, 1);
                }
            }
        }
        y1(a, b) {
            return truncate((Math.floor(255 * b))) << 24 | truncate(Math.floor(b * (this.yc + a * this.yg))) << 16 | truncate(Math.floor(b * (this.yb + a * this.yf))) << 8 | truncate(Math.floor(b * (this.ya + a * this.ye)));
        }
        y2(a) {
            return 255 << 24 | truncate(Math.floor((this.yc + a * this.yg))) << 16 | truncate(Math.floor((this.yb + a * this.yf))) << 8 | truncate(Math.floor((this.ya + a * this.ye)));
        }
        yp(a) {
            return (a >> 24 & 255) / 255;
        }
        z4(a, b, c, d, e) {
            if (b < 0 || b >= this.yw || c < 0 || c >= this.yv) {
                return;
            }
            let f = (c * this.yw) + b;
            this.xb[f] = this.xb[f] + d;
            this.w8[f] = this.w8[f] + e;
            if (this.xs) {
                this._itemIndexes[f] = a + 1;
            }
            this.yz += truncate(d);
        }
        z2() {
            let a = 0;
            let b = 0;
            let c = this.x4;
            let d = this.x3;
            let e = this.x2;
            let f = this.xb.length;
            let g = this.xb;
            let h = this.w8;
            let i = this.xa;
            let j = NaN;
            let k = NaN;
            let l = 0;
            let m = 0;
            for (let 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.y1(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;
            }
        }
        zu(a) {
            let b = a;
            b.cm();
        }
        ct() {
            return new HighDensityScatterSeriesView(this);
        }
        q7(a) {
            super.q7(a);
            this.xc = a;
        }
        ay(a) {
            if (a != null && a == this.xf && this.xm != null) {
                return new AxisRange(this.xm.minimum, this.xm.maximum);
            }
            if (a != null && a == this.xh && this.xo != null) {
                return new AxisRange(this.xo.minimum, this.xo.maximum);
            }
            return null;
        }
        sy(a, b) {
            if (this.dc != null) {
                let c = this.getEffectiveViewport1(this.cw);
                this.xr = !c.isEmpty;
            }
            this.ry(false);
        }
        sz(a, b) {
            this.ry(false);
        }
        kr(a) {
            if (!this.xs || this._itemIndexes == null || this.dc == null || this.dp == null || this._itemIndexes.length != (this.yw * this.yv)) {
                return null;
            }
            let b = this.dc.xm;
            let c = (a.x - b.left) / b.width;
            let d = (a.y - b.top) / b.height;
            let e = truncate(Math.round(this.w2.left + (this.w2.width * c)));
            let f = truncate(Math.round(this.w2.top + (this.w2.height * d)));
            let g = this.y5(e, f);
            if (g < 0 || g > this._itemIndexes.length - 1) {
                return null;
            }
            let h = this._itemIndexes[g] - 1;
            if (h < 0 || h > this.dp.count) {
                return null;
            }
            return this.dp.item(h);
        }
        y5(a, b) {
            let c = (this.yw * b) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            let d = 1;
            c = (this.yw * (b - d)) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yw * (b + d)) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yw * (b)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yw * (b)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yw * (b - d)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yw * (b + d)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yw * (b - d)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.yw * (b + d)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            return 0;
        }
        z7(a, b, c) {
            this.xa = a;
            this.yw = b;
            this.yv = c;
        }
        get_g8() {
            return true;
        }
        set_g8(a) {
            super.set_g8(a);
        }
        pb(a, b) {
            super.pb(a, b);
            this.xc.cn();
            if (this.cv != null) {
                this.cv.cn();
            }
            this.qr();
        }
        r0(a, b) {
            super.r0(a, b);
            if (!this.g1) {
                this.cw.be(b);
                return;
            }
            this.cw.be(b);
            if (this.d7(this.cv)) {
                return;
            }
            let c = typeCast(HighDensityScatterSeriesView.$, this.cv);
            let d = new ScatterFrame();
            this.zy(false, c);
            this.g1 = false;
        }
        rx(a, b, c, d, e) {
            super.rx(a, b, c, d, e);
            let f = this.ba.a$j.item(d);
            let g = f;
            f.bd(c);
            if (this.d7(g)) {
                return;
            }
            if (this.xk == null) {
                this.xk = new ScatterFrame();
            }
            this.zy(false, f);
        }
        o8() {
            super.o8();
            this.xf = null;
            this.xh = null;
        }
    }
    HighDensityScatterSeries.$t = markType(HighDensityScatterSeries, 'HighDensityScatterSeries', Series.$);
    HighDensityScatterSeries.$$p = markDep(DependencyProperty, PropertyMetadata, HighDensityScatterSeries, 'raisePropertyChanged', ['HeatMaximumColor:aao:z9', [Color.$, Defaults.be], 'HeatMaximum:yq:aaa', [1, 50], 'HeatMinimumColor:aap:aab', [Color.$, Defaults.bf], 'HeatMinimum:yr:aac', [1, 0], 'PointExtent:y3:aad', [1, 1], 'ProgressiveLoad:xv:aae', [0, true], 'UseBruteForce:xw:aaf', [0, false], 'XAxis:xf:aag', [NumericXAxis.$, null], 'XMemberAsLegendLabel:zf:aah', [2, null], 'XMemberAsLegendUnit:zh:aai', [2, null], 'XMemberPath:zj:aaj', [2, null], 'YAxis:xh:aak', [NumericYAxis.$, null], 'YMemberAsLegendLabel:zn:aal', [2, null], 'YMemberAsLegendUnit:zp:aam', [2, null], 'YMemberPath:zr:aan', [2, null]]);
    return HighDensityScatterSeries;
})();
/**
 * @hidden
 */
export let HighDensityScatterSeriesView = /*@__PURE__*/ (() => {
    class HighDensityScatterSeriesView extends SeriesView {
        constructor(a) {
            super(a);
            this.cf = null;
            this.cd = null;
            this.cl = 0;
            this.ck = 0;
            this.ci = null;
            this.cj = null;
            this.cg = null;
            this.cf = a;
        }
        a4() {
            super.a4();
            if (!this.t) {
                this.cf.aap = Defaults.bf;
                this.cf.aao = Defaults.be;
                this.cf.vp = Defaults.ba;
                this.cf.v5 = Defaults.a9;
            }
        }
        cq() {
            this.cf.z7(this.cd, this.cl, this.ck);
        }
        cm() {
            if (this.ci == null) {
                this.ci = this.f.j3.createElement("canvas");
                let a = this.f.j3.get2DCanvasContext(this.ci);
                this.cg = new RenderingContext(new CanvasViewRenderer(), a);
            }
            let b;
            if (this.s) {
                b = this.b9;
            }
            else {
                b = this.f.dc.xs();
            }
            let c = truncate(Math.round(b.left));
            let d = truncate(Math.round(b.top));
            let e = truncate(Math.round(b.width));
            let f = truncate(Math.round(b.height));
            let g = this.cl;
            let h = this.ck;
            this.cl = e;
            this.ck = f;
            if (g != this.cl || h != this.ck || this.cd == null) {
                this.ci.setAttribute("width", e.toString());
                this.ci.setAttribute("height", f.toString());
                this.cj = this.cg.h().getImageData(0, 0, e, f);
                let imageDataArray_ = this.cj.data;
                this.cd = imageDataArray_;
            }
            this.cf.z7(this.cd, this.cl, this.ck);
        }
        ce() {
            return this.cd;
        }
        cp() {
            let a = truncate(Math.round(this.b9.left));
            let b = truncate(Math.round(this.b9.left));
            let c = truncate(Math.round(this.b9.width));
            let d = truncate(Math.round(this.b9.height));
            this.cg.h().putImageData(this.cj, 0, 0);
            this.a2();
        }
        co(a) {
            if (this.f.j3 != null) {
                this.f.j3.setTimeout(a, 0);
            }
            else {
                window.setTimeout(a, 0);
            }
        }
        bj(a, b) {
            super.bj(a, b);
            if (b) {
                if (!this.cf.f9) {
                    return;
                }
                let c = new Rectangle();
                c.n = this.b9.left;
                c.o = this.b9.top;
                c.width = this.b9.width;
                c.height = this.b9.height;
                c._fill = this.b3();
                a.w(c);
                return;
            }
            if (this.ci == null) {
                return;
            }
            let d = truncate(Math.round(this.b9.left));
            let e = truncate(Math.round(this.b9.top));
            let f = truncate(Math.round(this.b9.width));
            let g = truncate(Math.round(this.b9.height));
            this.m.o(this.ci.getNativeElement(), this.f._opacity, d, e, f, g, d, e, f, g);
        }
        ch(a, b) {
            return Color.e(toNullable(Color.$, a), toNullable(Color.$, null)) && Color.e(toNullable(Color.$, b), toNullable(Color.$, null));
        }
        cn() {
            if (this.cd != null) {
                for (let a = 0; a < this.cd.length; a++) {
                    this.cd[a] = 0;
                }
                this.cp();
            }
        }
        ax(a) {
            super.ax(a);
            if (this.cd == null) {
                this.f.bc.exportSeriesPixelsData(a, null, this.cl, this.ck);
                return;
            }
            let b = new Array(intDivide(this.cd.length, 4));
            let c;
            for (let d = 0; d < intDivide(this.cd.length, 4); d++) {
                c = d * 4;
                b[d] = this.cd[c + 3] << 24 | this.cd[c] << 16 | this.cd[c + 1] << 8 | this.cd[c + 2];
            }
            this.f.bc.exportSeriesPixelsData(a, b, this.cl, this.ck);
        }
    }
    HighDensityScatterSeriesView.$t = markType(HighDensityScatterSeriesView, 'HighDensityScatterSeriesView', SeriesView.$);
    return HighDensityScatterSeriesView;
})();
