/*
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 { CategoryTrendLineManagerBase } from "./CategoryTrendLineManagerBase";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
import { Point_$type, markType } from "igniteui-react-core/ES2015/type";
import { TrendFitCalculator } from "./TrendFitCalculator";
import { TrendAverageCalculator } from "./TrendAverageCalculator";
import { truncate } from "igniteui-react-core/ES2015/number";
export class SortingTrendLineManager extends CategoryTrendLineManagerBase {
    constructor(a, b) {
        super();
        this.p = null;
        this.q = null;
        this.p = a;
        this.q = b;
    }
    get_g$a() {
        return 1;
    }
    get g$a() {
        return this.get_g$a();
    }
    prepareLineCore(a, b, c, d, e, f, g) {
        let h = g.d * g.c;
        let i = g.e * g.c;
        let j = new List$1(Point_$type, 0);
        if (b == 0) {
            this.a = null;
            this.d.clear();
            return;
        }
        if (this.c(b)) {
            this.d.clear();
            this.a = TrendFitCalculator.a(j, b, g, this.a, c.count, (k) => (k + 1), (k) => c.item(k), (k) => {
                let l = truncate(Math.floor(k));
                let m = truncate(Math.ceil(k));
                let n = k - l;
                let o;
                if (m <= i) {
                    o = this.p(l) + n * (this.p(m) - this.p(l));
                }
                else {
                    o = this.p(l) + n * (this.p(truncate(i)) - this.p(l));
                }
                return e(o);
            }, f, h, i);
        }
        if (this.b(b)) {
            this.a = null;
            TrendAverageCalculator.b(b, this.d, c, d);
            for (let k = g.d; k <= g.e; k += 1) {
                let l = k * g.c;
                let m = this.p(l);
                if (l >= 0 && l < this.d.count) {
                    let n = e(m);
                    let o = f(this.d._inner[l]);
                    j.add({ $type: Point_$type, x: n + g.a, y: o });
                }
            }
        }
        this.m(j, g, a);
    }
}
SortingTrendLineManager.$t = markType(SortingTrendLineManager, 'SortingTrendLineManager', CategoryTrendLineManagerBase.$);
