/*
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 { MathUtilities } from "./MathUtilities";
import { markType } from "igniteui-angular-core";
/**
 * @hidden
 */
var UltraCalcFunctionCeiling = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(UltraCalcFunctionCeiling, _super);
    function UltraCalcFunctionCeiling() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionCeiling.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 (c == 0) {
            return new ExcelCalcValue(0);
        }
        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.ceil(MathUtilities.i(f / c)) * c;
        return new ExcelCalcValue(i);
    };
    UltraCalcFunctionCeiling.prototype.get_name = function () {
        return "ceiling";
    };
    Object.defineProperty(UltraCalcFunctionCeiling.prototype, "name", {
        get: function () {
            return this.get_name();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionCeiling.prototype.get_minArgs = function () {
        return 1;
    };
    Object.defineProperty(UltraCalcFunctionCeiling.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionCeiling.prototype.get_maxArgs = function () {
        return 2;
    };
    Object.defineProperty(UltraCalcFunctionCeiling.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionCeiling.prototype.doesParameterAllowIntermediateResultArray = function (a, b) {
        return true;
    };
    UltraCalcFunctionCeiling.$t = markType(UltraCalcFunctionCeiling, 'UltraCalcFunctionCeiling', BuiltInFunctionBase.$);
    return UltraCalcFunctionCeiling;
}(BuiltInFunctionBase));
export { UltraCalcFunctionCeiling };
