define("background", ["viewBuilderApi", "componentmodelComponentApi", "clientkernelLoaderApi", "displayEngineApi", "gameLayoutApi", "PIXI", "BABYLON", "clientkernelEventbusApi", "backgroundApi", "clientkernelModulesApi"],
    function(viewBuilderApi, componentmodelComponentApi, clientkernelLoaderApi, displayEngineApi, gameLayoutApi, PIXI, BABYLON, clientkernelEventbusApi, backgroundApi, 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 background == 'undefined') {
            var background = {};
        };
        background.BrowserUtil = function() {};
        background.BrowserUtil.__name__ = ["background", "BrowserUtil"];
        background.BrowserUtil.checkIsIE = function() {
            var ua = window.navigator.userAgent;
            var trident = ua.indexOf("Trident/");
            if (trident > -1) return true;
            else return false;
        };
        background.BrowserUtil.isVideoSafe = function() {
            if (background.BrowserUtil.checkIsIE()) return false;
            if (background.BrowserUtil.mobileVideoDisabled == true && background.BrowserUtil.isMobile == true) return false;
            return background.BrowserUtil.videoSafe;
        };
        background.BrowserUtil.getScreenWidth = function() {
            var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;;
            return width;
        };
        background.BrowserUtil.getScreenHeight = function() {
            var height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;;
            return height;
        };
        background.BrowserUtil.registerVideoErrorListener = function(listener) {
            background.BrowserUtil.videoErrorListeners.push(listener);
        };
        background.BrowserUtil.videoError = function() {
            background.BrowserUtil.videoSafe = false;
            var _g = 0;
            var _g1 = background.BrowserUtil.videoErrorListeners;
            while (_g < _g1.length) {
                var listener = _g1[_g];
                ++_g;
                listener();
            }
        };
        background.BrowserUtil.prototype.__class__ = background.BrowserUtil;
        background.Activator = function(context) {};
        background.Activator = ck_implements(background.Activator, clientkernelModulesApi.IModuleActivator);
        background.Activator.__interfaces__ = [clientkernelModulesApi.IModuleActivator];
        background.Activator.__name__ = ["background", "Activator"];
        background.Activator.prototype.start = function(context) {
            context.getServiceTracker([viewBuilderApi.IViewBuilderFactory, clientkernelLoaderApi.IAssetRegistry, displayEngineApi.IDisplayProvider, clientkernelLoaderApi.IVariableRegistry]).then(function(context1) {
                var vbf = context1.getAnyService(viewBuilderApi.IViewBuilderFactory, null);
                var variables = context1.getAnyService(clientkernelLoaderApi.IVariableRegistry);
                var assetPack = variables.get("assetPack");
                if (assetPack == "mobile" || assetPack == "tablet") background.BrowserUtil.isMobile = true;
                background.ExternalService.initialize(context1, vbf);
                context1.registerService(new background.BackgroundFactory(context1), backgroundApi.BackgroundDeclaration, null);
            });
        };
        background.Activator.prototype.stop = function(context) {};
        background.Activator.main = function() {};
        background.Activator.prototype.__class__ = background.Activator;
        background.Background = function(context) {
            this.shouldPlayVideoInBrowser = true;
            this.backgroundElements = new _hcmn_.haxe_ds_StringMap();
            this.MAIN_CONFIG_ID = "background-config";
            this.COMPONENT_ID = "BACKGROUND";
            var _g = this;
            this.context = context;
            this.port = context.getImplementedPort(backgroundApi.IBackgroundImplementationPort);
            this.layoutPort = context.getUsedPort(gameLayoutApi.IGameLayoutPort);
            background.ExternalService.assetRegistry.getAsset(this.MAIN_CONFIG_ID).getContent().then(function(config) {
                _g.configuration = config;
                _g.initialize();
                _g.controller = new background.BackgroundController(_g);
            });
        };
        background.Background.__name__ = ["background", "Background"];
        background.Background.prototype.COMPONENT_ID = null;
        background.Background.prototype.MAIN_CONFIG_ID = null;
        background.Background.prototype.view = null;
        background.Background.prototype.port = null;
        background.Background.prototype.layoutPort = null;
        background.Background.prototype.controller = null;
        background.Background.prototype.context = null;
        background.Background.prototype.configuration = null;
        background.Background.prototype.backgroundElements = null;
        background.Background.prototype.bgElement = null;
        background.Background.prototype.shouldPlayVideoInBrowser = null;
        background.Background.prototype.parseConfiguration = function(config) {
            var _g1 = this;
            var sources = config.sources;
            if (config.desktopVideoDisabledIn != null && this.detectBrowser() != null) {
                var browsers = config.desktopVideoDisabledIn;
                var _g = 0;
                while (_g < browsers.length) {
                    var b = browsers[_g];
                    ++_g;
                    var browserName = _hcmn_.Std.string(b.name).toLowerCase();
                    var browserVersion = "-1";
                    if (b.version != null && b.version != "all") browserVersion = _hcmn_.Std.string(b.version).toLowerCase();
                    var detectedBrowserName = (_hcmn_.js_Boot.__cast(this.detectBrowser().name, String)).toLowerCase();
                    var detectedBrowserVersion = (_hcmn_.js_Boot.__cast(this.detectBrowser().version, String)).toLowerCase();
                    if (browserName == detectedBrowserName) {
                        if (browserVersion != "-1" && browserVersion == detectedBrowserVersion) this.shouldPlayVideoInBrowser = false;
                        else this.shouldPlayVideoInBrowser = false;
                    }
                }
            }
            background.BrowserUtil.mobileVideoDisabled = config.mobileVideoDisabled;
            if (sources == null) return;
            var sources1 = _hcmn_.Reflect.field(config, "sources");
            if (sources1 == null) {
                throw new Error("[zb] - There are no sources in background configuration !!!! Please check your background configuration for propper syntax  ");
                return;
            }
            var _g2 = 0;
            while (_g2 < sources1.length) {
                var s = [sources1[_g2]];
                ++_g2;
                if (s[0].type == "img") {
                    var key = s[0].id;
                    var value = new background.ImageBackgroundElement(s[0]);
                    this.backgroundElements.set(key, value);
                }
                if (s[0].type == "video" && this.shouldPlayVideoInBrowser) {
                    var key1 = s[0].id;
                    var value1 = new background.VideoBackgroundElement(s[0]);
                    this.backgroundElements.set(key1, value1);
                }
                if (s[0].defaultBg == true) _hcmn_.haxe_Timer.delay((function(s) {
                    return function() {
                        _g1.playDefault(s[0].id);
                    };
                })(s), 0);
            }
            var tempTransitionsMap = new _hcmn_.haxe_ds_StringMap();
            var transitions = _hcmn_.Reflect.field(config, "transitions");
            if (transitions == null) {
                var $it0 = this.backgroundElements.iterator();
                while ($it0.hasNext()) {
                    var bgElement = $it0.next();
                    bgElement.setTransition(new background.TransitionData(background.TransitionData.FADE, 0, $bind(this, this.transtionDone)));
                }
            } else {
                var _g3 = 0;
                while (_g3 < transitions.length) {
                    var ts = transitions[_g3];
                    ++_g3;
                    var key2 = ts.id;
                    var value2 = new background.TransitionData(ts.type, ts.duration, $bind(this, this.transtionDone));
                    if (_hcmn_.__map_reserved[key2] != null) tempTransitionsMap.setReserved(key2, value2);
                    else tempTransitionsMap.h[key2] = value2;
                }
                var $it1 = this.backgroundElements.keys();
                while ($it1.hasNext()) {
                    var key3 = $it1.next();
                    if (_hcmn_.__map_reserved[key3] != null ? tempTransitionsMap.existsReserved(key3) : tempTransitionsMap.h.hasOwnProperty(key3)) this.backgroundElements.get(key3).setTransition(_hcmn_.__map_reserved[key3] != null ? tempTransitionsMap.getReserved(key3) : tempTransitionsMap.h[key3]);
                    else this.backgroundElements.get(key3).setTransition(new background.TransitionData(background.TransitionData.FADE, 0, $bind(this, this.transtionDone)));
                }
            }
        };
        background.Background.prototype.detectBrowser = function() {
            var ua = window.navigator.userAgent;
            var edge = ua.indexOf("Edge/");
            if (edge > 0) return {
                name: "edge",
                version: _hcmn_.Std.parseInt(ua.substring(edge + 5, ua.indexOf(".", edge))) + ""
            };
            var trident = ua.indexOf("Trident/");
            if (trident > 0) {
                var rv = ua.indexOf("rv:");
                return {
                    name: "ie11",
                    version: _hcmn_.Std.parseInt(ua.substring(rv + 3, ua.indexOf(".", rv))) + ""
                };
            }
            var msie = ua.indexOf("MSIE ");
            if (msie > 0) return {
                name: "ie10",
                version: _hcmn_.Std.parseInt(ua.substring(msie + 5, ua.indexOf(".", msie))) + ""
            };
            return null;
        };
        background.Background.prototype.playDefault = function(id) {
            if (!this.shouldPlayVideoInBrowser) return;
            this.bgElement = this.backgroundElements.get(id);
            if (background.BrowserUtil.isVideoSafe()) {
                if (this.bgElement.isVideo()) {
                    var posterId = this.bgElement.getPoster();
                    this.bgElement = this.backgroundElements.get(posterId);
                }
            }
            this.bgElement.show();
            var $it0 = this.backgroundElements.iterator();
            while ($it0.hasNext()) {
                var elem = $it0.next();
                if (elem != this.bgElement) elem.dispose();
            }
        };
        background.Background.prototype.transtionDone = function(id) {
            var $it0 = this.backgroundElements.keys();
            while ($it0.hasNext()) {
                var key = $it0.next();
                if (key != id) this.backgroundElements.get(key).dispose();
            }
        };
        background.Background.prototype.initialize = function() {
            background.BrowserUtil.registerVideoErrorListener($bind(this, this.videoErrorListener));
            this.parseConfiguration(this.configuration);
        };
        background.Background.prototype.videoErrorListener = function() {
            if (this.bgElement.getPoster() != "") this.showBackground(this.bgElement.getPoster());
            else throw new Error("[zb] - Each video must have a 'poster' property defined, to act as a video faile safe point ");
            var $it0 = this.backgroundElements.iterator();
            while ($it0.hasNext()) {
                var elements = $it0.next();
                if (elements.isVideo()) elements.destroy();
            }
        };
        background.Background.prototype.showBackground = function(id) {
            this.bgElement = this.backgroundElements.get(id);
            if (this.bgElement == null) return;
            if (!background.BrowserUtil.isVideoSafe()) {
                if (this.bgElement.isVideo()) {
                    var posterId = this.bgElement.getPoster();
                    this.bgElement = this.backgroundElements.get(posterId);
                }
            }
            var i = 1;
            var $it0 = this.backgroundElements.iterator();
            while ($it0.hasNext()) {
                var element = $it0.next();
                if (element != this.bgElement) {
                    element.setZOrder(i == null ? "null" : "" + i);
                    i++;
                }
            }
            this.bgElement.setZOrder(i == null ? "null" : "" + i);
            this.bgElement.startTranstion();
        };
        background.Background.prototype.hideAllAnimations = function() {
            var $it0 = this.backgroundElements.iterator();
            while ($it0.hasNext()) {
                var element = $it0.next();
                element.dispose();
            }
        };
        background.Background.prototype.__class__ = background.Background;
        background.BackgroundController = function(bkg) {
            this.flag_addedToStage = false;
            this.background = bkg;
            this.background.port.hideBackground().subscribe($bind(this, this.onHideBackground));
            this.background.port.showBackground().subscribe($bind(this, this.onShowBackground));
            this.background.layoutPort.getUpdateComponentLayout().subscribe($bind(this, this.updateLayout));
        };
        background.BackgroundController.__name__ = ["background", "BackgroundController"];
        background.BackgroundController.prototype.background = null;
        background.BackgroundController.prototype.flag_addedToStage = null;
        background.BackgroundController.prototype.onShowBackground = function(e) {
            this.background.showBackground(e.getPayload());
        };
        background.BackgroundController.prototype.onHideBackground = function(e) {
            this.background.hideAllAnimations();
        };
        background.BackgroundController.prototype.updateLayout = function(e) {
            var layoutPayload = e.getPayload();
            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 = background.ExternalService.displayProvider.getStages();
                stage = this1.get(layerPayload.stage);
                var container = this.background.view.getComponentById(layerId);
                var containerDO = container.getDisplayObject();
                containerDO.setCacheAsBitmap(false);
                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 (!this.flag_addedToStage) {
                this.flag_addedToStage = true;
                null;
            }
            this.background.layoutPort.getComponentLayoutUpdated().publish(this.background.context.getInstance());
        };
        background.BackgroundController.prototype.__class__ = background.BackgroundController;
        background.BackgroundFactory = function(context) {
            this.context = context;
        };
        background.BackgroundFactory = ck_implements(background.BackgroundFactory, clientkernelModulesApi.IService);
        background.BackgroundFactory = ck_implements(background.BackgroundFactory, componentmodelComponentApi.IComponentFactory);
        background.BackgroundFactory.__interfaces__ = [clientkernelModulesApi.IService, componentmodelComponentApi.IComponentFactory];
        background.BackgroundFactory.__name__ = ["background", "BackgroundFactory"];
        background.BackgroundFactory.prototype.vbf = null;
        background.BackgroundFactory.prototype.context = null;
        background.BackgroundFactory.prototype.getComponentDeclaration = function() {
            return backgroundApi.BackgroundDeclaration;
        };
        background.BackgroundFactory.prototype.createComponent = function(context) {
            new background.Background(context);
        };
        background.BackgroundFactory.prototype.__class__ = background.BackgroundFactory;
        background.ExternalService = function() {};
        background.ExternalService.__name__ = ["background", "ExternalService"];
        background.ExternalService.displayProvider = null;
        background.ExternalService.assetRegistry = null;
        background.ExternalService.viewBuilderFactory = null;
        background.ExternalService.loadedAssets = null;
        background.ExternalService.loadedDefinitionConfig = null;
        background.ExternalService.bus = null;
        background.ExternalService.initialize = function(context, vbf) {
            background.ExternalService.displayProvider = context.getAnyService(displayEngineApi.IDisplayProvider, null);
            background.ExternalService.assetRegistry = context.getAnyService(clientkernelLoaderApi.IAssetRegistry, null);
            background.ExternalService.bus = context.getAnyService(clientkernelEventbusApi.IEventBus, null);
            background.ExternalService.viewBuilderFactory = vbf;
        };
        background.ExternalService.prototype.__class__ = background.ExternalService;

        background.IBackgroundElement = function() {}
        background.IBackgroundElement.prototype = {

            startTranstion: function() {
                return {
                    arguments: [],
                    returns: "void"
                };
            },
            setTransition: function(t) {
                return {
                    arguments: ["*"],
                    returns: "void"
                };
            },
            dispose: function() {
                return {
                    arguments: [],
                    returns: "void"
                };
            },
            setZOrder: function(order) {
                return {
                    arguments: ["string"],
                    returns: "void"
                };
            },
            isVideo: function() {
                return {
                    arguments: [],
                    returns: "boolean"
                };
            },
            getPoster: function() {
                return {
                    arguments: [],
                    returns: "string"
                };
            },
            show: function() {
                return {
                    arguments: [],
                    returns: "void"
                };
            },
            destroy: function() {
                return {
                    arguments: [],
                    returns: "void"
                };
            }
        };
        background.ImageBackgroundElement = function(data) {
            this.id = data.id;
            this.path = data.path;
            this.backgroundPosition = data.mobileBackgroundPosition;
            if (!background.BrowserUtil.isMobile || !this.properFormat(this.backgroundPosition)) this.backgroundPosition = "center";
            var _this = window.document;
            this.divCont = _this.createElement("div");
            this.divCont.id = this.id;
            window.document.body.appendChild(this.divCont);
            var imageFolder = background.ExternalService.assetRegistry.getAsset("background").getUrl();
            var len = imageFolder.lastIndexOf("/") + 1;
            imageFolder = _hcmn_.HxOverrides.substr(imageFolder, 0, len);
            var style = "width: 100%; height: 100%; position: fixed; padding:0; margin:0; opacity:0; left: 0px; top: 0px; overflow:hidden; background: url(" + imageFolder + this.path + "); background-repeat: no-repeat; background-size: cover; background-position:" + this.backgroundPosition + "; background-position-x:" + this.backgroundPosition + "; background-position-y:" + this.backgroundPosition + ";";
            this.divCont.setAttribute("style", style);
            this.divCont.style.opacity = "0";
        };
        background.ImageBackgroundElement = ck_implements(background.ImageBackgroundElement, background.IBackgroundElement);
        background.ImageBackgroundElement.__interfaces__ = [background.IBackgroundElement];
        background.ImageBackgroundElement.__name__ = ["background", "ImageBackgroundElement"];
        background.ImageBackgroundElement.prototype.id = null;
        background.ImageBackgroundElement.prototype.divCont = null;
        background.ImageBackgroundElement.prototype.domEl = null;
        background.ImageBackgroundElement.prototype.path = null;
        background.ImageBackgroundElement.prototype.transition = null;
        background.ImageBackgroundElement.prototype.backgroundPosition = null;
        background.ImageBackgroundElement.prototype.startTranstion = function() {
            if (this.transition.duration == 0) {
                this.divCont.style.opacity = "1.0";
                this.transition.callback(this.divCont.id);
            } else new background.Transition(this.divCont, this.transition);
        };
        background.ImageBackgroundElement.prototype.setTransition = function(transition) {
            this.transition = transition;
        };
        background.ImageBackgroundElement.prototype.dispose = function() {
            this.divCont.style.opacity = "0";
        };
        background.ImageBackgroundElement.prototype.setZOrder = function(order) {
            this.divCont.style.zIndex = order;
        };
        background.ImageBackgroundElement.prototype.isVideo = function() {
            return false;
        };
        background.ImageBackgroundElement.prototype.getPoster = function() {
            return "";
        };
        background.ImageBackgroundElement.prototype.show = function() {
            this.divCont.style.opacity = "1";
        };
        background.ImageBackgroundElement.prototype.destroy = function() {};
        background.ImageBackgroundElement.prototype.properFormat = function(backgroundPosition) {
            switch (backgroundPosition) {
                case "left":
                    return true;
                case "right":
                    return true;
                case "center":
                    return true;
            }
            return false;
        };
        background.ImageBackgroundElement.prototype.__class__ = background.ImageBackgroundElement;
        background.Transition = function(div, transitionData) {
            this.div = div;
            this.transitionData = transitionData;
            var duration = transitionData.duration;
            this.currentOpacity = parseFloat(div.style.opacity);
            this.time = _hcmn_.Math.round(duration / 10);
            this.increase = (1 - this.currentOpacity) / 10;
            var _g = transitionData.type;
            switch (_g) {
                case "fade":
                    _hcmn_.haxe_Timer.delay($bind(this, this.fade), this.time);
                    break;
                case "bounce":
                    _hcmn_.haxe_Timer.delay($bind(this, this.bounce), this.time);
                    break;
                case "swipe":
                    _hcmn_.haxe_Timer.delay($bind(this, this.swipe), this.time);
                    break;
                default:
                    _hcmn_.haxe_Timer.delay($bind(this, this.fade), this.time);
            }
        };
        background.Transition.__name__ = ["background", "Transition"];
        background.Transition.prototype.transitionData = null;
        background.Transition.prototype.currentOpacity = null;
        background.Transition.prototype.time = null;
        background.Transition.prototype.increase = null;
        background.Transition.prototype.div = null;
        background.Transition.prototype.fade = function() {
            this.currentOpacity = parseFloat(this.div.style.opacity);
            this.div.style.opacity = _hcmn_.Std.string(this.currentOpacity + this.increase);
            this.currentOpacity = parseFloat(this.div.style.opacity);
            if (this.currentOpacity < 1) _hcmn_.haxe_Timer.delay($bind(this, this.fade), this.time);
            else this.transitionData.callback(this.div.id);
        };
        background.Transition.prototype.swipe = function() {};
        background.Transition.prototype.bounce = function() {};
        background.Transition.prototype.__class__ = background.Transition;
        background.TransitionData = function(type, duration, callback) {
            this.callback = callback;
            this.duration = duration;
            this.type = type;
        };
        background.TransitionData.__name__ = ["background", "TransitionData"];
        background.TransitionData.prototype.callback = null;
        background.TransitionData.prototype.duration = null;
        background.TransitionData.prototype.type = null;
        background.TransitionData.prototype.__class__ = background.TransitionData;
        background.VideoBackgroundElement = function(data) {
            var _g = this;
            this.id = data.id;
            this.path = data.path;
            this.poster = data.poster;
            var iOSversion = function() {
                var ret = true;
                if (/iP(hone|od|ad)/.test(navigator.platform)) {
                    var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
                    ret = parseInt(v[1]) > 9;
                }
                return ret;
            };
            var _this = window.document;
            this.divCont = _this.createElement("div");
            this.divCont.id = this.id;
            this.divCont.setAttribute("style", "width: 100%; height: 100%; position: fixed; padding:0; margin:0; left: 0px; top: 0px; overflow:hidden; opacity:0");
            window.document.body.appendChild(this.divCont);
            if (!background.BrowserUtil.isVideoSafe()) {
                this.divCont.style.display = "none";
                return;
            }
            if (!iOSversion()) return;
            var videoFolder = background.ExternalService.assetRegistry.getAsset("background").getUrl();
            var len = videoFolder.lastIndexOf("/") + 1;
            videoFolder = _hcmn_.HxOverrides.substr(videoFolder, 0, len);
            var isMobile = typeof window.orientation !== 'undefined';
            var isIOS = function() {
                var iDevices = ["iPad", "iPhone", "iPod"];
                if (window.navigator.platform != null)
                    while (iDevices.length > 0)
                        if (window.navigator.platform.indexOf(iDevices.pop()) >= 0) return true;
                return false;
            };
            var domEl;
            domEl = "<video playsinline autoplay " + (data.loop ? "  loop " : " ") + " muted style=\"z-index:9999999;height: 100%;" + (data.visible ? "opacity:1;" : "opacity:1;") + (isMobile ? "position: absolute;" : "width: 100%; -webkit-transform: translateZ(0); -moz-transform: translateZ(0); -ms-transform: translateZ(0);-o-transform: translateZ(0); transform: translateZ(0); ") + "display:flex;align-items:center;\" poster=\"" + background.ExternalService.assetRegistry.getAsset("background").getUrl() + "\" id=\"" + "video" + this.id + "\" >";
            domEl += "<source src=\"" + videoFolder + this.path + ".mp4\" type=\"video/mp4\">" + "<source src=\"" + videoFolder + this.path + ".webm\" type=\"video/webm\">" + "<source src=\"" + videoFolder + this.path + ".ogg\" type=\"video/ogg\">";
            domEl += "</video>";
            this.divCont.innerHTML = domEl;
            window.document.body.style.backgroundSize = "";
            this._video = _hcmn_.js_Boot.__cast(window.document.getElementById("video" + this.id), HTMLVideoElement);
            this._video.load();
            this._video.onplaying = function() {
                _g.updateSize();
            };
            this._video.onerror = function() {
                background.BrowserUtil.videoError();
            };
            if (isMobile) {
                if (isIOS()) window.onpageshow = function() {
                    if (_g._video != null) {
                        var promise = _g._video.play();
                        promise["catch"](function(error) {
                            background.BrowserUtil.videoError();
                        });
                    }
                };
            }
            window.addEventListener("resize", $bind(this, this.updateSize));
            window.addEventListener("orientationchange", $bind(this, this.updateSize));
            background.ExternalService.bus.getChannel("Game").subscribe("Game.InitDone", $bind(this, this.updateSize));
            window.document.body.onfocus = function() {
                if (_g._video != null && _g._video.paused) {
                    var edge = false;
                    try {
                        var promise1 = _g._video.play();
                        promise1["catch"](function(error1) {
                            background.BrowserUtil.videoError();
                        });
                    } catch (e) {
                        if (e instanceof js._Boot.HaxeError) e = e.val;
                        edge = true;
                    }
                    if (edge) try {
                        _g._video.play();
                    } catch (e1) {
                        if (e1 instanceof js._Boot.HaxeError) e1 = e1.val;
                        background.BrowserUtil.videoError();
                    }
                }
            };
            if (isIOS()) window.setInterval(function() {
                if (_g._video.paused) _g._video.play();
            }, 300);
        };
        background.VideoBackgroundElement = ck_implements(background.VideoBackgroundElement, background.IBackgroundElement);
        background.VideoBackgroundElement.__interfaces__ = [background.IBackgroundElement];
        background.VideoBackgroundElement.__name__ = ["background", "VideoBackgroundElement"];
        background.VideoBackgroundElement.prototype.id = null;
        background.VideoBackgroundElement.prototype.divCont = null;
        background.VideoBackgroundElement.prototype.domEl = null;
        background.VideoBackgroundElement.prototype.path = null;
        background.VideoBackgroundElement.prototype._video = null;
        background.VideoBackgroundElement.prototype.transition = null;
        background.VideoBackgroundElement.prototype.poster = null;
        background.VideoBackgroundElement.prototype.get_video = function() {
            return this._video;
        };
        background.VideoBackgroundElement.prototype.updateSize = function(e) {
            if (this._video != null) {
                this.playVid();
                var bw = window.innerWidth;
                var bh = window.innerHeight;
                var screenAspect = bw / bh;
                if (bh > bw || screenAspect > 1 && screenAspect < this._video.videoWidth / this._video.videoHeight) {
                    this._video.style.height = "100%";
                    this._video.style.width = "auto";
                    this._video.style.marginLeft = -((this._video.clientWidth - bw) / 2) + "px";
                } else {
                    this._video.style.height = "auto";
                    this._video.style.width = "100%";
                    this._video.style.marginLeft = "0px";
                }
            }
        };
        background.VideoBackgroundElement.prototype.playVid = function() {
            if (this._video != null) {
                var noPromise = false;
                try {
                    if (this._video.paused) {
                        var promise = this._video.play();
                        promise["catch"](function(error) {
                            background.BrowserUtil.videoError();
                        });
                    }
                } catch (e) {
                    if (e instanceof js._Boot.HaxeError) e = e.val;
                    noPromise = true;
                }
                if (noPromise == true) try {
                    this._video.play();
                } catch (e1) {
                    if (e1 instanceof js._Boot.HaxeError) e1 = e1.val;
                    background.BrowserUtil.videoError();
                }
            }
        };
        background.VideoBackgroundElement.prototype.pauseVid = function() {
            if (this._video != null) {
                if (!this._video.paused) this._video.pause();
            }
        };
        background.VideoBackgroundElement.prototype.stop = function() {
            this.pauseVid();
            this.updateSize();
        };
        background.VideoBackgroundElement.prototype.play = function() {
            this.playVid();
            this.updateSize();
        };
        background.VideoBackgroundElement.prototype.startTranstion = function() {
            var _g = this;
            if (this.transition.duration == 0) {
                this.divCont.style.opacity = "1.0";
                this.playVid();
                this.transition.callback(this.divCont.id);
            } else {
                new background.Transition(this.divCont, this.transition);
                _hcmn_.haxe_Timer.delay(function() {
                    _g.playVid();
                }, _hcmn_.Math.round(this.transition.duration + 10));
            }
        };
        background.VideoBackgroundElement.prototype.setTransition = function(transition) {
            this.transition = transition;
        };
        background.VideoBackgroundElement.prototype.dispose = function() {
            this.divCont.style.opacity = "0.0";
            if (this._video != null) this.pauseVid();
        };
        background.VideoBackgroundElement.prototype.setZOrder = function(order) {
            this.divCont.style.zIndex = order;
        };
        background.VideoBackgroundElement.prototype.isVideo = function() {
            return true;
        };
        background.VideoBackgroundElement.prototype.getPoster = function() {
            return this.poster;
        };
        background.VideoBackgroundElement.prototype.show = function() {
            this.divCont.style.opacity = "1";
            this.playVid();
        };
        background.VideoBackgroundElement.prototype.destroy = function() {
            this._video = null;
        };
        background.VideoBackgroundElement.prototype.__class__ = background.VideoBackgroundElement;
        if (typeof haxe == 'undefined') {
            var haxe = {};
        };

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

            get: function(k) {
                return {
                    arguments: ["*"],
                    returns: "null"
                };
            }
        };
        if (!haxe.ds) {
            haxe.ds = {};
        };
        if (!haxe.ds._StringMap) {
            haxe.ds._StringMap = {};
        };
        haxe.ds._StringMap.StringMapIterator = function(map, keys) {
            this.map = map;
            this.keys = keys;
            this.index = 0;
            this.count = keys.length;
        };
        haxe.ds._StringMap.StringMapIterator.__name__ = ["haxe", "ds", "_StringMap", "StringMapIterator"];
        haxe.ds._StringMap.StringMapIterator.prototype.map = null;
        haxe.ds._StringMap.StringMapIterator.prototype.keys = null;
        haxe.ds._StringMap.StringMapIterator.prototype.index = null;
        haxe.ds._StringMap.StringMapIterator.prototype.count = null;
        haxe.ds._StringMap.StringMapIterator.prototype.hasNext = function() {
            return this.index < this.count;
        };
        haxe.ds._StringMap.StringMapIterator.prototype.next = function() {
            return this.map.get(this.keys[this.index++]);
        };
        haxe.ds._StringMap.StringMapIterator.prototype.__class__ = haxe.ds._StringMap.StringMapIterator;
        if (typeof js == 'undefined') {
            var js = {};
        };
        if (!js._Boot) {
            js._Boot = {};
        };
        js._Boot.HaxeError = function(val) {
            Error.call(this);
            this.val = val;
            this.message = String(val);
            if (Error.captureStackTrace) Error.captureStackTrace(this, js._Boot.HaxeError);
        };
        js._Boot.HaxeError.__name__ = ["js", "_Boot", "HaxeError"];
        js._Boot.HaxeError.__super__ = Error;
        for (var k in Error.prototype) js._Boot.HaxeError.prototype[k] = Error.prototype[k];
        js._Boot.HaxeError.prototype.val = null;
        js._Boot.HaxeError.prototype.__class__ = js._Boot.HaxeError;
        background.BrowserUtil.videoSafe = true;;
        background.BrowserUtil.videoErrorListeners = [];;
        background.BrowserUtil.mobileVideoDisabled = false;;
        background.BrowserUtil.isMobile = false;;
        background.TransitionData.FADE = "fade";;
        background.TransitionData.SWIPE = "swipe";;
        background.TransitionData.BOUNCE = "bounce";;
        return {
            exports: background,
            activator: background.Activator
        };
    });
//# sourceURL=genericBackground.js