define("gameProtocol", ["componentmodelComponentApi", "translationmanagerApi", "clientkernelLoaderApi", "gameProtocolApi", "clientkernelEventbusApi", "pfCommunicatorApi", "clientkernelModulesApi", "moneyApi"],
    function(componentmodelComponentApi, translationmanagerApi, clientkernelLoaderApi, gameProtocolApi, clientkernelEventbusApi, pfCommunicatorApi, 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 gameProtocol == 'undefined') {
            var gameProtocol = {};
        };
        gameProtocol.ExternalService = function() {};
        gameProtocol.ExternalService.__name__ = ["gameProtocol", "ExternalService"];
        gameProtocol.ExternalService.moduleContext = null;
        gameProtocol.ExternalService.assetRegistry = null;
        gameProtocol.ExternalService.eventBus = null;
        gameProtocol.ExternalService.variableRegistry = null;
        gameProtocol.ExternalService.translationManager = null;
        gameProtocol.ExternalService.moneyFormatter = null;
        gameProtocol.ExternalService.currencyFormatterController = null;
        gameProtocol.ExternalService.gameConfigJson = null;
        gameProtocol.ExternalService.init = function(context) {
            gameProtocol.ExternalService.moduleContext = context;
            gameProtocol.ExternalService.assetRegistry = context.getAnyService(clientkernelLoaderApi.IAssetRegistry);
            gameProtocol.ExternalService.eventBus = context.getAnyService(clientkernelEventbusApi.IEventBus);
            gameProtocol.ExternalService.variableRegistry = context.getAnyService(clientkernelLoaderApi.IVariableRegistry);
            gameProtocol.ExternalService.translationManager = context.getAnyService(translationmanagerApi.ITranslationManager);
            gameProtocol.ExternalService.moneyFormatter = context.getAnyService(moneyApi.IMoneyFormatter);
            gameProtocol.ExternalService.currencyFormatterController = context.getAnyService(moneyApi.IMoneyFormatterController);
        };
        gameProtocol.ExternalService.prototype.__class__ = gameProtocol.ExternalService;
        gameProtocol.GameProtocol = function() {
            this.isCecEnabled = false;
            this.servicesRegistered = false;
            this.gameLoaded = false;
            this.pfInitialized = false;
            this.pfBus = new gameProtocol.PfBus(this);
            this.gfBus = new gameProtocol.GfBus(this);
        };
        gameProtocol.GameProtocol = ck_implements(gameProtocol.GameProtocol, clientkernelModulesApi.IService);
        gameProtocol.GameProtocol = ck_implements(gameProtocol.GameProtocol, gameProtocolApi.IGameProtocol);
        gameProtocol.GameProtocol.__interfaces__ = [clientkernelModulesApi.IService, gameProtocolApi.IGameProtocol];
        gameProtocol.GameProtocol.__name__ = ["gameProtocol", "GameProtocol"];
        gameProtocol.GameProtocol.prototype.pfBus = null;
        gameProtocol.GameProtocol.prototype.gfBus = null;
        gameProtocol.GameProtocol.prototype.stageStrategy = null;
        gameProtocol.GameProtocol.prototype.strategyFactory = null;
        gameProtocol.GameProtocol.prototype.consoleService = null;
        gameProtocol.GameProtocol.prototype.parserService = null;
        gameProtocol.GameProtocol.prototype.preferenceService = null;
        gameProtocol.GameProtocol.prototype.pfInitialized = null;
        gameProtocol.GameProtocol.prototype.gameLoaded = null;
        gameProtocol.GameProtocol.prototype.servicesRegistered = null;
        gameProtocol.GameProtocol.prototype.isCecEnabled = null;
        gameProtocol.GameProtocol.prototype.registerServices = function(factory, console, parser, preference) {
            this.strategyFactory = factory;
            this.consoleService = console;
            this.parserService = parser;
            this.preferenceService = preference;
            var cecEnabled = _hcmn_.Reflect.getProperty(gameProtocol.ExternalService.gameConfigJson, "cecEnabled");
            if (cecEnabled != null) this.isCecEnabled = cecEnabled;
            this.servicesRegistered = true;
            if (this.pfBus.isPfGameInitReceived()) this.pfBus.parseInitPayload();
        };
        gameProtocol.GameProtocol.prototype.handleGameLoaded = function() {
            console.log("[GAME_PROTOCOL] gameLoaded");
            this.gameLoaded = true;
            if (this.pfInitialized) this.registerOptionsAndInitDone();
        };
        gameProtocol.GameProtocol.prototype.deductStake = function(value) {
            this.pfBus.deductStake(value);
        };
        gameProtocol.GameProtocol.prototype.sendPlayRequest = function(payload) {
            this.pfBus.sendPlayRequest(payload);
        };
        gameProtocol.GameProtocol.prototype.sendContinueRequest = function(payload) {
            this.pfBus.sendContinueRequest(payload);
        };
        gameProtocol.GameProtocol.prototype.changeConsoleOption = function(name, params) {
            this.pfBus.changeConsoleOption(name, params);
        };
        gameProtocol.GameProtocol.prototype.requestFullScreen = function(event) {
            this.pfBus.requestFullScreen();
        };
        gameProtocol.GameProtocol.prototype.nextState = function(payload) {
            console.log("[GAME_PROTOCOL] nextState");
            this.pfBus.pfStateMachine.replyToStateChangeEvent(payload);
        };
        gameProtocol.GameProtocol.prototype.enableConsoleOptions = function() {
            this.pfBus.enableConsoleOptions();
        };
        gameProtocol.GameProtocol.prototype.disableConsoleOptions = function() {
            this.pfBus.disableConsoleOptions();
        };
        gameProtocol.GameProtocol.prototype.updatePreference = function(payload) {
            this.pfBus.updatePreference(payload);
        };
        gameProtocol.GameProtocol.prototype.sendAutoSpinStart = function() {
            this.pfBus.gamePort.getAutoSpinStart().publish(null);
        };
        gameProtocol.GameProtocol.prototype.sendAutoSpinStopped = function(reason) {
            this.pfBus.gamePort.getAutoSpinStopped().publish(null);
        };
        gameProtocol.GameProtocol.prototype.getAutoSpinOption = function() {
            var requestPayload = {
                steps: 0,
                lossLimit: 0,
                winLimit: 0
            };
            return this.pfBus.gamePort.getAutoSpinOption().request(requestPayload, 0);
        };
        gameProtocol.GameProtocol.prototype.getTestPort = function() {
            return this.gfBus.getTestPort();
        };
        gameProtocol.GameProtocol.prototype.onPfInitialized = function() {
            console.log("[GAME_PROTOCOL] onPfInitialized");
            this.pfInitialized = true;
            if (this.gameLoaded) this.registerOptionsAndInitDone();
        };
        gameProtocol.GameProtocol.prototype.isServicesRegistered = function() {
            return this.servicesRegistered;
        };
        gameProtocol.GameProtocol.prototype.initializeCurrencyFormat = function(currencyResponse) {
            console.log("[GAME_PROTOCOL] initializeCurrencyFormat");
            var format = new moneyApi.CurrencyFormat(_hcmn_.Reflect.getProperty(currencyResponse, "@currencyCode"), _hcmn_.Reflect.getProperty(currencyResponse, "MAJOR_SYMBOL"), _hcmn_.Reflect.getProperty(currencyResponse, "MINOR_SYMBOL"), _hcmn_.Reflect.getProperty(currencyResponse, "MAJOR_SYMBOL_ALIGNMENT") == "left", _hcmn_.Reflect.getProperty(currencyResponse, "MINOR_SYMBOL_ALIGNMENT") == "left", _hcmn_.Reflect.getProperty(currencyResponse, "MAJOR_SYMBOL_PADDING_SPACE") == "true", _hcmn_.Reflect.getProperty(currencyResponse, "MINOR_SYMBOL_PADDING_SPACE") == "true", _hcmn_.Reflect.getProperty(currencyResponse, "DECIMAL_SEPARATOR"), _hcmn_.Reflect.getProperty(currencyResponse, "THOUSANDS_SEPARATOR"), _hcmn_.Std.parseInt(_hcmn_.Reflect.getProperty(currencyResponse, "DECIMAL_PRECISION")), _hcmn_.Reflect.getProperty(currencyResponse, "USE_THOUSANDS_SEPARATOR") == "yes", _hcmn_.Reflect.getProperty(currencyResponse, "MINOR_CURRENCY_LOCK") == "yes", _hcmn_.Reflect.getProperty(currencyResponse, "CHIP_SET_CODE"));
            gameProtocol.ExternalService.currencyFormatterController.setCurrencyFormat(format);
        };
        gameProtocol.GameProtocol.prototype.createStrategy = function(nextStage) {
            this.stageStrategy = this.strategyFactory.create(nextStage);
        };
        gameProtocol.GameProtocol.prototype.getStrategy = function() {
            this.stageStrategy = this.strategyFactory.getStrategy();
            return this.stageStrategy;
        };
        gameProtocol.GameProtocol.prototype.registerOptionsAndInitDone = function() {
            var _g = this;
            console.log("[GAME_PROTOCOL] xxxx");
            var options = gameProtocol.ExternalService.gameConfigJson.options;
            this.consoleService.initializeStakeOptions(options).then(function(opt) {
                gameProtocol.ExternalService.gameConfigJson.options = opt;
                _g.pfBus.registerGameOptions();
                _g.consoleService.changeStakeOptions();
                _g.pfBus.publishInitDone();
            });
        };
        gameProtocol.GameProtocol.prototype.callHandleOnMakeRequest = function(event) {
            this.getStrategy().handleOnMakeRequest(event);
        };
        gameProtocol.GameProtocol.prototype.sendCecEvent = function(name, params) {
            if (this.isCecEnabled) switch (name) {
                case "Paytable":
                    this.pfBus.cecPaytableUsed(params.state);
                    break;
                case "Help":
                    this.pfBus.cecHelpUsed(params.state);
                    break;
                case "Tutorial":
                    this.pfBus.tutorialUsed(params.state);
                    break;
                case "Sound":
                    this.pfBus.cecSoundUsed(params.state);
                    break;
                case "Stake":
                    this.pfBus.cecStakeSelected(params.type, params.name, params.previousValue, params.currentValue);
                    break;
            }
        };
        gameProtocol.GameProtocol.prototype.__class__ = gameProtocol.GameProtocol;
        gameProtocol.ModuleActivator = function() {};
        gameProtocol.ModuleActivator = ck_implements(gameProtocol.ModuleActivator, clientkernelModulesApi.IModuleActivator);
        gameProtocol.ModuleActivator.__interfaces__ = [clientkernelModulesApi.IModuleActivator];
        gameProtocol.ModuleActivator.__name__ = ["gameProtocol", "ModuleActivator"];
        gameProtocol.ModuleActivator.prototype.registration = null;
        gameProtocol.ModuleActivator.prototype.gameProtocol = null;
        gameProtocol.ModuleActivator.prototype.start = function(context) {
            var _g = this;
            context.getServiceTracker([clientkernelLoaderApi.IAssetRegistry, clientkernelEventbusApi.IEventBus, clientkernelLoaderApi.IVariableRegistry, translationmanagerApi.ITranslationManager, moneyApi.IMoneyFormatter, moneyApi.IMoneyFormatterController]).then(function(context1) {
                gameProtocol.ExternalService.init(context1);
                gameProtocol.ExternalService.assetRegistry.getAsset(gameProtocol.ModuleActivator.GAME_CONFIG_ASSET_ID).getContent().then(function(data) {
                    data.links = gameProtocol.ConfigHelper.translateLinks(data.links);
                    data.options = gameProtocol.ConfigHelper.translateOptions(data.options);
                    gameProtocol.ExternalService.gameConfigJson = data;
                    _g.gameProtocol = new gameProtocol.GameProtocol();
                    _g.registration = context1.registerService(_g.gameProtocol, gameProtocolApi.IGameProtocol, null);
                });
            });
        };
        gameProtocol.ModuleActivator.prototype.stop = function(context) {
            if (this.registration != null) this.registration.unregister();
        };
        gameProtocol.ModuleActivator.main = function() {};
        gameProtocol.ModuleActivator.prototype.__class__ = gameProtocol.ModuleActivator;
        gameProtocol.ConfigHelper = function() {};
        gameProtocol.ConfigHelper.__name__ = ["gameProtocol", "ConfigHelper"];
        gameProtocol.ConfigHelper.translateLinks = function(links) {
            var translatedLinks = [];
            var language = gameProtocol.ExternalService.variableRegistry.get("language", "en");
            var _g1 = 0;
            var _g = links.length;
            while (_g1 < _g) {
                var i = _g1++;
                translatedLinks[i] = links[i];
                translatedLinks[i].url = links[i].url.replace("_en", "_" + language);
            }
            return translatedLinks;
        };
        gameProtocol.ConfigHelper.translateOptions = function(options) {
            var translatedOptions = [];
            var _g1 = 0;
            var _g = options.length;
            while (_g1 < _g) {
                var i = _g1++;
                var opt = options[i];
                if (opt.text != null) opt.text = gameProtocol.ExternalService.translationManager.stringLookup(opt.text);
                if (opt.valueText != null && opt.valueText.constructor == Array) {
                    var valueText = opt.valueText;
                    var _g3 = 0;
                    var _g2 = valueText.length;
                    while (_g3 < _g2) {
                        var j = _g3++;
                        valueText[j] = gameProtocol.ExternalService.translationManager.stringLookup(valueText[j]);
                    }
                }
                translatedOptions[i] = opt;
            }
            return translatedOptions;
        };
        gameProtocol.ConfigHelper.prototype.__class__ = gameProtocol.ConfigHelper;
        gameProtocol.GfBus = function(gProtocol) {
            this.isGamePauses = false;
            console.log("[GFBUS]");
            this.gameProtocol = gProtocol;
            this.testPort = gameProtocolApi.TestPort["use"](gameProtocol.ExternalService.eventBus.getChannel(gameProtocol.GfBus.TF_BUS));
            this.subscribe();
        };
        gameProtocol.GfBus.__name__ = ["gameProtocol", "GfBus"];
        gameProtocol.GfBus.prototype.testPort = null;
        gameProtocol.GfBus.prototype.gameProtocol = null;
        gameProtocol.GfBus.prototype.isGamePauses = null;
        gameProtocol.GfBus.prototype.subscribe = function() {
            this.testPort.getGamePauses().subscribe($bind(this, this.handleGamePauses));
            this.testPort.getGameContinue().subscribe($bind(this, this.handleGameContinue));
        };
        gameProtocol.GfBus.prototype.handleGamePauses = function(event) {
            console.log("[GFBUS] handleGamePauses: isGamePauses = " + _hcmn_.Std.string(event.getPayload()));
            this.isGamePauses = event.getPayload();
        };
        gameProtocol.GfBus.prototype.handleGameContinue = function(event) {
            console.log("[GFBUS] handleGameContinue");
            this.gameProtocol.callHandleOnMakeRequest(this.gameProtocol.pfBus.pfStateMachine.getCurrentStateChangeEvent());
        };
        gameProtocol.GfBus.prototype.sendGamePaused = function() {
            console.log("[GFBUS] sendGamePaused");
            this.testPort.getGamePaused().publish(null);
        };
        gameProtocol.GfBus.prototype.getTestPort = function() {
            return this.testPort;
        };
        gameProtocol.GfBus.prototype.__class__ = gameProtocol.GfBus;
        gameProtocol.PFStates = function() {};
        gameProtocol.PFStates.__name__ = ["gameProtocol", "PFStates"];
        gameProtocol.PFStates.prototype.__class__ = gameProtocol.PFStates;
        gameProtocol.PfBus = function(gProtocol) {
            this.rgPresentation = false;
            this.pfGameInitReceived = false;
            this.knownConsoleLinks = [];
            this.knownConsoleOptions = [];
            console.log("[PFBUS]");
            this.gameProtocol = gProtocol;
            this.pfStateMachine = new gameProtocol.PfStateMachine(gProtocol);
            this.kernelPort = pfCommunicatorApi.KernelPort["use"](gameProtocol.ExternalService.eventBus.getChannel("Kernel"));
            this.clientServicePort = pfCommunicatorApi.ClientServicePort["use"](gameProtocol.ExternalService.eventBus.getChannel("ClientService"));
            this.consoleServicePort = pfCommunicatorApi.ConsoleServicePort["use"](gameProtocol.ExternalService.eventBus.getChannel("ConsoleService"));
            this.gamePort = pfCommunicatorApi.GamePort["use"](gameProtocol.ExternalService.eventBus.getChannel("Game"));
            var options = gameProtocol.ExternalService.gameConfigJson.options;
            var _g1 = 0;
            var _g = options.length;
            while (_g1 < _g) {
                var i = _g1++;
                this.knownConsoleOptions.push(options[i].name);
            }
            var links = gameProtocol.ExternalService.gameConfigJson.links;
            var _g11 = 0;
            var _g2 = links.length;
            while (_g11 < _g2) {
                var i1 = _g11++;
                this.knownConsoleLinks.push(links[i1].id);
            }
            this.subscribe();
        };
        gameProtocol.PfBus.__name__ = ["gameProtocol", "PfBus"];
        gameProtocol.PfBus.prototype.kernelPort = null;
        gameProtocol.PfBus.prototype.clientServicePort = null;
        gameProtocol.PfBus.prototype.consoleServicePort = null;
        gameProtocol.PfBus.prototype.gamePort = null;
        gameProtocol.PfBus.prototype.gameProtocol = null;
        gameProtocol.PfBus.prototype.pfStateMachine = null;
        gameProtocol.PfBus.prototype.gameInitPayload = null;
        gameProtocol.PfBus.prototype.knownConsoleOptions = null;
        gameProtocol.PfBus.prototype.knownConsoleLinks = null;
        gameProtocol.PfBus.prototype.pfGameInitReceived = null;
        gameProtocol.PfBus.prototype.rgPresentation = null;
        gameProtocol.PfBus.prototype.subscribe = function() {
            this.kernelPort.getSystemInit().subscribe($bind(this, this.handleSystemInit));
            this.kernelPort.getSystemReady().subscribe($bind(this, this.handleSystemReady));
            this.clientServicePort.getGameInit().subscribe($bind(this, this.handleGameInit));
            this.clientServicePort.getStateChange().subscribe(($_ = this.pfStateMachine, $bind($_, $_.handleStateChangeEvent)));
            this.clientServicePort.getAccountBalances().subscribe($bind(this, this.handleAccountBalances));
            this.clientServicePort.getStopAutospin().subscribe($bind(this, this.handleStopAutospin));
            this.clientServicePort.getErrorHandlerNotify().subscribe($bind(this, this.handleError));
            this.consoleServicePort.getGameHelpPage().subscribe($bind(this, this.handleHelpPageRequested));
            this.consoleServicePort.getGamePaytablePage().subscribe($bind(this, this.handlePaytablePageRequested));
            this.consoleServicePort.getConsoleControlEvent().subscribe($bind(this, this.handleConsoleControlEvent));
        };
        gameProtocol.PfBus.prototype.handleSystemReady = function(event) {};
        gameProtocol.PfBus.prototype.handleSystemInit = function(event) {
            if (event.getPayload().gameConfig != null) {
                if (event.getPayload().gameConfig.rgPresentation != null) this.rgPresentation = event.getPayload().gameConfig.rgPresentation;
            }
        };
        gameProtocol.PfBus.prototype.handleGameInit = function(event) {
            console.log("[PFBUS] handleGameInit");
            this.gameInitPayload = event.getPayload();
            var currencyResponse = this.gameInitPayload.CurrencyResponse.CURRENCY;
            var paytableResponse = this.gameInitPayload.PaytableResponse;
            var initGameLogicResponse = this.gameInitPayload.GameLogicResponse;
            this.gameInitPayload.rgPresentation = this.rgPresentation;
            this.gameProtocol.initializeCurrencyFormat(currencyResponse);
            if (this.gameProtocol.isServicesRegistered()) {
                this.parseInitPayload();
                this.gameProtocol.onPfInitialized();
            }
        };
        gameProtocol.PfBus.prototype.parseInitPayload = function() {
            this.gameProtocol.parserService.parseInitPayload(this.gameInitPayload, gameProtocol.ExternalService.gameConfigJson);
        };
        gameProtocol.PfBus.prototype.handleError = function(event) {
            console.log("[PFBUS] handleError");
        };
        gameProtocol.PfBus.prototype.handleAccountBalances = function(event) {
            console.log("[PFBUS] handleAccountBalances balance = " + event.getPayload().balance + " promoFreeSpin = " + _hcmn_.Std.string(_hcmn_.Reflect.getProperty(event.getPayload(), "freespin")));
            var balance = _hcmn_.Reflect.getProperty(event.getPayload(), "balance");
            var promoFreeSpinCount = _hcmn_.Std.parseInt(_hcmn_.Reflect.getProperty(event.getPayload(), "freespin"));
            this.gameProtocol.consoleService.handleAccountBalances(balance, promoFreeSpinCount);
        };
        gameProtocol.PfBus.prototype.handleStopAutospin = function(e) {
            console.log("[PFBUS] handleStopAutospin");
            this.gameProtocol.consoleService.handleStopAutospin(null);
        };
        gameProtocol.PfBus.prototype.handleHelpPageRequested = function(event) {
            var links = gameProtocol.ExternalService.gameConfigJson.links;
            this.gameProtocol.consoleService.handleHelpPageRequested(links);
        };
        gameProtocol.PfBus.prototype.handlePaytablePageRequested = function(event) {
            this.gameProtocol.consoleService.handlePaytablePageRequested();
        };
        gameProtocol.PfBus.prototype.handleConsoleControlEvent = function(event) {
            console.log("[PFBUS] handleConsoleControlEvent");
            var consoleControlEvent = event.getPayload();
            if (consoleControlEvent == null) return;
            var name = consoleControlEvent.option;
            var value = consoleControlEvent.value;
            switch (name) {
                case "betPerPattern":
                    this.gameProtocol.consoleService.handleBetPerLineChanged(value);
                    break;
                case "patternsBet":
                    this.gameProtocol.consoleService.handleSelectedLinesChanged(value);
                    break;
                case "paytable":
                    this.handlePaytablePageRequested(null);
                    break;
                case "howToPlay":
                    this.handleHelpPageRequested(null);
                    break;
                default:
                    this.gameProtocol.consoleService.handleGameOptionChangedFromPf(name, value);
            }
        };
        gameProtocol.PfBus.prototype.publishInitDone = function() {
            console.log("[PFBUS] publishInitDone");
            var versionVariable = _hcmn_.Reflect.getProperty(gameProtocol.ExternalService.gameConfigJson, "versionVariable");
            var gameVersion = gameProtocol.ExternalService.variableRegistry.get(versionVariable);
            var gleVersion = this.gameInitPayload.PaytableResponse.VersionInfo.GameLogicVersion;
            var version = new pfCommunicatorApi.Version(gameVersion, gleVersion);
            var initDone = new pfCommunicatorApi.InitDone(version);
            this.gamePort.getInitDone().publish(initDone);
        };
        gameProtocol.PfBus.prototype.deductStake = function(value) {
            var payload = parseFloat(value);
            this.gamePort.getDeductStake().publish(payload);
        };
        gameProtocol.PfBus.prototype.sendPlayRequest = function(payload) {
            var actionInput = new pfCommunicatorApi.ActionInput(payload.action);
            var patternSliderInput;
            if (payload.sliderInput == null) patternSliderInput = new pfCommunicatorApi.PatternSliderInput(0, 0);
            else patternSliderInput = new pfCommunicatorApi.PatternSliderInput(payload.sliderInput.betPerPattern, payload.sliderInput.patternsBet);
            var wagerInput = new pfCommunicatorApi.WagerInput();
            if (payload.wagerInput != null) {
                if (payload.wagerInput.name != null) wagerInput.setName(payload.wagerInput.name);
                if (payload.wagerInput.wager != null) wagerInput.setWager(payload.wagerInput.wager);
                if (payload.wagerInput.custom != null) wagerInput.setCustom(payload.wagerInput.custom);
            }
            var playData = new pfCommunicatorApi.PlayData(actionInput, patternSliderInput, wagerInput);
            if (payload.selectedPickerBonusChoice != null) {
                var pickerInput = new pfCommunicatorApi.PickerInput(payload.selectedPickerBonusChoice);
                playData = new pfCommunicatorApi.PlayData(actionInput, patternSliderInput, wagerInput, pickerInput);
            }
            this.gamePort.getPlay().publish(playData);
        };
        gameProtocol.PfBus.prototype.sendContinueRequest = function(payload) {};
        gameProtocol.PfBus.prototype.registerGameOptions = function() {
            var options = gameProtocol.ExternalService.gameConfigJson.options;
            this.gamePort.getRegister().publish(new pfCommunicatorApi.Options(options));
            this.disableConsoleOptions();
        };
        gameProtocol.PfBus.prototype.changeConsoleOption = function(name, params) {
            console.log("[PFBUS] changeConsoleOption: name = " + name + " params = " + _hcmn_.Std.string(params));
            var control = new pfCommunicatorApi.GameControlEvent(name, "change", params);
            this.gamePort.getGameControlEvent().publish(control);
        };
        gameProtocol.PfBus.prototype.enableConsoleOptions = function() {
            var _g1 = 0;
            var _g = this.knownConsoleOptions.length;
            while (_g1 < _g) {
                var i = _g1++;
                var control = new pfCommunicatorApi.GameControlEvent(this.knownConsoleOptions[i], "enable", [1]);
                this.gamePort.getGameControlEvent().publish(control);
            }
        };
        gameProtocol.PfBus.prototype.disableConsoleOptions = function() {
            var _g1 = 0;
            var _g = this.knownConsoleOptions.length;
            while (_g1 < _g) {
                var i = _g1++;
                if (this.knownConsoleOptions[i] != "sound") {
                    var control = new pfCommunicatorApi.GameControlEvent(this.knownConsoleOptions[i], "enable", [0]);
                    this.gamePort.getGameControlEvent().publish(control);
                }
            }
        };
        gameProtocol.PfBus.prototype.updatePreference = function(payload) {
            this.gamePort.getGameInfo().publish(payload);
        };
        gameProtocol.PfBus.prototype.requestFullScreen = function() {};
        gameProtocol.PfBus.prototype.isPfGameInitReceived = function() {
            return this.pfGameInitReceived;
        };
        gameProtocol.PfBus.prototype.cecPaytableUsed = function(state) {
            var cecPayload = new pfCommunicatorApi.CecPayload("Paytable", [{
                'key': "timestamp",
                'value': new _hcmn_.Date().getTime()
            }, {
                'key': "value",
                'value': state
            }]);
            var payload = new pfCommunicatorApi.ClientEventCapture("CECEvent", cecPayload);
            this.clientServicePort.getClientEventCapture().publish(payload);
        };
        gameProtocol.PfBus.prototype.cecHelpUsed = function(state) {
            var cecPayload = new pfCommunicatorApi.CecPayload("Help", [{
                'key': "timestamp",
                'value': new _hcmn_.Date().getTime()
            }, {
                'key': "value",
                'value': state
            }]);
            var payload = new pfCommunicatorApi.ClientEventCapture("CECEvent", cecPayload);
            this.clientServicePort.getClientEventCapture().publish(payload);
        };
        gameProtocol.PfBus.prototype.tutorialUsed = function(state) {
            var cecPayload = new pfCommunicatorApi.CecPayload("Tutorial", [{
                'key': "timestamp",
                'value': new _hcmn_.Date().getTime()
            }, {
                'key': "value",
                'value': state
            }]);
            var payload = new pfCommunicatorApi.ClientEventCapture("CECEvent", cecPayload);
            this.clientServicePort.getClientEventCapture().publish(payload);
        };
        gameProtocol.PfBus.prototype.cecSoundUsed = function(state) {
            var cecPayload = new pfCommunicatorApi.CecPayload("Sound", [{
                'key': "timestamp",
                'value': new _hcmn_.Date().getTime()
            }, {
                'key': "value",
                'value': state
            }]);
            var payload = new pfCommunicatorApi.ClientEventCapture("CECEvent", cecPayload);
            this.clientServicePort.getClientEventCapture().publish(payload);
        };
        gameProtocol.PfBus.prototype.cecBonus = function(type, win) {
            var cecPayload = new pfCommunicatorApi.CecPayload("Bonus", [{
                'key': "timestamp",
                'value': new _hcmn_.Date().getTime()
            }, {
                'key': "bonusType",
                'value': type
            }, {
                'key': "bonusWin",
                'value': win
            }]);
            var payload = new pfCommunicatorApi.ClientEventCapture("CECEvent", cecPayload);
            this.clientServicePort.getClientEventCapture().publish(payload);
        };
        gameProtocol.PfBus.prototype.cecStakeSelected = function(type, name, previousValue, currentValue) {
            var cecPayload = new pfCommunicatorApi.CecPayload(type, [{
                'key': "timestamp",
                'value': new _hcmn_.Date().getTime()
            }, {
                'key': "previous" + name,
                'value': previousValue
            }, {
                'key': "current" + name,
                'value': currentValue
            }]);
            var payload = new pfCommunicatorApi.ClientEventCapture("CECEvent", cecPayload);
            this.clientServicePort.getClientEventCapture().publish(payload);
        };
        gameProtocol.PfBus.prototype.__class__ = gameProtocol.PfBus;
        gameProtocol.PfStateMachine = function(gameProtocol) {
            console.log("[GAME_PROTOCOL] [PfStateMachine] STARTED");
            this.gameProtocol = gameProtocol;
        };
        gameProtocol.PfStateMachine.__name__ = ["gameProtocol", "PfStateMachine"];
        gameProtocol.PfStateMachine.prototype.currentStateChangeEvent = null;
        gameProtocol.PfStateMachine.prototype.gameProtocol = null;
        gameProtocol.PfStateMachine.prototype.getCurrentStateChangeEvent = function() {
            return this.currentStateChangeEvent;
        };
        gameProtocol.PfStateMachine.prototype.handleStateChangeEvent = function(event) {
            console.log("[GAME_PROTOCOL] [PfStateMachine] handleStateChangeEvent: state = " + event.getPayload().state);
            this.currentStateChangeEvent = event;
            var stateChange = event.getPayload();
            var _g = stateChange.state;
            switch (_g) {
                case "onBeforeShowStage":
                    this.handleOnBeforeShowStage(event);
                    break;
                case "onStartGameInProgressStage":
                    this.handleOnStartGameInProgressStage(event);
                    break;
                case "onStartGameInProgressNextStage":
                    this.handleOnStartGameInProgressNextStage(event);
                    break;
                case "onStartGameInitial":
                    this.handleOnStartGameInitial(event);
                    break;
                case "onBeforeRequest":
                    this.handleOnBeforeRequest(event);
                    break;
                case "onMakeRequest":
                    this.handleOnMakeRequest(event);
                    break;
                case "onResolveStage":
                    this.handleOnResolveStage(event);
                    break;
                case "onAbortNextStage":
                    this.handleOnAbortNextStage(event);
                    break;
                case "onInProgressStage":
                    this.handleOnInProgressStage(event);
                    break;
                case "onExitStage":
                    this.handleOnExitStage(event);
                    break;
                case "onResetNextStage":
                    this.handleOnResetNextStage(event);
                    break;
                case "onEnterNextStage":
                    this.handleOnEnterNextStage(event);
                    break;
                case "onEndGame":
                    this.handleOnEndGame(event);
                    break;
                case "onBeginNewGame":
                    this.handleOnBeginNewGame(event);
                    break;
                default:
                    throw new js._Boot.HaxeError("Unhandled PF state!");
            }
        };
        gameProtocol.PfStateMachine.prototype.replyToStateChangeEvent = function(data) {
            console.log("[GAME_PROTOCOL] [PfStateMachine] replyToStateChangeEvent: state = " + this.currentStateChangeEvent.getPayload().state);
            var event = this.currentStateChangeEvent;
            this.currentStateChangeEvent = null;
            var replyPayload = new pfCommunicatorApi.StateChangeReply(event.getPayload().state, data);
            event.reply(replyPayload);
        };
        gameProtocol.PfStateMachine.prototype.handleOnBeforeShowStage = function(event) {
            var nextStage = event.getPayload().response.OutcomeDetail.NextStage;
            console.log("[GAME_PROTOCOL] [PfStateMachine] [Strategy] handleOnBeforeShowStage: response.nextStage = " + nextStage);
            this.gameProtocol.createStrategy(nextStage);
            this.gameProtocol.getStrategy().handleOnBeforeShowStage(event);
        };
        gameProtocol.PfStateMachine.prototype.handleOnStartGameInProgressStage = function(event) {
            console.log("[GAME_PROTOCOL] [PfStateMachine] [Strategy] handleOnStartGameInProgressStage");
            this.gameProtocol.getStrategy().handleOnStartGameInProgressStage(event);
        };
        gameProtocol.PfStateMachine.prototype.handleOnStartGameInProgressNextStage = function(event) {
            console.log("[GAME_PROTOCOL] [PfStateMachine] [Strategy] handleOnStartGameInProgressNextStage");
            this.gameProtocol.getStrategy().handleOnStartGameInProgressNextStage(event);
        };
        gameProtocol.PfStateMachine.prototype.handleOnStartGameInitial = function(event) {
            console.log("[GAME_PROTOCOL] [PfStateMachine] [Strategy] handleOnStartGameInitial");
            this.gameProtocol.getStrategy().handleOnStartGameInitial(event);
        };
        gameProtocol.PfStateMachine.prototype.handleOnBeforeRequest = function(event) {
            console.log("[GAME_PROTOCOL] [PfStateMachine] [Strategy] handleOnBeforeRequest");
            this.gameProtocol.getStrategy().handleOnBeforeRequest(event);
        };
        gameProtocol.PfStateMachine.prototype.handleOnMakeRequest = function(event) {
            console.log("[GAME_PROTOCOL] [PfStateMachine] [Strategy] handleOnMakeRequest");
            if (!this.gameProtocol.gfBus.isGamePauses) this.gameProtocol.callHandleOnMakeRequest(event);
            else this.gameProtocol.gfBus.sendGamePaused();
        };
        gameProtocol.PfStateMachine.prototype.handleOnResolveStage = function(event) {
            console.log("[GAME_PROTOCOL] [PfStateMachine] [Strategy] handleOnResolveStage");
            this.gameProtocol.getStrategy().handleOnResolveStage(event);
        };
        gameProtocol.PfStateMachine.prototype.handleOnExitStage = function(event) {
            console.log("[GAME_PROTOCOL] [PfStateMachine] [Strategy] handleOnExitStage");
            this.gameProtocol.getStrategy().handleOnExitStage(event);
        };
        gameProtocol.PfStateMachine.prototype.handleOnEnterNextStage = function(event) {
            console.log("[GAME_PROTOCOL] [PfStateMachine] [Strategy] handleOnEnterNextStage");
            this.gameProtocol.getStrategy().handleOnEnterNextStage(event);
            var nextStage = event.getPayload().response.OutcomeDetail.NextStage;
            console.log("[GAME_PROTOCOL] [PfStateMachine] [Strategy] handleOnEnterNextStage: nextStage = " + nextStage);
            this.gameProtocol.createStrategy(nextStage);
        };
        gameProtocol.PfStateMachine.prototype.handleOnInProgressStage = function(event) {
            console.log("[GAME_PROTOCOL] [PfStateMachine] [Strategy] handleOnInProgressStage");
            this.gameProtocol.getStrategy().handleOnInProgressStage(event);
        };
        gameProtocol.PfStateMachine.prototype.handleOnEndGame = function(event) {
            console.log("[GAME_PROTOCOL] [PfStateMachine] [Strategy] handleOnEndGame");
            this.gameProtocol.getStrategy().handleOnEndGame(event);
        };
        gameProtocol.PfStateMachine.prototype.handleOnBeginNewGame = function(event) {
            console.log("[GAME_PROTOCOL] [PfStateMachine] [Strategy] handleOnBeginNewGame");
            this.gameProtocol.getStrategy().handleOnBeginNewGame(event);
        };
        gameProtocol.PfStateMachine.prototype.handleOnAbortNextStage = function(event) {
            console.log("[GAME_PROTOCOL] [PfStateMachine] [Strategy] handleOnAbortNextStage");
            this.gameProtocol.getStrategy().handleOnAbortNextStage(event);
        };
        gameProtocol.PfStateMachine.prototype.handleOnResetNextStage = function(event) {
            console.log("[GAME_PROTOCOL] [PfStateMachine] [Strategy] handleOnResetNextStage");
            this.gameProtocol.getStrategy().handleOnResetNextStage(event);
        };
        gameProtocol.PfStateMachine.prototype.__class__ = gameProtocol.PfStateMachine;
        if (typeof haxe == 'undefined') {
            var haxe = {};
        };

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

        };
        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;
        gameProtocol.ModuleActivator.GAME_CONFIG_ASSET_ID = "game-config_json";;
        gameProtocol.GfBus.TF_BUS = "TFBus";;
        gameProtocol.PFStates.BEFORE_SHOW = "onBeforeShowStage";;
        gameProtocol.PFStates.START_GAME_IN_PROGRESS = "onStartGameInProgressStage";;
        gameProtocol.PFStates.START_GAME_IN_PROGRESS_NEXT = "onStartGameInProgressNextStage";;
        gameProtocol.PFStates.START_GAME_INITIAL = "onStartGameInitial";;
        gameProtocol.PFStates.BEFORE_REQUEST = "onBeforeRequest";;
        gameProtocol.PFStates.MAKE_REQUEST = "onMakeRequest";;
        gameProtocol.PFStates.RESOLVE = "onResolveStage";;
        gameProtocol.PFStates.ABORT_NEXT = "onAbortNextStage";;
        gameProtocol.PFStates.IN_PROGRESS = "onInProgressStage";;
        gameProtocol.PFStates.EXIT = "onExitStage";;
        gameProtocol.PFStates.RESET_NEXT = "onResetNextStage";;
        gameProtocol.PFStates.ENTER_NEXT = "onEnterNextStage";;
        gameProtocol.PFStates.END_GAME = "onEndGame";;
        gameProtocol.PFStates.BEGIN_NEW_GAME = "onBeginNewGame";;
        gameProtocol.PFStates.CLIENT_SERVICE = "ClientService";;
        gameProtocol.PFStates.CONSOLE_SERVICE = "ConsoleService";;
        gameProtocol.PFStates.GAME = "Game";;
        gameProtocol.PFStates.KERNEL = "Kernel";;
        gameProtocol.PFStates.CONSOLE_OPTION_ENABLED = 1;;
        gameProtocol.PFStates.CONSOLE_OPTION_DISABLED = 0;;
        gameProtocol.PFStates.OPTION_BET_PER_LINE = "betPerPattern";;
        gameProtocol.PFStates.OPTION_SELECTED_LINES = "patternsBet";;
        gameProtocol.PFStates.OPTION_TOTAL_STAKE = "stake";;
        gameProtocol.PFStates.OPTION_HELP = "howToPlay";;
        gameProtocol.PFStates.OPTION_PAYTABLE = "paytable";;
        return {
            exports: gameProtocol,
            activator: gameProtocol.ModuleActivator
        };
    });
//# sourceURL=gameProtocol.js