/*
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 { CategoryTrendLineManager } from "./CategoryTrendLineManager";
import { Point_$type, markType } from "igniteui-angular-core";
import { TrendResolutionParams } from "./TrendResolutionParams";
import { ScalerParams } from "./ScalerParams";
import { SafeSortedReadOnlyDoubleCollection } from "./SafeSortedReadOnlyDoubleCollection";
import { List$1 } from "igniteui-angular-core";
import { BarTrendFitCalculator } from "./BarTrendFitCalculator";
import { TrendAverageCalculator } from "./TrendAverageCalculator";
/**
 * @hidden
 */
export let BarTrendLineManager = /*@__PURE__*/ (() => {
    class BarTrendLineManager extends CategoryTrendLineManager {
        prepareLine(a, b, c, d) {
            let e = b.n;
            let f = new ScalerParams(0, b.p, b.o, b.b.j$b, e);
            let g = new ScalerParams(0, b.p, b.o, b.c.j$b, e);
            let h = c.f;
            if (b.d != null && b.d.i$b != null) {
                h = new SafeSortedReadOnlyDoubleCollection(0, h, b.d.i$b);
            }
            let i = ((() => {
                let $ret = new TrendResolutionParams();
                $ret.e = b.j;
                $ret.f = b.k;
                $ret.g = b.l;
                $ret.a = d;
                $ret.d = b.i;
                $ret.i = b.o;
                $ret.h = b.n;
                return $ret;
            })());
            if (a.trendLineType != 0) {
                this.prepareLineCore(b.a.s, a.trendLineType, h, a.trendLinePeriod, (j) => b.c.j$c(j, g), (j) => b.b.j$c(j, f), i);
            }
        }
        prepareLineCore(a, b, c, d, e, f, g) {
            let h = g.f * g.e;
            let i = g.g * g.e;
            let j = new List$1(Point_$type, 0);
            if (b == 0) {
                this.a = null;
                this.i.clear();
                return;
            }
            if (this.d(b)) {
                this.i.clear();
                this.a = BarTrendFitCalculator.a(j, b, g, this.a, c.count, (k) => c.item(k), (k) => k + 1, e, (k) => f(k - 1), h + 1, i + 1);
            }
            if (this.c(b)) {
                this.a = null;
                TrendAverageCalculator.b(b, this.i, c, d);
                for (let k = g.f; k <= g.g; k += 1) {
                    let l = k * g.e;
                    if (l >= 0 && l < this.i.count) {
                        let m = e(this.i._inner[l]);
                        let n = f(l);
                        j.add({ $type: Point_$type, x: m, y: n + g.a });
                    }
                }
            }
            this.f(j, g, a);
        }
    }
    BarTrendLineManager.$t = markType(BarTrendLineManager, 'BarTrendLineManager', CategoryTrendLineManager.$);
    return BarTrendLineManager;
})();
