define("gameLayout", ["componentmodelComponentApi", "clientkernelLoaderApi", "slotModelApi", "displayEngineApi", "gameLayoutApi", "clientkernelEventbusApi", "clientkernelModulesApi", "moneyApi"],
    function(componentmodelComponentApi, clientkernelLoaderApi, slotModelApi, displayEngineApi, gameLayoutApi, 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 gameLayout == 'undefined') {
            var gameLayout = {};
        };
        gameLayout.Activator = function(context) {};
        gameLayout.Activator = ck_implements(gameLayout.Activator, clientkernelModulesApi.IModuleActivator);
        gameLayout.Activator.__interfaces__ = [clientkernelModulesApi.IModuleActivator];
        gameLayout.Activator.__name__ = ["gameLayout", "Activator"];
        gameLayout.Activator.prototype.start = function(context) {
            context.getServiceTracker([clientkernelLoaderApi.IAssetRegistry, displayEngineApi.IDisplayProvider]).then(function(context1) {
                context1.registerService(new gameLayout.GameLayoutFactory(context1), gameLayoutApi.GameLayoutDeclaration, null);
            });
        };
        gameLayout.Activator.prototype.stop = function(context) {};
        gameLayout.Activator.main = function() {};
        gameLayout.Activator.prototype.__class__ = gameLayout.Activator;
        gameLayout.CacheControl = function(scenarios_cfg, displayProvider, gameLayoutPort) {
            this.cachedIds = [];
            this.stage = displayProvider.getDefaultStage();
            this.dpFactory = displayProvider.getFactory();
            this.gameLayoutPort = gameLayoutPort;
            this.scenarios = new _hcmn_.haxe_ds_StringMap();
            this.cachedIds = [];
            var _g = 0;
            var _g1 = _hcmn_.Reflect.fields(scenarios_cfg);
            while (_g < _g1.length) {
                var field = _g1[_g];
                ++_g;
                var value = _hcmn_.Reflect.field(scenarios_cfg, field);
                this.scenarios.set(field, value);
            }
            gameLayoutPort.getCacheLayers().subscribe($bind(this, this.cacheLayers));
            gameLayoutPort.getUncacheLayers().subscribe($bind(this, this.uncacheLayers));
        };
        gameLayout.CacheControl.__name__ = ["gameLayout", "CacheControl"];
        gameLayout.CacheControl.prototype.stage = null;
        gameLayout.CacheControl.prototype.dpFactory = null;
        gameLayout.CacheControl.prototype.cachedIds = null;
        gameLayout.CacheControl.prototype.scenarios = null;
        gameLayout.CacheControl.prototype.gameLayoutPort = null;
        gameLayout.CacheControl.prototype.cacheLayers = function(e) {
            var scenarioSet;
            var key = e.getPayload();
            scenarioSet = this.scenarios.get(key);
            if (scenarioSet == null) return;
            var cacheGroups = [];
            var groupIndex = 0;
            var _g1 = 0;
            var _g = this.stage.getNumChildren();
            while (_g1 < _g) {
                var i = _g1++;
                var child = this.stage.getChildAt(i);
                if ((function($this) {
                        var $r;
                        var x = child.getName();
                        $r = _hcmn_.HxOverrides.indexOf(scenarioSet, x, 0);
                        return $r;
                    }(this)) >= 0) {
                    if (cacheGroups[groupIndex] == null) cacheGroups[groupIndex] = [];
                    cacheGroups[groupIndex].push(child);
                } else if (cacheGroups[groupIndex] != null) groupIndex++;
            }
            var _g2 = 0;
            while (_g2 < cacheGroups.length) {
                var group = cacheGroups[_g2];
                ++_g2;
                this.cachedIds.push(this.dpFactory.cache(group));
                null;
            }
        };
        gameLayout.CacheControl.prototype.uncacheLayers = function(e) {
            var _g = 0;
            var _g1 = this.cachedIds;
            while (_g < _g1.length) {
                var id = _g1[_g];
                ++_g;
                this.dpFactory.uncache(id);
            }
            this.cachedIds = [];
        };
        gameLayout.CacheControl.prototype.__class__ = gameLayout.CacheControl;
        gameLayout.GameLayout = function(mcontext, context) {
            this.fpsArray = [];
            this.gamePresented = false;
            this.updatingComponents = null;
            this.screenHeight = 0;
            this.screenWidth = 0;
            var _g = this;
            this.oldverify = define.verify;
            var myverify = $bind(this, this.verify);
            define.verify = myverify;
            this.context = context;
            this.mcontext = mcontext;
            this.components = new _hcmn_.haxe_ds_StringMap();
            this.port = context.getImplementedPort(gameLayoutApi.IGameLayoutImplementationPort);
            this.slotModelPort = context.getUsedPort(slotModelApi.ISlotModelPort);
            this.updatingComponents = null;
            this.assetRegistry = mcontext.getAnyService(clientkernelLoaderApi.IAssetRegistry);
            this.displayProvider = mcontext.getAnyService(displayEngineApi.IDisplayProvider);
            this.variablesRegistry = mcontext.getAnyService(clientkernelLoaderApi.IVariableRegistry);
            this.modelPerAspect = new _hcmn_.haxe_ds_StringMap();
            this.stages = new gameLayout.Stages(this.displayProvider, this.variablesRegistry);
            this.port.getComponentLayoutUpdated().subscribe($bind(this, this.componentUpdated));
            this.assetRegistry.getAsset("background").getContent().then(function(bg) {
                window.document.body.style.backgroundImage = "url(" + _g.assetRegistry.getAsset("background").getUrl() + ")";
            });
            this.assetRegistry.getAsset("gamelayout-config").getContent().then(function(config) {
                var map = context.getReferredComponents("layout");
                var wait = context.getReferredComponents("wait");
                var componentPromises = [];
                var componentNames = [];
                var $it0 = map.keys();
                while ($it0.hasNext()) {
                    var m = $it0.next();
                    componentNames.push(m);
                    componentPromises.push(_hcmn_.__map_reserved[m] != null ? map.getReserved(m) : map.h[m]);
                }
                var $it1 = wait.keys();
                while ($it1.hasNext()) {
                    var w = $it1.next();
                    componentPromises.push(_hcmn_.__map_reserved[w] != null ? wait.getReserved(w) : wait.h[w]);
                }
                Promise.all(componentPromises).then(function(data) {
                    var _g1 = 0;
                    var _g2 = componentNames.length;
                    while (_g1 < _g2) {
                        var i = _g1++;
                        var value = data[i];
                        _g.components.set(componentNames[i], value);
                    }
                    _g.initialize(config.layout);
                    if (config.cachescenarios != null) _g.cacheControl = new gameLayout.CacheControl(config.cachescenarios, _g.displayProvider, _g.port);
                });
            });
            var bus = mcontext.getAnyService(clientkernelEventbusApi.IEventBus, null);
            bus.getChannel("GFBus").subscribe("testable:testcomponent:getfps", $bind(this, this.handleFps));
            bus.getChannel("GFBus").subscribe("testable:testcomponent:measureFps", $bind(this, this.measureFps));
            bus.getChannel("GFBus").subscribe("testable:testcomponent:getfpsarray", $bind(this, this.handleFpsArray));
            if (window.location.search.indexOf("settext=enabled") != -1) {
                bus.getChannel("GFBus").subscribe("testable:testcomponent:settext", $bind(this, this.handleSetText));
                var textDOM;
                var _this = window.document;
                textDOM = _this.createElement("div");
                textDOM.setAttribute("id", "testTextDOM");
                textDOM.setAttribute("style", "position: absolute; top: 23px; left: 130px; font-family: Consolas; color: #fff; text-shadow: rgb(0, 0, 0) 1px 0px 0px, rgb(0, 0, 0) 0.540302px 0.841471px 0px, rgb(0, 0, 0) -0.416147px 0.909297px 0px, rgb(0, 0, 0) -0.989992px 0.14112px 0px, rgb(0, 0, 0) -0.653644px -0.756802px 0px, rgb(0, 0, 0) 0.283662px -0.958924px 0px, rgb(0, 0, 0) 0.96017px -0.279415px 0px; font-size: 15px; font-weight: bold;");
                window.document.body.appendChild(textDOM);
            }
            window.document.body.addEventListener("touchmove", function(e) {
                e.preventDefault();
            });
            this.attachComponents();
        };
        gameLayout.GameLayout.__name__ = ["gameLayout", "GameLayout"];
        gameLayout.GameLayout.prototype.mcontext = null;
        gameLayout.GameLayout.prototype.context = null;
        gameLayout.GameLayout.prototype.assetRegistry = null;
        gameLayout.GameLayout.prototype.variablesRegistry = null;
        gameLayout.GameLayout.prototype.displayProvider = null;
        gameLayout.GameLayout.prototype.modelPerAspect = null;
        gameLayout.GameLayout.prototype.stages = null;
        gameLayout.GameLayout.prototype.screenWidth = null;
        gameLayout.GameLayout.prototype.screenHeight = null;
        gameLayout.GameLayout.prototype.components = null;
        gameLayout.GameLayout.prototype.port = null;
        gameLayout.GameLayout.prototype.updatingComponents = null;
        gameLayout.GameLayout.prototype.relayout = null;
        gameLayout.GameLayout.prototype.oldverify = null;
        gameLayout.GameLayout.prototype.cacheControl = null;
        gameLayout.GameLayout.prototype.slotModelPort = null;
        gameLayout.GameLayout.prototype.gamePresented = null;
        gameLayout.GameLayout.prototype.fpsArray = null;
        gameLayout.GameLayout.prototype.timer = null;
        gameLayout.GameLayout.prototype.attachComponents = function() {
            this.slotModelPort.getGameCommands().getContinueCommandAvailable().subscribe($bind(this, this.handleGamePresented));
            this.slotModelPort.getGameCommands().getSpinCommandAvailable().subscribe($bind(this, this.handleGamePresented));
        };
        gameLayout.GameLayout.prototype.handleGamePresented = function(e) {
            if (!this.gamePresented) {
                if (e.getPayload()) {
                    this.stages.get("skgl_0").canvas.style.display = "block";
                    var stage = this.stages.get("skgl_0");
                    stage.destage.onWindowTouch($bind(this, this.onWindowTouch));
                }
                this.gamePresented = true;
            }
        };
        gameLayout.GameLayout.prototype.onWindowTouch = function() {
            var isMobile = this.variablesRegistry.get("skin") == "mobile" || this.variablesRegistry.get("assetPack") == "mobile";
            if (isMobile) this.slotModelPort.getGameCommands().getFullScreenCommandExecuted().publish(null);
        };
        gameLayout.GameLayout.prototype.measureFps = function(e) {
            var _g = this;
            var stage = this.stages.get("skgl_0");
            this.timer = new _hcmn_.haxe_Timer(100);
            this.timer.run = function() {
                var currentFps = stage.destage.getFpsInfo().fps;
                _g.fpsArray.push(currentFps);
            };
        };
        gameLayout.GameLayout.prototype.handleFpsArray = function(e) {
            var bus = this.mcontext.getAnyService(clientkernelEventbusApi.IEventBus, null);
            bus.getChannel("TBus").publish("testable:testcomponent:fpsarray", this.fpsArray);
            this.fpsArray = [];
            if (this.timer != null) this.timer.stop();
        };
        gameLayout.GameLayout.prototype.handleFps = function(e) {
            var stage = this.stages.get("skgl_0");
            var currentFps = stage.destage.getFpsInfo().fps;
            var bus = this.mcontext.getAnyService(clientkernelEventbusApi.IEventBus, null);
            bus.getChannel("TBus").publish("testable:testcomponent:fps", currentFps);
        };
        gameLayout.GameLayout.prototype.handleSetText = function(e) {
            var textToShow = e.getPayload();
            var textDOM = window.document.getElementById("testTextDOM");
            if (textDOM != null) {
                textDOM.innerHTML = textToShow;
                var bus = this.mcontext.getAnyService(clientkernelEventbusApi.IEventBus, null);
                bus.getChannel("TBus").publish("testable:testcomponent:settextconfirm", textToShow);
            }
        };
        gameLayout.GameLayout.prototype.verify = function() {
            var ret = this.oldverify();
            if (ret != null) return ret;
            if (this.updatingComponents == null) return null;
            var $it0 = this.updatingComponents.keys();
            while ($it0.hasNext()) {
                var i = $it0.next();
                var $it1 = this.components.keys();
                while ($it1.hasNext()) {
                    var j = $it1.next();
                    if (this.components.get(j).getId() == i) return "verify error: awaiting gamelayout for " + j;
                }
            }
            return null;
        };
        gameLayout.GameLayout.prototype.initialize = function(config) {
            var _g1 = 0;
            var _g = config.length;
            while (_g1 < _g) {
                var i = _g1++;
                var aspects = config[i].aspects;
                var gameLayoutModel = gameLayout.GameLayoutModelFactory.getModel(config[i].model.type);
                gameLayoutModel.configure(config[i].model.config);
                var _g2 = 0;
                while (_g2 < aspects.length) {
                    var a = aspects[_g2];
                    ++_g2;
                    this.modelPerAspect.set(a == null ? "null" : "" + a, gameLayoutModel);
                }
            }
            this.layout();
            window.addEventListener("resize", $bind(this, this.layout));
            var resizeTimer = new _hcmn_.haxe_Timer(200);
            resizeTimer.run = $bind(this, this.layout);
        };
        gameLayout.GameLayout.prototype.layout = function() {
            if (this.screenWidth != window.innerWidth || this.screenHeight != window.innerHeight) {
                window.scrollTo(0, 0);
                this.screenWidth = window.innerWidth;
                this.screenHeight = window.innerHeight;
                var devicePixelRatio = window.devicePixelRatio;
                if (devicePixelRatio == null) devicePixelRatio = 1.0;
                var r = 1;
                var screenAspect = this.screenWidth / this.screenHeight;
                var aspectIndex = this.matchAspect(screenAspect);
                var aspect = parseFloat(aspectIndex);
                var model = this.modelPerAspect.get(aspectIndex);
                var cl = model.getComponentLayout(aspect);
                this.stages.adjust(cl, aspect, _hcmn_.Math.floor(this.screenWidth * devicePixelRatio), _hcmn_.Math.floor(this.screenHeight * devicePixelRatio), devicePixelRatio);
                this.updateComponents(cl);
            }
        };
        gameLayout.GameLayout.prototype.updateComponents = function(cl) {
            window.PIXI._redrawRegionComponents = {};
            var $it0 = cl.keys();
            while ($it0.hasNext()) {
                var key = $it0.next();
                var containers;
                containers = (_hcmn_.__map_reserved[key] != null ? cl.getReserved(key) : cl.h[key]).containers;
                var $it1 = containers.keys();
                while ($it1.hasNext()) {
                    var k = $it1.next();
                    window.PIXI._redrawRegionComponents[k] = _hcmn_.__map_reserved[k] != null ? containers.getReserved(k) : containers.h[k];
                }
            }
            if (this.updatingComponents != null) {
                this.relayout = true;
                return;
            }
            this.updatingComponents = new _hcmn_.haxe_ds_StringMap();
            var $it2 = this.components.iterator();
            while ($it2.hasNext()) {
                var comp = $it2.next();
                var key1 = comp.getId();
                this.updatingComponents.set(key1, false);
            }
            this.relayout = false;
            var updatePayload = new haxe.ds.ObjectMap();
            $bind(updatePayload, updatePayload.exists);
            $bind(updatePayload, updatePayload.get);
            var $it3 = cl.keys();
            while ($it3.hasNext()) {
                var i = $it3.next();
                var cmp_u;
                cmp_u = _hcmn_.__map_reserved[i] != null ? cl.getReserved(i) : cl.h[i];
                var cmp = new gameLayoutApi.ComponentLayout(new _hcmn_.haxe_ds_StringMap());
                var $it4 = cmp_u.containers.keys();
                while ($it4.hasNext()) {
                    var i1 = $it4.next();
                    var cont = cmp_u.containers.get(i1);
                    var offsetcont = new gameLayoutApi.ContainerLayout(cont.id, cont.stage, cont.stageZIndex, this.stages.get(cont.stage).offsetLeft(cont.left), this.stages.get(cont.stage).offsetTop(cont.top), cont.width, cont.height, cont.zIndex, cont.configuration);
                    cmp.containers.set(i1, offsetcont);
                }
                if (this.components.exists(i)) updatePayload.set(this.components.get(i), cmp);
            }
            this.port.getUpdateComponentLayout().publish(updatePayload);
        };
        gameLayout.GameLayout.prototype.componentUpdated = function(event) {
            var key = event.getPayload().getId();
            this.updatingComponents.remove(key);
            if (!this.updatingComponents.iterator().hasNext()) {
                this.updatingComponents = null;
                this.port.getGameLayoutUpdated().publish(null);
                if (this.relayout) this.layout();
            }
        };
        gameLayout.GameLayout.prototype.matchAspect = function(aspect) {
            var minAspectDiff = 0;
            var ret = null;
            var $it0 = this.modelPerAspect.keys();
            while ($it0.hasNext()) {
                var i = $it0.next();
                var a = parseFloat(i);
                if (ret == null) {
                    minAspectDiff = _hcmn_.Math.abs(aspect - a);
                    ret = i;
                } else if (_hcmn_.Math.abs(aspect - a) < minAspectDiff) {
                    minAspectDiff = _hcmn_.Math.abs(aspect - a);
                    ret = i;
                }
            }
            return ret;
        };
        gameLayout.GameLayout.prototype.__class__ = gameLayout.GameLayout;
        gameLayout.GameLayoutFactory = function(mcontext) {
            this.mcontext = mcontext;
        };
        gameLayout.GameLayoutFactory = ck_implements(gameLayout.GameLayoutFactory, clientkernelModulesApi.IService);
        gameLayout.GameLayoutFactory = ck_implements(gameLayout.GameLayoutFactory, componentmodelComponentApi.IComponentFactory);
        gameLayout.GameLayoutFactory.__interfaces__ = [clientkernelModulesApi.IService, componentmodelComponentApi.IComponentFactory];
        gameLayout.GameLayoutFactory.__name__ = ["gameLayout", "GameLayoutFactory"];
        gameLayout.GameLayoutFactory.prototype.mcontext = null;
        gameLayout.GameLayoutFactory.prototype.createComponent = function(context) {
            new gameLayout.GameLayout(this.mcontext, context);
        };
        gameLayout.GameLayoutFactory.prototype.getComponentDeclaration = function() {
            return gameLayoutApi.GameLayoutDeclaration;
        };
        gameLayout.GameLayoutFactory.prototype.__class__ = gameLayout.GameLayoutFactory;
        gameLayout.StageElement = function(stage, stageZIndex, left, top, width, height) {
            this.stage = stage;
            this.stageZIndex = stageZIndex;
            this.gcHeight = height;
            this.gcWidth = width;
            this.gcTop = top;
            this.gcLeft = left;
        };
        gameLayout.StageElement.__name__ = ["gameLayout", "StageElement"];
        gameLayout.StageElement.prototype.stage = null;
        gameLayout.StageElement.prototype.stageZIndex = null;
        gameLayout.StageElement.prototype.gcHeight = null;
        gameLayout.StageElement.prototype.gcWidth = null;
        gameLayout.StageElement.prototype.gcTop = null;
        gameLayout.StageElement.prototype.gcLeft = null;
        gameLayout.StageElement.prototype.canvas = null;
        gameLayout.StageElement.prototype.destage = null;
        gameLayout.StageElement.prototype.expand = function(left, top, width, height) {
            var newleft;
            if (this.gcLeft < left) newleft = this.gcLeft;
            else newleft = left;
            var newright;
            if (this.gcLeft + this.gcWidth > left + width) newright = this.gcLeft + this.gcWidth;
            else newright = left + width;
            var newtop;
            if (this.gcTop < top) newtop = this.gcTop;
            else newtop = top;
            var newbottom;
            if (this.gcTop + this.gcHeight > top + height) newbottom = this.gcTop + this.gcHeight;
            else newbottom = top + height;
            this.gcLeft = newleft;
            this.gcWidth = newright - newleft;
            this.gcTop = newtop;
            this.gcHeight = newbottom - newtop;
        };
        gameLayout.StageElement.prototype.createCanvas = function(displayProvider, pcStagesOffsetLeft, pcStagesOffsetTop, pcStagesWidth, pcStagesHeight, gcStagesWidth, gcStagesHeight, r, targetFPS) {
            var _this = window.document;
            this.canvas = _this.createElement("canvas");
            this.canvas.id = this.stage;
            this.canvas.style.visibility = "visible";
            this.canvas.style.position = "absolute";
            this.canvas.style.display = "initial";
            this.canvas.style.zIndex = "" + this.stageZIndex * 10;
            this.canvas.style.outline = "none";
            this.canvas.tabIndex = 0;
            var stageDef = new displayEngineApi.StageDef();
            stageDef.id = this.canvas.id;
            stageDef.canvas = this.canvas;
            stageDef.dimension = new displayEngineApi.Point(this.canvas.width, this.canvas.height);
            stageDef.targetFPS = targetFPS;
            this.destage = displayProvider.getFactory().createStage(stageDef);
            this.destage.setScaleX(pcStagesWidth / gcStagesWidth);
            this.destage.setScaleY(pcStagesHeight / gcStagesHeight);
            this.adjust(displayProvider, pcStagesOffsetLeft, pcStagesOffsetTop, pcStagesWidth, pcStagesHeight, gcStagesWidth, gcStagesHeight, null, r);
            window.document.body.appendChild(this.canvas);
            this.canvas.focus();
        };
        gameLayout.StageElement.prototype.adjust = function(displayProvider, pcStagesOffsetLeft, pcStagesOffsetTop, pcStagesWidth, pcStagesHeight, gcStagesWidth, gcStagesHeight, newStage, r) {
            if (newStage != null) {
                this.gcLeft = newStage.gcLeft;
                this.gcWidth = newStage.gcWidth;
                this.gcTop = newStage.gcTop;
                this.gcHeight = newStage.gcHeight;
            }
            this.canvas.style.left = _hcmn_.Math.round(r * (pcStagesOffsetLeft + _hcmn_.Math.round(this.gcLeft * pcStagesWidth / gcStagesWidth))) + "px";
            this.canvas.style.top = _hcmn_.Math.round(r * (pcStagesOffsetTop + _hcmn_.Math.round(this.gcTop * pcStagesHeight / gcStagesHeight))) + "px";
            if (this.destage != null) {
                this.destage.setWidth(_hcmn_.Math.round(this.gcWidth * pcStagesWidth / gcStagesWidth));
                this.destage.setHeight(_hcmn_.Math.round(this.gcHeight * pcStagesHeight / gcStagesHeight));
                this.destage.setScaleX(pcStagesWidth / gcStagesWidth);
                this.destage.setScaleY(pcStagesHeight / gcStagesHeight);
            } else {
                this.canvas.width = _hcmn_.Math.round(this.gcWidth * pcStagesWidth / gcStagesWidth);
                this.canvas.height = _hcmn_.Math.round(this.gcHeight * pcStagesHeight / gcStagesHeight);
            }
            var scale = 1;
            if (r != 1) {
                this.canvas.style.width = _hcmn_.Math.round(this.canvas.width * r) + "px";
                this.canvas.style.height = _hcmn_.Math.round(this.canvas.height * r) + "px";
                scale = this.capCanvasSize(1440);
            } else {
                this.canvas.style.width = "";
                this.canvas.style.height = "";
            }
            if (this.destage != null && scale > 1) {
                this.destage.setScaleX(this.destage.getScaleX() / scale);
                this.destage.setScaleY(this.destage.getScaleY() / scale);
                this.destage.setWidth(this.canvas.width);
                this.destage.setHeight(this.canvas.height);
            }
            if (this.gcHeight == null && this.gcWidth == null) {
                this.canvas.width = _hcmn_.Math.floor(window.innerWidth / r);
                this.canvas.height = _hcmn_.Math.floor(window.innerHeight / r);
                this.canvas.style.left = "0";
                this.canvas.style.top = "0";
                this.canvas.style.width = window.innerWidth + "px";
                this.canvas.style.height = window.innerHeight + "px";
                if (r != 1) this.capCanvasSize(1440);
            }
        };
        gameLayout.StageElement.prototype.capCanvasSize = function(maxSize) {
            var newW = this.canvas.width;
            var newH = this.canvas.height;
            var scale = 1;
            if (this.canvas.width < this.canvas.height) {
                scale = this.canvas.height / maxSize;
                if (this.canvas.height > maxSize) {
                    newH = maxSize;
                    newW = _hcmn_.Math.round(this.canvas.width / scale);
                }
            } else {
                scale = this.canvas.width / maxSize;
                if (this.canvas.width > maxSize) {
                    newW = maxSize;
                    newH = _hcmn_.Math.round(this.canvas.height / scale);
                }
            }
            this.canvas.width = newW;
            this.canvas.height = newH;
            return scale;
        };
        gameLayout.StageElement.prototype.offsetLeft = function(left) {
            return left - this.gcLeft;
        };
        gameLayout.StageElement.prototype.offsetTop = function(top) {
            return top - this.gcTop;
        };
        gameLayout.StageElement.prototype.__class__ = gameLayout.StageElement;
        gameLayout.Stages = function(displayProvider, variablesRegistry) {
            this.variablesRegistry = variablesRegistry;
            this.displayProvider = displayProvider;
            this.r = 1;
            this.stages = new _hcmn_.haxe_ds_StringMap();
        };
        gameLayout.Stages.__name__ = ["gameLayout", "Stages"];
        gameLayout.Stages.prototype.stages = null;
        gameLayout.Stages.prototype.gcWidth = null;
        gameLayout.Stages.prototype.gcHeight = null;
        gameLayout.Stages.prototype.gcAspect = null;
        gameLayout.Stages.prototype.pcWidth = null;
        gameLayout.Stages.prototype.pcHeight = null;
        gameLayout.Stages.prototype.pcOffsetTop = null;
        gameLayout.Stages.prototype.pcOffsetLeft = null;
        gameLayout.Stages.prototype.r = null;
        gameLayout.Stages.prototype.displayProvider = null;
        gameLayout.Stages.prototype.variablesRegistry = null;
        gameLayout.Stages.prototype.adjust = function(cl, aspect, screenWidth, screenHeight, devicePixelRatio) {
            this.gcAspect = aspect;
            this.gcWidth = 1920;
            this.gcHeight = _hcmn_.Math.round(this.gcWidth / this.gcAspect);
            var pcAspect = screenWidth / screenHeight;
            if (pcAspect <= aspect) {
                this.pcWidth = screenWidth;
                this.pcHeight = _hcmn_.Math.round(this.pcWidth / this.gcAspect);
                this.pcOffsetTop = _hcmn_.Math.round((screenHeight - this.pcHeight) / 2);
                this.pcOffsetLeft = 0;
            } else {
                this.pcHeight = screenHeight;
                this.pcWidth = _hcmn_.Math.round(this.pcHeight * this.gcAspect);
                this.pcOffsetLeft = _hcmn_.Math.round((screenWidth - this.pcWidth) / 2);
                this.pcOffsetTop = 0;
            }
            var newstages = this.calculateStages(cl);
            var $it0 = this.stages.keys();
            while ($it0.hasNext()) {
                var k = $it0.next();
                if (!(_hcmn_.__map_reserved[k] != null ? newstages.existsReserved(k) : newstages.h.hasOwnProperty(k))) this.stages.get(k).canvas.remove();
                else this.stages.get(k).adjust(this.displayProvider, this.pcOffsetLeft, this.pcOffsetTop, this.pcWidth, this.pcHeight, this.gcWidth, this.gcHeight, _hcmn_.__map_reserved[k] != null ? newstages.getReserved(k) : newstages.h[k], this.r / devicePixelRatio);
            }
            var $it1 = newstages.keys();
            while ($it1.hasNext()) {
                var k1 = $it1.next();
                if (!this.stages.exists(k1)) {
                    var newstage;
                    newstage = _hcmn_.__map_reserved[k1] != null ? newstages.getReserved(k1) : newstages.h[k1];
                    var targetFPS = _hcmn_.Std.parseInt(this.variablesRegistry.get("targetFPS", "30"));
                    newstage.createCanvas(this.displayProvider, this.pcOffsetLeft, this.pcOffsetTop, this.pcWidth, this.pcHeight, this.gcWidth, this.gcHeight, this.r / devicePixelRatio, targetFPS);
                    this.stages.set(k1, newstage);
                }
            }
        };
        gameLayout.Stages.prototype.get = function(stage) {
            return this.stages.get(stage);
        };
        gameLayout.Stages.prototype.calculateStages = function(cl) {
            var ret = new _hcmn_.haxe_ds_StringMap();
            var $it0 = new haxe.ds._StringMap.StringMapIterator(cl, cl.arrayKeys());
            while ($it0.hasNext()) {
                var component = $it0.next();
                var $it1 = component.containers.iterator();
                while ($it1.hasNext()) {
                    var container = $it1.next();
                    if (!ret.exists(container.stage)) {
                        var value = new gameLayout.StageElement(container.stage, container.stageZIndex, container.left, container.top, container.width, container.height);
                        ret.set(container.stage, value);
                    } else ret.get(container.stage).expand(container.left, container.top, container.width, container.height);
                }
            }
            return ret;
        };
        gameLayout.Stages.prototype.__class__ = gameLayout.Stages;
        gameLayout.GameLayoutModelFactory = function() {};
        gameLayout.GameLayoutModelFactory.__name__ = ["gameLayout", "GameLayoutModelFactory"];
        gameLayout.GameLayoutModelFactory.getModel = function(type) {
            switch (type) {
                case "explicit":
                    return new gameLayout.ExplicitGameLayoutModel();
                default:
                    return new gameLayout.ExplicitGameLayoutModel();
            }
        };
        gameLayout.GameLayoutModelFactory.prototype.__class__ = gameLayout.GameLayoutModelFactory;

        gameLayout.IGameLayoutModel = function() {}
        gameLayout.IGameLayoutModel.prototype = {

            configure: function(config) {
                return {
                    arguments: ["*"],
                    returns: "void"
                };
            },
            getComponentLayout: function(exactAspect) {
                return {
                    arguments: ["number"],
                    returns: Map
                };
            },
            getRequiredStages: function() {
                return {
                    arguments: [],
                    returns: "array"
                };
            }
        };
        gameLayout.ExplicitGameLayoutModel = function() {
            this.requiredStages = null;
            this.componentLayout = null;
        };
        gameLayout.ExplicitGameLayoutModel = ck_implements(gameLayout.ExplicitGameLayoutModel, gameLayout.IGameLayoutModel);
        gameLayout.ExplicitGameLayoutModel.__interfaces__ = [gameLayout.IGameLayoutModel];
        gameLayout.ExplicitGameLayoutModel.__name__ = ["gameLayout", "ExplicitGameLayoutModel"];
        gameLayout.ExplicitGameLayoutModel.prototype.componentLayout = null;
        gameLayout.ExplicitGameLayoutModel.prototype.requiredStages = null;
        gameLayout.ExplicitGameLayoutModel.prototype.configure = function(config) {
            this.componentLayout = new _hcmn_.haxe_ds_StringMap();
            this.requiredStages = [];
            var _g1 = 0;
            var _g = config.components.length;
            while (_g1 < _g) {
                var i = _g1++;
                if (_hcmn_.HxOverrides.indexOf(this.requiredStages, config.components[i].stage, 0) == -1) this.requiredStages.push(config.components[i].stage);
                var cl = new gameLayoutApi.ComponentLayout(new _hcmn_.haxe_ds_StringMap());
                var _g3 = 0;
                var _g2 = config.components[i].containers.length;
                while (_g3 < _g2) {
                    var j = _g3++;
                    var cn = new gameLayoutApi.ContainerLayout(config.components[i].containers[j].id, this.stageName(config.components[i].containers[j].stage), config.components[i].containers[j].stageZIndex, config.components[i].containers[j].left, config.components[i].containers[j].top, config.components[i].containers[j].width, config.components[i].containers[j].height, config.components[i].containers[j].zindex, config.components[i].containers[j].configuration);
                    cl.containers.set(cn.id, cn);
                }
                this.componentLayout.set(config.components[i].id, cl);
            }
        };
        gameLayout.ExplicitGameLayoutModel.prototype.stageName = function(stageIndex) {
            return "skgl_" + stageIndex;
        };
        gameLayout.ExplicitGameLayoutModel.prototype.getComponentLayout = function(exactAspect) {
            return this.componentLayout;
        };
        gameLayout.ExplicitGameLayoutModel.prototype.getRequiredStages = function() {
            var stages = [];
            return stages;
        };
        gameLayout.ExplicitGameLayoutModel.prototype.__class__ = gameLayout.ExplicitGameLayoutModel;
        if (typeof haxe == 'undefined') {
            var haxe = {};
        };

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

        };
        if (!haxe.ds) {
            haxe.ds = {};
        };
        haxe.ds.ObjectMap = function() {
            this.h = {};
            this.h.__keys__ = {};
        };
        haxe.ds.ObjectMap.__interfaces__ = [haxe.IMap];
        haxe.ds.ObjectMap.__name__ = ["haxe", "ds", "ObjectMap"];
        haxe.ds.ObjectMap.prototype.h = null;
        haxe.ds.ObjectMap.prototype.set = function(key, value) {
            var id = key.__id__ || (key.__id__ = ++haxe.ds.ObjectMap.count);
            this.h[id] = value;
            this.h.__keys__[id] = key;
        };
        haxe.ds.ObjectMap.prototype.get = function(key) {
            return this.h[key.__id__];
        };
        haxe.ds.ObjectMap.prototype.exists = function(key) {
            return this.h.__keys__[key.__id__] != null;
        };
        haxe.ds.ObjectMap.prototype.__class__ = haxe.ds.ObjectMap;
        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;
        gameLayout.StageElement.CANVAS_CAP_DIMENSION = 1440;;
        haxe.ds.ObjectMap.count = 0;;
        return {
            exports: gameLayout,
            activator: gameLayout.Activator
        };
    });
//# sourceURL=gameLayout.js