/*
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 { CategoryLineRasterizer } from "./CategoryLineRasterizer";
import { typeCast, Array_$type, runOn, markType } from "igniteui-react-core";
import { ISortingAxis_$type } from "./ISortingAxis";
import { List$1 } from "igniteui-react-core";
import { Path } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { intDivide, isNaN_ } from "igniteui-react-core";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
import { Defaults } from "./Defaults";
/**
 * @hidden
 */
export let StepAreaSeries = /*@__PURE__*/ (() => {
    class StepAreaSeries extends HorizontalAnchoredCategorySeries {
        cg() {
            return new StepAreaSeriesView(this);
        }
        o0(a) {
            super.o0(a);
            this.zf = a;
        }
        get_d9() {
            return true;
        }
        get_d8() {
            return true;
        }
        get_fe() {
            return true;
        }
        get_ey() {
            return true;
        }
        cm() {
            if (this.cn == 0) {
                return 2;
            }
            return super.cm();
        }
        constructor() {
            super();
            this.ze = null;
            this.ze = new CategoryLineRasterizer();
            this.ab = StepAreaSeries.$;
        }
        preferredCategoryMode(a) {
            return typeCast(ISortingAxis_$type, a) !== null ? 0 : 1;
        }
        nj(a, b) {
            super.nj(a, b);
            let c = b;
            c.de();
        }
        zg(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);
        }
        vw() {
            return 1;
        }
        hz(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;
        }
        bx() {
            if (this.by == 0) {
                return 2;
            }
            else {
                return super.bx();
            }
        }
        w5(a, b) {
            super.w5(a, b);
            let c = b.by;
            let d = b.bx;
            let e = this.getEffectiveViewport1(b);
            let f = typeCast(ISortingAxis_$type, this.yv) != null;
            let g = this.yv != null ? 0.5 * this.yv.getCategorySize(c, d, e) : 0;
            if (this.yv != null && this.yv.ch) {
                g = -g;
            }
            let h = a.f.count * 2;
            let i = new List$1(Array_$type, 2, h);
            this.vu.a2(this, this.we(), runOn(this, this.vf), this.wn(b), this.wo(b));
            let j = false;
            let k = this.vu.b;
            if (k != null) {
                j = true;
            }
            for (let l = 0; l < h; l++) {
                let m = new Array(4);
                m[0] = this.zg(l, false, a, g, f);
                m[1] = a.f._inner[(intDivide(l, 2))][1];
                m[2] = this.zg(l, true, a, g, f);
                m[3] = a.f._inner[(intDivide(l, 2))][2];
                i.add(m);
            }
            let n = this.vv.cu.d;
            if (j) {
                let o = new ScalerParams(0, b.by, b.bx, this.yv.ch, e);
                this.w1(i, -1, this.valueColumn.count, this.yv, o, b.q);
            }
            let p = typeCast(StepAreaSeriesView.$, b);
            let q = p.ds;
            let r = p.dt;
            let s = p.dq;
            let t = p.dr;
            this.vu.ad(q, true, false, true, true);
            this.vu.ad(r, true, false, true, true);
            this.vu.ad(s, false, true, false, false);
            this.vu.ad(t, false, true, false, false);
            if (b.cy(a)) {
                p.dg(h, i, false, n, this.hj, (u, v, w, x, y) => this.yb(u, 2 * a.f.count, b), 1, this.xe(i, i.count - 1, b.bx, b.by, true));
                b.c1(a);
            }
            let u = this.fetchYAxis();
            p.dq._opacity = this.vu.j * this.hf;
            p.dr._opacity = 0.5 * this.vu.j * this.hf;
        }
        get useHighMarkerFidelity() {
            return this.wi;
        }
    }
    StepAreaSeries.$t = /*@__PURE__*/ markType(StepAreaSeries, 'StepAreaSeries', HorizontalAnchoredCategorySeries.$);
    return StepAreaSeries;
})();
/**
 * @hidden
 */
export let StepAreaSeriesView = /*@__PURE__*/ (() => {
    class StepAreaSeriesView extends AnchoredCategorySeriesView {
        constructor(a) {
            super(a);
            this.dd = null;
            this.dl = new Path();
            this.dn = new Path();
            this.dm = new Path();
            this.dp = new Path();
            this.dh = new Path();
            this.dj = new Path();
            this.di = new Path();
            this.dk = new Path();
            this.dd = a;
        }
        au() {
            super.au();
            if (!this.q) {
                this.dd.ua = Defaults.c;
            }
        }
        get dq() {
            return this.dl;
        }
        get ds() {
            return this.dn;
        }
        get dr() {
            return this.dm;
        }
        get dt() {
            return this.dp;
        }
        de() {
            this.dl.an = null;
            this.dm.an = null;
            this.dn.an = null;
            this.dp.an = null;
            this.as();
        }
        df(a, b, c, d, e, f, g) {
            this.df(a, b, c, d, e, f, g);
        }
        dg(a, b, c, d, e, f, g, h) {
            this.dd.ze.a = typeCast(ISortingAxis_$type, this.cw.fetchXAxis()) !== null ? true : false;
            this.dd.ze.j(this.dl, this.dn, this.dm, this.dp, a, b, c, d, e, f, g, h);
            this.as();
        }
        be() {
            super.be();
            this.dh.an = this.dl.an;
            this.dj.an = this.dn.an;
            this.di.an = this.dm.an;
            this.dk.an = this.dp.an;
            let a = this.br();
            this.dh._fill = a;
            this.dh._opacity = 1;
            this.di._fill = a;
            this.di._opacity = 1;
            this.dj._stroke = a;
            this.dj.ad = this.e.hk + 3;
            this.dk._stroke = a;
            this.dk.ad = this.e.hk + 3;
        }
        a8(a, b) {
            super.a8(a, b);
            if (b) {
                a.t(this.dh);
                a.t(this.di);
                a.t(this.dj);
                a.t(this.dk);
            }
            else {
                a.t(this.dl);
                a.t(this.dm);
                a.t(this.dn);
                a.t(this.dp);
            }
        }
        an(a) {
            super.an(a);
            this.e.a9.exportPathData(a, this.dn, "lowerShape", ["Lower"]);
            this.e.a9.exportPathData(a, this.dp, "upperShape", ["Upper", "Main"]);
            this.e.a9.exportPathData(a, this.dm, "translucentShape", ["Translucent"]);
            this.e.a9.exportPathData(a, this.dl, "fillShape", ["Fill"]);
        }
    }
    StepAreaSeriesView.$t = /*@__PURE__*/ markType(StepAreaSeriesView, 'StepAreaSeriesView', AnchoredCategorySeriesView.$);
    return StepAreaSeriesView;
})();
