/*
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 { 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.qg = null;
            this.qi = null;
            this.rr = 0;
            this.qk = false;
            this.q6 = Defaults.aq.o;
            this.q5 = Defaults.aq.n;
            this.q4 = Defaults.aq.m;
            this.q3 = Defaults.aq.l;
            this.q2 = Defaults.ap.o;
            this.q1 = Defaults.ap.n;
            this.q0 = Defaults.ap.m;
            this.qz = Defaults.ap.l;
            this.p8 = null;
            this.qd = null;
            this.qe = null;
            this.p9 = null;
            this.qb = null;
            this.qm = false;
            this.rs = 0;
            this.ru = 0;
            this.ro = 0;
            this.rn = 0;
            this.progressiveLoadStatusChanged = null;
            this.qr = null;
            this.qx = 0;
            this.qw = 0;
            this.qy = 0;
            this.rd = 0;
            this.rb = 0;
            this.rc = 0;
            this.re = 0;
            this.rg = 0;
            this.ri = 0;
            this.rh = 0;
            this.rf = 0;
            this.qt = 0;
            this.qu = 0;
            this.qv = 0;
            this.qs = 0;
            this.rq = 0;
            this.rp = 0;
            this.p5 = null;
            this.rt = 0;
            this.ql = false;
            this._itemIndexes = null;
            this.p6 = null;
            this.p3 = null;
            this.qf = null;
            this.ab = HighDensityScatterSeries.$;
            this.el = false;
        }
        get_d5() {
            return true;
        }
        gu() {
            if (!isNaN_(this.gt)) {
                return super.gu();
            }
            return Defaults.q;
        }
        get_ec() {
            return true;
        }
        get qh() {
            return this.qg;
        }
        set qh(a) {
            if (this.qg != a) {
                let b = this.qh;
                this.qg = a;
                this.raisePropertyChanged("XColumn", b, this.qh);
            }
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.ht(c);
            let e = d == null ? NaN : this.gb(d, "XMemberPath");
            let f = d == null ? NaN : this.gb(d, "YMemberPath");
            let g = new DataLegendSeriesValueInfo();
            g.l = e;
            g.a = 13;
            g.p = this.sd != null ? this.sd : "X";
            g.q = this.r9 != null ? this.r9 : "X:";
            g.r = this.sb != null ? this.sb : "";
            let h = new DataLegendSeriesValueInfo();
            h.l = f;
            h.a = 14;
            h.p = this.sl != null ? this.sl : "Y";
            h.q = this.sh != null ? this.sh : "Y:";
            g.r = this.sj != null ? this.sj : "";
            let i = new DataLegendSeriesContext();
            i.f = ((() => {
                let $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
                $ret.add(g);
                $ret.add(h);
                return $ret;
            })());
            i.b = this.av();
            return i;
        }
        hw(a, b) {
            let c = this.jq(b);
            if (c == HighDensityScatterSeries.$$p[10]) {
                return this.hx(a, b, this.sd);
            }
            if (c == HighDensityScatterSeries.$$p[14]) {
                return this.hx(a, b, this.sl);
            }
            return super.hw(a, b);
        }
        get qj() {
            return this.qi;
        }
        set qj(a) {
            if (this.qi != a) {
                let b = this.qj;
                this.qi = a;
                this.raisePropertyChanged("YColumn", b, this.qj);
            }
        }
        s0() {
            if (this.p8 == null) {
                return;
            }
            this.p8.s();
            let a = this.p8;
            a.progressiveThunkCompleted = delegateRemove(a.progressiveThunkCompleted, runOn(this, this.sn));
            this.p8 = null;
        }
        l3(a, b, c, d) {
            super.l3(a, b, c, d);
            switch (b) {
                case "SeriesViewer":
                    if (this.cd != null) {
                        let e = this.getEffectiveViewport1(this.b0);
                        this.ql = !e.isEmpty;
                    }
                    break;
                case "FastItemsSource":
                    this.s0();
                    if (typeCast(IFastItemsSource_$type, c) != null) {
                        c.deregisterColumn(this.qh);
                        c.deregisterColumn(this.qj);
                        this.qh = null;
                        this.qj = null;
                    }
                    if (typeCast(IFastItemsSource_$type, d) != null) {
                        this.qh = this.ch(this.sd);
                        this.qj = this.ch(this.sl);
                    }
                    if ((this.qc != null && !this.qc.c0()) || (this.qa != null && !this.qa.c0())) {
                        this.mh(false);
                    }
                    this.lp();
                    break;
                case HighDensityScatterSeries.$$p[7]:
                    let f = this.p9;
                    this.p9 = this.qa;
                    this.s0();
                    if (f != null) {
                        f.rangeChanged = delegateRemove(f.rangeChanged, runOn(this, this.sq));
                    }
                    if (this.p9 != null) {
                        let g = this.p9;
                        g.rangeChanged = delegateCombine(g.rangeChanged, runOn(this, this.sq));
                    }
                    if (c != null) {
                        c.bz(this);
                    }
                    if (d != null) {
                        d.cs(this);
                    }
                    if ((this.qa != null && !this.qa.c0()) || (d == null && c != null)) {
                        this.mh(false);
                    }
                    break;
                case HighDensityScatterSeries.$$p[11]:
                    let h = this.qb;
                    this.qb = this.qc;
                    this.s0();
                    if (h != null) {
                        h.rangeChanged = delegateRemove(h.rangeChanged, runOn(this, this.sq));
                    }
                    if (this.qb != null) {
                        let i = this.qb;
                        i.rangeChanged = delegateCombine(i.rangeChanged, runOn(this, this.sq));
                    }
                    if (c != null) {
                        c.bz(this);
                    }
                    if (d != null) {
                        d.cs(this);
                    }
                    if ((this.qc != null && !this.qc.c0()) || (d == null && c != null)) {
                        this.mh(false);
                    }
                    break;
                case "MouseOverEnabled":
                    this.qm = this.el;
                    this.mh(false);
                    break;
                case HighDensityScatterSeries.$$p[10]:
                    if (this.ck != null) {
                        this.ck.deregisterColumn(this.qh);
                        this.qh = this.ch(this.sd);
                    }
                    break;
                case "XColumn":
                    this.s0();
                    if (this.qa != null && !this.qa.c0()) {
                        this.mh(false);
                    }
                    this.lp();
                    break;
                case HighDensityScatterSeries.$$p[14]:
                    if (this.ck != null) {
                        this.ck.deregisterColumn(this.qj);
                        this.qj = this.ch(this.sl);
                    }
                    break;
                case "YColumn":
                    this.s0();
                    if (this.qc != null && !this.qc.c0()) {
                        this.mh(false);
                    }
                    this.lp();
                    break;
                case HighDensityScatterSeries.$$p[6]:
                    this.s0();
                    this.mh(false);
                    this.lo();
                    break;
                case HighDensityScatterSeries.$$p[3]:
                    this.mh(false);
                    this.lo();
                    break;
                case HighDensityScatterSeries.$$p[1]:
                    this.mh(false);
                    this.lo();
                    break;
                case HighDensityScatterSeries.$$p[0]:
                case HighDensityScatterSeries.$$p[2]:
                    if (!this.p7.b1(this.tj, this.ti)) {
                        return;
                    }
                    this.su();
                    this.mh(false);
                    this.lo();
                    break;
                case HighDensityScatterSeries.$$p[4]:
                    this.rr = Math.max(typeGetValue(d) - 1, 0);
                    this.qk = this.rr > 0;
                    this.mh(false);
                    this.lo();
                    break;
                case HighDensityScatterSeries.$$p[5]:
                    this.mh(false);
                    this.lo();
                    break;
            }
        }
        su() {
            this.q3 = this.tj.l;
            this.q6 = this.tj.o;
            this.q5 = this.tj.n;
            this.q4 = this.tj.m;
            this.qz = this.ti.l;
            this.q2 = this.ti.o;
            this.q1 = this.ti.n;
            this.q0 = this.ti.m;
            this.o7 = BrushUtil.g(truncate(this.q3), truncate(this.q6), truncate(this.q5), truncate(this.q4));
            this.o2 = BrushUtil.g(truncate(this.qz), truncate(this.q2), truncate(this.q1), truncate(this.q0));
        }
        qo(a) {
            if (typeCast(NumericYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        qn(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        sq(a, b) {
            this.s0();
            this.mh(false);
        }
        get ra() {
            return this.q2 - this.q6;
        }
        get q9() {
            return this.q1 - this.q5;
        }
        get q8() {
            return this.q0 - this.q4;
        }
        get q7() {
            return this.qz - this.q3;
        }
        e9(a, b, c) {
            let d = super.e9(a, b, c);
            if (this.qc == null || this.qa == null || this.qa.bh == null || this.qc.bh == null || this.qj == null || this.qh == null || this.qj.count < 1 || this.qh.count < 1 || this.qj.count != this.qh.count || this.qa.lv == this.qa.lu || this.qc.lv == this.qc.lu || this.py.isEmpty) {
                d = false;
            }
            return d;
        }
        get ry() {
            return this.rs;
        }
        set ry(a) {
            let b = this.rs;
            this.rs = a;
            this.raisePropertyChanged("ProgressiveStatus", b, this.rs);
        }
        mi(a) {
            super.mi(a);
            this.ss(a, this.b0);
        }
        ss(a, b) {
            if (this.cx(b)) {
                return;
            }
            if (this.p8 == null && !this.qq) {
                let c = new List$1(KDPointData.$, 2, this.qh.count);
                let d = this.qa;
                let e = this.qc;
                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.cg);
                let i = new ScalerParams(1, f, g, e.cg);
                let j;
                let k;
                for (let l = 0; l < this.qh.count; l++) {
                    j = d.ei(this.qh.item(l), h);
                    k = e.ei(this.qj.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.qp) {
                    this.rn = 1;
                    this.ro = truncate(logBase(c.count, 2)) + 3;
                    this.ry = truncate(((this.rn / this.ro) * 100));
                    if (this.progressiveLoadStatusChanged != null) {
                        this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.ry));
                    }
                    this.p8 = KDTree2D.b(c.toArray(), 1);
                    let m = this.p8;
                    m.progressiveThunkCompleted = delegateCombine(m.progressiveThunkCompleted, runOn(this, this.sn));
                    if (!this.p8.f(this.g9)) {
                        let n = this.p8;
                        n.progressiveThunkCompleted = delegateRemove(n.progressiveThunkCompleted, runOn(this, this.sn));
                    }
                    this.lo();
                }
                else {
                    let o = dateNow();
                    this.p8 = new KDTree2D(0, c.toArray(), 1);
                    let p = dateNow();
                }
            }
            if (this.qp && !this.qq) {
                this.st(b);
            }
            else {
                this.sv(b);
            }
        }
        k0(a, b, c, d) {
            super.k0(a, b, c, d);
            this.s0();
            let e = false;
            if (this.qa != null && !this.qa.c0()) {
                e = true;
            }
            if (this.qc != null && !this.qc.c0()) {
                e = true;
            }
            if (e) {
                this.mh(false);
            }
            this.lp();
        }
        sp(a) {
            let b = a;
            let c = this.rq * this.rp;
            if (this.qm) {
                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;
                    }
                }
            }
        }
        sv(a) {
            let b;
            let c;
            let d = null;
            if (a.q) {
                d = this._itemIndexes;
            }
            let e = a.getViewInfo(c, b);
            c = e.p0;
            b = e.p1;
            let f = a;
            let g = this.getEffectiveViewport1(a);
            this.qd = new ScalerParams(0, b, c, this.p9.cg, g);
            this.qe = new ScalerParams(0, b, c, this.qb.cg, g);
            this.so(a);
            this.sp(a);
            let h = this.rq * this.rp;
            if (this.p6 == null || this.p6.length != h) {
                this.p6 = new Array(h);
                this.p3 = new Array(h);
            }
            let i = this.p6.length;
            let j = this.p6;
            let k = this.p3;
            for (let l = 0; l < i; l++) {
                j[l] = 0;
                k[l] = 0;
            }
            this.ru = truncate(Math.round(this.ft));
            this.p5 = f.by();
            let m = this.p5.length;
            let n = this.p5;
            for (let o = 0; o < m; o++) {
                n[o] = 0;
            }
            let p = this.rl;
            let q = this.rk;
            if (isNaN_(p) || isInfinity(p)) {
                p = 0;
            }
            if (isNaN_(q) || isInfinity(q)) {
                q = 50;
            }
            this.qx = Math.min(p, q);
            this.qw = Math.max(p, q);
            if (this.qx < 0) {
                this.qx = 0;
            }
            if (this.qw < 0) {
                this.qw = 0;
            }
            this.qy = this.qw - this.qx;
            if (this.qq) {
                this.sr(a);
            }
            else {
                this.s2(a);
            }
            f.b9();
            if (a.q) {
                this._itemIndexes = d;
                this.p7.ca();
            }
        }
        st(a) {
            if (this.p8 == null) {
                return;
            }
            this.sv(a);
        }
        sn(a, b) {
            this.p7.b8(() => {
                if (this.rn < this.ro - 1) {
                    this.rn++;
                }
                this.ry = truncate(((this.rn / this.ro) * 100));
                if (this.progressiveLoadStatusChanged != null) {
                    this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.ry));
                }
                this.st(this.b0);
                this.lo();
                if (this.p8 != null) {
                    if (!this.p8.f(this.g9)) {
                        let c = this.p8;
                        c.progressiveThunkCompleted = delegateRemove(c.progressiveThunkCompleted, runOn(this, this.sn));
                        this.ry = 100;
                        if (this.progressiveLoadStatusChanged != null) {
                            this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.ry));
                        }
                    }
                }
            });
        }
        sr(a) {
            let b = arrayShallowClone(this.qh.asArray());
            this.qa.hm(boxArray$1(b), 0, b.length, this.qd);
            let c = arrayShallowClone(this.qj.asArray());
            this.rt = 0;
            let d = this.rr;
            let e = this.qk;
            let f = this.p6.length;
            this.qc.hm(boxArray$1(c), 0, c.length, this.qe);
            let g = 255 << 24 | truncate(this.q6) << 16 | truncate(this.q5) << 8 | truncate(this.q4);
            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.rq || j < 0 || j >= this.rp) {
                    continue;
                }
                if (e) {
                    let k = i - d;
                    let l = i + d;
                    l = l > (this.rq - 1) ? (this.rq - 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.rq) + o;
                            if (q < 0 || q > f - 1) {
                                continue;
                            }
                            this.p6[q] = this.p6[q] + 1;
                            this.p3[q] = 1;
                            this.rt++;
                            if (this.qm) {
                                this._itemIndexes[q] = h + 1;
                            }
                        }
                    }
                }
                else {
                    let r = (j * this.rq) + i;
                    this.p6[r] = this.p6[r] + 1;
                    this.p3[r] = 1;
                    this.rt++;
                    if (this.qm) {
                        this._itemIndexes[r] = h + 1;
                    }
                }
            }
            this.sw();
        }
        s2(a) {
            let b;
            let c;
            let d = a.getViewInfo(b, c);
            b = d.p0;
            c = d.p1;
            if (this.p8 == null) {
                return;
            }
            if (this.qr == null) {
                this.qr = new List$1(KDTreeNode2D.$, 2, truncate(Math.round(b.width * b.height)));
            }
            else {
                this.qr.clear();
            }
            let e = c.left;
            let f = c.right;
            let g = c.top;
            let h = c.bottom;
            this.rh = c.top;
            this.rf = c.height;
            this.rg = c.left;
            this.ri = c.width;
            this.rd = b.top;
            this.rb = b.height;
            this.rc = b.left;
            this.re = b.width;
            let i = this.getEffectiveViewport1(a);
            this.qt = (i.left - this.rc) / this.re;
            this.qu = (i.top - this.rd) / this.rb;
            let j = (i.right - this.rc) / this.re;
            this.qv = j - this.qt;
            let k = (i.bottom - this.rd) / this.rb;
            this.qs = k - this.qu;
            if (this.ql) {
                e = (e - this.qt) / this.qv;
                f = (f - this.qt) / this.qv;
                g = (g - this.qu) / this.qs;
                h = (h - this.qu) / this.qs;
            }
            let l = this.ft / b.width * c.width;
            let m = this.ft / 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.p8.t(this.qr, o, 0, 1, 0, 1);
            let p;
            this.rt = 0;
            for (let q = 0; q < this.qr.count; q++) {
                p = this.qr._inner[q];
                this.sx(p);
            }
            this.sw();
        }
        sx(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.sz(a.b, d, b, a.e);
            if (c > 0 && !b) {
                let e;
                for (let f = 0; f < c; f++) {
                    e = a.a[f];
                    this.sz(e, d, false, a.e);
                }
            }
            if (a.e != null) {
                a.e.a = false;
            }
        }
        en(a) {
            let b = this.cd != null ? this.cd.sf : Rect.empty;
            let c = this.cd != null ? this.cd.su : Rect.empty;
            let d = new Rect(0, 0, 0, 1, 1);
            let e = this.ps(this.b0);
            let f = new ScalerParams(0, d, d, this.qa.cg, e);
            let g = new ScalerParams(0, d, d, this.qc.cg, e);
            let h = !b.isEmpty && !c.isEmpty && this.ck != null ? this.ck.indexOf(a) : -1;
            let i = this.qa != null && this.qh != null && h < this.qh.count ? this.qa.ei(this.qh.item(h), f) : NaN;
            let j = this.qc != null && this.qj != null && h < this.qj.count ? this.qc.ei(this.qj.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.b8 != null) {
                this.b8.au(this.cd, b, true);
            }
            return h >= 0;
        }
        sz(a, b, c, d) {
            let e = this.rw(b);
            let f = a.c;
            let g = this.rr;
            if (c) {
                let h = d.d;
                let i = d.b;
                let j = d.e;
                let k = d.c;
                if (this.ql) {
                    h = this.qt + this.qv * h;
                    i = this.qt + this.qv * i;
                    j = this.qu + this.qs * j;
                    k = this.qu + this.qs * k;
                }
                let l = truncate((this.rc + this.re * (h - this.rg) / this.ri));
                let m = truncate((this.rc + this.re * (i - this.rg) / this.ri));
                let n = truncate((this.rd + this.rb * (j - this.rh) / this.rf));
                let o = truncate((this.rd + this.rb * (k - this.rh) / this.rf));
                l = truncate(Math.floor(l));
                m = truncate(Math.floor(m));
                n = truncate(Math.floor(n));
                o = truncate(Math.floor(o));
                if (this.qk) {
                    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.sy(f, s, t, q, r);
                    }
                }
            }
            else {
                let u = a.a;
                let v = a.b;
                if (this.ql) {
                    u = this.qt + this.qv * u;
                    v = this.qu + this.qs * v;
                }
                let w = truncate((this.rc + this.re * (u - this.rg) / this.ri));
                let x = truncate((this.rd + this.rb * (v - this.rh) / this.rf));
                w = truncate(Math.floor(w));
                x = truncate(Math.floor(x));
                if (this.qk) {
                    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.sy(f, af, ag, ad, ae);
                        }
                    }
                }
                else {
                    this.sy(f, w, x, b, 1);
                }
            }
        }
        rv(a, b) {
            return truncate((Math.floor(255 * b))) << 24 | truncate(Math.floor(b * (this.q6 + a * this.ra))) << 16 | truncate(Math.floor(b * (this.q5 + a * this.q9))) << 8 | truncate(Math.floor(b * (this.q4 + a * this.q8)));
        }
        rw(a) {
            return 255 << 24 | truncate(Math.floor((this.q6 + a * this.ra))) << 16 | truncate(Math.floor((this.q5 + a * this.q9))) << 8 | truncate(Math.floor((this.q4 + a * this.q8)));
        }
        rj(a) {
            return (a >> 24 & 255) / 255;
        }
        sy(a, b, c, d, e) {
            if (b < 0 || b >= this.rq || c < 0 || c >= this.rp) {
                return;
            }
            let f = (c * this.rq) + b;
            this.p6[f] = this.p6[f] + d;
            this.p3[f] = this.p3[f] + e;
            if (this.qm) {
                this._itemIndexes[f] = a + 1;
            }
            this.rt += truncate(d);
        }
        sw() {
            let a = 0;
            let b = 0;
            let c = this.qy;
            let d = this.qx;
            let e = this.qw;
            let f = this.p6.length;
            let g = this.p6;
            let h = this.p3;
            let i = this.p5;
            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.rv(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;
            }
        }
        so(a) {
            let b = a;
            b.b6();
        }
        bx() {
            return new HighDensityScatterSeriesView(this);
        }
        ly(a) {
            super.ly(a);
            this.p7 = a;
        }
        ap(a) {
            if (a != null && a == this.qa && this.qh != null) {
                return new AxisRange(this.qh.minimum, this.qh.maximum);
            }
            if (a != null && a == this.qc && this.qj != null) {
                return new AxisRange(this.qj.minimum, this.qj.maximum);
            }
            return null;
        }
        m4(a, b) {
            if (this.cd != null) {
                let c = this.getEffectiveViewport1(this.b0);
                this.ql = !c.isEmpty;
            }
            this.mh(false);
        }
        m5(a, b) {
            this.mh(false);
        }
        ht(a) {
            if (!this.qm || this._itemIndexes == null || this.cd == null || this.ck == null || this._itemIndexes.length != (this.rq * this.rp)) {
                return null;
            }
            let b = this.cd.sf;
            let c = (a.x - b.left) / b.width;
            let d = (a.y - b.top) / b.height;
            let e = truncate(Math.round(this.py.left + (this.py.width * c)));
            let f = truncate(Math.round(this.py.top + (this.py.height * d)));
            let g = this.rz(e, f);
            if (g < 0 || g > this._itemIndexes.length - 1) {
                return null;
            }
            let h = this._itemIndexes[g] - 1;
            if (h < 0 || h > this.ck.count) {
                return null;
            }
            return this.ck.item(h);
        }
        rz(a, b) {
            let c = (this.rq * b) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            let d = 1;
            c = (this.rq * (b - d)) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.rq * (b + d)) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.rq * (b)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.rq * (b)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.rq * (b - d)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.rq * (b + d)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.rq * (b - d)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.rq * (b + d)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            return 0;
        }
        s1(a, b, c) {
            this.p5 = a;
            this.rq = b;
            this.rp = c;
        }
        get_e3() {
            return true;
        }
        set_e3(a) {
            super.set_e3(a);
        }
        kx(a, b) {
            super.kx(a, b);
            this.p7.b7();
            if (this.bz != null) {
                this.bz.b7();
            }
            this.lo();
        }
        mj(a, b) {
            super.mj(a, b);
            if (!this.ez) {
                this.b0.a2(b);
                return;
            }
            this.b0.a2(b);
            if (this.cx(this.bz)) {
                return;
            }
            let c = typeCast(HighDensityScatterSeriesView.$, this.bz);
            let d = new ScatterFrame();
            this.ss(false, c);
            this.ez = false;
        }
        mg(a, b, c, d, e) {
            super.mg(a, b, c, d, e);
            let f = this.a6.a$h.item(d);
            let g = f;
            f.a1(c);
            if (this.cx(g)) {
                return;
            }
            if (this.qf == null) {
                this.qf = new ScatterFrame();
            }
            this.ss(false, f);
        }
        ku() {
            super.ku();
            this.qa = null;
            this.qc = null;
        }
    }
    HighDensityScatterSeries.$t = markType(HighDensityScatterSeries, 'HighDensityScatterSeries', Series.$);
    HighDensityScatterSeries.$$p = markDep(DependencyProperty, PropertyMetadata, HighDensityScatterSeries, 'raisePropertyChanged', ['HeatMaximumColor:ti:s3', [Color.$, Defaults.ap], 'HeatMaximum:rk:s4', [1, 50], 'HeatMinimumColor:tj:s5', [Color.$, Defaults.aq], 'HeatMinimum:rl:s6', [1, 0], 'PointExtent:rx:s7', [1, 1], 'ProgressiveLoad:qp:s8', [0, true], 'UseBruteForce:qq:s9', [0, false], 'XAxis:qa:ta', [NumericXAxis.$, null], 'XMemberAsLegendLabel:r9:tb', [2, null], 'XMemberAsLegendUnit:sb:tc', [2, null], 'XMemberPath:sd:td', [2, null], 'YAxis:qc:te', [NumericYAxis.$, null], 'YMemberAsLegendLabel:sh:tf', [2, null], 'YMemberAsLegendUnit:sj:tg', [2, null], 'YMemberPath:sl:th', [2, null]]);
    return HighDensityScatterSeries;
})();
/**
 * @hidden
 */
