/*
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 { __extends, __values } from "tslib";
import { Base, IEnumerable_$type, fromEnum, typeCast, Date_$type, Boolean_$type, Array_$type, Delegate_$type, runOn, Number_$type, String_$type, EnumUtil, typeGetValue, markType } from "./type";
import { TypeDescriptionContext } from "./TypeDescriptionContext";
import { TypeDescriptionCleanups } from "./TypeDescriptionCleanups";
import { Dictionary$2 } from "./Dictionary$2";
import { List$1 } from "./List$1";
import { Description } from "./Description";
import { DescriptionTreeNode } from "./DescriptionTreeNode";
import { Queue$1 } from "./Queue$1";
import { DescriptionTreeAction } from "./DescriptionTreeAction";
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 { GlobalAnimationState } from "./GlobalAnimationState";
import { TypeDescriptionWellKnownType_$type } from "./TypeDescriptionWellKnownType";
import { Tuple$2 } from "./Tuple$2";
import { DescriptionRefTargetInfo } from "./DescriptionRefTargetInfo";
import { NotImplementedException } from "./NotImplementedException";
import { truncate } from "./number";
import { ComponentRendererAdapter } from "./ComponentRendererAdapter";
import { stringIsNullOrEmpty, stringStartsWith, stringEndsWith } from "./string";
/**
 * @hidden
 */
