/*
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 { BuiltInFunctionBase } from "./BuiltInFunctionBase";
import { ExcelCalcValue } from "./ExcelCalcValue";
import { UltraCalcFunctionStdev } from "./UltraCalcFunctionStdev";
import { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { CalcFunctionUtilities } from "./CalcFunctionUtilities";
import { UltraCalcFunctionAverage } from "./UltraCalcFunctionAverage";
import { markType } from "igniteui-angular-core";
import { UltraCalcFunctionMax } from "./UltraCalcFunctionMax";
import { UltraCalcFunctionMin } from "./UltraCalcFunctionMin";
import { UltraCalcFunctionProduct } from "./UltraCalcFunctionProduct";
import { UltraCalcFunctionVar } from "./UltraCalcFunctionVar";
import { truncate } from "igniteui-angular-core";
import { boxArray$1 } from "igniteui-angular-core";
/**
 * @hidden
 */
export class UltraCalcFunctionSubtotal extends BuiltInFunctionBase {
    evaluate(a, b) {
        let c = new Array(b - 1);
        for (let d = c.length - 1; d >= 0; d--) {
            let e = a.pop();
            c[d] = e;
        }
        let f = a.pop();
        if (f.isError) {
            return f;
        }
        let g;
        if (((() => { let h = f._toDouble1(g); g = h.p0; return h.ret; })()) == false) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(1));
        }
        let h = truncate(g);
        let i = false;
        if (h > 100) {
            i = true;
            h -= 100;
        }
        switch (h) {
            case 1: return CalcFunctionUtilities.e(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, UltraCalcFunctionAverage._ak);
            case 2: return CalcFunctionUtilities.l(boxArray$1(c), CalcFunctionUtilities.c(a, false, false, i) | 2048);
            case 3: return CalcFunctionUtilities.l(boxArray$1(c), CalcFunctionUtilities.c(a, true, false, i) | 2048);
            case 4: return CalcFunctionUtilities.e(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, UltraCalcFunctionMax._ak);
            case 5: return CalcFunctionUtilities.e(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, UltraCalcFunctionMin._ak);
            case 6: return CalcFunctionUtilities.e(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, UltraCalcFunctionProduct._ak);
            case 7: return CalcFunctionUtilities.e(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, (j) => UltraCalcFunctionStdev._al(j, true));
            case 8: return CalcFunctionUtilities.e(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, (j) => UltraCalcFunctionStdev._al(j, false));
            case 9:
                {
                    let j = 0;
                    return CalcFunctionUtilities.g(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, (k) => j += k) || new ExcelCalcValue(j);
                }
            case 10: return CalcFunctionUtilities.e(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, (k) => UltraCalcFunctionVar._ak(k, true));
            case 11: return CalcFunctionUtilities.e(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, (k) => UltraCalcFunctionVar._ak(k, false));
            default: return new ExcelCalcValue(new ExcelCalcErrorValue(1));
        }
    }
    canParameterBeEnumerable(a) {
        return 1 <= a;
    }
    get_name() {
        return "subtotal";
    }
    get name() {
        return this.get_name();
    }
    get_minArgs() {
        return 2;
    }
    get minArgs() {
        return this.get_minArgs();
    }
    get_maxArgs() {
        return 0x7FFFFFFF;
    }
    get maxArgs() {
        return this.get_maxArgs();
    }
    doesParameterAllowIntermediateResultArray(a, b) {
        return true;
    }
}
UltraCalcFunctionSubtotal.$t = markType(UltraCalcFunctionSubtotal, 'UltraCalcFunctionSubtotal', BuiltInFunctionBase.$);
//# sourceMappingURL=UltraCalcFunctionSubtotal.js.map