/*
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";
import { Color } from "igniteui-react-core";
/**
 * @hidden
 */
export let StepLineSeries = /*@__PURE__*/ (() => {
    class StepLineSeries extends HorizontalAnchoredCategorySeries {
        get_ex() {
            return true;
        }
        get_fe() {
            return true;
        }
        get_ey() {
            return true;
        }
        cg() {
            return new StepLineSeriesView(this);
        }
        wg() {
            return true;
        }
        o0(a) {
            super.o0(a);
            this.zf = a;
        }
        constructor() {
            super();
            this.ze = null;
            this.ze = new CategoryLineRasterizer();
            this.ab = StepLineSeries.$;
        }
        ac() {
            super.ac();
        }
        preferredCategoryMode(a) {
            return typeCast(ISortingAxis_$type, a) !== null ? 0 : 1;
        }
        get_d9() {
            return true;
        }
        nj(a, b) {
            super.nj(a, b);
            let c = b;
            c.de();
        }
        bx() {
            if (this.by == 0) {
                return 2;
            }
            else {
                return super.bx();
            }
        }
        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;
        }
        zg(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);
        }
        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.ch;
            let h = 0;
            if (this.yv != null) {
                h = 0.5 * this.yv.getCategorySize(c, d, e);
            }
            let i = a.f;
            let j = 2 * i.count;
            let k = new List$1(Array_$type, 2, j);
            if (!this.yv.ch) {
                for (let l = 0; l < j; l++) {
                    let m = new Array(4);
                    m[0] = this.zg(l, false, a, h, g, f);
                    m[1] = a.f._inner[(intDivide(l, 2))][1];
                    m[2] = this.zg(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.zg(n, true, a, h, g, f);
                    o[1] = a.f._inner[(intDivide(n, 2))][1];
                    o[2] = this.zg(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.cu.d;
            this.vu.a2(this, this.we(), runOn(this, this.vf), this.wn(b), this.wo(b));
            let r = false;
            let s = this.vu.b;
            if (s != null) {
                r = true;
            }
            if (r) {
                let t = new ScalerParams(0, b.by, b.bx, this.yv.ch, e);
                this.w1(i, -1, this.valueColumn.count, this.yv, t, b.q);
            }
            let u = p.dk;
            let v = p.dl;
            let w = p.dj;
            this.vu.ad(u, true, false, true, false);
            this.vu.ad(v, true, false, true, false);
            this.vu.ad(w, false, true, false, false);
            w._opacity = 0.75 * this.vu.j;
            if (b.cy(a)) {
                p.df(j, k, false, 1, this.xd(k, j - 1, b.bx, b.by), q, this.hj);
                b.c1(a);
            }
        }
        get useHighMarkerFidelity() {
            return this.wi;
        }
    }
    StepLineSeries.$t = /*@__PURE__*/ markType(StepLineSeries, 'StepLineSeries', HorizontalAnchoredCategorySeries.$);
    return StepLineSeries;
})();
/**
 * @hidden
 */
export let StepLineSeriesView = /*@__PURE__*/ (() => {
    class StepLineSeriesView extends AnchoredCategorySeriesView {
        constructor(a) {
            super(a);
            this.dd = null;
            this.dn = new Path();
            this.dm = new Path();
            this.dp = new Path();
            this.di = new Path();
            this.dh = new Path();
            this.dg = new Path();
            this.dd = a;
        }
        au() {
            super.au();
            if (!this.q) {
                this.dd.ua = Defaults.c;
            }
        }
        get dk() {
            return this.dn;
        }
        get dl() {
            return this.dp;
        }
        get dj() {
            return this.dm;
        }
        de() {
            this.dm.an = null;
            this.dn.an = null;
            this.dp.an = null;
            this.as();
        }
        df(a, b, c, d, e, f, g) {
            this.dd.ze.a = typeCast(ISortingAxis_$type, this.cw.fetchXAxis()) !== null ? true : false;
            this.dd.ze.m(this.dn, this.dm, this.dp, a, b, c, d, e, f, g);
            this.as();
        }
        be() {
            super.be();
            this.dh.an = this.dn.an;
            this.di.an = this.dp.an;
            this.dg.an = this.dm.an;
            let a = this.br();
            this.dh._stroke = a;
            this.dh.ad = this.e.hk + 3;
            this.di._stroke = a;
            this.di.ad = this.e.hk + 3;
            this.dg._fill = a;
            this.dg._opacity = 1;
        }
        a8(a, b) {
            super.a8(a, b);
            if (a.d) {
                if (b) {
                    a.t(this.dg);
                    a.t(this.dh);
                    a.t(this.di);
                }
                else {
                    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", "Main"]);
            this.e.a9.exportPathData(a, this.dp, "upperShape", ["Upper"]);
            this.e.a9.exportPathData(a, this.dm, "translucentShape", ["Translucent"]);
        }
        af() {
            let a = new Color();
            a.colorString = "rgba(95,95,95,0.5)";
            this.e.s6 = a;
            this.e.ir = 3;
            this.e.is = 1;
            this.e.it = 4;
            this.e.gj = false;
        }
    }
    StepLineSeriesView.$t = /*@__PURE__*/ markType(StepLineSeriesView, 'StepLineSeriesView', AnchoredCategorySeriesView.$);
    return StepLineSeriesView;
})();
