/*
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 { Frame } from "./Frame";
import { Rect } from "igniteui-react-core/ES2015/Rect";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
import { Array_$type, Number_$type, Point_$type, typeCast, markType } from "igniteui-react-core/ES2015/type";
export class CategoryFrame extends Frame {
    constructor(a) {
        super();
        this.z = null;
        this.f = new List$1(Array_$type, 0);
        this.k = new List$1(Number_$type, 0);
        this.l = new List$1(Number_$type, 0);
        this.m = new List$1(Point_$type, 0);
        this.n = new List$1(Number_$type, 0);
        this.p = new List$1(Point_$type, 0);
        this.q = new List$1(Number_$type, 0);
        this.i = new List$1(Point_$type, 0);
        this.j = new List$1(Number_$type, 0);
        this.h = new List$1(Number_$type, 0);
        this.g = new List$1(Number_$type, 0);
        this.o = new List$1(Number_$type, 0);
        this.t = 0;
        this.s = 0;
        this.aa = null;
        this.z = new Rect(0, 0, 0, 1, 1);
        this.s = a;
        this.w();
    }
    c(a, b, c) {
        this.w();
        let d = typeCast(CategoryFrame.$, b);
        let e = typeCast(CategoryFrame.$, c);
        let f = d.f.count;
        let g = e.f.count;
        let h = Math.max(f, g);
        let i = Math.max(d.m.count, e.m.count);
        let j = Math.max(d.p.count, e.p.count);
        let k = Math.max(d.k.count, e.k.count);
        let l = Math.max(d.i.count, e.i.count);
        let m = d.o.count > 0;
        if (m) {
            this.x(this.o, a, d.o, e.o, h);
        }
        let n = d.n.count > 0;
        if (n) {
            this.x(this.n, a, d.n, e.n, i);
        }
        let o = d.q.count > 0;
        if (o) {
            this.x(this.q, a, d.q, e.q, j);
        }
        let p = d.l.count > 0;
        if (p) {
            this.x(this.l, a, d.l, e.l, k);
        }
        let q = d.j.count > 0;
        if (q) {
            this.x(this.j, a, d.j, e.j, l);
        }
        if (this.f.count < h) {
            while (this.f.count < h) {
                this.f.add(new Array(this.s));
            }
        }
        if (this.f.count > h) {
            this.f.v(h, this.f.count - h);
        }
        if (m) {
            let r = 0;
            for (let s = 0; s < Math.min(f, g); ++s) {
                let t = this.f._inner[s];
                r = a * this.o._inner[s];
                r = r > 1 ? 1 : r;
                for (let u = 0; u < this.s; ++u) {
                    t[u] = d.f._inner[s][u] + r * (e.f._inner[s][u] - d.f._inner[s][u]);
                }
            }
        }
        else {
            for (let v = 0; v < Math.min(f, g); ++v) {
                let w = this.f._inner[v];
                for (let x = 0; x < this.s; ++x) {
                    w[x] = d.f._inner[v][x] + a * (e.f._inner[v][x] - d.f._inner[v][x]);
                }
            }
        }
        if (f < g) {
            let y = new Array(this.s);
            for (let z = this.s - 1; z >= 0; --z) {
                y[z] = d.f.count > 0 ? d.f._inner[d.f.count - 1][z] : 0;
            }
            if (m) {
                let aa = 0;
                for (let ab = f; ab < g; ++ab) {
                    let ac = this.f._inner[ab];
                    aa = a * this.o._inner[ab];
                    aa = aa > 1 ? 1 : aa;
                    for (let ad = this.s - 1; ad >= 0; --ad) {
                        ac[ad] = y[ad] + aa * (e.f._inner[ab][ad] - y[ad]);
                    }
                }
            }
            else {
                for (let ae = f; ae < g; ++ae) {
                    let af = this.f._inner[ae];
                    for (let ag = this.s - 1; ag >= 0; --ag) {
                        af[ag] = y[ag] + a * (e.f._inner[ae][ag] - y[ag]);
                    }
                }
            }
        }
        if (f > g) {
            let ah = new Array(this.s);
            for (let ai = this.s - 1; ai >= 0; --ai) {
                ah[ai] = e.f.count > 0 ? e.f._inner[e.f.count - 1][ai] : 0;
            }
            if (m) {
                let aj = 0;
                for (let ak = g; ak < f; ++ak) {
                    let al = this.f._inner[ak];
                    aj = a * this.o._inner[ak];
                    aj = aj > 1 ? 1 : aj;
                    for (let am = this.s - 1; am >= 0; --am) {
                        al[am] = d.f._inner[ak][am] + aj * (ah[am] - d.f._inner[ak][am]);
                    }
                }
            }
            else {
                for (let an = g; an < f; ++an) {
                    let ao = this.f._inner[an];
                    for (let ap = this.s - 1; ap >= 0; --ap) {
                        ao[ap] = d.f._inner[an][ap] + a * (ah[ap] - d.f._inner[an][ap]);
                    }
                }
            }
        }
        if (n) {
            Frame.d(this.m, a, d.m, e.m, this.n);
        }
        else {
            Frame.a(this.m, a, d.m, e.m);
        }
        if (o) {
            Frame.d(this.p, a, d.p, e.p, this.q);
        }
        else {
            Frame.a(this.p, a, d.p, e.p);
        }
        if (p) {
            Frame.d(this.i, a, d.i, e.i, this.l);
        }
        else {
            Frame.a(this.i, a, d.i, e.i);
        }
        if (q) {
            Frame.e(this.h, a, d.h, e.h, this.j);
            Frame.e(this.g, a, d.g, e.g, this.j);
        }
        else {
            Frame.b(this.h, a, d.h, e.h);
            Frame.b(this.g, a, d.g, e.g);
        }
        let aq = d.aa;
        let ar = e.aa;
        if (Rect.l_op_Equality(aq, null)) {
            aq = this.z;
        }
        if (Rect.l_op_Equality(ar, null)) {
            ar = this.z;
        }
        let as = aq.left + (ar.left - aq.left) * a;
        let at = aq.top + (ar.top - aq.top) * a;
        let au = Math.max(0, aq.width + (ar.width - aq.width) * a);
        let av = Math.max(0, aq.height + (ar.height - aq.height) * a);
        this.aa = new Rect(0, as, at, au, av);
    }
    x(a, b, c, d, e) {
        if (d.count == 0) {
            for (let f = 0; f < c.count; f++) {
                d.add(c._inner[f]);
            }
        }
        else {
            Frame.b(a, b, c, d);
        }
        if (a.count < e) {
            let g = a.count;
            for (let h = 0; h < e - g; h++) {
                a.add(1);
            }
        }
    }
    v() {
        this.o.clear();
        this.q.clear();
        this.n.clear();
        this.l.clear();
        this.j.clear();
    }
    u() {
        this.w();
        this.v();
        this.aa = this.z;
    }
    y() {
        this.u();
        this.f.clear();
        this.i.clear();
        this.k.clear();
        this.m.clear();
        this.p.clear();
    }
    w() {
        CategoryFrame.r++;
        if (CategoryFrame.r >= (0x7FFFFFFF - 1)) {
            CategoryFrame.r = 0;
        }
        this.t = CategoryFrame.r;
    }
}
CategoryFrame.r = 0;
CategoryFrame.$t = markType(CategoryFrame, 'CategoryFrame', Frame.$);
/*<BeginStatics Name="Infragistics.Controls.Charts.CategoryFrame" />*/
/*<EndStatics Name="Infragistics.Controls.Charts.CategoryFrame" />*/
