/*
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 { ValueType, toNullable, typeCast, Number_$type, markStruct } from "igniteui-angular-core";
import { ST_UniversalMeasure } from "./ST_UniversalMeasure";
import { ST_DecimalNumberOrPercent } from "./ST_DecimalNumberOrPercent";
import { DocCoreUtils } from "./DocCoreUtils";
import { stringEmpty } from "igniteui-angular-core";
/**
 * @hidden
 */
export class ST_MeasurementOrPercent extends ValueType {
    constructor(a, ..._rest) {
        super();
        this.m = toNullable(ST_DecimalNumberOrPercent.$, null);
        this.n = toNullable(ST_UniversalMeasure.$, null);
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0: break;
            case 1:
                {
                    let c = _rest[0];
                    this.m = toNullable(ST_DecimalNumberOrPercent.$, c);
                    this.n = toNullable(ST_UniversalMeasure.$, null);
                }
                break;
            case 2:
                {
                    let c = _rest[0];
                    this.m = toNullable(ST_DecimalNumberOrPercent.$, null);
                    this.n = toNullable(ST_UniversalMeasure.$, c);
                }
                break;
        }
    }
    equals(a) {
        let b = toNullable(ST_MeasurementOrPercent.$, typeCast(ST_MeasurementOrPercent.$, a));
        if (ST_MeasurementOrPercent.j(b, toNullable(ST_MeasurementOrPercent.$, null))) {
            return false;
        }
        return ST_MeasurementOrPercent.g(this, b.getValueOrDefault());
    }
    getHashCode() {
        if (ST_DecimalNumberOrPercent.f(this.m, toNullable(ST_DecimalNumberOrPercent.$, null))) {
            return this.m.getValueOrDefault().getHashCode();
        }
        if (ST_UniversalMeasure.f(this.n, toNullable(ST_UniversalMeasure.$, null))) {
            return this.n.getValueOrDefault().getHashCode() << 1;
        }
        return 0;
    }
    toString() {
        return this.r(1);
    }
    r(a) {
        if (ST_DecimalNumberOrPercent.f(this.m, toNullable(ST_DecimalNumberOrPercent.$, null))) {
            return this.m.getValueOrDefault().k(a);
        }
        if (ST_UniversalMeasure.f(this.n, toNullable(ST_UniversalMeasure.$, null))) {
            return this.n.getValueOrDefault().toString();
        }
        return stringEmpty();
    }
    o(a) {
        if (ST_DecimalNumberOrPercent.f(this.m, toNullable(ST_DecimalNumberOrPercent.$, null))) {
            return {
                ret: toNullable(Number_$type, ((() => { let b = this.m.getValueOrDefault().i(a); a = b.p0; return b.ret; })())),
                p0: a
            };
        }
        a = true;
        if (ST_UniversalMeasure.f(this.n, toNullable(ST_UniversalMeasure.$, null))) {
            return {
                ret: this.n.getValueOrDefault().n(),
                p0: a
            };
        }
        return {
            ret: toNullable(Number_$type, null),
            p0: a
        };
    }
    static e(a, b) {
        let c = ST_DecimalNumberOrPercent.j(a, b);
        if (ST_DecimalNumberOrPercent.f(c, toNullable(ST_DecimalNumberOrPercent.$, null))) {
            return ST_MeasurementOrPercent.a(c.getValueOrDefault());
        }
        let d = ST_UniversalMeasure.o(a);
        if (ST_UniversalMeasure.f(d, toNullable(ST_UniversalMeasure.$, null))) {
            return ST_MeasurementOrPercent.b(d.getValueOrDefault());
        }
        throw DocCoreUtils.n(ST_MeasurementOrPercent.$, a);
    }
    get f() {
        return ST_UniversalMeasure.f(this.n, toNullable(ST_UniversalMeasure.$, null));
    }
    static g(a, b) {
        if (ST_DecimalNumberOrPercent.f(a.m, b.m)) {
            return false;
        }
        if (!a.n.hasValue) {
            return !b.n.hasValue;
        }
        if (!b.n.hasValue) {
            return false;
        }
        return ST_UniversalMeasure.b(a.n.value, b.n.value);
    }
    static h(a, b) {
        if (!a.hasValue) {
            return !b.hasValue;
        }
        else if (!b.hasValue) {
            return false;
        }
        return ST_MeasurementOrPercent.g(a.value, b.value);
    }
    static i(a, b) {
        return !(ST_MeasurementOrPercent.g(a, b));
    }
    static j(a, b) {
        if (!a.hasValue) {
            return b.hasValue;
        }
        else if (!b.hasValue) {
            return true;
        }
        return ST_MeasurementOrPercent.i(a.value, b.value);
    }
    static a(a) {
        return new ST_MeasurementOrPercent(1, a);
    }
    static p(a) {
        if (!a.hasValue) {
            return toNullable(ST_MeasurementOrPercent.$, null);
        }
        return toNullable(ST_MeasurementOrPercent.$, ST_MeasurementOrPercent.a(a.value));
    }
    static b(a) {
        return new ST_MeasurementOrPercent(2, a);
    }
    static q(a) {
        if (!a.hasValue) {
            return toNullable(ST_MeasurementOrPercent.$, null);
        }
        return toNullable(ST_MeasurementOrPercent.$, ST_MeasurementOrPercent.b(a.value));
    }
}
ST_MeasurementOrPercent.$t = markStruct(ST_MeasurementOrPercent, 'ST_MeasurementOrPercent');
//# sourceMappingURL=ST_MeasurementOrPercent.js.map