/*
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 { Base, markType } from "igniteui-react-core/ES5/type";
import { truncate } from "igniteui-react-core/ES5/number";
import { dateAddSeconds, dateFromValues, dateGetMonth, dateAddMinutes, dateAddHours, dateAddDays, dateMaxValue, dateAddMonths, dateAddYears } from "igniteui-react-core/ES5/date";
import { timeSpanFromTicks, timeSpanFromMilliseconds, timeSpanFromSeconds, timeSpanFromMinutes, timeSpanFromHours, timeSpanFromDays } from "igniteui-react-core/ES5/timespan";
var TimeAxisInterval = /** @class */ (function (_super) {
    tslib_1.__extends(TimeAxisInterval, _super);
    function TimeAxisInterval() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.e = 0;
        _this.d = 0;
        _this.a = 0;
        return _this;
    }
    TimeAxisInterval.prototype.c = function (a) {
        var b;
        switch (this.a) {
            case 0:
                var c = 10000;
                return dateAddSeconds(a, 1 / c);
            case 1:
                b = dateAddSeconds(a, 1 / 1000);
                return dateFromValues(b.getFullYear(), dateGetMonth(b), b.getDate(), b.getHours(), b.getMinutes(), b.getSeconds(), b.getMilliseconds());
            case 2:
                b = dateAddSeconds(a, 1);
                return dateFromValues(b.getFullYear(), dateGetMonth(b), b.getDate(), b.getHours(), b.getMinutes(), b.getSeconds(), 0);
            case 3:
                b = dateAddMinutes(a, 1);
                return dateFromValues(b.getFullYear(), dateGetMonth(b), b.getDate(), b.getHours(), b.getMinutes(), 0, 0);
            case 4:
            case 5:
                b = dateAddHours(a, 1);
                return dateFromValues(b.getFullYear(), dateGetMonth(b), b.getDate(), b.getHours(), 0, 0, 0);
            case 6:
            case 7:
            case 8:
                b = dateAddDays(a, 1);
                return dateFromValues(b.getFullYear(), dateGetMonth(b), b.getDate(), 0, 0, 0, 0);
            default: return a;
        }
    };
    TimeAxisInterval.prototype.b = function (a) {
        var b = +(dateMaxValue()) - +a;
        switch (this.a) {
            case 0:
                var c = 10000;
                if (b > timeSpanFromTicks(truncate(this.d))) {
                    return dateAddSeconds(a, this.d / c);
                }
                return dateMaxValue();
            case 1:
                if (b > timeSpanFromMilliseconds(this.d)) {
                    return dateAddSeconds(a, this.d / 1000);
                }
                return dateMaxValue();
            case 2:
                if (b > timeSpanFromSeconds(this.d)) {
                    return dateAddSeconds(a, this.d);
                }
                return dateMaxValue();
            case 3:
                if (b > timeSpanFromMinutes(this.d)) {
                    return dateAddMinutes(a, this.d);
                }
                return dateMaxValue();
            case 4:
                if (b > timeSpanFromHours(this.d)) {
                    return dateAddHours(a, this.d);
                }
                return dateMaxValue();
            case 5:
                if (b > timeSpanFromDays(this.d)) {
                    return dateAddDays(a, this.d);
                }
                return dateMaxValue();
            case 6:
                if (b > timeSpanFromDays(7 * this.d)) {
                    return dateAddDays(a, this.d * 7);
                }
                return dateMaxValue();
            case 7:
                if (b > timeSpanFromDays(31 * truncate(this.d))) {
                    return dateAddMonths(a, truncate(this.d));
                }
                return dateMaxValue();
            case 8:
                if (b > timeSpanFromDays(365 * truncate(this.d))) {
                    return dateAddYears(a, truncate(this.d));
                }
                return dateMaxValue();
            default: return a;
        }
    };
    TimeAxisInterval.$t = markType(TimeAxisInterval, 'TimeAxisInterval');
    return TimeAxisInterval;
}(Base));
export { TimeAxisInterval };
