/*
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 { __extends } from "tslib";
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
 */
var StepLineSeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(StepLineSeries, _super);
    function StepLineSeries() {
        var _this = _super.call(this) || this;
        _this.ac8 = null;
        _this.ac8 = new CategoryLineRasterizer();
        _this.ab = StepLineSeries.$;
        return _this;
    }
    StepLineSeries.prototype.bk = function () {
        return new StepLineSeries();
    };
    StepLineSeries.prototype.get_fl = function () {
        return true;
    };
    StepLineSeries.prototype.get_f2 = function () {
        return true;
    };
    StepLineSeries.prototype.get_fm = function () {
        return true;
    };
    StepLineSeries.prototype.ct = function () {
        return new StepLineSeriesView(this);
    };
    StepLineSeries.prototype.zy = function () {
        return true;
    };
    StepLineSeries.prototype.q7 = function (a) {
        _super.prototype.q7.call(this, a);
        this.ac9 = 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_ex = function () {
        return true;
    };
    StepLineSeries.prototype.pb = function (a, b) {
        _super.prototype.pb.call(this, a, b);
        var c = b;
        c.du();
    };
    StepLineSeries.prototype.b3 = function () {
        if (this.b4 == 0) {
            return 2;
        }
        else {
            return _super.prototype.b3.call(this);
        }
    };
    StepLineSeries.prototype.ix = 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.ada = 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.h._inner[(intDivide(a, 2))][0];
                }
                if (c.h.count == (intDivide(a, 2)) + 1) {
                    return c.h._inner[(intDivide(a, 2))][0];
                }
                return c.h._inner[(intDivide(a, 2)) + 1][0];
            }
            g = (a & 1) == 0;
            return c.h._inner[(intDivide(a, 2))][0] + (g ? d : -d);
        }
        if (f) {
            g = (a & 1) == 0;
            if (g || ((intDivide(a, 2)) + 1) >= c.h.count) {
                return c.h._inner[(intDivide(a, 2))][0];
            }
            if (c.h.count == (intDivide(a, 2)) + 1) {
                return c.h._inner[(intDivide(a, 2))][0];
            }
            return c.h._inner[(intDivide(a, 2)) + 1][0];
        }
        g = (a & 1) == 0;
        return c.h._inner[(intDivide(a, 2))][0] + (g ? -d : d);
    };
    StepLineSeries.prototype.aax = function (a, b) {
        _super.prototype.aax.call(this, a, b);
        var c = b.ca;
        var d = b.b9;
        var e = this.getEffectiveViewport1(b);
        var f = typeCast(ISortingAxis_$type, this.acp) != null;
        var g = this.acp.df;
        var h = 0;
        if (this.acp != null) {
            h = 0.5 * this.acp.getCategorySize(c, d, e);
        }
        var i = a.h;
        var j = 2 * i.count;
        var k = new List$1(Array_$type, 2, j);
        if (!this.acp.df) {
            for (var l = 0; l < j; l++) {
                var m = new Array(4);
                m[0] = this.ada(l, false, a, h, g, f);
                m[1] = a.h._inner[(intDivide(l, 2))][1];
                m[2] = this.ada(l, true, a, h, g, f);
                m[3] = a.h._inner[(intDivide(l, 2))][2];
                k.add(m);
            }
        }
        else {
            for (var n = 0; n < j; n++) {
                var o = new Array(4);
                o[0] = this.ada(n, true, a, h, g, f);
                o[1] = a.h._inner[(intDivide(n, 2))][1];
                o[2] = this.ada(n, true, a, h, g, f);
                o[3] = a.h._inner[(intDivide(n, 2))][2];
                k.add(o);
            }
        }
        var p = typeCast(StepLineSeriesView.$, b);
        var q = p.c9.d;
        this.zc.a2(this, this.zw(), runOn(this, this.yw), this.z5(b), this.z6(b));
        var r = false;
        var s = this.zc.b;
        if (s != null) {
            r = true;
        }
        if (r) {
            var t = new ScalerParams(0, b.ca, b.b9, this.acp.df, e);
            this.aat(i, -1, this.valueColumn.count, this.acp, t, b.t, -1);
        }
        var u = p.d0;
        var v = p.d1;
        var w = p.dz;
        this.zc.ad(u, true, false, true, false);
        this.zc.ad(v, true, false, true, false);
        this.zc.ad(w, false, true, false, false);
        w._opacity = 0.75 * this.zc.j;
        if (b.dd(a)) {
            p.dv(j, k, false, 1, this.aa5(k, j - 1, b.b9, b.ca), q, this.ie);
            b.dg(a);
        }
    };
    StepLineSeries.prototype.qa = function (a, b, c) {
        this.aap(a, b, c, this.y3, 0);
    };
    StepLineSeries.prototype.ak = function (a, b) {
        var c = new List$1(ChartSelection.$, 0);
        this.qa(a, c, b);
        return c.toArray();
    };
    Object.defineProperty(StepLineSeries.prototype, "useHighMarkerFidelity", {
        get: function () {
            return this.z0;
        },
        enumerable: false,
        configurable: true
    });
    StepLineSeries.$t = markType(StepLineSeries, 'StepLineSeries', HorizontalAnchoredCategorySeries.$);
    return StepLineSeries;
}(HorizontalAnchoredCategorySeries));
export { StepLineSeries };
/**
 * @hidden
 */
