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