/*
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 { TickmarkValues } from "./TickmarkValues";
import { LinearNumericSnapper } from "./LinearNumericSnapper";
import { markType } from "igniteui-react-core";
import { truncate, isNaN_ } from "igniteui-react-core";
/**
 * @hidden
 */
var LinearTickmarkValues = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(LinearTickmarkValues, _super);
    function LinearTickmarkValues() {
        var _this = _super.call(this) || this;
        _this.y = 0;
        _this.x = 0;
        _this.t = null;
        _this.u = null;
        _this.y = 0;
        return _this;
    }
    LinearTickmarkValues.prototype.s = function (a) {
        _super.prototype.s.call(this, a);
        var b;
        if (this.y != 0) {
            b = new LinearNumericSnapper(1, a.n, a.m, a.k, this.y, a.h);
        }
        else {
            b = new LinearNumericSnapper(0, a.n, a.m, a.k, a.h);
        }
        this.m = b.g;
        if ((a.d) && a.l > 0 && (a.m - a.n) / a.l < 1000) {
            this.m = a.l;
        }
        if (a.i != -1) {
            this.m = a.i;
        }
        if (this.m == 0) {
            this.p = 0;
            this.q = 0;
        }
        else {
            this.p = truncate(Math.floor((a.n - a.g) / this.m));
            this.q = truncate(Math.ceil((a.m - a.g) / this.m));
        }
        this.r = b.i;
        if (a.p != -1) {
            this.r = a.p;
        }
        this.n = a.j;
        this.x = a.g;
    };
    LinearTickmarkValues.prototype.j = function () {
        var a = 0;
        var b = this.p;
        if (!isNaN_(this.m)) {
            a = this.q - b + 1;
            if (a < 0) {
                a = 0;
            }
        }
        if (this.t == null || this.t.length != a) {
            this.t = new Array(a);
        }
        var c = this.t;
        for (var d = 0; d < a; ++d) {
            var e = this.x + (d + b) * this.m;
            c[d] = e;
        }
        return c;
    };
    LinearTickmarkValues.prototype.k = function () {
        if (this.n > 0) {
            return this.w();
        }
        return this.v();
    };
    LinearTickmarkValues.prototype.v = function () {
        var a = this.p;
        var b = this.q;
        var c = this.r;
        var d = this.m;
        var e = this.x;
        var f = this.o;
        var g = d / c;
        var h = 0;
        for (var i = a; i < b; ++i) {
            if (c > 0) {
                for (var j = 1; j < c; ++j) {
                    var k = e + i * d + (j * g);
                    if (k <= f) {
                        h++;
                    }
                }
            }
        }
        if (this.u == null || this.u.length != h) {
            this.u = new Array(h);
        }
        var l = this.u;
        var m = 0;
        for (var n = a; n < b; ++n) {
            if (c > 0) {
                for (var o = 1; o < c; ++o) {
                    var p = e + n * d + (o * g);
                    if (p <= this.o) {
                        l[m] = p;
                        m++;
                    }
                }
            }
        }
        return l;
    };
    LinearTickmarkValues.prototype.w = function () {
        var a = this.p;
        var b = this.q;
        var c = this.r;
        var d = this.m;
        var e = this.x;
        var f = this.o;
        var g = d / c;
        var h = 0;
        for (var i = a; i < b; ++i) {
            var j = e + i * this.m;
            var k = this.o;
            if (i + 1 <= this.q) {
                k = this.x + ((i + 1) * this.m);
            }
            if (k > this.o) {
                k = this.o;
            }
            while (j < k) {
                j += this.n;
                if (j < k) {
                    h++;
                }
            }
        }
        if (this.u == null || this.u.length != h) {
            this.u = new Array(h);
        }
        var l = this.u;
        var m = 0;
        for (var n = a; n < b; ++n) {
            var o = e + n * this.m;
            var p = this.o;
            if (n + 1 <= this.q) {
                p = this.x + ((n + 1) * this.m);
            }
            if (p > this.o) {
                p = this.o;
            }
            while (o < p) {
                o += this.n;
                if (o < p) {
                    l[m] = o;
                    m++;
                }
            }
        }
        return l;
    };
    LinearTickmarkValues.$t = markType(LinearTickmarkValues, 'LinearTickmarkValues', TickmarkValues.$);
    return LinearTickmarkValues;
}(TickmarkValues));
export { LinearTickmarkValues };
//# sourceMappingURL=LinearTickmarkValues.js.map
