/*
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 * as tslib_1 from "tslib";
import { HorizontalAnchoredCategorySeries } from "./HorizontalAnchoredCategorySeries";
import { IIsCategoryBased_$type } from "./IIsCategoryBased";
import { CategoryLineRasterizer } from "./CategoryLineRasterizer";
import { typeCast, Array_$type, runOn, markType } from "igniteui-react-core/ES5/type";
import { ISortingAxis_$type } from "./ISortingAxis";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { Path } from "igniteui-react-core/ES5/Path";
import { ScalerParams } from "./ScalerParams";
import { intDivide, isNaN_ } from "igniteui-react-core/ES5/number";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
import { Color } from "igniteui-react-core/ES5/Color";
/**
 * @hidden
 */
var StepLineSeries = /** @class */ (function (_super) {
    tslib_1.__extends(StepLineSeries, _super);
    function StepLineSeries() {
        var _this = _super.call(this) || this;
        _this.qa = null;
        _this.qa = new CategoryLineRasterizer();
        _this.ab = StepLineSeries.$;
        return _this;
    }
    StepLineSeries.prototype.bf = function () {
        return new StepLineSeriesView(this);
    };
    StepLineSeries.prototype.getHostReferenceValue = function () {
        return this.ee();
    };
    StepLineSeries.prototype.im = function (a) {
        _super.prototype.im.call(this, a);
        this.qb = a;
    };
    StepLineSeries.prototype.ac = function () {
        _super.prototype.ac.call(this);
    };
    StepLineSeries.prototype.preferredCategoryMode = function (a) {
        return typeCast(ISortingAxis_$type, a) !== null ? 0 : 1;
    };
    StepLineSeries.prototype.get_ck = function () {
        return true;
    };
    StepLineSeries.prototype.hp = function (a, b) {
        _super.prototype.hp.call(this, a, b);
        var c = b;
        c.c7();
    };
    StepLineSeries.prototype.bd = function () {
        if (this.be == 0) {
            return 2;
        }
        else {
            return _super.prototype.bd.call(this);
        }
    };
    StepLineSeries.prototype.ec = function (a, b, c, d, e, f, g, h) {
        var i = NaN;
        if (c >= 0 && c < b.count) {
            i = b.item(c);
        }
        var 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;
    };
    StepLineSeries.prototype.qc = function (a, b, c, d, e, f) {
        var 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);
    };
    StepLineSeries.prototype.oh = function (a, b) {
        _super.prototype.oh.call(this, a, b);
        var c = b.bs;
        var d = b.br;
        var e = this.getEffectiveViewport1(b);
        var f = typeCast(ISortingAxis_$type, this.pr) != null;
        var g = this.pr.b8;
        var h = 0;
        if (this.pr != null) {
            h = 0.5 * this.pr.getCategorySize(c, d, e);
        }
        var i = a.f;
        var j = 2 * i.count;
        var k = new List$1(Array_$type, 2, j);
        if (!this.pr.b8) {
            for (var l = 0; l < j; l++) {
                var m = new Array(4);
                m[0] = this.qc(l, false, a, h, g, f);
                m[1] = a.f._inner[(intDivide(l, 2))][1];
                m[2] = this.qc(l, true, a, h, g, f);
                m[3] = a.f._inner[(intDivide(l, 2))][2];
                k.add(m);
            }
        }
        else {
            for (var n = 0; n < j; n++) {
                var o = new Array(4);
                o[0] = this.qc(n, true, a, h, g, f);
                o[1] = a.f._inner[(intDivide(n, 2))][1];
                o[2] = this.qc(n, true, a, h, g, f);
                o[3] = a.f._inner[(intDivide(n, 2))][2];
                k.add(o);
            }
        }
        var p = typeCast(StepLineSeriesView.$, b);
        var q = p.cn.d;
        this.m7.x(this, this.ns(), this.pr, runOn(this, this.mt), this.n0(b), this.n1(b));
        var r = false;
        var s = this.m7.c;
        if (s != null) {
            r = true;
        }
        if (r) {
            var t = new ScalerParams(0, b.bs, b.br, this.pr.b8, e);
            this.od(i, -1, this.valueColumn.count, this.pr, t, b.n);
        }
        var u = p.dd;
        var v = p.de;
        var w = p.dc;
        this.m7.ae(u, true, false, true, false);
        this.m7.ae(v, true, false, true, false);
        this.m7.ae(w, false, true, false, false);
        w._opacity = 0.75 * this.m7.i;
        if (b.cr(a)) {
            p.c8(j, k, false, 1, this.op(k, j - 1, b.br, b.bs), q, this.er);
            b.cu(a);
        }
    };
    Object.defineProperty(StepLineSeries.prototype, "currentCategoryMode", {
        get: function () {
            return this.preferredCategoryMode(this.pr);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(StepLineSeries.prototype, "useHighMarkerFidelity", {
        get: function () {
            return this.nv;
        },
        enumerable: true,
        configurable: true
    });
    StepLineSeries.$t = markType(StepLineSeries, 'StepLineSeries', HorizontalAnchoredCategorySeries.$, [IIsCategoryBased_$type]);
    return StepLineSeries;
}(HorizontalAnchoredCategorySeries));
export { StepLineSeries };
/**
 * @hidden
 */
var StepLineSeriesView = /** @class */ (function (_super) {
    tslib_1.__extends(StepLineSeriesView, _super);
    function StepLineSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.c6 = null;
        _this.dg = new Path();
        _this.df = new Path();
        _this.dh = new Path();
        _this.db = new Path();
        _this.da = new Path();
        _this.c9 = new Path();
        _this.c6 = a;
        return _this;
    }
    Object.defineProperty(StepLineSeriesView.prototype, "dd", {
        get: function () {
            return this.dg;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(StepLineSeriesView.prototype, "de", {
        get: function () {
            return this.dh;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(StepLineSeriesView.prototype, "dc", {
        get: function () {
            return this.df;
        },
        enumerable: true,
        configurable: true
    });
    StepLineSeriesView.prototype.c7 = function () {
        this.df.aj = null;
        this.dg.aj = null;
        this.dh.aj = null;
        this.an();
    };
    StepLineSeriesView.prototype.c8 = function (a, b, c, d, e, f, g) {
        this.c6.qa.a = typeCast(ISortingAxis_$type, this.cp.fetchXAxis()) !== null ? true : false;
        this.c6.qa.m(this.dg, this.df, this.dh, a, b, c, d, e, f, g);
        this.an();
    };
    StepLineSeriesView.prototype.a9 = function () {
        _super.prototype.a9.call(this);
        this.da.aj = this.dg.aj;
        this.db.aj = this.dh.aj;
        this.c9.aj = this.df.aj;
        var a = this.bl();
        this.da._stroke = a;
        this.da.ac = this.e.ev + 3;
        this.db._stroke = a;
        this.db.ac = this.e.ev + 3;
        this.c9._fill = a;
        this.c9._opacity = 1;
    };
    StepLineSeriesView.prototype.a3 = function (a, b) {
        _super.prototype.a3.call(this, a, b);
        if (a.d) {
            if (b) {
                a.s(this.c9);
                a.s(this.da);
                a.s(this.db);
            }
            else {
                a.s(this.df);
                a.s(this.dg);
                a.s(this.dh);
            }
        }
    };
    StepLineSeriesView.prototype.ai = function (a) {
        _super.prototype.ai.call(this, a);
        this.e.a2.exportPathData(a, this.dg, "lowerShape", ["Lower", "Main"]);
        this.e.a2.exportPathData(a, this.dh, "upperShape", ["Upper"]);
        this.e.a2.exportPathData(a, this.df, "translucentShape", ["Translucent"]);
    };
    StepLineSeriesView.prototype.ac = function () {
        var a = new Color();
        a.colorString = "rgba(95,95,95,0.5)";
        this.e.k3 = a;
        this.e.es = 3;
        this.e.et = 1;
        this.e.eu = 4;
        this.e.dt = false;
    };
    StepLineSeriesView.$t = markType(StepLineSeriesView, 'StepLineSeriesView', AnchoredCategorySeriesView.$);
    return StepLineSeriesView;
}(AnchoredCategorySeriesView));
export { StepLineSeriesView };
