/*
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.qa = null;
        _this.qb = null;
        _this.qj = false;
        _this.p6 = null;
        _this.triangulationStatusChanged = null;
        _this.qm = null;
        _this.p7 = null;
        _this.p8 = null;
        _this.p9 = null;
        return _this;
    }
    ScatterTriangulationSeries.prototype.ku = function () {
        _super.prototype.ku.call(this);
        this.p3 = null;
        this.p4 = null;
    };
    ScatterTriangulationSeries.prototype.hw = function (a, b) {
        var c = this.jq(b);
        if (c == ScatterTriangulationSeries.$$p[8]) {
            return this.hx(a, b, this.q5);
        }
        if (c == ScatterTriangulationSeries.$$p[12]) {
            return this.hx(a, b, this.rd);
        }
        return _super.prototype.hw.call(this, a, b);
    };
    Object.defineProperty(ScatterTriangulationSeries.prototype, "qg", {
        get: function () {
            return this.qa;
        },
        set: function (a) {
            var b = this.qg != a;
            if (b) {
                var c = this.qg;
                this.qa = a;
                this.raisePropertyChanged("XColumn", c, this.qg);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "qh", {
        get: function () {
            return this.qb;
        },
        set: function (a) {
            var b = this.qh != a;
            if (b) {
                var c = this.qh;
                this.qb = a;
                this.raisePropertyChanged("YColumn", c, this.qh);
            }
        },
        enumerable: false,
        configurable: true
    });
    ScatterTriangulationSeries.prototype.mi = function (a) {
        var b = this.ck != null && this.qi == null && this.qm == null && this.qg != null && this.qh != null && this.qg.count >= 3 && this.qh.count >= 3 && !this.qj;
        if (b) {
            this.rh();
            this.qj = true;
        }
    };
    ScatterTriangulationSeries.prototype.rh = function () {
        this.p6 = new Triangulator(this.ck.count, this.qg, this.qh);
        var a = this.p6;
        a.triangulationStatusChanged = delegateCombine(a.triangulationStatusChanged, runOn(this, this.ri));
        this.p6.y();
    };
    ScatterTriangulationSeries.prototype.rf = function () {
        if (this.p6 == null) {
            return;
        }
        this.p6.r();
        var a = this.p6;
        a.triangulationStatusChanged = delegateRemove(a.triangulationStatusChanged, runOn(this, this.ri));
        this.p6 = null;
    };
    ScatterTriangulationSeries.prototype.ri = function (a, b) {
        var _this = this;
        if (this.triangulationStatusChanged != null) {
            this.triangulationStatusChanged(this, new TriangulationStatusEventArgs(b.currentStatus));
        }
        if (b.currentStatus >= 100) {
            if (this.p6 == null) {
                return;
            }
            var c = this.p6;
            c.triangulationStatusChanged = delegateRemove(c.triangulationStatusChanged, runOn(this, this.ri));
            this.qm = this.p6.n();
            this.p6 = null;
            var d = ((function () {
                var $ret = new FastItemsSource();
                $ret.e = _this.qm;
                return $ret;
            })());
            this.qd = this.qc(d, "v1");
            this.qe = this.qc(d, "v2");
            this.qf = this.qc(d, "v3");
            this.mh(false);
        }
    };
    ScatterTriangulationSeries.prototype.qc = function (a, b) {
        if (b == null) {
            return a.registerColumnInt(null, null, false);
        }
        var c = null;
        var d = SeriesViewer.cc(b, this.coercionMethods);
        c = d.a;
        return a.registerColumnInt(b, c, this.expectFunctions);
    };
    ScatterTriangulationSeries.prototype.l3 = function (a, b, c, d) {
        var _this = this;
        _super.prototype.l3.call(this, a, b, c, d);
        switch (b) {
            case "FastItemsSource":
                var e = typeCast(IFastItemsSource_$type, c);
                if (e != null) {
                    e.deregisterColumn(this.qg);
                    e.deregisterColumn(this.qh);
                    this.qg = null;
                    this.qh = null;
                }
                this.rg();
                var f = typeCast(IFastItemsSource_$type, d);
                if (f != null) {
                    this.qg = this.ch(this.q5);
                    this.qh = this.ch(this.rd);
                }
                this.mh(false);
                break;
            case ScatterTriangulationSeries.$$p[8]:
                if (this.ck != null) {
                    this.ck.deregisterColumn(this.qg);
                    this.qg = this.ch(this.q5);
                }
                this.rg();
                this.mh(false);
                this.lo();
                break;
            case ScatterTriangulationSeries.$$p[12]:
                if (this.ck != null) {
                    this.ck.deregisterColumn(this.qh);
                    this.qh = this.ch(this.rd);
                }
                this.rg();
                this.mh(false);
                this.lo();
                break;
            case ScatterTriangulationSeries.$$p[5]:
                if (c != null) {
                    (typeCast(Axis.$, c)).bz(this);
                }
                if (d != null) {
                    (typeCast(Axis.$, d)).cs(this);
                }
                if ((this.p3 != null && !this.p3.c0()) || (d == null && c != null)) {
                    this.mh(false);
                }
                this.lo();
                break;
            case ScatterTriangulationSeries.$$p[9]:
                if (c != null) {
                    (typeCast(Axis.$, c)).bz(this);
                }
                if (d != null) {
                    (typeCast(Axis.$, d)).cs(this);
                }
                if ((this.p4 != null && !this.p4.c0()) || (d == null && c != null)) {
                    this.mh(false);
                }
                this.lo();
                break;
            case ScatterTriangulationSeries.$$p[1]:
                if (this.trianglesSource != null) {
                    this.rf();
                    this.qi = ((function () {
                        var $ret = new FastItemsSource();
                        $ret.e = _this.trianglesSource;
                        return $ret;
                    })());
                }
                else {
                    this.qi = null;
                }
                break;
            case ScatterTriangulationSeries.$$p[0]:
                var g = typeCast(IFastItemsSource_$type, c);
                if (g != null) {
                    g.deregisterColumn(this.qd);
                    g.deregisterColumn(this.qe);
                    g.deregisterColumn(this.qf);
                    this.qd = null;
                    this.qe = null;
                    this.qf = null;
                }
                var h = typeCast(IFastItemsSource_$type, d);
                if (h != null) {
                    this.qd = this.qc(h, this.qt);
                    this.qe = this.qc(h, this.qv);
                    this.qf = this.qc(h, this.qx);
                }
                this.mh(false);
                this.lo();
                break;
            case ScatterTriangulationSeries.$$p[2]:
                if (this.qi != null) {
                    this.qi.deregisterColumn(this.qd);
                    this.qd = this.qc(this.qi, this.qt);
                }
                this.mh(false);
                this.lo();
                break;
            case ScatterTriangulationSeries.$$p[3]:
                if (this.qi != null) {
                    this.qi.deregisterColumn(this.qe);
                    this.qe = this.qc(this.qi, this.qv);
                }
                this.mh(false);
                this.lo();
                break;
            case ScatterTriangulationSeries.$$p[4]:
                if (this.qi != null) {
                    this.qi.deregisterColumn(this.qf);
                    this.qf = this.qc(this.qi, this.qx);
                }
                this.mh(false);
                this.lo();
                break;
            case "XColumn":
                if (this.p3 != null) {
                    this.p3.c0();
                }
                break;
            case "YColumn":
                if (this.p4 != null) {
                    this.p4.c0();
                }
                break;
        }
    };
    ScatterTriangulationSeries.prototype.ql = function (a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterTriangulationSeries.prototype.qk = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterTriangulationSeries.prototype.e9 = function (a, b, c) {
        return _super.prototype.e9.call(this, a, b, c) && this.ck != null && this.p3 != null && this.p4 != null && this.p3.bh != null && this.p4.bh != null && a.width > 0 && a.height > 0 && this.qd != null && this.qd.count > 0 && this.qe != null && this.qe.count > 0 && this.qf != null && this.qf.count > 0 && this.qg != null && this.qg.count > 0 && this.qh != null && this.qh.count > 0;
    };
    ScatterTriangulationSeries.prototype.rg = function () {
        if (this.trianglesSource == null) {
            this.qm = null;
            this.qd = null;
            this.qe = null;
            this.qf = null;
            this.qj = false;
        }
    };
    ScatterTriangulationSeries.prototype.le = function () {
        _super.prototype.le.call(this);
        if (this.p3 != null) {
            this.p3.h6();
        }
        if (this.p4 != null) {
            this.p4.h6();
        }
    };
    ScatterTriangulationSeries.prototype.k0 = function (a, b, c, d) {
        _super.prototype.k0.call(this, a, b, c, d);
        this.rg();
        this.mh(false);
    };
    ScatterTriangulationSeries.prototype.ap = function (a) {
        if (a != null && a == this.p3 && this.qg != null) {
            return new AxisRange(this.qg.minimum, this.qg.maximum);
        }
        if (a != null && a == this.p4 && this.qh != null) {
            return new AxisRange(this.qh.minimum, this.qh.maximum);
        }
        return null;
    };
    ScatterTriangulationSeries.prototype.m5 = function (a, b) {
        this.mh(false);
    };
    ScatterTriangulationSeries.prototype.m4 = function (a, b) {
        this.mh(false);
    };
    Object.defineProperty(ScatterTriangulationSeries.prototype, "qd", {
        get: function () {
            return this.p7;
        },
        set: function (a) {
            var b = this.qd != a;
            if (b) {
                var c = this.qd;
                this.p7 = a;
                this.raisePropertyChanged("TriangleVertexColumn1", c, this.qd);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "qe", {
        get: function () {
            return this.p8;
        },
        set: function (a) {
            var b = this.qe != a;
            if (b) {
                var c = this.qe;
                this.p8 = a;
                this.raisePropertyChanged("TriangleVertexColumn2", c, this.qe);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "qf", {
        get: function () {
            return this.p9;
        },
        set: function (a) {
            var b = this.qf != a;
            if (b) {
                var c = this.qf;
                this.p9 = a;
                this.raisePropertyChanged("TriangleVertexColumn3", c, this.qf);
            }
        },
        enumerable: false,
        configurable: true
    });
    ScatterTriangulationSeries.prototype.get_ed = function () {
        return true;
    };
    ScatterTriangulationSeries.prototype.get_d2 = function () {
        return true;
    };
    ScatterTriangulationSeries.prototype.getDataLegendSeriesContextAt = function (a, b) {
        var c = { $type: Point_$type, x: a, y: b };
        var d = this.ht(c);
        var e = d == null ? NaN : this.gb(d, "XMemberPath");
        var f = d == null ? NaN : this.gb(d, "YMemberPath");
        var g = new DataLegendSeriesValueInfo();
        g.l = e;
        g.a = 13;
        g.p = this.q5 != null ? this.q5 : "X";
        ;
        g.q = this.q1 != null ? this.q1 : "X:";
        g.r = this.q3 != null ? this.q3 : "";
        var h = new DataLegendSeriesValueInfo();
        h.l = f;
        h.a = 14;
        h.p = this.rd != null ? this.rd : "Y";
        ;
        h.q = this.q9 != null ? this.q9 : "Y:";
        h.r = this.rb != null ? this.rb : "";
        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:qi:rj', [IFastItemsSource_$type, null], 'TrianglesSource::rk', [IEnumerable_$type, null], 'TriangleVertexMemberPath1:qt:rl', [2, null], 'TriangleVertexMemberPath2:qv:rm', [2, null], 'TriangleVertexMemberPath3:qx:rn', [2, null], 'XAxis:p3:ro', [NumericXAxis.$, null], 'XMemberAsLegendLabel:q1:rp', [2, null], 'XMemberAsLegendUnit:q3:rq', [2, null], 'XMemberPath:q5:rr', [2, null], 'YAxis:p4:rs', [NumericYAxis.$, null], 'YMemberAsLegendLabel:q9:rt', [2, null], 'YMemberAsLegendUnit:rb:ru', [2, null], 'YMemberPath:rd:rv', [2, null]]);
    return ScatterTriangulationSeries;
}(Series));
export { ScatterTriangulationSeries };
