/*
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.w5 = null;
            this.w6 = null;
            this.xe = false;
            this.w1 = null;
            this.triangulationStatusChanged = null;
            this.xh = null;
            this.w2 = null;
            this.w3 = null;
            this.w4 = null;
        }
        o2() {
            super.o2();
            this.wy = null;
            this.wz = null;
        }
        kq(a, b) {
            let c = this.nd(b);
            if (c == ScatterTriangulationSeries.$$p[8]) {
                return this.kr(a, b, this.x0);
            }
            if (c == ScatterTriangulationSeries.$$p[12]) {
                return this.kr(a, b, this.x8);
            }
            return super.kq(a, b);
        }
        md(a) {
            let b = this.nd(a);
            if (b == ScatterTriangulationSeries.$$p[8]) {
                return this.x0;
            }
            if (b == ScatterTriangulationSeries.$$p[12]) {
                return this.x8;
            }
            return super.md(a);
        }
        get xb() {
            return this.w5;
        }
        set xb(a) {
            let b = this.xb != a;
            if (b) {
                let c = this.xb;
                this.w5 = a;
                this.raisePropertyChanged("XColumn", c, this.xb);
            }
        }
        get xc() {
            return this.w6;
        }
        set xc(a) {
            let b = this.xc != a;
            if (b) {
                let c = this.xc;
                this.w6 = a;
                this.raisePropertyChanged("YColumn", c, this.xc);
            }
        }
        rs(a) {
            let b = this.dn != null && this.xd == null && this.xh == null && this.xb != null && this.xc != null && this.xb.count >= 3 && this.xc.count >= 3 && !this.xe;
            if (b) {
                this.yc();
                this.xe = true;
            }
        }
        yc() {
            this.w1 = new Triangulator(this.dn.count, this.xb, this.xc);
            let a = this.w1;
            a.triangulationStatusChanged = delegateCombine(a.triangulationStatusChanged, runOn(this, this.yd));
            this.w1.y();
        }
        ya() {
            if (this.w1 == null) {
                return;
            }
            this.w1.r();
            let a = this.w1;
            a.triangulationStatusChanged = delegateRemove(a.triangulationStatusChanged, runOn(this, this.yd));
            this.w1 = null;
        }
        yd(a, b) {
            if (this.triangulationStatusChanged != null) {
                this.triangulationStatusChanged(this, new TriangulationStatusEventArgs(b.currentStatus));
            }
            if (b.currentStatus >= 100) {
                if (this.w1 == null) {
                    return;
                }
                let c = this.w1;
                c.triangulationStatusChanged = delegateRemove(c.triangulationStatusChanged, runOn(this, this.yd));
                this.xh = this.w1.n();
                this.w1 = null;
                let d = ((() => {
                    let $ret = new FastItemsSource();
                    $ret.e = this.xh;
                    return $ret;
                })());
                this.w8 = this.w7(d, "v1");
                this.w9 = this.w7(d, "v2");
                this.xa = this.w7(d, "v3");
                this.rr(false);
            }
        }
        w7(a, b) {
            if (b == null) {
                return a.registerColumnInt(null, null, false);
            }
            let c = null;
            let d = SeriesViewer.cu(b, this.coercionMethods);
            c = d.a;
            return a.registerColumnInt(b, c, this.expectFunctions);
        }
        q9(a, b, c, d) {
            super.q9(a, b, c, d);
            switch (b) {
                case ScatterTriangulationSeries.$$p[6]:
                case ScatterTriangulationSeries.$$p[10]:
                case ScatterTriangulationSeries.$$p[7]:
                case ScatterTriangulationSeries.$$p[11]:
                    this.qf();
                    break;
                case "FastItemsSource":
                    let e = typeCast(IFastItemsSource_$type, c);
                    if (e != null) {
                        e.deregisterColumn(this.xb);
                        e.deregisterColumn(this.xc);
                        this.xb = null;
                        this.xc = null;
                    }
                    this.yb();
                    let f = typeCast(IFastItemsSource_$type, d);
                    if (f != null) {
                        this.xb = this.dk(this.x0);
                        this.xc = this.dk(this.x8);
                    }
                    this.rr(this.gg && c != null);
                    break;
                case ScatterTriangulationSeries.$$p[8]:
                    if (this.dn != null) {
                        this.dn.deregisterColumn(this.xb);
                        this.xb = this.dk(this.x0);
                    }
                    this.yb();
                    this.rr(false);
                    this.ql();
                    break;
                case ScatterTriangulationSeries.$$p[12]:
                    if (this.dn != null) {
                        this.dn.deregisterColumn(this.xc);
                        this.xc = this.dk(this.x8);
                    }
                    this.yb();
                    this.rr(false);
                    this.ql();
                    break;
                case ScatterTriangulationSeries.$$p[5]:
                    if (c != null) {
                        (typeCast(Axis.$, c)).b0(this);
                    }
                    if (d != null) {
                        (typeCast(Axis.$, d)).ct(this);
                    }
                    if ((this.wy != null && !this.wy.c1()) || (d == null && c != null)) {
                        this.rr(false);
                    }
                    this.ql();
                    break;
                case ScatterTriangulationSeries.$$p[9]:
                    if (c != null) {
                        (typeCast(Axis.$, c)).b0(this);
                    }
                    if (d != null) {
                        (typeCast(Axis.$, d)).ct(this);
                    }
                    if ((this.wz != null && !this.wz.c1()) || (d == null && c != null)) {
                        this.rr(false);
                    }
                    this.ql();
                    break;
                case ScatterTriangulationSeries.$$p[4]:
                    if (this.trianglesSource != null) {
                        this.ya();
                        this.xd = ((() => {
                            let $ret = new FastItemsSource();
                            $ret.e = this.trianglesSource;
                            return $ret;
                        })());
                    }
                    else {
                        this.xd = null;
                    }
                    break;
                case ScatterTriangulationSeries.$$p[0]:
                    let g = typeCast(IFastItemsSource_$type, c);
                    if (g != null) {
                        g.deregisterColumn(this.w8);
                        g.deregisterColumn(this.w9);
                        g.deregisterColumn(this.xa);
                        this.w8 = null;
                        this.w9 = null;
                        this.xa = null;
                    }
                    let h = typeCast(IFastItemsSource_$type, d);
                    if (h != null) {
                        this.w8 = this.w7(h, this.xo);
                        this.w9 = this.w7(h, this.xq);
                        this.xa = this.w7(h, this.xs);
                    }
                    this.rr(false);
                    this.ql();
                    break;
                case ScatterTriangulationSeries.$$p[1]:
                    if (this.xd != null) {
                        this.xd.deregisterColumn(this.w8);
                        this.w8 = this.w7(this.xd, this.xo);
                    }
                    this.rr(false);
                    this.ql();
                    break;
                case ScatterTriangulationSeries.$$p[2]:
                    if (this.xd != null) {
                        this.xd.deregisterColumn(this.w9);
                        this.w9 = this.w7(this.xd, this.xq);
                    }
                    this.rr(false);
                    this.ql();
                    break;
                case ScatterTriangulationSeries.$$p[3]:
                    if (this.xd != null) {
                        this.xd.deregisterColumn(this.xa);
                        this.xa = this.w7(this.xd, this.xs);
                    }
                    this.rr(false);
                    this.ql();
                    break;
                case "XColumn":
                    if (this.wy != null) {
                        this.wy.c1();
                    }
                    break;
                case "YColumn":
                    if (this.wz != null) {
                        this.wz.c1();
                    }
                    break;
            }
        }
        xg(a) {
            if (typeCast(NumericYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        xf(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        he(a, b, c) {
            return super.he(a, b, c) && this.dn != null && this.wy != null && this.wz != null && this.wy.bi != null && this.wz.bi != null && a.width > 0 && a.height > 0 && this.w8 != null && this.w8.count > 0 && this.w9 != null && this.w9.count > 0 && this.xa != null && this.xa.count > 0 && this.xb != null && this.xb.count > 0 && this.xc != null && this.xc.count > 0;
        }
        yb() {
            if (this.trianglesSource == null) {
                this.xh = null;
                this.w8 = null;
                this.w9 = null;
                this.xa = null;
                this.xe = false;
            }
        }
        qb() {
            super.qb();
            if (this.wy != null) {
                this.wy.ia();
            }
            if (this.wz != null) {
                this.wz.ia();
            }
        }
        pb(a, b, c, d) {
            super.pb(a, b, c, d);
            this.yb();
            this.rr(false);
        }
        ay(a) {
            if (a != null && a == this.wy && this.xb != null) {
                return new AxisRange(this.xb.minimum, this.xb.maximum);
            }
            if (a != null && a == this.wz && this.xc != null) {
                return new AxisRange(this.xc.minimum, this.xc.maximum);
            }
            return null;
        }
        sr(a, b) {
            this.rr(false);
        }
        sq(a, b) {
            this.rr(false);
        }
        get w8() {
            return this.w2;
        }
        set w8(a) {
            let b = this.w8 != a;
            if (b) {
                let c = this.w8;
                this.w2 = a;
                this.raisePropertyChanged("TriangleVertexColumn1", c, this.w8);
            }
        }
        get w9() {
            return this.w3;
        }
        set w9(a) {
            let b = this.w9 != a;
            if (b) {
                let c = this.w9;
                this.w3 = a;
                this.raisePropertyChanged("TriangleVertexColumn2", c, this.w9);
            }
        }
        get xa() {
            return this.w4;
        }
        set xa(a) {
            let b = this.xa != a;
            if (b) {
                let c = this.xa;
                this.w4 = a;
                this.raisePropertyChanged("TriangleVertexColumn3", c, this.xa);
            }
        }
        get_fx() {
            return true;
        }
        get_fl() {
            return true;
        }
        getDataLegendSeriesContextAt(a, b) {
            let c = { $type: Point_$type, x: a, y: b };
            let d = this.kn(c);
            let e = d == null ? NaN : this.ix(d, "XMemberPath");
            let f = d == null ? NaN : this.ix(d, "YMemberPath");
            let g = new DataLegendSeriesValueInfo();
            g.l = e;
            g.a = 13;
            g.q = "X";
            g.r = this.x0 != null ? this.x0 : "X";
            g.s = this.xw != null ? this.xw : "X:";
            g.t = this.xy != null ? this.xy : "";
            let h = new DataLegendSeriesValueInfo();
            h.l = f;
            h.a = 14;
            h.q = "Y";
            h.r = this.x8 != null ? this.x8 : "Y";
            h.s = this.x4 != null ? this.x4 : "Y:";
            h.t = this.x6 != null ? this.x6 : "";
            let i = new DataLegendSeriesContext();
            i.e = ((() => {
                let $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
                $ret.add(g);
                $ret.add(h);
                return $ret;
            })());
            i.h = this.mc();
            return i;
        }
    }
    ScatterTriangulationSeries.$t = markType(ScatterTriangulationSeries, 'ScatterTriangulationSeries', Series.$);
    ScatterTriangulationSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterTriangulationSeries, 'raisePropertyChanged', ['FastTrianglesSource:xd:ye', [IFastItemsSource_$type, null], 'TriangleVertexMemberPath1:xo:yg', [2, null], 'TriangleVertexMemberPath2:xq:yh', [2, null], 'TriangleVertexMemberPath3:xs:yi', [2, null], 'TrianglesSource::yf', [IEnumerable_$type, null], 'XAxis:wy:yj', [NumericXAxis.$, null], 'XMemberAsLegendLabel:xw:yk', [2, null], 'XMemberAsLegendUnit:xy:yl', [2, null], 'XMemberPath:x0:ym', [2, null], 'YAxis:wz:yn', [NumericYAxis.$, null], 'YMemberAsLegendLabel:x4:yo', [2, null], 'YMemberAsLegendUnit:x6:yp', [2, null], 'YMemberPath:x8:yq', [2, null]]);
    return ScatterTriangulationSeries;
})();
