/*
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-react-core";
import { NumericYAxis } from "./NumericYAxis";
import { Color } from "igniteui-react-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-react-core";
import { DataLegendSeriesValueInfo } from "igniteui-react-core";
import { DataLegendSeriesContext } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { BrushUtil } from "igniteui-react-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-react-core";
import { truncate, isNaN_, isInfinity, logBase, intDivide } from "igniteui-react-core";
import { boxArray$1, arrayShallowClone } from "igniteui-react-core";
import { dateNow } from "igniteui-react-core";
import { RenderingContext } from "igniteui-react-core";
import { CanvasViewRenderer } from "igniteui-react-core";
import { Rectangle } from "igniteui-react-core";
/**
 * @hidden
 */
export let HighDensityScatterSeries = /*@__PURE__*/ (() => {
    class HighDensityScatterSeries extends Series {
        bc() {
            return new HighDensityScatterSeries();
        }
        get_e2() {
            return true;
        }
        iq() {
            if (!isNaN_(this.ip)) {
                return super.iq();
            }
            return Defaults.q;
        }
        constructor() {
            super();
            this.ug = null;
            this.ui = null;
            this.vr = 0;
            this.uk = false;
            this.u6 = Defaults.aq.o;
            this.u5 = Defaults.aq.n;
            this.u4 = Defaults.aq.m;
            this.u3 = Defaults.aq.l;
            this.u2 = Defaults.ap.o;
            this.u1 = Defaults.ap.n;
            this.u0 = Defaults.ap.m;
            this.uz = Defaults.ap.l;
            this.t8 = null;
            this.ud = null;
            this.ue = null;
            this.t9 = null;
            this.ub = null;
            this.um = false;
            this.vs = 0;
            this.vu = 0;
            this.vo = 0;
            this.vn = 0;
            this.progressiveLoadStatusChanged = null;
            this.ur = null;
            this.ux = 0;
            this.uw = 0;
            this.uy = 0;
            this.vd = 0;
            this.vb = 0;
            this.vc = 0;
            this.ve = 0;
            this.vg = 0;
            this.vi = 0;
            this.vh = 0;
            this.vf = 0;
            this.ut = 0;
            this.uu = 0;
            this.uv = 0;
            this.us = 0;
            this.vq = 0;
            this.vp = 0;
            this.t5 = null;
            this.vt = 0;
            this.ul = false;
            this._itemIndexes = null;
            this.t6 = null;
            this.t3 = null;
            this.uf = null;
            this.ab = HighDensityScatterSeries.$;
            this.fl = false;
        }
        get_fa() {
            return true;
        }
        get uh() {
            return this.ug;
        }
        set uh(a) {
            if (this.ug != a) {
                let b = this.uh;
                this.ug = a;
                this.raisePropertyChanged("XColumn", b, this.uh);
            }
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.js(c);
            let e = d == null ? NaN : this.h2(d, "XMemberPath");
            let f = d == null ? NaN : this.h2(d, "YMemberPath");
            let g = new DataLegendSeriesValueInfo();
            g.l = e;
            g.a = 13;
            g.p = "X";
            g.q = this.wd != null ? this.wd : "X";
            g.r = this.v9 != null ? this.v9 : "X:";
            g.s = this.wb != null ? this.wb : "";
            let h = new DataLegendSeriesValueInfo();
            h.l = f;
            h.a = 14;
            h.p = "Y";
            h.q = this.wl != null ? this.wl : "Y";
            h.r = this.wh != null ? this.wh : "Y:";
            h.s = this.wj != null ? this.wj : "";
            let i = new DataLegendSeriesContext();
            i.f = ((() => {
                let $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
                $ret.add(g);
                $ret.add(h);
                return $ret;
            })());
            i.b = this.aw();
            return i;
        }
        jv(a, b) {
            let c = this.lw(b);
            if (c == HighDensityScatterSeries.$$p[10]) {
                return this.jw(a, b, this.wd);
            }
            if (c == HighDensityScatterSeries.$$p[14]) {
                return this.jw(a, b, this.wl);
            }
            return super.jv(a, b);
        }
        get uj() {
            return this.ui;
        }
        set uj(a) {
            if (this.ui != a) {
                let b = this.uj;
                this.ui = a;
                this.raisePropertyChanged("YColumn", b, this.uj);
            }
        }
        w0() {
            if (this.t8 == null) {
                return;
            }
            this.t8.s();
            let a = this.t8;
            a.progressiveThunkCompleted = delegateRemove(a.progressiveThunkCompleted, runOn(this, this.wn));
            this.t8 = null;
        }
        pa(a, b, c, d) {
            super.pa(a, b, c, d);
            switch (b) {
                case "SeriesViewer":
                    if (this.cv != null) {
                        let e = this.getEffectiveViewport1(this.cg);
                        this.ul = !e.isEmpty;
                    }
                    break;
                case "FastItemsSource":
                    this.w0();
                    if (typeCast(IFastItemsSource_$type, c) != null) {
                        c.deregisterColumn(this.uh);
                        c.deregisterColumn(this.uj);
                        this.uh = null;
                        this.uj = null;
                    }
                    if (typeCast(IFastItemsSource_$type, d) != null) {
                        this.uh = this.c4(this.wd);
                        this.uj = this.c4(this.wl);
                    }
                    if ((this.uc != null && !this.uc.c1()) || (this.ua != null && !this.ua.c1())) {
                        this.pr(this.fr && c != null);
                    }
                    this.on();
                    break;
                case HighDensityScatterSeries.$$p[7]:
                    let f = this.t9;
                    this.t9 = this.ua;
                    this.w0();
                    if (f != null) {
                        f.rangeChanged = delegateRemove(f.rangeChanged, runOn(this, this.wq));
                    }
                    if (this.t9 != null) {
                        let g = this.t9;
                        g.rangeChanged = delegateCombine(g.rangeChanged, runOn(this, this.wq));
                    }
                    if (c != null) {
                        c.b0(this);
                    }
                    if (d != null) {
                        d.ct(this);
                    }
                    if ((this.ua != null && !this.ua.c1()) || (d == null && c != null)) {
                        this.pr(false);
                    }
                    break;
                case HighDensityScatterSeries.$$p[11]:
                    let h = this.ub;
                    this.ub = this.uc;
                    this.w0();
                    if (h != null) {
                        h.rangeChanged = delegateRemove(h.rangeChanged, runOn(this, this.wq));
                    }
                    if (this.ub != null) {
                        let i = this.ub;
                        i.rangeChanged = delegateCombine(i.rangeChanged, runOn(this, this.wq));
                    }
                    if (c != null) {
                        c.b0(this);
                    }
                    if (d != null) {
                        d.ct(this);
                    }
                    if ((this.uc != null && !this.uc.c1()) || (d == null && c != null)) {
                        this.pr(false);
                    }
                    break;
                case "MouseOverEnabled":
                    this.um = this.fl;
                    this.pr(false);
                    break;
                case HighDensityScatterSeries.$$p[10]:
                    if (this.c7 != null) {
                        this.c7.deregisterColumn(this.uh);
                        this.uh = this.c4(this.wd);
                    }
                    break;
                case "XColumn":
                    this.w0();
                    if (this.ua != null && !this.ua.c1()) {
                        this.pr(false);
                    }
                    this.on();
                    break;
                case HighDensityScatterSeries.$$p[14]:
                    if (this.c7 != null) {
                        this.c7.deregisterColumn(this.uj);
                        this.uj = this.c4(this.wl);
                    }
                    break;
                case "YColumn":
                    this.w0();
                    if (this.uc != null && !this.uc.c1()) {
                        this.pr(false);
                    }
                    this.on();
                    break;
                case HighDensityScatterSeries.$$p[6]:
                    this.w0();
                    this.pr(false);
                    this.om();
                    break;
                case HighDensityScatterSeries.$$p[3]:
                    this.pr(false);
                    this.om();
                    break;
                case HighDensityScatterSeries.$$p[1]:
                    this.pr(false);
                    this.om();
                    break;
                case HighDensityScatterSeries.$$p[0]:
                case HighDensityScatterSeries.$$p[2]:
                    if (!this.t7.b4(this.xj, this.xi)) {
                        return;
                    }
                    this.wu();
                    this.pr(false);
                    this.om();
                    break;
                case HighDensityScatterSeries.$$p[4]:
                    this.vr = Math.max(typeGetValue(d) - 1, 0);
                    this.uk = this.vr > 0;
                    this.pr(false);
                    this.om();
                    break;
                case HighDensityScatterSeries.$$p[5]:
                    this.pr(false);
                    this.om();
                    break;
            }
        }
        wu() {
            this.u3 = this.xj.l;
            this.u6 = this.xj.o;
            this.u5 = this.xj.n;
            this.u4 = this.xj.m;
            this.uz = this.xi.l;
            this.u2 = this.xi.o;
            this.u1 = this.xi.n;
            this.u0 = this.xi.m;
            this.s4 = BrushUtil.h(truncate(this.u3), truncate(this.u6), truncate(this.u5), truncate(this.u4));
            this.sy = BrushUtil.h(truncate(this.uz), truncate(this.u2), truncate(this.u1), truncate(this.u0));
        }
        uo(a) {
            if (typeCast(NumericYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        un(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        wq(a, b) {
            this.w0();
            this.pr(false);
        }
        get va() {
            return this.u2 - this.u6;
        }
        get u9() {
            return this.u1 - this.u5;
        }
        get u8() {
            return this.u0 - this.u4;
        }
        get u7() {
            return this.uz - this.u3;
        }
        gm(a, b, c) {
            let d = super.gm(a, b, c);
            if (this.uc == null || this.ua == null || this.ua.bi == null || this.uc.bi == null || this.uj == null || this.uh == null || this.uj.count < 1 || this.uh.count < 1 || this.uj.count != this.uh.count || this.ua.lx == this.ua.lw || this.uc.lx == this.uc.lw || this.ty.isEmpty) {
                d = false;
            }
            return d;
        }
        get vy() {
            return this.vs;
        }
        set vy(a) {
            let b = this.vs;
            this.vs = a;
            this.raisePropertyChanged("ProgressiveStatus", b, this.vs);
        }
        ps(a) {
            super.ps(a);
            this.ws(a, this.cg);
        }
        ws(a, b) {
            if (this.dm(b)) {
                return;
            }
            if (this.t8 == null && !this.uq) {
                let c = new List$1(KDPointData.$, 2, this.uh.count);
                let d = this.ua;
                let e = this.uc;
                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.ch);
                let i = new ScalerParams(1, f, g, e.ch);
                let j;
                let k;
                for (let l = 0; l < this.uh.count; l++) {
                    j = d.ej(this.uh.item(l), h);
                    k = e.ej(this.uj.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.up) {
                    this.vn = 1;
                    this.vo = truncate(logBase(c.count, 2)) + 3;
                    this.vy = truncate(((this.vn / this.vo) * 100));
                    if (this.progressiveLoadStatusChanged != null) {
                        this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.vy));
                    }
                    this.t8 = KDTree2D.b(c.toArray(), 1);
                    let m = this.t8;
                    m.progressiveThunkCompleted = delegateCombine(m.progressiveThunkCompleted, runOn(this, this.wn));
                    if (!this.t8.f(this.i5)) {
                        let n = this.t8;
                        n.progressiveThunkCompleted = delegateRemove(n.progressiveThunkCompleted, runOn(this, this.wn));
                    }
                    this.om();
                }
                else {
                    let o = dateNow();
                    this.t8 = new KDTree2D(0, c.toArray(), 1);
                    let p = dateNow();
                }
            }
            if (this.up && !this.uq) {
                this.wt(b);
            }
            else {
                this.wv(b);
            }
        }
        np(a, b, c, d) {
            super.np(a, b, c, d);
            this.w0();
            let e = false;
            if (this.ua != null && !this.ua.c1()) {
                e = true;
            }
            if (this.uc != null && !this.uc.c1()) {
                e = true;
            }
            if (e) {
                this.pr(false);
            }
            this.on();
        }
        wp(a) {
            let b = a;
            let c = this.vq * this.vp;
            if (this.um) {
                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;
                    }
                }
            }
        }
        wv(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.ud = new ScalerParams(0, b, c, this.t9.ch, g);
            this.ue = new ScalerParams(0, b, c, this.ub.ch, g);
            this.wo(a);
            this.wp(a);
            let h = this.vq * this.vp;
            if (this.t6 == null || this.t6.length != h) {
                this.t6 = new Array(h);
                this.t3 = new Array(h);
            }
            let i = this.t6.length;
            let j = this.t6;
            let k = this.t3;
            for (let l = 0; l < i; l++) {
                j[l] = 0;
                k[l] = 0;
            }
            this.vu = truncate(Math.round(this.hk));
            this.t5 = f.b1();
            let m = this.t5.length;
            let n = this.t5;
            for (let o = 0; o < m; o++) {
                n[o] = 0;
            }
            let p = this.vl;
            let q = this.vk;
            if (isNaN_(p) || isInfinity(p)) {
                p = 0;
            }
            if (isNaN_(q) || isInfinity(q)) {
                q = 50;
            }
            this.ux = Math.min(p, q);
            this.uw = Math.max(p, q);
            if (this.ux < 0) {
                this.ux = 0;
            }
            if (this.uw < 0) {
                this.uw = 0;
            }
            this.uy = this.uw - this.ux;
            if (this.uq) {
                this.wr(a);
            }
            else {
                this.w2(a);
            }
            f.cc();
            if (a.q) {
                this._itemIndexes = d;
                this.t7.cd();
            }
        }
        wt(a) {
            if (this.t8 == null) {
                return;
            }
            this.wv(a);
        }
        wn(a, b) {
            this.t7.cb(() => {
                if (this.vn < this.vo - 1) {
                    this.vn++;
                }
                this.vy = truncate(((this.vn / this.vo) * 100));
                if (this.progressiveLoadStatusChanged != null) {
                    this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.vy));
                }
                this.wt(this.cg);
                this.om();
                if (this.t8 != null) {
                    if (!this.t8.f(this.i5)) {
                        let c = this.t8;
                        c.progressiveThunkCompleted = delegateRemove(c.progressiveThunkCompleted, runOn(this, this.wn));
                        this.vy = 100;
                        if (this.progressiveLoadStatusChanged != null) {
                            this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.vy));
                        }
                    }
                }
            });
        }
        wr(a) {
            let b = arrayShallowClone(this.uh.asArray());
            this.ua.hn(boxArray$1(b), 0, b.length, this.ud);
            let c = arrayShallowClone(this.uj.asArray());
            this.vt = 0;
            let d = this.vr;
            let e = this.uk;
            let f = this.t6.length;
            this.uc.hn(boxArray$1(c), 0, c.length, this.ue);
            let g = 255 << 24 | truncate(this.u6) << 16 | truncate(this.u5) << 8 | truncate(this.u4);
            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.vq || j < 0 || j >= this.vp) {
                    continue;
                }
                if (e) {
                    let k = i - d;
                    let l = i + d;
                    l = l > (this.vq - 1) ? (this.vq - 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.vq) + o;
                            if (q < 0 || q > f - 1) {
                                continue;
                            }
                            this.t6[q] = this.t6[q] + 1;
                            this.t3[q] = 1;
                            this.vt++;
                            if (this.um) {
                                this._itemIndexes[q] = h + 1;
                            }
                        }
                    }
                }
                else {
                    let r = (j * this.vq) + i;
                    this.t6[r] = this.t6[r] + 1;
                    this.t3[r] = 1;
                    this.vt++;
                    if (this.um) {
                        this._itemIndexes[r] = h + 1;
                    }
                }
            }
            this.ww();
        }
        w2(a) {
            let b;
            let c;
            let d = a.getViewInfo(b, c);
            b = d.p0;
            c = d.p1;
            if (this.t8 == null) {
                return;
            }
            if (this.ur == null) {
                this.ur = new List$1(KDTreeNode2D.$, 2, truncate(Math.round(b.width * b.height)));
            }
            else {
                this.ur.clear();
            }
            let e = c.left;
            let f = c.right;
            let g = c.top;
            let h = c.bottom;
            this.vh = c.top;
            this.vf = c.height;
            this.vg = c.left;
            this.vi = c.width;
            this.vd = b.top;
            this.vb = b.height;
            this.vc = b.left;
            this.ve = b.width;
            let i = this.getEffectiveViewport1(a);
            this.ut = (i.left - this.vc) / this.ve;
            this.uu = (i.top - this.vd) / this.vb;
            let j = (i.right - this.vc) / this.ve;
            this.uv = j - this.ut;
            let k = (i.bottom - this.vd) / this.vb;
            this.us = k - this.uu;
            if (this.ul) {
                e = (e - this.ut) / this.uv;
                f = (f - this.ut) / this.uv;
                g = (g - this.uu) / this.us;
                h = (h - this.uu) / this.us;
            }
            let l = this.hk / b.width * c.width;
            let m = this.hk / 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.t8.t(this.ur, o, 0, 1, 0, 1);
            let p;
            this.vt = 0;
            for (let q = 0; q < this.ur.count; q++) {
                p = this.ur._inner[q];
                this.wx(p);
            }
            this.ww();
        }
        wx(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.wz(a.b, d, b, a.e);
            if (c > 0 && !b) {
                let e;
                for (let f = 0; f < c; f++) {
                    e = a.a[f];
                    this.wz(e, d, false, a.e);
                }
            }
            if (a.e != null) {
                a.e.a = false;
            }
        }
        fp(a) {
            let b = this.cv != null ? this.cv.tr : Rect.empty;
            let c = this.cv != null ? this.cv.t6 : Rect.empty;
            let d = new Rect(0, 0, 0, 1, 1);
            let e = this.ts(this.cg);
            let f = new ScalerParams(0, d, d, this.ua.ch, e);
            let g = new ScalerParams(0, d, d, this.uc.ch, e);
            let h = !b.isEmpty && !c.isEmpty && this.c7 != null ? this.c7.indexOf(a) : -1;
            let i = this.ua != null && this.uh != null && h < this.uh.count ? this.ua.ej(this.uh.item(h), f) : NaN;
            let j = this.uc != null && this.uj != null && h < this.uj.count ? this.uc.ej(this.uj.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.co != null) {
                this.co.au(this.cv, b, true);
            }
            return h >= 0;
        }
        wz(a, b, c, d) {
            let e = this.vw(b);
            let f = a.c;
            let g = this.vr;
            if (c) {
                let h = d.d;
                let i = d.b;
                let j = d.e;
                let k = d.c;
                if (this.ul) {
                    h = this.ut + this.uv * h;
                    i = this.ut + this.uv * i;
                    j = this.uu + this.us * j;
                    k = this.uu + this.us * k;
                }
                let l = truncate((this.vc + this.ve * (h - this.vg) / this.vi));
                let m = truncate((this.vc + this.ve * (i - this.vg) / this.vi));
                let n = truncate((this.vd + this.vb * (j - this.vh) / this.vf));
                let o = truncate((this.vd + this.vb * (k - this.vh) / this.vf));
                l = truncate(Math.floor(l));
                m = truncate(Math.floor(m));
                n = truncate(Math.floor(n));
                o = truncate(Math.floor(o));
                if (this.uk) {
                    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.wy(f, s, t, q, r);
                    }
                }
            }
            else {
                let u = a.a;
                let v = a.b;
                if (this.ul) {
                    u = this.ut + this.uv * u;
                    v = this.uu + this.us * v;
                }
                let w = truncate((this.vc + this.ve * (u - this.vg) / this.vi));
                let x = truncate((this.vd + this.vb * (v - this.vh) / this.vf));
                w = truncate(Math.floor(w));
                x = truncate(Math.floor(x));
                if (this.uk) {
                    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.wy(f, af, ag, ad, ae);
                        }
                    }
                }
                else {
                    this.wy(f, w, x, b, 1);
                }
            }
        }
        vv(a, b) {
            return truncate((Math.floor(255 * b))) << 24 | truncate(Math.floor(b * (this.u6 + a * this.va))) << 16 | truncate(Math.floor(b * (this.u5 + a * this.u9))) << 8 | truncate(Math.floor(b * (this.u4 + a * this.u8)));
        }
        vw(a) {
            return 255 << 24 | truncate(Math.floor((this.u6 + a * this.va))) << 16 | truncate(Math.floor((this.u5 + a * this.u9))) << 8 | truncate(Math.floor((this.u4 + a * this.u8)));
        }
        vj(a) {
            return (a >> 24 & 255) / 255;
        }
        wy(a, b, c, d, e) {
            if (b < 0 || b >= this.vq || c < 0 || c >= this.vp) {
                return;
            }
            let f = (c * this.vq) + b;
            this.t6[f] = this.t6[f] + d;
            this.t3[f] = this.t3[f] + e;
            if (this.um) {
                this._itemIndexes[f] = a + 1;
            }
            this.vt += truncate(d);
        }
        ww() {
            let a = 0;
            let b = 0;
            let c = this.uy;
            let d = this.ux;
            let e = this.uw;
            let f = this.t6.length;
            let g = this.t6;
            let h = this.t3;
            let i = this.t5;
            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.vv(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;
            }
        }
        wo(a) {
            let b = a;
            b.b9();
        }
        cd() {
            return new HighDensityScatterSeriesView(this);
        }
        o2(a) {
            super.o2(a);
            this.t7 = a;
        }
        aq(a) {
            if (a != null && a == this.ua && this.uh != null) {
                return new AxisRange(this.uh.minimum, this.uh.maximum);
            }
            if (a != null && a == this.uc && this.uj != null) {
                return new AxisRange(this.uj.minimum, this.uj.maximum);
            }
            return null;
        }
        qo(a, b) {
            if (this.cv != null) {
                let c = this.getEffectiveViewport1(this.cg);
                this.ul = !c.isEmpty;
            }
            this.pr(false);
        }
        qp(a, b) {
            this.pr(false);
        }
        js(a) {
            if (!this.um || this._itemIndexes == null || this.cv == null || this.c7 == null || this._itemIndexes.length != (this.vq * this.vp)) {
                return null;
            }
            let b = this.cv.tr;
            let c = (a.x - b.left) / b.width;
            let d = (a.y - b.top) / b.height;
            let e = truncate(Math.round(this.ty.left + (this.ty.width * c)));
            let f = truncate(Math.round(this.ty.top + (this.ty.height * d)));
            let g = this.vz(e, f);
            if (g < 0 || g > this._itemIndexes.length - 1) {
                return null;
            }
            let h = this._itemIndexes[g] - 1;
            if (h < 0 || h > this.c7.count) {
                return null;
            }
            return this.c7.item(h);
        }
        vz(a, b) {
            let c = (this.vq * b) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            let d = 1;
            c = (this.vq * (b - d)) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.vq * (b + d)) + a;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.vq * (b)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.vq * (b)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.vq * (b - d)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.vq * (b + d)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.vq * (b - d)) + a + 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            c = (this.vq * (b + d)) + a - 1;
            if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
                return c;
            }
            return 0;
        }
        w1(a, b, c) {
            this.t5 = a;
            this.vq = b;
            this.vp = c;
        }
        get_gg() {
            return true;
        }
        set_gg(a) {
            super.set_gg(a);
        }
        nk(a, b) {
            super.nk(a, b);
            this.t7.ca();
            if (this.cf != null) {
                this.cf.ca();
            }
            this.om();
        }
        pt(a, b) {
            super.pt(a, b);
            if (!this.f9) {
                this.cg.a4(b);
                return;
            }
            this.cg.a4(b);
            if (this.dm(this.cf)) {
                return;
            }
            let c = typeCast(HighDensityScatterSeriesView.$, this.cf);
            let d = new ScatterFrame();
            this.ws(false, c);
            this.f9 = false;
        }
        pq(a, b, c, d, e) {
            super.pq(a, b, c, d, e);
            let f = this.a3.a$h.item(d);
            let g = f;
            f.a3(c);
            if (this.dm(g)) {
                return;
            }
            if (this.uf == null) {
                this.uf = new ScatterFrame();
            }
            this.ws(false, f);
        }
        nh() {
            super.nh();
            this.ua = null;
            this.uc = null;
        }
    }
    HighDensityScatterSeries.$t = /*@__PURE__*/ markType(HighDensityScatterSeries, 'HighDensityScatterSeries', Series.$);
    HighDensityScatterSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, HighDensityScatterSeries, 'raisePropertyChanged', ['HeatMaximumColor:xi:w3', [Color.$, Defaults.ap], 'HeatMaximum:vk:w4', [1, 50], 'HeatMinimumColor:xj:w5', [Color.$, Defaults.aq], 'HeatMinimum:vl:w6', [1, 0], 'PointExtent:vx:w7', [1, 1], 'ProgressiveLoad:up:w8', [0, true], 'UseBruteForce:uq:w9', [0, false], 'XAxis:ua:xa', [NumericXAxis.$, null], 'XMemberAsLegendLabel:v9:xb', [2, null], 'XMemberAsLegendUnit:wb:xc', [2, null], 'XMemberPath:wd:xd', [2, null], 'YAxis:uc:xe', [NumericYAxis.$, null], 'YMemberAsLegendLabel:wh:xf', [2, null], 'YMemberAsLegendUnit:wj:xg', [2, null], 'YMemberPath:wl:xh', [2, null]]);
    return HighDensityScatterSeries;
})();
/**
 * @hidden
 */
