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