var StepLineSeriesView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(StepLineSeriesView, _super);
    function StepLineSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.dt = null;
        _this.d3 = new Path();
        _this.d2 = new Path();
        _this.d4 = new Path();
        _this.dy = new Path();
        _this.dx = new Path();
        _this.dw = new Path();
        _this.dt = a;
        return _this;
    }
    StepLineSeriesView.prototype.a4 = function () {
        _super.prototype.a4.call(this);
        if (!this.t) {
            this.dt.xk = Defaults.c;
        }
    };
    Object.defineProperty(StepLineSeriesView.prototype, "d0", {
        get: function () {
            return this.d3;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(StepLineSeriesView.prototype, "d1", {
        get: function () {
            return this.d4;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(StepLineSeriesView.prototype, "dz", {
        get: function () {
            return this.d2;
        },
        enumerable: false,
        configurable: true
    });
    StepLineSeriesView.prototype.du = function () {
        this.d2.an = null;
        this.d3.an = null;
        this.d4.an = null;
        this.a2();
    };
    StepLineSeriesView.prototype.dv = function (a, b, c, d, e, f, g) {
        this.dt.ac8.a = typeCast(ISortingAxis_$type, this.db.fetchXAxis()) !== null ? true : false;
        this.dt.ac8.m(this.d3, this.d2, this.d4, a, b, c, d, e, f, g);
        this.a2();
    };
    StepLineSeriesView.prototype.bq = function () {
        _super.prototype.bq.call(this);
        this.dx.an = this.d3.an;
        this.dy.an = this.d4.an;
        this.dw.an = this.d2.an;
        var a = this.b3();
        this.dx._stroke = a;
        this.dx.ad = this.f.ig + 3;
        this.dy._stroke = a;
        this.dy.ad = this.f.ig + 3;
        this.dw._fill = a;
        this.dw._opacity = 1;
    };
    StepLineSeriesView.prototype.bj = function (a, b) {
        _super.prototype.bj.call(this, a, b);
        if (a.d) {
            if (b) {
                a.t(this.dw);
                a.t(this.dx);
                a.t(this.dy);
            }
            else {
                a.t(this.d2);
                a.t(this.d3);
                a.t(this.d4);
            }
        }
    };
    StepLineSeriesView.prototype.ax = function (a) {
        _super.prototype.ax.call(this, a);
        this.f.bc.exportPathData(a, this.d3, "lowerShape", ["Lower", "Main"]);
        this.f.bc.exportPathData(a, this.d4, "upperShape", ["Upper"]);
        this.f.bc.exportPathData(a, this.d2, "translucentShape", ["Translucent"]);
    };
    StepLineSeriesView.prototype.an = function () {
        var a = new Color();
        a.colorString = "rgba(95,95,95,0.5)";
        this.f.wb = a;
        this.f.jq = 3;
        this.f.jr = 1;
        this.f.js = 4;
        this.f.hd = false;
    };
    StepLineSeriesView.$t = markType(StepLineSeriesView, 'StepLineSeriesView', AnchoredCategorySeriesView.$);
    return StepLineSeriesView;
}(AnchoredCategorySeriesView));
export { StepLineSeriesView };
