/*
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 { HorizontalAnchoredCategorySeries } from "./HorizontalAnchoredCategorySeries";
import { IIsCategoryBased_$type } from "./IIsCategoryBased";
import { CategoryLineRasterizer } from "./CategoryLineRasterizer";
import { typeCast, Array_$type, runOn, markType } from "igniteui-react-core/ES2015/type";
import { ISortingAxis_$type } from "./ISortingAxis";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
import { Path } from "igniteui-react-core/ES2015/Path";
import { ScalerParams } from "./ScalerParams";
import { intDivide, isNaN_ } from "igniteui-react-core/ES2015/number";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
import { Color } from "igniteui-react-core/ES2015/Color";
export class StepLineSeries extends HorizontalAnchoredCategorySeries {
    constructor() {
        super();
        this.p6 = null;
        this.p6 = new CategoryLineRasterizer();
        this.ab = StepLineSeries.$;
    }
    bf() {
        return new StepLineSeriesView(this);
    }
    ii(a) {
        super.ii(a);
        this.p7 = a;
    }
    ac() {
        super.ac();
    }
    preferredCategoryMode(a) {
        return typeCast(ISortingAxis_$type, a) !== null ? 0 : 1;
    }
    get_cj() {
        return true;
    }
    get cj() {
        return this.get_cj();
    }
    hl(a, b) {
        super.hl(a, b);
        let c = b;
        c.c5();
    }
    bd() {
        if (this.be == 0) {
            return 2;
        }
        else {
            return super.bd();
        }
    }
    ea(a, b, c, d, e, f, g, h) {
        let i = NaN;
        if (c >= 0 && c < b.count) {
            i = b.item(c);
        }
        let j = NaN;
        if (d >= 0 && d < b.count) {
            j = b.item(d);
        }
        if (f == 0) {
            return j;
        }
        if (e == b.count - 1) {
            return i;
        }
        if (isNaN_(j) && g != 0 && a <= 0.5 && !h) {
            return i;
        }
        if (isNaN_(i) && g != 0 && a >= 0.5 && !h) {
            return j;
        }
        if (a > 0.5) {
            return j;
        }
        return i;
    }
    p8(a, b, c, d, e, f) {
        let g;
        if (b) {
            if (f) {
                g = (a & 1) == 0;
                if (g || (intDivide(a, 2)) + 1 < 0) {
                    return c.f._inner[(intDivide(a, 2))][0];
                }
                if (c.f.count == (intDivide(a, 2)) + 1) {
                    return c.f._inner[(intDivide(a, 2))][0];
                }
                return c.f._inner[(intDivide(a, 2)) + 1][0];
            }
            g = (a & 1) == 0;
            return c.f._inner[(intDivide(a, 2))][0] + (g ? d : -d);
        }
        if (f) {
            g = (a & 1) == 0;
            if (g || ((intDivide(a, 2)) + 1) >= c.f.count) {
                return c.f._inner[(intDivide(a, 2))][0];
            }
            if (c.f.count == (intDivide(a, 2)) + 1) {
                return c.f._inner[(intDivide(a, 2))][0];
            }
            return c.f._inner[(intDivide(a, 2)) + 1][0];
        }
        g = (a & 1) == 0;
        return c.f._inner[(intDivide(a, 2))][0] + (g ? -d : d);
    }
    ob(a, b) {
        super.ob(a, b);
        let c = b.bq;
        let d = b.bp;
        let e = this.getEffectiveViewport1(b);
        let f = typeCast(ISortingAxis_$type, this.pn) != null;
        let g = this.pn.b8;
        let h = 0;
        if (this.pn != null) {
            h = 0.5 * this.pn.getCategorySize(c, d, e);
        }
        let i = a.f;
        let j = 2 * i.count;
        let k = new List$1(Array_$type, 2, j);
        if (!this.pn.b8) {
            for (let l = 0; l < j; l++) {
                let m = new Array(4);
                m[0] = this.p8(l, false, a, h, g, f);
                m[1] = a.f._inner[(intDivide(l, 2))][1];
                m[2] = this.p8(l, true, a, h, g, f);
                m[3] = a.f._inner[(intDivide(l, 2))][2];
                k.add(m);
            }
        }
        else {
            for (let n = 0; n < j; n++) {
                let o = new Array(4);
                o[0] = this.p8(n, true, a, h, g, f);
                o[1] = a.f._inner[(intDivide(n, 2))][1];
                o[2] = this.p8(n, true, a, h, g, f);
                o[3] = a.f._inner[(intDivide(n, 2))][2];
                k.add(o);
            }
        }
        let p = typeCast(StepLineSeriesView.$, b);
        let q = p.cl.d;
        this.m2.x(this, this.nn(), this.pn, runOn(this, this.mo), this.nv(b), this.nw(b));
        let r = false;
        let s = this.m2.c;
        if (s != null) {
            r = true;
        }
        if (r) {
            let t = new ScalerParams(0, b.bq, b.bp, this.pn.b8, e);
            this.n7(i, -1, this.valueColumn.count, this.pn, t, b.n);
        }
        let u = p.db;
        let v = p.dc;
        let w = p.da;
        this.m2.ae(u, true, false, true, false);
        this.m2.ae(v, true, false, true, false);
        this.m2.ae(w, false, true, false, false);
        w._opacity = 0.75 * this.m2.i;
        if (b.cp(a)) {
            p.c6(j, k, false, 1, this.ol(k, j - 1, b.bp, b.bq), q, this.eo);
            b.cs(a);
        }
    }
    get currentCategoryMode() {
        return this.preferredCategoryMode(this.pn);
    }
    get useHighMarkerFidelity() {
        return this.nq;
    }
}
StepLineSeries.$t = markType(StepLineSeries, 'StepLineSeries', HorizontalAnchoredCategorySeries.$, [IIsCategoryBased_$type]);
export class StepLineSeriesView extends AnchoredCategorySeriesView {
    constructor(a) {
        super(a);
        this.c4 = null;
        this.de = new Path();
        this.dd = new Path();
        this.df = new Path();
        this.c9 = new Path();
        this.c8 = new Path();
        this.c7 = new Path();
        this.c4 = a;
    }
    get db() {
        return this.de;
    }
    get dc() {
        return this.df;
    }
    get da() {
        return this.dd;
    }
    c5() {
        this.dd.aj = null;
        this.de.aj = null;
        this.df.aj = null;
        this.an();
    }
    c6(a, b, c, d, e, f, g) {
        this.c4.p6.a = typeCast(ISortingAxis_$type, this.cn.fetchXAxis()) !== null ? true : false;
        this.c4.p6.m(this.de, this.dd, this.df, a, b, c, d, e, f, g);
        this.an();
    }
    a9() {
        super.a9();
        this.c8.aj = this.de.aj;
        this.c9.aj = this.df.aj;
        this.c7.aj = this.dd.aj;
        let a = this.bk();
        this.c8._stroke = a;
        this.c8.ac = this.e.es + 3;
        this.c9._stroke = a;
        this.c9.ac = this.e.es + 3;
        this.c7._fill = a;
        this.c7._opacity = 1;
    }
    a3(a, b) {
        super.a3(a, b);
        if (a.d) {
            if (b) {
                a.s(this.c7);
                a.s(this.c8);
                a.s(this.c9);
            }
            else {
                a.s(this.dd);
                a.s(this.de);
                a.s(this.df);
            }
        }
    }
    ai(a) {
        super.ai(a);
        this.e.a2.exportPathData(a, this.de, "lowerShape", ["Lower", "Main"]);
        this.e.a2.exportPathData(a, this.df, "upperShape", ["Upper"]);
        this.e.a2.exportPathData(a, this.dd, "translucentShape", ["Translucent"]);
    }
    ac() {
        let a = new Color();
        a.colorString = "rgba(95,95,95,0.5)";
        this.e.ky = a;
        this.e.ep = 3;
        this.e.eq = 1;
        this.e.er = 4;
        this.e.dr = false;
    }
}
StepLineSeriesView.$t = markType(StepLineSeriesView, 'StepLineSeriesView', AnchoredCategorySeriesView.$);
