/*
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 { UltraCalcFunctionLookupBase } from "./UltraCalcFunctionLookupBase";
import { ExcelCalcValue } from "./ExcelCalcValue";
import { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { MathUtilities } from "./MathUtilities";
import { markType } from "igniteui-angular-core";
import { truncate } from "igniteui-angular-core";
/**
 * @hidden
 */
export class UltraCalcFunctionMatch extends UltraCalcFunctionLookupBase {
    evaluate(a, b) {
        let c = null;
        if (b == 3) {
            c = a.pop();
        }
        let d = a.pop();
        let e = a.pop();
        if (e.isError) {
            return e;
        }
        if (d.isError) {
            return d;
        }
        if (c != null && c.isError) {
            return c;
        }
        if (e.isNull) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(3));
        }
        let f = d._d(false);
        let g = f.getLength(0);
        let h = f.getLength(1);
        if (g != 1 && h != 1) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(3));
        }
        let i = (h < g);
        let j = i ? g : h;
        let k = 1;
        if (c != null && ((() => { let l = c._toDouble1(k); k = l.p0; return l.ret; })()) == false) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(1));
        }
        let l = truncate(MathUtilities.j(k));
        let m = UltraCalcFunctionLookupBase._al(f._i(i ? 1 : 0, 0), e, l);
        if (m < 0 || j <= m) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(3));
        }
        return new ExcelCalcValue(m + 1);
    }
    get_name() {
        return "match";
    }
    get name() {
        return this.get_name();
    }
    get_minArgs() {
        return 2;
    }
    get_maxArgs() {
        return 3;
    }
    doesParameterAllowIntermediateResultArray(a, b) {
        return (b == false);
    }
}
UltraCalcFunctionMatch.$t = markType(UltraCalcFunctionMatch, 'UltraCalcFunctionMatch', UltraCalcFunctionLookupBase.$);
//# sourceMappingURL=UltraCalcFunctionMatch.js.map