/*
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 { TrendLineManagerBase$1 } from "./TrendLineManagerBase$1";
import { Point_$type, fromEnum, markType } from "igniteui-react-core/ES5/type";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { TrendFitCalculator } from "./TrendFitCalculator";
import { TrendAverageCalculator } from "./TrendAverageCalculator";
import { PolarLinePlanner } from "./PolarLinePlanner";
import { isNaN_ } from "igniteui-react-core/ES5/number";
/**
 * @hidden
 */
var PolarTrendLineManager = /** @class */ (function (_super) {
    tslib_1.__extends(PolarTrendLineManager, _super);
    function PolarTrendLineManager() {
        var _this = _super.call(this, Point_$type) || this;
        _this.q = false;
        _this.p = 0;
        _this.s = 0;
        _this.r = 0;
        _this.t = null;
        _this.u = null;
        return _this;
    }
    PolarTrendLineManager.prototype.get_g$a = function () {
        return 2;
    };
    Object.defineProperty(PolarTrendLineManager.prototype, "g$a", {
        get: function () {
            return this.get_g$a();
        },
        enumerable: true,
        configurable: true
    });
    PolarTrendLineManager.prototype.v = 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);
        if (!h.g.isEmpty && !h.f.isEmpty) {
            var o_1 = c;
            var p_1 = d;
            var q = 0;
            if (o_1 != null) {
                q = o_1.count;
            }
            if (p_1 != null) {
                q = Math.min(q, p_1.count);
            }
            if (b == 0) {
                this.a = null;
                this.d.clear();
                return;
            }
            if (this.c(b)) {
                this.d.clear();
                this.a = TrendFitCalculator.a(n, b, h, this.a, q, function (r) { return o_1.item(r); }, function (r) { return p_1.item(r); }, f, g, l, m);
            }
            if (this.b(b)) {
                this.a = null;
                TrendAverageCalculator.c(b, this.d, c, d, e);
                try {
                    for (var _b = tslib_1.__values(fromEnum(this.d)), _c = _b.next(); !_c.done; _c = _b.next()) {
                        var r = _c.value;
                        var s = f(r.x);
                        var t = g(r.y);
                        if (!isNaN_(s) && !isNaN_(t)) {
                            n.add({ $type: Point_$type, x: s, y: t });
                        }
                    }
                }
                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; }
                }
            }
            if (n.count > 0) {
                this.n(n, h, a, i);
            }
        }
    };
    PolarTrendLineManager.prototype.n = function (a, b, c, d) {
        var _this = this;
        if (d != null) {
            d.i = c;
        }
        var e = ((function () {
            var $ret = new PolarLinePlanner();
            $ret.m = function (f) { return a.item(f).x; };
            $ret.n = function (f) { return a.item(f).y; };
            $ret.a = d;
            $ret.q = a.count;
            $ret.l = b.b;
            $ret.o = function (f) { return _this.t(a.item(f).x, a.item(f).y); };
            $ret.p = function (f) { return _this.u(a.item(f).x, a.item(f).y); };
            $ret.f = _this.q;
            $ret.b = _this.p;
            $ret.ab = b.f;
            $ret.ac = b.g;
            return $ret;
        })());
        e.x(null, null);
    };
    PolarTrendLineManager.$t = markType(PolarTrendLineManager, 'PolarTrendLineManager', TrendLineManagerBase$1.$.specialize(Point_$type));
    return PolarTrendLineManager;
}(TrendLineManagerBase$1));
export { PolarTrendLineManager };
