/*
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 { DependencyProperty } from "igniteui-angular-core";
import { IEnumerable_$type, runOn, delegateCombine, delegateRemove, typeCast, Point_$type, markType, markDep } from "igniteui-angular-core";
import { NumericXAxis } from "./NumericXAxis";
import { NumericYAxis } from "./NumericYAxis";
import { IFastItemsSource_$type } from "igniteui-angular-core";
import { Triangulator } from "igniteui-angular-core";
import { TriangulationStatusEventArgs } from "igniteui-angular-core";
import { FastItemsSource } from "igniteui-angular-core";
import { SeriesViewer } from "./SeriesViewer";
import { Axis } from "./Axis";
import { AxisRange } from "./AxisRange";
import { DataLegendSeriesValueInfo } from "igniteui-angular-core";
import { DataLegendSeriesContext } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
/**
 * @hidden
 */
export let ScatterTriangulationSeries = /*@__PURE__*/ (() => {
    class ScatterTriangulationSeries extends Series {
        constructor() {
            super(...arguments);
            this.qj = null;
            this.qk = null;
            this.qs = false;
            this.qf = null;
            this.triangulationStatusChanged = null;
            this.qv = null;
            this.qg = null;
            this.qh = null;
            this.qi = null;
        }
        kz() {
            super.kz();
            this.qc = null;
            this.qd = null;
        }
        h1(a, b) {
            let c = this.jv(b);
            if (c == ScatterTriangulationSeries.$$p[8]) {
                return this.h2(a, b, this.re);
            }
            if (c == ScatterTriangulationSeries.$$p[12]) {
                return this.h2(a, b, this.rm);
            }
            return super.h1(a, b);
        }
        get qp() {
            return this.qj;
        }
        set qp(a) {
            let b = this.qp != a;
            if (b) {
                let c = this.qp;
                this.qj = a;
                this.raisePropertyChanged("XColumn", c, this.qp);
            }
        }
        get qq() {
            return this.qk;
        }
        set qq(a) {
            let b = this.qq != a;
            if (b) {
                let c = this.qq;
                this.qk = a;
                this.raisePropertyChanged("YColumn", c, this.qq);
            }
        }
        mo(a) {
            let b = this.cl != null && this.qr == null && this.qv == null && this.qp != null && this.qq != null && this.qp.count >= 3 && this.qq.count >= 3 && !this.qs;
            if (b) {
                this.rq();
                this.qs = true;
            }
        }
        rq() {
            this.qf = new Triangulator(this.cl.count, this.qp, this.qq);
            let a = this.qf;
            a.triangulationStatusChanged = delegateCombine(a.triangulationStatusChanged, runOn(this, this.rr));
            this.qf.y();
        }
        ro() {
            if (this.qf == null) {
                return;
            }
            this.qf.r();
            let a = this.qf;
            a.triangulationStatusChanged = delegateRemove(a.triangulationStatusChanged, runOn(this, this.rr));
            this.qf = null;
        }
        rr(a, b) {
            if (this.triangulationStatusChanged != null) {
                this.triangulationStatusChanged(this, new TriangulationStatusEventArgs(b.currentStatus));
            }
            if (b.currentStatus >= 100) {
                if (this.qf == null) {
                    return;
                }
                let c = this.qf;
                c.triangulationStatusChanged = delegateRemove(c.triangulationStatusChanged, runOn(this, this.rr));
                this.qv = this.qf.n();
                this.qf = null;
                let d = ((() => {
                    let $ret = new FastItemsSource();
                    $ret.e = this.qv;
                    return $ret;
                })());
                this.qm = this.ql(d, "v1");
                this.qn = this.ql(d, "v2");
                this.qo = this.ql(d, "v3");
                this.mn(false);
            }
        }
        ql(a, b) {
            if (b == null) {
                return a.registerColumnInt(null, null, false);
            }
            let c = null;
            let d = SeriesViewer.cg(b, this.coercionMethods);
            c = d.a;
            return a.registerColumnInt(b, c, this.expectFunctions);
        }
        l9(a, b, c, d) {
            super.l9(a, b, c, d);
            switch (b) {
                case "FastItemsSource":
                    let e = typeCast(IFastItemsSource_$type, c);
                    if (e != null) {
                        e.deregisterColumn(this.qp);
                        e.deregisterColumn(this.qq);
                        this.qp = null;
                        this.qq = null;
                    }
                    this.rp();
                    let f = typeCast(IFastItemsSource_$type, d);
                    if (f != null) {
                        this.qp = this.ci(this.re);
                        this.qq = this.ci(this.rm);
                    }
                    this.mn(false);
                    break;
                case ScatterTriangulationSeries.$$p[8]:
                    if (this.cl != null) {
                        this.cl.deregisterColumn(this.qp);
                        this.qp = this.ci(this.re);
                    }
                    this.rp();
                    this.mn(false);
                    this.lu();
                    break;
                case ScatterTriangulationSeries.$$p[12]:
                    if (this.cl != null) {
                        this.cl.deregisterColumn(this.qq);
                        this.qq = this.ci(this.rm);
                    }
                    this.rp();
                    this.mn(false);
                    this.lu();
                    break;
                case ScatterTriangulationSeries.$$p[5]:
                    if (c != null) {
                        (typeCast(Axis.$, c)).bz(this);
                    }
                    if (d != null) {
                        (typeCast(Axis.$, d)).cs(this);
                    }
                    if ((this.qc != null && !this.qc.c0()) || (d == null && c != null)) {
                        this.mn(false);
                    }
                    this.lu();
                    break;
                case ScatterTriangulationSeries.$$p[9]:
                    if (c != null) {
                        (typeCast(Axis.$, c)).bz(this);
                    }
                    if (d != null) {
                        (typeCast(Axis.$, d)).cs(this);
                    }
                    if ((this.qd != null && !this.qd.c0()) || (d == null && c != null)) {
                        this.mn(false);
                    }
                    this.lu();
                    break;
                case ScatterTriangulationSeries.$$p[1]:
                    if (this.trianglesSource != null) {
                        this.ro();
                        this.qr = ((() => {
                            let $ret = new FastItemsSource();
                            $ret.e = this.trianglesSource;
                            return $ret;
                        })());
                    }
                    else {
                        this.qr = null;
                    }
                    break;
                case ScatterTriangulationSeries.$$p[0]:
                    let g = typeCast(IFastItemsSource_$type, c);
                    if (g != null) {
                        g.deregisterColumn(this.qm);
                        g.deregisterColumn(this.qn);
                        g.deregisterColumn(this.qo);
                        this.qm = null;
                        this.qn = null;
                        this.qo = null;
                    }
                    let h = typeCast(IFastItemsSource_$type, d);
                    if (h != null) {
                        this.qm = this.ql(h, this.q2);
                        this.qn = this.ql(h, this.q4);
                        this.qo = this.ql(h, this.q6);
                    }
                    this.mn(false);
                    this.lu();
                    break;
                case ScatterTriangulationSeries.$$p[2]:
                    if (this.qr != null) {
                        this.qr.deregisterColumn(this.qm);
                        this.qm = this.ql(this.qr, this.q2);
                    }
                    this.mn(false);
                    this.lu();
                    break;
                case ScatterTriangulationSeries.$$p[3]:
                    if (this.qr != null) {
                        this.qr.deregisterColumn(this.qn);
                        this.qn = this.ql(this.qr, this.q4);
                    }
                    this.mn(false);
                    this.lu();
                    break;
                case ScatterTriangulationSeries.$$p[4]:
                    if (this.qr != null) {
                        this.qr.deregisterColumn(this.qo);
                        this.qo = this.ql(this.qr, this.q6);
                    }
                    this.mn(false);
                    this.lu();
                    break;
                case "XColumn":
                    if (this.qc != null) {
                        this.qc.c0();
                    }
                    break;
                case "YColumn":
                    if (this.qd != null) {
                        this.qd.c0();
                    }
                    break;
            }
        }
        qu(a) {
            if (typeCast(NumericYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        qt(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        fd(a, b, c) {
            return super.fd(a, b, c) && this.cl != null && this.qc != null && this.qd != null && this.qc.bh != null && this.qd.bh != null && a.width > 0 && a.height > 0 && this.qm != null && this.qm.count > 0 && this.qn != null && this.qn.count > 0 && this.qo != null && this.qo.count > 0 && this.qp != null && this.qp.count > 0 && this.qq != null && this.qq.count > 0;
        }
        rp() {
            if (this.trianglesSource == null) {
                this.qv = null;
                this.qm = null;
                this.qn = null;
                this.qo = null;
                this.qs = false;
            }
        }
        lk() {
            super.lk();
            if (this.qc != null) {
                this.qc.h6();
            }
            if (this.qd != null) {
                this.qd.h6();
            }
        }
        k5(a, b, c, d) {
            super.k5(a, b, c, d);
            this.rp();
            this.mn(false);
        }
        aq(a) {
            if (a != null && a == this.qc && this.qp != null) {
                return new AxisRange(this.qp.minimum, this.qp.maximum);
            }
            if (a != null && a == this.qd && this.qq != null) {
                return new AxisRange(this.qq.minimum, this.qq.maximum);
            }
            return null;
        }
        nb(a, b) {
            this.mn(false);
        }
        na(a, b) {
            this.mn(false);
        }
        get qm() {
            return this.qg;
        }
        set qm(a) {
            let b = this.qm != a;
            if (b) {
                let c = this.qm;
                this.qg = a;
                this.raisePropertyChanged("TriangleVertexColumn1", c, this.qm);
            }
        }
        get qn() {
            return this.qh;
        }
        set qn(a) {
            let b = this.qn != a;
            if (b) {
                let c = this.qn;
                this.qh = a;
                this.raisePropertyChanged("TriangleVertexColumn2", c, this.qn);
            }
        }
        get qo() {
            return this.qi;
        }
        set qo(a) {
            let b = this.qo != a;
            if (b) {
                let c = this.qo;
                this.qi = a;
                this.raisePropertyChanged("TriangleVertexColumn3", c, this.qo);
            }
        }
        get_eg() {
            return true;
        }
        get_d5() {
            return true;
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.hy(c);
            let e = d == null ? NaN : this.gf(d, "XMemberPath");
            let f = d == null ? NaN : this.gf(d, "YMemberPath");
            let g = new DataLegendSeriesValueInfo();
            g.l = e;
            g.a = 13;
            g.p = "X";
            g.q = this.re != null ? this.re : "X";
            g.r = this.ra != null ? this.ra : "X:";
            g.s = this.rc != null ? this.rc : "";
            let h = new DataLegendSeriesValueInfo();
            h.l = f;
            h.a = 14;
            h.p = "Y";
            h.q = this.rm != null ? this.rm : "Y";
            h.r = this.ri != null ? this.ri : "Y:";
            h.s = this.rk != null ? this.rk : "";
            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;
        }
    }
    ScatterTriangulationSeries.$t = markType(ScatterTriangulationSeries, 'ScatterTriangulationSeries', Series.$);
    ScatterTriangulationSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterTriangulationSeries, 'raisePropertyChanged', ['FastTrianglesSource:qr:rs', [IFastItemsSource_$type, null], 'TrianglesSource::rt', [IEnumerable_$type, null], 'TriangleVertexMemberPath1:q2:ru', [2, null], 'TriangleVertexMemberPath2:q4:rv', [2, null], 'TriangleVertexMemberPath3:q6:rw', [2, null], 'XAxis:qc:rx', [NumericXAxis.$, null], 'XMemberAsLegendLabel:ra:ry', [2, null], 'XMemberAsLegendUnit:rc:rz', [2, null], 'XMemberPath:re:r0', [2, null], 'YAxis:qd:r1', [NumericYAxis.$, null], 'YMemberAsLegendLabel:ri:r2', [2, null], 'YMemberAsLegendUnit:rk:r3', [2, null], 'YMemberPath:rm:r4', [2, null]]);
    return ScatterTriangulationSeries;
})();
