/*
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 { BuiltInFunctionBase } from "./BuiltInFunctionBase";
import { ExcelCalcValue } from "./ExcelCalcValue";
import { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { markType } from "igniteui-angular-core";
import { intDivide } from "igniteui-angular-core";
import { timeSpanInit1 } from "igniteui-angular-core";
import { dateFromValues } from "igniteui-angular-core";
/**
 * @hidden
 */
var UltraCalcFunctionTime = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(UltraCalcFunctionTime, _super);
    function UltraCalcFunctionTime() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionTime.prototype.evaluate = function (a, b) {
        var c = a.pop();
        var d = a.pop();
        var e = a.pop();
        if (e.isError) {
            return e;
        }
        if (d.isError) {
            return d;
        }
        if (c.isError) {
            return c;
        }
        var f = c._toInt321();
        var g = d._toInt321();
        var h = e._toInt321();
        if (true) {
            var i = 32767;
            if (f < 0 || g < 0 || h < 0 || i < f || i < g || i < h) {
                return new ExcelCalcValue(new ExcelCalcErrorValue(4));
            }
            g += (intDivide(f, 60));
            f = f % 60;
            h += (intDivide(g, 60));
            g = g % 60;
            h = h % 24;
        }
        if (true) {
            var j = timeSpanInit1(h, g, f);
            var k = ExcelCalcValue._a2(j);
            return new ExcelCalcValue(k);
        }
        else {
            var l = dateFromValues(1, 1, 1, h, g, f, 0);
            return new ExcelCalcValue(l.getTime());
        }
    };
    UltraCalcFunctionTime.prototype.get_name = function () {
        return "time";
    };
    Object.defineProperty(UltraCalcFunctionTime.prototype, "name", {
        get: function () {
            return this.get_name();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionTime.prototype.get_minArgs = function () {
        return 3;
    };
    Object.defineProperty(UltraCalcFunctionTime.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionTime.prototype.get_maxArgs = function () {
        return 3;
    };
    Object.defineProperty(UltraCalcFunctionTime.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionTime.prototype.doesParameterAllowIntermediateResultArray = function (a, b) {
        return true;
    };
    UltraCalcFunctionTime.$t = markType(UltraCalcFunctionTime, 'UltraCalcFunctionTime', BuiltInFunctionBase.$);
    return UltraCalcFunctionTime;
}(BuiltInFunctionBase));
export { UltraCalcFunctionTime };
