/*
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 { CategoryFramePreparerBase } from "./CategoryFramePreparerBase";
import { IHasCategoryTrendline_$type } from "./IHasCategoryTrendline";
import { IHasHighLowValueCategory_$type } from "./IHasHighLowValueCategory";
import { ISupportsMarkers_$type } from "./ISupportsMarkers";
import { IProvidesViewport_$type } from "./IProvidesViewport";
import { ISupportsErrorBars_$type } from "./ISupportsErrorBars";
import { IBucketizer_$type } from "./IBucketizer";
import { DefaultCategoryTrendlineHost } from "./DefaultCategoryTrendlineHost";
import { DefaultHighLowValueProvider } from "./DefaultHighLowValueProvider";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { typeCast, Point_$type, Number_$type, markType } from "igniteui-react-core/ES5/type";
import { HighLowValuesHolder } from "./HighLowValuesHolder";
import { isNaN_ } from "igniteui-react-core/ES5/number";
/**
 * @hidden
 */
var RangeCategoryFramePreparer = /** @class */ (function (_super) {
    tslib_1.__extends(RangeCategoryFramePreparer, _super);
    function RangeCategoryFramePreparer(a) {
        var _rest = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            _rest[_i - 1] = arguments[_i];
        }
        var _this = this;
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0:
                {
                    var c = _rest[0];
                    var d = [c, typeCast(ISupportsMarkers_$type, c), typeCast(IProvidesViewport_$type, c), typeCast(ISupportsErrorBars_$type, c), typeCast(IBucketizer_$type, c)];
                    {
                        var f = d[0];
                        var g = d[1];
                        var h = d[2];
                        var i = d[3];
                        var j = d[4];
                        _this = _super.call(this, 1, f, g, h, i, j) || this;
                        _this.aa = null;
                        _this.ab = null;
                        _this.aa = new DefaultCategoryTrendlineHost();
                        if (typeCast(IHasCategoryTrendline_$type, f) !== null) {
                            _this.aa = typeCast(IHasCategoryTrendline_$type, f);
                        }
                        _this.ab = new DefaultHighLowValueProvider();
                        if (typeCast(IHasHighLowValueCategory_$type, f) !== null) {
                            _this.ab = typeCast(IHasHighLowValueCategory_$type, f);
                        }
                    }
                }
                break;
            case 1:
                {
                    var c = _rest[0];
                    var d = _rest[1];
                    var e = _rest[2];
                    var f = _rest[3];
                    var g = _rest[4];
                    _this = _super.call(this, 1, c, d, e, f, g) || this;
                    _this.aa = null;
                    _this.ab = null;
                    _this.aa = new DefaultCategoryTrendlineHost();
                    if (typeCast(IHasCategoryTrendline_$type, c) !== null) {
                        _this.aa = typeCast(IHasCategoryTrendline_$type, c);
                    }
                    _this.ab = new DefaultHighLowValueProvider();
                    if (typeCast(IHasHighLowValueCategory_$type, c) !== null) {
                        _this.ab = typeCast(IHasHighLowValueCategory_$type, c);
                    }
                }
                break;
        }
        return _this;
    }
    RangeCategoryFramePreparer.prototype.l = function (a, b, c, d, e, f) {
        var g = b[0];
        var h = b[1];
        var i = b[2];
        if (!isNaN_(g) && !isNaN_(h) && !isNaN_(i)) {
            a.m.add({ $type: Point_$type, x: g, y: (h + i) / 2 });
            this.c.updateMarkerTemplate(e, d, f);
            return true;
        }
        return false;
    };
    RangeCategoryFramePreparer.prototype.z = function (a, b, c, d) {
        var e = a;
        var f = e.f;
        var g = e.g;
        var h = f.item(b);
        var i = g.item(b);
        var j = Math.max(h, i);
        var k = Math.min(h, i);
        if (c) {
            e.c = k;
            e.d = j;
        }
        else {
            e.b = j;
            e.a = k;
        }
    };
    RangeCategoryFramePreparer.prototype.u = function (a, b, c) {
        var d = a;
        var e = d.f;
        var f = d.g;
        var g = e.item(b);
        var h = f.item(b);
        if (!isNaN_(g)) {
            d.b = Math.max(d.b, g);
            d.a = Math.min(d.a, g);
        }
        if (!isNaN_(h)) {
            d.b = Math.max(d.b, h);
            d.a = Math.min(d.a, h);
        }
    };
    RangeCategoryFramePreparer.prototype.e = function (a, b) {
        var c = b;
        return [a, c.a, c.b];
    };
    RangeCategoryFramePreparer.prototype.x = function (a, b, c, d, e, f) {
        if (d) {
            b[0] = b[0] + c;
        }
        else {
            b[0] = a.b.j$b(b[0], e) + c;
        }
        b[1] = a.c.j$b(b[1], f);
        b[2] = a.c.j$b(b[2], f);
    };
    RangeCategoryFramePreparer.prototype.y = function (a, b, c, d, e, f, g) {
        _super.prototype.y.call(this, a, b, c, d, e, f, g);
        var h = a.h;
        var i = a.a.f.count;
        var j = a.a.f;
        var k = this.q;
        var l = k.count;
        var m = new List$1(Number_$type, 0);
        if (!c) {
            m.add(0);
        }
        var n = new List$1(Number_$type, 0);
        n.add(1);
        n.add(2);
        a.b.j$d(j, m, 0, i, d);
        a.c.j$d(j, n, 0, i, e);
        for (var o = 0; o < i; o++) {
            j._inner[o][0] = j._inner[o][0] + b;
        }
        if (g) {
            a.b.j$d(k, m, 0, l, d);
            a.c.j$d(k, n, 0, l, e);
            for (var p = 0; p < l; p++) {
                k._inner[p][0] = k._inner[p][0] + b;
            }
        }
    };
    RangeCategoryFramePreparer.prototype.j = function (a) {
        var b = new HighLowValuesHolder();
        b.f = this.ab.highColumn;
        b.g = this.ab.lowColumn;
        return b;
    };
    RangeCategoryFramePreparer.$t = markType(RangeCategoryFramePreparer, 'RangeCategoryFramePreparer', CategoryFramePreparerBase.$);
    return RangeCategoryFramePreparer;
}(CategoryFramePreparerBase));
export { RangeCategoryFramePreparer };
