/*
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 { __extends } from "tslib";
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
 */
var ST_MeasurementOrPercent = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(ST_MeasurementOrPercent, _super);
    function ST_MeasurementOrPercent(a) {
        var _rest = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            _rest[_i - 1] = arguments[_i];
        }
        var _this = _super.call(this) || this;
        _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:
                {
                    var c = _rest[0];
                    _this.m = toNullable(ST_DecimalNumberOrPercent.$, c);
                    _this.n = toNullable(ST_UniversalMeasure.$, null);
                }
                break;
            case 2:
                {
                    var c = _rest[0];
                    _this.m = toNullable(ST_DecimalNumberOrPercent.$, null);
                    _this.n = toNullable(ST_UniversalMeasure.$, c);
                }
                break;
        }
        return _this;
    }
    ST_MeasurementOrPercent.prototype.equals = function (a) {
        var 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());
    };
    ST_MeasurementOrPercent.prototype.getHashCode = function () {
        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;
    };
    ST_MeasurementOrPercent.prototype.toString = function () {
        return this.r(1);
    };
    ST_MeasurementOrPercent.prototype.r = function (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();
    };
    ST_MeasurementOrPercent.prototype.o = function (a) {
        var _this = this;
        if (ST_DecimalNumberOrPercent.f(this.m, toNullable(ST_DecimalNumberOrPercent.$, null))) {
            return {
                ret: toNullable(Number_$type, ((function () { var 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
        };
    };
    ST_MeasurementOrPercent.e = function (a, b) {
        var c = ST_DecimalNumberOrPercent.j(a, b);
        if (ST_DecimalNumberOrPercent.f(c, toNullable(ST_DecimalNumberOrPercent.$, null))) {
            return ST_MeasurementOrPercent.a(c.getValueOrDefault());
        }
        var 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);
    };
    Object.defineProperty(ST_MeasurementOrPercent.prototype, "f", {
        get: function () {
            return ST_UniversalMeasure.f(this.n, toNullable(ST_UniversalMeasure.$, null));
        },
        enumerable: false,
        configurable: true
    });
    ST_MeasurementOrPercent.g = function (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);
    };
    ST_MeasurementOrPercent.h = function (a, b) {
        if (!a.hasValue) {
            return !b.hasValue;
        }
        else if (!b.hasValue) {
            return false;
        }
        return ST_MeasurementOrPercent.g(a.value, b.value);
    };
    ST_MeasurementOrPercent.i = function (a, b) {
        return !(ST_MeasurementOrPercent.g(a, b));
    };
    ST_MeasurementOrPercent.j = function (a, b) {
        if (!a.hasValue) {
            return b.hasValue;
        }
        else if (!b.hasValue) {
            return true;
        }
        return ST_MeasurementOrPercent.i(a.value, b.value);
    };
    ST_MeasurementOrPercent.a = function (a) {
        return new ST_MeasurementOrPercent(1, a);
    };
    ST_MeasurementOrPercent.p = function (a) {
        if (!a.hasValue) {
            return toNullable(ST_MeasurementOrPercent.$, null);
        }
        return toNullable(ST_MeasurementOrPercent.$, ST_MeasurementOrPercent.a(a.value));
    };
    ST_MeasurementOrPercent.b = function (a) {
        return new ST_MeasurementOrPercent(2, a);
    };
    ST_MeasurementOrPercent.q = function (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');
    return ST_MeasurementOrPercent;
}(ValueType));
export { ST_MeasurementOrPercent };
