/*
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 { TrendLineManagerBase$1 } from "./TrendLineManagerBase$1";
import { Point_$type, fromEnum, markType } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { TrendFitCalculator } from "./TrendFitCalculator";
import { TrendAverageCalculator } from "./TrendAverageCalculator";
import { isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
var ScatterTrendLineManager = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(ScatterTrendLineManager, _super);
    function ScatterTrendLineManager() {
        return _super.call(this, Point_$type) || this;
    }
    ScatterTrendLineManager.prototype.get_g$a = function () {
        return 4;
    };
    Object.defineProperty(ScatterTrendLineManager.prototype, "g$a", {
        get: function () {
            return this.get_g$a();
        },
        enumerable: false,
        configurable: true
    });
    ScatterTrendLineManager.prototype.h = function (a, b, c, d, e, f, g, h, i, j, k) {
        var e_1, _a;
        var l = j;
        var m = k;
        var n = new List$1(Point_$type, 0);
        var o = 0;
        if (c != null) {
            o = c.count;
        }
        if (d != null) {
            o = Math.min(o, d.count);
        }
        if (!h.g.isEmpty && !h.f.isEmpty) {
            if (b == 0) {
                this.a = null;
                this.d.clear();
            }
            else if (this.c(b)) {
                this.d.clear();
                this.a = TrendFitCalculator.a(n, b, h, this.a, o, function (p) { return c.item(p); }, function (p) { return d.item(p); }, f, g, l, m);
            }
            else if (this.b(b)) {
                this.a = null;
                this.d.clear();
                TrendAverageCalculator.c(b, this.d, c, d, e);
                try {
                    for (var _b = __values(fromEnum(this.d)), _c = _b.next(); !_c.done; _c = _b.next()) {
                        var p = _c.value;
                        var q = f(p.x);
                        var r = g(p.y);
                        if (!isNaN_(q) && !isNaN_(r)) {
                            n.add({ $type: Point_$type, x: q, y: r });
                        }
                    }
                }
                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.f(n, h, a, i);
        }
    };
    ScatterTrendLineManager.$t = markType(ScatterTrendLineManager, 'ScatterTrendLineManager', TrendLineManagerBase$1.$.specialize(Point_$type));
    return ScatterTrendLineManager;
}(TrendLineManagerBase$1));
export { ScatterTrendLineManager };
