/*
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, Base, toNullable, typeCast, Number_$type, markStruct } from "igniteui-angular-core";
import { DocCoreUtils } from "./DocCoreUtils";
import { CultureInfo } from "igniteui-angular-core";
import { truncate } from "igniteui-angular-core";
import { tryParseNumber1 } from "igniteui-angular-core";
/**
 * @hidden
 */
export class ST_UniversalMeasure extends ValueType {
    constructor(a, ..._rest) {
        super();
        this.a = 0;
        this.j = 0;
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0: break;
            case 1:
                {
                    let c = _rest[0];
                    let d = _rest[1];
                    this.j = c;
                    this.a = d;
                }
                break;
        }
    }
    equals(a) {
        let b = toNullable(ST_UniversalMeasure.$, typeCast(ST_UniversalMeasure.$, a));
        if (ST_UniversalMeasure.f(b, toNullable(ST_UniversalMeasure.$, null))) {
            return false;
        }
        return ST_UniversalMeasure.c(this, b.getValueOrDefault());
    }
    getHashCode() {
        return Base.getHashCodeStatic(this.a) << 16 ^ (this.j);
    }
    toString() {
        return ST_UniversalMeasure.p(this.j, this.a);
    }
    n() {
        return toNullable(Number_$type, this.k());
    }
    m() {
        return DocCoreUtils.t(this.k());
    }
    k() {
        return ST_UniversalMeasure.l(this.j, this.a);
    }
    static o(a) {
        let b;
        let c;
        if (((() => { let d = ST_UniversalMeasure.i(a, b, c); b = d.p1; c = d.p2; return d.ret; })()) == false || b < 0) {
            return toNullable(ST_UniversalMeasure.$, null);
        }
        return toNullable(ST_UniversalMeasure.$, new ST_UniversalMeasure(1, b, c));
    }
    static l(a, b) {
        let c = 20;
        let d = 72;
        let e = 2.54;
        let f = 10;
        let g = 12;
        let t1 = b;
        L0: while (true) {
            switch (t1) {
                case 0:
                    a /= e;
                    t1 = 2;
                    continue L0;
                case 2:
                    a *= d;
                    t1 = 3;
                    continue L0;
                case 1:
                    a /= f;
                    t1 = 0;
                    continue L0;
                case 3: return (a * c);
                case 4:
                case 5:
                    a /= g;
                    t1 = 3;
                    continue L0;
                default: return truncate((a));
            }
            break;
        }
    }
    static i(a, b, c) {
        b = 0;
        c = 0;
        if (a.length < 3) {
            return {
                ret: false,
                p1: b,
                p2: c
            };
        }
        let d = a.substr(0, a.length - 2);
        let e = a.substr(a.length - 2);
        switch (e) {
            case "cm":
                c = 0;
                break;
            case "mm":
                c = 1;
                break;
            case "in":
                c = 2;
                break;
            case "pt":
                c = 3;
                break;
            case "pc":
                c = 4;
                break;
            case "pi":
                c = 5;
                break;
            default: return {
                ret: false,
                p1: b,
                p2: c
            };
        }
        if (((() => { let f = tryParseNumber1(d, 167 | 64, CultureInfo.invariantCulture, b); b = f.p3; return f.ret; })()) == false) {
            return {
                ret: false,
                p1: b,
                p2: c
            };
        }
        return {
            ret: true,
            p1: b,
            p2: c
        };
    }
    static p(a, b) {
        let c;
        switch (b) {
            case 0:
                c = "cm";
                break;
            case 2:
                c = "in";
                break;
            case 1:
                c = "mm";
                break;
            case 3:
                c = "pt";
                break;
            case 4:
                c = "pc";
                break;
            case 5:
                c = "pi";
                break;
            default:
                c = "pt";
                break;
        }
        return a.toString() + c;
    }
    static b(a, b) {
        return a.a == b.a && a.j == b.j;
    }
    static c(a, b) {
        return a.a == b.a && a.j == b.j;
    }
    static d(a, b) {
        if (!a.hasValue) {
            return !b.hasValue;
        }
        else if (!b.hasValue) {
            return false;
        }
        return ST_UniversalMeasure.c(a.value, b.value);
    }
    static e(a, b) {
        return !(ST_UniversalMeasure.c(a, b));
    }
    static f(a, b) {
        if (!a.hasValue) {
            return b.hasValue;
        }
        else if (!b.hasValue) {
            return true;
        }
        return ST_UniversalMeasure.e(a.value, b.value);
    }
}
ST_UniversalMeasure.$t = markStruct(ST_UniversalMeasure, 'ST_UniversalMeasure');
//# sourceMappingURL=ST_UniversalMeasure.js.map