/*
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, String_$type, markType } from "igniteui-angular-core";
import { ArgumentOutOfRangeException } from "igniteui-angular-core";
import { DivideByZeroException } from "./DivideByZeroException";
import { MathUtilities } from "./MathUtilities";
import { List$1 } from "igniteui-angular-core";
import { log10, logBase, isInfinity, isNaN_ } from "igniteui-angular-core";
import { stringReplace, stringContains, stringEmpty, stringToCharArray, stringCompare } from "igniteui-angular-core";
import { numberToString2 } from "igniteui-angular-core";
import { stringFormat } from "igniteui-angular-core";
/**
 * @hidden
 */
export class UltraCalcFunctionComplex_ComplexNumber extends Base {
    constructor(a, ..._rest) {
        super();
        this.ai = 0;
        this.ae = 0;
        this.am = null;
        this.x = false;
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0:
                {
                    let c = _rest[0];
                    let d = _rest[1];
                    let e = _rest[2];
                    let f = [c, d, e, true];
                    {
                        let h = f[0];
                        let i = f[1];
                        let j = f[2];
                        let k = f[3];
                        this.ai = h;
                        this.ae = i;
                        this.am = j;
                        this.x = k;
                    }
                }
                break;
            case 1:
                {
                    let c = _rest[0];
                    let d = _rest[1];
                    this.x = ((() => { let e = UltraCalcFunctionComplex_ComplexNumber.z(c, d, this.ai, this.ae, this.am); this.ai = e.p2; this.ae = e.p3; this.am = e.p4; return e.ret; })());
                }
                break;
            case 2:
                {
                    let c = _rest[0];
                    let d = _rest[1];
                    let e = _rest[2];
                    let f = _rest[3];
                    this.ai = c;
                    this.ae = d;
                    this.am = e;
                    this.x = f;
                }
                break;
        }
    }
    get aj() {
        return this.ai;
    }
    set aj(a) {
        this.ai = a;
    }
    get af() {
        return this.ae;
    }
    get an() {
        return this.am;
    }
    set an(a) {
        if (a != "i" && a != "j") {
            throw new ArgumentOutOfRangeException(0);
        }
        this.am = a;
    }
    get y() {
        if (isInfinity(this.aj) || isNaN_(this.aj)) {
            return false;
        }
        if (isInfinity(this.af) || isNaN_(this.af)) {
            return false;
        }
        return this.x;
    }
    toString() {
        if (this.y == false) {
            return "#NUM";
        }
        return UltraCalcFunctionComplex_ComplexNumber.al(this.aj, this.af, this.an);
    }
    ab() {
        return Math.sqrt(Math.pow(this.aj, 2) + Math.pow(this.af, 2));
    }
    ac() {
        if (this.af == 0 && this.aj == 0) {
            throw new DivideByZeroException(null, null);
        }
        return Math.atan2(this.af, this.aj);
    }
    c() {
        return new UltraCalcFunctionComplex_ComplexNumber(0, this.ai, -this.ae, this.am);
    }
    d() {
        let a = Math.cos(this.aj) * Math.cosh(this.af);
        let b = -(Math.sin(this.aj) * Math.sinh(this.af));
        return new UltraCalcFunctionComplex_ComplexNumber(0, a, b, this.an);
    }
    e() {
        let a = Math.pow(2.7182818284590451, this.aj);
        let b = Math.cos(this.af) * a;
        let c = Math.sin(this.af) * a;
        let d = new UltraCalcFunctionComplex_ComplexNumber(0, b, c, this.an);
        return d;
    }
    ad() {
        let a = Math.pow(this.aj, 2);
        let b = Math.pow(this.af, 2);
        let c = a + b;
        let d = Math.sqrt(c);
        return d;
    }
    m() {
        let a = this.ad();
        let b = Math.log(a);
        let c = this.ak();
        let d = new UltraCalcFunctionComplex_ComplexNumber(0, b, c, this.an);
        return d;
    }
    n() {
        return UltraCalcFunctionComplex_ComplexNumber.k(this.m(), UltraCalcFunctionComplex_ComplexNumber.ag);
    }
    o() {
        return UltraCalcFunctionComplex_ComplexNumber.k(this.m(), UltraCalcFunctionComplex_ComplexNumber.ah);
    }
    u(a) {
        let b = this.ad();
        let c = this.ak();
        let d = Math.pow(b, a);
        let e = c * a;
        let f = d * (Math.cos(e));
        let g = d * (Math.sin(e));
        return new UltraCalcFunctionComplex_ComplexNumber(0, f, g, this.an);
    }
    v() {
        let a = Math.sin(this.aj) * Math.cosh(this.af);
        let b = Math.cos(this.aj) * Math.sinh(this.af);
        return new UltraCalcFunctionComplex_ComplexNumber(0, a, b, this.an);
    }
    w() {
        let a = this.ad();
        let b = this.ak();
        let c = Math.sqrt(a);
        let d = b / 2;
        let e = c * Math.cos(d);
        let f = c * Math.sin(d);
        return new UltraCalcFunctionComplex_ComplexNumber(0, e, f, this.an);
    }
    ak() {
        return Math.atan2(this.af, this.aj);
    }
    static z(a, b, c, d, e) {
        b = stringReplace(b, " ", "");
        let f = UltraCalcFunctionComplex_ComplexNumber.b(b);
        let g = f.length;
        if (g > 2 || g <= 0) {
            c = 0;
            d = 0;
            e = "i";
            return {
                ret: false,
                p2: c,
                p3: d,
                p4: e
            };
        }
        let h;
        let i;
        let j;
        if (g == 1) {
            i = b;
            j = ((() => { let k = UltraCalcFunctionComplex_ComplexNumber.aa(a, b, d, e); d = k.p2; e = k.p3; return k.ret; })());
            if (j) {
                c = 0;
            }
            else {
                d = 0;
                j = ((() => { let k = MathUtilities.c(b, a, c); c = k.p2; return k.ret; })());
                if (j == false) {
                    return {
                        ret: false,
                        p2: c,
                        p3: d,
                        p4: e
                    };
                }
            }
        }
        else {
            h = f[0];
            i = f[1];
            j = ((() => { let k = MathUtilities.c(h, a, c); c = k.p2; return k.ret; })());
            if (j == false) {
                d = 0;
                e = "i";
                return {
                    ret: false,
                    p2: c,
                    p3: d,
                    p4: e
                };
            }
            j = ((() => { let k = UltraCalcFunctionComplex_ComplexNumber.aa(a, i, d, e); d = k.p2; e = k.p3; return k.ret; })());
            if (j == false) {
                return {
                    ret: false,
                    p2: c,
                    p3: d,
                    p4: e
                };
            }
        }
        return {
            ret: true,
            p2: c,
            p3: d,
            p4: e
        };
    }
    static aa(a, b, c, d) {
        d = stringContains(b, "j") ? "j" : "i";
        if (stringContains(b, "i") == false && stringContains(b, "j") == false) {
            c = 0;
            return {
                ret: false,
                p2: c,
                p3: d
            };
        }
        switch (b) {
            case "i":
            case "j":
            case "+i":
            case "+j":
                c = 1;
                return {
                    ret: true,
                    p2: c,
                    p3: d
                };
            case "-i":
            case "-j":
                c = -1;
                return {
                    ret: true,
                    p2: c,
                    p3: d
                };
        }
        b = stringReplace(b, "i", stringEmpty());
        b = stringReplace(b, "j", stringEmpty());
        return {
            ret: ((() => { let e = MathUtilities.c(b, a, c); c = e.p2; return e.ret; })()),
            p2: c,
            p3: d
        };
    }
    static b(a) {
        let b = new List$1(String_$type, 2, 1);
        let c = a.substr(0, 1);
        let d = stringToCharArray(a);
        for (let e = 1; e < d.length; e++) {
            let f = d[e];
            if (f == '-' || f == '+') {
                let g = d[e - 1].toString().toLowerCase();
                if (g != "e") {
                    b.add(c);
                    c = stringEmpty();
                }
            }
            c += f;
        }
        b.add(c);
        return b.toArray();
    }
    static al(a, b, c) {
        let d = "G";
        a = MathUtilities.i(a);
        b = MathUtilities.i(b);
        let e;
        if (a == 0 && b == 0) {
            e = "0";
        }
        else if (a != 0 && b == 0) {
            e = numberToString2(a, d);
        }
        else {
            let f = (b > 0) ? "+" : "-";
            let g;
            if (a != 0) {
                g = numberToString2(a, d);
            }
            else {
                g = stringEmpty();
                if (f == "+") {
                    f = stringEmpty();
                }
            }
            b = Math.abs(b);
            let h = stringFormat("{0}{1}", f, (b == 1) ? stringEmpty() : numberToString2(b, d));
            e = stringFormat("{0}{1}{2}", g, h, c);
        }
        return e;
    }
    static get g() {
        if (UltraCalcFunctionComplex_ComplexNumber.f == null) {
            UltraCalcFunctionComplex_ComplexNumber.f = new UltraCalcFunctionComplex_ComplexNumber(2, 0, 0, "i", false);
        }
        return UltraCalcFunctionComplex_ComplexNumber.f;
    }
    static i(a, b) {
        if (stringCompare(b.an, a.an) != 0) {
            return UltraCalcFunctionComplex_ComplexNumber.g;
        }
        let c = Math.pow(b.aj, 2) + Math.pow(b.af, 2);
        let d = ((a.aj * b.aj) + (a.af * b.af)) / c;
        let e = ((a.af * b.aj) - (a.aj * b.af)) / c;
        let f = new UltraCalcFunctionComplex_ComplexNumber(0, d, e, a.an);
        return f;
    }
    static j(a, b) {
        if (stringCompare(a.an, b.an) != 0) {
            return UltraCalcFunctionComplex_ComplexNumber.g;
        }
        let c = ((a.aj * b.aj) - (a.af * b.af));
        let d = ((a.aj * b.af) + (a.af * b.aj));
        let e = new UltraCalcFunctionComplex_ComplexNumber(0, c, d, a.an);
        return e;
    }
    static k(a, b) {
        let c = a.an;
        let d = a.aj * b;
        let e = a.af * b;
        return new UltraCalcFunctionComplex_ComplexNumber(0, d, e, c);
    }
    static h(a, b) {
        if (stringCompare(a.an, b.an) != 0) {
            return UltraCalcFunctionComplex_ComplexNumber.g;
        }
        let c = a.aj + b.aj;
        let d = a.af + b.af;
        let e = new UltraCalcFunctionComplex_ComplexNumber(0, c, d, a.an);
        return e;
    }
    static l(a, b) {
        if (stringCompare(a.an, b.an) != 0) {
            return UltraCalcFunctionComplex_ComplexNumber.g;
        }
        let c = a.aj - b.aj;
        let d = a.af - b.af;
        let e = new UltraCalcFunctionComplex_ComplexNumber(0, c, d, a.an);
        return e;
    }
}
UltraCalcFunctionComplex_ComplexNumber.$t = markType(UltraCalcFunctionComplex_ComplexNumber, 'UltraCalcFunctionComplex_ComplexNumber');
UltraCalcFunctionComplex_ComplexNumber.f = null;
UltraCalcFunctionComplex_ComplexNumber.a = ['+', '-'];
UltraCalcFunctionComplex_ComplexNumber.ag = log10(2.7182818284590451);
UltraCalcFunctionComplex_ComplexNumber.ah = logBase(2.7182818284590451, 2);
//# sourceMappingURL=UltraCalcFunctionComplex_ComplexNumber.js.map