/*
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/ES2015/DependencyProperty";
import { NumericYAxis } from "./NumericYAxis";
import { Color } from "igniteui-react-core/ES2015/Color";
import { ScatterFrame } from "./ScatterFrame";
import { KDTree2D } from "./KDTree2D";
import { Type, typeGetValue, runOn, delegateRemove, typeCast, delegateCombine, markType, Nullable$1 } from "igniteui-react-core/ES2015/type";
import { Rect } from "igniteui-react-core/ES2015/Rect";
import { IFastItemsSource_$type } from "igniteui-react-core/ES2015/IFastItemsSource";
import { SeriesView } from "./SeriesView";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
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/ES2015/PropertyMetadata";
import { truncate, isNaN_, isInfinity, logBase, intDivide } from "igniteui-react-core/ES2015/number";
import { boxArray$1, arrayShallowClone } from "igniteui-react-core/ES2015/array";
import { dateNow } from "igniteui-react-core/ES2015/date";
import { RenderingContext } from "igniteui-react-core/ES2015/RenderingContext";
import { CanvasViewRenderer } from "igniteui-react-core/ES2015/CanvasViewRenderer";
import { Rectangle } from "igniteui-react-core/ES2015/Rectangle";
export class HighDensityScatterSeries extends Series {
    constructor() {
        super();
        this.l4 = null;
        this.l6 = null;
        this.nc = 0;
        this.l8 = false;
        this.ms = 0;
        this.mr = 0;
        this.mq = 0;
        this.mp = 255;
        this.mo = 0;
        this.mn = 0;
        this.mv = 255;
        this.mu = 0;
        this.mt = 0;
        this.lw = null;
        this.l1 = null;
        this.l2 = null;
        this.lx = null;
        this.lz = null;
        this.ma = false;
        this.nd = 0;
        this.nf = 0;
        this.m9 = 0;
        this.m8 = 0;
        this.progressiveLoadStatusChanged = null;
        this.mf = null;
        this.ml = 0;
        this.mk = 0;
        this.mm = 0;
        this.my = 0;
        this.mw = 0;
        this.mx = 0;
        this.mz = 0;
        this.m1 = 0;
        this.m3 = 0;
        this.m2 = 0;
        this.m0 = 0;
        this.mh = 0;
        this.mi = 0;
        this.mj = 0;
        this.mg = 0;
        this.nb = 0;
        this.na = 0;
        this.lt = null;
        this.ne = 0;
        this.l9 = false;
        this._itemIndexes = null;
        this.lu = null;
        this.lr = null;
        this.l3 = null;
        this.ab = HighDensityScatterSeries.$;
        this.c5 = false;
    }
    get_c4() {
        return true;
    }
    get l5() {
        return this.l4;
    }
    set l5(a) {
        if (this.l4 != a) {
            let b = this.l5;
            this.l4 = a;
            this.raisePropertyChanged("XColumn", b, this.l5);
        }
    }
    get l7() {
        return this.l6;
    }
    set l7(a) {
        if (this.l6 != a) {
            let b = this.l7;
            this.l6 = a;
            this.raisePropertyChanged("YColumn", b, this.l7);
        }
    }
    oc() {
        if (this.lw == null) {
            return;
        }
        this.lw.s();
        let a = this.lw;
        a.progressiveThunkCompleted = delegateRemove(a.progressiveThunkCompleted, runOn(this, this.n0));
        this.lw = null;
    }
    ir(a, b, c, d) {
        super.ir(a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                if (this.bs != null) {
                    let e = this.getEffectiveViewport1(this.bi);
                    this.l9 = !e.isEmpty;
                }
                break;
            case "FastItemsSource":
                this.oc();
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.l5);
                    c.deregisterColumn(this.l7);
                    this.l5 = null;
                    this.l7 = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.l5 = this.bw(this.nu);
                    this.l7 = this.bw(this.ny);
                }
                if ((this.l0 != null && !this.l0.ck()) || (this.ly != null && !this.ly.ck())) {
                    this.i4(false);
                }
                this.ic();
                break;
            case HighDensityScatterSeries.$$p[7]:
                let f = this.lx;
                this.lx = this.ly;
                this.oc();
                if (f != null) {
                    f.rangeChanged = delegateRemove(f.rangeChanged, runOn(this, this.n3));
                }
                if (this.lx != null) {
                    let g = this.lx;
                    g.rangeChanged = delegateCombine(g.rangeChanged, runOn(this, this.n3));
                }
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ch(this);
                }
                if ((this.ly != null && !this.ly.ck()) || (d == null && c != null)) {
                    this.i4(false);
                }
                break;
            case HighDensityScatterSeries.$$p[9]:
                let h = this.lz;
                this.lz = this.l0;
                this.oc();
                if (h != null) {
                    h.rangeChanged = delegateRemove(h.rangeChanged, runOn(this, this.n3));
                }
                if (this.lz != null) {
                    let i = this.lz;
                    i.rangeChanged = delegateCombine(i.rangeChanged, runOn(this, this.n3));
                }
                if (c != null) {
                    c.bv(this);
                }
                if (d != null) {
                    d.ch(this);
                }
                if ((this.l0 != null && !this.l0.ck()) || (d == null && c != null)) {
                    this.i4(false);
                }
                break;
            case "MouseOverEnabled":
                this.ma = this.c5;
                this.i4(false);
                break;
            case HighDensityScatterSeries.$$p[8]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.l5);
                    this.l5 = this.bw(this.nu);
                }
                break;
            case "XColumn":
                this.oc();
                if (this.ly != null && !this.ly.ck()) {
                    this.i4(false);
                }
                this.ic();
                break;
            case HighDensityScatterSeries.$$p[10]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.l7);
                    this.l7 = this.bw(this.ny);
                }
                break;
            case "YColumn":
                this.oc();
                if (this.l0 != null && !this.l0.ck()) {
                    this.i4(false);
                }
                this.ic();
                break;
            case HighDensityScatterSeries.$$p[6]:
                this.oc();
                this.i4(false);
                this.ib();
                break;
            case HighDensityScatterSeries.$$p[3]:
                this.i4(false);
                this.ib();
                break;
            case HighDensityScatterSeries.$$p[1]:
                this.i4(false);
                this.ib();
                break;
            case HighDensityScatterSeries.$$p[0]:
            case HighDensityScatterSeries.$$p[2]:
                if (!this.lv.by(this.or, this.oq)) {
                    return;
                }
                this.ms = this.or.o;
                this.mr = this.or.n;
                this.mq = this.or.m;
                this.mp = this.oq.o;
                this.mo = this.oq.n;
                this.mn = this.oq.m;
                this.mv = this.mp - this.ms;
                this.mu = this.mo - this.mr;
                this.mt = this.mn - this.mq;
                this.i4(false);
                this.ib();
                break;
            case HighDensityScatterSeries.$$p[4]:
                this.nc = Math.max(typeGetValue(d) - 1, 0);
                this.l8 = this.nc > 0;
                this.i4(false);
                this.ib();
                break;
            case HighDensityScatterSeries.$$p[5]:
                this.i4(false);
                this.ib();
                break;
        }
    }
    mc(a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    }
    mb(a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    }
    n3(a, b) {
        this.oc();
        this.i4(false);
    }
    du(a, b, c) {
        let d = super.du(a, b, c);
        if (this.l0 == null || this.ly == null || this.ly.bf == null || this.l0.bf == null || this.l7 == null || this.l5 == null || this.l7.count < 1 || this.l5.count < 1 || this.l7.count != this.l5.count || this.ly.jx == this.ly.jw || this.l0.jx == this.l0.jw || this.lp.isEmpty) {
            d = false;
        }
        return d;
    }
    get nj() {
        return this.nd;
    }
    set nj(a) {
        let b = this.nd;
        this.nd = a;
        this.raisePropertyChanged("ProgressiveStatus", b, this.nd);
    }
    i5(a) {
        super.i5(a);
        this.n5(a, this.bi);
    }
    n5(a, b) {
        if (this.cc(b)) {
            return;
        }
        if (this.lw == null && !this.me) {
            let c = new List$1(KDPointData.$, 2, this.l5.count);
            let d = this.ly;
            let e = this.l0;
            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.b8);
            let i = new ScalerParams(1, f, g, e.b8);
            let j;
            let k;
            for (let l = 0; l < this.l5.count; l++) {
                j = d.dt(this.l5.item(l), h);
                k = e.dt(this.l7.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.md) {
                this.m8 = 1;
                this.m9 = truncate(logBase(c.count, 2)) + 3;
                this.nj = truncate(((this.m8 / this.m9) * 100));
                if (this.progressiveLoadStatusChanged != null) {
                    this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.nj));
                }
                this.lw = KDTree2D.b(c.toArray(), 1);
                let m = this.lw;
                m.progressiveThunkCompleted = delegateCombine(m.progressiveThunkCompleted, runOn(this, this.n0));
                if (!this.lw.f(this.e0)) {
                    let n = this.lw;
                    n.progressiveThunkCompleted = delegateRemove(n.progressiveThunkCompleted, runOn(this, this.n0));
                }
                this.ib();
            }
            else {
                let o = dateNow();
                this.lw = new KDTree2D(0, c.toArray(), 1);
                let p = dateNow();
            }
        }
        if (this.md && !this.me) {
            this.n6(b);
        }
        else {
            this.n7(b);
        }
    }
    hr(a, b, c, d) {
        super.hr(a, b, c, d);
        this.oc();
        let e = false;
        if (this.ly != null && !this.ly.ck()) {
            e = true;
        }
        if (this.l0 != null && !this.l0.ck()) {
            e = true;
        }
        if (e) {
            this.i4(false);
        }
        this.ic();
    }
    n2(a) {
        let b = a;
        let c = this.nb * this.na;
        if (this.ma) {
            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;
                }
            }
        }
    }
    n7(a) {
        let b;
        let c;
        let d = null;
        if (a.n) {
            d = this._itemIndexes;
        }
        let e = a.getViewInfo(c, b);
        c = e.p0;
        b = e.p1;
        let f = a;
        let g = this.getEffectiveViewport1(a);
        this.l1 = new ScalerParams(0, b, c, this.lx.b8, g);
        this.l2 = new ScalerParams(0, b, c, this.lz.b8, g);
        this.n1(a);
        this.n2(a);
        let h = this.nb * this.na;
        if (this.lu == null || this.lu.length != h) {
            this.lu = new Array(h);
            this.lr = new Array(h);
        }
        let i = this.lu.length;
        let j = this.lu;
        let k = this.lr;
        for (let l = 0; l < i; l++) {
            j[l] = 0;
            k[l] = 0;
        }
        this.nf = truncate(Math.round(this.eq));
        this.lt = f.bv();
        let m = this.lt.length;
        let n = this.lt;
        for (let o = 0; o < m; o++) {
            n[o] = 0;
        }
        let p = this.m6;
        let q = this.m5;
        if (isNaN_(p) || isInfinity(p)) {
            p = 0;
        }
        if (isNaN_(q) || isInfinity(q)) {
            q = 50;
        }
        this.ml = Math.min(p, q);
        this.mk = Math.max(p, q);
        if (this.ml < 0) {
            this.ml = 0;
        }
        if (this.mk < 0) {
            this.mk = 0;
        }
        this.mm = this.mk - this.ml;
        if (this.me) {
            this.n4(a);
        }
        else {
            this.oe(a);
        }
        f.b6();
        if (a.n) {
            this._itemIndexes = d;
            this.lv.b7();
        }
    }
    n6(a) {
        if (this.lw == null) {
            return;
        }
        this.n7(a);
    }
    n0(a, b) {
        this.lv.b5(() => {
            if (this.m8 < this.m9 - 1) {
                this.m8++;
            }
            this.nj = truncate(((this.m8 / this.m9) * 100));
            if (this.progressiveLoadStatusChanged != null) {
                this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.nj));
            }
            this.n6(this.bi);
            this.ib();
            if (this.lw != null) {
                if (!this.lw.f(this.e0)) {
                    let c = this.lw;
                    c.progressiveThunkCompleted = delegateRemove(c.progressiveThunkCompleted, runOn(this, this.n0));
                    this.nj = 100;
                    if (this.progressiveLoadStatusChanged != null) {
                        this.progressiveLoadStatusChanged(this, new ProgressiveLoadStatusEventArgs(this.nj));
                    }
                }
            }
        });
    }
    n4(a) {
        let b = arrayShallowClone(this.l5.asArray());
        this.ly.gh(boxArray$1(b), 0, b.length, this.l1);
        let c = arrayShallowClone(this.l7.asArray());
        this.ne = 0;
        let d = this.nc;
        let e = this.l8;
        let f = this.lu.length;
        this.l0.gh(boxArray$1(c), 0, c.length, this.l2);
        let g = 255 << 24 | truncate(this.ms) << 16 | truncate(this.mr) << 8 | truncate(this.mq);
        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.nb || j < 0 || j >= this.na) {
                continue;
            }
            if (e) {
                let k = i - d;
                let l = i + d;
                l = l > (this.nb - 1) ? (this.nb - 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.nb) + o;
                        if (q < 0 || q > f - 1) {
                            continue;
                        }
                        this.lu[q] = this.lu[q] + 1;
                        this.lr[q] = 1;
                        this.ne++;
                        if (this.ma) {
                            this._itemIndexes[q] = h + 1;
                        }
                    }
                }
            }
            else {
                let r = (j * this.nb) + i;
                this.lu[r] = this.lu[r] + 1;
                this.lr[r] = 1;
                this.ne++;
                if (this.ma) {
                    this._itemIndexes[r] = h + 1;
                }
            }
        }
        this.n8();
    }
    oe(a) {
        let b;
        let c;
        let d = a.getViewInfo(b, c);
        b = d.p0;
        c = d.p1;
        if (this.lw == null) {
            return;
        }
        if (this.mf == null) {
            this.mf = new List$1(KDTreeNode2D.$, 2, truncate(Math.round(b.width * b.height)));
        }
        else {
            this.mf.clear();
        }
        let e = c.left;
        let f = c.right;
        let g = c.top;
        let h = c.bottom;
        this.m2 = c.top;
        this.m0 = c.height;
        this.m1 = c.left;
        this.m3 = c.width;
        this.my = b.top;
        this.mw = b.height;
        this.mx = b.left;
        this.mz = b.width;
        let i = this.getEffectiveViewport1(a);
        this.mh = (i.left - this.mx) / this.mz;
        this.mi = (i.top - this.my) / this.mw;
        let j = (i.right - this.mx) / this.mz;
        this.mj = j - this.mh;
        let k = (i.bottom - this.my) / this.mw;
        this.mg = k - this.mi;
        if (this.l9) {
            e = (e - this.mh) / this.mj;
            f = (f - this.mh) / this.mj;
            g = (g - this.mi) / this.mg;
            h = (h - this.mi) / this.mg;
        }
        let l = this.eq / b.width * c.width;
        let m = this.eq / 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.lw.t(this.mf, o, 0, 1, 0, 1);
        let p;
        this.ne = 0;
        for (let q = 0; q < this.mf.count; q++) {
            p = this.mf._inner[q];
            this.n9(p);
        }
        this.n8();
    }
    n9(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.ob(a.b, d, b, a.e);
        if (c > 0 && !b) {
            let e;
            for (let f = 0; f < c; f++) {
                e = a.a[f];
                this.ob(e, d, false, a.e);
            }
        }
        if (a.e != null) {
            a.e.a = false;
        }
    }
    c7(a) {
        let b = this.bs != null ? this.bs.mn : Rect.empty;
        let c = this.bs != null ? this.bs.m0 : Rect.empty;
        let d = new Rect(0, 0, 0, 1, 1);
        let e = this.lj(this.bi);
        let f = new ScalerParams(0, d, d, this.ly.b8, e);
        let g = new ScalerParams(0, d, d, this.l0.b8, e);
        let h = !b.isEmpty && !c.isEmpty && this.bz != null ? this.bz.indexOf(a) : -1;
        let i = this.ly != null && this.l5 != null && h < this.l5.count ? this.ly.dt(this.l5.item(h), f) : NaN;
        let j = this.l0 != null && this.l7 != null && h < this.l7.count ? this.l0.dt(this.l7.item(h), g) : NaN;
        if (!isNaN_(i)) {
            if (i < b.left + 0.1 * b.width) {
                i = i + 0.4 * b.width;
                b.x = i - 0.5 * b.width;
            }
            if (i > b.right - 0.1 * b.width) {
                i = i - 0.4 * b.width;
                b.x = i - 0.5 * b.width;
            }
        }
        if (!isNaN_(j)) {
            if (j < b.top + 0.1 * b.height) {
                j = j + 0.4 * b.height;
                b.y = j - 0.5 * b.height;
            }
            if (j > b.bottom - 0.1 * b.height) {
                j = j - 0.4 * b.height;
                b.y = j - 0.5 * b.height;
            }
        }
        if (this.bn != null) {
            this.bn.ap(this.bs, b, true);
        }
        return h >= 0;
    }
    ob(a, b, c, d) {
        let e = this.nh(b);
        let f = a.c;
        let g = this.nc;
        if (c) {
            let h = d.d;
            let i = d.b;
            let j = d.e;
            let k = d.c;
            if (this.l9) {
                h = this.mh + this.mj * h;
                i = this.mh + this.mj * i;
                j = this.mi + this.mg * j;
                k = this.mi + this.mg * k;
            }
            let l = truncate((this.mx + this.mz * (h - this.m1) / this.m3));
            let m = truncate((this.mx + this.mz * (i - this.m1) / this.m3));
            let n = truncate((this.my + this.mw * (j - this.m2) / this.m0));
            let o = truncate((this.my + this.mw * (k - this.m2) / this.m0));
            l = truncate(Math.floor(l));
            m = truncate(Math.floor(m));
            n = truncate(Math.floor(n));
            o = truncate(Math.floor(o));
            if (this.l8) {
                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.oa(f, s, t, q, r);
                }
            }
        }
        else {
            let u = a.a;
            let v = a.b;
            if (this.l9) {
                u = this.mh + this.mj * u;
                v = this.mi + this.mg * v;
            }
            let w = truncate((this.mx + this.mz * (u - this.m1) / this.m3));
            let x = truncate((this.my + this.mw * (v - this.m2) / this.m0));
            w = truncate(Math.floor(w));
            x = truncate(Math.floor(x));
            if (this.l8) {
                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.oa(f, af, ag, ad, ae);
                    }
                }
            }
            else {
                this.oa(f, w, x, b, 1);
            }
        }
    }
    ng(a, b) {
        return truncate((Math.floor(255 * b))) << 24 | truncate(Math.floor(b * (this.ms + a * this.mv))) << 16 | truncate(Math.floor(b * (this.mr + a * this.mu))) << 8 | truncate(Math.floor(b * (this.mq + a * this.mt)));
    }
    nh(a) {
        return 255 << 24 | truncate(Math.floor((this.ms + a * this.mv))) << 16 | truncate(Math.floor((this.mr + a * this.mu))) << 8 | truncate(Math.floor((this.mq + a * this.mt)));
    }
    m4(a) {
        return (a >> 24 & 255) / 255;
    }
    oa(a, b, c, d, e) {
        if (b < 0 || b >= this.nb || c < 0 || c >= this.na) {
            return;
        }
        let f = (c * this.nb) + b;
        this.lu[f] = this.lu[f] + d;
        this.lr[f] = this.lr[f] + e;
        if (this.ma) {
            this._itemIndexes[f] = a + 1;
        }
        this.ne += truncate(d);
    }
    n8() {
        let a = 0;
        let b = 0;
        let c = this.mm;
        let d = this.ml;
        let e = this.mk;
        let f = this.lu.length;
        let g = this.lu;
        let h = this.lr;
        let i = this.lt;
        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.ng(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;
        }
    }
    n1(a) {
        let b = a;
        b.b3();
    }
    bf() {
        return new HighDensityScatterSeriesView(this);
    }
    il(a) {
        super.il(a);
        this.lv = a;
    }
    an(a) {
        if (a != null && a == this.ly && this.l5 != null) {
            return new AxisRange(this.l5.minimum, this.l5.maximum);
        }
        if (a != null && a == this.l0 && this.l7 != null) {
            return new AxisRange(this.l7.minimum, this.l7.maximum);
        }
        return null;
    }
    jj(a, b) {
        if (this.bs != null) {
            let c = this.getEffectiveViewport1(this.bi);
            this.l9 = !c.isEmpty;
        }
        this.i4(false);
    }
    jk(a, b) {
        this.i4(false);
    }
    fl(a) {
        if (!this.ma || this._itemIndexes == null || this.bs == null || this.bz == null || this._itemIndexes.length != (this.nb * this.na)) {
            return null;
        }
        let b = this.bs.mn;
        let c = (a.x - b.left) / b.width;
        let d = (a.y - b.top) / b.height;
        let e = truncate(Math.round(this.lp.left + (this.lp.width * c)));
        let f = truncate(Math.round(this.lp.top + (this.lp.height * d)));
        let g = this.nk(e, f);
        if (g < 0 || g > this._itemIndexes.length - 1) {
            return null;
        }
        let h = this._itemIndexes[g] - 1;
        if (h < 0 || h > this.bz.count) {
            return null;
        }
        return this.bz.item(h);
    }
    nk(a, b) {
        let c = (this.nb * b) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        let d = 1;
        c = (this.nb * (b - d)) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nb * (b + d)) + a;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nb * (b)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nb * (b)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nb * (b - d)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nb * (b + d)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nb * (b - d)) + a + 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        c = (this.nb * (b + d)) + a - 1;
        if (c > 0 && c < this._itemIndexes.length && this._itemIndexes[c] > 0) {
            return c;
        }
        return 0;
    }
    od(a, b, c) {
        this.lt = a;
        this.nb = b;
        this.na = c;
    }
    get_dn() {
        return true;
    }
    set_dn(a) {
        super.set_dn(a);
    }
    ho(a, b) {
        super.ho(a, b);
        this.lv.b4();
        if (this.bh != null) {
            this.bh.b4();
        }
        this.ib();
    }
    i6(a, b) {
        super.i6(a, b);
        if (!this.dj) {
            this.bi.az(b);
            return;
        }
        this.bi.az(b);
        if (this.cc(this.bh)) {
            return;
        }
        let c = typeCast(HighDensityScatterSeriesView.$, this.bh);
        let d = new ScatterFrame();
        this.n5(false, c);
        this.dj = false;
    }
    i3(a, b, c, d, e) {
        super.i3(a, b, c, d, e);
        let f = this.a0.a$h.item(d);
        let g = f;
        f.ay(c);
        if (this.cc(g)) {
            return;
        }
        if (this.l3 == null) {
            this.l3 = new ScatterFrame();
        }
        this.n5(false, f);
    }
    hm() {
        super.hm();
        this.ly = null;
        this.l0 = null;
    }
}
HighDensityScatterSeries.$t = markType(HighDensityScatterSeries, 'HighDensityScatterSeries', Series.$);
Type.dep(DependencyProperty, PropertyMetadata, HighDensityScatterSeries, 'raisePropertyChanged', ['HeatMaximumColor:oq:of', [Color.$, null], 'HeatMaximum:m5:og', [1, 50], 'HeatMinimumColor:or:oh', [Color.$, null], 'HeatMinimum:m6:oi', [1, 0], 'PointExtent:ni:oj', [1, 1], 'ProgressiveLoad:md:ok', [0, true], 'UseBruteForce:me:ol', [0, false], 'XAxis:ly:om', [NumericXAxis.$, null], 'XMemberPath:nu:on', [2, null], 'YAxis:l0:oo', [NumericYAxis.$, null], 'YMemberPath:ny:op', [2, null]]);
export class HighDensityScatterSeriesView extends SeriesView {
    constructor(a) {
        super(a);
        this.bw = null;
        this.bu = null;
        this.b2 = 0;
        this.b1 = 0;
        this.bz = null;
        this.b0 = null;
        this.bx = null;
        this.bw = a;
    }
    ap() {
        super.ap();
        if (!this.n) {
            this.e.eq = 4;
            this.bw.or = Color.u(255, 0, 0, 0);
            this.bw.oq = Color.u(255, 255, 0, 0);
        }
    }
    b7() {
        this.bw.od(this.bu, this.b2, this.b1);
    }
    b3() {
        if (this.bz == null) {
            this.bz = this.e.e0.createElement("canvas");
            let a = this.e.e0.get2DCanvasContext(this.bz);
            this.bx = new RenderingContext(new CanvasViewRenderer(), a);
        }
        let b;
        if (this.m) {
            b = this.br;
        }
        else {
            b = this.e.bs.ms();
        }
        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.b2;
        let h = this.b1;
        this.b2 = e;
        this.b1 = f;
        if (g != this.b2 || h != this.b1 || this.bu == null) {
            this.bz.setAttribute("width", e.toString());
            this.bz.setAttribute("height", f.toString());
            this.b0 = this.bx.g().getImageData(0, 0, e, f);
            let imageDataArray_ = this.b0.data;
            this.bu = imageDataArray_;
        }
        this.bw.od(this.bu, this.b2, this.b1);
    }
    bv() {
        return this.bu;
    }
    b6() {
        let a = truncate(Math.round(this.br.left));
        let b = truncate(Math.round(this.br.left));
        let c = truncate(Math.round(this.br.width));
        let d = truncate(Math.round(this.br.height));
        this.bx.g().putImageData(this.b0, 0, 0);
        this.an();
    }
    b5(a) {
        if (this.e.e0 != null) {
            this.e.e0.setTimeout(a, 0);
        }
        else {
            window.setTimeout(a, 0);
        }
    }
    a3(a, b) {
        super.a3(a, b);
        if (b) {
            if (!this.bw.c5) {
                return;
            }
            let c = new Rectangle();
            c.n = this.br.left;
            c.o = this.br.top;
            c.width = this.br.width;
            c.height = this.br.height;
            c._fill = this.bl();
            a.v(c);
            return;
        }
        if (this.bz == null) {
            return;
        }
        let d = truncate(Math.round(this.br.left));
        let e = truncate(Math.round(this.br.top));
        let f = truncate(Math.round(this.br.width));
        let g = truncate(Math.round(this.br.height));
        this.h.n(this.bz.getNativeElement(), this.e._opacity, d, e, f, g, d, e, f, g);
    }
    by(a, b) {
        return Color.e(Nullable$1.toNullable(Color.$, a), Nullable$1.toNullable(Color.$, null)) && Color.e(Nullable$1.toNullable(Color.$, b), Nullable$1.toNullable(Color.$, null));
    }
    b4() {
        if (this.bu != null) {
            for (let a = 0; a < this.bu.length; a++) {
                this.bu[a] = 0;
            }
            this.b6();
        }
    }
    ai(a) {
        super.ai(a);
        if (this.bu == null) {
            this.e.a2.exportSeriesPixelsData(a, null, this.b2, this.b1);
            return;
        }
        let b = new Array(intDivide(this.bu.length, 4));
        let c;
        for (let d = 0; d < intDivide(this.bu.length, 4); d++) {
            c = d * 4;
            b[d] = this.bu[c + 3] << 24 | this.bu[c] << 16 | this.bu[c + 1] << 8 | this.bu[c + 2];
        }
        this.e.a2.exportSeriesPixelsData(a, b, this.b2, this.b1);
    }
}
HighDensityScatterSeriesView.$t = markType(HighDensityScatterSeriesView, 'HighDensityScatterSeriesView', SeriesView.$);
