/*
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";
/**
 * @hidden
 */
var UltraCalcFunctionFV = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(UltraCalcFunctionFV, _super);
    function UltraCalcFunctionFV() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionFV.prototype.evaluate = function (a, b) {
        var c = 0;
        if (b == 5) {
            var d = a.pop();
            if (d.isError) {
                return d;
            }
            c = d._toInt321();
        }
        var e = 0;
        if (b >= 4) {
            var f_1 = a.pop();
            if (f_1.isError) {
                return new ExcelCalcValue(f_1.toErrorValue());
            }
            if (!((function () { var g = f_1._toDouble1(e); e = g.p0; return g.ret; })())) {
                return new ExcelCalcValue(new ExcelCalcErrorValue(4));
            }
        }
        var g, h, i;
        var j = a.pop();
        var k = a.pop();
        var l = a.pop();
        if (l.isError) {
            return l;
        }
        if (k.isError) {
            return k;
        }
        if (j.isError) {
            return j;
        }
        if (!((function () { var m = j._toDouble1(g); g = m.p0; return m.ret; })()) || !((function () { var m = k._toDouble1(h); h = m.p0; return m.ret; })()) || !((function () { var m = l._toDouble1(i); i = m.p0; return m.ret; })())) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(4));
        }
        return new ExcelCalcValue(UltraCalcFunctionFV._ak(i, h, g, e, c));
    };
    UltraCalcFunctionFV._ak = function (a, b, c, d, e) {
        return (c * ((Math.pow(1 + a, e == 0 ? b : b + 1) - 1) / a) - (e == 0 ? 0 : c) + (d * Math.pow(1 + a, b))) * -1;
    };
    UltraCalcFunctionFV.prototype.get_name = function () {
        return "fv";
    };
    Object.defineProperty(UltraCalcFunctionFV.prototype, "name", {
        get: function () {
            return this.get_name();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionFV.prototype.get_minArgs = function () {
        return 3;
    };
    Object.defineProperty(UltraCalcFunctionFV.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionFV.prototype.get_maxArgs = function () {
        return 5;
    };
    Object.defineProperty(UltraCalcFunctionFV.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionFV.prototype.doesParameterAllowIntermediateResultArray = function (a, b) {
        return true;
    };
    UltraCalcFunctionFV.$t = markType(UltraCalcFunctionFV, 'UltraCalcFunctionFV', BuiltInFunctionBase.$);
    return UltraCalcFunctionFV;
}(BuiltInFunctionBase));
export { UltraCalcFunctionFV };
