/*
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, __values } from "tslib";
import { Base, fromEnum, typeCast, markType } from "igniteui-angular-core";
import { ITrendLineManager_$type } from "./ITrendLineManager";
import { List$1 } from "igniteui-angular-core";
import { Polyline } from "igniteui-angular-core";
import { Flattener } from "igniteui-angular-core";
import { Series } from "./Series";
import { Panel } from "igniteui-angular-core";
import { isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
var TrendLineManagerBase$1 = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(TrendLineManagerBase$1, _super);
    function TrendLineManagerBase$1($tTrendColumn) {
        var _this = _super.call(this) || this;
        _this.$tTrendColumn = null;
        _this.d = null;
        _this.a = null;
        _this.g = ((function () {
            var $ret = new Polyline();
            $ret.ab = false;
            return $ret;
        })());
        _this.$tTrendColumn = $tTrendColumn;
        _this.$type = _this.$type.specialize(_this.$tTrendColumn);
        _this.d = new List$1(_this.$tTrendColumn, 0);
        return _this;
    }
    Object.defineProperty(TrendLineManagerBase$1.prototype, "g$j", {
        get: function () {
            return this.g;
        },
        enumerable: false,
        configurable: true
    });
    TrendLineManagerBase$1.prototype.g$g = function (a) {
        this.g$h(a, null);
    };
    TrendLineManagerBase$1.prototype.c = function (a) {
        return a == 1 || a == 2 || a == 3 || a == 4 || a == 5 || a == 6 || a == 7 || a == 8;
    };
    TrendLineManagerBase$1.prototype.b = function (a) {
        return a == 9 || a == 10 || a == 11 || a == 12 || a == 13;
    };
    TrendLineManagerBase$1.prototype.g$h = function (a, b) {
        var e_1, _a;
        this.g$j.an.clear();
        if (b != null) {
            b.i = this.g$j.an;
        }
        if (a != null) {
            try {
                for (var _b = __values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var c = _c.value;
                    if (!isNaN_(c.x) && !isNaN_(c.y)) {
                        if (b != null) {
                            b.j(c);
                        }
                        else {
                            this.g$j.an.add(c);
                        }
                    }
                }
            }
            catch (e_1_1) {
                e_1 = { error: e_1_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_1)
                        throw e_1.error;
                }
            }
        }
        this.g$j.ab = this.g$j.an.count > 0;
    };
    TrendLineManagerBase$1.prototype.e = function (a, b, c) {
        this.f(a, b, c, null);
    };
    TrendLineManagerBase$1.prototype.f = function (a, b, c, d) {
        var e_2, _a;
        if (d != null) {
            d.i = c;
        }
        try {
            for (var _b = __values(fromEnum(Flattener.d(a.count, function (f) { return a.item(f).x; }, function (f) { return a.item(f).y; }, b.b))), _c = _b.next(); !_c.done; _c = _b.next()) {
                var e = _c.value;
                if (d != null) {
                    d.j(a.item(e));
                }
                else {
                    c.add(a.item(e));
                }
            }
        }
        catch (e_2_1) {
            e_2 = { error: e_2_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_2)
                    throw e_2.error;
            }
        }
    };
    TrendLineManagerBase$1.prototype.g$c = function (a, b) {
        if (a == null || b == null) {
            return;
        }
        if (this.g$j.x != null) {
            this.g$f();
        }
        a.ab.add(this.g$j);
    };
    TrendLineManagerBase$1.prototype.g$f = function () {
        if (this.g$j == null) {
            return;
        }
        var a = typeCast(Panel.$, this.g$j.x);
        if (a != null) {
            a.ab.remove(this.g$j);
        }
    };
    TrendLineManagerBase$1.prototype.g$d = function () {
        this.g$j.an.clear();
    };
    TrendLineManagerBase$1.prototype.g$i = function () {
        this.a = null;
        this.d.clear();
    };
    TrendLineManagerBase$1.prototype.g$e = function (a, b, c, d) {
        switch (a) {
            case 3:
            case 2:
            case 1:
            case 0:
            case 4:
                this.g$i();
                break;
        }
    };
    TrendLineManagerBase$1.prototype.g$b = function (a, b, c, d) {
        var e = false;
        switch (b) {
            case "TrendLineType":
            case "TrendLinePeriod":
                this.g$i();
                e = true;
                break;
            case "TrendLineThickness":
                e = true;
                break;
            case Series.$$p[12]:
                e = true;
                this.g$i();
                break;
        }
        return e;
    };
    TrendLineManagerBase$1.$t = markType(TrendLineManagerBase$1, 'TrendLineManagerBase$1', Base.$, [ITrendLineManager_$type]);
    return TrendLineManagerBase$1;
}(Base));
export { TrendLineManagerBase$1 };
