/*
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-angular-core";
import { ISortingAxis_$type } from "./ISortingAxis";
import { List$1 } from "igniteui-angular-core";
import { Path } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { intDivide, isNaN_ } from "igniteui-angular-core";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
import { Defaults } from "./Defaults";
/**
 * @hidden
 */
export let StepAreaSeries = /*@__PURE__*/ (() => {
    class StepAreaSeries extends HorizontalAnchoredCategorySeries {
        constructor() {
            super();
            this.u6 = null;
            this.u6 = new CategoryLineRasterizer();
            this.ab = StepAreaSeries.$;
        }
        bx() {
            return new StepAreaSeriesView(this);
        }
        ly(a) {
            super.ly(a);
            this.u7 = a;
        }
        get_de() {
            return true;
        }
        get_dd() {
            return true;
        }
        get_eh() {
            return true;
        }
        get_d2() {
            return true;
        }
        b3() {
            if (this.b4 == 0) {
                return 2;
            }
            return super.b3();
        }
        preferredCategoryMode(a) {
            return typeCast(ISortingAxis_$type, a) !== null ? 0 : 1;
        }
        kx(a, b) {
            super.kx(a, b);
            let c = b;
            c.db();
        }
        u8(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);
        }
        ry() {
            return 1;
        }
        f9(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;
        }
        bp() {
            if (this.bq == 0) {
                return 2;
            }
            else {
                return super.bp();
            }
        }
        s6(a, b) {
            super.s6(a, b);
            let c = b.bv;
            let d = b.bu;
            let e = this.getEffectiveViewport1(b);
            let f = typeCast(ISortingAxis_$type, this.un) != null;
            let g = this.un != null ? 0.5 * this.un.getCategorySize(c, d, e) : 0;
            if (this.un != null && this.un.cg) {
                g = -g;
            }
            let h = a.f.count * 2;
            let i = new List$1(Array_$type, 2, h);
            this.rw.a0(this, this.sg(), runOn(this, this.rh), this.so(b), this.sp(b));
            let j = false;
            let k = this.rw.b;
            if (k != null) {
                j = true;
            }
            for (let l = 0; l < h; l++) {
                let m = new Array(4);
                m[0] = this.u8(l, false, a, g, f);
                m[1] = a.f._inner[(intDivide(l, 2))][1];
                m[2] = this.u8(l, true, a, g, f);
                m[3] = a.f._inner[(intDivide(l, 2))][2];
                i.add(m);
            }
            let n = this.rx.cr.d;
            if (j) {
                let o = new ScalerParams(0, b.bv, b.bu, this.un.cg, e);
                this.s2(i, -1, this.valueColumn.count, this.un, o, b.q);
            }
            let p = typeCast(StepAreaSeriesView.$, b);
            let q = p.dp;
            let r = p.dq;
            let s = p.dm;
            let t = p.dn;
            this.rw.ad(q, true, false, true, true);
            this.rw.ad(r, true, false, true, true);
            this.rw.ad(s, false, true, false, false);
            this.rw.ad(t, false, true, false, false);
            if (b.cv(a)) {
                p.dd(h, i, false, n, this.ft, (u, v, w, x, y) => this.t5(u, 2 * a.f.count, b), 1, this.tf(i, i.count - 1, b.bu, b.bv, true));
                b.cy(a);
            }
            let u = this.fetchYAxis();
            p.dm._opacity = this.rw.j * this.fq;
            p.dn._opacity = 0.5 * this.rw.j * this.fq;
        }
        get useHighMarkerFidelity() {
            return this.sj;
        }
    }
    StepAreaSeries.$t = markType(StepAreaSeries, 'StepAreaSeries', HorizontalAnchoredCategorySeries.$);
    return StepAreaSeries;
})();
/**
 * @hidden
 */
export let StepAreaSeriesView = /*@__PURE__*/ (() => {
    class StepAreaSeriesView extends AnchoredCategorySeriesView {
        constructor(a) {
            super(a);
            this.da = null;
            this.di = new Path();
            this.dk = new Path();
            this.dj = new Path();
            this.dl = new Path();
            this.de = new Path();
            this.dg = new Path();
            this.df = new Path();
            this.dh = new Path();
            this.da = a;
        }
        as() {
            super.as();
            if (!this.q) {
                this.da.qc = Defaults.c;
            }
        }
        get dm() {
            return this.di;
        }
        get dp() {
            return this.dk;
        }
        get dn() {
            return this.dj;
        }
        get dq() {
            return this.dl;
        }
        db() {
            this.di.ak = null;
            this.dj.ak = null;
            this.dk.ak = null;
            this.dl.ak = null;
            this.aq();
        }
        dc(a, b, c, d, e, f, g) {
            this.dc(a, b, c, d, e, f, g);
        }
        dd(a, b, c, d, e, f, g, h) {
            this.da.u6.a = typeCast(ISortingAxis_$type, this.ct.fetchXAxis()) !== null ? true : false;
            this.da.u6.j(this.di, this.dk, this.dj, this.dl, a, b, c, d, e, f, g, h);
            this.aq();
        }
        bc() {
            super.bc();
            this.de.ak = this.di.ak;
            this.dg.ak = this.dk.ak;
            this.df.ak = this.dj.ak;
            this.dh.ak = this.dl.ak;
            let a = this.bo();
            this.de._fill = a;
            this.de._opacity = 1;
            this.df._fill = a;
            this.df._opacity = 1;
            this.dg._stroke = a;
            this.dg.ac = this.e.fu + 3;
            this.dh._stroke = a;
            this.dh.ac = this.e.fu + 3;
        }
        a6(a, b) {
            super.a6(a, b);
            if (b) {
                a.s(this.de);
                a.s(this.df);
                a.s(this.dg);
                a.s(this.dh);
            }
            else {
                a.s(this.di);
                a.s(this.dj);
                a.s(this.dk);
                a.s(this.dl);
            }
        }
        al(a) {
            super.al(a);
            this.e.a8.exportPathData(a, this.dk, "lowerShape", ["Lower"]);
            this.e.a8.exportPathData(a, this.dl, "upperShape", ["Upper", "Main"]);
            this.e.a8.exportPathData(a, this.dj, "translucentShape", ["Translucent"]);
            this.e.a8.exportPathData(a, this.di, "fillShape", ["Fill"]);
        }
    }
    StepAreaSeriesView.$t = markType(StepAreaSeriesView, 'StepAreaSeriesView', AnchoredCategorySeriesView.$);
    return StepAreaSeriesView;
})();
