/*
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 { markType } from "igniteui-angular-core";
import { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { MathUtilities } from "./MathUtilities";
import { truncate } from "igniteui-angular-core";
/**
 * @hidden
 */
var UltraCalcFunctionSearch = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(UltraCalcFunctionSearch, _super);
    function UltraCalcFunctionSearch() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionSearch.prototype.evaluate = function (a, b) {
        var c = null;
        if (b > 2) {
            c = a.pop();
        }
        var d = a.pop();
        var e = a.pop();
        if (e.isError) {
            return e;
        }
        if (d.isError) {
            return d;
        }
        if (c != null && c.isError) {
            return c;
        }
        var f = e.toString();
        var g = d.toString();
        var h = 0;
        if (c != null) {
            var i_1;
            if (((function () { var j = c._toDouble1(i_1); i_1 = j.p0; return j.ret; })()) == false) {
                return new ExcelCalcValue(new ExcelCalcErrorValue(1));
            }
            h = truncate(MathUtilities.j(i_1)) - 1;
            if (h < 0 || g.length <= h) {
                return new ExcelCalcValue(new ExcelCalcErrorValue(1));
            }
        }
        var j = a._w.compareInfo.indexOf6(g, f, h, 1);
        if (j < 0) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(1));
        }
        return new ExcelCalcValue(j + 1);
    };
    UltraCalcFunctionSearch.prototype.get_name = function () {
        return "search";
    };
    Object.defineProperty(UltraCalcFunctionSearch.prototype, "name", {
        get: function () {
            return this.get_name();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionSearch.prototype.get_minArgs = function () {
        return 2;
    };
    Object.defineProperty(UltraCalcFunctionSearch.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionSearch.prototype.get_maxArgs = function () {
        return 3;
    };
    Object.defineProperty(UltraCalcFunctionSearch.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionSearch.prototype.doesParameterAllowIntermediateResultArray = function (a, b) {
        return true;
    };
    UltraCalcFunctionSearch.$t = markType(UltraCalcFunctionSearch, 'UltraCalcFunctionSearch', BuiltInFunctionBase.$);
    return UltraCalcFunctionSearch;
}(BuiltInFunctionBase));
export { UltraCalcFunctionSearch };
