define("wolfRunPopup", ["viewBuilderApi", "componentmodelComponentApi", "translationmanagerApi", "clientkernelLoaderApi", "displayEngineApi", "wolfRunPopupApi", "displayEngineUtils", "gameLayoutApi", "clientkernelEventbusApi", "clientkernelModulesApi"],
    function(viewBuilderApi, componentmodelComponentApi, translationmanagerApi, clientkernelLoaderApi, displayEngineApi, wolfRunPopupApi, displayEngineUtils, gameLayoutApi, 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 haxe == 'undefined') {
            var haxe = {};
        };

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

            get: function(k) {
                return {
                    arguments: ["*"],
                    returns: "null"
                };
            },
            keys: function() {
                return {
                    arguments: [],
                    returns: "null"
                };
            }
        };
        if (typeof js == 'undefined') {
            var js = {};
        };
        if (!js._Boot) {
            js._Boot = {};
        };
        js._Boot.HaxeError = function(val) {
            Error.call(this);
            this.val = val;
            this.message = String(val);
            if (Error.captureStackTrace) Error.captureStackTrace(this, js._Boot.HaxeError);
        };
        js._Boot.HaxeError.__name__ = ["js", "_Boot", "HaxeError"];
        js._Boot.HaxeError.__super__ = Error;
        for (var k in Error.prototype) js._Boot.HaxeError.prototype[k] = Error.prototype[k];
        js._Boot.HaxeError.prototype.val = null;
        js._Boot.HaxeError.prototype.__class__ = js._Boot.HaxeError;
        if (typeof wolfRunPopup == 'undefined') {
            var wolfRunPopup = {};
        };
        wolfRunPopup.Activator = function(context) {};
        wolfRunPopup.Activator = ck_implements(wolfRunPopup.Activator, clientkernelModulesApi.IModuleActivator);
        wolfRunPopup.Activator.__interfaces__ = [clientkernelModulesApi.IModuleActivator];
        wolfRunPopup.Activator.__name__ = ["wolfRunPopup", "Activator"];
        wolfRunPopup.Activator.prototype.start = function(context) {
            context.getServiceTracker([viewBuilderApi.IViewBuilderFactory, clientkernelLoaderApi.IAssetRegistry, displayEngineApi.IDisplayProvider, translationmanagerApi.ITranslationManager]).then(function(context1) {
                wolfRunPopup.ExternalService.initialize(context1);
                context1.registerService(new wolfRunPopup.PopupFactory(context1), wolfRunPopupApi.PopupDeclaration, null);
            });
        };
        wolfRunPopup.Activator.prototype.stop = function(context) {};
        wolfRunPopup.Activator.main = function() {};
        wolfRunPopup.Activator.prototype.__class__ = wolfRunPopup.Activator;
        wolfRunPopup.ExternalService = function() {};
        wolfRunPopup.ExternalService.__name__ = ["wolfRunPopup", "ExternalService"];
        wolfRunPopup.ExternalService._context = null;
        wolfRunPopup.ExternalService.assetRegistry = null;
        wolfRunPopup.ExternalService.displayProvider = null;
        wolfRunPopup.ExternalService.viewBuilderFactory = null;
        wolfRunPopup.ExternalService.translationManager = null;
        wolfRunPopup.ExternalService.buss = null;
        wolfRunPopup.ExternalService.initialize = function(context) {
            wolfRunPopup.ExternalService._context = context;
            wolfRunPopup.ExternalService.assetRegistry = context.getAnyService(clientkernelLoaderApi.IAssetRegistry, null);
            wolfRunPopup.ExternalService.displayProvider = context.getAnyService(displayEngineApi.IDisplayProvider, null);
            wolfRunPopup.ExternalService.viewBuilderFactory = context.getAnyService(viewBuilderApi.IViewBuilderFactory, null);
            wolfRunPopup.ExternalService.translationManager = context.getAnyService(translationmanagerApi.ITranslationManager, null);
            wolfRunPopup.ExternalService.buss = context.getAnyService(clientkernelEventbusApi.IEventBus, null);
        };
        wolfRunPopup.ExternalService.getAsset = function(id) {
            return wolfRunPopup.ExternalService.assetRegistry.getAsset(id).getContent();
        };
        wolfRunPopup.ExternalService.getBus = function() {
            return wolfRunPopup.ExternalService.buss;
        };
        wolfRunPopup.ExternalService.prototype.__class__ = wolfRunPopup.ExternalService;
        wolfRunPopup.Popup = function(context, cfgId) {
            this.context = context;
            this.layoutPort = context.getUsedPort(gameLayoutApi.IGameLayoutPort);
            this.layoutPort.getUpdateComponentLayout().subscribe($bind(this, this.updateLayout));
            this.implementationPopupPort = context.getImplementedPort(wolfRunPopupApi.IPopupImplementationPort);
            this.implementationPopupPort.getShowAwardCap().subscribe($bind(this, this.handleAwardCap));
            this.implementationPopupPort.getHide().subscribe($bind(this, this.handleHide));
            this.builder = new wolfRunPopup.PopupBuilder();
        };
        wolfRunPopup.Popup.__name__ = ["wolfRunPopup", "Popup"];
        wolfRunPopup.Popup.prototype.context = null;
        wolfRunPopup.Popup.prototype.layoutPort = null;
        wolfRunPopup.Popup.prototype.implementationPopupPort = null;
        wolfRunPopup.Popup.prototype.layoutPayload = null;
        wolfRunPopup.Popup.prototype.popupScreen = null;
        wolfRunPopup.Popup.prototype.builder = null;
        wolfRunPopup.Popup.prototype.handleHide = function(e) {
            if (this.popupScreen != null) {
                this.popupScreen.remove();
                this.popupScreen = null;
            }
        };
        wolfRunPopup.Popup.prototype.handleAwardCap = function(e) {
            var _g = this;
            this.builder.loadAdditional("freespinbonus-assets/" + "FREE_GAME_INTRO_VB").then(function(vba) {
                _g.builder.create("AWARDCAP", wolfRunPopup.AwardCap).then(function(popup) {
                    _g.popupScreen = popup;
                    _g.popupScreen.animAssets = vba;
                    _g.popupScreen.init(e.getPayload());
                    _g.popupScreen.show();
                    _g.popupScreen.hideButton();
                    _g.popupScreen.updateLayout(_g.layoutPayload);
                });
            });
        };
        wolfRunPopup.Popup.prototype.hideComponent = function(e) {
            this.popupScreen.remove();
            this.popupScreen = null;
        };
        wolfRunPopup.Popup.prototype.updateLayout = function(e) {
            this.layoutPayload = e.getPayload();
            this.builder.setLayout(this.layoutPayload);
            if (this.popupScreen != null) this.popupScreen.updateLayout(this.layoutPayload);
            this.layoutPort.getComponentLayoutUpdated().publish(this.context.getInstance());
        };
        wolfRunPopup.Popup.prototype.__class__ = wolfRunPopup.Popup;
        wolfRunPopup.PopupFactory = function(context) {
            this.context = context;
        };
        wolfRunPopup.PopupFactory = ck_implements(wolfRunPopup.PopupFactory, clientkernelModulesApi.IService);
        wolfRunPopup.PopupFactory = ck_implements(wolfRunPopup.PopupFactory, componentmodelComponentApi.IComponentFactory);
        wolfRunPopup.PopupFactory.__interfaces__ = [clientkernelModulesApi.IService, componentmodelComponentApi.IComponentFactory];
        wolfRunPopup.PopupFactory.__name__ = ["wolfRunPopup", "PopupFactory"];
        wolfRunPopup.PopupFactory.prototype.context = null;
        wolfRunPopup.PopupFactory.prototype.getComponentDeclaration = function() {
            return wolfRunPopupApi.PopupDeclaration;
        };
        wolfRunPopup.PopupFactory.prototype.createComponent = function(context) {
            var cfgId = context.getConfiguration();
            new wolfRunPopup.Popup(context, cfgId);
        };
        wolfRunPopup.PopupFactory.prototype.__class__ = wolfRunPopup.PopupFactory;
        wolfRunPopup.PopupBase = function(id, view, stage) {
            this.stage = stage;
            this.id = id;
            this.view = view.getComponentById(id);
        };
        wolfRunPopup.PopupBase.__name__ = ["wolfRunPopup", "PopupBase"];
        wolfRunPopup.PopupBase.prototype.onFinishCallback = null;
        wolfRunPopup.PopupBase.prototype.stage = null;
        wolfRunPopup.PopupBase.prototype.id = null;
        wolfRunPopup.PopupBase.prototype.view = null;
        wolfRunPopup.PopupBase.prototype.animAssets = null;
        wolfRunPopup.PopupBase.prototype.init = function(data) {};
        wolfRunPopup.PopupBase.prototype.setOnFinishListener = function(listener) {
            this.onFinishCallback = listener;
        };
        wolfRunPopup.PopupBase.prototype.remove = function() {
            this.stage.removeChild(this.view.getDisplayObject());
            this.view.hide();
        };
        wolfRunPopup.PopupBase.prototype.updateLayout = function(componentLayout) {
            var layout = componentLayout.containers.get(this.id);
            var container = this.view.getDisplayObject();
            container.setX(layout.left);
            container.setY(layout.top);
            container.setScaleX(layout.width / container.getUserData().viewBuilderW);
            container.setScaleY(layout.height / container.getUserData().viewBuilderH);
            container.setZIndex(layout.zIndex);
        };
        wolfRunPopup.PopupBase.prototype.onPress = function(e) {
            this.onFinish();
        };
        wolfRunPopup.PopupBase.prototype.show = function() {
            this.stage.addChild(this.view.getDisplayObject());
            this.view.show();
        };
        wolfRunPopup.PopupBase.prototype.hideButton = function() {};
        wolfRunPopup.PopupBase.prototype.onFinish = function() {
            this.onFinishCallback();
        };
        wolfRunPopup.PopupBase.prototype.__class__ = wolfRunPopup.PopupBase;
        wolfRunPopup.AwardCap = function(id, view, stage) {
            wolfRunPopup.PopupBase.call(this, id, view, stage);
        };
        wolfRunPopup.AwardCap.__name__ = ["wolfRunPopup", "AwardCap"];
        wolfRunPopup.AwardCap.__super__ = wolfRunPopup.PopupBase;
        for (var k in wolfRunPopup.PopupBase.prototype) wolfRunPopup.AwardCap.prototype[k] = wolfRunPopup.PopupBase.prototype[k];
        wolfRunPopup.AwardCap.prototype.zoomAnimationHolder = null;
        wolfRunPopup.AwardCap.prototype.zoomAnimation = null;
        wolfRunPopup.AwardCap.prototype.labelHolder = null;
        wolfRunPopup.AwardCap.prototype.init = function(data) {
            this.labelHolder = this.view.getComponentById("MaxAwardLabels");
            if (this.labelHolder == null) throw new Error("not found: " + "MaxAwardLabels");
            this.labelHolder.hide();
            this.setTextLabels(data);
            this.createZoomAnimation(this.animAssets);
        };
        wolfRunPopup.AwardCap.prototype.createZoomAnimation = function(vbAsset) {
            if (vbAsset == null) throw new Error("asset not found: " + "popup-assets/" + ("FREE_GAME_INTRO" + "_VB"));
            var vbAnimView = wolfRunPopup.ExternalService.viewBuilderFactory.createView(vbAsset);
            if (vbAnimView == null) throw new Error("error on creating view");
            var vbdbAniamtionHolder = vbAnimView.createContainerFromStoredConfig("ANIMATION_HOLDER");
            this.zoomAnimation = vbdbAniamtionHolder.getComponentById("ANIMATION_CONTENT");
            this.zoomAnimationHolder = this.view.getComponentById("FREE_GAME_INTRO");
            if (this.zoomAnimationHolder == null) throw new Error("not found: " + "FREE_GAME_INTRO");
            this.zoomAnimationHolder.addChildComponent(this.zoomAnimation, "FREE_GAME_INTRO" + "_VB");
            this.zoomAnimationHolder.hide();
        };
        wolfRunPopup.AwardCap.prototype.show = function() {
            wolfRunPopup.PopupBase.prototype.show.call(this);
            this.zoomIn();
        };
        wolfRunPopup.AwardCap.prototype.remove = function() {
            this.zoomOut();
        };
        wolfRunPopup.AwardCap.prototype.setTextLabels = function(data) {
            var $it0 = (function($this) {
                var $r;
                var this1 = $this.labelHolder.getChildComponents();
                $r = this1.keys();
                return $r;
            }(this));
            while ($it0.hasNext()) {
                var key = $it0.next();
                var label = this.labelHolder.getComponentById(key);
                if (key == "MaxWinValue") label.setText(data.value);
                if (key == "FreeSpinsComplete" && data.freeSpin == false) label.setText("");
            }
        };
        wolfRunPopup.AwardCap.prototype.zoomIn = function() {
            if (this.zoomAnimationHolder == null || this.zoomAnimation == null) throw new Error("zoomAnimation not initialized");
            this.zoomAnimationHolder.show();
            this.zoomAnimation.addEventListener("evIntroComplete", $bind(this, this.onZoomInCompleted));
            this.zoomAnimation.gotoAndPlay(false, "intro");
        };
        wolfRunPopup.AwardCap.prototype.onZoomInCompleted = function() {
            this.zoomAnimation.stop();
            this.zoomAnimation.removeEventListener("evIntroComplete");
            this.labelHolder.show();
        };
        wolfRunPopup.AwardCap.prototype.zoomOut = function() {
            this.labelHolder.hide();
            this.zoomAnimation.addEventListener("evOutroComplete", $bind(this, this.onZoomOutCompleted));
            this.zoomAnimation.gotoAndPlay(false, "outro");
        };
        wolfRunPopup.AwardCap.prototype.onZoomOutCompleted = function() {
            this.zoomAnimation.stop();
            this.zoomAnimation.removeEventListener("evOutroComplete");
            this.zoomAnimation.hide();
            this.zoomAnimationHolder.hide();
            this.dispose();
        };
        wolfRunPopup.AwardCap.prototype.dispose = function() {
            wolfRunPopup.PopupBase.prototype.remove.call(this);
        };
        wolfRunPopup.AwardCap.prototype.__class__ = wolfRunPopup.AwardCap;
        wolfRunPopup.PopupBuilder = function() {};
        wolfRunPopup.PopupBuilder.__name__ = ["wolfRunPopup", "PopupBuilder"];
        wolfRunPopup.PopupBuilder.prototype.layoutPayload = null;
        wolfRunPopup.PopupBuilder.prototype.loadAdditional = function(id) {
            return wolfRunPopup.ExternalService.getAsset(id);
        };
        wolfRunPopup.PopupBuilder.prototype.create = function(id, popupClass) {
            var _g = this;
            var promise = new Promise(function(resolve, reject) {
                var assetId = "popup-assets/" + id;
                wolfRunPopup.ExternalService.getAsset(assetId).then(function(vbAssets) {
                    var view = wolfRunPopup.ExternalService.viewBuilderFactory.createView(vbAssets);
                    var popup = _hcmn_.Type.createInstance(popupClass, [id, view, _g.getStage(id)]);
                    resolve(popup);
                });
            });
            return promise;
        };
        wolfRunPopup.PopupBuilder.prototype.setLayout = function(layoutPayload) {
            this.layoutPayload = layoutPayload;
        };
        wolfRunPopup.PopupBuilder.prototype.getStage = function(container) {
            var container1 = this.layoutPayload.containers.get(container).stage;
            var this1 = wolfRunPopup.ExternalService.displayProvider.getStages();
            return this1.get(container1);
        };
        wolfRunPopup.PopupBuilder.prototype.__class__ = wolfRunPopup.PopupBuilder;
        wolfRunPopup.Popup.AWARD_CAP_ID = "AWARDCAP";;
        wolfRunPopup.Popup.ANIM_ID = "FREE_GAME_INTRO_VB";;
        wolfRunPopup.AwardCap.ASSETS_ID = "popup-assets/";;
        wolfRunPopup.AwardCap.ZOOM_ANIM = "FREE_GAME_INTRO";;
        wolfRunPopup.AwardCap.ANIM_VB = "FREE_GAME_INTRO" + "_VB";;
        wolfRunPopup.AwardCap.ANIM_ZOOM_IN = "intro";;
        wolfRunPopup.AwardCap.ANIM_ZOOM_OUT = "outro";;
        wolfRunPopup.AwardCap.ANIM_ZOOM_IN_DONE = "evIntroComplete";;
        wolfRunPopup.AwardCap.ANIM_ZOOM_OUT_DONE = "evOutroComplete";;
        wolfRunPopup.AwardCap.LABELS_MAX_AWARD = "MaxAwardLabels";;
        return {
            exports: wolfRunPopup,
            activator: wolfRunPopup.Activator
        };
    });
//# sourceURL=wolfRunPopup.js