/*
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, typeCast, fromEnum, String_$type, markType } from "./type";
import { CodeGeneratingCodeWriter } from "./CodeGeneratingCodeWriter";
import { CodeGeneratingImportManager } from "./CodeGeneratingImportManager";
import { CodeGeneratingComponentRendererDataEmitterPropertyType } from "./CodeGeneratingComponentRendererDataEmitterPropertyType";
import { JsonDictionaryValue } from "./JsonDictionaryValue";
import { HashSet$1 } from "./HashSet$1";
import { JsonDictionaryObject } from "./JsonDictionaryObject";
import { JsonDictionaryArray } from "./JsonDictionaryArray";
import { List$1 } from "./List$1";
import { CodeGeneratingComponentRendererDataEmitterItemType } from "./CodeGeneratingComponentRendererDataEmitterItemType";
import { JsonDictionaryParser } from "./JsonDictionaryParser";
/**
 * @hidden
 */
export let CodeGeneratingComponentRendererDataEmitter = /*@__PURE__*/ (() => {
    class CodeGeneratingComponentRendererDataEmitter extends Base {
        constructor(a, b) {
            super();
            this.n = null;
            this.m = null;
            this.e = null;
            this.d = null;
            this.i = ((() => {
                let $ret = new CodeGeneratingImportManager();
                $ret.packageOverride = "./SampleData";
                return $ret;
            })());
            this.j = new CodeGeneratingImportManager();
            this.c = null;
            this.n = a;
            this.m = b;
            this.e = new CodeGeneratingCodeWriter(this.n);
            this.d = new CodeGeneratingCodeWriter(this.n);
            this.c = new CodeGeneratingCodeWriter(this.n);
        }
        t(a, b = false) {
            return a;
        }
        s(a) {
            return a;
        }
        get h() {
            return this.e;
        }
        get g() {
            return this.d;
        }
        get k() {
            return this.i;
        }
        get l() {
            return this.j;
        }
        set l(a) {
            this.j = a;
        }
        get f() {
            return this.c;
        }
        set f(a) {
            this.c = a;
        }
        r(a, b) {
            return null;
        }
        get_q() {
            return "";
        }
        get q() {
            return this.get_q();
        }
        x(a) {
            if (a != null) {
                let b = a;
                let c = b.e();
                for (let d = 0; d < c.length; d++) {
                    let e = c[d];
                    let f = b.item(e);
                    if (typeCast(JsonDictionaryValue.$, f) !== null) {
                        let g = f;
                        this.ad(e, g);
                    }
                    else if (typeCast(JsonDictionaryArray.$, f) !== null) {
                        let h = f;
                        this.ab(e, h, this.h, this.k);
                        this.ac(e);
                    }
                    else {
                        let i = f;
                        let j = this.a(i);
                        let k = this.b(i);
                        let l = this.p(this.t(e, true), this.t(e), j, k);
                        for (let m of fromEnum(l)) {
                            this.y(m, this.h, this.k);
                        }
                        this.ae(e, j, k, i);
                    }
                }
            }
            let n = new HashSet$1(String_$type, 0);
            for (let o = 0; o < this.m.q.count; o++) {
                let p = this.m.q._inner[o];
                if (p.a != null && p.c == null) {
                    if (this.n.library != null && this.n.library.hasItem(p.a.e)) {
                        if (n.contains(p.a.e)) {
                            continue;
                        }
                        n.add_1(p.a.e);
                        let q = this.n.library.getItem(p.a.e);
                        if (q.type == 0) {
                            let r = new CodeGeneratingCodeWriter(this.n);
                            let s = new CodeGeneratingImportManager();
                            let t = q.name;
                            let u = q.getContentForPlatform(this.m.platform);
                            if (u.isJson) {
                                let v = new JsonDictionaryParser();
                                let w = v.parse(u.content);
                                this.aa(r);
                                this.ab(t, w, r, s);
                                this.z(r);
                                this.ac(t);
                            }
                            else {
                                let x = u.content;
                                this.v(t, s);
                                r.j(x);
                                this.ac(t);
                            }
                            this.w(t, s);
                            this.m.addContainerNewFileResult(t + this.q, r.toString());
                        }
                    }
                }
            }
            this.m.addContainerResult("vmProperties", this.g.toString());
            this.m.addImportResult("vmImports", this.k);
            this.m.addImportResult("vmLibraryImports", this.l);
            this.m.addContainerResult("vmLibraryProjectFiles", this.f.toString());
            this.m.addContainerResult("vmData", this.h.toString());
        }
        z(a) {
        }
        aa(a) {
        }
        w(a, b) {
        }
        v(a, b) {
        }
        ae(a, b, c, d) {
        }
        ac(a) {
        }
        ad(a, b) {
        }
        ab(a, b, c, d) {
            if (typeCast(JsonDictionaryArray.$, b) !== null) {
                let e = b;
                if (e.items != null && e.items.length > 0) {
                    let f = this.o(e.items);
                    if (f != null) {
                        let g = this.a(f);
                        let h = this.b(f);
                        if (g != null) {
                            this.ag(a, g, h, c, d);
                            for (let i = 0; i < e.items.length; i++) {
                                this.u(a, g, h, e.items[i], i, c);
                            }
                            this.af(a, g, h, c);
                        }
                    }
                }
            }
        }
        af(a, b, c, d) {
        }
        y(a, b, c) {
        }
        p(a, b, c, d) {
            let e = new List$1(CodeGeneratingComponentRendererDataEmitterItemType.$, 0);
            let f = new CodeGeneratingComponentRendererDataEmitterItemType();
            f.d = a;
            f.c = b;
            f.a = c;
            f.b = d;
            e.add(f);
            for (let g = 0; g < c.length; g++) {
                let h = c[g];
                let i = d[g];
                if (i.f) {
                    let j = this.p(this.t(a) + "_" + h, this.t(a) + "_" + h, i.a, i.b);
                    e.o(j);
                }
                else if (i.d) {
                    let k = this.p(this.t(a) + "_" + h + "Item", this.t(a) + "_" + h, i.a, i.b);
                    e.o(k);
                }
            }
            return e;
        }
        u(a, b, c, d, e, f) {
        }
        ag(a, b, c, d, e) {
        }
        b(a) {
            let b = new List$1(CodeGeneratingComponentRendererDataEmitterPropertyType.$, 0);
            if (typeCast(JsonDictionaryObject.$, a) !== null) {
                let c = a;
                let d = c.e();
                for (let f = 0; f < d.length; f++) {
                    let e = d[f];
                    let g = c.item(e);
                    let h = new CodeGeneratingComponentRendererDataEmitterPropertyType();
                    if (typeCast(JsonDictionaryObject.$, g) !== null) {
                        h.f = true;
                        let i = this.a(g);
                        let j = this.b(g);
                        h.a = i;
                        h.b = j;
                    }
                    else if (typeCast(JsonDictionaryArray.$, g) !== null) {
                        h.d = true;
                        let k = g;
                        if (k.items != null && k.items.length > 0) {
                            let l = this.o(k.items);
                            let m = this.a(l);
                            let n = this.b(l);
                            h.a = m;
                            h.b = n;
                        }
                    }
                    else {
                        let o = g;
                        h.c = o.e;
                    }
                    b.add(h);
                }
                return b.toArray();
            }
            return null;
        }
        a(a) {
            if (typeCast(JsonDictionaryObject.$, a) !== null) {
                let b = a;
                return b.e();
            }
            return null;
        }
        o(a) {
            for (let b = 0; b < a.length; b++) {
                if (a[b] != null) {
                    let c = this.b(a[b]);
                    if (c == null) {
                        continue;
                    }
                    let d = true;
                    for (let e = 0; e < c.length; e++) {
                        if (!c[e].e()) {
                            d = false;
                        }
                    }
                    if (!d) {
                        continue;
                    }
                    return a[b];
                }
            }
            return null;
        }
    }
    CodeGeneratingComponentRendererDataEmitter.$t = markType(CodeGeneratingComponentRendererDataEmitter, 'CodeGeneratingComponentRendererDataEmitter');
    return CodeGeneratingComponentRendererDataEmitter;
})();
