/*
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, IEnumerable_$type, fromEnum, typeCast, Date_$type, Boolean_$type, Array_$type, runOn, Number_$type, Delegate_$type, String_$type, markType } from "./type";
import { TypeDescriptionContext } from "./TypeDescriptionContext";
import { TypeDescriptionCleanups } from "./TypeDescriptionCleanups";
import { Dictionary$2 } from "./Dictionary$2";
import { Description } from "./Description";
import { DescriptionTreeNode } from "./DescriptionTreeNode";
import { Queue$1 } from "./Queue$1";
import { DescriptionTreeAction } from "./DescriptionTreeAction";
import { List$1 } from "./List$1";
import { DescriptionRef } from "./DescriptionRef";
import { TypeDescriptionPropretyTransforms } from "./TypeDescriptionPropretyTransforms";
import { DescriptionSerializerBuilder } from "./DescriptionSerializerBuilder";
import { DescriptionSerializer } from "./DescriptionSerializer";
import { DataSourceLocalDataProvider } from "./DataSourceLocalDataProvider";
import { JsonDictionaryParser } from "./JsonDictionaryParser";
import { DescriptionTreeBuilder } from "./DescriptionTreeBuilder";
import { JsonDictionaryObject } from "./JsonDictionaryObject";
import { JsonDictionaryValue } from "./JsonDictionaryValue";
import { JsonDictionaryArray } from "./JsonDictionaryArray";
import { TypeDescriptionMetadata } from "./TypeDescriptionMetadata";
import { DescriptionTreeReconciler } from "./DescriptionTreeReconciler";
import { HashSet$1 } from "./HashSet$1";
import { Tuple$2 } from "./Tuple$2";
import { DescriptionRefTargetInfo } from "./DescriptionRefTargetInfo";
import { NotImplementedException } from "./NotImplementedException";
import { ComponentRendererAdapter } from "./ComponentRendererAdapter";
import { stringIsNullOrEmpty, stringStartsWith, stringEndsWith } from "./string";
/**
 * @hidden
 */
