/*
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.qa = null;
            this.qb = null;
            this.qj = false;
            this.p6 = null;
            this.triangulationStatusChanged = null;
            this.qm = null;
            this.p7 = null;
            this.p8 = null;
            this.p9 = null;
        }
        ku() {
            super.ku();
            this.p3 = null;
            this.p4 = null;
        }
        hw(a, b) {
            let c = this.jq(b);
            if (c == ScatterTriangulationSeries.$$p[8]) {
                return this.hx(a, b, this.q5);
            }
            if (c == ScatterTriangulationSeries.$$p[12]) {
                return this.hx(a, b, this.rd);
            }
            return super.hw(a, b);
        }
        get qg() {
            return this.qa;
        }
        set qg(a) {
            let b = this.qg != a;
            if (b) {
                let c = this.qg;
                this.qa = a;
                this.raisePropertyChanged("XColumn", c, this.qg);
            }
        }
        get qh() {
            return this.qb;
        }
        set qh(a) {
            let b = this.qh != a;
            if (b) {
                let c = this.qh;
                this.qb = a;
                this.raisePropertyChanged("YColumn", c, this.qh);
            }
        }
        mi(a) {
            let b = this.ck != null && this.qi == null && this.qm == null && this.qg != null && this.qh != null && this.qg.count >= 3 && this.qh.count >= 3 && !this.qj;
            if (b) {
                this.rh();
                this.qj = true;
            }
        }
        rh() {
            this.p6 = new Triangulator(this.ck.count, this.qg, this.qh);
            let a = this.p6;
            a.triangulationStatusChanged = delegateCombine(a.triangulationStatusChanged, runOn(this, this.ri));
            this.p6.y();
        }
        rf() {
            if (this.p6 == null) {
                return;
            }
            this.p6.r();
            let a = this.p6;
            a.triangulationStatusChanged = delegateRemove(a.triangulationStatusChanged, runOn(this, this.ri));
            this.p6 = null;
        }
        ri(a, b) {
            if (this.triangulationStatusChanged != null) {
                this.triangulationStatusChanged(this, new TriangulationStatusEventArgs(b.currentStatus));
            }
            if (b.currentStatus >= 100) {
                if (this.p6 == null) {
                    return;
                }
                let c = this.p6;
                c.triangulationStatusChanged = delegateRemove(c.triangulationStatusChanged, runOn(this, this.ri));
                this.qm = this.p6.n();
                this.p6 = null;
                let d = ((() => {
                    let $ret = new FastItemsSource();
                    $ret.e = this.qm;
                    return $ret;
                })());
                this.qd = this.qc(d, "v1");
                this.qe = this.qc(d, "v2");
                this.qf = this.qc(d, "v3");
                this.mh(false);
            }
        }
        qc(a, b) {
            if (b == null) {
                return a.registerColumnInt(null, null, false);
            }
            let c = null;
            let d = SeriesViewer.cc(b, this.coercionMethods);
            c = d.a;
            return a.registerColumnInt(b, c, this.expectFunctions);
        }
        l3(a, b, c, d) {
            super.l3(a, b, c, d);
            switch (b) {
                case "FastItemsSource":
                    let e = typeCast(IFastItemsSource_$type, c);
                    if (e != null) {
                        e.deregisterColumn(this.qg);
                        e.deregisterColumn(this.qh);
                        this.qg = null;
                        this.qh = null;
                    }
                    this.rg();
                    let f = typeCast(IFastItemsSource_$type, d);
                    if (f != null) {
                        this.qg = this.ch(this.q5);
                        this.qh = this.ch(this.rd);
                    }
                    this.mh(false);
                    break;
                case ScatterTriangulationSeries.$$p[8]:
                    if (this.ck != null) {
                        this.ck.deregisterColumn(this.qg);
                        this.qg = this.ch(this.q5);
                    }
                    this.rg();
                    this.mh(false);
                    this.lo();
                    break;
                case ScatterTriangulationSeries.$$p[12]:
                    if (this.ck != null) {
                        this.ck.deregisterColumn(this.qh);
                        this.qh = this.ch(this.rd);
                    }
                    this.rg();
                    this.mh(false);
                    this.lo();
                    break;
                case ScatterTriangulationSeries.$$p[5]:
                    if (c != null) {
                        (typeCast(Axis.$, c)).bz(this);
                    }
                    if (d != null) {
                        (typeCast(Axis.$, d)).cs(this);
                    }
                    if ((this.p3 != null && !this.p3.c0()) || (d == null && c != null)) {
                        this.mh(false);
                    }
                    this.lo();
                    break;
                case ScatterTriangulationSeries.$$p[9]:
                    if (c != null) {
                        (typeCast(Axis.$, c)).bz(this);
                    }
                    if (d != null) {
                        (typeCast(Axis.$, d)).cs(this);
                    }
                    if ((this.p4 != null && !this.p4.c0()) || (d == null && c != null)) {
                        this.mh(false);
                    }
                    this.lo();
                    break;
                case ScatterTriangulationSeries.$$p[1]:
                    if (this.trianglesSource != null) {
                        this.rf();
                        this.qi = ((() => {
                            let $ret = new FastItemsSource();
                            $ret.e = this.trianglesSource;
                            return $ret;
                        })());
                    }
                    else {
                        this.qi = null;
                    }
                    break;
                case ScatterTriangulationSeries.$$p[0]:
                    let g = typeCast(IFastItemsSource_$type, c);
                    if (g != null) {
                        g.deregisterColumn(this.qd);
                        g.deregisterColumn(this.qe);
                        g.deregisterColumn(this.qf);
                        this.qd = null;
                        this.qe = null;
                        this.qf = null;
                    }
                    let h = typeCast(IFastItemsSource_$type, d);
                    if (h != null) {
                        this.qd = this.qc(h, this.qt);
                        this.qe = this.qc(h, this.qv);
                        this.qf = this.qc(h, this.qx);
                    }
                    this.mh(false);
                    this.lo();
                    break;
                case ScatterTriangulationSeries.$$p[2]:
                    if (this.qi != null) {
                        this.qi.deregisterColumn(this.qd);
                        this.qd = this.qc(this.qi, this.qt);
                    }
                    this.mh(false);
                    this.lo();
                    break;
                case ScatterTriangulationSeries.$$p[3]:
                    if (this.qi != null) {
                        this.qi.deregisterColumn(this.qe);
                        this.qe = this.qc(this.qi, this.qv);
                    }
                    this.mh(false);
                    this.lo();
                    break;
                case ScatterTriangulationSeries.$$p[4]:
                    if (this.qi != null) {
                        this.qi.deregisterColumn(this.qf);
                        this.qf = this.qc(this.qi, this.qx);
                    }
                    this.mh(false);
                    this.lo();
                    break;
                case "XColumn":
                    if (this.p3 != null) {
                        this.p3.c0();
                    }
                    break;
                case "YColumn":
                    if (this.p4 != null) {
                        this.p4.c0();
                    }
                    break;
            }
        }
        ql(a) {
            if (typeCast(NumericYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        qk(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        e9(a, b, c) {
            return super.e9(a, b, c) && this.ck != null && this.p3 != null && this.p4 != null && this.p3.bh != null && this.p4.bh != null && a.width > 0 && a.height > 0 && this.qd != null && this.qd.count > 0 && this.qe != null && this.qe.count > 0 && this.qf != null && this.qf.count > 0 && this.qg != null && this.qg.count > 0 && this.qh != null && this.qh.count > 0;
        }
        rg() {
            if (this.trianglesSource == null) {
                this.qm = null;
                this.qd = null;
                this.qe = null;
                this.qf = null;
                this.qj = false;
            }
        }
        le() {
            super.le();
            if (this.p3 != null) {
                this.p3.h6();
            }
            if (this.p4 != null) {
                this.p4.h6();
            }
        }
        k0(a, b, c, d) {
            super.k0(a, b, c, d);
            this.rg();
            this.mh(false);
        }
        ap(a) {
            if (a != null && a == this.p3 && this.qg != null) {
                return new AxisRange(this.qg.minimum, this.qg.maximum);
            }
            if (a != null && a == this.p4 && this.qh != null) {
                return new AxisRange(this.qh.minimum, this.qh.maximum);
            }
            return null;
        }
        m5(a, b) {
            this.mh(false);
        }
        m4(a, b) {
            this.mh(false);
        }
        get qd() {
            return this.p7;
        }
        set qd(a) {
            let b = this.qd != a;
            if (b) {
                let c = this.qd;
                this.p7 = a;
                this.raisePropertyChanged("TriangleVertexColumn1", c, this.qd);
            }
        }
        get qe() {
            return this.p8;
        }
        set qe(a) {
            let b = this.qe != a;
            if (b) {
                let c = this.qe;
                this.p8 = a;
                this.raisePropertyChanged("TriangleVertexColumn2", c, this.qe);
            }
        }
        get qf() {
            return this.p9;
        }
        set qf(a) {
            let b = this.qf != a;
            if (b) {
                let c = this.qf;
                this.p9 = a;
                this.raisePropertyChanged("TriangleVertexColumn3", c, this.qf);
            }
        }
        get_ed() {
            return true;
        }
        get_d2() {
            return true;
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.ht(c);
            let e = d == null ? NaN : this.gb(d, "XMemberPath");
            let f = d == null ? NaN : this.gb(d, "YMemberPath");
            let g = new DataLegendSeriesValueInfo();
            g.l = e;
            g.a = 13;
            g.p = this.q5 != null ? this.q5 : "X";
            ;
            g.q = this.q1 != null ? this.q1 : "X:";
            g.r = this.q3 != null ? this.q3 : "";
            let h = new DataLegendSeriesValueInfo();
            h.l = f;
            h.a = 14;
            h.p = this.rd != null ? this.rd : "Y";
            ;
            h.q = this.q9 != null ? this.q9 : "Y:";
            h.r = this.rb != null ? this.rb : "";
            let i = new DataLegendSeriesContext();
            i.f = ((() => {
                let $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
                $ret.add(g);
                $ret.add(h);
                return $ret;
            })());
            i.b = this.av();
            return i;
        }
    }
    ScatterTriangulationSeries.$t = markType(ScatterTriangulationSeries, 'ScatterTriangulationSeries', Series.$);
    ScatterTriangulationSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterTriangulationSeries, 'raisePropertyChanged', ['FastTrianglesSource:qi:rj', [IFastItemsSource_$type, null], 'TrianglesSource::rk', [IEnumerable_$type, null], 'TriangleVertexMemberPath1:qt:rl', [2, null], 'TriangleVertexMemberPath2:qv:rm', [2, null], 'TriangleVertexMemberPath3:qx:rn', [2, null], 'XAxis:p3:ro', [NumericXAxis.$, null], 'XMemberAsLegendLabel:q1:rp', [2, null], 'XMemberAsLegendUnit:q3:rq', [2, null], 'XMemberPath:q5:rr', [2, null], 'YAxis:p4:rs', [NumericYAxis.$, null], 'YMemberAsLegendLabel:q9:rt', [2, null], 'YMemberAsLegendUnit:rb:ru', [2, null], 'YMemberPath:rd:rv', [2, null]]);
    return ScatterTriangulationSeries;
})();
