define("scarabTutorial", ["viewBuilderApi", "componentmodelComponentApi", "translationmanagerApi", "clientkernelLoaderApi", "displayEngineApi", "gameLayoutApi", "PIXI", "BABYLON", "scarabTutorialApi", "clientkernelEventbusApi", "clientkernelModulesApi", "moneyApi"],
    function(viewBuilderApi, componentmodelComponentApi, translationmanagerApi, clientkernelLoaderApi, displayEngineApi, gameLayoutApi, PIXI, BABYLON, scarabTutorialApi, 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 scarabTutorial == 'undefined') {
            var scarabTutorial = {};
        };
        scarabTutorial.Activator = function(context) {};
        scarabTutorial.Activator = ck_implements(scarabTutorial.Activator, clientkernelModulesApi.IModuleActivator);
        scarabTutorial.Activator.__interfaces__ = [clientkernelModulesApi.IModuleActivator];
        scarabTutorial.Activator.__name__ = ["scarabTutorial", "Activator"];
        scarabTutorial.Activator.prototype.start = function(context) {
            context.getServiceTracker([clientkernelLoaderApi.IAssetRegistry, viewBuilderApi.IViewBuilderFactory, displayEngineApi.IDisplayProvider]).then(function(context1) {
                scarabTutorial.ExternalService.initialize(context1);
                var vbf = context1.getAnyService(viewBuilderApi.IViewBuilderFactory, null);
                scarabTutorial.ExternalService.bus = context1.getAnyService(clientkernelEventbusApi.IEventBus, null);
                scarabTutorial.ExternalService.viewBuilderFactory = vbf;
                context1.registerService(new scarabTutorial.TutorialFactory(vbf, context1), scarabTutorialApi.TutorialDeclaration, null);
            });
        };
        scarabTutorial.Activator.prototype.stop = function(context) {};
        scarabTutorial.Activator.main = function() {};
        scarabTutorial.Activator.prototype.__class__ = scarabTutorial.Activator;
        scarabTutorial.ExternalService = function() {};
        scarabTutorial.ExternalService.__name__ = ["scarabTutorial", "ExternalService"];
        scarabTutorial.ExternalService.assetRegistry = null;
        scarabTutorial.ExternalService.vbAssets = null;
        scarabTutorial.ExternalService.vbf = null;
        scarabTutorial.ExternalService.displayProvider = null;
        scarabTutorial.ExternalService.translationManager = null;
        scarabTutorial.ExternalService.bus = null;
        scarabTutorial.ExternalService.viewBuilderFactory = null;
        scarabTutorial.ExternalService.moneyFormatter = null;
        scarabTutorial.ExternalService.variableRegistry = null;
        scarabTutorial.ExternalService.initialize = function(context) {
            scarabTutorial.ExternalService.assetRegistry = context.getAnyService(clientkernelLoaderApi.IAssetRegistry, null);
            scarabTutorial.ExternalService.vbf = context.getAnyService(viewBuilderApi.IViewBuilderFactory, null);
            scarabTutorial.ExternalService.displayProvider = context.getAnyService(displayEngineApi.IDisplayProvider, null);
            scarabTutorial.ExternalService.vbAssets = new _hcmn_.haxe_ds_StringMap();
            scarabTutorial.ExternalService.moneyFormatter = context.getAnyService(moneyApi.IMoneyFormatter, null);
            scarabTutorial.ExternalService.variableRegistry = context.getAnyService(clientkernelLoaderApi.IVariableRegistry, null);
        };
        scarabTutorial.ExternalService.getLanguage = function() {
            return scarabTutorial.ExternalService.variableRegistry.get("language");
        };
        scarabTutorial.ExternalService.prototype.__class__ = scarabTutorial.ExternalService;
        scarabTutorial.Tutorial = function(context, vbf) {
            this.assetsLoaded = false;
            this.initialized = false;
            this.layoutPayload = null;
            this.vba = null;
            this.cfgId = "tutorial_definition_config.json";
            this.vbf = vbf;
            this.context = context;
            this.components = new haxe.ds.EnumValueMap();
            this.port = context.getImplementedPort(scarabTutorialApi.ITutorialImplementationPort);
            this.layoutPort = context.getUsedPort(gameLayoutApi.IGameLayoutPort);
            this.layoutPort.getUpdateComponentLayout().subscribe($bind(this, this.updateLayout));
            this.loadConfigData();
            this.baseEvents = new scarabTutorial.BaseEvents();
            this.baseEvents.confirmed.add($bind(this, this.handleConfirmed));
            this.baseEvents.closed.add($bind(this, this.handleClosed));
            this.baseEvents.currentPage.add($bind(this, this.handleCurrentPage));
        };
        scarabTutorial.Tutorial.__name__ = ["scarabTutorial", "Tutorial"];
        scarabTutorial.Tutorial.prototype.view = null;
        scarabTutorial.Tutorial.prototype.cfgId = null;
        scarabTutorial.Tutorial.prototype.context = null;
        scarabTutorial.Tutorial.prototype.vba = null;
        scarabTutorial.Tutorial.prototype.vbf = null;
        scarabTutorial.Tutorial.prototype.controller = null;
        scarabTutorial.Tutorial.prototype.layoutPayload = null;
        scarabTutorial.Tutorial.prototype.initialized = null;
        scarabTutorial.Tutorial.prototype.assetsLoaded = null;
        scarabTutorial.Tutorial.prototype.port = null;
        scarabTutorial.Tutorial.prototype.layoutPort = null;
        scarabTutorial.Tutorial.prototype.cfg = null;
        scarabTutorial.Tutorial.prototype.baseEvents = null;
        scarabTutorial.Tutorial.prototype.components = null;
        scarabTutorial.Tutorial.prototype.loadConfigData = function() {
            var _g = this;
            haxe.Log.trace("[TUTORIAL] loadConfigData() ", {
                fileName: "Tutorial.hx",
                lineNumber: 68,
                className: "game.tutorial.Tutorial",
                methodName: "loadConfigData",
                customParams: [this.cfg]
            });
            scarabTutorial.ExternalService.assetRegistry.getAsset(this.cfgId).getContent().then(function(data) {
                haxe.Log.trace("[TUTORIAL] loadConfigData() loaded ", {
                    fileName: "Tutorial.hx",
                    lineNumber: 71,
                    className: "game.tutorial.Tutorial",
                    methodName: "loadConfigData",
                    customParams: [_g.cfg]
                });
                _g.cfg = data;
                _g.loadVBAssets();
            });
        };
        scarabTutorial.Tutorial.prototype.loadVBAssets = function() {
            var _g = this;
            haxe.Log.trace("[TUTORIAL] loadVBAssets()", {
                fileName: "Tutorial.hx",
                lineNumber: 80,
                className: "game.tutorial.Tutorial",
                methodName: "loadVBAssets"
            });
            scarabTutorial.ExternalService.assetRegistry.getAssetsContent(this.cfg.assetsToLoad).then(function(data) {
                haxe.Log.trace("[TUTORIAL] loadVBAssets() loaded " + _hcmn_.Std.string(_g.cfg.assetsToLoad), {
                    fileName: "Tutorial.hx",
                    lineNumber: 82,
                    className: "game.tutorial.Tutorial",
                    methodName: "loadVBAssets"
                });
                scarabTutorial.ExternalService.vbAssets = data;
                _g.loadMainAssets();
            });
        };
        scarabTutorial.Tutorial.prototype.loadMainAssets = function() {
            var _g = this;
            haxe.Log.trace("[TUTORIAL] loadMainAssets()", {
                fileName: "Tutorial.hx",
                lineNumber: 92,
                className: "game.tutorial.Tutorial",
                methodName: "loadMainAssets"
            });
            scarabTutorial.ExternalService.assetRegistry.getAsset(this.cfg.rootView).getContent().then(function(vba) {
                haxe.Log.trace("[TUTORIAL] loadMainAssets() loaded", {
                    fileName: "Tutorial.hx",
                    lineNumber: 95,
                    className: "game.tutorial.Tutorial",
                    methodName: "loadMainAssets"
                });
                _g.vba = vba;
                _g.assetsLoaded = true;
                _g.initialize();
            });
        };
        scarabTutorial.Tutorial.prototype.updateLayout = function(e) {
            haxe.Log.trace("[TUTORIAL] updateLayout() ", {
                fileName: "Tutorial.hx",
                lineNumber: 104,
                className: "game.tutorial.Tutorial",
                methodName: "updateLayout"
            });
            this.layoutPayload = e.getPayload();
            if (!this.initialized) this.initialize();
            else {
                this.controller.updateLayout(this.layoutPayload);
                this.layoutPort.getComponentLayoutUpdated().publish(this.context.getInstance());
            }
        };
        scarabTutorial.Tutorial.prototype.initialize = function() {
            haxe.Log.trace("[TUTORIAL] initialize() " + _hcmn_.Std.string(this.initialized) + _hcmn_.Std.string(this.layoutPayload), {
                fileName: "Tutorial.hx",
                lineNumber: 119,
                className: "game.tutorial.Tutorial",
                methodName: "initialize"
            });
            if (!this.initialized && this.vba != null && this.layoutPayload != null) {
                this.controller = new scarabTutorial.TutorialController(this);
                this.view = this.vbf.createView(this.vba);
                this.registerAllComponents();
                this.controller.updateLayout(this.layoutPayload);
                this.layoutPort.getComponentLayoutUpdated().publish(this.context.getInstance());
                this.port.getHide().subscribe($bind(this, this.handleHide));
                this.port.getShow().subscribe($bind(this, this.handleShow));
                this.port.setNextPage().subscribe($bind(this, this.handleNext));
                this.port.setPreviousPage().subscribe($bind(this, this.handlePrevious));
                this.initialized = true;
            }
        };
        scarabTutorial.Tutorial.prototype.registerAllComponents = function() {
            haxe.Log.trace("[TUTORIAL] registerAllComponents()", {
                fileName: "Tutorial.hx",
                lineNumber: 141,
                className: "game.tutorial.Tutorial",
                methodName: "registerAllComponents",
                customParams: [this.initialized]
            });
            var $it0 = (function($this) {
                var $r;
                var this1 = $this.view.getChildComponents();
                $r = this1.keys();
                return $r;
            }(this));
            while ($it0.hasNext()) {
                var compId = $it0.next();
                var constructorIndex;
                var _this = _hcmn_.Type.getEnumConstructs(scarabTutorialApi.TutorialLayerEnum);
                constructorIndex = _hcmn_.HxOverrides.indexOf(_this, compId, 0);
                if (constructorIndex < 0) continue;
                var componentEnum = _hcmn_.Type.createEnum(scarabTutorialApi.TutorialLayerEnum, compId, null);
                this.registerComponent(componentEnum);
            }
        };
        scarabTutorial.Tutorial.prototype.registerComponent = function(componentEnum) {
            haxe.Log.trace("[TUTORIAL] registerComponent() ", {
                fileName: "Tutorial.hx",
                lineNumber: 155,
                className: "game.tutorial.Tutorial",
                methodName: "registerComponent",
                customParams: [componentEnum]
            });
            this.registerContainerComponent(scarabTutorialApi.TutorialLayerEnum.TUTORIAL_VIEW, scarabTutorial.TutorialView);
            return true;
        };
        scarabTutorial.Tutorial.prototype.registerContainerComponent = function(componentEnum, componentClass) {
            var container = this.view.getComponentById(componentEnum[0]);
            if (container == null) return;
            var value = _hcmn_.Type.createInstance(componentClass, [container, this.view, this.baseEvents, this.cfg]);
            this.components.set(componentEnum, value);
        };
        scarabTutorial.Tutorial.prototype.handleClosed = function(e) {
            haxe.Log.trace("[TUTORIAL] handleTutorialConfirmed ", {
                fileName: "Tutorial.hx",
                lineNumber: 176,
                className: "game.tutorial.Tutorial",
                methodName: "handleClosed"
            });
            this.port.getClosed().publish(null);
        };
        scarabTutorial.Tutorial.prototype.handleConfirmed = function(e) {
            haxe.Log.trace("[TUTORIAL] handleTutorialConfirmed ", {
                fileName: "Tutorial.hx",
                lineNumber: 181,
                className: "game.tutorial.Tutorial",
                methodName: "handleConfirmed"
            });
            this.port.getConfirmed().publish(null);
        };
        scarabTutorial.Tutorial.prototype.handleHide = function(e) {
            haxe.Log.trace("[TUTORIAL] HIDE " + _hcmn_.Std.string(e), {
                fileName: "Tutorial.hx",
                lineNumber: 187,
                className: "game.tutorial.Tutorial",
                methodName: "handleHide"
            });
            this.components.get(scarabTutorialApi.TutorialLayerEnum.TUTORIAL_VIEW).hide();
        };
        scarabTutorial.Tutorial.prototype.handleShow = function(e) {
            haxe.Log.trace("[TUTORIAL] SHOW " + _hcmn_.Std.string(e), {
                fileName: "Tutorial.hx",
                lineNumber: 193,
                className: "game.tutorial.Tutorial",
                methodName: "handleShow"
            });
            ((function($this) {
                var $r;
                var key = e.getPayload();
                $r = $this.components.get(key);
                return $r;
            }(this))).show();
        };
        scarabTutorial.Tutorial.prototype.handleCurrentPage = function(e) {
            haxe.Log.trace("[TUTORIAL] handleCurrentPage, page: " + _hcmn_.Std.string(e), {
                fileName: "Tutorial.hx",
                lineNumber: 199,
                className: "game.tutorial.Tutorial",
                methodName: "handleCurrentPage"
            });
            this.port.getCurrentPage().publish(e);
        };
        scarabTutorial.Tutorial.prototype.handlePrevious = function(e) {
            haxe.Log.trace("[TUTORIAL] PREVIOUS PAGE", {
                fileName: "Tutorial.hx",
                lineNumber: 204,
                className: "game.tutorial.Tutorial",
                methodName: "handlePrevious"
            });
            this.components.get(scarabTutorialApi.TutorialLayerEnum.TUTORIAL_VIEW).handleLeft(e);
        };
        scarabTutorial.Tutorial.prototype.handleNext = function(e) {
            haxe.Log.trace("[TUTORIAL] NEXT PAGE", {
                fileName: "Tutorial.hx",
                lineNumber: 209,
                className: "game.tutorial.Tutorial",
                methodName: "handleNext"
            });
            this.components.get(scarabTutorialApi.TutorialLayerEnum.TUTORIAL_VIEW).handleRight(e);
        };
        scarabTutorial.Tutorial.prototype.__class__ = scarabTutorial.Tutorial;
        scarabTutorial.TutorialController = function(tutorial) {
            this.flag_addedToStage = false;
            this.tutorial = tutorial;
        };
        scarabTutorial.TutorialController.__name__ = ["scarabTutorial", "TutorialController"];
        scarabTutorial.TutorialController.prototype.flag_addedToStage = null;
        scarabTutorial.TutorialController.prototype.tutorial = null;
        scarabTutorial.TutorialController.prototype.updateLayout = function(layoutPayload) {
            var $it0 = layoutPayload.containers.keys();
            while ($it0.hasNext()) {
                var layerId = $it0.next();
                var layerPayload = layoutPayload.containers.get(layerId);
                var cfg = layerPayload.configuration;
                var stage;
                var this1 = scarabTutorial.ExternalService.displayProvider.getStages();
                stage = this1.get(layerPayload.stage);
                var container;
                container = (function($this) {
                    var $r;
                    var this2 = $this.tutorial.view.getChildComponents();
                    $r = this2.get(layerId);
                    return $r;
                }(this));
                var containerDO = container.getDisplayObject();
                if (containerDO == null) return;
                if (!this.flag_addedToStage) stage.addChild(containerDO);
                containerDO.setX(layerPayload.left);
                containerDO.setY(layerPayload.top);
                containerDO.setScaleX(layerPayload.width / containerDO.getUserData().viewBuilderW);
                containerDO.setScaleY(layerPayload.height / containerDO.getUserData().viewBuilderH);
                containerDO.setZIndex(layerPayload.zIndex);
                if (cfg != null) {}
            }
            if (!this.flag_addedToStage) this.flag_addedToStage = true;
        };
        scarabTutorial.TutorialController.prototype.__class__ = scarabTutorial.TutorialController;
        scarabTutorial.TutorialFactory = function(vbf, context) {
            this.context = context;
            this.vbf = vbf;
        };
        scarabTutorial.TutorialFactory = ck_implements(scarabTutorial.TutorialFactory, clientkernelModulesApi.IService);
        scarabTutorial.TutorialFactory = ck_implements(scarabTutorial.TutorialFactory, componentmodelComponentApi.IComponentFactory);
        scarabTutorial.TutorialFactory.__interfaces__ = [clientkernelModulesApi.IService, componentmodelComponentApi.IComponentFactory];
        scarabTutorial.TutorialFactory.__name__ = ["scarabTutorial", "TutorialFactory"];
        scarabTutorial.TutorialFactory.prototype.context = null;
        scarabTutorial.TutorialFactory.prototype.vbf = null;
        scarabTutorial.TutorialFactory.prototype.getComponentDeclaration = function() {
            return scarabTutorialApi.TutorialDeclaration;
        };
        scarabTutorial.TutorialFactory.prototype.createComponent = function(context) {
            new scarabTutorial.Tutorial(context, this.vbf);
        };
        scarabTutorial.TutorialFactory.prototype.__class__ = scarabTutorial.TutorialFactory;
        scarabTutorial.TutorialView = function(container, rootView, baseEvents, cfg) {
            this.totalPages = 1;
            this.currentPage = 0;
            this.baseEvents = baseEvents;
            this.cfg = cfg;
            this.totalPages = cfg.totalPages;
            this.rootView = rootView;
            this.container = container;
            this.registeredViews = [];
            this.pages = new _hcmn_.haxe_ds_StringMap();
            container.hide();
            this.setConfig();
            var bus = scarabTutorial.ExternalService.bus;
            bus.getChannel("GFBus").publish("testable:testcomponent:tutorialTotalPages", this.totalPages);
        };
        scarabTutorial.TutorialView.__name__ = ["scarabTutorial", "TutorialView"];
        scarabTutorial.TutorialView.prototype.container = null;
        scarabTutorial.TutorialView.prototype.rootView = null;
        scarabTutorial.TutorialView.prototype.cfg = null;
        scarabTutorial.TutorialView.prototype.content = null;
        scarabTutorial.TutorialView.prototype.currentPage = null;
        scarabTutorial.TutorialView.prototype.baseEvents = null;
        scarabTutorial.TutorialView.prototype.pages = null;
        scarabTutorial.TutorialView.prototype.registeredViews = null;
        scarabTutorial.TutorialView.prototype.totalPages = null;
        scarabTutorial.TutorialView.prototype.setConfig = function() {
            this.content = [];
            var currentPage = 0;
            var _g = 0;
            var _g1 = _hcmn_.Reflect.fields(this.cfg.content);
            while (_g < _g1.length) {
                var elements = _g1[_g];
                ++_g;
                var element = _hcmn_.Reflect.field(this.cfg.content, elements);
                this.content[currentPage] = [];
                var elementNumber = 0;
                var _g2 = 0;
                var _g3 = _hcmn_.Reflect.fields(element);
                while (_g2 < _g3.length) {
                    var pages = _g3[_g2];
                    ++_g2;
                    var page = _hcmn_.Reflect.field(element, pages);
                    var id = page.id;
                    var position = new displayEngineApi.Point(page.pos[0], page.pos[1]);
                    var scale = new displayEngineApi.Point(1, 1);
                    var labels = new _hcmn_.haxe_ds_StringMap();
                    var type = "static";
                    var play = true;
                    var moneyFormatter = true;
                    var assetId = -1;
                    if (page.scale != null) {
                        scale.x = page.scale[0];
                        scale.y = page.scale[1];
                    }
                    if (page.type != null) type = page.type;
                    if (page.play != null) play = page.play;
                    if (page.moneyFormatter != null) moneyFormatter = page.moneyFormatter;
                    if (page.assetId != null) assetId = page.assetId;
                    if (page.labels != null) {
                        var lblFields = _hcmn_.Reflect.fields(page.labels);
                        var _g5 = 0;
                        var _g4 = lblFields.length;
                        while (_g5 < _g4) {
                            var i = _g5++;
                            var text = _hcmn_.Reflect.field(page.labels, lblFields[i]);
                            var key = lblFields[i];
                            if (_hcmn_.__map_reserved[key] != null) labels.setReserved(key, text);
                            else labels.h[key] = text;
                        }
                    }
                    var prop = {
                        id: page.id,
                        position: position,
                        scale: scale,
                        type: type,
                        play: play,
                        moneyFormatter: moneyFormatter,
                        labels: labels,
                        assetId: assetId
                    };
                    this.content[currentPage][elementNumber] = prop;
                    elementNumber++;
                }
                currentPage++;
            }
        };
        scarabTutorial.TutorialView.prototype.showPage = function() {
            haxe.Log.trace("[TUTORIAL] showPage", {
                fileName: "TutorialView.hx",
                lineNumber: 142,
                className: "game.tutorial.components.TutorialView",
                methodName: "showPage"
            });
            this.baseEvents.currentPage.dispatch(this.currentPage);
            var $it0 = this.pages.iterator();
            while ($it0.hasNext()) {
                var e = $it0.next();
                e.hide();
            }
            this.pages.get("page_" + this.currentPage).show();
            var controls = this.container.getContainerById("controls");
            var counterLabel = controls.getLabelById("page_counter");
            counterLabel.setText(_hcmn_.Std.string(this.currentPage + 1) + "/" + _hcmn_.Std.string(this.content.length));
        };
        scarabTutorial.TutorialView.prototype.setupControls = function() {
            haxe.Log.trace("[TUTORIAL] setupControls", {
                fileName: "TutorialView.hx",
                lineNumber: 160,
                className: "game.tutorial.components.TutorialView",
                methodName: "setupControls"
            });
            var controls = this.container.getContainerById("controls");
            var counterLabel = controls.getLabelById("page_counter");
            counterLabel.setText(_hcmn_.Std.string(this.currentPage + 1) + "/" + _hcmn_.Std.string(this.content.length));
            var btnRight = controls.getButtonById("BtnRight");
            btnRight = controls.getButtonById("BtnRight");
            btnRight.getEvents().DOWN().addListener($bind(this, this.handleRight));
            var btnLeft = controls.getButtonById("BtnLeft");
            btnLeft = controls.getButtonById("BtnLeft");
            btnLeft.getEvents().DOWN().addListener($bind(this, this.handleLeft));
            btnLeft.disable();
            var btnConfirm = controls.getButtonById("BtnConfirm");
            btnConfirm.getEvents().DOWN().addListener($bind(this, this.handleConfirm));
            var btnConfirmed = controls.getButtonById("BtnConfirmed");
            btnConfirmed.getEvents().DOWN().addListener($bind(this, this.handleConfirm));
            var btnClose = controls.getButtonById("BtnClose");
            btnClose.getEvents().DOWN().addListener($bind(this, this.handleClose));
            btnConfirm.show();
            btnConfirmed.hide();
        };
        scarabTutorial.TutorialView.prototype.handleClose = function(e) {
            haxe.Log.trace("[TUTORIAL] handleClose", {
                fileName: "TutorialView.hx",
                lineNumber: 191,
                className: "game.tutorial.components.TutorialView",
                methodName: "handleClose"
            });
            this.baseEvents.closed.dispatch(null);
        };
        scarabTutorial.TutorialView.prototype.handleConfirm = function(e) {
            haxe.Log.trace("[TUTORIAL] handleConfirm", {
                fileName: "TutorialView.hx",
                lineNumber: 197,
                className: "game.tutorial.components.TutorialView",
                methodName: "handleConfirm"
            });
            var controls = this.container.getContainerById("controls");
            var btnConfirm = controls.getButtonById("BtnConfirm");
            var btnConfirmed = controls.getButtonById("BtnConfirmed");
            var btnId = e.id;
            if (btnId == "BtnConfirm") {
                btnConfirm.hide();
                btnConfirmed.show();
            } else if (btnId == "BtnConfirmed") {
                btnConfirm.show();
                btnConfirmed.hide();
            }
            this.baseEvents.confirmed.dispatch(null);
        };
        scarabTutorial.TutorialView.prototype.handleRight = function(e) {
            haxe.Log.trace("[TUTORIAL] handleRight", {
                fileName: "TutorialView.hx",
                lineNumber: 220,
                className: "game.tutorial.components.TutorialView",
                methodName: "handleRight"
            });
            var controls = this.container.getContainerById("controls");
            var btnRight = controls.getButtonById("BtnRight");
            var btnLeft = controls.getButtonById("BtnLeft");
            if (this.currentPage >= this.content.length + 1) return;
            this.currentPage++;
            if (this.currentPage >= this.content.length) {
                this.baseEvents.currentPage.dispatch(this.currentPage);
                return;
            }
            btnLeft.enable();
            this.showPage();
        };
        scarabTutorial.TutorialView.prototype.handleLeft = function(e) {
            haxe.Log.trace("[TUTORIAL] handleLeft", {
                fileName: "TutorialView.hx",
                lineNumber: 246,
                className: "game.tutorial.components.TutorialView",
                methodName: "handleLeft"
            });
            var controls = this.container.getContainerById("controls");
            var btnRight = controls.getButtonById("BtnRight");
            var btnLeft = controls.getButtonById("BtnLeft");
            if (this.currentPage <= 0) {
                btnLeft.disable();
                return;
            }
            this.currentPage--;
            if (this.currentPage <= 0) btnLeft.disable();
            btnRight.enable();
            this.showPage();
        };
        scarabTutorial.TutorialView.prototype.createContentFromConfig = function(pageId, currentPage) {
            haxe.Log.trace("[TUTORIAL] createContentFromConfig", {
                fileName: "TutorialView.hx",
                lineNumber: 272,
                className: "game.tutorial.components.TutorialView",
                methodName: "createContentFromConfig"
            });
            var page = this.container.createContainerFromStoredConfig(pageId);
            this.container.addChildComponent(page, pageId);
            var pageContainer = this.container.getContainerById(pageId);
            var _g1 = 0;
            var _g = this.content[currentPage].length;
            while (_g1 < _g) {
                var i = _g1++;
                var vbContainer = null;
                var id = this.content[currentPage][i].id;
                var type = this.content[currentPage][i].type;
                var play = this.content[currentPage][i].play;
                var moneyFormatter = this.content[currentPage][i].moneyFormatter;
                var labels = this.content[currentPage][i].labels;
                var assetId = this.content[currentPage][i].assetId;
                if (assetId != -1) {
                    var vbView = this.registeredViews[assetId];
                    vbContainer = vbView.createContainerFromStoredConfig(id);
                } else {
                    var len = this.registeredViews.length;
                    var _g2 = 0;
                    while (_g2 < len) {
                        var j = _g2++;
                        var vbView1 = this.registeredViews[j];
                        if ((function($this) {
                                var $r;
                                var this1 = vbView1.getChildComponents();
                                $r = this1.exists(id);
                                return $r;
                            }(this))) vbContainer = vbView1.getContainerById(id);
                        else if (vbView1.createContainerFromStoredConfig(id) != null) vbContainer = vbView1.createContainerFromStoredConfig(id);
                    }
                }
                if (vbContainer != null) {
                    var childId = id + "_" + i;
                    vbContainer.show();
                    pageContainer.addChildComponent(vbContainer, childId);
                    var xPos = this.content[currentPage][i].position.x | 0;
                    var yPos = this.content[currentPage][i].position.y | 0;
                    var scaleX = this.content[currentPage][i].scale.x;
                    var scaleY = this.content[currentPage][i].scale.y;
                    vbContainer.setX(xPos);
                    vbContainer.setY(yPos);
                    vbContainer.getDisplayObject().setScaleX(scaleX);
                    vbContainer.getDisplayObject().setScaleY(scaleY);
                    if (type == "anim") {
                        if ((function($this) {
                                var $r;
                                var this2 = vbContainer.getChildComponents();
                                $r = this2.exists("ANIMATION_CONTENT");
                                return $r;
                            }(this))) {
                            var vbContent = vbContainer.getVBAnimationById("ANIMATION_CONTENT");
                            vbContent.show();
                            if (play) vbContent.play(false);
                            var hasContent = _hcmn_.Lambda.count(labels);
                            if (hasContent > 0) this.updateLabelContent(vbContent, labels, moneyFormatter);
                        }
                    }
                }
            }
            pageContainer.hide();
            this.pages.set(pageId, pageContainer);
        };
        scarabTutorial.TutorialView.prototype.updateLabelContent = function(vbAnimation, labels, moneyFormatter) {
            haxe.Log.trace("[TUTORIAL] updateLabelContent", {
                fileName: "TutorialView.hx",
                lineNumber: 366,
                className: "game.tutorial.components.TutorialView",
                methodName: "updateLabelContent"
            });
            var $it0 = (function($this) {
                var $r;
                var this1 = vbAnimation.getChildComponents();
                $r = this1.keys();
                return $r;
            }(this));
            while ($it0.hasNext()) {
                var key = $it0.next();
                var vbChild = vbAnimation.getContainerById(key);
                var $it1 = labels.keys();
                while ($it1.hasNext()) {
                    var label = $it1.next();
                    if ((function($this) {
                            var $r;
                            var this2 = vbChild.getChildComponents();
                            $r = this2.exists(label);
                            return $r;
                        }(this))) {
                        var lbl = vbChild.getLabelById(label);
                        var text;
                        text = _hcmn_.__map_reserved[label] != null ? labels.getReserved(label) : labels.h[label];
                        if (moneyFormatter) lbl.setText(this.reFormat(scarabTutorial.ExternalService.moneyFormatter.format(text)));
                        else lbl.setText(text);
                    }
                }
            }
        };
        scarabTutorial.TutorialView.prototype.reFormat = function(v) {
            if (v.indexOf("Ft") > 0) return v;
            else return v.split(".").shift();
        };
        scarabTutorial.TutorialView.prototype.createViews = function() {
            haxe.Log.trace("[TUTORIAL] createViews", {
                fileName: "TutorialView.hx",
                lineNumber: 400,
                className: "game.tutorial.components.TutorialView",
                methodName: "createViews"
            });
            var totalAssets = 0;
            var $it0 = scarabTutorial.ExternalService.vbAssets.keys();
            while ($it0.hasNext()) {
                var key = $it0.next();
                this.registeredViews[totalAssets] = null;
                var vbAsset = scarabTutorial.ExternalService.vbAssets.get(key);
                var vbView = scarabTutorial.ExternalService.viewBuilderFactory.createView(vbAsset);
                this.registeredViews[totalAssets] = vbView;
                this.registeredViews[totalAssets].show();
                vbView = null;
                totalAssets++;
            }
        };
        scarabTutorial.TutorialView.prototype.show = function() {
            haxe.Log.trace("[TUTORIAL_VIEW] show ", {
                fileName: "TutorialView.hx",
                lineNumber: 419,
                className: "game.tutorial.components.TutorialView",
                methodName: "show"
            });
            var _g1 = 0;
            var _g = this.totalPages;
            while (_g1 < _g) {
                var i = _g1++;
                this.createViews();
                this.createContentFromConfig("page" + "_" + i, i);
                var page = this.pages.get("page_" + i);
                this.updateOffsets(page);
            }
            this.setupControls();
            this.showPage();
        };
        scarabTutorial.TutorialView.prototype.hide = function() {
            haxe.Log.trace("[TUTORIAL] hide", {
                fileName: "TutorialView.hx",
                lineNumber: 441,
                className: "game.tutorial.components.TutorialView",
                methodName: "hide"
            });
            var _g1 = 0;
            var _g = this.registeredViews.length;
            while (_g1 < _g) {
                var i = _g1++;
                this.registeredViews[i] = null;
            }
            var _g11 = 0;
            var _g2 = this.content.length;
            while (_g11 < _g2) {
                var i1 = _g11++;
                var pageId = "page" + "_" + i1;
                if ((function($this) {
                        var $r;
                        var this1 = $this.container.getChildComponents();
                        $r = this1.exists(pageId);
                        return $r;
                    }(this))) this.container.disposeChildComponent(pageId);
            }
            var $it0 = this.pages.iterator();
            while ($it0.hasNext()) {
                var el = $it0.next();
                el.dispose();
            }
            this.container.hide();
            this.container.dispose();
        };
        scarabTutorial.TutorialView.prototype.updateOffsets = function(page) {
            if (this.cfg.offsets != null) {
                var offsets = this.cfg.offsets;
                var _g = 0;
                var _g1 = _hcmn_.Reflect.fields(offsets);
                while (_g < _g1.length) {
                    var lang = _g1[_g];
                    ++_g;
                    if (lang == scarabTutorial.ExternalService.getLanguage()) {
                        var elements = _hcmn_.Reflect.field(offsets, lang);
                        var _g2 = 0;
                        var _g3 = _hcmn_.Reflect.fields(elements);
                        while (_g2 < _g3.length) {
                            var displayObjectId = _g3[_g2];
                            ++_g2;
                            var point = _hcmn_.Reflect.field(elements, displayObjectId);
                            if ((function($this) {
                                    var $r;
                                    var this1 = page.getChildComponents();
                                    $r = this1.exists(displayObjectId);
                                    return $r;
                                }(this))) {
                                var x = _hcmn_.Std["int"](((function($this) {
                                    var $r;
                                    var this2 = page.getChildComponents();
                                    $r = this2.get(displayObjectId);
                                    return $r;
                                }(this))).getDisplayObject().getX());
                                var y = _hcmn_.Std["int"](((function($this) {
                                    var $r;
                                    var this3 = page.getChildComponents();
                                    $r = this3.get(displayObjectId);
                                    return $r;
                                }(this))).getDisplayObject().getY());
                                var offsetX = point.x;
                                var offsetY = point.y;
                                ((function($this) {
                                    var $r;
                                    var this4 = page.getChildComponents();
                                    $r = this4.get(displayObjectId);
                                    return $r;
                                }(this))).setX(x + offsetX);
                                ((function($this) {
                                    var $r;
                                    var this5 = page.getChildComponents();
                                    $r = this5.get(displayObjectId);
                                    return $r;
                                }(this))).setY(y + offsetY);
                            }
                        }
                    }
                }
            }
        };
        scarabTutorial.TutorialView.prototype.__class__ = scarabTutorial.TutorialView;
        scarabTutorial.BaseEvents = function() {
            this.confirmed = new _hcmn_.msignal_Signal1();
            this.closed = new _hcmn_.msignal_Signal1();
            this.currentPage = new _hcmn_.msignal_Signal1();
        };
        scarabTutorial.BaseEvents.__name__ = ["scarabTutorial", "BaseEvents"];
        scarabTutorial.BaseEvents.prototype.confirmed = null;
        scarabTutorial.BaseEvents.prototype.closed = null;
        scarabTutorial.BaseEvents.prototype.currentPage = null;
        scarabTutorial.BaseEvents.prototype.__class__ = scarabTutorial.BaseEvents;
        if (typeof haxe == 'undefined') {
            var haxe = {};
        };

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

            get: function(k) {
                return {
                    arguments: ["*"],
                    returns: "null"
                };
            },
            exists: function(k) {
                return {
                    arguments: ["*"],
                    returns: "boolean"
                };
            },
            keys: function() {
                return {
                    arguments: [],
                    returns: "null"
                };
            }
        };
        haxe.Log = function() {};
        haxe.Log.__name__ = ["haxe", "Log"];
        haxe.Log.trace = function(v, infos) {
            _hcmn_.js_Boot.__trace(v, infos);
        };
        haxe.Log.prototype.__class__ = haxe.Log;
        if (!haxe.ds) {
            haxe.ds = {};
        };
        haxe.ds.BalancedTree = function() {};
        haxe.ds.BalancedTree.__name__ = ["haxe", "ds", "BalancedTree"];
        haxe.ds.BalancedTree.prototype.root = null;
        haxe.ds.BalancedTree.prototype.set = function(key, value) {
            this.root = this.setLoop(key, value, this.root);
        };
        haxe.ds.BalancedTree.prototype.get = function(key) {
            var node = this.root;
            while (node != null) {
                var c = this.compare(key, node.key);
                if (c == 0) return node.value;
                if (c < 0) node = node.left;
                else node = node.right;
            }
            return null;
        };
        haxe.ds.BalancedTree.prototype.exists = function(key) {
            var node = this.root;
            while (node != null) {
                var c = this.compare(key, node.key);
                if (c == 0) return true;
                else if (c < 0) node = node.left;
                else node = node.right;
            }
            return false;
        };
        haxe.ds.BalancedTree.prototype.keys = function() {
            var ret = [];
            this.keysLoop(this.root, ret);
            return _hcmn_.HxOverrides.iter(ret);
        };
        haxe.ds.BalancedTree.prototype.setLoop = function(k, v, node) {
            if (node == null) return new haxe.ds.TreeNode(null, k, v, null);
            var c = this.compare(k, node.key);
            if (c == 0) return new haxe.ds.TreeNode(node.left, k, v, node.right, node == null ? 0 : node._height);
            else if (c < 0) {
                var nl = this.setLoop(k, v, node.left);
                return this.balance(nl, node.key, node.value, node.right);
            } else {
                var nr = this.setLoop(k, v, node.right);
                return this.balance(node.left, node.key, node.value, nr);
            }
        };
        haxe.ds.BalancedTree.prototype.keysLoop = function(node, acc) {
            if (node != null) {
                this.keysLoop(node.left, acc);
                acc.push(node.key);
                this.keysLoop(node.right, acc);
            }
        };
        haxe.ds.BalancedTree.prototype.balance = function(l, k, v, r) {
            var hl;
            if (l == null) hl = 0;
            else hl = l._height;
            var hr;
            if (r == null) hr = 0;
            else hr = r._height;
            if (hl > hr + 2) {
                if ((function($this) {
                        var $r;
                        var _this = l.left;
                        $r = _this == null ? 0 : _this._height;
                        return $r;
                    }(this)) >= (function($this) {
                        var $r;
                        var _this1 = l.right;
                        $r = _this1 == null ? 0 : _this1._height;
                        return $r;
                    }(this))) return new haxe.ds.TreeNode(l.left, l.key, l.value, new haxe.ds.TreeNode(l.right, k, v, r));
                else return new haxe.ds.TreeNode(new haxe.ds.TreeNode(l.left, l.key, l.value, l.right.left), l.right.key, l.right.value, new haxe.ds.TreeNode(l.right.right, k, v, r));
            } else if (hr > hl + 2) {
                if ((function($this) {
                        var $r;
                        var _this2 = r.right;
                        $r = _this2 == null ? 0 : _this2._height;
                        return $r;
                    }(this)) > (function($this) {
                        var $r;
                        var _this3 = r.left;
                        $r = _this3 == null ? 0 : _this3._height;
                        return $r;
                    }(this))) return new haxe.ds.TreeNode(new haxe.ds.TreeNode(l, k, v, r.left), r.key, r.value, r.right);
                else return new haxe.ds.TreeNode(new haxe.ds.TreeNode(l, k, v, r.left.left), r.left.key, r.left.value, new haxe.ds.TreeNode(r.left.right, r.key, r.value, r.right));
            } else return new haxe.ds.TreeNode(l, k, v, r, (hl > hr ? hl : hr) + 1);
        };
        haxe.ds.BalancedTree.prototype.compare = function(k1, k2) {
            return _hcmn_.Reflect.compare(k1, k2);
        };
        haxe.ds.BalancedTree.prototype.__class__ = haxe.ds.BalancedTree;
        haxe.ds.TreeNode = function(l, k, v, r, h) {
            if (h == null) h = -1;
            this.left = l;
            this.key = k;
            this.value = v;
            this.right = r;
            if (h == -1) this._height = ((function($this) {
                var $r;
                var _this = $this.left;
                $r = _this == null ? 0 : _this._height;
                return $r;
            }(this)) > (function($this) {
                var $r;
                var _this1 = $this.right;
                $r = _this1 == null ? 0 : _this1._height;
                return $r;
            }(this)) ? (function($this) {
                var $r;
                var _this2 = $this.left;
                $r = _this2 == null ? 0 : _this2._height;
                return $r;
            }(this)) : (function($this) {
                var $r;
                var _this3 = $this.right;
                $r = _this3 == null ? 0 : _this3._height;
                return $r;
            }(this))) + 1;
            else this._height = h;
        };
        haxe.ds.TreeNode.__name__ = ["haxe", "ds", "TreeNode"];
        haxe.ds.TreeNode.prototype.left = null;
        haxe.ds.TreeNode.prototype.right = null;
        haxe.ds.TreeNode.prototype.key = null;
        haxe.ds.TreeNode.prototype.value = null;
        haxe.ds.TreeNode.prototype._height = null;
        haxe.ds.TreeNode.prototype.__class__ = haxe.ds.TreeNode;
        haxe.ds.EnumValueMap = function() {
            haxe.ds.BalancedTree.call(this);
        };
        haxe.ds.EnumValueMap.__interfaces__ = [haxe.IMap];
        haxe.ds.EnumValueMap.__name__ = ["haxe", "ds", "EnumValueMap"];
        haxe.ds.EnumValueMap.__super__ = haxe.ds.BalancedTree;
        for (var k in haxe.ds.BalancedTree.prototype) haxe.ds.EnumValueMap.prototype[k] = haxe.ds.BalancedTree.prototype[k];
        haxe.ds.EnumValueMap.prototype.compare = function(k1, k2) {
            var d = k1[1] - k2[1];
            if (d != 0) return d;
            var p1 = k1.slice(2);
            var p2 = k2.slice(2);
            if (p1.length == 0 && p2.length == 0) return 0;
            return this.compareArgs(p1, p2);
        };
        haxe.ds.EnumValueMap.prototype.compareArgs = function(a1, a2) {
            var ld = a1.length - a2.length;
            if (ld != 0) return ld;
            var _g1 = 0;
            var _g = a1.length;
            while (_g1 < _g) {
                var i = _g1++;
                var d = this.compareArg(a1[i], a2[i]);
                if (d != 0) return d;
            }
            return 0;
        };
        haxe.ds.EnumValueMap.prototype.compareArg = function(v1, v2) {
            if (_hcmn_.Reflect.isEnumValue(v1) && _hcmn_.Reflect.isEnumValue(v2)) return this.compare(v1, v2);
            else if ((v1 instanceof Array) && v1.__enum__ == null && ((v2 instanceof Array) && v2.__enum__ == null)) return this.compareArgs(v1, v2);
            else return _hcmn_.Reflect.compare(v1, v2);
        };
        haxe.ds.EnumValueMap.prototype.__class__ = haxe.ds.EnumValueMap;
        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;
        return {
            exports: scarabTutorial,
            activator: scarabTutorial.Activator
        };
    });
//# sourceURL=scarabTutorial.js