/*
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 { Base, toNullable, typeCast, markType, enumGetBox, EnumUtil } from "igniteui-angular-core";
import { FormatConditionType_$type } from "./FormatConditionType";
import { AverageConditionalFormat } from "./AverageConditionalFormat";
import { RankConditionalFormat } from "./RankConditionalFormat";
import { OperatorConditionalFormat } from "./OperatorConditionalFormat";
import { SingleTargetFormula } from "./SingleTargetFormula";
import { FormulaConditionalFormat } from "./FormulaConditionalFormat";
import { CellReferenceMode_$type } from "./CellReferenceMode";
import { TextOperatorConditionalFormat } from "./TextOperatorConditionalFormat";
import { NamedReferenceFormula } from "./NamedReferenceFormula";
import { StrToken } from "./StrToken";
import { DateTimeConditionalFormat } from "./DateTimeConditionalFormat";
import { DataBarConditionalFormat } from "./DataBarConditionalFormat";
import { ColorScaleConditionalFormat } from "./ColorScaleConditionalFormat";
import { IconSetConditionalFormat } from "./IconSetConditionalFormat";
import { BlanksConditionalFormat } from "./BlanksConditionalFormat";
import { NoBlanksConditionalFormat } from "./NoBlanksConditionalFormat";
import { ErrorsConditionalFormat } from "./ErrorsConditionalFormat";
import { NoErrorsConditionalFormat } from "./NoErrorsConditionalFormat";
import { UniqueConditionalFormat } from "./UniqueConditionalFormat";
import { DuplicateConditionalFormat } from "./DuplicateConditionalFormat";
import { FormatConditionTimePeriod_$type } from "./FormatConditionTimePeriod";
import { CfVo } from "./CfVo";
import { IconCriterion } from "./IconCriterion";
import { IconSet_$type } from "./IconSet";
/**
 * @hidden
 */
