/*
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 * as tslib_1 from "tslib";
import { Series } from "./Series";
import { DependencyProperty } from "igniteui-react-core/ES5/DependencyProperty";
import { IEnumerable_$type, Type, runOn, delegateCombine, delegateRemove, typeCast, markType } from "igniteui-react-core/ES5/type";
import { NumericXAxis } from "./NumericXAxis";
import { NumericYAxis } from "./NumericYAxis";
import { IFastItemsSource_$type } from "igniteui-react-core/ES5/IFastItemsSource";
import { Triangulator } from "igniteui-react-core/ES5/Triangulator";
import { TriangulationStatusEventArgs } from "igniteui-react-core/ES5/TriangulationStatusEventArgs";
import { FastItemsSource } from "igniteui-react-core/ES5/FastItemsSource";
import { SeriesViewer } from "./SeriesViewer";
import { Axis } from "./Axis";
import { AxisRange } from "./AxisRange";
import { PropertyMetadata } from "igniteui-react-core/ES5/PropertyMetadata";
/**
 * @hidden
 */
var ScatterTriangulationSeries = /** @class */ (function (_super) {
    tslib_1.__extends(ScatterTriangulationSeries, _super);
    function ScatterTriangulationSeries() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.l0 = null;
        _this.l1 = null;
        _this.l9 = false;
        _this.lw = null;
        _this.triangulationStatusChanged = null;
        _this.mc = null;
        _this.lx = null;
        _this.ly = null;
        _this.lz = null;
        return _this;
    }
    ScatterTriangulationSeries.prototype.hn = function () {
        _super.prototype.hn.call(this);
        this.lt = null;
        this.lu = null;
    };
    Object.defineProperty(ScatterTriangulationSeries.prototype, "l6", {
        get: function () {
            return this.l0;
        },
        set: function (a) {
            var b = this.l6 != a;
            if (b) {
                var c = this.l6;
                this.l0 = a;
                this.raisePropertyChanged("XColumn", c, this.l6);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "l7", {
        get: function () {
            return this.l1;
        },
        set: function (a) {
            var b = this.l7 != a;
            if (b) {
                var c = this.l7;
                this.l1 = a;
                this.raisePropertyChanged("YColumn", c, this.l7);
            }
        },
        enumerable: true,
        configurable: true
    });
    ScatterTriangulationSeries.prototype.i7 = function (a) {
        var b = this.bz != null && this.l8 == null && this.mc == null && this.l6 != null && this.l7 != null && this.l6.count >= 3 && this.l7.count >= 3 && !this.l9;
        if (b) {
            this.mz();
            this.l9 = true;
        }
    };
    ScatterTriangulationSeries.prototype.mz = function () {
        this.lw = new Triangulator(this.bz.count, this.l6, this.l7);
        var a = this.lw;
        a.triangulationStatusChanged = delegateCombine(a.triangulationStatusChanged, runOn(this, this.m0));
        this.lw.y();
    };
    ScatterTriangulationSeries.prototype.mx = function () {
        if (this.lw == null) {
            return;
        }
        this.lw.r();
        var a = this.lw;
        a.triangulationStatusChanged = delegateRemove(a.triangulationStatusChanged, runOn(this, this.m0));
        this.lw = null;
    };
    ScatterTriangulationSeries.prototype.m0 = function (a, b) {
        var _this = this;
        if (this.triangulationStatusChanged != null) {
            this.triangulationStatusChanged(this, new TriangulationStatusEventArgs(b.currentStatus));
        }
        if (b.currentStatus >= 100) {
            if (this.lw == null) {
                return;
            }
            var c = this.lw;
            c.triangulationStatusChanged = delegateRemove(c.triangulationStatusChanged, runOn(this, this.m0));
            this.mc = this.lw.n();
            this.lw = null;
            var d = ((function () {
                var $ret = new FastItemsSource();
                $ret.e = _this.mc;
                return $ret;
            })());
            this.l3 = this.l2(d, "v1");
            this.l4 = this.l2(d, "v2");
            this.l5 = this.l2(d, "v3");
            this.i6(false);
        }
    };
    ScatterTriangulationSeries.prototype.l2 = function (a, b) {
        if (b == null) {
            return a.registerColumnInt(null, null, false);
        }
        var c = null;
        var d = SeriesViewer.bb(b, this.coercionMethods);
        c = d.a;
        return a.registerColumnInt(b, c, this.expectFunctions);
    };
    ScatterTriangulationSeries.prototype.is = function (a, b, c, d) {
        var _this = this;
        _super.prototype.is.call(this, a, b, c, d);
        switch (b) {
            case "FastItemsSource":
                var e = typeCast(IFastItemsSource_$type, c);
                if (e != null) {
                    e.deregisterColumn(this.l6);
                    e.deregisterColumn(this.l7);
                    this.l6 = null;
                    this.l7 = null;
                }
                this.my();
                var f = typeCast(IFastItemsSource_$type, d);
                if (f != null) {
                    this.l6 = this.bw(this.mr);
                    this.l7 = this.bw(this.mv);
                }
                this.i6(false);
                break;
            case ScatterTriangulationSeries.$$p[6]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.l6);
                    this.l6 = this.bw(this.mr);
                }
                this.my();
                this.i6(false);
                this.ic();
                break;
            case ScatterTriangulationSeries.$$p[8]:
                if (this.bz != null) {
                    this.bz.deregisterColumn(this.l7);
                    this.l7 = this.bw(this.mv);
                }
                this.my();
                this.i6(false);
                this.ic();
                break;
            case ScatterTriangulationSeries.$$p[5]:
                if (c != null) {
                    (typeCast(Axis.$, c)).bv(this);
                }
                if (d != null) {
                    (typeCast(Axis.$, d)).ch(this);
                }
                if ((this.lt != null && !this.lt.ck()) || (d == null && c != null)) {
                    this.i6(false);
                }
                this.ic();
                break;
            case ScatterTriangulationSeries.$$p[7]:
                if (c != null) {
                    (typeCast(Axis.$, c)).bv(this);
                }
                if (d != null) {
                    (typeCast(Axis.$, d)).ch(this);
                }
                if ((this.lu != null && !this.lu.ck()) || (d == null && c != null)) {
                    this.i6(false);
                }
                this.ic();
                break;
            case ScatterTriangulationSeries.$$p[1]:
                if (this.trianglesSource != null) {
                    this.mx();
                    this.l8 = ((function () {
                        var $ret = new FastItemsSource();
                        $ret.e = _this.trianglesSource;
                        return $ret;
                    })());
                }
                else {
                    this.l8 = null;
                }
                break;
            case ScatterTriangulationSeries.$$p[0]:
                var g = typeCast(IFastItemsSource_$type, c);
                if (g != null) {
                    g.deregisterColumn(this.l3);
                    g.deregisterColumn(this.l4);
                    g.deregisterColumn(this.l5);
                    this.l3 = null;
                    this.l4 = null;
                    this.l5 = null;
                }
                var h = typeCast(IFastItemsSource_$type, d);
                if (h != null) {
                    this.l3 = this.l2(h, this.mj);
                    this.l4 = this.l2(h, this.ml);
                    this.l5 = this.l2(h, this.mn);
                }
                this.i6(false);
                this.ic();
                break;
            case ScatterTriangulationSeries.$$p[2]:
                if (this.l8 != null) {
                    this.l8.deregisterColumn(this.l3);
                    this.l3 = this.l2(this.l8, this.mj);
                }
                this.i6(false);
                this.ic();
                break;
            case ScatterTriangulationSeries.$$p[3]:
                if (this.l8 != null) {
                    this.l8.deregisterColumn(this.l4);
                    this.l4 = this.l2(this.l8, this.ml);
                }
                this.i6(false);
                this.ic();
                break;
            case ScatterTriangulationSeries.$$p[4]:
                if (this.l8 != null) {
                    this.l8.deregisterColumn(this.l5);
                    this.l5 = this.l2(this.l8, this.mn);
                }
                this.i6(false);
                this.ic();
                break;
            case "XColumn":
                if (this.lt != null) {
                    this.lt.ck();
                }
                break;
            case "YColumn":
                if (this.lu != null) {
                    this.lu.ck();
                }
                break;
        }
    };
    ScatterTriangulationSeries.prototype.mb = function (a) {
        if (typeCast(NumericYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterTriangulationSeries.prototype.ma = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    ScatterTriangulationSeries.prototype.dv = function (a, b, c) {
        return _super.prototype.dv.call(this, a, b, c) && this.bz != null && this.lt != null && this.lu != null && this.lt.bf != null && this.lu.bf != null && a.width > 0 && a.height > 0 && this.l3 != null && this.l3.count > 0 && this.l4 != null && this.l4.count > 0 && this.l5 != null && this.l5.count > 0 && this.l6 != null && this.l6.count > 0 && this.l7 != null && this.l7.count > 0;
    };
    ScatterTriangulationSeries.prototype.my = function () {
        if (this.trianglesSource == null) {
            this.mc = null;
            this.l3 = null;
            this.l4 = null;
            this.l5 = null;
            this.l9 = false;
        }
    };
    ScatterTriangulationSeries.prototype.h4 = function () {
        _super.prototype.h4.call(this);
        if (this.lt != null) {
            this.lt.gz();
        }
        if (this.lu != null) {
            this.lu.gz();
        }
    };
    ScatterTriangulationSeries.prototype.hs = function (a, b, c, d) {
        _super.prototype.hs.call(this, a, b, c, d);
        this.my();
        this.i6(false);
    };
    ScatterTriangulationSeries.prototype.an = function (a) {
        if (a != null && a == this.lt && this.l6 != null) {
            return new AxisRange(this.l6.minimum, this.l6.maximum);
        }
        if (a != null && a == this.lu && this.l7 != null) {
            return new AxisRange(this.l7.minimum, this.l7.maximum);
        }
        return null;
    };
    ScatterTriangulationSeries.prototype.jm = function (a, b) {
        this.i6(false);
    };
    ScatterTriangulationSeries.prototype.jl = function (a, b) {
        this.i6(false);
    };
    Object.defineProperty(ScatterTriangulationSeries.prototype, "l3", {
        get: function () {
            return this.lx;
        },
        set: function (a) {
            var b = this.l3 != a;
            if (b) {
                var c = this.l3;
                this.lx = a;
                this.raisePropertyChanged("TriangleVertexColumn1", c, this.l3);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "l4", {
        get: function () {
            return this.ly;
        },
        set: function (a) {
            var b = this.l4 != a;
            if (b) {
                var c = this.l4;
                this.ly = a;
                this.raisePropertyChanged("TriangleVertexColumn2", c, this.l4);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ScatterTriangulationSeries.prototype, "l5", {
        get: function () {
            return this.lz;
        },
        set: function (a) {
            var b = this.l5 != a;
            if (b) {
                var c = this.l5;
                this.lz = a;
                this.raisePropertyChanged("TriangleVertexColumn3", c, this.l5);
            }
        },
        enumerable: true,
        configurable: true
    });
    ScatterTriangulationSeries.prototype.get_c5 = function () {
        return true;
    };
    ScatterTriangulationSeries.$t = markType(ScatterTriangulationSeries, 'ScatterTriangulationSeries', Series.$);
    return ScatterTriangulationSeries;
}(Series));
export { ScatterTriangulationSeries };
Type.dep(DependencyProperty, PropertyMetadata, ScatterTriangulationSeries, 'raisePropertyChanged', ['FastTrianglesSource:l8:m1', [IFastItemsSource_$type, null], 'TrianglesSource::m2', [IEnumerable_$type, null], 'TriangleVertexMemberPath1:mj:m3', [2, null], 'TriangleVertexMemberPath2:ml:m4', [2, null], 'TriangleVertexMemberPath3:mn:m5', [2, null], 'XAxis:lt:m6', [NumericXAxis.$, null], 'XMemberPath:mr:m7', [2, null], 'YAxis:lu:m8', [NumericYAxis.$, null], 'YMemberPath:mv:m9', [2, null]]);
