/*
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";
/**
 * @hidden
 */
export class StepAreaSeries extends HorizontalAnchoredCategorySeries {
    constructor() {
        super();
        this.qa = null;
        this.qa = new CategoryLineRasterizer();
        this.ab = StepAreaSeries.$;
    }
    bf() {
        return new StepAreaSeriesView(this);
    }
    getHostReferenceValue() {
        return this.ee();
    }
    im(a) {
        super.im(a);
        this.qb = a;
    }
    get_ck() {
        return true;
    }
    preferredCategoryMode(a) {
        return typeCast(ISortingAxis_$type, a) !== null ? 0 : 1;
    }
    hp(a, b) {
        super.hp(a, b);
        let c = b;
        c.c7();
    }
    qc(a, b, c, d, e) {
        if (b) {
            if (e) {
                if ((a & 1) == 0 || ((intDivide(a, 2)) + 1) >= c.f.count) {
                    return c.f._inner[(intDivide(a, 2))][0];
                }
                return c.f._inner[(intDivide(a, 2)) + 1][0];
            }
            return c.f._inner[(intDivide(a, 2))][0] + ((a & 1) == 1 ? -d : d);
        }
        if (e) {
            if ((a & 1) == 0 || ((intDivide(a, 2)) + 1) >= c.f.count) {
                return c.f._inner[(intDivide(a, 2))][0];
            }
            return c.f._inner[(intDivide(a, 2)) + 1][0];
        }
        return c.f._inner[(intDivide(a, 2))][0] + ((a & 1) == 0 ? -d : d);
    }
    m9() {
        return 1;
    }
    ec(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;
    }
    bd() {
        if (this.be == 0) {
            return 2;
        }
        else {
            return super.bd();
        }
    }
    oh(a, b) {
        super.oh(a, b);
        let c = b.bs;
        let d = b.br;
        let e = this.getEffectiveViewport1(b);
        let f = typeCast(ISortingAxis_$type, this.pr) != null;
        let g = this.pr != null ? 0.5 * this.pr.getCategorySize(c, d, e) : 0;
        if (this.pr != null && this.pr.b8) {
            g = -g;
        }
        let h = a.f.count * 2;
        let i = new List$1(Array_$type, 2, h);
        this.m7.x(this, this.ns(), this.pr, runOn(this, this.mt), this.n0(b), this.n1(b));
        let j = false;
        let k = this.m7.c;
        if (k != null) {
            j = true;
        }
        for (let l = 0; l < h; l++) {
            let m = new Array(4);
            m[0] = this.qc(l, false, a, g, f);
            m[1] = a.f._inner[(intDivide(l, 2))][1];
            m[2] = this.qc(l, true, a, g, f);
            m[3] = a.f._inner[(intDivide(l, 2))][2];
            i.add(m);
        }
        let n = this.m8.cn.d;
        if (j) {
            let o = new ScalerParams(0, b.bs, b.br, this.pr.b8, e);
            this.od(i, -1, this.valueColumn.count, this.pr, o, b.n);
        }
        let p = typeCast(StepAreaSeriesView.$, b);
        let q = p.dj;
        let r = p.dl;
        let s = p.df;
        let t = p.dh;
        this.m7.ae(q, true, false, true, true);
        this.m7.ae(r, true, false, true, true);
        this.m7.ae(s, false, true, false, false);
        this.m7.ae(t, false, true, false, false);
        if (b.cr(a)) {
            p.c9(h, i, false, n, this.er, (u, v, w, x, y) => this.pb(u, 2 * a.f.count, b), 1, this.oq(i, i.count - 1, b.br, b.bs, true));
            b.cu(a);
        }
        let u = this.fetchYAxis();
        p.df._opacity = this.d3;
        p.dh._opacity = 0.5 * this.d3;
    }
    get currentCategoryMode() {
        return this.preferredCategoryMode(this.pr);
    }
    get useHighMarkerFidelity() {
        return this.nv;
    }
}
StepAreaSeries.$t = markType(StepAreaSeries, 'StepAreaSeries', HorizontalAnchoredCategorySeries.$, [IIsCategoryBased_$type]);
/**
 * @hidden
 */
export class StepAreaSeriesView extends AnchoredCategorySeriesView {
    constructor(a) {
        super(a);
        this.c6 = null;
        this.de = new Path();
        this.di = new Path();
        this.dg = new Path();
        this.dk = new Path();
        this.da = new Path();
        this.dc = new Path();
        this.db = new Path();
        this.dd = new Path();
        this.c6 = a;
    }
    ap() {
        super.ap();
        if (!this.n) {
            this.e.bj = 1;
        }
    }
    get df() {
        return this.de;
    }
    get dj() {
        return this.di;
    }
    get dh() {
        return this.dg;
    }
    get dl() {
        return this.dk;
    }
    c7() {
        this.de.aj = null;
        this.dg.aj = null;
        this.di.aj = null;
        this.dk.aj = null;
        this.an();
    }
    c8(a, b, c, d, e, f, g) {
        this.c8(a, b, c, d, e, f, g);
    }
    c9(a, b, c, d, e, f, g, h) {
        this.c6.qa.a = typeCast(ISortingAxis_$type, this.cp.fetchXAxis()) !== null ? true : false;
        this.c6.qa.j(this.de, this.di, this.dg, this.dk, a, b, c, d, e, f, g, h);
        this.an();
    }
    a9() {
        super.a9();
        this.da.aj = this.de.aj;
        this.dc.aj = this.di.aj;
        this.db.aj = this.dg.aj;
        this.dd.aj = this.dk.aj;
        let a = this.bl();
        this.da._fill = a;
        this.da._opacity = 1;
        this.db._fill = a;
        this.db._opacity = 1;
        this.dc._stroke = a;
        this.dc.ac = this.e.ev + 3;
        this.dd._stroke = a;
        this.dd.ac = this.e.ev + 3;
    }
    a3(a, b) {
        super.a3(a, b);
        if (b) {
            a.s(this.da);
            a.s(this.db);
            a.s(this.dc);
            a.s(this.dd);
        }
        else {
            a.s(this.de);
            a.s(this.dg);
            a.s(this.di);
            a.s(this.dk);
        }
    }
    ai(a) {
        super.ai(a);
        this.e.a2.exportPathData(a, this.di, "lowerShape", ["Lower"]);
        this.e.a2.exportPathData(a, this.dk, "upperShape", ["Upper", "Main"]);
        this.e.a2.exportPathData(a, this.dg, "translucentShape", ["Translucent"]);
        this.e.a2.exportPathData(a, this.de, "fillShape", ["Fill"]);
    }
}
StepAreaSeriesView.$t = markType(StepAreaSeriesView, 'StepAreaSeriesView', AnchoredCategorySeriesView.$);
