/*
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.xf = null;
        _this.xg = null;
        _this.xo = false;
        _this.xb = null;
        _this.triangulationStatusChanged = null;
        _this.xr = null;
        _this.xc = null;
        _this.xd = null;
        _this.xe = null;
        return _this;
    }
    ScatterTriangulationSeries.prototype.o8 = function () {
        _super.prototype.o8.call(this);
        this.w8 = null;
        this.w9 = null;
    };
    ScatterTriangulationSeries.prototype.ku = function (a, b) {
        var c = this.ni(b);
        if (c == ScatterTriangulationSeries.$$p[8]) {
            return this.kv(a, b, this.ya);
        }
        if (c == ScatterTriangulationSeries.$$p[12]) {
            return this.kv(a, b, this.yi);
        }
        return _super.prototype.ku.call(this, a, b);
    };
    ScatterTriangulationSeries.prototype.mi = function (a) {
        var b = this.ni(a);
        if (b == ScatterTriangulationSeries.$$p[8]) {
            return this.ya;
        }
        if (b == ScatterTriangulationSeries.$$p[12]) {
            return this.yi;
        }
        return _super.prototype.mi.call(this, a);
    };
    Object.defineProperty(ScatterTriangulationSeries.prototype, "xl", {
        get: function () {
            return this.xf;
        },
        set: function (a) {
            var b = this.xl != a;
            if (b) {
                var c = this.xl;
                this.xf = a;
                this.raisePropertyChanged("XColumn", c, this.xl);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "xm", {
        get: function () {
            return this.xg;
        },
        set: function (a) {
            var b = this.xm != a;
            if (b) {
                var c = this.xm;
                this.xg = a;
                this.raisePropertyChanged("YColumn", c, this.xm);
            }
        },
        enumerable: false,
        configurable: true
    });
    ScatterTriangulationSeries.prototype.rz = function (a) {
        var b = this.dp != null && this.xn == null && this.xr == null && this.xl != null && this.xm != null && this.xl.count >= 3 && this.xm.count >= 3 && !this.xo;
        if (b) {
            this.ym();
            this.xo = true;
        }
    };
    ScatterTriangulationSeries.prototype.ym = function () {
        this.xb = new Triangulator(this.dp.count, this.xl, this.xm);
        var a = this.xb;
        a.triangulationStatusChanged = delegateCombine(a.triangulationStatusChanged, runOn(this, this.yn));
        this.xb.y();
    };
    ScatterTriangulationSeries.prototype.yk = function () {
        if (this.xb == null) {
            return;
        }
        this.xb.r();
        var a = this.xb;
        a.triangulationStatusChanged = delegateRemove(a.triangulationStatusChanged, runOn(this, this.yn));
        this.xb = null;
    };
    ScatterTriangulationSeries.prototype.yn = function (a, b) {
        var _this = this;
        if (this.triangulationStatusChanged != null) {
            this.triangulationStatusChanged(this, new TriangulationStatusEventArgs(b.currentStatus));
        }
        if (b.currentStatus >= 100) {
            if (this.xb == null) {
                return;
            }
            var c = this.xb;
            c.triangulationStatusChanged = delegateRemove(c.triangulationStatusChanged, runOn(this, this.yn));
            this.xr = this.xb.n();
            this.xb = null;
            var d = ((function () {
                var $ret = new FastItemsSource();
                $ret.e = _this.xr;
                return $ret;
            })());
            this.xi = this.xh(d, "v1");
            this.xj = this.xh(d, "v2");
            this.xk = this.xh(d, "v3");
            this.ry(false);
        }
    };
    ScatterTriangulationSeries.prototype.xh = function (a, b) {
        if (b == null) {
            return a.registerColumnInt(null, null, false);
        }
        var c = null;
        var d = SeriesViewer.c7(b, this.coercionMethods);
        c = d.a;
        return a.registerColumnInt(b, c, this.expectFunctions);
    };
    ScatterTriangulationSeries.prototype.rg = function (a, b, c, d) {
        var _this = this;
        _super.prototype.rg.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.ql();
                break;
            case "FastItemsSource":
                var e = typeCast(IFastItemsSource_$type, c);
                if (e != null) {
                    e.deregisterColumn(this.xl);
                    e.deregisterColumn(this.xm);
                    this.xl = null;
                    this.xm = null;
                }
                this.yl();
                var f = typeCast(IFastItemsSource_$type, d);
                if (f != null) {
                    this.xl = this.dl(this.ya);
                    this.xm = this.dl(this.yi);
                }
                this.ry(this.gh && c != null);
                break;
            case ScatterTriangulationSeries.$$p[8]:
                if (this.dp != null) {
                    this.dp.deregisterColumn(this.xl);
                    this.xl = this.dl(this.ya);
                }
                this.yl();
                this.ry(false);
                this.qr();
                break;
            case ScatterTriangulationSeries.$$p[12]:
                if (this.dp != null) {
                    this.dp.deregisterColumn(this.xm);
                    this.xm = this.dl(this.yi);
                }
                this.yl();
                this.ry(false);
                this.qr();
                break;
            case ScatterTriangulationSeries.$$p[5]:
                if (c != null) {
                    (typeCast(Axis.$, c)).cq(this);
                }
                if (d != null) {
                    (typeCast(Axis.$, d)).du(this);
                }
                if ((this.w8 != null && !this.w8.d2()) || (d == null && c != null)) {
                    this.ry(false);
                }
                this.qr();
                break;
            case ScatterTriangulationSeries.$$p[9]:
                if (c != null) {
                    (typeCast(Axis.$, c)).cq(this);
                }
                if (d != null) {
                    (typeCast(Axis.$, d)).du(this);
                }
                if ((this.w9 != null && !this.w9.d2()) || (d == null && c != null)) {
                    this.ry(false);
                }
                this.qr();
                break;
            case ScatterTriangulationSeries.$$p[4]:
                if (this.trianglesSource != null) {
                    this.yk();
                    this.xn = ((function () {
                        var $ret = new FastItemsSource();
                        $ret.e = _this.trianglesSource;
                        return $ret;
                    })());
                }
                else {
                    this.xn = null;
                }
                break;
            case ScatterTriangulationSeries.$$p[0]:
                var g = typeCast(IFastItemsSource_$type, c);
                if (g != null) {
                    g.deregisterColumn(this.xi);
                    g.deregisterColumn(this.xj);
                    g.deregisterColumn(this.xk);
                    this.xi = null;
                    this.xj = null;
                    this.xk = null;
                }
                var h = typeCast(IFastItemsSource_$type, d);
                if (h != null) {
                    this.xi = this.xh(h, this.xy);
                    this.xj = this.xh(h, this.x0);
                    this.xk = this.xh(h, this.x2);
                }
                this.ry(false);
                this.qr();
                break;
            case ScatterTriangulationSeries.$$p[1]:
                if (this.xn != null) {
                    this.xn.deregisterColumn(this.xi);
                    this.xi = this.xh(this.xn, this.xy);
                }
                this.ry(false);
                this.qr();
                break;
            case ScatterTriangulationSeries.$$p[2]:
                if (this.xn != null) {
                    this.xn.deregisterColumn(this.xj);
                    this.xj = this.xh(this.xn, this.x0);
                }
                this.ry(false);
                this.qr();
                break;
            case ScatterTriangulationSeries.$$p[3]:
                if (this.xn != null) {
                    this.xn.deregisterColumn(this.xk);
                    this.xk = this.xh(this.xn, this.x2);
                }
                this.ry(false);
                this.qr();
                break;
            case "XColumn":
                if (this.w8 != null) {
                    this.w8.d2();
                }
                break;
            case "YColumn":
                if (this.w9 != null) {
                    this.w9.d2();
                }
                break;
        }
    };
    ScatterTriangulationSeries.prototype.xq = function (a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterTriangulationSeries.prototype.xp = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterTriangulationSeries.prototype.hf = function (a, b, c) {
        return _super.prototype.hf.call(this, a, b, c) && this.dp != null && this.w8 != null && this.w9 != null && this.w8.b0 != null && this.w9.b0 != null && a.width > 0 && a.height > 0 && this.xi != null && this.xi.count > 0 && this.xj != null && this.xj.count > 0 && this.xk != null && this.xk.count > 0 && this.xl != null && this.xl.count > 0 && this.xm != null && this.xm.count > 0;
    };
    ScatterTriangulationSeries.prototype.yl = function () {
        if (this.trianglesSource == null) {
            this.xr = null;
            this.xi = null;
            this.xj = null;
            this.xk = null;
            this.xo = false;
        }
    };
    ScatterTriangulationSeries.prototype.qh = function () {
        _super.prototype.qh.call(this);
        if (this.w8 != null) {
            this.w8.k2();
        }
        if (this.w9 != null) {
            this.w9.k2();
        }
    };
    ScatterTriangulationSeries.prototype.ph = function (a, b, c, d) {
        _super.prototype.ph.call(this, a, b, c, d);
        this.yl();
        this.ry(false);
    };
    ScatterTriangulationSeries.prototype.ay = function (a) {
        if (a != null && a == this.w8 && this.xl != null) {
            return new AxisRange(this.xl.minimum, this.xl.maximum);
        }
        if (a != null && a == this.w9 && this.xm != null) {
            return new AxisRange(this.xm.minimum, this.xm.maximum);
        }
        return null;
    };
    ScatterTriangulationSeries.prototype.sz = function (a, b) {
        this.ry(false);
    };
    ScatterTriangulationSeries.prototype.sy = function (a, b) {
        this.ry(false);
    };
    Object.defineProperty(ScatterTriangulationSeries.prototype, "xi", {
        get: function () {
            return this.xc;
        },
        set: function (a) {
            var b = this.xi != a;
            if (b) {
                var c = this.xi;
                this.xc = a;
                this.raisePropertyChanged("TriangleVertexColumn1", c, this.xi);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "xj", {
        get: function () {
            return this.xd;
        },
        set: function (a) {
            var b = this.xj != a;
            if (b) {
                var c = this.xj;
                this.xd = a;
                this.raisePropertyChanged("TriangleVertexColumn2", c, this.xj);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "xk", {
        get: function () {
            return this.xe;
        },
        set: function (a) {
            var b = this.xk != a;
            if (b) {
                var c = this.xk;
                this.xe = a;
                this.raisePropertyChanged("TriangleVertexColumn3", c, this.xk);
            }
        },
        enumerable: false,
        configurable: true
    });
    ScatterTriangulationSeries.prototype.get_fy = function () {
        return true;
    };
    ScatterTriangulationSeries.prototype.get_fm = function () {
        return true;
    };
    ScatterTriangulationSeries.prototype.getDataLegendSeriesContextAt = function (a, b) {
        var c = { $type: Point_$type, x: a, y: b };
        var d = this.kr(c);
        var e = d == null ? NaN : this.iz(d, "XMemberPath");
        var f = d == null ? NaN : this.iz(d, "YMemberPath");
        var g = new DataLegendSeriesValueInfo();
        g.l = e;
        g.a = 13;
        g.q = "X";
        g.r = this.ya != null ? this.ya : "X";
        g.s = this.x6 != null ? this.x6 : "X:";
        g.t = this.x8 != null ? this.x8 : "";
        var h = new DataLegendSeriesValueInfo();
        h.l = f;
        h.a = 14;
        h.q = "Y";
        h.r = this.yi != null ? this.yi : "Y";
        h.s = this.ye != null ? this.ye : "Y:";
        h.t = this.yg != null ? this.yg : "";
        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.mh();
        return i;
    };
    ScatterTriangulationSeries.$t = markType(ScatterTriangulationSeries, 'ScatterTriangulationSeries', Series.$);
    ScatterTriangulationSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterTriangulationSeries, 'raisePropertyChanged', ['FastTrianglesSource:xn:yo', [IFastItemsSource_$type, null], 'TriangleVertexMemberPath1:xy:yq', [2, null], 'TriangleVertexMemberPath2:x0:yr', [2, null], 'TriangleVertexMemberPath3:x2:ys', [2, null], 'TrianglesSource::yp', [IEnumerable_$type, null], 'XAxis:w8:yt', [NumericXAxis.$, null], 'XMemberAsLegendLabel:x6:yu', [2, null], 'XMemberAsLegendUnit:x8:yv', [2, null], 'XMemberPath:ya:yw', [2, null], 'YAxis:w9:yx', [NumericYAxis.$, null], 'YMemberAsLegendLabel:ye:yy', [2, null], 'YMemberAsLegendUnit:yg:yz', [2, null], 'YMemberPath:yi:y0', [2, null]]);
    return ScatterTriangulationSeries;
}(Series));
export { ScatterTriangulationSeries };
