/*
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.qf = null;
        _this.qg = null;
        _this.qo = false;
        _this.qb = null;
        _this.triangulationStatusChanged = null;
        _this.qr = null;
        _this.qc = null;
        _this.qd = null;
        _this.qe = null;
        return _this;
    }
    ScatterTriangulationSeries.prototype.kx = function () {
        _super.prototype.kx.call(this);
        this.p8 = null;
        this.p9 = null;
    };
    ScatterTriangulationSeries.prototype.hy = function (a, b) {
        var c = this.js(b);
        if (c == ScatterTriangulationSeries.$$p[8]) {
            return this.hz(a, b, this.ra);
        }
        if (c == ScatterTriangulationSeries.$$p[12]) {
            return this.hz(a, b, this.ri);
        }
        return _super.prototype.hy.call(this, a, b);
    };
    Object.defineProperty(ScatterTriangulationSeries.prototype, "ql", {
        get: function () {
            return this.qf;
        },
        set: function (a) {
            var b = this.ql != a;
            if (b) {
                var c = this.ql;
                this.qf = a;
                this.raisePropertyChanged("XColumn", c, this.ql);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "qm", {
        get: function () {
            return this.qg;
        },
        set: function (a) {
            var b = this.qm != a;
            if (b) {
                var c = this.qm;
                this.qg = a;
                this.raisePropertyChanged("YColumn", c, this.qm);
            }
        },
        enumerable: false,
        configurable: true
    });
    ScatterTriangulationSeries.prototype.mm = function (a) {
        var b = this.ck != null && this.qn == null && this.qr == null && this.ql != null && this.qm != null && this.ql.count >= 3 && this.qm.count >= 3 && !this.qo;
        if (b) {
            this.rm();
            this.qo = true;
        }
    };
    ScatterTriangulationSeries.prototype.rm = function () {
        this.qb = new Triangulator(this.ck.count, this.ql, this.qm);
        var a = this.qb;
        a.triangulationStatusChanged = delegateCombine(a.triangulationStatusChanged, runOn(this, this.rn));
        this.qb.y();
    };
    ScatterTriangulationSeries.prototype.rk = function () {
        if (this.qb == null) {
            return;
        }
        this.qb.r();
        var a = this.qb;
        a.triangulationStatusChanged = delegateRemove(a.triangulationStatusChanged, runOn(this, this.rn));
        this.qb = null;
    };
    ScatterTriangulationSeries.prototype.rn = function (a, b) {
        var _this = this;
        if (this.triangulationStatusChanged != null) {
            this.triangulationStatusChanged(this, new TriangulationStatusEventArgs(b.currentStatus));
        }
        if (b.currentStatus >= 100) {
            if (this.qb == null) {
                return;
            }
            var c = this.qb;
            c.triangulationStatusChanged = delegateRemove(c.triangulationStatusChanged, runOn(this, this.rn));
            this.qr = this.qb.n();
            this.qb = null;
            var d = ((function () {
                var $ret = new FastItemsSource();
                $ret.e = _this.qr;
                return $ret;
            })());
            this.qi = this.qh(d, "v1");
            this.qj = this.qh(d, "v2");
            this.qk = this.qh(d, "v3");
            this.ml(false);
        }
    };
    ScatterTriangulationSeries.prototype.qh = function (a, b) {
        if (b == null) {
            return a.registerColumnInt(null, null, false);
        }
        var c = null;
        var d = SeriesViewer.cg(b, this.coercionMethods);
        c = d.a;
        return a.registerColumnInt(b, c, this.expectFunctions);
    };
    ScatterTriangulationSeries.prototype.l7 = function (a, b, c, d) {
        var _this = this;
        _super.prototype.l7.call(this, a, b, c, d);
        switch (b) {
            case "FastItemsSource":
                var e = typeCast(IFastItemsSource_$type, c);
                if (e != null) {
                    e.deregisterColumn(this.ql);
                    e.deregisterColumn(this.qm);
                    this.ql = null;
                    this.qm = null;
                }
                this.rl();
                var f = typeCast(IFastItemsSource_$type, d);
                if (f != null) {
                    this.ql = this.ch(this.ra);
                    this.qm = this.ch(this.ri);
                }
                this.ml(false);
                break;
            case ScatterTriangulationSeries.$$p[8]:
                if (this.ck != null) {
                    this.ck.deregisterColumn(this.ql);
                    this.ql = this.ch(this.ra);
                }
                this.rl();
                this.ml(false);
                this.ls();
                break;
            case ScatterTriangulationSeries.$$p[12]:
                if (this.ck != null) {
                    this.ck.deregisterColumn(this.qm);
                    this.qm = this.ch(this.ri);
                }
                this.rl();
                this.ml(false);
                this.ls();
                break;
            case ScatterTriangulationSeries.$$p[5]:
                if (c != null) {
                    (typeCast(Axis.$, c)).bz(this);
                }
                if (d != null) {
                    (typeCast(Axis.$, d)).cs(this);
                }
                if ((this.p8 != null && !this.p8.c0()) || (d == null && c != null)) {
                    this.ml(false);
                }
                this.ls();
                break;
            case ScatterTriangulationSeries.$$p[9]:
                if (c != null) {
                    (typeCast(Axis.$, c)).bz(this);
                }
                if (d != null) {
                    (typeCast(Axis.$, d)).cs(this);
                }
                if ((this.p9 != null && !this.p9.c0()) || (d == null && c != null)) {
                    this.ml(false);
                }
                this.ls();
                break;
            case ScatterTriangulationSeries.$$p[1]:
                if (this.trianglesSource != null) {
                    this.rk();
                    this.qn = ((function () {
                        var $ret = new FastItemsSource();
                        $ret.e = _this.trianglesSource;
                        return $ret;
                    })());
                }
                else {
                    this.qn = null;
                }
                break;
            case ScatterTriangulationSeries.$$p[0]:
                var g = typeCast(IFastItemsSource_$type, c);
                if (g != null) {
                    g.deregisterColumn(this.qi);
                    g.deregisterColumn(this.qj);
                    g.deregisterColumn(this.qk);
                    this.qi = null;
                    this.qj = null;
                    this.qk = null;
                }
                var h = typeCast(IFastItemsSource_$type, d);
                if (h != null) {
                    this.qi = this.qh(h, this.qy);
                    this.qj = this.qh(h, this.q0);
                    this.qk = this.qh(h, this.q2);
                }
                this.ml(false);
                this.ls();
                break;
            case ScatterTriangulationSeries.$$p[2]:
                if (this.qn != null) {
                    this.qn.deregisterColumn(this.qi);
                    this.qi = this.qh(this.qn, this.qy);
                }
                this.ml(false);
                this.ls();
                break;
            case ScatterTriangulationSeries.$$p[3]:
                if (this.qn != null) {
                    this.qn.deregisterColumn(this.qj);
                    this.qj = this.qh(this.qn, this.q0);
                }
                this.ml(false);
                this.ls();
                break;
            case ScatterTriangulationSeries.$$p[4]:
                if (this.qn != null) {
                    this.qn.deregisterColumn(this.qk);
                    this.qk = this.qh(this.qn, this.q2);
                }
                this.ml(false);
                this.ls();
                break;
            case "XColumn":
                if (this.p8 != null) {
                    this.p8.c0();
                }
                break;
            case "YColumn":
                if (this.p9 != null) {
                    this.p9.c0();
                }
                break;
        }
    };
    ScatterTriangulationSeries.prototype.qq = function (a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterTriangulationSeries.prototype.qp = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterTriangulationSeries.prototype.fb = function (a, b, c) {
        return _super.prototype.fb.call(this, a, b, c) && this.ck != null && this.p8 != null && this.p9 != null && this.p8.bh != null && this.p9.bh != null && a.width > 0 && a.height > 0 && this.qi != null && this.qi.count > 0 && this.qj != null && this.qj.count > 0 && this.qk != null && this.qk.count > 0 && this.ql != null && this.ql.count > 0 && this.qm != null && this.qm.count > 0;
    };
    ScatterTriangulationSeries.prototype.rl = function () {
        if (this.trianglesSource == null) {
            this.qr = null;
            this.qi = null;
            this.qj = null;
            this.qk = null;
            this.qo = false;
        }
    };
    ScatterTriangulationSeries.prototype.li = function () {
        _super.prototype.li.call(this);
        if (this.p8 != null) {
            this.p8.h6();
        }
        if (this.p9 != null) {
            this.p9.h6();
        }
    };
    ScatterTriangulationSeries.prototype.k3 = function (a, b, c, d) {
        _super.prototype.k3.call(this, a, b, c, d);
        this.rl();
        this.ml(false);
    };
    ScatterTriangulationSeries.prototype.ap = function (a) {
        if (a != null && a == this.p8 && this.ql != null) {
            return new AxisRange(this.ql.minimum, this.ql.maximum);
        }
        if (a != null && a == this.p9 && this.qm != null) {
            return new AxisRange(this.qm.minimum, this.qm.maximum);
        }
        return null;
    };
    ScatterTriangulationSeries.prototype.m9 = function (a, b) {
        this.ml(false);
    };
    ScatterTriangulationSeries.prototype.m8 = function (a, b) {
        this.ml(false);
    };
    Object.defineProperty(ScatterTriangulationSeries.prototype, "qi", {
        get: function () {
            return this.qc;
        },
        set: function (a) {
            var b = this.qi != a;
            if (b) {
                var c = this.qi;
                this.qc = a;
                this.raisePropertyChanged("TriangleVertexColumn1", c, this.qi);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "qj", {
        get: function () {
            return this.qd;
        },
        set: function (a) {
            var b = this.qj != a;
            if (b) {
                var c = this.qj;
                this.qd = a;
                this.raisePropertyChanged("TriangleVertexColumn2", c, this.qj);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "qk", {
        get: function () {
            return this.qe;
        },
        set: function (a) {
            var b = this.qk != a;
            if (b) {
                var c = this.qk;
                this.qe = a;
                this.raisePropertyChanged("TriangleVertexColumn3", c, this.qk);
            }
        },
        enumerable: false,
        configurable: true
    });
    ScatterTriangulationSeries.prototype.get_ee = function () {
        return true;
    };
    ScatterTriangulationSeries.prototype.get_d3 = function () {
        return true;
    };
    ScatterTriangulationSeries.prototype.getDataLegendSeriesContextAt = function (a, b) {
        var c = { $type: Point_$type, x: a, y: b };
        var d = this.hv(c);
        var e = d == null ? NaN : this.gd(d, "XMemberPath");
        var f = d == null ? NaN : this.gd(d, "YMemberPath");
        var g = new DataLegendSeriesValueInfo();
        g.l = e;
        g.a = 13;
        g.p = "X";
        g.q = this.ra != null ? this.ra : "X";
        g.r = this.q6 != null ? this.q6 : "X:";
        g.s = this.q8 != null ? this.q8 : "";
        var h = new DataLegendSeriesValueInfo();
        h.l = f;
        h.a = 14;
        h.p = "Y";
        h.q = this.ri != null ? this.ri : "Y";
        h.r = this.re != null ? this.re : "Y:";
        h.s = this.rg != null ? this.rg : "";
        var i = new DataLegendSeriesContext();
        i.f = ((function () {
            var $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:qn:ro', [IFastItemsSource_$type, null], 'TrianglesSource::rp', [IEnumerable_$type, null], 'TriangleVertexMemberPath1:qy:rq', [2, null], 'TriangleVertexMemberPath2:q0:rr', [2, null], 'TriangleVertexMemberPath3:q2:rs', [2, null], 'XAxis:p8:rt', [NumericXAxis.$, null], 'XMemberAsLegendLabel:q6:ru', [2, null], 'XMemberAsLegendUnit:q8:rv', [2, null], 'XMemberPath:ra:rw', [2, null], 'YAxis:p9:rx', [NumericYAxis.$, null], 'YMemberAsLegendLabel:re:ry', [2, null], 'YMemberAsLegendUnit:rg:rz', [2, null], 'YMemberPath:ri:r0', [2, null]]);
    return ScatterTriangulationSeries;
}(Series));
export { ScatterTriangulationSeries };