export let ComponentRenderer = /*@__PURE__*/ (() => {
    class ComponentRenderer extends Base {
        constructor() {
            super();
            this._adapter = null;
            this._context = null;
            this._isProceedOnErrorEnabled = false;
            this.i = null;
            this.j = null;
            this.aw = new Dictionary$2(Base.$, Description.$, 0);
            this.ax = new Dictionary$2(Base.$, Boolean_$type, 0);
            this.ay = new Dictionary$2(Base.$, Boolean_$type, 0);
            this.av = new Dictionary$2(Base.$, Boolean_$type, 0);
            this.at = new Dictionary$2(Base.$, DescriptionTreeNode.$, 0);
            this.a1 = new Dictionary$2(Base.$, ContainerState.$, 0);
            this.az = new Dictionary$2(Base.$, Queue$1.$.specialize(Queue$1.$.specialize(DescriptionTreeAction.$)), 0);
            this.au = new Dictionary$2(Base.$, List$1.$.specialize(Delegate_$type), 0);
            this.as = new Dictionary$2(Base.$, Boolean_$type, 0);
            this.a0 = new Dictionary$2(String_$type, DescriptionRef.$, 0);
            this.a2 = new Dictionary$2(String_$type, Base.$, 0);
            this.a4 = new Dictionary$2(String_$type, Base.$, 0);
            this.a8 = new List$1(Delegate_$type, 0);
            this.a3 = new Dictionary$2(String_$type, List$1.$.specialize(Delegate_$type), 0);
            this.a6 = new List$1(Delegate_$type, 0);
            this.a7 = new List$1(Delegate_$type, 0);
            this._shouldNamespaceSystemRefValues = false;
            let a = this.h();
            this.adapter = a;
            let adapter_ = this.adapter;
            let b = (adapter_._platform);
            if (b == "Igc") {
                ComponentRenderer.platform = 4;
            }
            else if (b == "Igr") {
                ComponentRenderer.platform = 2;
            }
            this.context = new TypeDescriptionContext(this.adapter, ComponentRenderer.platform);
            this.i = new TypeDescriptionPropretyTransforms();
            this.j = new TypeDescriptionCleanups();
        }
        static get defaultInstance() {
            return ComponentRenderer._defaultInstance;
        }
        static set defaultInstance(a) {
            ComponentRenderer._defaultInstance = a;
        }
        get adapter() {
            return this._adapter;
        }
        set adapter(a) {
            this._adapter = a;
        }
        get context() {
            return this._context;
        }
        set context(a) {
            this._context = a;
        }
        get isProceedOnErrorEnabled() {
            return this._isProceedOnErrorEnabled;
        }
        set isProceedOnErrorEnabled(a) {
            this._isProceedOnErrorEnabled = a;
        }
        h() {
            return (new ComponentRendererAdapter());
        }
        toJson(a) {
            let b = new DescriptionSerializerBuilder();
            let c = new DescriptionSerializer();
            b.f("{");
            b.i();
            b.f("\"descriptions\": {");
            b.i();
            let d = true;
            for (let e of fromEnum(this.at.keys)) {
                if (d) {
                    d = false;
                }
                else {
                    b.f(",");
                }
                let f = e;
                let g = this.at.item(e);
                let h = "root";
                h = a(f);
                if (stringIsNullOrEmpty(h)) {
                    h = "root";
                }
                b.e("\"" + h + "\"");
                b.e(": ");
                c.t(this.context, g, b);
            }
            b.f("");
            b.h();
            b.e("}");
            if (this.a4.count > 0) {
                b.e(",");
            }
            b.f("");
            if (this.a4.count > 0) {
                d = true;
                b.f("refs: {");
                b.i();
                for (let i of fromEnum(this.a4.keys)) {
                    if (!this.o(i, this.a4.item(i))) {
                        continue;
                    }
                    if (d) {
                        d = false;
                    }
                    else {
                        b.f(",");
                    }
                    this.dh(b, i, this.a4.item(i));
                }
                b.f("");
                b.h();
                b.f("}");
            }
            b.h();
            b.f("}");
            return b.toString();
        }
        dh(a, b, c) {
            a.e("\"" + b + "\": ");
            this.di(a, c);
        }
        di(a, b) {
            if (this.x(b)) {
                if (typeof b === 'string') {
                    a.e(b == null ? "null" : "\"" + b.toString() + "\"");
                }
                else if (typeof b === 'number') {
                    a.e(b == null ? "null" : b.toString());
                }
                else if (typeof b === 'number') {
                    a.e(b == null ? "null" : b.toString());
                }
                else if (typeof b === 'number') {
                    a.e(b == null ? "null" : b.toString());
                }
                else if (typeof b === 'number') {
                    a.e(b == null ? "null" : b.toString());
                }
                else if (typeof b === 'number') {
                    a.e(b == null ? "null" : b.toString());
                }
                else if (typeof b === 'number') {
                    a.e(b == null ? "null" : b.toString());
                }
                else if (typeof b === 'number') {
                    a.e(b == null ? "null" : b.toString());
                }
                else if (typeCast(Date_$type, b) !== null) {
                    let v_ = b;
                    a.e("\"" + (v_.toJSON()) + "\"");
                }
                else if (typeCast(Boolean_$type, b) !== null) {
                    a.e(b == null ? "null" : b.toString().toLowerCase());
                }
                else {
                    a.e("null");
                }
            }
            else {
                if (b == null) {
                    a.e("null");
                    return;
                }
                if (this.u(b)) {
                    a.f("[");
                    a.i();
                    let c = new DataSourceLocalDataProvider();
                    c.dataSource = b;
                    for (let d = 0; d < c.actualCount; d++) {
                        if (d > 0) {
                            a.f(",");
                        }
                        this.dg(a, c, d);
                    }
                    a.f("");
                    a.h();
                    a.e("]");
                }
                else {
                    let e = [b];
                    let f = new DataSourceLocalDataProvider();
                    f.dataSource = e;
                    this.dg(a, f, 0);
                }
            }
        }
        x(a) {
            if (typeof a === 'string') {
                return true;
            }
            if (typeof a === 'number' || typeof a === 'number' || typeof a === 'number' || typeof a === 'number' || typeof a === 'number' || typeof a === 'number' || typeof a === 'number') {
                return true;
            }
            if (typeCast(Date_$type, a) !== null) {
                return true;
            }
            if (typeCast(Boolean_$type, a) !== null) {
                return true;
            }
            return false;
        }
        u(a) {
            if (typeCast(Array_$type, a) !== null) {
                return true;
            }
            if (typeCast(IEnumerable_$type, a) !== null) {
                return true;
            }
            return false;
        }
        dg(a, b, c) {
            a.f("{");
            a.i();
            let d = b.actualSchema;
            for (let e = 0; e < d.propertyNames.length; e++) {
                if (e > 0) {
                    a.f(",");
                }
                let f = d.propertyNames[e];
                if (stringStartsWith(f, "[")) {
                    f = f.substr(1, f.length - 2);
                }
                a.e("\"" + f + "\"");
                a.e(": ");
                let g = b.getItemValue(b.getItemAtIndex(c), d.propertyNames[e]);
                switch (d.propertyTypes[e]) {
                    case 0:
                        a.e(g == null ? "null" : "\"" + g.toString() + "\"");
                        break;
                    case 2:
                        a.e(g == null ? "null" : "\"" + g.toString() + "\"");
                        break;
                    case 10:
                    case 6:
                    case 5:
                    case 1:
                    case 3:
                    case 4:
                    case 7:
                        a.e(g == null ? "null" : g.toString());
                        break;
                    case 8:
                        let v_ = g;
                        a.e("\"" + (v_.toJSON()) + "\"");
                        break;
                    case 11:
                        this.di(a, g);
                        break;
                }
            }
            a.h();
            a.f("}");
        }
        o(a, b) {
            if (b == null) {
                return true;
            }
            let v_ = b;
            if ((typeof v_ === 'function')) {
                return false;
            }
            return true;
        }
        createObjectFromJson(a, b) {
            let c = new JsonDictionaryParser();
            let d = c.parse(a);
            let e = new DescriptionSerializer();
            let f = false;
            let g = e.d(this.context, d, f, null, false);
            if (g.result == null) {
                return null;
            }
            let h = DescriptionTreeBuilder.createTree(this.context, g.result);
            let i = this.a1.item(b);
            if (h.c("Type")) {
                let j = h.a("Type").b;
                return this.bu(j, h, b, i, true, -1, null);
            }
            else {
                return this.bt(typeCast(JsonDictionaryObject.$, d));
            }
        }
        loadJson(a, b) {
            this.cs(a, b, null, false, false, false);
        }
        loadJsonOverlay(a, b, c) {
            this.cs(a, b, c, true, false, true);
        }
        loadJsonDelta(a, b, c) {
            this.cs(a, b, null, true, c, false);
        }
        ap() {
            return false;
        }
        cu(a) {
        }
        cs(a, b, c, d, e, f) {
            let g = new JsonDictionaryParser();
            let h = g.parse(a);
            let i = new DescriptionSerializer();
            i.h = this.isProceedOnErrorEnabled;
            i.g = this.ap();
            let j = null;
            if (typeCast(JsonDictionaryObject.$, h) !== null) {
                let k = h;
                if (k.g("skipAlterDataCasing")) {
                    let l = k.item("skipAlterDataCasing");
                    if (l.value) {
                        this.cu(true);
                    }
                }
                else {
                    this.cu(false);
                }
                if (k.g("descriptions")) {
                    let m = k.item("descriptions");
                    if (typeCast(JsonDictionaryObject.$, m) !== null) {
                        let n = m;
                        let o = n.e();
                        for (let p = 0; p < o.length; p++) {
                            let q = o[p];
                            let r = n.item(q);
                            let s = b(q);
                            if (s == null) {
                                continue;
                            }
                            j = s;
                            let t = false;
                            let u = this.ba();
                            if (u != null) {
                                t = true;
                            }
                            let v = null;
                            if (this.isProceedOnErrorEnabled) {
                                try {
                                    v = i.d(this.context, r, t, u, false);
                                }
                                catch (w) {
                                    return;
                                }
                            }
                            else {
                                v = i.d(this.context, r, t, u, false);
                            }
                            if (v.result == null) {
                                continue;
                            }
                            if (f) {
                                if (!this.a5.containsKey(s)) {
                                    let x = null;
                                    if (this.isProceedOnErrorEnabled) {
                                        try {
                                            x = i.d(this.context, r, t, u, true);
                                        }
                                        catch (y) {
                                            return;
                                        }
                                    }
                                    else {
                                        x = i.d(this.context, r, t, u, true);
                                    }
                                    this.dd(x.result, s, d, true, false);
                                    let z = c(q);
                                    let aa = this.a5.item(s);
                                    this.co(this.at.item(s), z, aa, s);
                                }
                            }
                            this.dd(v.result, s, d, e, false);
                        }
                    }
                }
                if (k.g("refs") && j != null) {
                    let ab = k.item("refs");
                    let ac = this.af(ab);
                    if (!ac && typeCast(JsonDictionaryObject.$, ab) !== null) {
                        let ad = ab;
                        let ae = ad.e();
                        for (let af = 0; af < ae.length; af++) {
                            let ag = ae[af];
                            let ah = ad.item(ag);
                            if (typeCast(JsonDictionaryValue.$, ah) !== null) {
                                let ai = ah;
                                this.provideRefValue(j, ag, ai.value);
                            }
                            else if (typeCast(JsonDictionaryArray.$, ah) !== null) {
                                let aj = ah;
                                let ak = this.a(aj);
                                this.provideRefValue(j, ag, ak);
                            }
                            else {
                                let al = this.bt(ah);
                                this.provideRefValue(j, ag, al);
                            }
                        }
                    }
                }
                if (k.g("modules") && j != null) {
                    let am = k.item("modules");
                    this.ac(am);
                }
                if (k.g("strings") && j != null) {
                    let an = k.item("strings");
                    this.aj(an);
                }
                if (k.g("onInit") && j != null) {
                    let ao = k.item("onInit");
                    this.ad(ao);
                }
                if (k.g("onViewInit") && j != null) {
                    let ap = k.item("onViewInit");
                    this.ae(ap);
                }
            }
        }
        provideRefValueFromJson(a, b, c) {
            let d = b;
            let e = new JsonDictionaryParser();
            let f = e.parse(c);
            if (typeCast(JsonDictionaryValue.$, f) !== null) {
                let g = f;
                this.provideRefValue(a, d, g.value);
            }
            else if (typeCast(JsonDictionaryArray.$, f) !== null) {
                let h = f;
                let i = this.a(h);
                this.provideRefValue(a, d, i);
            }
            else {
                let j = this.bt(f);
                this.provideRefValue(a, d, j);
            }
        }
        ba() {
            return null;
        }
        af(a) {
            return false;
        }
        ac(a) {
            return false;
        }
        aj(a) {
            return false;
        }
        ad(a) {
            return false;
        }
        ae(a) {
            return false;
        }
        b7(a, b, c) {
            let d = a;
            if (c != null) {
                d = c.j(b);
            }
            else {
                if (TypeDescriptionMetadata.shouldCamelize(b)) {
                    d = TypeDescriptionMetadata.camelize(d);
                }
            }
            if (stringEndsWith(d, "Ref")) {
                d = d.substr(0, d.length - ("Ref").length);
            }
            return d;
        }
        co(a, b, c, d) {
            if (!c.b(b)) {
                c.k(d, this.at.item(d).g, b, this.at.item(d), runOn(this, this.cz), -1);
            }
            for (let e of fromEnum(a.f())) {
                this.cp(this.b7(e.c, ComponentRenderer.platform, e.a), e.b, b, c, d, a.g);
            }
        }
        cp(a, b, c, d, e, f) {
            if (typeCast(DescriptionTreeNode.$, b) !== null) {
                let g = b;
                let h = this.adapter.getPropertyValue(c, a);
                if (!d.b(h) && !d.a(g.g)) {
                    d.k(e, g.g, h, g, runOn(this, this.cz), f);
                }
                for (let i of fromEnum(g.f())) {
                    this.cp(a + "." + this.b7(i.c, ComponentRenderer.platform, i.a), i.b, c, d, e, g.g);
                }
            }
            if (typeCast(Array_$type, b) !== null) {
                let j = new Dictionary$2(Number_$type, DescriptionTreeNode.$, 0);
                let k = 0;
                let l = b.length;
                let o = b;
                for (let n = 0; n < o.length; n++) {
                    let m = o[n];
                    if (typeCast(DescriptionTreeNode.$, m) !== null) {
                        let p = m;
                        j.item(k, p);
                    }
                    k++;
                }
                let q = this.adapter.getPropertyValue(c, a);
                k = 0;
                this.adapter.forPropertyValueItem(c, a, (r) => {
                    if (j.containsKey(k)) {
                        let s = j.item(k);
                        if (!d.b(r) && !d.a(s.g)) {
                            d.k(e, s.g, r, s, runOn(this, this.cz), f);
                        }
                        for (let t of fromEnum(s.f())) {
                            this.cp(a + "." + t.c, t.b, c, d, e, s.g);
                        }
                    }
                    k++;
                });
                if (l > 0 && k == 0) {
                    let r = this.cb(a);
                    this.adapter.forPropertyValueItem(c, r, (s) => {
                        if (j.containsKey(k)) {
                            let t = j.item(k);
                            if (!d.b(s) && !d.a(t.g)) {
                                d.k(e, t.g, s, t, runOn(this, this.cz), f);
                            }
                            for (let u of fromEnum(t.f())) {
                                this.cp(r + "." + u.c, u.b, c, d, e, t.g);
                            }
                        }
                        k++;
                    });
                }
            }
        }
        cb(a) {
            let b = a.lastIndexOf('.');
            let c = null;
            let d = a;
            if (b > 0) {
                c = a.substr(0, b);
                d = a.substr(b + 1);
            }
            d = "actual" + this.b9(d);
            if (c != null) {
                return c + "." + d;
            }
            return d;
        }
        b9(a) {
            return a.substr(0, 1).toUpperCase() + a.substr(1);
        }
        a(a) {
            let b = new Array(a.items.length);
            for (let c = 0; c < a.items.length; c++) {
                let d = this.bt(a.items[c]);
                b[c] = d;
            }
            return b;
        }
        bt(a) {
            if (a == null) {
                return null;
            }
            let b = {};
            let dict_ = b;
            let c = a.e();
            for (let d = 0; d < c.length; d++) {
                let key_ = c[d];
                if (typeCast(JsonDictionaryObject.$, a.item(key_)) !== null) {
                    let val_ = this.bt(a.item(key_));
                    dict_[key_] = val_;
                }
                else if (typeCast(JsonDictionaryArray.$, a.item(key_)) !== null) {
                    let val_ = this.a(a.item(key_));
                    dict_[key_] = val_;
                }
                else {
                    let val_ = a.item(key_).value;
                    dict_[key_] = val_;
                }
            }
            return dict_;
        }
        get a5() {
            return this.a1;
        }
        cleanup(a, b) {
            this.dd(null, a, false, false, b);
        }
        render(a, b) {
            this.dd(a, b, false, false, false);
        }
        dd(a, b, c, d, e) {
            if (!this.a1.containsKey(b)) {
                this.a1.item(b, new ContainerState());
                this.a1.item(b).i = b;
            }
            this.aw.item(b, a);
            this.ax.item(b, c);
            this.ay.item(b, d);
            this.av.item(b, e);
            this.cv(b, () => this.db(b));
        }
        cv(a, b) {
            this.adapter.onUIThread(a, b);
        }
        db(a) {
            if (this.aw.containsKey(a)) {
                let b = this.ax.containsKey(a) ? this.ax.item(a) : false;
                let c = this.ay.containsKey(a) ? this.ay.item(a) : false;
                let d = this.aw.item(a);
                this.aw.removeItem(a);
                let e = DescriptionTreeBuilder.createTree(this.context, d);
                let f = null;
                if (this.at.containsKey(a)) {
                    f = this.at.item(a);
                }
                let g = DescriptionTreeReconciler.c(f, e, b);
                if (!c && b) {
                    e = f.b();
                    DescriptionTreeReconciler.a(f, g);
                    let h = f;
                    f = e;
                    e = h;
                    g = DescriptionTreeReconciler.c(f, e, false);
                }
                if (c) {
                    let i = DescriptionTreeReconciler.a(f, g);
                    if (!this.a1.containsKey(a)) {
                        this.a1.addItem(a, ((() => {
                            let $ret = new ContainerState();
                            $ret.i = a;
                            return $ret;
                        })()));
                    }
                    let j = this.a1.item(a);
                    if (i.a.count > 0) {
                        for (let k of fromEnum(i.a)) {
                            if (j.a(k)) {
                                let l = j.j(k);
                                this.cm(a, l, j);
                            }
                        }
                    }
                    if (i.c.count > 0) {
                        for (let m of fromEnum(i.c)) {
                            let n = this.bz(a, j, m);
                            let o = this.adapter.getPropertyValue(n, m.j);
                            if (o != null) {
                                if (!j.b(o)) {
                                    let p = m.g;
                                    if (typeCast(DescriptionTreeNode.$, p) !== null) {
                                        let q = p.g;
                                        j.k(a, q, o, p, runOn(this, this.cz), m.c.g);
                                    }
                                }
                            }
                        }
                    }
                    if (i.d.count > 0) {
                        for (let r of fromEnum(i.d)) {
                            let s = r.g;
                            if (s != null) {
                                if (!j.b(s)) {
                                    let t = r.g;
                                    if (typeCast(DescriptionTreeNode.$, t) !== null) {
                                        let u = t.g;
                                        this.at.item(a, t);
                                    }
                                }
                            }
                        }
                    }
                    if (i.b.count > 0) {
                        for (let v of fromEnum(i.b)) {
                            let w = v.c.a(v.j).b;
                            if (w == null) {
                                continue;
                            }
                            let x = new Dictionary$2(String_$type, DescriptionTreeNode.$, 0);
                            for (let y = 0; y < w.length; y++) {
                                let z = w[y];
                                if (typeCast(DescriptionTreeNode.$, z) !== null) {
                                    let aa = z;
                                    if (aa.c("Name")) {
                                        x.item(aa.a("Name").b, aa);
                                    }
                                }
                            }
                            if (x.count == 0) {
                                continue;
                            }
                            let ab = this.bz(a, j, v);
                            let ac = this.adapter.getPropertyValue(ab, v.j);
                            if (ac != null) {
                                let ad = 0;
                                this.adapter.forPropertyValueItem(ab, v.j, (ae) => {
                                    if (x.containsKey(this.adapter.getPropertyValue(ae, "Name").toString())) {
                                        if (!j.b(ae)) {
                                            let af = x.item(this.adapter.getPropertyValue(ae, "Name").toString());
                                            if (typeCast(DescriptionTreeNode.$, af) !== null) {
                                                let ag = af.g;
                                                j.k(a, ag, ae, af, runOn(this, this.cz), v.c.g);
                                            }
                                        }
                                    }
                                    ad++;
                                });
                            }
                        }
                    }
                }
                else {
                    this.at.item(a, e);
                }
                if (!c) {
                    this.dc(a, g);
                }
                if (this.av.item(a)) {
                    this.c9(a);
                    if (this.a1.containsKey(a)) {
                        this.a1.removeItem(a);
                    }
                }
            }
        }
        provideRefValue(a, b, c) {
            this.cv(a, () => {
                if (!this.a1.containsKey(a)) {
                    this.a1.addItem(a, ((() => {
                        let $ret = new ContainerState();
                        $ret.i = a;
                        return $ret;
                    })()));
                }
                let d = this.a1.item(a);
                this.cz(a, b, c, true);
            });
        }
        removeRefValue(a, b) {
            this.cv(a, () => {
                if (!this.a1.containsKey(a)) {
                    this.a1.addItem(a, ((() => {
                        let $ret = new ContainerState();
                        $ret.i = a;
                        return $ret;
                    })()));
                }
                let c = this.a1.item(a);
                this.removeRefValueCore(a, b, true);
            });
        }
        c9(a) {
            let b = this.a1.item(a);
            let c = new List$1(String_$type, 0);
            for (let d of fromEnum(this.a0.keys)) {
                if (this.a0.item(d).c == 0) {
                    c.add(d);
                }
            }
            for (let e = 0; e < c.count; e++) {
                let f = this.shouldNamespaceSystemRefValues;
                this.shouldNamespaceSystemRefValues = false;
                this.removeRefValueCore(a, c._inner[e], this.a4.containsKey(c._inner[e]));
                this.shouldNamespaceSystemRefValues = f;
            }
        }
        clearRefValues(a) {
            this.cv(a, () => {
                if (!this.a1.containsKey(a)) {
                    this.a1.addItem(a, ((() => {
                        let $ret = new ContainerState();
                        $ret.i = a;
                        return $ret;
                    })()));
                }
                let b = this.a1.item(a);
                this.clearUserRefValues();
            });
        }
        v(a) {
            if (this.as.containsKey(a) && this.as.item(a)) {
                return false;
            }
            if (this.az.containsKey(a) && this.az.item(a).count > 0) {
                return false;
            }
            return true;
        }
        queueForIdle(a, b) {
            this.cv(a, () => {
                if (this.v(a)) {
                    b();
                }
                else {
                    if (!this.au.containsKey(a)) {
                        this.au.item(a, new List$1(Delegate_$type, 0));
                    }
                    this.au.item(a).add(b);
                }
            });
        }
        tryFlushIdleActions(a) {
            if (this.v(a)) {
                if (this.au.containsKey(a)) {
                    let b = new List$1(Delegate_$type, 1, this.au.item(a));
                    this.au.item(a).clear();
                    for (let c = 0; c < b.count; c++) {
                        b._inner[c]();
                    }
                }
            }
        }
        dc(a, b) {
            let c = this.a1.item(a);
            this.cw(a, c, b);
        }
        df(a, b) {
            if (this.isProceedOnErrorEnabled) {
                try {
                    this.cn(a, b, true);
                }
                catch (c) {
                    this.as.item(a, false);
                }
            }
            else {
                this.cn(a, b, true);
            }
        }
        dl(a, b) {
            if (this.isProceedOnErrorEnabled) {
                try {
                    this.cn(a, b, false);
                }
                catch (c) {
                    this.as.item(a, false);
                }
            }
            else {
                this.cn(a, b, false);
            }
        }
        cn(a, b, c) {
            if (!c) {
                if (this.as.containsKey(a) && this.as.item(a)) {
                    return;
                }
            }
            this.as.item(a, true);
            let d = true;
            while (d && this.az.item(a).count > 0) {
                while (this.az.item(a).count > 0 && this.az.item(a).c().count < 1) {
                    this.az.item(a).b();
                }
                if (this.az.item(a).count < 1) {
                    break;
                }
                let e = this.az.item(a).c();
                while (e.count > 0) {
                    let f = e.b();
                    d = this.z(a, b, f);
                    if (!d) {
                        break;
                    }
                }
            }
            if (d) {
                this.as.item(a, false);
            }
            if (this.v(a)) {
                this.tryFlushIdleActions(a);
            }
        }
        cw(a, b, c) {
            let d = new Queue$1(DescriptionTreeAction.$);
            for (let e = 0; e < c.count; e++) {
                d.g(c._inner[e]);
            }
            if (!this.az.containsKey(a)) {
                this.az.addItem(a, new Queue$1(Queue$1.$.specialize(DescriptionTreeAction.$)));
            }
            this.az.item(a).g(d);
            this.dl(a, b);
        }
        cx(a, b, c) {
            for (let d = 0; d < c.count; d++) {
                this.z(a, b, c._inner[d]);
            }
        }
        z(a, b, c) {
            switch (c.a) {
                case 5: return this.aa(a, b, c);
                case 2: return this.ab(a, b, c);
                case 4: return this.ag(a, b, c);
                case 3: return this.ah(a, b, c);
                case 1: return this.ai(a, b, c);
                case 0: return this.ak(a, b, c);
            }
            return true;
        }
        ak(a, b, c) {
            let d = this.bz(a, b, c);
            this.ar(a, b, c, d);
            return true;
        }
        ar(a, b, c, d) {
            let e = this.bw(c, a, b);
            e = this.i.transform(ComponentRenderer.platform, e, c);
            let f = false;
            if (this.a8 != null && this.a8.count > 0) {
                for (let g = 0; g < this.a8.count; g++) {
                    let h = this.a8._inner[g];
                    let i = this.b8(a, c);
                    if (h(i, d, e)) {
                        f = true;
                    }
                }
            }
            if (c.j == "Type" || c.j == "type") {
                f = true;
            }
            if (f) {
                return true;
            }
            if (c.d != null && c.d.knownType == 9) {
                this.ao(a, b, c.i(ComponentRenderer.platform), c.d, e, d);
            }
            else {
                this.dj(a, b, c.i(ComponentRenderer.platform), c.d, e, c.h, d);
            }
            return true;
        }
        b8(a, b) {
            let c = b.c;
            let d = "";
            if (c != this.at.item(a)) {
                let e = this.b6(a, c);
                d = e;
            }
            if (d.length > 0) {
                d += ".";
            }
            d += b.j;
            return d;
        }
        b6(a, b) {
            if (b == null) {
                return "";
            }
            let c = this.cc("", this.at.item(a), b);
            if (c.c) {
                return c.d;
            }
            return "";
        }
        cc(a, b, c) {
            if (b == c) {
                return new Tuple$2(Boolean_$type, String_$type, true, a);
            }
            if (a.length > 0) {
                a += ".";
            }
            let d = b.f();
            for (let e = 0; e < d.count; e++) {
                let f = d._inner[e];
                if (typeCast(DescriptionTreeNode.$, f.b) !== null) {
                    if (f.b.g == c.g) {
                        a += f.c;
                        return new Tuple$2(Boolean_$type, String_$type, true, a);
                    }
                    else {
                        let g = a + f.c;
                        let h = this.cc(g, f.b, c);
                        if (h.c) {
                            return h;
                        }
                    }
                }
                if (f.a != null && f.a.knownType == 9) {
                    let i = f.b;
                    for (let j = 0; j < i.length; j++) {
                        if (typeCast(DescriptionTreeNode.$, i[j]) !== null) {
                            let k = i[j];
                            if (k.g == c.g) {
                                a += f.c + "[" + j + "]";
                                return new Tuple$2(Boolean_$type, String_$type, true, a);
                            }
                            else {
                                let l = a + f.c + "[" + j + "]";
                                let m = this.cc(l, k, c);
                                if (m.c) {
                                    return m;
                                }
                            }
                        }
                    }
                }
            }
            return new Tuple$2(Boolean_$type, String_$type, false, a);
        }
        ao(a, b, c, d, e, f) {
            if (this.a3.containsKey(c)) {
                for (let g of fromEnum(this.a3.item(c))) {
                    g(c, f, e);
                }
            }
            this.adapter.setOrUpdateCollectionOnTarget(a, c, d, this.context, f, e);
            return true;
        }
        bw(a, b, c) {
            if (a.d == null) {
                return a.g;
            }
            switch (a.d.knownType) {
                case 10: return this.bc(a, b, c);
                case 7: return this.bd(a);
                case 4: return this.be(a);
                case 6: return this.bf(a);
                case 9: return this.bc(a, b, c);
                case 5: return this.bg(a);
                case 16: return this.bh(a);
                case 20: return this.b0(a, c);
                case 22: return this.b3(a, c);
                case 15: return null;
                case 3: return this.bi(a);
                case 19: return this.b1(a, c);
                case 8: return this.bk(a, b, c);
                case 13: return null;
                case 18: return this.b2(a, c);
                case 1: return this.bl(a);
                case 11: return this.bm(a);
                case 14: return this.bn(a);
                case 12: return this.bo(a);
                case 2: return this.bp(a);
                case 21: return this.bq(a);
                case 17: return this.br(a, b, c);
                case 0: return null;
            }
            return null;
        }
        br(a, b, c) {
            let d = this.bs(a.g, a, b, c);
            return d;
        }
        bs(a, b, c, d) {
            if (typeof a === 'string') {
                if (stringStartsWith(a, "@d:")) {
                    let v_ = a.substr(3);
                    a = new Date(v_);
                }
            }
            if (typeCast(Array_$type, a) !== null) {
                let e = a;
                let f = new Array(e.length);
                for (let g = 0; g < e.length; g++) {
                    let h = this.bs(e[g], b, c, d);
                    f[g] = h;
                }
                a = f;
            }
            if (typeCast(DescriptionTreeNode.$, a) !== null) {
                let i = a;
                if (i.i == "EmbeddedRef") {
                    return this.bu(i.i, a, c, d, false, b.c.g, b.d);
                }
            }
            return a;
        }
        bq(a) {
            return a.g;
        }
        bp(a) {
            return a.g != null ? a.g.toString() : null;
        }
        bo(a) {
            let b = a.g;
            let width_ = b.width;
            let height_ = b.height;
            let c = { width: width_, height: height_ };
            return c;
        }
        bn(a) {
            let b = a.g;
            let top_ = b.top;
            let left_ = b.left;
            let width_ = b.width;
            let height_ = b.height;
            let c = { left: left_, top: top_, width: width_, height: height_ };
            return c;
        }
        bm(a) {
            let b = a.g;
            let x_ = b.x;
            let y_ = b.y;
            let c = { x: x_, y: y_ };
            return c;
        }
        bl(a) {
            if (a.g == null) {
                if (a.d != null && (a.d.specificType == "double" || a.d.specificType == "float")) {
                    return NaN;
                }
                return 0;
            }
            return a.g;
        }
        e(a, b) {
            if (this.a0.containsKey(a)) {
                let c = this.a0.item(a);
                return c;
            }
            let d = new DescriptionRef(a);
            this.a0.addItem(a, d);
            return d;
        }
        b2(a, b) {
            return a.g == null ? null : this.e(a.g, b);
        }
        bk(a, b, c) {
            let d = a.d.specificType;
            if (d == null) {
                d = a.d.specificExternalType;
            }
            if (typeCast(DescriptionTreeNode.$, a.g) !== null) {
                let e = a.g;
                if (e.c("Type")) {
                    d = e.a("Type").b;
                }
            }
            let f = this.bu(d, a.g, b, c, false, a.c.g, a.d);
            return f;
        }
        b1(a, b) {
            return a.g == null ? null : this.e(a.g, b);
        }
        bi(a) {
            if (typeof a.g === 'string') {
                let v_ = a.g;
                a.g = new Date(v_);
            }
            return a.g;
        }
        b0(a, b) {
            return a.g == null ? null : this.e(a.g, b);
        }
        b3(a, b) {
            return a.g == null ? null : this.e(a.g, b);
        }
        b5(a) {
            return a;
        }
        bh(a) {
            let b = a.g;
            if (b == null) {
                return null;
            }
            let c = new Array(b.length);
            for (let d = 0; d < b.length; d++) {
                c[d] = this.b5(b[d]);
            }
            return c;
        }
        bg(a) {
            return this.b5(a.g);
        }
        bf(a) {
            let b = a.g;
            if (b == null) {
                return null;
            }
            let c = new Array(b.length);
            for (let d = 0; d < b.length; d++) {
                c[d] = this.b4(b[d]);
            }
            return c;
        }
        b4(a) {
            return a;
        }
        be(a) {
            return this.b4(a.g);
        }
        bd(a) {
            return a.g;
        }
        addTargetPropertyUpdatingListener(a) {
            this.a8.add(a);
        }
        removeTargetPropertyUpdatingListener(a) {
            this.a8.remove(a);
        }
        addPropertyUpdatingListener(a, b) {
            if (!this.a3.containsKey(a)) {
                this.a3.addItem(a, new List$1(Delegate_$type, 0));
            }
            this.a3.item(a).add(b);
        }
        addReferenceLookupListener(a) {
            this.a6.add(a);
        }
        removeReferenceLookupListener(a) {
            this.a6.remove(a);
        }
        removePropertyUpdatingListener(a, b) {
            if (this.a3.containsKey(a)) {
                this.a3.item(a).remove(b);
                if (this.a3.item(a).count == 0) {
                    this.a3.removeItem(a);
                }
            }
        }
        addNamespaceLookupListener(a) {
            this.a7.add(a);
        }
        removeNamespaceLookupListener(a) {
            this.a7.remove(a);
        }
        bc(a, b, c) {
            if (a.g == null) {
                return null;
            }
            let d = a.g;
            let e = new List$1(Base.$, 0);
            let f = a.d.specificType;
            if (f == null) {
                f = a.d.specificExternalType;
            }
            if (a.d.knownType == 9) {
                f = a.d.collectionElementType;
                if (f == null) {
                    f = a.d.specificExternalType;
                }
            }
            for (let g = 0; g < d.length; g++) {
                let h = f;
                if (typeCast(DescriptionTreeNode.$, d[g]) !== null) {
                    let i = d[g];
                    if (i.c("Type")) {
                        h = i.a("Type").b;
                    }
                }
                let j = this.bu(h, d[g], b, c, false, a.c.g, a.d);
                e.add1(j);
            }
            return e.toArray();
        }
        dj(a, b, c, d, e, f, g) {
            if (typeCast(DescriptionRef.$, e) !== null) {
                let h = e;
                let i = false;
                if (f != null && typeof f === 'string') {
                    if (this.r(f)) {
                        let j = this.f(f);
                        if (Base.equalsStatic(j, e)) {
                            i = true;
                        }
                        else {
                            j.j(a, g, c);
                        }
                    }
                }
                if (this.s(e)) {
                    let k = e;
                    if (k.e != null && k.e.length > 0 && this.a2.containsKey(k.e)) {
                        k.a = true;
                    }
                    e = this.by(e);
                    this.dk(g, c, d, e, f, k);
                }
                else {
                    this.adapter.onPendingRef(g, c, d, e);
                }
                let l = null;
                l = (m, n) => {
                    let o = m;
                    if (o.e != null && o.e.length > 0 && this.a2.containsKey(o.e)) {
                        o.a = true;
                    }
                    let p = this.by(m);
                    this.dk(g, c, d, p, f, o);
                };
                if (!i) {
                    h.g(a, g, c, l);
                }
                return;
            }
            this.dk(g, c, d, e, f, null);
        }
        hasUserRef(a) {
            return this.a4.containsKey(a);
        }
        get shouldNamespaceSystemRefValues() {
            return this._shouldNamespaceSystemRefValues;
        }
        set shouldNamespaceSystemRefValues(a) {
            this._shouldNamespaceSystemRefValues = a;
        }
        cz(a, b, c, d) {
            let e = null;
            if (d) {
                if (this.a4.containsKey(b)) {
                    e = this.a4.item(b);
                }
                this.a4.item(b, c);
            }
            else {
                if (this.shouldNamespaceSystemRefValues) {
                    let f = "";
                    if (this.a7 != null && this.a7.count > 0) {
                        for (let g = 0; g < this.a7.count; g++) {
                            f = this.a7._inner[g](a);
                        }
                    }
                    if (!stringIsNullOrEmpty(f)) {
                        b = f + "/" + b;
                    }
                }
                if (this.a2.containsKey(b)) {
                    e = this.a2.item(b);
                }
                this.a2.item(b, c);
                if (this.a0.containsKey(b)) {
                    this.a0.item(b).a = true;
                }
            }
            if (this.a0.containsKey(b)) {
                this.a0.item(b).f(e, c);
            }
        }
        removeRefValueCore(a, b, c) {
            let d = null;
            if (c) {
                if (this.a4.containsKey(b)) {
                    d = this.a4.item(b);
                }
                this.a4.removeItem(b);
            }
            else {
                if (this.shouldNamespaceSystemRefValues) {
                    let e = "";
                    if (this.a7 != null && this.a7.count > 0) {
                        for (let f = 0; f < this.a7.count; f++) {
                            e = this.a7._inner[f](a);
                        }
                    }
                    if (!stringIsNullOrEmpty(e)) {
                        b = e + "/" + b;
                    }
                }
                if (this.a2.containsKey(b)) {
                    d = this.a2.item(b);
                }
                this.a2.removeItem(b);
            }
            if (this.a0.containsKey(b)) {
                this.a0.item(b).f(d, this.by(this.a0.item(b)));
                if (this.a0.item(b).c <= 0) {
                    this.a0.item(b).h();
                    this.a0.removeItem(b);
                }
            }
        }
        clearUserRefValues() {
            let a = new List$1(String_$type, 0);
            for (let b of fromEnum(this.a4.keys)) {
                a.add(b);
            }
            for (let c of fromEnum(a)) {
                this.removeRefValueCore(null, c, true);
            }
        }
        s(a) {
            return this.a4.containsKey(a.e) || this.a2.containsKey(a.e);
        }
        by(a) {
            if (this.a4.containsKey(a.e)) {
                return this.a4.item(a.e);
            }
            if (this.a2.containsKey(a.e)) {
                return this.a2.item(a.e);
            }
            return null;
        }
        r(a) {
            return this.a0.containsKey(a);
        }
        f(a) {
            return this.a0.item(a);
        }
        getMissingRefs() {
            let a = new List$1(String_$type, 0);
            for (let b of fromEnum(this.a0.keys)) {
                if (!this.s(this.a0.item(b))) {
                    a.add(b);
                }
            }
            return a.toArray();
        }
        getRefChangeInfos(a) {
            let b = new List$1(DescriptionRefTargetInfo.$, 0);
            if (this.a0.containsKey(a)) {
                for (let c of fromEnum(this.a0.item(a).b)) {
                    b.add(((() => {
                        let $ret = new DescriptionRefTargetInfo();
                        $ret.container = c.b;
                        $ret.propertyName = c.d;
                        $ret.target = c.c;
                        return $ret;
                    })()));
                }
            }
            return b.toArray();
        }
        bz(a, b, c) {
            return b.j(c.c.g);
        }
        ai(a, b, c) {
            let d = this.bz(a, b, c);
            this.an(a, b, c, d);
            return true;
        }
        an(a, b, c, d) {
            this.adapter.resetPropertyOnTarget(a, c.i(ComponentRenderer.platform), c.d, d);
            return true;
        }
        ah(a, b, c) {
            if (c.c == null) {
                return this.am(a, b, c);
            }
            else {
                let d = this.bz(a, b, c);
                this.de(a, b, c, d);
            }
            return true;
        }
        de(a, b, c, d) {
            let e = c.i(ComponentRenderer.platform);
            let f = c.d.collectionElementType;
            if (f == null) {
                f = c.d.specificExternalType;
            }
            let g = this.bu(f, c.g, a, b, false, c.c.g, c.d);
            this.adapter.replaceItemInCollection(e, c.d, d, c.e, g);
            if (c.h != null && typeCast(DescriptionTreeNode.$, c.h) !== null) {
                let h = c.h.g;
                if (h >= 0) {
                    let i = b.j(h);
                    if (i != null) {
                        this.cm(a, i, b);
                    }
                }
            }
        }
        am(a, b, c) {
            let d = this.adapter.getRootObject(a);
            if (d != null) {
                this.cm(a, d, b);
            }
            if (!(typeCast(DescriptionTreeNode.$, c.g) !== null)) {
                throw new NotImplementedException(0);
            }
            let e = c.g;
            let f = false;
            this.adapter.replaceRootItem(a, e.i, this.context, (g) => {
                let h = this.adapter.getRootObject(a);
                b.k(a, e.g, h, e, runOn(this, this.cz), -1);
                let i = this.a9(e);
                this.cx(a, b, i);
                f = true;
                if (g) {
                    this.df(a, b);
                }
            });
            return f;
        }
        cm(a, b, c) {
            let d = this.bb(a, b, c);
            for (let e of fromEnum(this.a0.values)) {
                e.i(b);
            }
            if (d != -1) {
                c.l(this, a, d, runOn(this, this.removeRefValueCore));
            }
            this.j.b(ComponentRenderer.platform, b);
        }
        bb(a, b, c) {
            return c.h(b);
        }
        ag(a, b, c) {
            if (c.c == null) {
                return this.al(a, b, c);
            }
            else {
                let d = this.bz(a, b, c);
                this.c2(a, b, c, d);
            }
            return true;
        }
        c2(a, b, c, d) {
            let e = c.i(ComponentRenderer.platform);
            this.adapter.removeItemFromCollection(e, c.d, d, c.f);
            if (c.h != null && typeCast(DescriptionTreeNode.$, c.h) !== null) {
                let f = c.h.g;
                if (f >= 0) {
                    let g = b.j(f);
                    if (g != null) {
                        this.cm(a, g, b);
                    }
                }
            }
        }
        al(a, b, c) {
            let d = this.adapter.getRootObject(a);
            if (d != null) {
                this.cm(a, d, b);
            }
            let e = false;
            this.adapter.removeRootItem(a, this.context, (f) => {
                e = true;
                if (f) {
                    this.df(a, b);
                }
            });
            return e;
        }
        ab(a, b, c) {
            if (c.c == null) {
                return this.m(a, b, c);
            }
            else {
                let d = this.bz(a, b, c);
                this.cd(a, b, c, d);
            }
            return true;
        }
        m(a, b, c) {
            if (!(typeCast(DescriptionTreeNode.$, c.g) !== null)) {
                throw new NotImplementedException(0);
            }
            let d = c.g;
            let e = false;
            this.adapter.replaceRootItem(a, d.i, this.context, (f) => {
                let g = this.adapter.getRootObject(a);
                b.k(a, d.g, g, d, runOn(this, this.cz), -1);
                let h = this.a9(d);
                this.cx(a, b, h);
                e = true;
                if (f) {
                    this.df(a, b);
                }
            });
            return e;
        }
        cd(a, b, c, d) {
            let e = c.i(ComponentRenderer.platform);
            let f = c.d.collectionElementType;
            if (typeCast(DescriptionTreeNode.$, c.g) !== null) {
                let g = c.g;
                if (g.c("Type")) {
                    f = g.a("Type").b;
                }
            }
            if (f == null) {
                f = c.d.specificExternalType;
            }
            let h = this.bu(f, c.g, a, b, false, c.c.g, c.d);
            this.adapter.addItemToCollection(e, c.d, d, c.e, h);
        }
        bu(a, b, c, d, e, f, g) {
            if (this.w(a)) {
                return b;
            }
            let h = null;
            if (b != null && typeCast(DescriptionTreeNode.$, b) !== null) {
                let i = b;
                if (i.c("Name")) {
                    let j = i.a("Name").b;
                    if (!stringIsNullOrEmpty(j)) {
                        if (this.shouldNamespaceSystemRefValues) {
                            let k = "";
                            if (this.a7 != null && this.a7.count > 0) {
                                for (let l = 0; l < this.a7.count; l++) {
                                    k = this.a7._inner[l](c);
                                }
                            }
                            if (!stringIsNullOrEmpty(k)) {
                                j = k + "/" + j;
                            }
                        }
                        if (this.a2.containsKey(j)) {
                            let m = this.a2.item(j);
                            h = m;
                        }
                    }
                }
                if (h == null) {
                    h = this.context.w(a, c);
                }
            }
            else if (b != null) {
                h = this.context.w(a, c);
            }
            if (b == null) {
                return h;
            }
            if (typeCast(DescriptionTreeNode.$, b) !== null) {
                let n = b;
                if (n.i == "EmbeddedRef") {
                    let o = "uuid";
                    let p = null;
                    for (let q = 0; q < n.f().count; q++) {
                        if (n.f()._inner[q].c == "RefType") {
                            o = n.f()._inner[q].b;
                        }
                        if (n.f()._inner[q].c == "Value") {
                            p = n.f()._inner[q].b;
                        }
                    }
                    if (p != null) {
                        for (let r = 0; r < this.a6.count; r++) {
                            let s = this.a6._inner[r](c, o, p);
                            if (s != null) {
                                return s;
                            }
                        }
                        return null;
                    }
                }
                else {
                    d.k(c, n.g, h, n, runOn(this, this.cz), f);
                    let t = this.a9(n);
                    this.cx(c, d, t);
                    if (e) {
                        d.l(this, c, n.g, runOn(this, this.removeRefValueCore));
                    }
                }
            }
            let u = (a == "object" || a == "Object");
            if (!u && typeof b === 'string' && a.toLowerCase() != "string") {
                return this.bj(a, b, g);
            }
            if (u) {
                return b;
            }
            return h;
        }
        w(a) {
            return a == "int" || a == "Int32" || a == "short" || a == "Int16" || a == "double" || a == "Double" || a == "float" || a == "Float" || a == "Single" || a == "single" || a == "DateTime" || a == "decimal" || a == "Decimal" || a == "long" || a == "Int64" || a == "byte" || a == "bool" || a == "string" || a == "String";
        }
        bj(a, b, c) {
            return this.context.s(a, b, c, this.n());
        }
        n() {
            return true;
        }
        a9(a) {
            let b = a.f();
            let c = new List$1(DescriptionTreeAction.$, 0);
            for (let d = 0; d < b.count; d++) {
                let e = new DescriptionTreeAction();
                e.a = 0;
                e.j = b._inner[d].c;
                e.d = b._inner[d].a;
                e.c = a;
                e.b = a;
                e.g = b._inner[d].b;
                if (e.d != null && e.d.mustBeFirst) {
                    c.insert(0, e);
                }
                else {
                    c.add(e);
                }
            }
            return c;
        }
        aa(a, b, c) {
            if (c.c == null) {
                return this.q(a, b, c);
            }
            else {
                let d = this.bz(a, b, c);
                this.cj(a, b, c, d);
            }
            return true;
        }
        cj(a, b, c, d) {
            let e = c.i(ComponentRenderer.platform);
            this.adapter.clearCollection(d, e, c.d);
            if (c.h != null && typeCast(Array_$type, c.h) !== null) {
                let f = c.h;
                for (let g = 0; g < f.length; g++) {
                    let h = f[g];
                    if (h != null && typeCast(DescriptionTreeNode.$, h) !== null) {
                        let i = h.g;
                        if (i >= 0) {
                            let j = b.j(i);
                            if (j != null) {
                                this.cm(a, j, b);
                            }
                        }
                    }
                }
            }
        }
        dk(a, b, c, d, e, f) {
            if (this.a3.containsKey(b)) {
                for (let g of fromEnum(this.a3.item(b))) {
                    g(b, a, d);
                }
            }
            this.adapter.setPropertyValue(a, b, c, d, e, f);
        }
        bx(a, b) {
            return this.adapter.getPropertyValue(a, b);
        }
        q(a, b, c) {
            return this.p(a, b);
        }
        p(a, b) {
            let c = this.adapter.getRootObject(a);
            if (c != null) {
                this.cm(a, c, b);
            }
            let d = false;
            this.adapter.clearContainer(a, this.context, (e) => {
                d = true;
                if (e) {
                    this.df(a, b);
                }
            });
            return d;
        }
    }
    ComponentRenderer.$t = /*@__PURE__*/ markType(ComponentRenderer, 'ComponentRenderer');
    ComponentRenderer._defaultInstance = null;
    ComponentRenderer.platform = 3;
    return ComponentRenderer;
})();
/**
 * @hidden
 */