var ConditionFactory_BIFF8 = /** @class */ (function (_super) {
    tslib_1.__extends(ConditionFactory_BIFF8, _super);
    function ConditionFactory_BIFF8() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ConditionFactory_BIFF8.i = function (a, b) {
        var c = toNullable(FormatConditionType_$type, null);
        if (b.hasValue) {
            switch (b.value) {
                case 25:
                case 29:
                case 26:
                case 30:
                    c = toNullable(FormatConditionType_$type, 11);
                    break;
                case 9:
                    c = toNullable(FormatConditionType_$type, 9);
                    break;
                case 0:
                    c = toNullable(FormatConditionType_$type, 0);
                    break;
                case 2:
                    c = toNullable(FormatConditionType_$type, 2);
                    break;
                case 8:
                    c = toNullable(FormatConditionType_$type, 8);
                    break;
                case 3:
                    c = toNullable(FormatConditionType_$type, 3);
                    break;
                case 27:
                    c = toNullable(FormatConditionType_$type, 7);
                    break;
                case 11:
                    c = toNullable(FormatConditionType_$type, 13);
                    break;
                case 5:
                    c = toNullable(FormatConditionType_$type, 4);
                    break;
                case 1:
                    c = toNullable(FormatConditionType_$type, 1);
                    break;
                case 4:
                    c = toNullable(FormatConditionType_$type, 5);
                    break;
                case 18:
                case 19:
                case 23:
                case 24:
                case 21:
                case 15:
                case 16:
                case 17:
                case 20:
                case 22:
                    c = toNullable(FormatConditionType_$type, 10);
                    break;
                case 10:
                    c = toNullable(FormatConditionType_$type, 12);
                    break;
                case 12:
                    c = toNullable(FormatConditionType_$type, 14);
                    break;
                case 7:
                    c = toNullable(FormatConditionType_$type, 6);
                    break;
            }
        }
        if (b.hasValue) {
        }
        if (c.hasValue == false) {
            c = toNullable(FormatConditionType_$type, Extensions_BIFF8.e(a));
        }
        return c.hasValue ? c.value : 0;
    };
    ConditionFactory_BIFF8.d = function (a, b, c, d) {
        var e = null;
        switch (a) {
            case 11:
                e = ConditionFactory_BIFF8.a(b, c, d);
                break;
            case 9:
                e = ConditionFactory_BIFF8.b(b, c, d);
                break;
            case 0:
                e = ConditionFactory_BIFF8.n(b, c, d);
                break;
            case 2:
                e = ConditionFactory_BIFF8.c(b, c, d);
                break;
            case 3:
                e = ConditionFactory_BIFF8.e(b, c, d);
                break;
            case 7:
                e = ConditionFactory_BIFF8.g(b, c, d);
                break;
            case 13:
                e = ConditionFactory_BIFF8.h(b, c, d);
                break;
            case 1:
                e = ConditionFactory_BIFF8.j(b, c, d);
                break;
            case 5:
                e = ConditionFactory_BIFF8.k(b, c, d);
                break;
            case 12:
                e = ConditionFactory_BIFF8.l(b, c, d);
                break;
            case 14:
                e = ConditionFactory_BIFF8.m(b, c, d);
                break;
            case 4:
                e = ConditionFactory_BIFF8.o(b, c, d);
                break;
            case 8:
                e = ConditionFactory_BIFF8.p(b, c, d);
                break;
            case 10:
                e = ConditionFactory_BIFF8.f(b, c, d);
                break;
            case 6:
                e = ConditionFactory_BIFF8.q(b, c, d);
                break;
            default: break;
        }
        return e;
    };
    ConditionFactory_BIFF8.a = function (a, b, c) {
        var d = new AverageConditionalFormat(1, a.c, 0);
        ConditionFactory_BIFF8.s(d, b);
        ConditionFactory_BIFF8.t(d, b);
        var e = b.l != null ? b.l.a : null;
        if (e != null) {
            var f = e.a > 0;
            var g = b.e.c.hasValue ? b.e.c.value : 25;
            d.aboveBelow = Extensions_BIFF8.a(g, f);
            d.numericStandardDeviation = e != null ? e.a : 0;
        }
        return d;
    };
    ConditionFactory_BIFF8.o = function (a, b, c) {
        var d = new RankConditionalFormat(1, a.c, 1, 10);
        ConditionFactory_BIFF8.s(d, b);
        ConditionFactory_BIFF8.t(d, b);
        var e = b.l != null ? b.l.c : b.g != null ? b.g : null;
        if (e == null) {
        }
        else {
            d.topBottom = e.b ? 1 : 0;
            d.isPercent = e.a;
            d.rank = e.c;
        }
        return d;
    };
    ConditionFactory_BIFF8.n = function (a, b, c) {
        var d = new OperatorConditionalFormat(1, a.c, 2);
        ConditionFactory_BIFF8.s(d, b);
        ConditionFactory_BIFF8.t(d, b);
        d.operator = Extensions_BIFF8.b(b.k);
        var e = null;
        var f = null;
        var g = ConditionFactory_BIFF8.r(b.b, e);
        e = g.p1;
        var h = ConditionFactory_BIFF8.r(b.c, f);
        f = h.p1;
        if (e != null) {
            d._cd = e;
        }
        if (f != null) {
            d._ce = f;
        }
        return d;
    };
    ConditionFactory_BIFF8.j = function (a, b, c) {
        var d = new FormulaConditionalFormat(1, a.c, null, toNullable(CellReferenceMode_$type, null));
        ConditionFactory_BIFF8.s(d, b);
        ConditionFactory_BIFF8.t(d, b);
        var e = null;
        var f = ConditionFactory_BIFF8.r(b.b, e);
        e = f.p1;
        if (e != null) {
            d._b5 = e;
        }
        return d;
    };
    ConditionFactory_BIFF8.p = function (a, b, c) {
        var d = new TextOperatorConditionalFormat(1, a.c, null, 2);
        ConditionFactory_BIFF8.s(d, b);
        ConditionFactory_BIFF8.t(d, b);
        var e = b.l != null ? b.l.d : null;
        d.textOperator = Extensions_BIFF8.c(e.a);
        var f = null;
        var g = typeCast(NamedReferenceFormula.$, b.b);
        if (g != null) {
            var j = g._e;
            for (var i = 0; i < j.length; i++) {
                var h = j[i];
                var k = typeCast(StrToken.$, h);
                if (k != null) {
                    f = k.p;
                    break;
                }
            }
        }
        else {
        }
        d.text = f;
        return d;
    };
    ConditionFactory_BIFF8.f = function (a, b, c) {
        var d = new DateTimeConditionalFormat(1, a.c, 0);
        ConditionFactory_BIFF8.s(d, b);
        ConditionFactory_BIFF8.t(d, b);
        d.dateOperator = Extensions_BIFF8.d(b);
        return d;
    };
    ConditionFactory_BIFF8.e = function (a, b, c) {
        var d = new DataBarConditionalFormat(1, a.c);
        ConditionFactory_BIFF8.s(d, b);
        d.barFillType = 1;
        d.direction = -5003;
        Extensions_BIFF8.v(d, b);
        var e = b.f;
        if (e != null) {
            d.barColor = e.c;
            Extensions_BIFF8.r(d.minPoint, e.b);
            Extensions_BIFF8.r(d.maxPoint, e.a);
            d.direction = e.d ? -5004 : -5003;
            d.fillPercentMin = e.g;
            d.fillPercentMax = e.f;
            d.showValue = (e.e == false);
        }
        return d;
    };
    ConditionFactory_BIFF8.c = function (a, b, c) {
        var d = b.d;
        var e = d != null && d.a != null ? d.a.length : 2;
        var f = e == 3 ? 1 : 0;
        var g = new ColorScaleConditionalFormat(1, a.c, f);
        ConditionFactory_BIFF8.s(g, b);
        Extensions_BIFF8.u(g, b);
        if (d != null && d.a != null) {
            Extensions_BIFF8.q(g.minimumThreshold, d.b[0], d.a[0]);
            switch (f) {
                case 0:
                    Extensions_BIFF8.q(g.maximumThreshold, d.b[1], d.a[1]);
                    break;
                case 1:
                    Extensions_BIFF8.q(g.midpointThreshold, d.b[1], d.a[1]);
                    Extensions_BIFF8.q(g.maximumThreshold, d.b[2], d.a[2]);
                    break;
            }
        }
        return g;
    };
    ConditionFactory_BIFF8.k = function (a, b, c) {
        var d = new IconSetConditionalFormat(1, a.c, 4);
        ConditionFactory_BIFF8.s(d, b);
        Extensions_BIFF8.w(d, b);
        var e = b.j;
        if (e != null) {
            d.iconSet = Extensions_BIFF8.g(e);
            Extensions_BIFF8.t(d._iconCriteria$i, e.a);
            d.isReverseOrder = e.c;
            d.showValue = (e.d == false);
        }
        return d;
    };
    ConditionFactory_BIFF8.b = function (a, b, c) {
        var d = new BlanksConditionalFormat(1, a.c);
        ConditionFactory_BIFF8.s(d, b);
        ConditionFactory_BIFF8.t(d, b);
        return d;
    };
    ConditionFactory_BIFF8.l = function (a, b, c) {
        var d = new NoBlanksConditionalFormat(1, a.c);
        ConditionFactory_BIFF8.s(d, b);
        ConditionFactory_BIFF8.t(d, b);
        return d;
    };
    ConditionFactory_BIFF8.h = function (a, b, c) {
        var d = new ErrorsConditionalFormat(1, a.c);
        ConditionFactory_BIFF8.s(d, b);
        ConditionFactory_BIFF8.t(d, b);
        return d;
    };
    ConditionFactory_BIFF8.m = function (a, b, c) {
        var d = new NoErrorsConditionalFormat(1, a.c);
        ConditionFactory_BIFF8.s(d, b);
        ConditionFactory_BIFF8.t(d, b);
        return d;
    };
    ConditionFactory_BIFF8.q = function (a, b, c) {
        var d = new UniqueConditionalFormat(1, a.c);
        ConditionFactory_BIFF8.s(d, b);
        ConditionFactory_BIFF8.t(d, b);
        return d;
    };
    ConditionFactory_BIFF8.g = function (a, b, c) {
        var d = new DuplicateConditionalFormat(1, a.c);
        ConditionFactory_BIFF8.s(d, b);
        ConditionFactory_BIFF8.t(d, b);
        return d;
    };
    ConditionFactory_BIFF8.s = function (a, b) {
        a.priority = b.e.d;
        a.stopIfTrue = b.e.b;
    };
    ConditionFactory_BIFF8.t = function (a, b) {
        a._bw = b.h != null && b.h.d != null ? b.h.d : b.n != null ? b.n : null;
    };
    ConditionFactory_BIFF8.r = function (a, b, c) {
        if (c === void 0) { c = true; }
        b = null;
        if (a == null) {
            return {
                p1: b
            };
        }
        b = typeCast(SingleTargetFormula.$, a);
        if (c) {
        }
        return {
            p1: b
        };
    };
    ConditionFactory_BIFF8.$t = markType(ConditionFactory_BIFF8, 'ConditionFactory_BIFF8');
    return ConditionFactory_BIFF8;
}(Base));
export { ConditionFactory_BIFF8 };
/**
 * @hidden
 */
