/*
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 { ChartSelection } from "./ChartSelection";
import { intDivide, isNaN_ } from "igniteui-angular-core";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
import { Defaults } from "./Defaults";
import { Color } from "igniteui-angular-core";
/**
 * @hidden
 */
export let StepLineSeries = /*@__PURE__*/ (() => {
    class StepLineSeries extends HorizontalAnchoredCategorySeries {
        constructor() {
            super();
            this.acw = null;
            this.acw = new CategoryLineRasterizer();
            this.ab = StepLineSeries.$;
        }
        bj() {
            return new StepLineSeries();
        }
        get_fk() {
            return true;
        }
        get_f1() {
            return true;
        }
        get_fl() {
            return true;
        }
        cs() {
            return new StepLineSeriesView(this);
        }
        zo() {
            return true;
        }
        q1(a) {
            super.q1(a);
            this.acx = a;
        }
        ac() {
            super.ac();
        }
        preferredCategoryMode(a) {
            return typeCast(ISortingAxis_$type, a) !== null ? 0 : 1;
        }
        get_ev() {
            return true;
        }
        o5(a, b) {
            super.o5(a, b);
            let c = b;
            c.dg();
        }
        b2() {
            if (this.b3 == 0) {
                return 2;
            }
            else {
                return super.b2();
            }
        }
        iv(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;
        }
        acy(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);
        }
        aak(a, b) {
            super.aak(a, b);
            let c = b.by;
            let d = b.bx;
            let e = this.getEffectiveViewport1(b);
            let f = typeCast(ISortingAxis_$type, this.acd) != null;
            let g = this.acd.ch;
            let h = 0;
            if (this.acd != null) {
                h = 0.5 * this.acd.getCategorySize(c, d, e);
            }
            let i = a.f;
            let j = 2 * i.count;
            let k = new List$1(Array_$type, 2, j);
            if (!this.acd.ch) {
                for (let l = 0; l < j; l++) {
                    let m = new Array(4);
                    m[0] = this.acy(l, false, a, h, g, f);
                    m[1] = a.f._inner[(intDivide(l, 2))][1];
                    m[2] = this.acy(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.acy(n, true, a, h, g, f);
                    o[1] = a.f._inner[(intDivide(n, 2))][1];
                    o[2] = this.acy(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.cw.d;
            this.y2.a2(this, this.zm(), runOn(this, this.ym), this.zv(b), this.zw(b));
            let r = false;
            let s = this.y2.b;
            if (s != null) {
                r = true;
            }
            if (r) {
                let t = new ScalerParams(0, b.by, b.bx, this.acd.ch, e);
                this.aag(i, -1, this.valueColumn.count, this.acd, t, b.q, -1);
            }
            let u = p.dm;
            let v = p.dn;
            let w = p.dl;
            this.y2.ad(u, true, false, true, false);
            this.y2.ad(v, true, false, true, false);
            this.y2.ad(w, false, true, false, false);
            w._opacity = 0.75 * this.y2.j;
            if (b.c0(a)) {
                p.dh(j, k, false, 1, this.aat(k, j - 1, b.bx, b.by), q, this.id);
                b.c3(a);
            }
        }
        p4(a, b, c) {
            this.aac(a, b, c, this.yt, 0);
        }
        ak(a, b) {
            let c = new List$1(ChartSelection.$, 0);
            this.p4(a, c, b);
            return c.toArray();
        }
        get useHighMarkerFidelity() {
            return this.zq;
        }
    }
    StepLineSeries.$t = markType(StepLineSeries, 'StepLineSeries', HorizontalAnchoredCategorySeries.$);
    return StepLineSeries;
})();
/**
 * @hidden
 */
export let StepLineSeriesView = /*@__PURE__*/ (() => {
    class StepLineSeriesView extends AnchoredCategorySeriesView {
        constructor(a) {
            super(a);
            this.df = null;
            this.dq = new Path();
            this.dp = new Path();
            this.dr = new Path();
            this.dk = new Path();
            this.dj = new Path();
            this.di = new Path();
            this.df = a;
        }
        au() {
            super.au();
            if (!this.q) {
                this.df.xa = Defaults.c;
            }
        }
        get dm() {
            return this.dq;
        }
        get dn() {
            return this.dr;
        }
        get dl() {
            return this.dp;
        }
        dg() {
            this.dp.an = null;
            this.dq.an = null;
            this.dr.an = null;
            this.as();
        }
        dh(a, b, c, d, e, f, g) {
            this.df.acw.a = typeCast(ISortingAxis_$type, this.cy.fetchXAxis()) !== null ? true : false;
            this.df.acw.m(this.dq, this.dp, this.dr, a, b, c, d, e, f, g);
            this.as();
        }
        be() {
            super.be();
            this.dj.an = this.dq.an;
            this.dk.an = this.dr.an;
            this.di.an = this.dp.an;
            let a = this.br();
            this.dj._stroke = a;
            this.dj.ad = this.e.ie + 3;
            this.dk._stroke = a;
            this.dk.ad = this.e.ie + 3;
            this.di._fill = a;
            this.di._opacity = 1;
        }
        a8(a, b) {
            super.a8(a, b);
            if (a.d) {
                if (b) {
                    a.t(this.di);
                    a.t(this.dj);
                    a.t(this.dk);
                }
                else {
                    a.t(this.dp);
                    a.t(this.dq);
                    a.t(this.dr);
                }
            }
        }
        an(a) {
            super.an(a);
            this.e.bc.exportPathData(a, this.dq, "lowerShape", ["Lower", "Main"]);
            this.e.bc.exportPathData(a, this.dr, "upperShape", ["Upper"]);
            this.e.bc.exportPathData(a, this.dp, "translucentShape", ["Translucent"]);
        }
        af() {
            let a = new Color();
            a.colorString = "rgba(95,95,95,0.5)";
            this.e.v1 = a;
            this.e.jm = 3;
            this.e.jn = 1;
            this.e.jo = 4;
            this.e.hc = false;
        }
    }
    StepLineSeriesView.$t = markType(StepLineSeriesView, 'StepLineSeriesView', AnchoredCategorySeriesView.$);
    return StepLineSeriesView;
})();
