/*
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 { BuiltInFunctionBase } from "./BuiltInFunctionBase";
import { ExcelCalcValue } from "./ExcelCalcValue";
import { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { MathUtilities } from "./MathUtilities";
import { markType } from "igniteui-angular-core";
/**
 * @hidden
 */
var UltraCalcFunctionFloor = /** @class */ (function (_super) {
    tslib_1.__extends(UltraCalcFunctionFloor, _super);
    function UltraCalcFunctionFloor() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionFloor.prototype.evaluate = function (a, b) {
        var c = 1;
        if (b > 1) {
            var d_1 = a.pop();
            if (d_1.isError) {
                return new ExcelCalcValue(d_1.toErrorValue());
            }
            if (!((function () { var e = d_1._toDouble1(c); c = e.p0; return e.ret; })())) {
                return new ExcelCalcValue(new ExcelCalcErrorValue(4));
            }
        }
        var e = a.pop();
        if (e.isError) {
            return new ExcelCalcValue(e.toErrorValue());
        }
        var f;
        if (!((function () { var g = e._toDouble1(f); f = g.p0; return g.ret; })())) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(4));
        }
        if (f == 0 && c == 0) {
            return new ExcelCalcValue(0);
        }
        if (c == 0) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(2));
        }
        var g = f < 0 ? -1 : 1;
        var h = c < 0 ? -1 : 1;
        if (true) {
            if (f != 0 && c != 0 && 0 < g && h < 0) {
                return new ExcelCalcValue(new ExcelCalcErrorValue(4));
            }
        }
        var i = Math.floor(MathUtilities.i(f / c)) * c;
        return new ExcelCalcValue(i);
    };
    UltraCalcFunctionFloor.prototype.get_name = function () {
        return "floor";
    };
    Object.defineProperty(UltraCalcFunctionFloor.prototype, "name", {
        get: function () {
            return this.get_name();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionFloor.prototype.get_minArgs = function () {
        return 1;
    };
    Object.defineProperty(UltraCalcFunctionFloor.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionFloor.prototype.get_maxArgs = function () {
        return 2;
    };
    Object.defineProperty(UltraCalcFunctionFloor.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionFloor.prototype.doesParameterAllowIntermediateResultArray = function (a, b) {
        return true;
    };
    UltraCalcFunctionFloor.$t = markType(UltraCalcFunctionFloor, 'UltraCalcFunctionFloor', BuiltInFunctionBase.$);
    return UltraCalcFunctionFloor;
}(BuiltInFunctionBase));
export { UltraCalcFunctionFloor };
//# sourceMappingURL=UltraCalcFunctionFloor.js.map