/*
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 { __extends } from "tslib";
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
 */
var ScatterTriangulationSeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(ScatterTriangulationSeries, _super);
    function ScatterTriangulationSeries() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _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;
        return _this;
    }
    ScatterTriangulationSeries.prototype.o2 = function () {
        _super.prototype.o2.call(this);
        this.wy = null;
        this.wz = null;
    };
    ScatterTriangulationSeries.prototype.kq = function (a, b) {
        var 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.prototype.kq.call(this, a, b);
    };
    ScatterTriangulationSeries.prototype.md = function (a) {
        var b = this.nd(a);
        if (b == ScatterTriangulationSeries.$$p[8]) {
            return this.x0;
        }
        if (b == ScatterTriangulationSeries.$$p[12]) {
            return this.x8;
        }
        return _super.prototype.md.call(this, a);
    };
    Object.defineProperty(ScatterTriangulationSeries.prototype, "xb", {
        get: function () {
            return this.w5;
        },
        set: function (a) {
            var b = this.xb != a;
            if (b) {
                var c = this.xb;
                this.w5 = a;
                this.raisePropertyChanged("XColumn", c, this.xb);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "xc", {
        get: function () {
            return this.w6;
        },
        set: function (a) {
            var b = this.xc != a;
            if (b) {
                var c = this.xc;
                this.w6 = a;
                this.raisePropertyChanged("YColumn", c, this.xc);
            }
        },
        enumerable: false,
        configurable: true
    });
    ScatterTriangulationSeries.prototype.rs = function (a) {
        var 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;
        }
    };
    ScatterTriangulationSeries.prototype.yc = function () {
        this.w1 = new Triangulator(this.dn.count, this.xb, this.xc);
        var a = this.w1;
        a.triangulationStatusChanged = delegateCombine(a.triangulationStatusChanged, runOn(this, this.yd));
        this.w1.y();
    };
    ScatterTriangulationSeries.prototype.ya = function () {
        if (this.w1 == null) {
            return;
        }
        this.w1.r();
        var a = this.w1;
        a.triangulationStatusChanged = delegateRemove(a.triangulationStatusChanged, runOn(this, this.yd));
        this.w1 = null;
    };
    ScatterTriangulationSeries.prototype.yd = function (a, b) {
        var _this = this;
        if (this.triangulationStatusChanged != null) {
            this.triangulationStatusChanged(this, new TriangulationStatusEventArgs(b.currentStatus));
        }
        if (b.currentStatus >= 100) {
            if (this.w1 == null) {
                return;
            }
            var c = this.w1;
            c.triangulationStatusChanged = delegateRemove(c.triangulationStatusChanged, runOn(this, this.yd));
            this.xh = this.w1.n();
            this.w1 = null;
            var d = ((function () {
                var $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);
        }
    };
    ScatterTriangulationSeries.prototype.w7 = function (a, b) {
        if (b == null) {
            return a.registerColumnInt(null, null, false);
        }
        var c = null;
        var d = SeriesViewer.cu(b, this.coercionMethods);
        c = d.a;
        return a.registerColumnInt(b, c, this.expectFunctions);
    };
    ScatterTriangulationSeries.prototype.q9 = function (a, b, c, d) {
        var _this = this;
        _super.prototype.q9.call(this, 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":
                var e = typeCast(IFastItemsSource_$type, c);
                if (e != null) {
                    e.deregisterColumn(this.xb);
                    e.deregisterColumn(this.xc);
                    this.xb = null;
                    this.xc = null;
                }
                this.yb();
                var 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 = ((function () {
                        var $ret = new FastItemsSource();
                        $ret.e = _this.trianglesSource;
                        return $ret;
                    })());
                }
                else {
                    this.xd = null;
                }
                break;
            case ScatterTriangulationSeries.$$p[0]:
                var 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;
                }
                var 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;
        }
    };
    ScatterTriangulationSeries.prototype.xg = function (a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterTriangulationSeries.prototype.xf = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterTriangulationSeries.prototype.he = function (a, b, c) {
        return _super.prototype.he.call(this, 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;
    };
    ScatterTriangulationSeries.prototype.yb = function () {
        if (this.trianglesSource == null) {
            this.xh = null;
            this.w8 = null;
            this.w9 = null;
            this.xa = null;
            this.xe = false;
        }
    };
    ScatterTriangulationSeries.prototype.qb = function () {
        _super.prototype.qb.call(this);
        if (this.wy != null) {
            this.wy.ia();
        }
        if (this.wz != null) {
            this.wz.ia();
        }
    };
    ScatterTriangulationSeries.prototype.pb = function (a, b, c, d) {
        _super.prototype.pb.call(this, a, b, c, d);
        this.yb();
        this.rr(false);
    };
    ScatterTriangulationSeries.prototype.ay = function (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;
    };
    ScatterTriangulationSeries.prototype.sr = function (a, b) {
        this.rr(false);
    };
    ScatterTriangulationSeries.prototype.sq = function (a, b) {
        this.rr(false);
    };
    Object.defineProperty(ScatterTriangulationSeries.prototype, "w8", {
        get: function () {
            return this.w2;
        },
        set: function (a) {
            var b = this.w8 != a;
            if (b) {
                var c = this.w8;
                this.w2 = a;
                this.raisePropertyChanged("TriangleVertexColumn1", c, this.w8);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "w9", {
        get: function () {
            return this.w3;
        },
        set: function (a) {
            var b = this.w9 != a;
            if (b) {
                var c = this.w9;
                this.w3 = a;
                this.raisePropertyChanged("TriangleVertexColumn2", c, this.w9);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "xa", {
        get: function () {
            return this.w4;
        },
        set: function (a) {
            var b = this.xa != a;
            if (b) {
                var c = this.xa;
                this.w4 = a;
                this.raisePropertyChanged("TriangleVertexColumn3", c, this.xa);
            }
        },
        enumerable: false,
        configurable: true
    });
    ScatterTriangulationSeries.prototype.get_fx = function () {
        return true;
    };
    ScatterTriangulationSeries.prototype.get_fl = function () {
        return true;
    };
    ScatterTriangulationSeries.prototype.getDataLegendSeriesContextAt = function (a, b) {
        var c = { $type: Point_$type, x: a, y: b };
        var d = this.kn(c);
        var e = d == null ? NaN : this.ix(d, "XMemberPath");
        var f = d == null ? NaN : this.ix(d, "YMemberPath");
        var 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 : "";
        var 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 : "";
        var i = new DataLegendSeriesContext();
        i.e = ((function () {
            var $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;
}(Series));
export { ScatterTriangulationSeries };