export let HighDensityScatterSeriesView = /*@__PURE__*/ (() => {
    class HighDensityScatterSeriesView extends SeriesView {
        constructor(a) {
            super(a);
            this.bz = null;
            this.bx = null;
            this.b5 = 0;
            this.b4 = 0;
            this.b2 = null;
            this.b3 = null;
            this.b0 = null;
            this.bz = a;
        }
        as() {
            super.as();
            if (!this.q) {
                this.bz.tj = Defaults.aq;
                this.bz.ti = Defaults.ap;
                this.bz.o2 = Defaults.al;
                this.bz.o7 = Defaults.ak;
            }
        }
        ca() {
            this.bz.s1(this.bx, this.b5, this.b4);
        }
        b6() {
            if (this.b2 == null) {
                this.b2 = this.e.g9.createElement("canvas");
                let a = this.e.g9.get2DCanvasContext(this.b2);
                this.b0 = new RenderingContext(new CanvasViewRenderer(), a);
            }
            let b;
            if (this.p) {
                b = this.bu;
            }
            else {
                b = this.e.cd.sk();
            }
            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.b5;
            let 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);
                let imageDataArray_ = this.b3.data;
                this.bx = imageDataArray_;
            }
            this.bz.s1(this.bx, this.b5, this.b4);
        }
        by() {
            return this.bx;
        }
        b9() {
            let a = truncate(Math.round(this.bu.left));
            let b = truncate(Math.round(this.bu.left));
            let c = truncate(Math.round(this.bu.width));
            let d = truncate(Math.round(this.bu.height));
            this.b0.g().putImageData(this.b3, 0, 0);
            this.aq();
        }
        b8(a) {
            if (this.e.g9 != null) {
                this.e.g9.setTimeout(a, 0);
            }
            else {
                window.setTimeout(a, 0);
            }
        }
        a6(a, b) {
            super.a6(a, b);
            if (b) {
                if (!this.bz.el) {
                    return;
                }
                let 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;
            }
            let d = truncate(Math.round(this.bu.left));
            let e = truncate(Math.round(this.bu.top));
            let f = truncate(Math.round(this.bu.width));
            let g = truncate(Math.round(this.bu.height));
            this.k.n(this.b2.getNativeElement(), this.e._opacity, d, e, f, g, d, e, f, g);
        }
        b1(a, b) {
            return Color.e(toNullable(Color.$, a), toNullable(Color.$, null)) && Color.e(toNullable(Color.$, b), toNullable(Color.$, null));
        }
        b7() {
            if (this.bx != null) {
                for (let a = 0; a < this.bx.length; a++) {
                    this.bx[a] = 0;
                }
                this.b9();
            }
        }
        al(a) {
            super.al(a);
            if (this.bx == null) {
                this.e.a8.exportSeriesPixelsData(a, null, this.b5, this.b4);
                return;
            }
            let b = new Array(intDivide(this.bx.length, 4));
            let c;
            for (let 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.a8.exportSeriesPixelsData(a, b, this.b5, this.b4);
        }
    }
    HighDensityScatterSeriesView.$t = markType(HighDensityScatterSeriesView, 'HighDensityScatterSeriesView', SeriesView.$);
    return HighDensityScatterSeriesView;
})();
