/*
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 { Rect } from "igniteui-react-core/ES2015/Rect";
import { Base, Point_$type, markType } from "igniteui-react-core/ES2015/type";
import { Random } from "igniteui-react-core/ES2015/Random";
import { isNaN_, isInfinity } from "igniteui-react-core/ES2015/number";
export class CategoryTransitionSourceFramePreparer extends Base {
    constructor() {
        super(...arguments);
        this.a = new Random(0);
    }
    p(a, b, c, d, e, f, g, h, i, j, k) {
        a.aa = new Rect(0, 0, 0, 1, 1);
        a.f.clear();
        a.k.clear();
        a.m.clear();
        a.p.clear();
        a.i.clear();
        a.h.clear();
        a.g.clear();
        let l = false;
        let m = false;
        if (e != null) {
            l = e.b8;
        }
        if (d != null) {
            m = d.b8;
        }
        let n = f;
        if (n == 0) {
            n = g;
        }
        switch (n) {
            case 1:
                let o = j();
                this.t(a, b, o, c);
                break;
            case 7:
                this.r(a, b, false, c, k);
                break;
            case 9:
                this.s(a, b, true, c, k);
                break;
            case 10:
                this.s(a, b, false, c, k);
                break;
            case 8:
                this.r(a, b, true, c, k);
                break;
            case 2:
                this.u(a, b, false);
                break;
            case 3:
                this.u(a, b, true);
                break;
            case 4:
                this.v(a, b, true);
                break;
            case 5:
                this.v(a, b, false);
                break;
            case 6:
                this.j(a, b);
                a.aa = new Rect(0, 0.5, 0.5, 0, 0);
                break;
            case 16:
                if (c) {
                    this.s(a, b, l, c, k);
                }
                else {
                    this.r(a, b, m, c, k);
                }
                break;
            case 17:
                if (c) {
                    this.s(a, b, !l, c, k);
                }
                else {
                    this.r(a, b, !m, c, k);
                }
                break;
            case 18:
                if (c) {
                    this.r(a, b, m, c, k);
                }
                else {
                    this.s(a, b, l, c, k);
                }
                break;
            case 19:
                if (c) {
                    this.r(a, b, !m, c, k);
                }
                else {
                    this.s(a, b, !l, c, k);
                }
                break;
            case 12:
                if (c) {
                    this.v(a, b, l);
                }
                else {
                    this.u(a, b, m);
                }
                break;
            case 13:
                if (c) {
                    this.v(a, b, !l);
                }
                else {
                    this.u(a, b, !m);
                }
                break;
            case 14:
                if (c) {
                    this.u(a, b, m);
                }
                else {
                    this.v(a, b, l);
                }
                break;
            case 15:
                if (c) {
                    this.u(a, b, !m);
                }
                else {
                    this.v(a, b, !l);
                }
                break;
            case 11:
                this.q(a, b);
                break;
        }
        if (h == 0) {
            h = i;
        }
        a.v();
        b.v();
        switch (h) {
            case 3:
                this.b(a.f.count, n, a.o, b.o, d, e, c, k);
                this.b(a.m.count, n, a.n, b.n, d, e, c, k);
                this.b(a.p.count, n, a.q, b.q, d, e, c, k);
                this.b(a.i.count, n, a.l, b.l, d, e, c, k);
                this.b(a.h.count, n, a.j, b.j, d, e, c, k);
                break;
            case 2:
                let p = j();
                this.d(a.f.count, p, n, a.f, b.f, a.o, b.o, d, e, c, k);
                this.f(a.m.count, p, n, a.m, b.m, a.n, b.n, d, e, c, k);
                this.f(a.p.count, p, n, a.p, b.p, a.q, b.q, d, e, c, k);
                this.f(a.i.count, p, n, a.i, b.i, a.l, b.l, d, e, c, k);
                this.e(a.h.count, p, n, a.h, b.h, a.j, b.j, d, e, c, k);
                break;
            case 4:
                this.c(a.f.count, n, a.o, b.o);
                this.c(a.m.count, n, a.n, b.n);
                this.c(a.p.count, n, a.q, b.q);
                this.c(a.i.count, n, a.l, b.l);
                this.c(a.h.count, n, a.j, b.j);
                break;
        }
    }
    c(a, b, c, d) {
        if (a == 0) {
            return;
        }
        for (let e = 0; e < a; e++) {
            c.add(1 + this.a.nextDouble());
            d.add(1 + this.a.nextDouble());
        }
    }
    d(a, b, c, d, e, f, g, h, i, j, k) {
        if (a == 0) {
            return;
        }
        let l = false;
        let m = i;
        if (j) {
            m = h;
        }
        if (m != null) {
            l = m.b8;
        }
        let n = k.bottom;
        let o = k.bottom;
        let p = k.top;
        if (j) {
            o = k.right;
            p = k.left;
        }
        if (l) {
            o = k.top;
            p = k.bottom;
            if (j) {
                o = k.left;
                p = k.right;
            }
        }
        b = Math.max(b, Math.min(p, o));
        b = Math.min(b, Math.max(p, o));
        n = 0;
        let q;
        for (let r = 0; r < a; r++) {
            q = e._inner[r];
            for (let s = 1; s < q.length; s++) {
                if (isNaN_(q[s]) || isInfinity(q[s])) {
                    continue;
                }
                n = Math.max(n, Math.abs(b - q[s]));
            }
        }
        let t;
        let u;
        let v;
        for (let w = 0; w < a; w++) {
            q = e._inner[w];
            t = Math.abs(q[1] - b);
            u = Math.abs(q[1] - b);
            for (let x = 1; x < q.length; x++) {
                if (isNaN_(q[x]) || isInfinity(q[x])) {
                    continue;
                }
                t = Math.max(Math.abs(q[x] - b), t);
                u = Math.min(Math.abs(q[x] - b), u);
            }
            let y = (t + u) / 2;
            if (isNaN_(y) || n == 0) {
                v = 1;
            }
            else {
                v = y / n;
            }
            f.add(2 - v);
            g.add(2 - v);
        }
    }
    f(a, b, c, d, e, f, g, h, i, j, k) {
        if (a == 0) {
            return;
        }
        let l = false;
        let m = i;
        if (j) {
            m = h;
        }
        if (m != null) {
            l = m.b8;
        }
        let n = k.bottom;
        let o = k.bottom;
        let p = k.top;
        if (j) {
            o = k.right;
            p = k.left;
        }
        if (l) {
            o = k.top;
            p = k.bottom;
            if (j) {
                o = k.left;
                p = k.right;
            }
        }
        b = Math.max(b, Math.min(p, o));
        b = Math.min(b, Math.max(p, o));
        n = 0;
        let q;
        for (let r = 0; r < a; r++) {
            q = e._inner[r];
            if (j) {
                if (isNaN_(q.x) || isInfinity(q.x)) {
                    continue;
                }
                n = Math.max(n, Math.abs(q.x - b));
            }
            else {
                if (isNaN_(q.y) || isInfinity(q.y)) {
                    continue;
                }
                n = Math.max(n, Math.abs(q.y - b));
            }
        }
        let s;
        for (let t = 0; t < a; t++) {
            q = e._inner[t];
            let u;
            if (j) {
                u = q.x;
            }
            else {
                u = q.y;
            }
            if (isNaN_(u) || isInfinity(u) || n == 0) {
                s = 1;
            }
            else {
                s = Math.abs(u - b) / n;
            }
            f.add(2 - s);
            g.add(2 - s);
        }
    }
    e(a, b, c, d, e, f, g, h, i, j, k) {
        if (a == 0) {
            return;
        }
        let l = false;
        let m = i;
        if (j) {
            m = h;
        }
        if (m != null) {
            l = m.b8;
        }
        let n = k.bottom;
        let o = k.bottom;
        let p = k.top;
        if (j) {
            o = k.right;
            p = k.left;
        }
        if (l) {
            o = k.top;
            p = k.bottom;
            if (j) {
                o = k.left;
                p = k.right;
            }
        }
        b = Math.max(b, Math.min(p, o));
        b = Math.min(b, Math.max(p, o));
        n = 0;
        let q;
        for (let r = 0; r < a; r++) {
            q = e._inner[r];
            if (isNaN_(q) || isInfinity(q)) {
                continue;
            }
            n = Math.max(n, Math.abs(q - b));
        }
        let s;
        for (let t = 0; t < a; t++) {
            q = e._inner[t];
            let u;
            u = q;
            if (n == 0 || isNaN_(u) || isInfinity(u)) {
                s = 1;
            }
            else {
                s = Math.abs(u - b) / n;
            }
            f.add(2 - s);
            g.add(2 - s);
        }
    }
    b(a, b, c, d, e, f, g, h) {
        if (a == 0) {
            return;
        }
        let i = e;
        if (g) {
            i = f;
        }
        let j = false;
        if (i != null) {
            j = i.b8;
        }
        let k;
        for (let l = 0; l < a; l++) {
            if (a == 1) {
                k = 1;
            }
            else {
                k = l / (a - 1);
            }
            k = 1 - k;
            c.add(1 + k);
            d.add(1 + k);
        }
    }
    q(a, b) {
        a.f.clear();
        a.k.clear();
        a.m.clear();
        a.p.clear();
        a.i.clear();
        a.h.clear();
        a.g.clear();
        this.g(a.f, b.f);
        this.h(a.k, b.k);
        this.k(a.m, b.m);
        this.k(a.p, b.p);
        this.k(a.i, b.i);
        this.h(a.h, b.h);
        this.h(a.g, b.g);
        let c = a.f.count;
        let d = a.f;
        let e;
        let f;
        let g;
        let h;
        for (let i = 0; i < c; i++) {
            e = d._inner[i];
            f = e[1];
            g = e[1];
            for (let j = 2; j < e.length; j++) {
                f = Math.min(f, e[j]);
                g = Math.max(g, e[j]);
            }
            h = (f + g) / 2;
            for (let k = 1; k < e.length; k++) {
                e[k] = h;
            }
        }
        let l = a.h.count;
        let m = a.h;
        let n = a.g;
        for (let o = 0; o < l; o++) {
            m._inner[o] = 0;
            n._inner[o] = 0;
        }
    }
    u(a, b, c) {
        if (c) {
            this.j(a, b);
            a.aa = new Rect(0, 1, 0, 0, 1);
        }
        else {
            this.j(a, b);
            a.aa = new Rect(0, 0, 0, 0, 1);
        }
    }
    v(a, b, c) {
        if (c) {
            this.j(a, b);
            a.aa = new Rect(0, 0, 0, 1, 0);
        }
        else {
            this.j(a, b);
            a.aa = new Rect(0, 0, 1, 1, 0);
        }
    }
    j(a, b) {
        a.f.clear();
        a.k.clear();
        a.m.clear();
        a.p.clear();
        a.i.clear();
        a.h.clear();
        a.g.clear();
        this.g(a.f, b.f);
        this.h(a.k, b.k);
        this.k(a.m, b.m);
        this.k(a.p, b.p);
        this.k(a.i, b.i);
        this.h(a.h, b.h);
        this.h(a.g, b.g);
    }
    o(a, b, c, d, e) {
        let f = b.count;
        let g;
        let h;
        for (let i = 0; i < f; i++) {
            g = b._inner[i];
            if (e) {
                if (c) {
                    h = { $type: Point_$type, x: d, y: g.y };
                }
                else {
                    h = { $type: Point_$type, x: g.x, y: d };
                }
            }
            else {
                if (c) {
                    h = { $type: Point_$type, x: g.x, y: d };
                }
                else {
                    h = { $type: Point_$type, x: d, y: g.y };
                }
            }
            a.add(h);
        }
    }
    k(a, b) {
        let c = b.count;
        let d;
        let e;
        for (let f = 0; f < c; f++) {
            d = b._inner[f];
            e = { $type: Point_$type, x: d.x, y: d.y };
            a.add(e);
        }
    }
    g(a, b) {
        let c = b.count;
        let d = b;
        let e;
        let f;
        let g = a;
        for (let h = 0; h < c; h++) {
            f = d._inner[h];
            e = new Array(f.length);
            for (let i = 0; i < e.length; i++) {
                e[i] = f[i];
            }
            g.add(e);
        }
    }
    l(a, b, c, d, e) {
        let f = b.count;
        let g = b;
        let h;
        let i;
        let j = a;
        for (let k = 0; k < f; k++) {
            i = g._inner[k];
            h = new Array(i.length);
            if (e) {
                h[0] = i[0];
                for (let l = 1; l < h.length; l++) {
                    h[l] = d;
                }
            }
            else {
                h[0] = d;
                for (let m = 1; m < h.length; m++) {
                    h[m] = i[m];
                }
            }
            j.add(h);
        }
    }
    n(a, b) {
        let c = b.count;
        let d;
        for (let e = 0; e < c; e++) {
            d = b._inner[e];
            a.add(d);
        }
    }
    i(a, b) {
        let c = b.count;
        let d;
        for (let e = 0; e < c; e++) {
            d = b._inner[e];
            a.add(d);
        }
    }
    h(a, b) {
        let c = b.count;
        let d;
        for (let e = 0; e < c; e++) {
            d = b._inner[e];
            a.add(d);
        }
    }
    m(a, b, c, d, e) {
        let f = b.count;
        let g;
        for (let h = 0; h < f; h++) {
            g = b._inner[h];
            a.add(g);
        }
    }
    r(a, b, c, d, e) {
        let f = e.right;
        if (!c) {
            f = e.left;
        }
        let g = false;
        if (d) {
            g = true;
        }
        this.l(a.f, b.f, d, f, g);
        this.m(a.k, b.k, d, f, g);
        this.o(a.m, b.m, d, f, g);
        this.o(a.p, b.p, d, f, g);
        this.o(a.i, b.i, d, f, g);
        this.m(a.h, b.h, d, f, g);
        this.m(a.g, b.g, d, f, g);
    }
    s(a, b, c, d, e) {
        let f = e.bottom;
        if (c) {
            f = e.top;
        }
        let g = true;
        if (d) {
            g = false;
        }
        this.l(a.f, b.f, d, f, g);
        this.m(a.k, b.k, d, f, g);
        this.o(a.m, b.m, d, f, g);
        this.o(a.p, b.p, d, f, g);
        this.o(a.i, b.i, d, f, g);
        this.m(a.h, b.h, d, f, g);
        this.m(a.g, b.g, d, f, g);
    }
    t(a, b, c, d) {
        this.l(a.f, b.f, d, c, true);
        this.m(a.k, b.k, d, c, true);
        this.o(a.m, b.m, d, c, true);
        this.o(a.p, b.p, d, c, true);
        this.o(a.i, b.i, d, c, true);
        this.m(a.h, b.h, d, c, true);
        this.m(a.g, b.g, d, c, true);
    }
}
CategoryTransitionSourceFramePreparer.$t = markType(CategoryTransitionSourceFramePreparer, 'CategoryTransitionSourceFramePreparer');
