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