export let ContainerState = /*@__PURE__*/ (() => {
    class ContainerState extends Base {
        constructor() {
            super(...arguments);
            this.i = null;
            this.e = new Dictionary$2(Number_$type, Base.$, 0);
            this.f = new Dictionary$2(Base.$, Number_$type, 0);
            this.d = new Dictionary$2(Number_$type, String_$type, 0);
            this.g = new Dictionary$2(Number_$type, HashSet$1.$.specialize(Number_$type), 0);
            this.c = new Dictionary$2(Number_$type, List$1.$.specialize(Number_$type), 0);
        }
        k(a, b, c, d, e, f) {
            if (d.c("Name")) {
                this.d.item(b, d.a("Name").b);
                e(a, this.d.item(b), c, false);
            }
            this.e.item(b, c);
            this.f.item(c, b);
            if (!this.g.containsKey(b)) {
                this.g.item(b, new HashSet$1(Number_$type, 0));
            }
            this.g.item(b).add_1(f);
            if (f >= 0) {
                if (!this.c.containsKey(f)) {
                    this.c.item(f, new List$1(Number_$type, 0));
                }
                this.c.item(f).add(b);
            }
        }
        a(a) {
            return this.e.containsKey(a);
        }
        b(a) {
            return this.f.containsKey(a);
        }
        j(a) {
            return this.e.item(a);
        }
        l(a, b, c, d) {
            if (this.c.containsKey(c)) {
                let e = this.c.item(c);
                for (let f = 0; f < e.count; f++) {
                    if (!this.g.containsKey(e._inner[f]) || this.g.item(e._inner[f]).count < 1 || (this.g.item(e._inner[f]).count == 1 && this.g.item(e._inner[f]).contains(c))) {
                        if (this.e.containsKey(e._inner[f])) {
                            a.cm(b, this.e.item(e._inner[f]), this);
                        }
                    }
                }
                this.c.removeItem(c);
            }
            let g = this.e.item(c);
            this.f.removeItem(g);
            this.e.removeItem(c);
            if (this.g.containsKey(c)) {
                this.g.removeItem(c);
            }
            if (this.d.containsKey(c)) {
                let h = this.d.item(c);
                this.d.removeItem(c);
                d(b, h, false);
            }
        }
        h(a) {
            if (this.f.containsKey(a)) {
                return this.f.item(a);
            }
            return -1;
        }
    }
    ContainerState.$t = /*@__PURE__*/ markType(ContainerState, 'ContainerState');
    return ContainerState;
})();
