/*
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-react-core";
import { IEnumerable_$type, runOn, delegateCombine, delegateRemove, typeCast, Point_$type, markType, markDep } from "igniteui-react-core";
import { NumericXAxis } from "./NumericXAxis";
import { NumericYAxis } from "./NumericYAxis";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { Triangulator } from "igniteui-react-core";
import { TriangulationStatusEventArgs } from "igniteui-react-core";
import { FastItemsSource } from "igniteui-react-core";
import { SeriesViewer } from "./SeriesViewer";
import { Axis } from "./Axis";
import { AxisRange } from "./AxisRange";
import { DataLegendSeriesValueInfo } from "igniteui-react-core";
import { DataLegendSeriesContext } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
/**
 * @hidden
 */
export let ScatterTriangulationSeries = /*@__PURE__*/ (() => {
    class ScatterTriangulationSeries extends Series {
        constructor() {
            super(...arguments);
            this.w3 = null;
            this.w4 = null;
            this.xc = false;
            this.wz = null;
            this.triangulationStatusChanged = null;
            this.xf = null;
            this.w0 = null;
            this.w1 = null;
            this.w2 = null;
        }
        o2() {
            super.o2();
            this.ww = null;
            this.wx = null;
        }
        kq(a, b) {
            let c = this.nd(b);
            if (c == ScatterTriangulationSeries.$$p[8]) {
                return this.kr(a, b, this.xy);
            }
            if (c == ScatterTriangulationSeries.$$p[12]) {
                return this.kr(a, b, this.x6);
            }
            return super.kq(a, b);
        }
        md(a) {
            let b = this.nd(a);
            if (b == ScatterTriangulationSeries.$$p[8]) {
                return this.xy;
            }
            if (b == ScatterTriangulationSeries.$$p[12]) {
                return this.x6;
            }
            return super.md(a);
        }
        get w9() {
            return this.w3;
        }
        set w9(a) {
            let b = this.w9 != a;
            if (b) {
                let c = this.w9;
                this.w3 = a;
                this.raisePropertyChanged("XColumn", 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("YColumn", c, this.xa);
            }
        }
        rq(a) {
            let b = this.dn != null && this.xb == null && this.xf == null && this.w9 != null && this.xa != null && this.w9.count >= 3 && this.xa.count >= 3 && !this.xc;
            if (b) {
                this.ya();
                this.xc = true;
            }
        }
        ya() {
            this.wz = new Triangulator(this.dn.count, this.w9, this.xa);
            let a = this.wz;
            a.triangulationStatusChanged = delegateCombine(a.triangulationStatusChanged, runOn(this, this.yb));
            this.wz.y();
        }
        x8() {
            if (this.wz == null) {
                return;
            }
            this.wz.r();
            let a = this.wz;
            a.triangulationStatusChanged = delegateRemove(a.triangulationStatusChanged, runOn(this, this.yb));
            this.wz = null;
        }
        yb(a, b) {
            if (this.triangulationStatusChanged != null) {
                this.triangulationStatusChanged(this, new TriangulationStatusEventArgs(b.currentStatus));
            }
            if (b.currentStatus >= 100) {
                if (this.wz == null) {
                    return;
                }
                let c = this.wz;
                c.triangulationStatusChanged = delegateRemove(c.triangulationStatusChanged, runOn(this, this.yb));
                this.xf = this.wz.n();
                this.wz = null;
                let d = ((() => {
                    let $ret = new FastItemsSource();
                    $ret.e = this.xf;
                    return $ret;
                })());
                this.w6 = this.w5(d, "v1");
                this.w7 = this.w5(d, "v2");
                this.w8 = this.w5(d, "v3");
                this.rp(false);
            }
        }
        w5(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);
        }
        q7(a, b, c, d) {
            super.q7(a, b, c, d);
            switch (b) {
                case ScatterTriangulationSeries.$$p[6]:
                case ScatterTriangulationSeries.$$p[10]:
                case ScatterTriangulationSeries.$$p[7]:
                case ScatterTriangulationSeries.$$p[11]:
                    this.qd();
                    break;
                case "FastItemsSource":
                    let e = typeCast(IFastItemsSource_$type, c);
                    if (e != null) {
                        e.deregisterColumn(this.w9);
                        e.deregisterColumn(this.xa);
                        this.w9 = null;
                        this.xa = null;
                    }
                    this.x9();
                    let f = typeCast(IFastItemsSource_$type, d);
                    if (f != null) {
                        this.w9 = this.dk(this.xy);
                        this.xa = this.dk(this.x6);
                    }
                    this.rp(this.gg && c != null);
                    break;
                case ScatterTriangulationSeries.$$p[8]:
                    if (this.dn != null) {
                        this.dn.deregisterColumn(this.w9);
                        this.w9 = this.dk(this.xy);
                    }
                    this.x9();
                    this.rp(false);
                    this.qj();
                    break;
                case ScatterTriangulationSeries.$$p[12]:
                    if (this.dn != null) {
                        this.dn.deregisterColumn(this.xa);
                        this.xa = this.dk(this.x6);
                    }
                    this.x9();
                    this.rp(false);
                    this.qj();
                    break;
                case ScatterTriangulationSeries.$$p[5]:
                    if (c != null) {
                        (typeCast(Axis.$, c)).b0(this);
                    }
                    if (d != null) {
                        (typeCast(Axis.$, d)).ct(this);
                    }
                    if ((this.ww != null && !this.ww.c1()) || (d == null && c != null)) {
                        this.rp(false);
                    }
                    this.qj();
                    break;
                case ScatterTriangulationSeries.$$p[9]:
                    if (c != null) {
                        (typeCast(Axis.$, c)).b0(this);
                    }
                    if (d != null) {
                        (typeCast(Axis.$, d)).ct(this);
                    }
                    if ((this.wx != null && !this.wx.c1()) || (d == null && c != null)) {
                        this.rp(false);
                    }
                    this.qj();
                    break;
                case ScatterTriangulationSeries.$$p[4]:
                    if (this.trianglesSource != null) {
                        this.x8();
                        this.xb = ((() => {
                            let $ret = new FastItemsSource();
                            $ret.e = this.trianglesSource;
                            return $ret;
                        })());
                    }
                    else {
                        this.xb = null;
                    }
                    break;
                case ScatterTriangulationSeries.$$p[0]:
                    let g = typeCast(IFastItemsSource_$type, c);
                    if (g != null) {
                        g.deregisterColumn(this.w6);
                        g.deregisterColumn(this.w7);
                        g.deregisterColumn(this.w8);
                        this.w6 = null;
                        this.w7 = null;
                        this.w8 = null;
                    }
                    let h = typeCast(IFastItemsSource_$type, d);
                    if (h != null) {
                        this.w6 = this.w5(h, this.xm);
                        this.w7 = this.w5(h, this.xo);
                        this.w8 = this.w5(h, this.xq);
                    }
                    this.rp(false);
                    this.qj();
                    break;
                case ScatterTriangulationSeries.$$p[1]:
                    if (this.xb != null) {
                        this.xb.deregisterColumn(this.w6);
                        this.w6 = this.w5(this.xb, this.xm);
                    }
                    this.rp(false);
                    this.qj();
                    break;
                case ScatterTriangulationSeries.$$p[2]:
                    if (this.xb != null) {
                        this.xb.deregisterColumn(this.w7);
                        this.w7 = this.w5(this.xb, this.xo);
                    }
                    this.rp(false);
                    this.qj();
                    break;
                case ScatterTriangulationSeries.$$p[3]:
                    if (this.xb != null) {
                        this.xb.deregisterColumn(this.w8);
                        this.w8 = this.w5(this.xb, this.xq);
                    }
                    this.rp(false);
                    this.qj();
                    break;
                case "XColumn":
                    if (this.ww != null) {
                        this.ww.c1();
                    }
                    break;
                case "YColumn":
                    if (this.wx != null) {
                        this.wx.c1();
                    }
                    break;
            }
        }
        xe(a) {
            if (typeCast(NumericYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        xd(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        he(a, b, c) {
            return super.he(a, b, c) && this.dn != null && this.ww != null && this.wx != null && this.ww.bi != null && this.wx.bi != null && a.width > 0 && a.height > 0 && this.w6 != null && this.w6.count > 0 && this.w7 != null && this.w7.count > 0 && this.w8 != null && this.w8.count > 0 && this.w9 != null && this.w9.count > 0 && this.xa != null && this.xa.count > 0;
        }
        x9() {
            if (this.trianglesSource == null) {
                this.xf = null;
                this.w6 = null;
                this.w7 = null;
                this.w8 = null;
                this.xc = false;
            }
        }
        p9() {
            super.p9();
            if (this.ww != null) {
                this.ww.ia();
            }
            if (this.wx != null) {
                this.wx.ia();
            }
        }
        pb(a, b, c, d) {
            super.pb(a, b, c, d);
            this.x9();
            this.rp(false);
        }
        ay(a) {
            if (a != null && a == this.ww && this.w9 != null) {
                return new AxisRange(this.w9.minimum, this.w9.maximum);
            }
            if (a != null && a == this.wx && this.xa != null) {
                return new AxisRange(this.xa.minimum, this.xa.maximum);
            }
            return null;
        }
        sp(a, b) {
            this.rp(false);
        }
        so(a, b) {
            this.rp(false);
        }
        get w6() {
            return this.w0;
        }
        set w6(a) {
            let b = this.w6 != a;
            if (b) {
                let c = this.w6;
                this.w0 = a;
                this.raisePropertyChanged("TriangleVertexColumn1", c, this.w6);
            }
        }
        get w7() {
            return this.w1;
        }
        set w7(a) {
            let b = this.w7 != a;
            if (b) {
                let c = this.w7;
                this.w1 = a;
                this.raisePropertyChanged("TriangleVertexColumn2", c, this.w7);
            }
        }
        get w8() {
            return this.w2;
        }
        set w8(a) {
            let b = this.w8 != a;
            if (b) {
                let c = this.w8;
                this.w2 = a;
                this.raisePropertyChanged("TriangleVertexColumn3", c, this.w8);
            }
        }
        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.xy != null ? this.xy : "X";
            g.s = this.xu != null ? this.xu : "X:";
            g.t = this.xw != null ? this.xw : "";
            let h = new DataLegendSeriesValueInfo();
            h.l = f;
            h.a = 14;
            h.q = "Y";
            h.r = this.x6 != null ? this.x6 : "Y";
            h.s = this.x2 != null ? this.x2 : "Y:";
            h.t = this.x4 != null ? this.x4 : "";
            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 = /*@__PURE__*/ markType(ScatterTriangulationSeries, 'ScatterTriangulationSeries', Series.$);
    ScatterTriangulationSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, ScatterTriangulationSeries, 'raisePropertyChanged', ['FastTrianglesSource:xb:yc', [IFastItemsSource_$type, null], 'TriangleVertexMemberPath1:xm:ye', [2, null], 'TriangleVertexMemberPath2:xo:yf', [2, null], 'TriangleVertexMemberPath3:xq:yg', [2, null], 'TrianglesSource::yd', [IEnumerable_$type, null], 'XAxis:ww:yh', [NumericXAxis.$, null], 'XMemberAsLegendLabel:xu:yi', [2, null], 'XMemberAsLegendUnit:xw:yj', [2, null], 'XMemberPath:xy:yk', [2, null], 'YAxis:wx:yl', [NumericYAxis.$, null], 'YMemberAsLegendLabel:x2:ym', [2, null], 'YMemberAsLegendUnit:x4:yn', [2, null], 'YMemberPath:x6:yo', [2, null]]);
    return ScatterTriangulationSeries;
})();
