/*
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 { Base, typeCast, String_$type, markType } from "igniteui-angular-core";
import { MathUtilities } from "./MathUtilities";
import { ExcelUtils } from "./ExcelUtils";
import { ExcelCalcValue } from "./ExcelCalcValue";
import { CalculationContext } from "./CalculationContext";
import { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { stringIsNullOrEmpty, stringContains } from "igniteui-angular-core";
/**
 * @hidden
 */
export class UltraCalcConditionalFunctionBase_CriteriaEvaluator extends Base {
    constructor(a, b) {
        super();
        this.b = null;
        this.f = null;
        this.e = null;
        this.c = 0;
        this.g = null;
        this.a = null;
        let c = a._w;
        this.f = b != null ? b.toString() : null;
        let d;
        let e = typeCast(String_$type, b);
        if (stringIsNullOrEmpty(e) == false) {
            let f = true;
            let g = null;
            switch (e.charAt(0)) {
                case '=':
                    this.c = 0;
                    g = e.substr(1);
                    break;
                case '<':
                    f = false;
                    if (e.length > 1) {
                        switch (e.charAt(1)) {
                            case '>':
                                this.c = 1;
                                g = e.substr(2);
                                break;
                            case '=':
                                this.c = 5;
                                g = e.substr(2);
                                break;
                        }
                    }
                    if (g == null) {
                        this.c = 4;
                        g = e.substr(1);
                    }
                    break;
                case '>':
                    f = false;
                    if (e.length > 1 && e.charAt(1) == '=') {
                        this.c = 3;
                        g = e.substr(2);
                    }
                    else {
                        this.c = 2;
                        g = e.substr(1);
                    }
                    break;
                default:
                    g = e;
                    break;
            }
            this.f = g;
            let h;
            if (((() => { let i = MathUtilities.c(g.trim(), c, h); h = i.p2; return i.ret; })())) {
                d = h;
                if (f == false) {
                    this.f = null;
                }
            }
            else {
                if (stringContains(g, "*") || stringContains(g, "?")) {
                    let i;
                    this.g = ((() => { let j = ExcelUtils.ep(g, i); i = j.p1; return j.ret; })());
                }
                d = g;
            }
        }
        else {
            d = b;
        }
        this.b = new ExcelCalcValue(d);
        this.b._n = new CalculationContext(1, a, 64);
        this.e = this.b._getResolvedValue3(false);
        this.a = typeCast(ExcelCalcErrorValue.$, d);
    }
    d(a) {
        let b = a._getResolvedValue3(false);
        if (ExcelCalcValue._aa(b)) {
            return this.a != null && this.a.code == b.code;
        }
        if (ExcelCalcValue._ac(b) != ExcelCalcValue._ac(this.e)) {
            return false;
        }
        let c = false;
        if (ExcelCalcValue._ag(b)) {
            if (this.f == null) {
                return false;
            }
            c = true;
        }
        if (ExcelCalcValue._u(b) != ExcelCalcValue._u(this.e)) {
            return false;
        }
        if (this.g != null) {
            return this.g.i(a._bp(b, a._a0)).i;
        }
        let d = ExcelCalcValue._a4(a, b, this.b, c ? this.f : this.e);
        switch (this.c) {
            case 0: return d == 0;
            case 1: return d != 0;
            case 2: return d > 0;
            case 3: return d >= 0;
            case 4: return d < 0;
            case 5: return d <= 0;
            default: return false;
        }
    }
}
UltraCalcConditionalFunctionBase_CriteriaEvaluator.$t = markType(UltraCalcConditionalFunctionBase_CriteriaEvaluator, 'UltraCalcConditionalFunctionBase_CriteriaEvaluator');
//# sourceMappingURL=UltraCalcConditionalFunctionBase_CriteriaEvaluator.js.map