define("translationmanagerImpl", ["translationmanagerApi", "clientkernelLoaderApi", "clientkernelEventbusApi", "clientkernelModulesApi", "moneyApi"],
    function(translationmanagerApi, clientkernelLoaderApi, clientkernelEventbusApi, clientkernelModulesApi, moneyApi) {
        "use strict";

        function $iterator(o) {
            if (o instanceof Array) return function() {
                return {
                    cur: 0,
                    arr: o,
                    hasNext: function() {
                        return this.cur < this.arr.length;
                    },
                    next: function() {
                        return this.arr[this.cur++];
                    }
                };
            };
            return typeof(o.iterator) == 'function' ? $bind(o, o.iterator) : o.iterator;
        };;
        var $fid = 0;

        function $bind(o, m) {
            if (m == null) return null;
            if (m.__id__ == null) m.__id__ = $fid++;
            var f;
            if (o.hx__closures__ == null) o.hx__closures__ = {};
            else f = o.hx__closures__[m.__id__];
            if (f == null) {
                f = function() {
                    return f.method.apply(f.scope, arguments);
                };
                f.scope = o;
                f.method = m;
                o.hx__closures__[m.__id__] = f;
            }
            return f;
        };
        var $_;
        var $estr = function() {
            return _hcmn_.js_Boot.__string_rec(this, '');
        };
        if (typeof haxe == 'undefined') {
            var haxe = {};
        };

        haxe.IMap = function() {}
        haxe.IMap.prototype = {

        };
        if (!haxe.ds) {
            haxe.ds = {};
        };
        if (!haxe.ds._StringMap) {
            haxe.ds._StringMap = {};
        };
        haxe.ds._StringMap.StringMapIterator = function(map, keys) {
            this.map = map;
            this.keys = keys;
            this.index = 0;
            this.count = keys.length;
        };
        haxe.ds._StringMap.StringMapIterator.__name__ = ["haxe", "ds", "_StringMap", "StringMapIterator"];
        haxe.ds._StringMap.StringMapIterator.prototype.map = null;
        haxe.ds._StringMap.StringMapIterator.prototype.keys = null;
        haxe.ds._StringMap.StringMapIterator.prototype.index = null;
        haxe.ds._StringMap.StringMapIterator.prototype.count = null;
        haxe.ds._StringMap.StringMapIterator.prototype.hasNext = function() {
            return this.index < this.count;
        };
        haxe.ds._StringMap.StringMapIterator.prototype.next = function() {
            return this.map.get(this.keys[this.index++]);
        };
        haxe.ds._StringMap.StringMapIterator.prototype.__class__ = haxe.ds._StringMap.StringMapIterator;
        if (typeof js == 'undefined') {
            var js = {};
        };
        if (!js._Boot) {
            js._Boot = {};
        };
        js._Boot.HaxeError = function(val) {
            Error.call(this);
            this.val = val;
            this.message = String(val);
            if (Error.captureStackTrace) Error.captureStackTrace(this, js._Boot.HaxeError);
        };
        js._Boot.HaxeError.__name__ = ["js", "_Boot", "HaxeError"];
        js._Boot.HaxeError.__super__ = Error;
        for (var k in Error.prototype) js._Boot.HaxeError.prototype[k] = Error.prototype[k];
        js._Boot.HaxeError.prototype.val = null;
        js._Boot.HaxeError.prototype.__class__ = js._Boot.HaxeError;
        if (typeof translationmanagerImpl == 'undefined') {
            var translationmanagerImpl = {};
        };
        translationmanagerImpl.Activator = function() {};
        translationmanagerImpl.Activator = ck_implements(translationmanagerImpl.Activator, clientkernelModulesApi.IModuleActivator);
        translationmanagerImpl.Activator.__interfaces__ = [clientkernelModulesApi.IModuleActivator];
        translationmanagerImpl.Activator.__name__ = ["translationmanagerImpl", "Activator"];
        translationmanagerImpl.Activator.prototype.start = function(context) {
            context.getServiceTracker([clientkernelLoaderApi.IAssetRegistry, moneyApi.IMoneyFormatter]).then(function(context1) {
                translationmanagerImpl.ExternalService.initialize(context1);
            });
        };
        translationmanagerImpl.Activator.prototype.stop = function(context) {};
        translationmanagerImpl.Activator.main = function() {
            null;
        };
        translationmanagerImpl.Activator.prototype.__class__ = translationmanagerImpl.Activator;
        translationmanagerImpl.ExternalService = function() {};
        translationmanagerImpl.ExternalService.__name__ = ["translationmanagerImpl", "ExternalService"];
        translationmanagerImpl.ExternalService.assetRegistry = null;
        translationmanagerImpl.ExternalService.moneyFormatter = null;
        translationmanagerImpl.ExternalService.stringTables = null;
        translationmanagerImpl.ExternalService.styleTables = null;
        translationmanagerImpl.ExternalService.initialize = function(context) {
            translationmanagerImpl.ExternalService.assetRegistry = context.getAnyService(clientkernelLoaderApi.IAssetRegistry, null);
            translationmanagerImpl.ExternalService.moneyFormatter = context.getAnyService(moneyApi.IMoneyFormatter, null);
            translationmanagerImpl.ExternalService.assetRegistry.getAsset("multilanguage_assets").getAllContent().then(function(multilanguageData) {
                translationmanagerImpl.ExternalService.parseMLData(multilanguageData);
                context.registerService(new translationmanagerImpl.TranslationManager(), translationmanagerApi.ITranslationManager, null);
            });
        };
        translationmanagerImpl.ExternalService.parseMLData = function(multilanguageData) {
            translationmanagerImpl.ExternalService.stringTables = new _hcmn_.haxe_ds_StringMap();
            translationmanagerImpl.ExternalService.styleTables = new _hcmn_.haxe_ds_StringMap();
            var tempKeys = [];
            var $it0 = multilanguageData.keys();
            while ($it0.hasNext()) {
                var k = $it0.next();
                tempKeys.push(k);
            }
            var i = tempKeys.length;
            while (i > 0) {
                i--;
                var key = tempKeys[i];
                if (key.indexOf("stringtable") != -1) {
                    var value;
                    value = _hcmn_.__map_reserved[key] != null ? multilanguageData.getReserved(key) : multilanguageData.h[key];
                    translationmanagerImpl.ExternalService.stringTables.set(key, value);
                } else if (key.indexOf("styletable") != -1) {
                    var value1;
                    value1 = _hcmn_.__map_reserved[key] != null ? multilanguageData.getReserved(key) : multilanguageData.h[key];
                    translationmanagerImpl.ExternalService.styleTables.set(key, value1);
                }
            }
        };
        translationmanagerImpl.ExternalService.prototype.__class__ = translationmanagerImpl.ExternalService;
        translationmanagerImpl.StringTable = function(stringtable) {
            this.messages = new _hcmn_.haxe_ds_StringMap();
            var msgs = stringtable.messages;
            var _g = 0;
            var _g1 = _hcmn_.Reflect.fields(msgs);
            while (_g < _g1.length) {
                var i = _g1[_g];
                ++_g;
                var value = _hcmn_.Reflect.field(msgs, i);
                this.messages.set(i, value);
            }
        };
        translationmanagerImpl.StringTable = ck_implements(translationmanagerImpl.StringTable, translationmanagerApi.IStringTable);
        translationmanagerImpl.StringTable.__interfaces__ = [translationmanagerApi.IStringTable];
        translationmanagerImpl.StringTable.__name__ = ["translationmanagerImpl", "StringTable"];
        translationmanagerImpl.StringTable.prototype.messages = null;
        translationmanagerImpl.StringTable.prototype.getString = function(id, fillIn) {
            if (fillIn != null) return this.replaceTokens(this.messages.get(id), fillIn);
            return this.messages.get(id);
        };
        translationmanagerImpl.StringTable.prototype.replaceTokens = function(message, fillIn) {
            return message;
        };
        translationmanagerImpl.StringTable.prototype.__class__ = translationmanagerImpl.StringTable;
        translationmanagerImpl.StyleTable = function(styletable) {
            this.styleTable = new _hcmn_.haxe_ds_StringMap();
            var styles = styletable.styles;
            var _g = 0;
            var _g1 = _hcmn_.Reflect.fields(styles);
            while (_g < _g1.length) {
                var i = _g1[_g];
                ++_g;
                var attributes = new _hcmn_.haxe_ds_StringMap();
                var value = _hcmn_.Reflect.field(styles, i);
                this.styleTable.set(i, value);
            }
        };
        translationmanagerImpl.StyleTable = ck_implements(translationmanagerImpl.StyleTable, translationmanagerApi.IStyleTable);
        translationmanagerImpl.StyleTable.__interfaces__ = [translationmanagerApi.IStyleTable];
        translationmanagerImpl.StyleTable.__name__ = ["translationmanagerImpl", "StyleTable"];
        translationmanagerImpl.StyleTable.prototype.styleTable = null;
        translationmanagerImpl.StyleTable.prototype.getAttributes = function(id) {
            var attributes = this.styleTable.get(id);
            return attributes;
        };
        translationmanagerImpl.StyleTable.prototype.__class__ = translationmanagerImpl.StyleTable;
        translationmanagerImpl.TranslationManager = function() {
            this.createStringTables();
            this.createStyleTables();
        };
        translationmanagerImpl.TranslationManager = ck_implements(translationmanagerImpl.TranslationManager, translationmanagerApi.ITranslationManager);
        translationmanagerImpl.TranslationManager = ck_implements(translationmanagerImpl.TranslationManager, clientkernelModulesApi.IService);
        translationmanagerImpl.TranslationManager.__interfaces__ = [translationmanagerApi.ITranslationManager, clientkernelModulesApi.IService];
        translationmanagerImpl.TranslationManager.__name__ = ["translationmanagerImpl", "TranslationManager"];
        translationmanagerImpl.TranslationManager.prototype.stringTables = null;
        translationmanagerImpl.TranslationManager.prototype.styleTables = null;
        translationmanagerImpl.TranslationManager.prototype.createStyleTables = function() {
            this.styleTables = new _hcmn_.haxe_ds_StringMap();
            var $it0 = translationmanagerImpl.ExternalService.styleTables.keys();
            while ($it0.hasNext()) {
                var key = $it0.next();
                var value = new translationmanagerImpl.StyleTable(translationmanagerImpl.ExternalService.styleTables.get(key));
                this.styleTables.set(key, value);
            }
        };
        translationmanagerImpl.TranslationManager.prototype.createStringTables = function() {
            this.stringTables = new _hcmn_.haxe_ds_StringMap();
            var $it0 = translationmanagerImpl.ExternalService.stringTables.keys();
            while ($it0.hasNext()) {
                var key = $it0.next();
                var value = new translationmanagerImpl.StringTable(translationmanagerImpl.ExternalService.stringTables.get(key));
                this.stringTables.set(key, value);
            }
        };
        translationmanagerImpl.TranslationManager.prototype.getLocale = function() {
            return null;
        };
        translationmanagerImpl.TranslationManager.prototype.getStringTables = function() {
            return this.stringTables;
        };
        translationmanagerImpl.TranslationManager.prototype.getStyleTables = function() {
            return this.styleTables;
        };
        translationmanagerImpl.TranslationManager.prototype.stringLookup = function(id, fillIn) {
            var msg = null;
            var $it0 = this.stringTables.iterator();
            while ($it0.hasNext()) {
                var table = $it0.next();
                msg = table.getString(id);
                if (msg != null) {
                    if (fillIn != null) {
                        var _g1 = 0;
                        var _g = fillIn.length;
                        while (_g1 < _g) {
                            var i = _g1++;
                            msg = msg.split("{$" + (i + 1) + "}").join(fillIn[i]);
                        }
                    }
                    return msg;
                }
            }
            return id;
        };
        translationmanagerImpl.TranslationManager.prototype.moneyFormatFillin = function(msg) {
            var ereg = new _hcmn_.EReg("({MONEY=)(.+?)(}|\n|$)", "g");
            if (!ereg.match(msg)) return msg;
            while (ereg.match(msg)) {
                var replacementString = ereg.matched(1) + ereg.matched(2) + "}";
                msg = _hcmn_.StringTools.replace(msg, replacementString, translationmanagerImpl.ExternalService.moneyFormatter.format(ereg.matched(2)));
            }
            return msg;
        };
        translationmanagerImpl.TranslationManager.prototype.styleLookup = function(id) {
            var attr = null;
            var $it0 = this.styleTables.iterator();
            while ($it0.hasNext()) {
                var table = $it0.next();
                attr = table.getAttributes(id);
                if (attr != null) return attr;
            }
            return null;
        };
        translationmanagerImpl.TranslationManager.prototype.__class__ = translationmanagerImpl.TranslationManager;
        translationmanagerImpl.ExternalService.MULTILANGUAGE_PACK_ID = "multilanguage_assets";;
        return {
            exports: translationmanagerImpl,
            activator: translationmanagerImpl.Activator
        };
    });