var ComponentRenderer = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(ComponentRenderer, _super);
    function ComponentRenderer() {
        var _this = _super.call(this) || this;
        _this._adapter = null;
        _this._context = null;
        _this._isProceedOnErrorEnabled = false;
        _this.j = null;
        _this.k = null;
        _this._preserveKeyOrder = false;
        _this._allowNullForRemove = false;
        _this.be = new List$1(Delegate_$type, 0);
        _this.a1 = new Dictionary$2(Base.$, Description.$, 0);
        _this.a2 = new Dictionary$2(Base.$, Boolean_$type, 0);
        _this.a3 = new Dictionary$2(Base.$, Boolean_$type, 0);
        _this.a0 = new Dictionary$2(Base.$, Boolean_$type, 0);
        _this.ay = new Dictionary$2(Base.$, String_$type, 0);
        _this.az = new Dictionary$2(Base.$, Number_$type, 0);
        _this.aw = new Dictionary$2(Base.$, DescriptionTreeNode.$, 0);
        _this.a7 = new Dictionary$2(Base.$, ContainerState.$, 0);
        _this.a4 = new Dictionary$2(Base.$, Queue$1.$.specialize(Queue$1.$.specialize(DescriptionTreeAction.$)), 0);
        _this.ax = new Dictionary$2(Base.$, List$1.$.specialize(Delegate_$type), 0);
        _this.av = new Dictionary$2(Base.$, Boolean_$type, 0);
        _this.a6 = new Dictionary$2(String_$type, DescriptionRef.$, 0);
        _this.a8 = new Dictionary$2(String_$type, Base.$, 0);
        _this.ba = new Dictionary$2(String_$type, Base.$, 0);
        _this.a5 = new Dictionary$2(Base.$, String_$type, 0);
        _this.bl = null;
        _this.bg = new List$1(Delegate_$type, 0);
        _this.a9 = new Dictionary$2(String_$type, List$1.$.specialize(Delegate_$type), 0);
        _this.bd = new List$1(Delegate_$type, 0);
        _this.bf = new List$1(Delegate_$type, 0);
        _this.bc = null;
        _this._shouldNamespaceSystemRefValues = false;
        var a = _this.i();
        _this.adapter = a;
        var adapter_ = _this.adapter;
        var 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.j = new TypeDescriptionPropretyTransforms();
        _this.k = new TypeDescriptionCleanups();
        return _this;
    }
    Object.defineProperty(ComponentRenderer, "defaultInstance", {
        get: function () {
            return ComponentRenderer._defaultInstance;
        },
        set: function (a) {
            ComponentRenderer._defaultInstance = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ComponentRenderer.prototype, "adapter", {
        get: function () {
            return this._adapter;
        },
        set: function (a) {
            this._adapter = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ComponentRenderer.prototype, "context", {
        get: function () {
            return this._context;
        },
        set: function (a) {
            this._context = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(ComponentRenderer.prototype, "isProceedOnErrorEnabled", {
        get: function () {
            return this._isProceedOnErrorEnabled;
        },
        set: function (a) {
            this._isProceedOnErrorEnabled = a;
        },
        enumerable: false,
        configurable: true
    });
    ComponentRenderer.prototype.i = function () {
        return (new ComponentRendererAdapter());
    };
    ComponentRenderer.prototype.toJson = function (a) {
        var e_1, _a, e_2, _b;
        var b = new DescriptionSerializerBuilder();
        var c = new DescriptionSerializer();
        b.f("{");
        b.i();
        b.f("\"descriptions\": {");
        b.i();
        var d = true;
        try {
            for (var _c = __values(fromEnum(this.aw.keys)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var e = _d.value;
                if (d) {
                    d = false;
                }
                else {
                    b.f(",");
                }
                var f = e;
                var g = this.aw.item(e);
                var h = "root";
                h = a(f);
                if (stringIsNullOrEmpty(h)) {
                    h = "root";
                }
                b.e("\"" + h + "\"");
                b.e(": ");
                c.t(this.context, g, b);
            }
        }
        catch (e_1_1) {
            e_1 = { error: e_1_1 };
        }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return))
                    _a.call(_c);
            }
            finally {
                if (e_1)
                    throw e_1.error;
            }
        }
        b.f("");
        b.h();
        b.e("}");
        if (this.ba.count > 0) {
            b.e(",");
        }
        b.f("");
        if (this.ba.count > 0) {
            d = true;
            b.f("refs: {");
            b.i();
            try {
                for (var _e = __values(fromEnum(this.ba.keys)), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var i = _f.value;
                    if (!this.q(i, this.ba.item(i))) {
                        continue;
                    }
                    if (d) {
                        d = false;
                    }
                    else {
                        b.f(",");
                    }
                    this.eg(b, i, this.ba.item(i));
                }
            }
            catch (e_2_1) {
                e_2 = { error: e_2_1 };
            }
            finally {
                try {
                    if (_f && !_f.done && (_b = _e.return))
                        _b.call(_e);
                }
                finally {
                    if (e_2)
                        throw e_2.error;
                }
            }
            b.f("");
            b.h();
            b.f("}");
        }
        b.h();
        b.f("}");
        return b.toString();
    };
    ComponentRenderer.prototype.eg = function (a, b, c) {
        a.e("\"" + b + "\": ");
        this.eh(a, c);
    };
    ComponentRenderer.prototype.eh = function (a, b) {
        if (this.z(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) {
                var 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.w(b)) {
                a.f("[");
                a.i();
                var c = new DataSourceLocalDataProvider();
                c.dataSource = b;
                for (var d = 0; d < c.actualCount; d++) {
                    if (d > 0) {
                        a.f(",");
                    }
                    this.ef(a, c, d);
                }
                a.f("");
                a.h();
                a.e("]");
            }
            else {
                var e = [b];
                var f = new DataSourceLocalDataProvider();
                f.dataSource = e;
                this.ef(a, f, 0);
            }
        }
    };
    ComponentRenderer.prototype.z = function (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;
    };
    ComponentRenderer.prototype.w = function (a) {
        if (typeCast(Array_$type, a) !== null) {
            return true;
        }
        if (typeCast(IEnumerable_$type, a) !== null) {
            return true;
        }
        return false;
    };
    ComponentRenderer.prototype.ef = function (a, b, c) {
        a.f("{");
        a.i();
        var d = b.actualSchema;
        for (var e = 0; e < d.propertyNames.length; e++) {
            if (e > 0) {
                a.f(",");
            }
            var f = d.propertyNames[e];
            if (stringStartsWith(f, "[")) {
                f = f.substr(1, f.length - 2);
            }
            a.e("\"" + f + "\"");
            a.e(": ");
            var 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:
                    var v_ = g;
                    a.e("\"" + (v_.toJSON()) + "\"");
                    break;
                case 11:
                    this.eh(a, g);
                    break;
            }
        }
        a.h();
        a.f("}");
    };
    ComponentRenderer.prototype.q = function (a, b) {
        if (b == null) {
            return true;
        }
        var v_ = b;
        if ((typeof v_ === 'function')) {
            return false;
        }
        return true;
    };
    ComponentRenderer.prototype.createObjectFromJson = function (a, b) {
        var c = new JsonDictionaryParser();
        var d = c.parse(a);
        var e = new DescriptionSerializer();
        var f = false;
        var g = e.d(this.context, d, f, null, false);
        if (g.result == null) {
            return null;
        }
        var h = DescriptionTreeBuilder.createTree(this.context, g.result);
        var i = this.a7.item(b);
        if (h.c("Type")) {
            var j = h.a("Type").b;
            return this.b6(j, h, b, i, true, -1, null);
        }
        else {
            return this.b5(typeCast(JsonDictionaryObject.$, d));
        }
    };
    ComponentRenderer.prototype.loadJson = function (a, b) {
        this.dm(a, b, null, false, false, false);
    };
    ComponentRenderer.prototype.loadJsonOverlay = function (a, b, c) {
        this.dm(a, b, c, true, false, true);
    };
    ComponentRenderer.prototype.loadJsonDelta = function (a, b, c) {
        this.dm(a, b, null, true, c, false);
    };
    Object.defineProperty(ComponentRenderer.prototype, "preserveKeyOrder", {
        get: function () {
            return this._preserveKeyOrder;
        },
        set: function (a) {
            this._preserveKeyOrder = a;
        },
        enumerable: false,
        configurable: true
    });
    ComponentRenderer.prototype.as = function () {
        return false;
    };
    ComponentRenderer.prototype.dp = function (a) {
    };
    Object.defineProperty(ComponentRenderer.prototype, "allowNullForRemove", {
        get: function () {
            return this._allowNullForRemove;
        },
        set: function (a) {
            this._allowNullForRemove = a;
        },
        enumerable: false,
        configurable: true
    });
    ComponentRenderer.prototype.dm = function (a, b, c, d, e, f) {
        var g = new JsonDictionaryParser();
        var h = g.parse(a);
        var i = new DescriptionSerializer();
        i.h = this.isProceedOnErrorEnabled;
        i.g = this.as();
        var j = null;
        if (typeCast(JsonDictionaryObject.$, h) !== null) {
            var k = h;
            if (k.g("skipAlterDataCasing")) {
                var l = k.item("skipAlterDataCasing");
                if (l.value) {
                    this.dp(true);
                }
            }
            else {
                this.dp(false);
            }
            var m = null;
            if (k.g("animationIdleRef") || k.g("hasAnimations")) {
                m = "AnimationIdleHandler";
                if (k.g("animationIdleRef")) {
                    m = k.item("animationIdleRef").value;
                }
            }
            var n = 0;
            if (k.g("animationIdleTimeout")) {
                n = truncate(k.item("animationIdleTimeout").value);
            }
            if (k.g("descriptions")) {
                var o = k.item("descriptions");
                if (typeCast(JsonDictionaryObject.$, o) !== null) {
                    var p = o;
                    var q = p.e();
                    for (var r = 0; r < q.length; r++) {
                        var s = q[r];
                        var t = p.item(s);
                        var u = b(s);
                        if (u == null) {
                            continue;
                        }
                        j = u;
                        var v = false;
                        var w = this.bj();
                        if (w != null) {
                            v = true;
                        }
                        var x = null;
                        if (this.isProceedOnErrorEnabled) {
                            try {
                                x = i.d(this.context, t, v, w, false);
                            }
                            catch (y) {
                                return;
                            }
                        }
                        else {
                            x = i.d(this.context, t, v, w, false);
                        }
                        if (x.result == null && !this.allowNullForRemove) {
                            continue;
                        }
                        if (f) {
                            if (!this.bb.containsKey(u)) {
                                var z = null;
                                if (this.isProceedOnErrorEnabled) {
                                    try {
                                        z = i.d(this.context, t, v, w, true);
                                    }
                                    catch (aa) {
                                        return;
                                    }
                                }
                                else {
                                    z = i.d(this.context, t, v, w, true);
                                }
                                this.ea(z.result, u, d, true, false, m, n);
                                m = null;
                                var ab = c(s);
                                var ac = this.bb.item(u);
                                this.dg(this.aw.item(u), ab, ac, u);
                            }
                        }
                        this.ea(x.result, u, d, e, false, m, n);
                        m = null;
                    }
                }
            }
            if (k.g("refs") && j != null) {
                var ad = k.item("refs");
                var ae = this.ai(ad);
                if (!ae && typeCast(JsonDictionaryObject.$, ad) !== null) {
                    var af = ad;
                    var ag = af.e();
                    for (var ah = 0; ah < ag.length; ah++) {
                        var ai = ag[ah];
                        var aj = af.item(ai);
                        if (typeCast(JsonDictionaryValue.$, aj) !== null) {
                            var ak = aj;
                            this.provideRefValue(j, ai, ak.value);
                        }
                        else if (typeCast(JsonDictionaryArray.$, aj) !== null) {
                            var al = aj;
                            var am = this.a(al);
                            this.provideRefValue(j, ai, am);
                        }
                        else {
                            var an = this.b5(aj);
                            this.provideRefValue(j, ai, an);
                        }
                    }
                }
            }
            if (k.g("modules") && j != null) {
                var ao = k.item("modules");
                this.af(ao);
            }
            if (k.g("strings") && j != null) {
                var ap = k.item("strings");
                this.am(ap);
            }
            if (k.g("onInit") && j != null) {
                var aq = k.item("onInit");
                this.ag(aq);
            }
            if (k.g("onViewInit") && j != null) {
                var ar = k.item("onViewInit");
                this.ah(ar);
            }
        }
    };
    ComponentRenderer.prototype.provideRefValueFromJson = function (a, b, c) {
        var d = b;
        var e = new JsonDictionaryParser();
        var f = e.parse(c);
        if (typeCast(JsonDictionaryValue.$, f) !== null) {
            var g = f;
            this.provideRefValue(a, d, g.value);
        }
        else if (typeCast(JsonDictionaryArray.$, f) !== null) {
            var h = f;
            var i = this.a(h);
            this.provideRefValue(a, d, i);
        }
        else {
            var j = this.b5(f);
            this.provideRefValue(a, d, j);
        }
    };
    ComponentRenderer.prototype.addMemberPathTransformer = function (a) {
        this.be.add(a);
    };
    ComponentRenderer.prototype.removeMemberPathTransformer = function (a) {
        this.be.remove(a);
    };
    ComponentRenderer.prototype.bj = function () {
        var _this = this;
        if (this.be.count > 0) {
            return function (a) {
                var b = a;
                for (var c = 0; c < _this.be.count; c++) {
                    b = _this.be._inner[c](b);
                }
                return b;
            };
        }
        return null;
    };
    ComponentRenderer.prototype.ai = function (a) {
        return false;
    };
    ComponentRenderer.prototype.af = function (a) {
        return false;
    };
    ComponentRenderer.prototype.am = function (a) {
        return false;
    };
    ComponentRenderer.prototype.ag = function (a) {
        return false;
    };
    ComponentRenderer.prototype.ah = function (a) {
        return false;
    };
    ComponentRenderer.prototype.cw = function (a, b, c) {
        var d = a;
        if (c != null) {
            d = c.k(b);
        }
        else {
            if (TypeDescriptionMetadata.shouldCamelize(b)) {
                d = TypeDescriptionMetadata.camelize(d);
            }
        }
        if (stringEndsWith(d, "Ref")) {
            d = d.substr(0, d.length - ("Ref").length);
        }
        return d;
    };
    ComponentRenderer.prototype.dg = function (a, b, c, d) {
        var e_3, _a;
        if (!c.b(b)) {
            c.k(d, this.aw.item(d).g, b, this.aw.item(d), runOn(this, this.du), -1);
        }
        try {
            for (var _b = __values(fromEnum(a.f())), _c = _b.next(); !_c.done; _c = _b.next()) {
                var e = _c.value;
                this.dh(this.cw(e.c, ComponentRenderer.platform, e.a), e.b, b, c, d, a.g);
            }
        }
        catch (e_3_1) {
            e_3 = { error: e_3_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_3)
                    throw e_3.error;
            }
        }
    };
    ComponentRenderer.prototype.dh = function (a, b, c, d, e, f) {
        var e_4, _a;
        var _this = this;
        if (typeCast(DescriptionTreeNode.$, b) !== null) {
            var g = b;
            var h = this.adapter.getPropertyValue(c, a);
            if (!d.b(h) && !d.a(g.g)) {
                d.k(e, g.g, h, g, runOn(this, this.du), f);
            }
            try {
                for (var _b = __values(fromEnum(g.f())), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var i = _c.value;
                    this.dh(a + "." + this.cw(i.c, ComponentRenderer.platform, i.a), i.b, c, d, e, g.g);
                }
            }
            catch (e_4_1) {
                e_4 = { error: e_4_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_4)
                        throw e_4.error;
                }
            }
        }
        if (typeCast(Array_$type, b) !== null) {
            var j_1 = new Dictionary$2(Number_$type, DescriptionTreeNode.$, 0);
            var k_1 = 0;
            var l = b.length;
            var o = b;
            for (var n = 0; n < o.length; n++) {
                var m = o[n];
                if (typeCast(DescriptionTreeNode.$, m) !== null) {
                    var p = m;
                    j_1.item(k_1, p);
                }
                k_1++;
            }
            var q = this.adapter.getPropertyValue(c, a);
            k_1 = 0;
            this.adapter.forPropertyValueItem(c, a, function (r) {
                var e_5, _a;
                if (j_1.containsKey(k_1)) {
                    var s = j_1.item(k_1);
                    if (!d.b(r) && !d.a(s.g)) {
                        d.k(e, s.g, r, s, runOn(_this, _this.du), f);
                    }
                    try {
                        for (var _b = __values(fromEnum(s.f())), _c = _b.next(); !_c.done; _c = _b.next()) {
                            var t = _c.value;
                            _this.dh(a + "." + t.c, t.b, c, d, e, s.g);
                        }
                    }
                    catch (e_5_1) {
                        e_5 = { error: e_5_1 };
                    }
                    finally {
                        try {
                            if (_c && !_c.done && (_a = _b.return))
                                _a.call(_b);
                        }
                        finally {
                            if (e_5)
                                throw e_5.error;
                        }
                    }
                }
                k_1++;
            });
            if (l > 0 && k_1 == 0) {
                var r_1 = this.c1(a);
                this.adapter.forPropertyValueItem(c, r_1, function (s) {
                    var e_6, _a;
                    if (j_1.containsKey(k_1)) {
                        var t = j_1.item(k_1);
                        if (!d.b(s) && !d.a(t.g)) {
                            d.k(e, t.g, s, t, runOn(_this, _this.du), f);
                        }
                        try {
                            for (var _b = __values(fromEnum(t.f())), _c = _b.next(); !_c.done; _c = _b.next()) {
                                var u = _c.value;
                                _this.dh(r_1 + "." + u.c, u.b, c, d, e, t.g);
                            }
                        }
                        catch (e_6_1) {
                            e_6 = { error: e_6_1 };
                        }
                        finally {
                            try {
                                if (_c && !_c.done && (_a = _b.return))
                                    _a.call(_b);
                            }
                            finally {
                                if (e_6)
                                    throw e_6.error;
                            }
                        }
                    }
                    k_1++;
                });
            }
        }
    };
    ComponentRenderer.prototype.c1 = function (a) {
        var b = a.lastIndexOf('.');
        var c = null;
        var d = a;
        if (b > 0) {
            c = a.substr(0, b);
            d = a.substr(b + 1);
        }
        d = "actual" + this.cy(d);
        if (c != null) {
            return c + "." + d;
        }
        return d;
    };
    ComponentRenderer.prototype.cy = function (a) {
        return a.substr(0, 1).toUpperCase() + a.substr(1);
    };
    ComponentRenderer.prototype.a = function (a) {
        var b = new Array(a.items.length);
        for (var c = 0; c < a.items.length; c++) {
            var d = this.b5(a.items[c]);
            b[c] = d;
        }
        return b;
    };
    ComponentRenderer.prototype.b5 = function (a) {
        if (a == null) {
            return null;
        }
        var b = {};
        var dict_ = b;
        var c = a.e();
        for (var d = 0; d < c.length; d++) {
            var key_ = c[d];
            if (typeCast(JsonDictionaryObject.$, a.item(key_)) !== null) {
                var val_ = this.b5(a.item(key_));
                dict_[key_] = val_;
            }
            else if (typeCast(JsonDictionaryArray.$, a.item(key_)) !== null) {
                var val_ = this.a(a.item(key_));
                dict_[key_] = val_;
            }
            else {
                var val_ = a.item(key_).value;
                dict_[key_] = val_;
            }
        }
        return dict_;
    };
    Object.defineProperty(ComponentRenderer.prototype, "bb", {
        get: function () {
            return this.a7;
        },
        enumerable: false,
        configurable: true
    });
    ComponentRenderer.prototype.cleanup = function (a, b) {
        this.bl = a;
        this.ea(null, a, false, false, b, null, 0);
    };
    ComponentRenderer.prototype.render = function (a, b) {
        this.ea(a, b, false, false, false, null, 0);
    };
    ComponentRenderer.prototype.ea = function (a, b, c, d, e, f, g) {
        var _this = this;
        if (!this.a7.containsKey(b)) {
            this.a7.item(b, new ContainerState());
            this.a7.item(b).i = b;
        }
        this.a1.item(b, a);
        this.a2.item(b, c);
        this.a3.item(b, d);
        this.a0.item(b, e);
        this.ay.item(b, f);
        this.az.item(b, g);
        this.dq(b, function () { return _this.d8(b); });
    };
    ComponentRenderer.prototype.dq = function (a, b) {
        this.adapter.onUIThread(a, b);
    };
    ComponentRenderer.prototype.d8 = function (a) {
        var e_7, _a, e_8, _b, e_9, _c, e_10, _d;
        var _this = this;
        if (this.a1.containsKey(a)) {
            var b = this.a2.containsKey(a) ? this.a2.item(a) : false;
            var c = this.a3.containsKey(a) ? this.a3.item(a) : false;
            var d = this.a1.item(a);
            var e = this.ay.containsKey(a) ? this.ay.item(a) : null;
            var f = this.az.containsKey(a) ? this.az.item(a) : 0;
            this.a1.removeItem(a);
            var g = DescriptionTreeBuilder.createTreeWithOptions(this.context, d, this.preserveKeyOrder);
            var h = null;
            if (this.aw.containsKey(a)) {
                h = this.aw.item(a);
            }
            var i = DescriptionTreeReconciler.c(h, g, b);
            if (!c && b) {
                g = h.b();
                DescriptionTreeReconciler.a(h, i);
                var j = h;
                h = g;
                g = j;
                i = DescriptionTreeReconciler.c(h, g, false);
            }
            if (c) {
                var k = DescriptionTreeReconciler.a(h, i);
                if (!this.a7.containsKey(a)) {
                    this.a7.addItem(a, ((function () {
                        var $ret = new ContainerState();
                        $ret.i = a;
                        return $ret;
                    })()));
                }
                var l_1 = this.a7.item(a);
                if (k.a.count > 0) {
                    try {
                        for (var _e = __values(fromEnum(k.a)), _f = _e.next(); !_f.done; _f = _e.next()) {
                            var m = _f.value;
                            if (l_1.a(m)) {
                                var n = l_1.j(m);
                                this.de(a, n, l_1);
                            }
                        }
                    }
                    catch (e_7_1) {
                        e_7 = { error: e_7_1 };
                    }
                    finally {
                        try {
                            if (_f && !_f.done && (_a = _e.return))
                                _a.call(_e);
                        }
                        finally {
                            if (e_7)
                                throw e_7.error;
                        }
                    }
                }
                if (k.c.count > 0) {
                    try {
                        for (var _g = __values(fromEnum(k.c)), _h = _g.next(); !_h.done; _h = _g.next()) {
                            var o = _h.value;
                            var p = this.cc(a, l_1, o);
                            var q = this.adapter.getPropertyValue(p, o.j);
                            if (q != null) {
                                if (!l_1.b(q)) {
                                    var r = o.g;
                                    if (typeCast(DescriptionTreeNode.$, r) !== null) {
                                        var s = r.g;
                                        l_1.k(a, s, q, r, runOn(this, this.du), o.c.g);
                                    }
                                }
                            }
                        }
                    }
                    catch (e_8_1) {
                        e_8 = { error: e_8_1 };
                    }
                    finally {
                        try {
                            if (_h && !_h.done && (_b = _g.return))
                                _b.call(_g);
                        }
                        finally {
                            if (e_8)
                                throw e_8.error;
                        }
                    }
                }
                if (k.d.count > 0) {
                    try {
                        for (var _j = __values(fromEnum(k.d)), _k = _j.next(); !_k.done; _k = _j.next()) {
                            var t = _k.value;
                            var u = t.g;
                            if (u != null) {
                                if (!l_1.b(u)) {
                                    var v = t.g;
                                    if (typeCast(DescriptionTreeNode.$, v) !== null) {
                                        var w = v.g;
                                        this.aw.item(a, v);
                                    }
                                }
                            }
                        }
                    }
                    catch (e_9_1) {
                        e_9 = { error: e_9_1 };
                    }
                    finally {
                        try {
                            if (_k && !_k.done && (_c = _j.return))
                                _c.call(_j);
                        }
                        finally {
                            if (e_9)
                                throw e_9.error;
                        }
                    }
                }
                if (k.b.count > 0) {
                    var _loop_1 = function (x) {
                        var y = x.c.a(x.j).b;
                        if (y == null) {
                            return "continue";
                        }
                        var z = new Dictionary$2(String_$type, DescriptionTreeNode.$, 0);
                        for (var aa = 0; aa < y.length; aa++) {
                            var ab = y[aa];
                            if (typeCast(DescriptionTreeNode.$, ab) !== null) {
                                var ac = ab;
                                if (ac.c("Name")) {
                                    z.item(ac.a("Name").b, ac);
                                }
                            }
                        }
                        if (z.count == 0) {
                            return "continue";
                        }
                        var ad = this_1.cc(a, l_1, x);
                        var ae = this_1.adapter.getPropertyValue(ad, x.j);
                        if (ae != null) {
                            var af_1 = 0;
                            this_1.adapter.forPropertyValueItem(ad, x.j, function (ag) {
                                if (z.containsKey(_this.adapter.getPropertyValue(ag, "Name").toString())) {
                                    if (!l_1.b(ag)) {
                                        var ah = z.item(_this.adapter.getPropertyValue(ag, "Name").toString());
                                        if (typeCast(DescriptionTreeNode.$, ah) !== null) {
                                            var ai = ah.g;
                                            l_1.k(a, ai, ag, ah, runOn(_this, _this.du), x.c.g);
                                        }
                                    }
                                }
                                af_1++;
                            });
                        }
                    };
                    var this_1 = this;
                    try {
                        for (var _l = __values(fromEnum(k.b)), _m = _l.next(); !_m.done; _m = _l.next()) {
                            var x = _m.value;
                            _loop_1(x);
                        }
                    }
                    catch (e_10_1) {
                        e_10 = { error: e_10_1 };
                    }
                    finally {
                        try {
                            if (_m && !_m.done && (_d = _l.return))
                                _d.call(_l);
                        }
                        finally {
                            if (e_10)
                                throw e_10.error;
                        }
                    }
                }
            }
            else {
                this.aw.item(a, g);
            }
            if (!c) {
                if (e != null && this.v(e)) {
                    var ag_1 = this.ba.item(e);
                    if (ag_1 != null) {
                        var ah = GlobalAnimationState.d.i();
                        if (f > 0) {
                            GlobalAnimationState.d.n(function (ai) { return ag_1(ai); }, ah, f);
                        }
                        else {
                            GlobalAnimationState.d.m(function () { return ag_1(false); }, ah);
                        }
                    }
                }
                this.d9(a, i);
            }
            if (this.a0.item(a)) {
                this.d6(a);
                if (this.a7.containsKey(a)) {
                    this.a7.removeItem(a);
                }
            }
        }
        if (this.bl != null) {
            if (this.a1.containsKey(this.bl)) {
                this.a1.removeItem(this.bl);
            }
            if (this.a2.containsKey(this.bl)) {
                this.a2.removeItem(this.bl);
            }
            if (this.a3.containsKey(this.bl)) {
                this.a3.removeItem(this.bl);
            }
            if (this.a0.containsKey(this.bl)) {
                this.a0.removeItem(this.bl);
            }
            if (this.aw.containsKey(this.bl)) {
                this.aw.removeItem(this.bl);
            }
            if (this.a4.containsKey(this.bl)) {
                this.a4.removeItem(this.bl);
            }
            if (this.ax.containsKey(this.bl)) {
                this.ax.removeItem(this.bl);
            }
            if (this.av.containsKey(this.bl)) {
                this.av.removeItem(this.bl);
            }
            if (this.az.containsKey(this.bl)) {
                this.az.removeItem(this.bl);
            }
            if (this.ay.containsKey(this.bl)) {
                this.ay.removeItem(this.bl);
            }
            this.bl = null;
        }
    };
    ComponentRenderer.prototype.getTargetValue = function (a, b, c) {
        var d = this.context.getMetadata(a, this.cy(b));
        var e = d.k(ComponentRenderer.platform);
        return this.adapter.getPropertyValue(c, e);
    };
    ComponentRenderer.prototype.setTargetValue = function (a, b, c, d, e) {
        var f = this.context.getMetadata(a, this.cy(b));
        var g = f.k(ComponentRenderer.platform);
        this.adapter.setPropertyValue(c, g, f, d, e, null);
    };
    ComponentRenderer.prototype.executeMethod = function (a, b, c) {
        var _this = this;
        var d = new JsonDictionaryParser();
        var e = d.parse(b);
        if (!this.a7.containsKey(a)) {
            this.a7.item(a, new ContainerState());
            this.a7.item(a).i = a;
        }
        var f = this.a7.item(a);
        var g = new DescriptionSerializer();
        g.h = this.isProceedOnErrorEnabled;
        g.g = this.as();
        var h = this.aw.item(a);
        var i = null;
        var j = new List$1(Base.$, 0);
        var k = new List$1(TypeDescriptionMetadata.$, 0);
        if (typeCast(JsonDictionaryObject.$, e) !== null) {
            var l = null;
            var m = e;
            if (m.g("targetRef")) {
                l = this.cu(m, "targetRef");
            }
            var n = null;
            if (m.g("methodName")) {
                n = this.cu(m, "methodName");
            }
            if (l != null) {
                if (this.a8.containsKey(l)) {
                    i = this.a8.item(l);
                }
            }
            else {
                i = f.j(h.g);
            }
            if (m.g("args")) {
                var o = m.item("args");
                for (var p = 0; p < o.items.length; p++) {
                    var q = o.items[p];
                    var r = this.g(h, q, g);
                    var s = null;
                    if (typeCast(DescriptionTreeNode.$, r.g) !== null && r.g.i == "EmbeddedRef") {
                        s = this.ce(a, r.g);
                    }
                    else {
                        s = this.b9(r, a, f);
                    }
                    if (r.d.knownType == 8 && r.d.specificType == "string") {
                        s = this.bu(r.d.specificExternalType, s, r.d);
                    }
                    j.add1(s);
                    k.add(r.d);
                }
            }
            var t_1 = null;
            if (m.g("return")) {
                var u = m.item("return");
                var v = this.g(h, u, g);
                t_1 = v.d;
            }
            this.adapter.executeMethod(i, n, j.toArray(), k.toArray(), function (w) {
                var x = _this.cz(w, t_1);
                c(x);
            });
        }
    };
    ComponentRenderer.prototype.ce = function (a, b) {
        if (b.i == "EmbeddedRef") {
            var c = "uuid";
            var d = null;
            for (var e = 0; e < b.f().count; e++) {
                if (b.f()._inner[e].c == "RefType") {
                    c = b.f()._inner[e].b;
                }
                if (b.f()._inner[e].c == "Value") {
                    d = b.f()._inner[e].b;
                }
            }
            if (d != null) {
                for (var f = 0; f < this.bd.count; f++) {
                    var g = this.bd._inner[f](a, c, d);
                    if (g != null) {
                        return g;
                    }
                }
                if (c == "name") {
                    var h = d;
                    if (this.a8.containsKey(h)) {
                        return this.a8.item(h);
                    }
                    if (this.ba.containsKey(h)) {
                        return this.ba.item(h);
                    }
                }
                return null;
            }
        }
        return null;
    };
    ComponentRenderer.bi = function (a) {
        if (typeCast(Date_$type, a) !== null) {
            return a.getTime();
        }
        if (a == null) {
            return 0;
        }
        return a;
    };
    ComponentRenderer.prototype.cz = function (a, b) {
        var _this = this;
        var c = new JsonDictionaryObject();
        c.item("knownType", ((function () {
            var $ret = new JsonDictionaryValue();
            $ret.e = 2;
            $ret.value = EnumUtil.getName(TypeDescriptionWellKnownType_$type, b.knownType);
            return $ret;
        })()));
        if (b.specificType != null) {
            c.item("specificType", ((function () {
                var $ret = new JsonDictionaryValue();
                $ret.e = 2;
                $ret.value = b.specificType;
                return $ret;
            })()));
        }
        if (b.specificExternalType != null) {
            c.item("specificExternalType", ((function () {
                var $ret = new JsonDictionaryValue();
                $ret.e = 2;
                $ret.value = b.specificExternalType;
                return $ret;
            })()));
        }
        if (b.collectionElementType != null) {
            c.item("collectionElementType", ((function () {
                var $ret = new JsonDictionaryValue();
                $ret.e = 2;
                $ret.value = b.collectionElementType;
                return $ret;
            })()));
        }
        switch (b.knownType) {
            case 0: break;
            case 1:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 0;
                    $ret.value = ComponentRenderer.bi(a);
                    return $ret;
                })()));
                break;
            case 2:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = a != null ? a.toString() : null;
                    return $ret;
                })()));
                break;
            case 3:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = a != null ? a.toString() : null;
                    return $ret;
                })()));
                break;
            case 4:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = _this.cf(a);
                    return $ret;
                })()));
                break;
            case 5:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = _this.ch(a);
                    return $ret;
                })()));
                break;
            case 6:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = _this.cg(a);
                    return $ret;
                })()));
                break;
            case 7:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 1;
                    $ret.value = a;
                    return $ret;
                })()));
                break;
            case 8: break;
            case 9: break;
            case 10: break;
            case 11:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = _this.ck(a);
                    return $ret;
                })()));
                break;
            case 12:
                c.item("result", this.cm(a));
                break;
            case 13: break;
            case 14:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = _this.cl(a);
                    return $ret;
                })()));
                break;
            case 15: break;
            case 16:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = _this.ci(a);
                    return $ret;
                })()));
                break;
            case 17: break;
            case 18: break;
            case 19: break;
            case 20: break;
            case 21:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = _this.cn(a);
                    return $ret;
                })()));
                break;
            case 22: break;
            case 23:
                c.item("result", ((function () {
                    var $ret = new JsonDictionaryValue();
                    $ret.e = 2;
                    $ret.value = _this.cj(a);
                    return $ret;
                })()));
                break;
        }
        return c.b();
    };
    ComponentRenderer.prototype.cj = function (a) {
        return this.adapter.serializeDoubleCollection(a);
    };
    ComponentRenderer.prototype.cn = function (a) {
        return this.adapter.serializeTimespan(a);
    };
    ComponentRenderer.prototype.ci = function (a) {
        return this.adapter.serializeColorCollection(a);
    };
    ComponentRenderer.prototype.cl = function (a) {
        return this.adapter.serializeRect(a);
    };
    ComponentRenderer.prototype.cm = function (a) {
        return this.adapter.serializeSize(a);
    };
    ComponentRenderer.prototype.ck = function (a) {
        return this.adapter.serializePoint(a);
    };
    ComponentRenderer.prototype.cg = function (a) {
        return this.adapter.serializeBrushCollection(a);
    };
    ComponentRenderer.prototype.ch = function (a) {
        return this.adapter.serializeColor(a);
    };
    ComponentRenderer.prototype.cf = function (a) {
        return this.adapter.serializeBrush(a);
    };
    ComponentRenderer.prototype.g = function (a, b, c) {
        var d = new DescriptionTreeAction();
        d.a = 0;
        d.c = a;
        d.j = "*argument";
        var e = new TypeDescriptionMetadata();
        e.propertyName = "*argument";
        var f;
        var g = this.cu(b, "knownType");
        var h = EnumUtil.tryParse$1(TypeDescriptionWellKnownType_$type, g, true, f);
        f = h.p2;
        e.knownType = f;
        e.specificExternalType = this.cu(b, "specificExternalType");
        e.specificType = this.cu(b, "specificType");
        e.collectionElementType = this.cu(b, "collectionElementType");
        d.d = e;
        var i = null;
        i = this.b8(e, b, c);
        d.g = i;
        return d;
    };
    ComponentRenderer.prototype.cu = function (a, b) {
        if (typeCast(JsonDictionaryObject.$, a) !== null) {
            var c = a;
            if (c.g(b)) {
                return c.item(b).value != null ? c.item(b).value.toString() : null;
            }
        }
        return null;
    };
    ComponentRenderer.prototype.b8 = function (a, b, c) {
        if (typeCast(JsonDictionaryObject.$, b) !== null) {
            var d = b;
            if (d.g("value")) {
                var e = (d.item("value")) != null ? (d.item("value")) : null;
                return this.b4(a.knownType, a.specificType, a.specificExternalType, a.collectionElementType, e, c);
            }
        }
        return null;
    };
    ComponentRenderer.prototype.b4 = function (a, b, c, d, e, f) {
        if (typeCast(JsonDictionaryObject.$, e) !== null) {
            var g = e;
            if (g.g("type") || g.g("refType")) {
                var h = f.c(this.context, g.b());
                if (h != null) {
                    var i = h.result;
                    if (i == null) {
                        return null;
                    }
                    return DescriptionTreeBuilder.createTreeWithOptions(this.context, i, this.preserveKeyOrder);
                }
                return null;
            }
            else if (a == 11) {
                var j = DescriptionSerializer.k(this.context, g);
                return DescriptionTreeBuilder.createTreeWithOptions(this.context, j, this.preserveKeyOrder);
            }
            else if (a == 14) {
                var k = DescriptionSerializer.k(this.context, g);
                return DescriptionTreeBuilder.createTreeWithOptions(this.context, k, this.preserveKeyOrder);
            }
            else if (a == 12) {
                var l = DescriptionSerializer.k(this.context, g);
                return DescriptionTreeBuilder.createTreeWithOptions(this.context, l, this.preserveKeyOrder);
            }
        }
        else if (typeCast(JsonDictionaryArray.$, e) !== null) {
            var m = e;
            var n = "string";
            var o = false;
            if (a == 10) {
                n = c;
            }
            if (a == 9) {
                o = true;
                n = d;
            }
            var p = new Array(m.items.length);
            var q = void 0;
            var r = void 0;
            var s = void 0;
            var t = void 0;
            var u = this.dj(o, n, b, c, q, r, s, t);
            q = u.p4;
            r = u.p5;
            s = u.p6;
            t = u.p7;
            if (m.items != null) {
                for (var v = 0; v < m.items.length; v++) {
                    var w = m.items[v];
                    var x = this.b4(q, r, s, t, w, f);
                    p[v] = x;
                }
            }
            return p;
        }
        else if (typeCast(JsonDictionaryValue.$, e) !== null) {
            return e.value;
        }
        return e;
    };
    ComponentRenderer.prototype.dj = function (a, b, c, d, e, f, g, h) {
        if (a) {
            e = 8;
            f = b;
            g = null;
            h = null;
            return {
                p4: e,
                p5: f,
                p6: g,
                p7: h
            };
        }
        var i = c;
        if (d != null) {
            i = d;
        }
        h = null;
        switch (d) {
            case "string":
                if (c != null && c != "string") {
                    e = 8;
                    f = "string";
                    g = d;
                }
                else {
                    e = 2;
                    f = null;
                    g = null;
                }
                return {
                    p4: e,
                    p5: f,
                    p6: g,
                    p7: h
                };
            case "double":
                e = 1;
                f = "double";
                g = "double";
                return {
                    p4: e,
                    p5: f,
                    p6: g,
                    p7: h
                };
            case "int":
                e = 1;
                f = "double";
                g = "double";
                return {
                    p4: e,
                    p5: f,
                    p6: g,
                    p7: h
                };
            case "long":
                e = 1;
                f = "double";
                g = "double";
                return {
                    p4: e,
                    p5: f,
                    p6: g,
                    p7: h
                };
            case "bool":
                e = 1;
                f = "double";
                g = "double";
                return {
                    p4: e,
                    p5: f,
                    p6: g,
                    p7: h
                };
        }
        e = 8;
        f = c;
        g = d;
        return {
            p4: e,
            p5: f,
            p6: g,
            p7: h
        };
    };
    ComponentRenderer.prototype.resolveRefValue = function (a, b, c) {
        var _this = this;
        this.dq(a, function () {
            if (!_this.a7.containsKey(a)) {
                _this.a7.addItem(a, ((function () {
                    var $ret = new ContainerState();
                    $ret.i = a;
                    return $ret;
                })()));
            }
            var d = _this.a7.item(a);
            if (!_this.hasRef(b)) {
                if (_this.a8.containsKey(b)) {
                    c(_this.a8.item(b));
                    return;
                }
                c(null);
                return;
            }
            var e = _this.f(b);
            var f = _this.cb(e);
            c(f);
        });
    };
    ComponentRenderer.prototype.resolveRefName = function (a, b, c) {
        var _this = this;
        this.dq(a, function () {
            if (!_this.a7.containsKey(a)) {
                _this.a7.addItem(a, ((function () {
                    var $ret = new ContainerState();
                    $ret.i = a;
                    return $ret;
                })()));
            }
            var d = _this.a7.item(a);
            if (b != null && _this.a5.containsKey(b)) {
                c(_this.a5.item(b));
                return;
            }
            c(null);
        });
    };
    ComponentRenderer.prototype.provideRefValue = function (a, b, c) {
        var _this = this;
        this.dq(a, function () {
            if (!_this.a7.containsKey(a)) {
                _this.a7.addItem(a, ((function () {
                    var $ret = new ContainerState();
                    $ret.i = a;
                    return $ret;
                })()));
            }
            var d = _this.a7.item(a);
            _this.du(a, b, c, true);
        });
    };
    ComponentRenderer.prototype.removeRefValue = function (a, b) {
        var _this = this;
        this.dq(a, function () {
            if (!_this.a7.containsKey(a)) {
                _this.a7.addItem(a, ((function () {
                    var $ret = new ContainerState();
                    $ret.i = a;
                    return $ret;
                })()));
            }
            var c = _this.a7.item(a);
            _this.removeRefValueCore(a, b, true);
        });
    };
    ComponentRenderer.prototype.d6 = function (a) {
        var e_11, _a;
        var b = this.a7.item(a);
        var c = new List$1(String_$type, 0);
        try {
            for (var _b = __values(fromEnum(this.a6.keys)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var d = _c.value;
                if (this.a6.item(d).c == 0) {
                    c.add(d);
                }
            }
        }
        catch (e_11_1) {
            e_11 = { error: e_11_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_11)
                    throw e_11.error;
            }
        }
        for (var e = 0; e < c.count; e++) {
            var f = this.shouldNamespaceSystemRefValues;
            this.shouldNamespaceSystemRefValues = false;
            this.removeRefValueCore(a, c._inner[e], this.ba.containsKey(c._inner[e]));
            this.shouldNamespaceSystemRefValues = f;
            if (this.bc != null && this.bc.count > 0) {
                for (var g = 0; g < this.bc.count; g++) {
                    this.bc._inner[g](a, c._inner[e]);
                }
            }
        }
    };
    ComponentRenderer.prototype.clearRefValues = function (a) {
        var _this = this;
        this.dq(a, function () {
            if (!_this.a7.containsKey(a)) {
                _this.a7.addItem(a, ((function () {
                    var $ret = new ContainerState();
                    $ret.i = a;
                    return $ret;
                })()));
            }
            var b = _this.a7.item(a);
            _this.clearUserRefValues();
        });
    };
    ComponentRenderer.prototype.x = function (a) {
        if (this.av.containsKey(a) && this.av.item(a)) {
            return false;
        }
        if (this.a4.containsKey(a) && this.a4.item(a).count > 0) {
            return false;
        }
        return true;
    };
    ComponentRenderer.prototype.queueForIdle = function (a, b) {
        var _this = this;
        this.dq(a, function () {
            if (_this.x(a)) {
                b();
            }
            else {
                if (!_this.ax.containsKey(a)) {
                    _this.ax.item(a, new List$1(Delegate_$type, 0));
                }
                _this.ax.item(a).add(b);
            }
        });
    };
    ComponentRenderer.prototype.tryFlushIdleActions = function (a) {
        if (this.x(a)) {
            if (this.ax.containsKey(a)) {
                var b = new List$1(Delegate_$type, 1, this.ax.item(a));
                this.ax.item(a).clear();
                for (var c = 0; c < b.count; c++) {
                    b._inner[c]();
                }
            }
        }
    };
    ComponentRenderer.prototype.d9 = function (a, b) {
        var c = this.a7.item(a);
        this.dr(a, c, b);
    };
    ComponentRenderer.prototype.ee = function (a, b) {
        if (this.isProceedOnErrorEnabled) {
            try {
                this.df(a, b, true);
            }
            catch (c) {
                this.av.item(a, false);
            }
        }
        else {
            this.df(a, b, true);
        }
    };
    ComponentRenderer.prototype.el = function (a, b) {
        if (this.isProceedOnErrorEnabled) {
            try {
                this.df(a, b, false);
            }
            catch (c) {
                this.av.item(a, false);
            }
        }
        else {
            this.df(a, b, false);
        }
    };
    ComponentRenderer.prototype.df = function (a, b, c) {
        if (!c) {
            if (this.av.containsKey(a) && this.av.item(a)) {
                return;
            }
        }
        this.av.item(a, true);
        var d = true;
        while (d && this.a4.item(a).count > 0) {
            while (this.a4.item(a).count > 0 && this.a4.item(a).c().count < 1) {
                this.a4.item(a).b();
            }
            if (this.a4.item(a).count < 1) {
                break;
            }
            var e = this.a4.item(a).c();
            while (e.count > 0) {
                var f = e.b();
                d = this.ac(a, b, f);
                if (!d) {
                    break;
                }
            }
        }
        if (d) {
            this.av.item(a, false);
        }
        if (this.x(a)) {
            this.tryFlushIdleActions(a);
        }
    };
    ComponentRenderer.prototype.dr = function (a, b, c) {
        var d = new Queue$1(DescriptionTreeAction.$);
        for (var e = 0; e < c.count; e++) {
            d.g(c._inner[e]);
        }
        if (!this.a4.containsKey(a)) {
            this.a4.addItem(a, new Queue$1(Queue$1.$.specialize(DescriptionTreeAction.$)));
        }
        this.a4.item(a).g(d);
        this.el(a, b);
    };
    ComponentRenderer.prototype.ds = function (a, b, c) {
        for (var d = 0; d < c.count; d++) {
            this.ac(a, b, c._inner[d]);
        }
    };
    ComponentRenderer.prototype.ac = function (a, b, c) {
        switch (c.a) {
            case 5: return this.ad(a, b, c);
            case 2: return this.ae(a, b, c);
            case 4: return this.aj(a, b, c);
            case 3: return this.ak(a, b, c);
            case 1: return this.al(a, b, c);
            case 0: return this.an(a, b, c);
        }
        return true;
    };
    ComponentRenderer.prototype.an = function (a, b, c) {
        var d = this.cc(a, b, c);
        this.au(a, b, c, d);
        return true;
    };
    ComponentRenderer.prototype.au = function (a, b, c, d) {
        var e = this.b9(c, a, b);
        e = this.j.transform(ComponentRenderer.platform, e, c);
        var f = false;
        if (this.bg != null && this.bg.count > 0) {
            for (var g = 0; g < this.bg.count; g++) {
                var h = this.bg._inner[g];
                var i = this.cx(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.ar(a, b, c.i(ComponentRenderer.platform), c.d, e, d);
        }
        else {
            this.ei(a, b, c.i(ComponentRenderer.platform), c.d, e, c.h, d);
        }
        return true;
    };
    ComponentRenderer.prototype.cx = function (a, b) {
        var c = b.c;
        var d = "";
        if (c != this.aw.item(a)) {
            var e = this.cv(a, c);
            d = e;
        }
        if (d.length > 0) {
            d += ".";
        }
        d += b.j;
        return d;
    };
    ComponentRenderer.prototype.cv = function (a, b) {
        if (b == null) {
            return "";
        }
        var c = this.c2("", this.aw.item(a), b);
        if (c.c) {
            return c.d;
        }
        return "";
    };
    ComponentRenderer.prototype.c2 = function (a, b, c) {
        if (b == c) {
            return new Tuple$2(Boolean_$type, String_$type, true, a);
        }
        if (a.length > 0) {
            a += ".";
        }
        var d = b.f();
        for (var e = 0; e < d.count; e++) {
            var 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 {
                    var g = a + f.c;
                    var h = this.c2(g, f.b, c);
                    if (h.c) {
                        return h;
                    }
                }
            }
            if (f.a != null && f.a.knownType == 9) {
                var i = f.b;
                for (var j = 0; j < i.length; j++) {
                    if (typeCast(DescriptionTreeNode.$, i[j]) !== null) {
                        var k = i[j];
                        if (k.g == c.g) {
                            a += f.c + "[" + j + "]";
                            return new Tuple$2(Boolean_$type, String_$type, true, a);
                        }
                        else {
                            var l = a + f.c + "[" + j + "]";
                            var m = this.c2(l, k, c);
                            if (m.c) {
                                return m;
                            }
                        }
                    }
                }
            }
        }
        return new Tuple$2(Boolean_$type, String_$type, false, a);
    };
    ComponentRenderer.prototype.ar = function (a, b, c, d, e, f) {
        var e_12, _a;
        if (this.a9.containsKey(c)) {
            try {
                for (var _b = __values(fromEnum(this.a9.item(c))), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var g = _c.value;
                    g(c, f, e);
                }
            }
            catch (e_12_1) {
                e_12 = { error: e_12_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_12)
                        throw e_12.error;
                }
            }
        }
        this.adapter.setOrUpdateCollectionOnTarget(a, c, d, this.context, f, e);
        return true;
    };
    ComponentRenderer.prototype.b9 = function (a, b, c) {
        if (a.d == null) {
            return a.g;
        }
        switch (a.d.knownType) {
            case 10: return this.bm(a, b, c);
            case 7: return this.bn(a);
            case 4: return this.bo(a);
            case 6: return this.bp(a);
            case 23: return this.bt(a);
            case 9: return this.bm(a, b, c);
            case 5: return this.bq(a);
            case 16: return this.br(a);
            case 20: return this.co(a, c);
            case 22: return this.cr(a, c);
            case 15: return null;
            case 3: return this.bs(a);
            case 19: return this.cp(a, c);
            case 8: return this.bv(a, b, c);
            case 13: return null;
            case 18: return this.cq(a, c);
            case 1: return this.bw(a);
            case 11: return this.bx(a);
            case 14: return this.by(a);
            case 12: return this.bz(a);
            case 2: return this.b0(a);
            case 21: return this.b1(a);
            case 17: return this.b2(a, b, c);
            case 0: return null;
        }
        return null;
    };
    ComponentRenderer.prototype.b2 = function (a, b, c) {
        var d = this.b3(a.g, a, b, c);
        return d;
    };
    ComponentRenderer.prototype.b3 = function (a, b, c, d) {
        if (typeof a === 'string') {
            if (stringStartsWith(a, "@d:")) {
                var v_ = a.substr(3);
                a = new Date(v_);
            }
        }
        if (typeCast(Array_$type, a) !== null) {
            var e = a;
            var f = new Array(e.length);
            for (var g = 0; g < e.length; g++) {
                var h = this.b3(e[g], b, c, d);
                f[g] = h;
            }
            a = f;
        }
        if (typeCast(DescriptionTreeNode.$, a) !== null) {
            var i = a;
            if (i.i == "EmbeddedRef") {
                return this.b6(i.i, a, c, d, false, b.c.g, b.d);
            }
        }
        return a;
    };
    ComponentRenderer.prototype.b1 = function (a) {
        return a.g;
    };
    ComponentRenderer.prototype.b0 = function (a) {
        return a.g != null ? a.g.toString() : null;
    };
    ComponentRenderer.prototype.bz = function (a) {
        var b = a.g;
        var width_ = b.width;
        var height_ = b.height;
        var c = { width: width_, height: height_ };
        return c;
    };
    ComponentRenderer.prototype.by = function (a) {
        var b = a.g;
        var top_ = b.top;
        var left_ = b.left;
        var width_ = b.width;
        var height_ = b.height;
        var c = { left: left_, top: top_, width: width_, height: height_ };
        return c;
    };
    ComponentRenderer.prototype.bx = function (a) {
        var b = a.g;
        var x_ = b.x;
        var y_ = b.y;
        var c = { x: x_, y: y_ };
        return c;
    };
    ComponentRenderer.prototype.bw = function (a) {
        if (a.g == null) {
            if (a.d != null && ((a.d.specificType == "double" || a.d.specificType == "float") || (a.d.specificExternalType == "double" || a.d.specificExternalType == "float"))) {
                return NaN;
            }
            return 0;
        }
        var b = a.g;
        if (typeof b === 'number') {
            b = typeGetValue(b);
        }
        if (a.d != null && a.d.specificExternalType != null) {
            switch (a.d.specificExternalType) {
                case "int":
                    b = truncate(b);
                    break;
                case "float":
                    b = b;
                    break;
                case "short":
                    b = truncate(b);
                    break;
                case "long":
                    b = truncate(b);
                    break;
            }
        }
        return b;
    };
    ComponentRenderer.prototype.e = function (a) {
        if (this.a6.containsKey(a)) {
            var b = this.a6.item(a);
            return b;
        }
        var c = new DescriptionRef(a);
        this.a6.addItem(a, c);
        return c;
    };
    ComponentRenderer.prototype.cq = function (a, b) {
        return a.g == null ? null : this.e(a.g);
    };
    ComponentRenderer.prototype.bv = function (a, b, c) {
        var d = a.d.specificType;
        if (d == null) {
            d = a.d.specificExternalType;
        }
        if (typeCast(DescriptionTreeNode.$, a.g) !== null) {
            var e = a.g;
            if (e.c("Type")) {
                d = e.a("Type").b;
            }
        }
        var f = this.b6(d, a.g, b, c, false, a.c.g, a.d);
        return f;
    };
    ComponentRenderer.prototype.cp = function (a, b) {
        return a.g == null ? null : this.e(a.g);
    };
    ComponentRenderer.prototype.bs = function (a) {
        if (typeof a.g === 'string') {
            var v_ = a.g;
            a.g = new Date(v_);
        }
        return a.g;
    };
    ComponentRenderer.prototype.co = function (a, b) {
        return a.g == null ? null : this.e(a.g);
    };
    ComponentRenderer.prototype.cr = function (a, b) {
        return a.g == null ? null : this.e(a.g);
    };
    ComponentRenderer.prototype.ct = function (a) {
        return a;
    };
    ComponentRenderer.prototype.br = function (a) {
        var b = a.g;
        if (b == null) {
            return null;
        }
        var c = new Array(b.length);
        for (var d = 0; d < b.length; d++) {
            c[d] = this.ct(b[d]);
        }
        return c;
    };
    ComponentRenderer.prototype.bq = function (a) {
        return this.ct(a.g);
    };
    ComponentRenderer.prototype.bp = function (a) {
        var b = a.g;
        if (b == null) {
            return null;
        }
        var c = new Array(b.length);
        for (var d = 0; d < b.length; d++) {
            c[d] = this.cs(b[d]);
        }
        return c;
    };
    ComponentRenderer.prototype.bt = function (a) {
        var b = a.g;
        if (b == null) {
            return null;
        }
        var c = new Array(b.length);
        for (var d = 0; d < b.length; d++) {
            c[d] = b[d];
        }
        return c;
    };
    ComponentRenderer.prototype.cs = function (a) {
        return a;
    };
    ComponentRenderer.prototype.bo = function (a) {
        return this.cs(a.g);
    };
    ComponentRenderer.prototype.bn = function (a) {
        return a.g;
    };
    ComponentRenderer.prototype.addTargetPropertyUpdatingListener = function (a) {
        this.bg.add(a);
    };
    ComponentRenderer.prototype.removeTargetPropertyUpdatingListener = function (a) {
        this.bg.remove(a);
    };
    ComponentRenderer.prototype.addPropertyUpdatingListener = function (a, b) {
        if (!this.a9.containsKey(a)) {
            this.a9.addItem(a, new List$1(Delegate_$type, 0));
        }
        this.a9.item(a).add(b);
    };
    ComponentRenderer.prototype.addReferenceLookupListener = function (a) {
        this.bd.add(a);
    };
    ComponentRenderer.prototype.removeReferenceLookupListener = function (a) {
        this.bd.remove(a);
    };
    ComponentRenderer.prototype.removePropertyUpdatingListener = function (a, b) {
        if (this.a9.containsKey(a)) {
            this.a9.item(a).remove(b);
            if (this.a9.item(a).count == 0) {
                this.a9.removeItem(a);
            }
        }
    };
    ComponentRenderer.prototype.addNamespaceLookupListener = function (a) {
        this.bf.add(a);
    };
    ComponentRenderer.prototype.removeNamespaceLookupListener = function (a) {
        this.bf.remove(a);
    };
    ComponentRenderer.prototype.addCleanupListener = function (a) {
        if (this.bc == null) {
            this.bc = new List$1(Delegate_$type, 0);
        }
        this.bc.add(a);
    };
    ComponentRenderer.prototype.removeCleanupListener = function (a) {
        if (this.bc != null) {
            this.bc.remove(a);
        }
    };
    ComponentRenderer.prototype.bm = function (a, b, c) {
        if (a.g == null) {
            return null;
        }
        var d = a.g;
        var e = new List$1(Base.$, 0);
        var 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 (var g = 0; g < d.length; g++) {
            var h = f;
            if (typeCast(DescriptionTreeNode.$, d[g]) !== null) {
                var i = d[g];
                if (i.c("Type")) {
                    h = i.a("Type").b;
                }
            }
            var j = this.b6(h, d[g], b, c, false, a.c.g, a.d);
            e.add1(j);
        }
        return e.toArray();
    };
    ComponentRenderer.prototype.ei = function (a, b, c, d, e, f, g) {
        var _this = this;
        if (typeCast(DescriptionRef.$, e) !== null) {
            var h = e;
            var i = false;
            if (f != null && typeof f === 'string') {
                if (this.hasRef(f)) {
                    var j = this.f(f);
                    if (Base.equalsStatic(j, e)) {
                        i = true;
                    }
                    else {
                        j.j(a, g, c);
                    }
                }
            }
            if (this.u(e)) {
                var k = e;
                if (k.e != null && k.e.length > 0 && this.a8.containsKey(k.e)) {
                    k.a = true;
                }
                e = this.cb(e);
                this.ej(g, c, d, e, f, k);
            }
            else {
                this.adapter.onPendingRef(g, c, d, e);
            }
            var l = null;
            l = function (m, n) {
                var o = m;
                if (o.e != null && o.e.length > 0 && _this.a8.containsKey(o.e)) {
                    o.a = true;
                }
                var p = _this.cb(m);
                _this.ej(g, c, d, p, n.b, o);
            };
            if (!i) {
                h.g(a, g, c, l);
            }
            return;
        }
        this.ej(g, c, d, e, f, null);
    };
    ComponentRenderer.prototype.v = function (a) {
        return this.ba.containsKey(a);
    };
    Object.defineProperty(ComponentRenderer.prototype, "shouldNamespaceSystemRefValues", {
        get: function () {
            return this._shouldNamespaceSystemRefValues;
        },
        set: function (a) {
            this._shouldNamespaceSystemRefValues = a;
        },
        enumerable: false,
        configurable: true
    });
    ComponentRenderer.prototype.du = function (a, b, c, d) {
        var e = null;
        if (d) {
            if (this.ba.containsKey(b)) {
                e = this.ba.item(b);
            }
            this.ba.item(b, c);
            if (c != null) {
                this.a5.item(c, b);
            }
        }
        else {
            if (this.shouldNamespaceSystemRefValues) {
                var f = "";
                if (this.bf != null && this.bf.count > 0) {
                    for (var g = 0; g < this.bf.count; g++) {
                        f = this.bf._inner[g](a);
                    }
                }
                if (!stringIsNullOrEmpty(f)) {
                    b = f + "/" + b;
                }
            }
            if (this.a8.containsKey(b)) {
                e = this.a8.item(b);
            }
            this.a8.item(b, c);
            if (c != null) {
                this.a5.item(c, b);
            }
            if (this.a6.containsKey(b)) {
                this.a6.item(b).a = true;
            }
        }
        if (this.a6.containsKey(b)) {
            this.a6.item(b).f(e, c);
        }
    };
    ComponentRenderer.prototype.removeRefValueCore = function (a, b, c) {
        var d = null;
        if (c) {
            if (this.ba.containsKey(b)) {
                d = this.ba.item(b);
            }
            this.ba.removeItem(b);
            if (d != null && this.a5.containsKey(d)) {
                this.a5.removeItem(d);
            }
        }
        else {
            if (this.shouldNamespaceSystemRefValues) {
                var e = "";
                if (this.bf != null && this.bf.count > 0) {
                    for (var f = 0; f < this.bf.count; f++) {
                        e = this.bf._inner[f](a);
                    }
                }
                if (!stringIsNullOrEmpty(e)) {
                    b = e + "/" + b;
                }
            }
            if (this.a8.containsKey(b)) {
                d = this.a8.item(b);
            }
            this.a8.removeItem(b);
            if (d != null && this.a5.containsKey(d)) {
                this.a5.removeItem(d);
            }
        }
        if (this.a6.containsKey(b)) {
            this.a6.item(b).f(d, this.cb(this.a6.item(b)));
            if (this.a6.item(b).c <= 0) {
                this.a6.item(b).h();
                this.a6.removeItem(b);
            }
        }
    };
    ComponentRenderer.prototype.clearUserRefValues = function () {
        var e_13, _a, e_14, _b;
        var a = new List$1(String_$type, 0);
        try {
            for (var _c = __values(fromEnum(this.ba.keys)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var b = _d.value;
                a.add(b);
            }
        }
        catch (e_13_1) {
            e_13 = { error: e_13_1 };
        }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return))
                    _a.call(_c);
            }
            finally {
                if (e_13)
                    throw e_13.error;
            }
        }
        try {
            for (var _e = __values(fromEnum(a)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var c = _f.value;
                this.removeRefValueCore(null, c, true);
            }
        }
        catch (e_14_1) {
            e_14 = { error: e_14_1 };
        }
        finally {
            try {
                if (_f && !_f.done && (_b = _e.return))
                    _b.call(_e);
            }
            finally {
                if (e_14)
                    throw e_14.error;
            }
        }
    };
    ComponentRenderer.prototype.u = function (a) {
        return this.ba.containsKey(a.e) || this.a8.containsKey(a.e);
    };
    ComponentRenderer.prototype.cb = function (a) {
        if (this.ba.containsKey(a.e)) {
            return this.ba.item(a.e);
        }
        if (this.a8.containsKey(a.e)) {
            return this.a8.item(a.e);
        }
        return null;
    };
    ComponentRenderer.prototype.hasRef = function (a) {
        return this.a6.containsKey(a);
    };
    ComponentRenderer.prototype.f = function (a) {
        return this.a6.item(a);
    };
    ComponentRenderer.prototype.getMissingRefs = function () {
        var e_15, _a;
        var a = new List$1(String_$type, 0);
        try {
            for (var _b = __values(fromEnum(this.a6.keys)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                if (!this.u(this.a6.item(b))) {
                    a.add(b);
                }
            }
        }
        catch (e_15_1) {
            e_15 = { error: e_15_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_15)
                    throw e_15.error;
            }
        }
        return a.toArray();
    };
    ComponentRenderer.prototype.getRefChangeInfos = function (a) {
        var e_16, _a;
        var b = new List$1(DescriptionRefTargetInfo.$, 0);
        if (this.a6.containsKey(a)) {
            var _loop_2 = function (c) {
                b.add(((function () {
                    var $ret = new DescriptionRefTargetInfo();
                    $ret.container = c.b;
                    $ret.propertyName = c.d;
                    $ret.target = c.c;
                    return $ret;
                })()));
            };
            try {
                for (var _b = __values(fromEnum(this.a6.item(a).b)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var c = _c.value;
                    _loop_2(c);
                }
            }
            catch (e_16_1) {
                e_16 = { error: e_16_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_16)
                        throw e_16.error;
                }
            }
        }
        return b.toArray();
    };
    ComponentRenderer.prototype.cc = function (a, b, c) {
        return b.j(c.c.g);
    };
    ComponentRenderer.prototype.al = function (a, b, c) {
        var d = this.cc(a, b, c);
        this.aq(a, b, c, d);
        return true;
    };
    ComponentRenderer.prototype.aq = function (a, b, c, d) {
        this.adapter.resetPropertyOnTarget(a, c.i(ComponentRenderer.platform), c.d, d);
        return true;
    };
    ComponentRenderer.prototype.ak = function (a, b, c) {
        if (c.c == null) {
            return this.ap(a, b, c);
        }
        else {
            var d = this.cc(a, b, c);
            this.eb(a, b, c, d);
        }
        return true;
    };
    ComponentRenderer.prototype.eb = function (a, b, c, d) {
        var e = c.i(ComponentRenderer.platform);
        var f = c.d.collectionElementType;
        if (typeCast(DescriptionTreeNode.$, c.g) !== null) {
            var g = c.g;
            if (g.c("Type")) {
                f = g.a("Type").b;
            }
        }
        if (f == null) {
            f = c.d.specificExternalType;
        }
        var h = this.b6(f, c.g, a, b, false, c.c.g, c.d);
        this.adapter.replaceItemInCollection(e, c.d, d, c.e, h);
        if (c.h != null && typeCast(DescriptionTreeNode.$, c.h) !== null) {
            var i = c.h.g;
            if (i >= 0) {
                var j = b.j(i);
                if (j != null) {
                    this.de(a, j, b);
                }
            }
        }
    };
    ComponentRenderer.prototype.ap = function (a, b, c) {
        var _this = this;
        var d = this.adapter.getRootObject(a);
        if (d != null) {
            this.de(a, d, b);
        }
        if (!(typeCast(DescriptionTreeNode.$, c.g) !== null)) {
            throw new NotImplementedException(0);
        }
        var e = c.g;
        var f = false;
        this.adapter.replaceRootItem(a, e.i, this.context, function (g) {
            var h = _this.adapter.getRootObject(a);
            b.k(a, e.g, h, e, runOn(_this, _this.du), -1);
            var i = _this.bh(e);
            _this.ds(a, b, i);
            f = true;
            if (g) {
                _this.ee(a, b);
            }
        });
        return f;
    };
    ComponentRenderer.prototype.de = function (a, b, c) {
        var e_17, _a;
        var d = this.bk(a, b, c);
        try {
            for (var _b = __values(fromEnum(this.a6.values)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var e = _c.value;
                e.i(b);
            }
        }
        catch (e_17_1) {
            e_17 = { error: e_17_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_17)
                    throw e_17.error;
            }
        }
        if (d != -1) {
            c.l(this, a, d, runOn(this, this.removeRefValueCore));
        }
        this.k.b(ComponentRenderer.platform, b);
    };
    ComponentRenderer.prototype.bk = function (a, b, c) {
        return c.h(b);
    };
    ComponentRenderer.prototype.aj = function (a, b, c) {
        if (c.c == null) {
            return this.ao(a, b, c);
        }
        else {
            var d = this.cc(a, b, c);
            this.dy(a, b, c, d);
        }
        return true;
    };
    ComponentRenderer.prototype.dy = function (a, b, c, d) {
        var e = c.i(ComponentRenderer.platform);
        this.adapter.removeItemFromCollection(e, c.d, d, c.f);
        if (c.h != null && typeCast(DescriptionTreeNode.$, c.h) !== null) {
            var f = c.h.g;
            if (f >= 0) {
                var g = b.j(f);
                if (g != null) {
                    this.de(a, g, b);
                }
            }
        }
    };
    ComponentRenderer.prototype.ao = function (a, b, c) {
        var _this = this;
        var d = this.adapter.getRootObject(a);
        if (d != null) {
            this.de(a, d, b);
        }
        var e = false;
        this.adapter.removeRootItem(a, this.context, function (f) {
            e = true;
            if (f) {
                _this.ee(a, b);
            }
        });
        return e;
    };
    ComponentRenderer.prototype.ae = function (a, b, c) {
        if (c.c == null) {
            return this.n(a, b, c);
        }
        else {
            var d = this.cc(a, b, c);
            this.c4(a, b, c, d);
        }
        return true;
    };
    ComponentRenderer.prototype.n = function (a, b, c) {
        var _this = this;
        if (!(typeCast(DescriptionTreeNode.$, c.g) !== null)) {
            throw new NotImplementedException(0);
        }
        var d = c.g;
        var e = false;
        this.adapter.replaceRootItem(a, d.i, this.context, function (f) {
            var g = _this.adapter.getRootObject(a);
            b.k(a, d.g, g, d, runOn(_this, _this.du), -1);
            var h = _this.bh(d);
            _this.ds(a, b, h);
            e = true;
            if (f) {
                _this.ee(a, b);
            }
        });
        return e;
    };
    ComponentRenderer.prototype.c4 = function (a, b, c, d) {
        var e = c.i(ComponentRenderer.platform);
        var f = c.d.collectionElementType;
        if (typeCast(DescriptionTreeNode.$, c.g) !== null) {
            var g = c.g;
            if (g.c("Type")) {
                f = g.a("Type").b;
            }
        }
        if (f == null) {
            f = c.d.specificExternalType;
        }
        var h = this.b6(f, c.g, a, b, false, c.c.g, c.d);
        this.adapter.addItemToCollection(e, c.d, d, c.e, h);
    };
    ComponentRenderer.prototype.b6 = function (a, b, c, d, e, f, g) {
        if (this.y(a)) {
            return b;
        }
        var h = null;
        if (b != null && typeCast(DescriptionTreeNode.$, b) !== null) {
            var i = b;
            var j = null;
            if (i.c("Name")) {
                j = i.a("Name").b;
                if (!stringIsNullOrEmpty(j)) {
                    if (this.shouldNamespaceSystemRefValues) {
                        var k = "";
                        if (this.bf != null && this.bf.count > 0) {
                            for (var l = 0; l < this.bf.count; l++) {
                                k = this.bf._inner[l](c);
                            }
                        }
                        if (!stringIsNullOrEmpty(k)) {
                            j = k + "/" + j;
                        }
                    }
                    if (this.a8.containsKey(j)) {
                        var m = this.a8.item(j);
                        h = m;
                    }
                }
            }
            if (h == null) {
                h = this.context.y(a, c, j);
            }
        }
        else if (b != null) {
            h = this.context.y(a, c, null);
        }
        if (b == null) {
            return h;
        }
        if (typeCast(DescriptionTreeNode.$, b) !== null) {
            var n = b;
            if (n.i == "EmbeddedRef") {
                var o = "uuid";
                var p = null;
                for (var 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 (var r = 0; r < this.bd.count; r++) {
                        var s = this.bd._inner[r](c, o, p);
                        if (s != null) {
                            return s;
                        }
                    }
                    if (o == "name") {
                        var t = p;
                        if (this.a8.containsKey(t)) {
                            return this.a8.item(t);
                        }
                    }
                    return null;
                }
            }
            else {
                if (!this.a7.containsKey(c)) {
                    this.a7.addItem(c, ((function () {
                        var $ret = new ContainerState();
                        $ret.i = c;
                        return $ret;
                    })()));
                    d = this.a7.item(c);
                }
                d.k(c, n.g, h, n, runOn(this, this.du), f);
                var u = this.bh(n);
                this.ds(c, d, u);
                if (e) {
                    d.l(this, c, n.g, runOn(this, this.removeRefValueCore));
                }
            }
        }
        var v = (a == "object" || a == "Object");
        var w = v && typeof b === 'string' && stringStartsWith(b.toString(), "[") && stringEndsWith(b.toString(), "]");
        if (w) {
            var newVal_ = b;
            var x = JSON.parse(newVal_);
            return x;
        }
        if (!v && typeof b === 'string' && a.toLowerCase() != "string") {
            return this.bu(a, b, g);
        }
        if (v) {
            return b;
        }
        return h;
    };
    ComponentRenderer.prototype.y = function (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";
    };
    ComponentRenderer.prototype.bu = function (a, b, c) {
        return this.context.t(a, b, c, this.o());
    };
    ComponentRenderer.prototype.o = function () {
        return true;
    };
    ComponentRenderer.prototype.bh = function (a) {
        var b = a.f();
        var c = new List$1(DescriptionTreeAction.$, 0);
        for (var d = 0; d < b.count; d++) {
            var 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;
    };
    ComponentRenderer.prototype.ad = function (a, b, c) {
        if (c.c == null) {
            return this.s(a, b, c);
        }
        else {
            var d = this.cc(a, b, c);
            this.db(a, b, c, d);
        }
        return true;
    };
    ComponentRenderer.prototype.db = function (a, b, c, d) {
        var e = c.i(ComponentRenderer.platform);
        this.adapter.clearCollection(d, e, c.d);
        if (c.h != null && typeCast(Array_$type, c.h) !== null) {
            var f = c.h;
            for (var g = 0; g < f.length; g++) {
                var h = f[g];
                if (h != null && typeCast(DescriptionTreeNode.$, h) !== null) {
                    var i = h.g;
                    if (i >= 0) {
                        var j = b.j(i);
                        if (j != null) {
                            this.de(a, j, b);
                        }
                    }
                }
            }
        }
    };
    ComponentRenderer.prototype.ej = function (a, b, c, d, e, f) {
        var e_18, _a;
        if (this.a9.containsKey(b)) {
            try {
                for (var _b = __values(fromEnum(this.a9.item(b))), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var g = _c.value;
                    g(b, a, d);
                }
            }
            catch (e_18_1) {
                e_18 = { error: e_18_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_18)
                        throw e_18.error;
                }
            }
        }
        this.adapter.setPropertyValue(a, b, c, d, e, f);
    };
    ComponentRenderer.prototype.ca = function (a, b) {
        return this.adapter.getPropertyValue(a, b);
    };
    ComponentRenderer.prototype.s = function (a, b, c) {
        return this.r(a, b);
    };
    ComponentRenderer.prototype.r = function (a, b) {
        var _this = this;
        var c = this.adapter.getRootObject(a);
        if (c != null) {
            this.de(a, c, b);
        }
        var d = false;
        this.adapter.clearContainer(a, this.context, function (e) {
            d = true;
            if (e) {
                _this.ee(a, b);
            }
        });
        return d;
    };
    ComponentRenderer.$t = markType(ComponentRenderer, 'ComponentRenderer');
    ComponentRenderer._defaultInstance = null;
    ComponentRenderer.platform = 3;
    return ComponentRenderer;
}(Base));
export { ComponentRenderer };
/**
 * @hidden
 */
var ContainerState = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(ContainerState, _super);
    function ContainerState() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _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);
        return _this;
    }
    ContainerState.prototype.k = function (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);
        }
    };
    ContainerState.prototype.a = function (a) {
        return this.e.containsKey(a);
    };
    ContainerState.prototype.b = function (a) {
        return this.f.containsKey(a);
    };
    ContainerState.prototype.j = function (a) {
        return this.e.item(a);
    };
    ContainerState.prototype.l = function (a, b, c, d) {
        if (this.c.containsKey(c)) {
            var e = this.c.item(c);
            for (var 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.de(b, this.e.item(e._inner[f]), this);
                    }
                }
            }
            this.c.removeItem(c);
        }
        var 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)) {
            var h = this.d.item(c);
            this.d.removeItem(c);
            d(b, h, false);
        }
    };
    ContainerState.prototype.h = function (a) {
        if (this.f.containsKey(a)) {
            return this.f.item(a);
        }
        return -1;
    };
    ContainerState.$t = markType(ContainerState, 'ContainerState');
    return ContainerState;
}(Base));
export { ContainerState };