export let HighDensityScatterSeriesView = /*@__PURE__*/ (() => {
    class HighDensityScatterSeriesView extends SeriesView {
        constructor(a) {
            super(a);
            this.b2 = null;
            this.b0 = null;
            this.b8 = 0;
            this.b7 = 0;
            this.b5 = null;
            this.b6 = null;
            this.b3 = null;
            this.b2 = a;
        }
        au() {
            super.au();
            if (!this.q) {
                this.b2.xj = Defaults.aq;
                this.b2.xi = Defaults.ap;
                this.b2.sy = Defaults.al;
                this.b2.s4 = Defaults.ak;
            }
        }
        cd() {
            this.b2.w1(this.b0, this.b8, this.b7);
        }
        b9() {
            if (this.b5 == null) {
                this.b5 = this.e.i5.createElement("canvas");
                let a = this.e.i5.get2DCanvasContext(this.b5);
                this.b3 = new RenderingContext(new CanvasViewRenderer(), a);
            }
            let b;
            if (this.p) {
                b = this.bx;
            }
            else {
                b = this.e.cv.tw();
            }
            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.b8;
            let h = this.b7;
            this.b8 = e;
            this.b7 = f;
            if (g != this.b8 || h != this.b7 || this.b0 == null) {
                this.b5.setAttribute("width", e.toString());
                this.b5.setAttribute("height", f.toString());
                this.b6 = this.b3.h().getImageData(0, 0, e, f);
                let imageDataArray_ = this.b6.data;
                this.b0 = imageDataArray_;
            }
            this.b2.w1(this.b0, this.b8, this.b7);
        }
        b1() {
            return this.b0;
        }
        cc() {
            let a = truncate(Math.round(this.bx.left));
            let b = truncate(Math.round(this.bx.left));
            let c = truncate(Math.round(this.bx.width));
            let d = truncate(Math.round(this.bx.height));
            this.b3.h().putImageData(this.b6, 0, 0);
            this.as();
        }
        cb(a) {
            if (this.e.i5 != null) {
                this.e.i5.setTimeout(a, 0);
            }
            else {
                window.setTimeout(a, 0);
            }
        }
        a8(a, b) {
            super.a8(a, b);
            if (b) {
                if (!this.b2.fl) {
                    return;
                }
                let c = new Rectangle();
                c.n = this.bx.left;
                c.o = this.bx.top;
                c.width = this.bx.width;
                c.height = this.bx.height;
                c._fill = this.br();
                a.w(c);
                return;
            }
            if (this.b5 == null) {
                return;
            }
            let d = truncate(Math.round(this.bx.left));
            let e = truncate(Math.round(this.bx.top));
            let f = truncate(Math.round(this.bx.width));
            let g = truncate(Math.round(this.bx.height));
            this.k.o(this.b5.getNativeElement(), this.e._opacity, d, e, f, g, d, e, f, g);
        }
        b4(a, b) {
            return Color.e(toNullable(Color.$, a), toNullable(Color.$, null)) && Color.e(toNullable(Color.$, b), toNullable(Color.$, null));
        }
        ca() {
            if (this.b0 != null) {
                for (let a = 0; a < this.b0.length; a++) {
                    this.b0[a] = 0;
                }
                this.cc();
            }
        }
        an(a) {
            super.an(a);
            if (this.b0 == null) {
                this.e.a5.exportSeriesPixelsData(a, null, this.b8, this.b7);
                return;
            }
            let b = new Array(intDivide(this.b0.length, 4));
            let c;
            for (let d = 0; d < intDivide(this.b0.length, 4); d++) {
                c = d * 4;
                b[d] = this.b0[c + 3] << 24 | this.b0[c] << 16 | this.b0[c + 1] << 8 | this.b0[c + 2];
            }
            this.e.a5.exportSeriesPixelsData(a, b, this.b8, this.b7);
        }
    }
    HighDensityScatterSeriesView.$t = /*@__PURE__*/ markType(HighDensityScatterSeriesView, 'HighDensityScatterSeriesView', SeriesView.$);
    return HighDensityScatterSeriesView;
})();
