define("scarabViewManager", ["scarabViewManagerApi", "viewBuilderApi", "componentmodelComponentApi", "translationmanagerApi", "clientkernelLoaderApi", "displayEngineApi", "displayEngineUtils", "gameLayoutApi", "PIXI", "BABYLON", "clientkernelEventbusApi", "clientkernelModulesApi"],
    function(scarabViewManagerApi, viewBuilderApi, componentmodelComponentApi, translationmanagerApi, clientkernelLoaderApi, displayEngineApi, displayEngineUtils, gameLayoutApi, PIXI, BABYLON, clientkernelEventbusApi, clientkernelModulesApi) {
        "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 scarabViewManager == 'undefined') {
            var scarabViewManager = {};
        };
        scarabViewManager.Activator = function(context) {};
        scarabViewManager.Activator = ck_implements(scarabViewManager.Activator, clientkernelModulesApi.IModuleActivator);
        scarabViewManager.Activator.__interfaces__ = [clientkernelModulesApi.IModuleActivator];
        scarabViewManager.Activator.__name__ = ["scarabViewManager", "Activator"];
        scarabViewManager.Activator.prototype.start = function(context) {
            context.getServiceTracker([clientkernelLoaderApi.IAssetRegistry, viewBuilderApi.IViewBuilderFactory, displayEngineApi.IDisplayProvider]).then(function(context1) {
                scarabViewManager.ExternalService.initialize(context1);
                var vbf = context1.getAnyService(viewBuilderApi.IViewBuilderFactory, null);
                scarabViewManager.ExternalService.bus = context1.getAnyService(clientkernelEventbusApi.IEventBus, null);
                scarabViewManager.ExternalService.viewBuilderFactory = vbf;
                context1.registerService(new scarabViewManager.ViewManagerFactory(vbf, context1), scarabViewManagerApi.ViewManagerDeclaration, null);
            });
        };
        scarabViewManager.Activator.prototype.stop = function(context) {};
        scarabViewManager.Activator.main = function() {};
        scarabViewManager.Activator.prototype.__class__ = scarabViewManager.Activator;
        scarabViewManager.ExternalService = function() {};
        scarabViewManager.ExternalService.__name__ = ["scarabViewManager", "ExternalService"];
        scarabViewManager.ExternalService.assetRegistry = null;
        scarabViewManager.ExternalService.vbf = null;
        scarabViewManager.ExternalService.displayProvider = null;
        scarabViewManager.ExternalService.translationManager = null;
        scarabViewManager.ExternalService.bus = null;
        scarabViewManager.ExternalService.viewBuilderFactory = null;
        scarabViewManager.ExternalService.initialize = function(context) {
            scarabViewManager.ExternalService.assetRegistry = context.getAnyService(clientkernelLoaderApi.IAssetRegistry, null);
            scarabViewManager.ExternalService.vbf = context.getAnyService(viewBuilderApi.IViewBuilderFactory, null);
            scarabViewManager.ExternalService.displayProvider = context.getAnyService(displayEngineApi.IDisplayProvider, null);
        };
        scarabViewManager.ExternalService.prototype.__class__ = scarabViewManager.ExternalService;
        scarabViewManager.ViewManager = function(context, vbf) {
            this.assets = new _hcmn_.haxe_ds_StringMap();
            this.assetsLoaded = false;
            this.initialized = false;
            this.layoutPayload = null;
            this.vba = null;
            this.cfgId = "view_manager_definition_config.json";
            this.vbAssetID = "view_manager.viewbuilder.json";
            this.vbf = vbf;
            this.context = context;
            this.baseEvents = new scarabViewManager.BaseEvents();
            this.port = context.getImplementedPort(scarabViewManagerApi.IViewManagerImplementationPort);
            this.layoutPort = context.getUsedPort(gameLayoutApi.IGameLayoutPort);
            this.layoutPort.getUpdateComponentLayout().subscribe($bind(this, this.updateLayout));
            this.loadConfigData();
        };
        scarabViewManager.ViewManager.__name__ = ["scarabViewManager", "ViewManager"];
        scarabViewManager.ViewManager.prototype.vbAssetID = null;
        scarabViewManager.ViewManager.prototype.cfgId = null;
        scarabViewManager.ViewManager.prototype.view = null;
        scarabViewManager.ViewManager.prototype.context = null;
        scarabViewManager.ViewManager.prototype.vba = null;
        scarabViewManager.ViewManager.prototype.vbf = null;
        scarabViewManager.ViewManager.prototype.controller = null;
        scarabViewManager.ViewManager.prototype.layoutPayload = null;
        scarabViewManager.ViewManager.prototype.initialized = null;
        scarabViewManager.ViewManager.prototype.assetsLoaded = null;
        scarabViewManager.ViewManager.prototype.port = null;
        scarabViewManager.ViewManager.prototype.layoutPort = null;
        scarabViewManager.ViewManager.prototype.cfg = null;
        scarabViewManager.ViewManager.prototype.assets = null;
        scarabViewManager.ViewManager.prototype.vbView = null;
        scarabViewManager.ViewManager.prototype.vmComponent = null;
        scarabViewManager.ViewManager.prototype.baseEvents = null;
        scarabViewManager.ViewManager.prototype.loadConfigData = function() {
            var _g = this;
            scarabViewManager.ExternalService.assetRegistry.getAsset(this.cfgId).getContent().then(function(data) {
                _g.cfg = data;
                _g.loadMainAssets();
            });
        };
        scarabViewManager.ViewManager.prototype.loadMainAssets = function() {
            var _g = this;
            scarabViewManager.ExternalService.assetRegistry.getAsset(this.vbAssetID).getContent().then(function(vba) {
                _g.vba = vba;
                _g.assetsLoaded = true;
                _g.initialize();
            });
        };
        scarabViewManager.ViewManager.prototype.updateLayout = function(e) {
            this.layoutPayload = e.getPayload();
            if (!this.initialized) this.initialize();
            else {
                this.controller.updateLayout(this.layoutPayload);
                this.layoutPort.getComponentLayoutUpdated().publish(this.context.getInstance());
            }
        };
        scarabViewManager.ViewManager.prototype.initialize = function() {
            if (!this.initialized && this.vba != null && this.layoutPayload != null) {
                this.controller = new scarabViewManager.ViewManagerController(this);
                this.vmComponent = new scarabViewManager.ViewManagerComponent(this.cfg, this.port);
                this.view = this.vbf.createView(this.vba);
                this.controller.updateLayout(this.layoutPayload);
                this.layoutPort.getComponentLayoutUpdated().publish(this.context.getInstance());
                this.layoutPort.getGameLayoutUpdated().subscribe(($_ = this.controller, $bind($_, $_.onGameLayoutUpdateCompleted)));
                this.layoutPort.getGameLayoutUpdateStarted().subscribe(($_ = this.controller, $bind($_, $_.gameLayoutUpdateStarted)));
                this.port.getActivate().subscribe($bind(this, this.handleActivate));
                this.port.getDeActivate().subscribe($bind(this, this.handleDeActivate));
                this.port.getReset().subscribe($bind(this, this.handleReset));
                this.port.getShow().subscribe($bind(this, this.handleShow));
                this.port.getHide().subscribe($bind(this, this.handleHide));
                this.port.getShake().subscribe($bind(this, this.handleShake));
                this.initialized = true;
            }
        };
        scarabViewManager.ViewManager.prototype.handleShow = function(e) {
            this.vmComponent.show(e.getPayload());
        };
        scarabViewManager.ViewManager.prototype.handleHide = function(e) {
            this.vmComponent.hide(e.getPayload());
        };
        scarabViewManager.ViewManager.prototype.handleShake = function(e) {
            this.vmComponent.initShake(e.getPayload());
        };
        scarabViewManager.ViewManager.prototype.handleActivate = function(e) {
            this.vmComponent.activate(e.getPayload());
        };
        scarabViewManager.ViewManager.prototype.handleDeActivate = function(e) {
            this.vmComponent.deactivate(e.getPayload());
        };
        scarabViewManager.ViewManager.prototype.handleReset = function(e) {
            this.vmComponent.reset(e.getPayload());
        };
        scarabViewManager.ViewManager.prototype.__class__ = scarabViewManager.ViewManager;
        scarabViewManager.ViewManagerController = function(viewManager) {
            this.flag_addedToStage = false;
            this.viewManager = viewManager;
        };
        scarabViewManager.ViewManagerController.__name__ = ["scarabViewManager", "ViewManagerController"];
        scarabViewManager.ViewManagerController.prototype.flag_addedToStage = null;
        scarabViewManager.ViewManagerController.prototype.viewManager = null;
        scarabViewManager.ViewManagerController.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 = scarabViewManager.ExternalService.displayProvider.getStages();
                stage = this1.get(layerPayload.stage);
                var container;
                container = (function($this) {
                    var $r;
                    var this2 = $this.viewManager.view.getChildComponents();
                    $r = this2.get(layerId);
                    return $r;
                }(this));
                var containerDO = container.getDisplayObject();
                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);
                var cfg1 = layerPayload.configuration;
                this.viewManager.vmComponent.onLayoutUpdate(cfg1);
            }
            if (!this.flag_addedToStage) this.flag_addedToStage = true;
        };
        scarabViewManager.ViewManagerController.prototype.onGameLayoutUpdateCompleted = function(e) {
            haxe.Log.trace("[ViewManagerController] [onGameLayoutUpdateCompleted]", {
                fileName: "ViewManagerController.hx",
                lineNumber: 55,
                className: "game.viewmanager.ViewManagerController",
                methodName: "onGameLayoutUpdateCompleted"
            });
            this.viewManager.vmComponent.onGameLayoutUpdateCompleted();
        };
        scarabViewManager.ViewManagerController.prototype.gameLayoutUpdateStarted = function(e) {
            haxe.Log.trace("[ViewManagerController] [gameLayoutUpdateStarted]", {
                fileName: "ViewManagerController.hx",
                lineNumber: 61,
                className: "game.viewmanager.ViewManagerController",
                methodName: "gameLayoutUpdateStarted"
            });
            this.viewManager.vmComponent.onGameLayoutUpdateStarted();
        };
        scarabViewManager.ViewManagerController.prototype.__class__ = scarabViewManager.ViewManagerController;
        scarabViewManager.ViewManagerFactory = function(vbf, context) {
            this.context = context;
            this.vbf = vbf;
        };
        scarabViewManager.ViewManagerFactory = ck_implements(scarabViewManager.ViewManagerFactory, clientkernelModulesApi.IService);
        scarabViewManager.ViewManagerFactory = ck_implements(scarabViewManager.ViewManagerFactory, componentmodelComponentApi.IComponentFactory);
        scarabViewManager.ViewManagerFactory.__interfaces__ = [clientkernelModulesApi.IService, componentmodelComponentApi.IComponentFactory];
        scarabViewManager.ViewManagerFactory.__name__ = ["scarabViewManager", "ViewManagerFactory"];
        scarabViewManager.ViewManagerFactory.prototype.context = null;
        scarabViewManager.ViewManagerFactory.prototype.vbf = null;
        scarabViewManager.ViewManagerFactory.prototype.getComponentDeclaration = function() {
            return scarabViewManagerApi.ViewManagerDeclaration;
        };
        scarabViewManager.ViewManagerFactory.prototype.createComponent = function(context) {
            new scarabViewManager.ViewManager(context, this.vbf);
        };
        scarabViewManager.ViewManagerFactory.prototype.__class__ = scarabViewManager.ViewManagerFactory;
        scarabViewManager.ViewManagerComponent = function(cfg, port) {
            this.implPort = port;
            this.maskSize = [];
            var this1 = scarabViewManager.ExternalService.displayProvider.getStages();
            this.stage = this1.get("skgl_0");
            this.tweens = new _hcmn_.haxe_ds_StringMap();
            this.activeScenarios = new _hcmn_.haxe_ds_StringMap();
            this.scenarios = new _hcmn_.haxe_ds_StringMap();
            this.initProperties = new _hcmn_.haxe_ds_StringMap();
            var _g = 0;
            var _g1 = _hcmn_.Reflect.fields(cfg.scenarios);
            while (_g < _g1.length) {
                var scenarioId = _g1[_g];
                ++_g;
                var element = _hcmn_.Reflect.field(cfg.scenarios, scenarioId);
                var layerProps = [];
                var _g2 = 0;
                var _g3 = _hcmn_.Reflect.fields(element);
                while (_g2 < _g3.length) {
                    var properties = _g3[_g2];
                    ++_g2;
                    var props = _hcmn_.Reflect.field(element, properties);
                    var _g5 = 0;
                    var _g4 = props.length;
                    while (_g5 < _g4) {
                        var i = _g5++;
                        layerProps[i] = {
                            id: props[i].id,
                            x: props[i].x,
                            y: props[i].y,
                            rotation: props[i].r,
                            alpha: props[i].a,
                            time: props[i].time,
                            mask: props[i].mask,
                            type: props[i].type
                        };
                    }
                }
                var allLayers = {
                    layers: layerProps
                };
                this.activeScenarios.set(scenarioId, false);
                this.scenarios.set(scenarioId, allLayers);
            }
            haxe.Log.trace("VIEW_MANAGER.activate() " + this.activeScenarios.toString(), {
                fileName: "ViewManagerComponent.hx",
                lineNumber: 95,
                className: "game.viewmanager.components.ViewManagerComponent",
                methodName: "new"
            });
        };
        scarabViewManager.ViewManagerComponent.__name__ = ["scarabViewManager", "ViewManagerComponent"];
        scarabViewManager.ViewManagerComponent.prototype.stage = null;
        scarabViewManager.ViewManagerComponent.prototype.tweens = null;
        scarabViewManager.ViewManagerComponent.prototype.activeScenarios = null;
        scarabViewManager.ViewManagerComponent.prototype.scenarios = null;
        scarabViewManager.ViewManagerComponent.prototype.initProperties = null;
        scarabViewManager.ViewManagerComponent.prototype.implPort = null;
        scarabViewManager.ViewManagerComponent.prototype.maskSize = null;
        scarabViewManager.ViewManagerComponent.prototype.activate = function(scenarioId) {
            var _g2 = this;
            haxe.Log.trace("VIEW_MANAGER.activate() " + scenarioId, {
                fileName: "ViewManagerComponent.hx",
                lineNumber: 100,
                className: "game.viewmanager.components.ViewManagerComponent",
                methodName: "activate",
                customParams: [this.tweens.exists(scenarioId)]
            });
            if (!this.tweens.exists(scenarioId)) {
                var value = [];
                this.tweens.set(scenarioId, value);
                this.activeScenarios.set(scenarioId, true);
                var totalTweens = 0;
                var currentTween = 0;
                var viewManager = this.stage.getChildByID("VIEW_MANAGER");
                viewManager.setWidth(this.stage.getWidth());
                viewManager.setHeight(this.stage.getHeight());
                var _g1 = 0;
                var _g = this.scenarios.get(scenarioId).layers.length;
                while (_g1 < _g) {
                    var i = _g1++;
                    var layerProperties = this.scenarios.get(scenarioId).layers[i];
                    var layerId = layerProperties.id;
                    var dObj = this.stage.getChildByID(layerId);
                    viewManager.addChild(dObj);
                    var type = layerProperties.type;
                    var time = layerProperties.time;
                    var xPos = dObj.getX();
                    var yPos = dObj.getY();
                    this.tweens.get(scenarioId).push(displayEngineUtils.TweenX.to(dObj, {
                        x: xPos + layerProperties.x,
                        y: yPos + layerProperties.y,
                        rotation: layerProperties.rotation,
                        alpha: layerProperties.alpha
                    }, time, null, null, null, null, null, null, null, {
                        fileName: "ViewManagerComponent.hx",
                        lineNumber: 128,
                        className: "game.viewmanager.components.ViewManagerComponent",
                        methodName: "activate"
                    }).ease(displayEngineUtils.EaseX.sineIn).onFinish(function() {
                        currentTween++;
                        if (currentTween >= totalTweens) {
                            haxe.Log.trace("VIEW_MANAGER.activate.getCompleted " + _hcmn_.Std.string(_g2.activeScenarios.get(scenarioId)), {
                                fileName: "ViewManagerComponent.hx",
                                lineNumber: 141,
                                className: "game.viewmanager.components.ViewManagerComponent",
                                methodName: "activate",
                                customParams: [scenarioId]
                            });
                            _g2.reset(scenarioId);
                            _g2.implPort.getCompleted().publish(scenarioId);
                            _g2.activeScenarios.set(scenarioId, false);
                        }
                    }));
                }
                totalTweens = this.tweens.get(scenarioId).length;
                if (viewManager.getMask() != null) viewManager.setMask(null);
                var points = [this.maskSize[0], this.maskSize[1], this.maskSize[2], this.maskSize[3]];
                var mask = this.getMask(points);
                viewManager.setMask(mask);
            } else return;
        };
        scarabViewManager.ViewManagerComponent.prototype.deactivate = function(scenarioId) {};
        scarabViewManager.ViewManagerComponent.prototype.onLayoutUpdate = function(cfg) {
            haxe.Log.trace("VIEW_MANAGER.layoutUpdate() " + this.activeScenarios.toString(), {
                fileName: "ViewManagerComponent.hx",
                lineNumber: 174,
                className: "game.viewmanager.components.ViewManagerComponent",
                methodName: "onLayoutUpdate"
            });
            var viewManager = this.stage.getChildByID("VIEW_MANAGER");
            viewManager.setWidth(this.stage.getWidth());
            viewManager.setHeight(this.stage.getHeight());
            this.maskSize = cfg.mask;
            if (viewManager.getMask() != null) viewManager.setMask(null);
            var points = [this.maskSize[0], this.maskSize[1], this.maskSize[2], this.maskSize[3]];
            var mask = this.getMask(points);
            viewManager.setMask(mask);
        };
        scarabViewManager.ViewManagerComponent.prototype.onGameLayoutUpdateStarted = function() {
            haxe.Log.trace("VIEW_MANAGER.onGameLayoutUpdateStarted() ", {
                fileName: "ViewManagerComponent.hx",
                lineNumber: 193,
                className: "game.viewmanager.components.ViewManagerComponent",
                methodName: "onGameLayoutUpdateStarted"
            });
            var $it0 = this.scenarios.keys();
            while ($it0.hasNext()) {
                var scenarioId = $it0.next();
                if (this.activeScenarios.get(scenarioId)) this.reset(scenarioId);
            }
        };
        scarabViewManager.ViewManagerComponent.prototype.onGameLayoutUpdateCompleted = function() {
            var _g1 = 0;
            var _g = this.stage.getChildren().length;
            while (_g1 < _g) {
                var i = _g1++;
                var layerId = this.stage.getChildAt(i).getName();
                var dObj = this.stage.getChildByID(layerId);
                var props = {
                    x: dObj.getX(),
                    y: dObj.getY(),
                    rotation: dObj.getRotation(),
                    alpha: dObj.getAlpha()
                };
                this.initProperties.set(layerId, props);
            }
            this.implPort.getUpdated().publish(this.activeScenarios);
            var $it0 = this.activeScenarios.keys();
            while ($it0.hasNext()) {
                var scenarioId = $it0.next();
                this.activeScenarios.set(scenarioId, false);
            }
        };
        scarabViewManager.ViewManagerComponent.prototype.show = function(scenarioId) {
            haxe.Log.trace("VIEW_MANAGER.show() " + scenarioId, {
                fileName: "ViewManagerComponent.hx",
                lineNumber: 230,
                className: "game.viewmanager.components.ViewManagerComponent",
                methodName: "show"
            });
            var len = this.scenarios.get(scenarioId).layers.length;
            var _g = 0;
            while (_g < len) {
                var i = _g++;
                var layerId = this.scenarios.get(scenarioId).layers[i].id;
                if (this.stage.getChildByID(layerId) != null) {
                    var dObj = this.stage.getChildByID(layerId);
                    dObj.setVisible(true);
                }
            }
        };
        scarabViewManager.ViewManagerComponent.prototype.hide = function(scenarioId) {
            haxe.Log.trace("VIEW_MANAGER.hide() " + scenarioId, {
                fileName: "ViewManagerComponent.hx",
                lineNumber: 246,
                className: "game.viewmanager.components.ViewManagerComponent",
                methodName: "hide"
            });
            var len = this.scenarios.get(scenarioId).layers.length;
            var _g = 0;
            while (_g < len) {
                var i = _g++;
                var layerId = this.scenarios.get(scenarioId).layers[i].id;
                if (this.stage.getChildByID(layerId) != null) {
                    var dObj = this.stage.getChildByID(layerId);
                    dObj.setVisible(false);
                }
            }
        };
        scarabViewManager.ViewManagerComponent.prototype.reset = function(scenarioId) {
            haxe.Log.trace("VIEW_MANAGER.reset() " + _hcmn_.Std.string(this.activeScenarios.get(scenarioId)), {
                fileName: "ViewManagerComponent.hx",
                lineNumber: 261,
                className: "game.viewmanager.components.ViewManagerComponent",
                methodName: "reset",
                customParams: [scenarioId]
            });
            var scenarioActive = this.activeScenarios.get(scenarioId);
            if (scenarioActive) {
                if (this.tweens.exists(scenarioId)) {
                    var _g1 = 0;
                    var _g = this.tweens.get(scenarioId).length;
                    while (_g1 < _g) {
                        var i = _g1++;
                        var tween = this.tweens.get(scenarioId)[i];
                        tween.onFinish(null);
                        tween.stop();
                        var totalTime = tween.get_totalTime();
                        tween["goto"](totalTime, false);
                        tween.onHead($bind(tween, tween.stop));
                        tween = null;
                    }
                    this.tweens.remove(scenarioId);
                }
            }
            var viewManager = this.stage.getChildByID("VIEW_MANAGER");
            viewManager.setWidth(this.stage.getWidth());
            viewManager.setHeight(this.stage.getHeight());
            var totalChildren = viewManager.getChildren().length;
            var len = viewManager.getChildren().length;
            var _g2 = 0;
            while (_g2 < len) {
                var i1 = _g2++;
                totalChildren--;
                var dObj = viewManager.getChildAt(totalChildren);
                this.stage.addChild(dObj);
            }
            if (viewManager.getMask() != null) viewManager.setMask(null);
            viewManager.setX(0);
            viewManager.setY(0);
        };
        scarabViewManager.ViewManagerComponent.prototype.initShake = function(props) {
            var _g = this;
            var viewManager = this.stage.getChildByID("VIEW_MANAGER");
            var scenarioId = props.scenarioId;
            haxe.Log.trace("[ViewManagerComponent] [initShake] ", {
                fileName: "ViewManagerComponent.hx",
                lineNumber: 312,
                className: "game.viewmanager.components.ViewManagerComponent",
                methodName: "initShake",
                customParams: [props, this.tweens.exists(scenarioId)]
            });
            var rndX = 1;
            var rndY = 1;
            var multiplier = props.multiplier;
            var limit = props.limit;
            var step = props.step;
            var rndDestX = this.getRandomTanValue(-Math.PI / 4, _hcmn_.Math.PI / 4) * multiplier;
            var rndDestY = this.getRandomTanValue(-Math.PI / 4, _hcmn_.Math.PI / 4) * multiplier;
            var sumRndX = 0;
            var sumRndY = 0;
            var initX = viewManager.getX();
            var initY = viewManager.getY();
            var xPos = viewManager.getX();
            var yPos = viewManager.getY();
            viewManager.setX(0);
            viewManager.setY(0);
            if (!this.tweens.exists(scenarioId)) {
                var value = [];
                this.tweens.set(scenarioId, value);
                this.activeScenarios.set(scenarioId, true);
                viewManager.setWidth(this.stage.getWidth());
                viewManager.setHeight(this.stage.getHeight());
                var _g1 = 0;
                var _g2 = this.scenarios.get(scenarioId).layers.length;
                while (_g1 < _g2) {
                    var i = _g1++;
                    var layerProperties = this.scenarios.get(scenarioId).layers[i];
                    var layerId = layerProperties.id;
                    var dObj = this.stage.getChildByID(layerId);
                    viewManager.addChild(dObj);
                }
                this.tweens.get(scenarioId).push(displayEngineUtils.TweenX.to(viewManager, {}, props.time, null, null, null, null, null, null, null, {
                    fileName: "ViewManagerComponent.hx",
                    lineNumber: 352,
                    className: "game.viewmanager.components.ViewManagerComponent",
                    methodName: "initShake"
                }).ease(displayEngineUtils.EaseX.sineIn).onUpdate(function() {
                    xPos = initX + rndX;
                    yPos = initY + rndY;
                    sumRndX += rndX;
                    sumRndY += rndY;
                    viewManager.setX(xPos);
                    viewManager.setY(yPos);
                    if (_hcmn_.Math.abs(sumRndX) < _hcmn_.Math.abs(rndDestX)) rndX = _g.moveToDest(rndX, rndDestX, multiplier, step);
                    else {
                        rndX = _g.getTanValue(rndX, limit, multiplier, step);
                        if (rndX == 0) {
                            rndDestX = _g.getRandomTanValue(-Math.PI / 4, _hcmn_.Math.PI / 4) * multiplier;
                            sumRndX = 0;
                        }
                    }
                    if (_hcmn_.Math.abs(sumRndY) < _hcmn_.Math.abs(rndDestY)) rndY = _g.moveToDest(rndY, rndDestY, multiplier, step);
                    else {
                        rndY = _g.getTanValue(rndY, limit, multiplier, step);
                        if (rndY == 0) {
                            rndDestY = _g.getRandomTanValue(-Math.PI / 4, _hcmn_.Math.PI / 4) * multiplier;
                            sumRndY = 0;
                        }
                    }
                }).onFinish(function() {
                    _g.reset(scenarioId);
                    viewManager.setX(0);
                    viewManager.setY(0);
                    _g.activeScenarios.set(scenarioId, false);
                }));
                if (viewManager.getMask() != null) viewManager.setMask(null);
            }
        };
        scarabViewManager.ViewManagerComponent.prototype.getRandomTanValue = function(min, max) {
            return _hcmn_.Math.tan(_hcmn_.Math.random() * (max - min) + min);
        };
        scarabViewManager.ViewManagerComponent.prototype.getTanValue = function(input, limit, multiplier, step) {
            var value = input;
            if (value < -limit) value = this.getRandomTanValue(_hcmn_.Math.atan(value / multiplier), _hcmn_.Math.atan((value + step) / multiplier)) * multiplier;
            else if (value > limit) value = this.getRandomTanValue(_hcmn_.Math.atan(value / multiplier), _hcmn_.Math.atan((value - step) / multiplier)) * multiplier;
            else value = 0;
            return value;
        };
        scarabViewManager.ViewManagerComponent.prototype.moveToDest = function(input, dest, multiplier, step) {
            var value = input;
            if (value < dest) value = this.getRandomTanValue(_hcmn_.Math.atan(value / multiplier), _hcmn_.Math.atan((value + step) / multiplier)) * multiplier;
            else value = this.getRandomTanValue(_hcmn_.Math.atan(value / multiplier), _hcmn_.Math.atan((value - step) / multiplier)) * multiplier;
            return value;
        };
        scarabViewManager.ViewManagerComponent.prototype.getMask = function(points, paddingX, paddingY, alpha) {
            if (alpha == null) alpha = 0;
            if (paddingY == null) paddingY = 0;
            if (paddingX == null) paddingX = 0;
            var mask = this.getGraphics(points, 16711680, 0.2);
            mask.setX(paddingX);
            mask.setY(paddingY);
            return mask;
        };
        scarabViewManager.ViewManagerComponent.prototype.getGraphics = function(points, colour, alpha) {
            if (alpha == null) alpha = 1;
            if (colour == null) colour = 16711680;
            var graphics = scarabViewManager.ExternalService.displayProvider.getFactory().createGraphics();
            graphics.beginFill(colour, alpha);
            graphics.moveTo(points[0][0], points[0][1]);
            var _g = 0;
            while (_g < points.length) {
                var point = points[_g];
                ++_g;
                graphics.lineTo(point[0], point[1]);
            }
            graphics.endFill();
            return graphics;
        };
        scarabViewManager.ViewManagerComponent.prototype.__class__ = scarabViewManager.ViewManagerComponent;
        scarabViewManager.BaseEvents = function() {
            this.choice = new _hcmn_.msignal_Signal1();
        };
        scarabViewManager.BaseEvents.__name__ = ["scarabViewManager", "BaseEvents"];
        scarabViewManager.BaseEvents.prototype.choice = null;
        scarabViewManager.BaseEvents.prototype.__class__ = scarabViewManager.BaseEvents;
        if (typeof haxe == 'undefined') {
            var haxe = {};
        };

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

            get: function(k) {
                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 (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: scarabViewManager,
            activator: scarabViewManager.Activator
        };
    });
//# sourceURL=scarabViewManager.js