var Extensions_BIFF8 = /** @class */ (function (_super) {
    tslib_1.__extends(Extensions_BIFF8, _super);
    function Extensions_BIFF8() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Extensions_BIFF8.e = function (a) {
        var b = 0;
        switch (a) {
            case 1:
                b = 0;
                break;
            case 3:
                b = 2;
                break;
            case 4:
                b = 3;
                break;
            case 5:
                b = 4;
                break;
            case 2:
                b = 1;
                break;
            case 6:
                b = 5;
                break;
            case 0: break;
        }
        return b;
    };
    Extensions_BIFF8.a = function (a, b) {
        var c = 0;
        switch (a) {
            case 25:
                c = b ? 4 : 0;
                break;
            case 29:
                c = 2;
                break;
            case 26:
                c = b ? 5 : 1;
                break;
            case 30:
                c = 3;
                break;
            default: break;
        }
        return c;
    };
    Extensions_BIFF8.b = function (a) {
        var b = 2;
        switch (a) {
            case 1:
                b = 0;
                break;
            case 3: break;
            case 7:
                b = 6;
                break;
            case 5:
                b = 4;
                break;
            case 8:
                b = 7;
                break;
            case 6:
                b = 5;
                break;
            case 2:
                b = 1;
                break;
            case 4:
                b = 3;
                break;
            default: break;
        }
        return b;
    };
    Extensions_BIFF8.i = function (a) {
        var b = 3;
        switch (a) {
            case 0:
                b = 1;
                break;
            case 2: break;
            case 4:
                b = 5;
                break;
            case 6:
                b = 7;
                break;
            case 5:
                b = 6;
                break;
            case 7:
                b = 8;
                break;
            case 1:
                b = 2;
                break;
            case 3:
                b = 4;
                break;
            default: break;
        }
        return b;
    };
    Extensions_BIFF8.c = function (a) {
        var b = 2;
        switch (a) {
            case 2:
                b = 0;
                break;
            case 3:
                b = 1;
                break;
            case 0:
                b = 2;
                break;
            case 1:
                b = 3;
                break;
            default: break;
        }
        return b;
    };
    Extensions_BIFF8.d = function (a) {
        var b = toNullable(FormatConditionTimePeriod_$type, null);
        var c = a.l != null ? a.l.b : null;
        if (c != null) {
            switch (c.a) {
                case 2:
                    b = toNullable(FormatConditionTimePeriod_$type, 6);
                    break;
                case 5:
                    b = toNullable(FormatConditionTimePeriod_$type, 9);
                    break;
                case 4:
                    b = toNullable(FormatConditionTimePeriod_$type, 5);
                    break;
                case 8:
                    b = toNullable(FormatConditionTimePeriod_$type, 8);
                    break;
                case 7:
                    b = toNullable(FormatConditionTimePeriod_$type, 4);
                    break;
                case 9:
                    b = toNullable(FormatConditionTimePeriod_$type, 7);
                    break;
                case 3:
                    b = toNullable(FormatConditionTimePeriod_$type, 3);
                    break;
                case 0:
                    b = toNullable(FormatConditionTimePeriod_$type, 0);
                    break;
                case 6:
                    b = toNullable(FormatConditionTimePeriod_$type, 1);
                    break;
                case 1:
                    b = toNullable(FormatConditionTimePeriod_$type, 2);
                    break;
                default: break;
            }
        }
        if (b.hasValue) {
            return b.value;
        }
        if (a.e.c.hasValue) {
            switch (a.e.c.value) {
                case 18:
                    b = toNullable(FormatConditionTimePeriod_$type, 6);
                    break;
                case 19:
                    b = toNullable(FormatConditionTimePeriod_$type, 9);
                    break;
                case 23:
                    b = toNullable(FormatConditionTimePeriod_$type, 5);
                    break;
                case 20:
                    b = toNullable(FormatConditionTimePeriod_$type, 8);
                    break;
                case 22:
                    b = toNullable(FormatConditionTimePeriod_$type, 4);
                    break;
                case 24:
                    b = toNullable(FormatConditionTimePeriod_$type, 7);
                    break;
                case 21:
                    b = toNullable(FormatConditionTimePeriod_$type, 3);
                    break;
                case 15:
                    b = toNullable(FormatConditionTimePeriod_$type, 0);
                    break;
                case 16:
                    b = toNullable(FormatConditionTimePeriod_$type, 1);
                    break;
                case 17:
                    b = toNullable(FormatConditionTimePeriod_$type, 2);
                    break;
                default: break;
            }
        }
        return b.hasValue ? b.value : 0;
    };
    Extensions_BIFF8.f = function (a) {
        var b = 0;
        switch (a) {
            case 7:
                b = 3;
                break;
            case 3:
                b = 5;
                break;
            case 2:
                b = 4;
                break;
            case 1: break;
            case 4:
                b = 1;
                break;
            case 5:
                b = 2;
                break;
            default: break;
        }
        return b;
    };
    Extensions_BIFF8.g = function (a) {
        var b = a.b;
        b += 1;
        return b;
    };
    Extensions_BIFF8.r = function (a, b) {
        var c = Extensions_BIFF8.f(b.b);
        if (c == 3) {
            var d = null;
            var e = ConditionFactory_BIFF8.r(b.a, d);
            d = e.p1;
            a._ai(d);
        }
        else if (c != 4 && c != 5) {
            a._setValue1(b.c, c);
        }
        else {
            a._setValue(c);
        }
    };
    Extensions_BIFF8.n = function (a) {
        var b = new CfVo();
        b.b = Extensions_BIFF8.m(a.valueType);
        switch (a.valueType) {
            case 6:
            case 4:
            case 7:
            case 5: break;
            case 0:
            case 1:
            case 2:
                b.c = a.value;
                break;
            case 3:
                b.a = a.formula;
                break;
        }
        return b;
    };
    Extensions_BIFF8.q = function (a, b, c) {
        Extensions_BIFF8.r(a._b, b);
        a.formatColor = c;
    };
    Extensions_BIFF8.u = function (a, b) {
        Extensions_BIFF8.x(a, b);
    };
    Extensions_BIFF8.v = function (a, b) {
        Extensions_BIFF8.x(a, b);
    };
    Extensions_BIFF8.w = function (a, b) {
        Extensions_BIFF8.x(a, b);
    };
    Extensions_BIFF8.x = function (a, b) {
        if (b.a == null) {
            return;
        }
        var c = null;
        var d = ConditionFactory_BIFF8.r(b.a, c);
        c = d.p1;
        if (c != null) {
            a._b6(c);
        }
    };
    Extensions_BIFF8.t = function (a, b) {
        var c = new Array(b.length);
        var d = a._d;
        var e = IconSetConditionalFormat._b9(d.iconSet);
        for (var f = 0; f < b.length; f++) {
            c[f] = new IconCriterion(1, a, f, d.iconSet, e[f]);
            Extensions_BIFF8.s(c[f], b[f]);
        }
        a._q(c);
    };
    Extensions_BIFF8.s = function (a, b) {
        a.comparison = b.b ? 0 : 1;
        Extensions_BIFF8.r(a._b, b.a);
    };
    Extensions_BIFF8.l = function (a) {
        switch (a.conditionType) {
            case 0: return 1;
            case 2: return 3;
            case 3: return 4;
            case 5: return 6;
            case 4: return 5;
            case 11:
            case 9:
            case 12:
            case 13:
            case 14:
            case 1:
            case 8:
            case 10:
            case 6:
            case 7: return 2;
            default: return 2;
        }
    };
    Extensions_BIFF8.j = function (a) {
        var b = 0;
        switch (a.conditionType) {
            case 11:
                var c = typeCast(AverageConditionalFormat.$, a);
                switch (c.aboveBelow) {
                    case 0:
                    case 4:
                        b = 25;
                        break;
                    case 2:
                        b = 29;
                        break;
                    case 1:
                    case 5:
                        b = 26;
                        break;
                    case 3:
                        b = 30;
                        break;
                }
                break;
            case 9:
                b = 9;
                break;
            case 0:
                b = 0;
                break;
            case 2:
                b = 2;
                break;
            case 3:
                b = 3;
                break;
            case 7:
                b = 27;
                break;
            case 13:
                b = 11;
                break;
            case 1:
                b = 1;
                break;
            case 5:
                b = 4;
                break;
            case 12:
                b = 10;
                break;
            case 14:
                b = 12;
                break;
            case 4:
                b = 5;
                break;
            case 8:
                b = 8;
                break;
            case 10:
                var d = typeCast(DateTimeConditionalFormat.$, a);
                switch (d.dateOperator) {
                    case 9:
                        b = 19;
                        break;
                    case 6:
                        b = 18;
                        break;
                    case 5:
                        b = 23;
                        break;
                    case 8:
                        b = 20;
                        break;
                    case 4:
                        b = 22;
                        break;
                    case 7:
                        b = 24;
                        break;
                    case 3:
                        b = 21;
                        break;
                    case 0:
                        b = 15;
                        break;
                    case 1:
                        b = 16;
                        break;
                    case 2:
                        b = 17;
                        break;
                }
                break;
            case 6:
                b = 7;
                break;
        }
        return b;
    };
    Extensions_BIFF8.m = function (a) {
        var b = 1;
        switch (a) {
            case 7:
            case 5:
                b = 3;
                break;
            case 6:
            case 4:
                b = 2;
                break;
            case 0:
                b = 1;
                break;
            case 1:
                b = 4;
                break;
            case 2:
                b = 5;
                break;
            case 3:
                b = 7;
                break;
        }
        return b;
    };
    Extensions_BIFF8.p = function (a) {
        var b = false;
        switch (a) {
            case 0:
            case 4:
            case 2:
                b = true;
                break;
            case 1:
            case 5:
            case 3:
                b = false;
                break;
        }
        return b;
    };
    Extensions_BIFF8.k = function (a) {
        var b = 0;
        switch (a) {
            case 0:
                b = 2;
                break;
            case 1:
                b = 3;
                break;
            case 2:
                b = 0;
                break;
            case 3:
                b = 1;
                break;
        }
        return b;
    };
    Extensions_BIFF8.h = function (a) {
        var b = 0;
        switch (a) {
            case 0: break;
            case 1:
                b = 6;
                break;
            case 2:
                b = 1;
                break;
            case 9:
                b = 5;
                break;
            case 6:
                b = 2;
                break;
            case 5:
                b = 4;
                break;
            case 8:
                b = 8;
                break;
            case 4:
                b = 7;
                break;
            case 7:
                b = 9;
                break;
            case 3:
                b = 3;
                break;
        }
        return b;
    };
    Extensions_BIFF8.o = function (a) {
        var b = (a - 1);
        if (EnumUtil.isDefined(IconSet_$type, enumGetBox(IconSet_$type, b)) == false) {
            b = 3;
        }
        return b;
    };
    Extensions_BIFF8.$t = markType(Extensions_BIFF8, 'Extensions_BIFF8');
    return Extensions_BIFF8;
}(Base));
export { Extensions_BIFF8 };
//# sourceMappingURL=ConditionFactory_BIFF8_combined.js.map