/*
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 { DoubleTrendLineManagerBase } from "./DoubleTrendLineManagerBase";
import { Point_$type, markType } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { TrendFitCalculator } from "./TrendFitCalculator";
import { TrendAverageCalculator } from "./TrendAverageCalculator";
import { PolarLinePlanner } from "./PolarLinePlanner";
import { isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
export let RadialTrendLineManager = /*@__PURE__*/ (() => {
    class RadialTrendLineManager extends DoubleTrendLineManagerBase {
        constructor() {
            super(...arguments);
            this.k = 0;
            this.j = 0;
            this.l = null;
            this.m = null;
        }
        get_g$a() {
            return 3;
        }
        get g$a() {
            return this.get_g$a();
        }
        n(a, b, c, d, e, f, g, h) {
            let i = g.f * g.e;
            let j = g.g * g.e;
            let k = new List$1(Point_$type, 0);
            if (!g.j.isEmpty && !g.i.isEmpty) {
                if (b == 0) {
                    this.a = null;
                    this.i.clear();
                    return;
                }
                if (this.d(b)) {
                    this.i.clear();
                    this.a = TrendFitCalculator.a(k, b, g, this.a, c.count, (l) => (l + 1), (l) => c.item(l), (l) => e(l - 1), f, i + 1, j + 1);
                }
                if (this.c(b)) {
                    this.a = null;
                    TrendAverageCalculator.b(b, this.i, c, d);
                    for (let l = g.f; l <= g.g; l += 1) {
                        let m = (l % c.count) * g.e;
                        if (m >= 0 && m < this.i.count) {
                            let n = e(m);
                            let o = f(this.i._inner[m]);
                            if (!isNaN_(n) && !isNaN_(o)) {
                                k.add({ $type: Point_$type, x: n + g.a, y: o });
                            }
                        }
                    }
                }
                if (k.count > 0) {
                    this.g(k, g, a, h);
                }
            }
        }
        f(a, b, c) {
            this.g(a, b, c, null);
        }
        g(a, b, c, d) {
            if (d != null) {
                d.i = c;
            }
            let e = ((() => {
                let $ret = new PolarLinePlanner();
                $ret.m = (f) => a.item(f).x;
                $ret.n = (f) => a.item(f).y;
                $ret.a = d;
                $ret.q = a.count;
                $ret.l = b.d;
                $ret.o = (f) => this.l(a.item(f).x, a.item(f).y);
                $ret.p = (f) => this.m(a.item(f).x, a.item(f).y);
                $ret.f = true;
                $ret.ad = b.i;
                $ret.ac = b.h;
                $ret.ae = b.j;
                return $ret;
            })());
            e.x(null, null);
        }
    }
    RadialTrendLineManager.$t = markType(RadialTrendLineManager, 'RadialTrendLineManager', DoubleTrendLineManagerBase.$);
    return RadialTrendLineManager;
})();
