/*
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 { Snapper } from "./Snapper";
import { markType } from "igniteui-angular-core";
import { truncate, isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
var LinearCategorySnapper = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(LinearCategorySnapper, _super);
    function LinearCategorySnapper(a) {
        var _rest = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            _rest[_i - 1] = arguments[_i];
        }
        var _this = _super.call(this) || this;
        _this.g = 0;
        _this.h = 0;
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0:
                {
                    var c = _rest[0];
                    var d = _rest[1];
                    var e = _rest[2];
                    var f = _rest[3];
                    var g = [c, d, e, NaN, 0, f];
                    {
                        var i = g[0];
                        var j = g[1];
                        var k = g[2];
                        var l = g[3];
                        var m = g[4];
                        var n = g[5];
                        if (n > 0) {
                            _this.f = n;
                            _this.b = true;
                        }
                        _this.g = l;
                        _this.h = 0;
                        var o = Math.min(10, truncate((k / _this.f)));
                        if (o > 0) {
                            var p = _this.i(i, j, o);
                            if (_this.b && p > o) {
                                _this.g = l;
                                p = _this.i(i, j, o - 1);
                            }
                            o = p;
                            if (k / o > _this.f * 10) {
                                _this.h = 10;
                            }
                            else {
                                if (k / o > _this.f * 5) {
                                    _this.h = 5;
                                }
                                else {
                                    if (k / o > _this.f * 2) {
                                        _this.h = 2;
                                    }
                                }
                            }
                        }
                    }
                }
                break;
            case 1:
                {
                    var c = _rest[0];
                    var d = _rest[1];
                    var e = _rest[2];
                    var f = _rest[3];
                    var g = _rest[4];
                    var h = _rest[5];
                    if (h > 0) {
                        _this.f = h;
                        _this.b = true;
                    }
                    _this.g = f;
                    _this.h = 0;
                    var i = Math.min(10, truncate((e / _this.f)));
                    if (i > 0) {
                        var j = _this.i(c, d, i);
                        if (_this.b && j > i) {
                            _this.g = f;
                            j = _this.i(c, d, i - 1);
                        }
                        i = j;
                        if (e / i > _this.f * 10) {
                            _this.h = 10;
                        }
                        else {
                            if (e / i > _this.f * 5) {
                                _this.h = 5;
                            }
                            else {
                                if (e / i > _this.f * 2) {
                                    _this.h = 2;
                                }
                            }
                        }
                    }
                }
                break;
        }
        return _this;
    }
    LinearCategorySnapper.prototype.i = function (a, b, c) {
        var d = Snapper.e(b - a, false);
        if (isNaN_(this.g)) {
            var e = Math.max(c - 1, 1);
            this.g = Snapper.e(d / e, true);
        }
        if (this.g < 1) {
            this.g = 1;
        }
        var f = Math.floor(a / this.g) * this.g;
        var g = Math.ceil(b / this.g) * this.g;
        var h = truncate(Math.round((g - f) / this.g));
        return h;
    };
    LinearCategorySnapper.$t = markType(LinearCategorySnapper, 'LinearCategorySnapper', Snapper.$);
    return LinearCategorySnapper;
}(Snapper));
export { LinearCategorySnapper };
