var __extends = (this && this.__extends) || function(d, b) {
    for (var p in b)
        if (b.hasOwnProperty(p)) d[p] = b[p];

    function __() {
        this.constructor = d;
    }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
define("BaseGameControlsViewController", ["require", "exports", "wcgf/core/events", "wcgf/coreComponents/PlayButtonController", "wcgf/coreComponents/LabeledTextFieldController", "wcgf/coreComponents/GenericStepperController", "wcgf/coreComponents/GenericPlaqueController", "wcgf/core/AssetManager", "wcgf/core/TextManager", "wcgf/coreComponents/AutoPlayButtonController", "wcgf/core/CurrencyFormatter", "wcgf/gameComponents/RollupIncrementer", "wcgf/sequencers/ISequenceItem", "wcgf/sounds/SoundManager", "wcgf/gameComponents/MobileBetControls", "wcgf/textFormatters/CurrencyTextFormatter", "wcgf/messageBus/ConsoleBusProxy", "wcgf/messageBus/GameMsgBus", "wcgf/gameComponents/BetManager", "wcgf/gameComponents/BaseGameBetControls", "wcgf/coreComponents/TextFieldController"], function(require, exports, events_1, PlayButtonController_1, LabeledTextFieldController_1, GenericStepperController_1, GenericPlaqueController_1, AssetManager_1, TextManager_1, AutoPlayButtonController_1, CurrencyFormatter_1, RollupIncrementer_1, ISequenceItem_1, SoundManager_1, MobileBetControls_1, CurrencyTextFormatter_1, ConsoleBusProxy_1, GameMsgBus_1, BetManager_1, BaseGameBetControls_1, TextFieldController_1) {
    "use strict";
    var ControlsState;
    (function(ControlsState) {
        ControlsState[ControlsState["Spinning"] = 0] = "Spinning";
        ControlsState[ControlsState["Idle"] = 1] = "Idle";
        ControlsState[ControlsState["Rollup"] = 2] = "Rollup";
        ControlsState[ControlsState["AutoSpinIdle"] = 3] = "AutoSpinIdle";
        ControlsState[ControlsState["BonusIdle"] = 4] = "BonusIdle";
        ControlsState[ControlsState["BonusTransition"] = 5] = "BonusTransition";
        ControlsState[ControlsState["InsufficientFunds"] = 6] = "InsufficientFunds";
        ControlsState[ControlsState["Disable"] = 7] = "Disable";
    })(ControlsState = exports.ControlsState || (exports.ControlsState = {}));
    var BaseGameControlsViewController = (function(_super) {
        __extends(BaseGameControlsViewController, _super);

        function BaseGameControlsViewController() {
            var _this = _super.call(this) || this;
            _this._rollupIndex = 0;
            _this._threshold = 1000;
            _this._isMaxStep = false;
            _this._lockControls = false;
            _this._totalBalance = 0;
            _this._autoPlayOpen = false;
            _this._state = ControlsState.Idle;
            _this._skipEnable = true;
            _this._rgPresentation = false;
            _this._isAboveBet = false;
            _this._assetManager = AssetManager_1.AssetManager.getInstance();
            _this._msgBus = GameMsgBus_1.GameMsgBus.getInstance();
            _this._consoleProxy = ConsoleBusProxy_1.ConsoleBusProxy.getInstance();
            _this._plaqueController = new GenericPlaqueController_1.GenericPlaqueController();
            _this._betControls = new BaseGameBetControls_1.BaseGameBetControllers(_this._plaqueController);
            _this._betControls.soundMap.setValue(BaseGameBetControls_1.BetControlSounds.LineBetMeterUpSound, "ControlsBetUp");
            _this._betControls.soundMap.setValue(BaseGameBetControls_1.BetControlSounds.LineBetMeterMaxSound, "ControlsBetMax");
            _this._betControls.soundMap.setValue(BaseGameBetControls_1.BetControlSounds.LineBetMeterDownSound, "ControlsBetDown");
            return _this;
        }
        BaseGameControlsViewController.prototype.init = function(data) {
            if (data === void 0) {
                data = null;
            }
            this._rgPresentation = data.gameConfig ? (data.gameConfig.rgPresentation ? data.gameConfig.rgPresentation : false) : false;
            BetManager_1.BetManager.getInstance().addEventListener(BetManager_1.BetManager.TOTAL_BET_CHANGE, this.onBetLineValueChange, this);
            BetManager_1.BetManager.getInstance().addEventListener(BetManager_1.BetManager.BALANCE_CHANGE, this.onBalanceChange, this);
            GameMsgBus_1.GameMsgBus.getInstance().addEventListener(GameMsgBus_1.GameMsgBus.START_GAME_INITIAL, this.checkInsufficientFunds, this);
            GameMsgBus_1.GameMsgBus.getInstance().addEventListener(GameMsgBus_1.GameMsgBus.BEGIN_NEW_GAME, this.checkInsufficientFunds, this);
            this.setMobileBetControls();
            this.setDenomination(data);
            this.setPlayButton();
            this.setAutoPlayButton(data);
            if (data.gameLogicResponse.promotionalFreeSpin != null) {
                this.setPromoFreeSpinMeter(data);
            } else {
                this.setBalanceMeter(data);
            }
            this._betControls.init(data);
            this.setWinMeter();
            this.setPayout(data);
            this.resetWin();
            this.setRollup();
            this.setPlaqueController(data);
            this.updateBalance(data.gameLogicResponse.balances.totalBalance);
            this.checkInsufficientFunds();
            this.setPressToChangeBetNotice(data.gameLogicResponse.outcomeDetail.nextStage);
        };
        BaseGameControlsViewController.prototype.setPressToChangeBetNotice = function(stage) {
            if (stage != "BaseGame") {
                this.hidePressToChangeBetNotice();
            } else if (AssetManager_1.AssetManager.getInstance().clientConfigData.assetPack != "desktop") {
                this._betMessageTextField = new TextFieldController_1.TextFieldController(this._assetManager.getAsset("changeBetNotice")["textField"]);
                this._betMessageTextField.setText(TextManager_1.TextManager.getInstance().getText("pressToChangeBet"));
            }
        };
        BaseGameControlsViewController.prototype.setMobileBetControls = function() {
            this._mobileBetControl = new MobileBetControls_1.MobileBetControls(this._assetManager.getSkin("MobileBetControls"));
            this._mobileBetControl.addEventListener(MobileBetControls_1.MobileBetControls.MOBILE_BET_CONTROLS_OPEN, this.onMobileBetControlsOpen, this);
            this._mobileBetControl.addEventListener(MobileBetControls_1.MobileBetControls.MOBILE_BET_CONTROLS_CLOSE, this.onMobileBetControlsClose, this);
            this._mobileBetControl.init();
        };
        BaseGameControlsViewController.prototype.onMobileBetControlsOpen = function(evt) {
            this._playButton.enable = false;
            this._autoPlayButton.enable = false;
            this.hidePressToChangeBetNotice();
            SoundManager_1.SoundManager.getInstance().execute("ControlsButtonOptionsOpen");
        };
        BaseGameControlsViewController.prototype.hidePressToChangeBetNotice = function() {
            if (AssetManager_1.AssetManager.getInstance().clientConfigData.assetPack != "desktop") {
                this._assetManager.getAsset("changeBetNotice").visible = false;
            }
        };
        BaseGameControlsViewController.prototype.onMobileBetControlsClose = function(evt) {
            this._state = ControlsState.Idle;
            this.updateState();
            SoundManager_1.SoundManager.getInstance().execute("ControlsButtonOptionsClose");
        };
        BaseGameControlsViewController.prototype.setPlayButton = function() {
            this._playButton = new PlayButtonController_1.PlayButtonController(this._assetManager.getAsset("playButton"));
            this._playButton.init();
            this._playButton.state = PlayButtonController_1.PlayButtonState.Spin;
            this._playButton.addEventListener(PlayButtonController_1.PlayButtonController.SKIP_BUTTON_CLICK, this.onSkipButtonClick, this);
            this._playButton.addEventListener(PlayButtonController_1.PlayButtonController.SPIN_BUTTON_CLICK, this.onSpinButtonClick, this);
            this._playButton.addEventListener(PlayButtonController_1.PlayButtonController.START_BUTTON_CLICK, this.onStartButtonClick, this);
        };
        BaseGameControlsViewController.prototype.setAutoPlayButton = function(data) {
            this._autoPlayButton = new AutoPlayButtonController_1.AutoPlayButtonController(this._assetManager.getAsset("autoPlay"));
            this._autoPlayButton.init(data);
            this._autoPlayButton.state = AutoPlayButtonController_1.AutoPlayButtonState.Play;
        };
        BaseGameControlsViewController.prototype.setBalanceMeter = function(data) {
            this._assetManager.getAsset("promoFSMeter").visible = false;
            this._balanceMeter = new LabeledTextFieldController_1.LabeledTextFieldController(this._assetManager.getAsset("balanceMeter"));
            this._balanceMeter.init();
            this._balanceMeter.textFormatter = new CurrencyTextFormatter_1.CurrencyTextFormatter({
                denomination: 1
            });
            this._balanceMeter.label = TextManager_1.TextManager.getInstance().getText("balance");
        };
        BaseGameControlsViewController.prototype.setPromoFreeSpinMeter = function(data) {
            this._assetManager.getAsset("balanceMeter").visible = false;
            this._promoFSMeter = new LabeledTextFieldController_1.LabeledTextFieldController(this._assetManager.getAsset("promoFSMeter"));
            this._promoFSMeter.init();
            this._promoFSMeter.label = TextManager_1.TextManager.getInstance().getText("freeSpins");
            var spinValue = data.gameLogicResponse.promotionalFreeSpin.count.toString();
            this.updatePromoFS(spinValue);
            this.setPromoFSCount(data);
        };
        BaseGameControlsViewController.prototype.setTotalBetMeterMobile = function() {
            var asset = this._assetManager.getAsset("totalBetMeter_Mobile");
            if (asset != null) {
                this._totalBetMeterMobile = new LabeledTextFieldController_1.LabeledTextFieldController(asset);
                this._totalBetMeterMobile.init();
                this._totalBetMeterMobile.label = TextManager_1.TextManager.getInstance().getText("totalBet");
            }
        };
        BaseGameControlsViewController.prototype.setWinMeter = function() {
            this._winMeter = new LabeledTextFieldController_1.LabeledTextFieldController(this._assetManager.getAsset("winMeter"));
            this._winMeter.init();
            this._winMeter.setAutoCache(false);
            this._winMeter.label = TextManager_1.TextManager.getInstance().getText("win");
        };
        BaseGameControlsViewController.prototype.setDenomination = function(data) {
            if (data != null && data.paytableResponse != null && data.paytableResponse.denominationList != null && data.paytableResponse.denominationList.length > 0) {
                this._denomination = data.paytableResponse.denominationList[0].value;
            }
        };
        BaseGameControlsViewController.prototype.setPlaqueController = function(data) {
            this._plaqueController.init(data);
        };
        BaseGameControlsViewController.prototype.setRollup = function() {
            this._rollup = new RollupIncrementer_1.RollupIncrementer();
            this._rollup.denomination = this._denomination;
            this._rollup.updateSteps(this._betControls.betManager.totalBet);
            this._rollup.textField = this._winMeter;
        };
        BaseGameControlsViewController.prototype.skipRollup = function() {
            if (this.hasPayout()) {
                this._rollup.stopSequence();
            }
        };
        BaseGameControlsViewController.prototype.setRollupSequence = function() {
            if (this.hasPayout()) {
                var totalBet = this._betControls.betManager.totalBet;
                this._isAboveBet = this._payout > totalBet;
                this._rollup.targetValue = this._payout;
                this.calculateThreshold();
                this._rollup.updateSteps(this._betControls.betManager.totalBet);
                this._rollup.addEventListener(ISequenceItem_1.sequencers.SEQUENCE_END, this.onRollupComplete, this);
                this._rollup.addEventListener(ISequenceItem_1.sequencers.SEQUENCE_START, this.onRollupStart, this);
            } else {
                this._isAboveBet = false;
            }
        };
        BaseGameControlsViewController.prototype.onRollupStart = function(evt) {
            this._rollup.removeEventListener(ISequenceItem_1.sequencers.SEQUENCE_START, this.onRollupStart, this);
            if (this._isAboveBet || !this._rgPresentation) {
                if (this._rollupIndex == BaseGameControlsViewController.BIG_WIN_ROLLUP_INDEX) {
                    SoundManager_1.SoundManager.getInstance().execute("BigWinRollupLoop");
                } else {
                    SoundManager_1.SoundManager.getInstance().execute("BaseRollupLoop" + this._rollupIndex);
                }
            }
        };
        BaseGameControlsViewController.prototype.onRollupComplete = function(evt) {
            this._rollup.removeEventListener(ISequenceItem_1.sequencers.SEQUENCE_END, this.onRollupComplete, this);
            if (this._rollupIndex == BaseGameControlsViewController.BIG_WIN_ROLLUP_INDEX) {
                SoundManager_1.SoundManager.getInstance().execute("BigWinRollupLoopTerm");
            } else if (this._isAboveBet || !this._rgPresentation) {
                SoundManager_1.SoundManager.getInstance().execute("BaseRollupLoop" + this._rollupIndex + "Term");
            } else {
                SoundManager_1.SoundManager.getInstance().execute("RollupLow");
            }
        };
        Object.defineProperty(BaseGameControlsViewController.prototype, "rollup", {
            get: function() {
                return this._rollup;
            },
            enumerable: true,
            configurable: true
        });
        BaseGameControlsViewController.prototype.calculateThreshold = function() {
            if (this.thresholdReached(100, BaseGameControlsViewController.BIG_WIN_MULTIPLIER)) {
                this._rollupIndex = 4;
            } else if (this.thresholdReached(100, BaseGameControlsViewController.MID_WIN_MULTIPLIER)) {
                this._rollupIndex = 3;
            } else if (this.thresholdReached(100, BaseGameControlsViewController.LOW_WIN_MULTIPLIER)) {
                this._rollupIndex = 2;
            } else {
                this._rollupIndex = 1;
            }
        };
        BaseGameControlsViewController.prototype.thresholdReached = function(threshold, multiplier) {
            return (this._payout >= threshold &&
                this._payout >= (this._betControls.betManager.totalBet * multiplier));
        };
        BaseGameControlsViewController.prototype.onBalanceChange = function(evt) {
            this.updateBalance(evt.data);
        };
        BaseGameControlsViewController.prototype.updateBalance = function(balance) {
            this._totalBalance = balance;
            if (this._balanceMeter != null) {
                this._balanceMeter.setText(this._totalBalance.toString());
            }
        };
        BaseGameControlsViewController.prototype.updatePromoFS = function(spinNumber) {
            this._promoFSMeter.setText(spinNumber);
        };
        BaseGameControlsViewController.prototype.setPromoFSCount = function(data) {
            this._promoFSCount = data.gameLogicResponse.promotionalFreeSpin.count;
        };
        BaseGameControlsViewController.prototype.updateTotalBet = function() {
            this.updateTotalBetFieldMobile(this.formatValue(this._betControls.betManager.totalBet, this._denomination));
        };
        BaseGameControlsViewController.prototype.updateTotalBetFieldMobile = function(totalBet) {
            if (this._totalBetMeterMobile != null) {
                this._totalBetMeterMobile.setText(totalBet);
            }
        };
        BaseGameControlsViewController.prototype.checkInsufficientFunds = function() {
            console.log((this._autoPlayButton.state == AutoPlayButtonController_1.AutoPlayButtonState.Play) + " , " + (this._autoPlayButton.state == AutoPlayButtonController_1.AutoPlayButtonState.Stop) + " , " + (this._autoPlayButton.state == AutoPlayButtonController_1.AutoPlayButtonState.ChoiceSelect));
            if (BetManager_1.BetManager.getInstance().insufficientFunds && this.autoSpinIsActive()) {
                this._autoPlayButton.state = AutoPlayButtonController_1.AutoPlayButtonState.Play;
                this.dispatchEvent(new events_1.events.Event(BaseGameControlsViewController.AUTO_PLAY_STOP_CLICK, null, this));
            }
            if (!this.autoSpinIsActive() && !this._mobileBetControl.isOpen) {
                this.updateState();
            }
        };
        BaseGameControlsViewController.prototype.updateWin = function(data) {
            this.setPayout(data);
            this.updateWinField(this.formatValue(this._payout, this._denomination));
        };
        BaseGameControlsViewController.prototype.resetWin = function() {
            this.updateWinField("");
        };
        BaseGameControlsViewController.prototype.updateWinField = function(win) {
            this._winMeter.setText(win);
        };
        BaseGameControlsViewController.prototype.onBetLineValueChange = function(evt) {
            this.dispatchEvent(new events_1.events.Event(GenericStepperController_1.GenericStepperController.VALUE_CHANGE, null, this));
            this.updateTotalBet();
            this._rollup.updateSteps(this._betControls.betManager.totalBet);
            this.checkInsufficientFunds();
        };
        BaseGameControlsViewController.prototype.setTotalBet = function(data) {};
        BaseGameControlsViewController.prototype.setPayout = function(data) {
            if (this.payoutExists(data)) {
                this._payout = data.gameLogicResponse.prizeOutcomes.getValue("Game.Total").pay;
            } else {
                this._payout = 0;
            }
        };
        BaseGameControlsViewController.prototype.hasPayout = function() {
            return (this._payout > 0);
        };
        BaseGameControlsViewController.prototype.payoutExists = function(data) {
            return (!!data.gameLogicResponse.prizeOutcomes.nElements);
        };
        BaseGameControlsViewController.prototype.handleAutoPlayEnd = function() {
            this._autoPlayButton.handleAutoPlaySpinEnd();
        };
        BaseGameControlsViewController.prototype.autoSpinIsActive = function() {
            return (this._autoPlayButton.state == AutoPlayButtonController_1.AutoPlayButtonState.Stop);
        };
        Object.defineProperty(BaseGameControlsViewController.prototype, "promoFSCount", {
            get: function() {
                return this._promoFSCount;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(BaseGameControlsViewController.prototype, "state", {
            get: function() {
                return this._state;
            },
            set: function(value) {
                if (this._state != value) {
                    this._state = value;
                    this.updateState();
                }
            },
            enumerable: true,
            configurable: true
        });
        BaseGameControlsViewController.prototype.updateState = function() {
            switch (this._state) {
                case ControlsState.Idle:
                    this._playButton.state = PlayButtonController_1.PlayButtonState.Spin;
                    this._playButton.enable = !BetManager_1.BetManager.getInstance().insufficientFunds;
                    this._playButton.sendReceiveEnable = false;
                    this._betControls.enabled = !this.autoSpinIsActive();
                    this._mobileBetControl.enable = true;
                    this._consoleProxy.enableBetControlConsole();
                    this._autoPlayButton.handleAutoPlaySpinEnd();
                    this._autoPlayButton.enable = !BetManager_1.BetManager.getInstance().insufficientFunds;
                    break;
                case ControlsState.Rollup:
                    this._playButton.enable = this._skipEnable;
                    this._playButton.state = PlayButtonController_1.PlayButtonState.Skip;
                    this._betControls.enabled = false;
                    this._mobileBetControl.enable = false;
                    this._consoleProxy.disableControlConsole();
                    this._playButton.sendReceiveEnable = false;
                    break;
                case ControlsState.Spinning:
                    this._playButton.state = PlayButtonController_1.PlayButtonState.Spin;
                    this._playButton.enable = false;
                    this._playButton.sendReceiveEnable = true;
                    this._betControls.enabled = false;
                    this._mobileBetControl.enable = false;
                    this._consoleProxy.disableControlConsole();
                    this._autoPlayButton.handleAutoPlaySpinStart();
                    break;
                case ControlsState.AutoSpinIdle:
                    this._playButton.enable = true;
                    this._playButton.state = PlayButtonController_1.PlayButtonState.Spin;
                    this._consoleProxy.disableControlConsole();
                    this._mobileBetControl.enable = false;
                    this._playButton.sendReceiveEnable = false;
                    this._autoPlayButton.handleAutoPlaySpinEnd();
                    break;
                case ControlsState.BonusIdle:
                    this._playButton.state = PlayButtonController_1.PlayButtonState.Start;
                    this._playButton.enable = true;
                    this._consoleProxy.disableControlConsole();
                    this._mobileBetControl.enable = false;
                    this._playButton.sendReceiveEnable = false;
                    this._autoPlayButton.state = AutoPlayButtonController_1.AutoPlayButtonState.Spin;
                    this._autoPlayButton.enable = false;
                    this._autoPlayButton.autoPlaySpinning = false;
                    break;
                case ControlsState.BonusTransition:
                    this._playButton.state = PlayButtonController_1.PlayButtonState.Start;
                    this._playButton.enable = false;
                    this._consoleProxy.disableControlConsole();
                    this._mobileBetControl.enable = false;
                    this._playButton.sendReceiveEnable = false;
                    break;
                case ControlsState.Disable:
                    this._playButton.state = PlayButtonController_1.PlayButtonState.Spin;
                    this._playButton.enable = false;
                    this._consoleProxy.disableControlConsole();
                    this._mobileBetControl.enable = false;
                    this._playButton.sendReceiveEnable = false;
                    this._autoPlayButton.state = AutoPlayButtonController_1.AutoPlayButtonState.Spin;
                    this._autoPlayButton.enable = false;
                    this._autoPlayButton.autoPlaySpinning = false;
                    break;
                default:
                    break;
            }
        };
        Object.defineProperty(BaseGameControlsViewController.prototype, "rollupIndex", {
            get: function() {
                return this._rollupIndex;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(BaseGameControlsViewController.prototype, "skipEnable", {
            get: function() {
                return this._skipEnable;
            },
            set: function(value) {
                if (this._skipEnable != value) {
                    this._skipEnable = value;
                    this.updateState();
                }
            },
            enumerable: true,
            configurable: true
        });
        BaseGameControlsViewController.prototype.onSkipButtonClick = function(evt) {
            this.hidePressToChangeBetNotice();
            this.dispatchEvent(new events_1.events.Event(BaseGameControlsViewController.SKIP_BUTTON_CLICK, null, this));
        };
        BaseGameControlsViewController.prototype.onStartButtonClick = function(evt) {
            this.hidePressToChangeBetNotice();
            this.dispatchEvent(new events_1.events.Event(BaseGameControlsViewController.START_BUTTON_CLICK, null, this));
        };
        BaseGameControlsViewController.prototype.onSpinButtonClick = function(evt) {
            SoundManager_1.SoundManager.getInstance().execute("ControlsSpin");
            this.hidePressToChangeBetNotice();
            this.dispatchEvent(new events_1.events.Event(BaseGameControlsViewController.SPIN_BUTTON_CLICK, null, this));
        };
        BaseGameControlsViewController.prototype.onAutoPlayButtonClick = function(evt) {
            if (!this._autoPlayOpen) {
                this._autoPlayOpen = true;
                SoundManager_1.SoundManager.getInstance().execute("ControlsAutoPlay");
            } else {
                this._autoPlayOpen = false;
                SoundManager_1.SoundManager.getInstance().execute("ControlsAutoPlayClose");
            }
            this.dispatchEvent(new events_1.events.Event(BaseGameControlsViewController.AUTO_PLAY_CLICK, null, this));
            this._betControls.enabled = false;
        };
        BaseGameControlsViewController.prototype.onAutoPlayChoicesClick = function(evt) {
            this._autoPlayOpen = false;
            this.hidePressToChangeBetNotice();
            SoundManager_1.SoundManager.getInstance().execute("ControlsAutoPlaySelect");
            this.dispatchEvent(new events_1.events.Event(BaseGameControlsViewController.AUTO_PLAY_CHOICES_CLICK, null, this));
        };
        BaseGameControlsViewController.prototype.onAutoPlayStopButtonClick = function(evt) {
            SoundManager_1.SoundManager.getInstance().execute("ControlsAutoPlayClose");
            this.dispatchEvent(new events_1.events.Event(BaseGameControlsViewController.AUTO_PLAY_STOP_CLICK, null, this));
            this.checkInsufficientFunds();
        };
        BaseGameControlsViewController.prototype.onAutoPlayChoicesCancelClick = function(event) {
            this.dispatchEvent(new events_1.events.Event(BaseGameControlsViewController.AUTO_PLAY_CHOICES_CANCEL_CLICK, null, this));
        };
        BaseGameControlsViewController.prototype.formatValue = function(value, denomination) {
            if (denomination === void 0) {
                denomination = this._denomination;
            }
            return CurrencyFormatter_1.CurrencyFormatter.getInstance().format(value, denomination);
        };
        BaseGameControlsViewController.prototype.addEventListeners = function() {
            this._playButton.addEventListener(PlayButtonController_1.PlayButtonController.SKIP_BUTTON_CLICK, this.onSkipButtonClick, this);
            this._playButton.addEventListener(PlayButtonController_1.PlayButtonController.SPIN_BUTTON_CLICK, this.onSpinButtonClick, this);
            this._playButton.addEventListener(PlayButtonController_1.PlayButtonController.START_BUTTON_CLICK, this.onStartButtonClick, this);
            this._autoPlayButton.addEventListener(AutoPlayButtonController_1.AutoPlayButtonController.AUTO_PLAY_BUTTON_CLICK, this.onAutoPlayButtonClick, this);
            this._autoPlayButton.addEventListener(AutoPlayButtonController_1.AutoPlayButtonController.AUTO_PLAY_CHOICES_BUTTON_CLICK, this.onAutoPlayChoicesClick, this);
            this._autoPlayButton.addEventListener(AutoPlayButtonController_1.AutoPlayButtonController.AUTO_PLAY_STOP_BUTTON_CLICK, this.onAutoPlayStopButtonClick, this);
            this._autoPlayButton.addEventListener(AutoPlayButtonController_1.AutoPlayButtonController.AUTO_PLAY_CHOICES_CANCEL_CLICK, this.onAutoPlayChoicesCancelClick, this);
            this._mobileBetControl.addEventListener(MobileBetControls_1.MobileBetControls.MOBILE_BET_CONTROLS_OPEN, this.onMobileBetControlsOpen, this);
            this._mobileBetControl.addEventListener(MobileBetControls_1.MobileBetControls.MOBILE_BET_CONTROLS_CLOSE, this.onMobileBetControlsClose, this);
        };
        BaseGameControlsViewController.prototype.removeEventListeners = function() {
            this._playButton.removeEventListener(PlayButtonController_1.PlayButtonController.SKIP_BUTTON_CLICK, this.onSkipButtonClick, this);
            this._playButton.removeEventListener(PlayButtonController_1.PlayButtonController.SPIN_BUTTON_CLICK, this.onSpinButtonClick, this);
            this._playButton.removeEventListener(PlayButtonController_1.PlayButtonController.START_BUTTON_CLICK, this.onStartButtonClick, this);
            this._autoPlayButton.removeEventListener(AutoPlayButtonController_1.AutoPlayButtonController.AUTO_PLAY_BUTTON_CLICK, this.onAutoPlayButtonClick, this);
            this._autoPlayButton.removeEventListener(AutoPlayButtonController_1.AutoPlayButtonController.AUTO_PLAY_CHOICES_BUTTON_CLICK, this.onAutoPlayChoicesClick, this);
            this._autoPlayButton.removeEventListener(AutoPlayButtonController_1.AutoPlayButtonController.AUTO_PLAY_STOP_BUTTON_CLICK, this.onAutoPlayStopButtonClick, this);
            this._autoPlayButton.removeEventListener(AutoPlayButtonController_1.AutoPlayButtonController.AUTO_PLAY_CHOICES_CANCEL_CLICK, this.onAutoPlayChoicesCancelClick, this);
            this._mobileBetControl.removeEventListener(MobileBetControls_1.MobileBetControls.MOBILE_BET_CONTROLS_OPEN, this.onMobileBetControlsOpen, this);
            this._mobileBetControl.removeEventListener(MobileBetControls_1.MobileBetControls.MOBILE_BET_CONTROLS_CLOSE, this.onMobileBetControlsClose, this);
        };
        BaseGameControlsViewController.prototype.addBusListeners = function() {};
        BaseGameControlsViewController.prototype.removeBusListeners = function() {};
        return BaseGameControlsViewController;
    }(events_1.events.EventDispatcher));
    BaseGameControlsViewController.SPIN_BUTTON_CLICK = "BaseGameControlsViewSpinClick";
    BaseGameControlsViewController.SKIP_BUTTON_CLICK = "BaseGameControlsViewSkipClick";
    BaseGameControlsViewController.START_BUTTON_CLICK = "BaseGameControlsViewStartClick";
    BaseGameControlsViewController.AUTO_PLAY_CLICK = "BaseGameControlsViewAutoPlayClick";
    BaseGameControlsViewController.AUTO_PLAY_CHOICES_CLICK = "BaseGameControlsViewAutoPlayChoicesClick";
    BaseGameControlsViewController.AUTO_PLAY_STOP_CLICK = "BaseGameControlsViewAutoPlayStopClick";
    BaseGameControlsViewController.AUTO_PLAY_CHOICES_CANCEL_CLICK = "BaseGameControlsViewAutoPlayCancelClick";
    BaseGameControlsViewController.BIG_WIN_MULTIPLIER = 10;
    BaseGameControlsViewController.MID_WIN_MULTIPLIER = 5;
    BaseGameControlsViewController.LOW_WIN_MULTIPLIER = 2;
    BaseGameControlsViewController.BIG_WIN_ROLLUP_INDEX = 4;
    exports.BaseGameControlsViewController = BaseGameControlsViewController;
});
define("WinCycleHelper", ["require", "exports"], function(require, exports) {
    "use strict";
    var WinCycleHelper = (function() {
        function WinCycleHelper() {}
        WinCycleHelper.prototype.setHighlightOutcomes = function(data) {
            this._highlightOutcomes = data.gameLogicResponse.highlightOutcomes;
        };
        WinCycleHelper.prototype.getHighlightOutcomes = function() {
            return this._highlightOutcomes;
        };
        WinCycleHelper.prototype.setPrizeOutcomes = function(data) {
            this._prizeOutcomes = data.gameLogicResponse.prizeOutcomes;
        };
        WinCycleHelper.prototype.getPrizeOutcomes = function() {
            return this._prizeOutcomes;
        };
        Object.defineProperty(WinCycleHelper.prototype, "prizeNames", {
            get: function() {
                return this._prizeNames;
            },
            set: function(value) {
                this._prizeNames = value;
            },
            enumerable: true,
            configurable: true
        });
        WinCycleHelper.prototype.getOutcomePrizes = function(data, prizeNames) {
            if (prizeNames === void 0) {
                prizeNames = this._prizeNames;
            }
            this.getPrizes(data, prizeNames);
            this._outcomePrizes = new Array();
            for (var prizeIndex in this._prizeOutcome) {
                for (var prizeOutcomeIndex in this._prizeOutcome[prizeIndex].prizes) {
                    this._outcomePrizes.push(this._prizeOutcome[prizeIndex].prizes[prizeOutcomeIndex]);
                }
            }
            return this._outcomePrizes;
        };
        WinCycleHelper.prototype.getPrizes = function(data, prizeNames) {
            if (prizeNames === void 0) {
                prizeNames = this._prizeNames;
            }
            this._prizeOutcome = new Array();
            this.setPrizeOutcomes(data);
            for (var _i = 0, prizeNames_1 = prizeNames; _i < prizeNames_1.length; _i++) {
                var prizeName = prizeNames_1[_i];
                this._prizeOutcome.push(this._prizeOutcomes.getValue(prizeName));
            }
            return this._prizeOutcome;
        };
        WinCycleHelper.prototype.getOutcomeHighlights = function(data, prizeNames) {
            if (prizeNames === void 0) {
                prizeNames = this._prizeNames;
            }
            this.getHighlights(data, prizeNames);
            this._outcomeHighlights = new Array();
            for (var highlightIndex in this._highlightOutcome) {
                for (var highlightOutcomeIndex in this._highlightOutcome[highlightIndex].highlights) {
                    this._outcomeHighlights.push(this._highlightOutcome[highlightIndex].highlights[highlightOutcomeIndex]);
                }
            }
            return this._outcomeHighlights;
        };
        WinCycleHelper.prototype.getHighlights = function(data, prizeNames) {
            if (prizeNames === void 0) {
                prizeNames = this._prizeNames;
            }
            this._highlightOutcome = new Array();
            this.setHighlightOutcomes(data);
            for (var _i = 0, prizeNames_2 = prizeNames; _i < prizeNames_2.length; _i++) {
                var highlightName = prizeNames_2[_i];
                this._highlightOutcome.push(this._highlightOutcomes.getValue(highlightName));
            }
            return this._highlightOutcome;
        };
        WinCycleHelper.prototype.hasPrize = function(data) {
            if (data === void 0) {
                data = null;
            }
            for (var prizeIndex in this._prizeOutcome) {
                if (this._prizeOutcome[prizeIndex].pay > 0) {
                    return true;
                }
            }
            if (data) {
                if (data.gameLogicResponse.prizeOutcomes.getValue("Game.Total").pay > 0) {
                    return true;
                }
            }
            return false;
        };
        WinCycleHelper.prototype.hasBonusTrigger = function() {
            for (var _i = 0, _a = this._highlightPrizeOutcomes; _i < _a.length; _i++) {
                var highlightPrizeOutcome = _a[_i];
                if (highlightPrizeOutcome.name == WinCycleHelper.BONUS_TRIGGER_NAME && highlightPrizeOutcome.symbolCount > WinCycleHelper.BONUS_TRIGGER_COUNT) {
                    return true;
                }
            }
            return false;
        };
        WinCycleHelper.prototype.setHighlightPrizeOutcome = function(outcomeHighlights, outcomePrizes) {
            this._highlightPrizeOutcomes = new Array();
            for (var i = 0; i < outcomeHighlights.length; i++) {
                var highlight = outcomeHighlights[i];
                for (var _i = 0, outcomePrizes_1 = outcomePrizes; _i < outcomePrizes_1.length; _i++) {
                    var cell = outcomePrizes_1[_i];
                    if (cell.name == highlight.name) {
                        var highlightPrizeOutcome = new HighlightPrizeOutcome();
                        highlightPrizeOutcome.name = cell.name;
                        highlightPrizeOutcome.cells = highlight.cells;
                        highlightPrizeOutcome.payName = cell.payName;
                        highlightPrizeOutcome.multiplier = cell.multiplier;
                        highlightPrizeOutcome.betMultiplier = cell.betMultiplier;
                        highlightPrizeOutcome.pay = cell.pay;
                        highlightPrizeOutcome.totalPay = cell.totalPay;
                        highlightPrizeOutcome.symbolCount = cell.symbolCount;
                        highlightPrizeOutcome.position = cell.position;
                        highlightPrizeOutcome.ways = cell.ways;
                        if (cell.name.slice(0, WinCycleHelper.LINE_NAME.length) == WinCycleHelper.LINE_NAME) {
                            highlightPrizeOutcome.line = parseFloat(cell.name.slice(WinCycleHelper.LINE_NAME.length + 1, cell.name.length));
                        }
                        this._highlightPrizeOutcomes.push(highlightPrizeOutcome);
                        break;
                    }
                }
            }
            return this._highlightPrizeOutcomes;
        };
        Object.defineProperty(WinCycleHelper.prototype, "highlightPrizeOutcomes", {
            get: function() {
                return this._highlightPrizeOutcomes;
            },
            enumerable: true,
            configurable: true
        });
        WinCycleHelper.prototype.sortHighlightPrizeOutcome = function(descendingOrder) {
            if (descendingOrder === void 0) {
                descendingOrder = true;
            }
            if (descendingOrder) {
                this._highlightPrizeOutcomes.sort(function(a, b) {
                    return b.pay - a.pay;
                });
            } else {
                this._highlightPrizeOutcomes.sort(function(a, b) {
                    return a.pay - b.pay;
                });
            }
        };
        WinCycleHelper.prototype.prioritizePrize = function(prizeName) {
            for (var _i = 0, _a = this._highlightPrizeOutcomes; _i < _a.length; _i++) {
                var highlight = _a[_i];
                if (highlight.name == prizeName) {
                    this._highlightPrizeOutcomes.splice(this._highlightPrizeOutcomes.indexOf(highlight), 1);
                    this._highlightPrizeOutcomes.unshift(highlight);
                }
            }
        };
        WinCycleHelper.prototype.sortLineNumber = function() {
            if (this._highlightPrizeOutcomes.length > 1) {
                var tempHighlightsArray = new Array();
                var tempSortHighlightsArray = new Array();
                for (var highlightIndex = 1; highlightIndex <= this._highlightPrizeOutcomes.length; highlightIndex++) {
                    tempSortHighlightsArray.push(this._highlightPrizeOutcomes[highlightIndex - 1]);
                    if (this._highlightPrizeOutcomes[highlightIndex] != null &&
                        this._highlightPrizeOutcomes[highlightIndex].totalPay != this._highlightPrizeOutcomes[highlightIndex - 1].totalPay) {
                        tempSortHighlightsArray.sort(function(a, b) {
                            return a.line - b.line;
                        });
                        tempHighlightsArray = tempHighlightsArray.concat(tempSortHighlightsArray);
                        tempSortHighlightsArray.length = 0;
                        tempSortHighlightsArray = new Array();
                    }
                }
                tempSortHighlightsArray.sort(function(a, b) {
                    return a.line - b.line;
                });
                this._highlightPrizeOutcomes = tempHighlightsArray.concat(tempSortHighlightsArray);
            }
        };
        return WinCycleHelper;
    }());
    WinCycleHelper.LINE_NAME = "Line";
    WinCycleHelper.BONUS_TRIGGER_NAME = "Scatter";
    WinCycleHelper.BONUS_TRIGGER_COUNT = 2;
    exports.WinCycleHelper = WinCycleHelper;
    var HighlightPrizeOutcome = (function() {
        function HighlightPrizeOutcome() {}
        return HighlightPrizeOutcome;
    }());
    exports.HighlightPrizeOutcome = HighlightPrizeOutcome;
});
define("WinCycle", ["require", "exports", "wcgf/vendors/typescript_collections/Dictionary", "wcgf/gameComponents/PaylinesController", "wcgf/gameComponents/WinBoxesController", "wcgf/gameComponents/OnSymbolWinController", "wcgf/core/events", "wcgf/sequencers/ISequenceItem", "wcgf/sequencers/LinearSequencer", "wcgf/sequencers/ParallelSequencer", "wcgf/sequencers/TimerEventSequenceItem", "wcgf/sounds/SoundManager", "wcgf/core/AssetManager"], function(require, exports, Dictionary_1, PaylinesController_1, WinBoxesController_1, OnSymbolWinController_1, events_2, ISequenceItem_2, LinearSequencer_1, ParallelSequencer_1, TimerEventSequenceItem_1, SoundManager_2, AssetManager_2) {
    "use strict";
    var WinCycle = (function(_super) {
        __extends(WinCycle, _super);

        function WinCycle(reelSet) {
            var _this = _super.call(this) || this;
            _this._lastIndex = 0;
            _this._payout = 0;
            _this._firstCycleDone = false;
            _this._firstCycleHit = false;
            _this._hasBonusWinSequence = false;
            _this._firstHighlightHit = false;
            _this._isSequenceDone = false;
            _this._isSequenceEnded = false;
            _this._isSequenceStarted = false;
            _this._symbolAudio = new Dictionary_1.default();
            _this._isAboveBet = false;
            _this._rgPresentation = false;
            _this.setStaticWild = function(cellAnims) {
                _this._reelSet.reels.forEach(function(reelName, reel) {
                    for (var _i = 0, _a = reel.currentSymbols; _i < _a.length; _i++) {
                        var symbol = _a[_i];
                        if (cellAnims.containsKey(symbol.cellName) && symbol.symbolId === "w01") {
                            console.log((symbol));
                            symbol.gotoAndStop("high", 12);
                        }
                    }
                });
            };
            _this.resetStaticWild = function(cellAnims) {
                _this._reelSet.reels.forEach(function(reelName, reel) {
                    for (var _i = 0, _a = reel.currentSymbols; _i < _a.length; _i++) {
                        var symbol = _a[_i];
                        if (cellAnims.containsKey(symbol.cellName) && symbol.symbolId === "w01") {
                            console.log((symbol));
                            symbol.setStatic();
                        }
                    }
                });
            };
            _this._payLinesController = new PaylinesController_1.PaylinesController;
            _this._winBoxController = new WinBoxesController_1.WinBoxesController;
            _this._onSymbolWinController = new OnSymbolWinController_1.OnSymbolWinController;
            _this._reelSet = reelSet;
            return _this;
        }
        WinCycle.prototype.init = function(data) {
            this._rgPresentation = data.gameConfig ? (data.gameConfig.rgPresentation ? data.gameConfig.rgPresentation : false) : false;
            this._payLinesController.init();
            this._winBoxController.init();
            this._winBoxController.animateWinBoxes = true;
            this._onSymbolWinController.init(data);
        };
        WinCycle.prototype.setHighlights = function(outcomeHighlightPrizes, isAboveBet) {
            if (isAboveBet === void 0) {
                isAboveBet = true;
            }
            this._outcomeHighlightPrizes = outcomeHighlightPrizes;
            var sequenceItems = new Array();
            this._lastIndex = this._outcomeHighlightPrizes.length - 1;
            this._firstCycleDone = false;
            this._firstCycleHit = false;
            this._firstHighlightHit = false;
            this._overlaySequence = null;
            this._isAboveBet = isAboveBet;
            for (var i = 0; i < this._outcomeHighlightPrizes.length; i++) {
                var highlight = this._outcomeHighlightPrizes[i];
                var cellAnims = new Dictionary_1.default();
                cellAnims = this.getCellAnims(highlight);
                var showWinSQ = new TimerEventSequenceItem_1.TimerEventSequenceItem(0, this.showWin, [{
                    index: i
                }], this);
                var hideWinSq = new TimerEventSequenceItem_1.TimerEventSequenceItem(0, this.hideWin, [i], this);
                var pauseSq = new TimerEventSequenceItem_1.TimerEventSequenceItem(300);
                if (this._isAboveBet || !this._rgPresentation) {
                    var showSymbolsSQ = new ParallelSequencer_1.ParallelSequencer(this.getSymbolSequences(cellAnims));
                    sequenceItems.push(showWinSQ, showSymbolsSQ, hideWinSq, pauseSq);
                } else {
                    var setStaticWildSq = new TimerEventSequenceItem_1.TimerEventSequenceItem(0, this.setStaticWild, cellAnims);
                    var resetStaticWildSq = new TimerEventSequenceItem_1.TimerEventSequenceItem(0, this.resetStaticWild, cellAnims);
                    var pause2Sq = new TimerEventSequenceItem_1.TimerEventSequenceItem(1000);
                    sequenceItems.push(showWinSQ, setStaticWildSq, pause2Sq, resetStaticWildSq, hideWinSq, pauseSq);
                }
            }
            this._winSequencer = new LinearSequencer_1.LinearSequencer(sequenceItems, 0);
        };
        WinCycle.prototype.setBonusHighlights = function(outcomeHighlightPrizes) {
            this._outcomeHighlightPrizes = outcomeHighlightPrizes;
            var sequenceItems = new Array();
            var bonusSequenceItems = new Array();
            this._lastIndex = this._outcomeHighlightPrizes.length - 1;
            this._firstCycleDone = false;
            this._firstCycleHit = false;
            this._hasBonusWinSequence = true;
            for (var i = 0; i < this._outcomeHighlightPrizes.length; i++) {
                var highlight = this._outcomeHighlightPrizes[i];
                var cellAnims = new Dictionary_1.default();
                cellAnims = this.getCellAnims(highlight);
                var showSymbolsSQ = new ParallelSequencer_1.ParallelSequencer(this.getSymbolSequences(cellAnims));
                var pauseSq = new TimerEventSequenceItem_1.TimerEventSequenceItem(300);
                sequenceItems.push(showSymbolsSQ, pauseSq);
                cellAnims = this.getCellAnims(highlight, "high_intro");
                var showSymbolIntroSQ = new ParallelSequencer_1.ParallelSequencer(this.getSymbolSequences(cellAnims));
                bonusSequenceItems.push(showSymbolIntroSQ);
            }
            var symbolIntro = new LinearSequencer_1.LinearSequencer(bonusSequenceItems, 1);
            var symbolLoop = new LinearSequencer_1.LinearSequencer(sequenceItems, 0);
            var bonusSequence = new Array();
            bonusSequence.push(symbolIntro, symbolLoop);
            this._winSequencer = new LinearSequencer_1.LinearSequencer(bonusSequence, 1);
        };
        WinCycle.prototype.getCellAnims = function(highlight, animName) {
            if (animName === void 0) {
                animName = "";
            }
            var cellAnims = new Dictionary_1.default();
            for (var _i = 0, _a = highlight.cells; _i < _a.length; _i++) {
                var cell = _a[_i];
                if (animName == "") {
                    animName = "high";
                    if (this._hasBonusWinSequence) {
                        animName = "high_loop";
                    }
                }
                cellAnims.setValue(cell.name, animName);
            }
            return cellAnims;
        };
        WinCycle.prototype.getSymbolSequences = function(cellAnims) {
            var t = this;
            var symbolSequences = new Array();
            this._reelSet.reels.forEach(function(reelName, reel) {
                for (var _i = 0, _a = reel.currentSymbols; _i < _a.length; _i++) {
                    var symbol = _a[_i];
                    if (cellAnims.containsKey(symbol.cellName)) {
                        symbolSequences.push(symbol.getSymbolSequenceItem(cellAnims.getValue(symbol.cellName), 1));
                    }
                }
            });
            return symbolSequences;
        };
        WinCycle.prototype.setPayout = function(data, stageName) {
            if (stageName == "BaseGame") {
                this._payout = data.gameLogicResponse.prizeOutcomes.getValue("Game.Total").pay;
            } else {
                this._payout = data.gameLogicResponse.prizeOutcomes.getValue("FreeSpin.Lines").pay;
            }
        };
        WinCycle.prototype.showWin = function(linesInfo) {
            var cellNames = [];
            var currentPayout;
            var prizeOutcomes = [];
            for (var _i = 0, linesInfo_1 = linesInfo; _i < linesInfo_1.length; _i++) {
                var lineInfo = linesInfo_1[_i];
                var index = lineInfo.index;
                if (index == this._lastIndex && !this._firstCycleHit) {
                    this._firstCycleDone = true;
                }
                var highlightPrize = this._outcomeHighlightPrizes[index];
                prizeOutcomes.push(highlightPrize);
                for (var _a = 0, _b = highlightPrize.cells; _a < _b.length; _a++) {
                    var cell = _b[_a];
                    cellNames.push(cell.name);
                }
                var lineName = highlightPrize.name.replace(/\s/g, '');
                if (lineName.substring(0, 4) == "Line") {
                    this._payLinesController.showLine(lineName, null, cellNames);
                }
                if (highlightPrize.name == "Scatter" && highlightPrize.symbolCount > 2) {
                    currentPayout = this._payout;
                } else {
                    currentPayout = highlightPrize.totalPay;
                }
            }
            var topPrize;
            for (var _c = 0, prizeOutcomes_1 = prizeOutcomes; _c < prizeOutcomes_1.length; _c++) {
                var cell = prizeOutcomes_1[_c];
                if (!topPrize) {
                    topPrize = cell;
                }
                if (cell.pay > topPrize.pay) {
                    topPrize = cell;
                }
                this.handleSymbolAudio(cell);
            }
            if (this._isAboveBet || !this._rgPresentation) {
                this._winBoxController.showWinBoxes(cellNames);
            } else {
                var winBoxesContainer = AssetManager_2.AssetManager.getInstance().getAsset("WinBoxesContainer");
                for (var index in cellNames) {
                    winBoxesContainer[cellNames[index]]["highlight"].gotoAndStop("static");
                    winBoxesContainer[cellNames[index]].visible = true;
                }
                console.log(winBoxesContainer);
            }
            this._onSymbolWinController.showOnSymbolWin(cellNames, currentPayout);
        };
        WinCycle.prototype.handleSymbolAudio = function(cell) {
            if (!this._firstHighlightHit && !this._overlaySequence && (this._isAboveBet || !this._rgPresentation)) {
                this._firstHighlightHit = true;
                var symbolId = cell.payName.split(" ")[1];
                SoundManager_2.SoundManager.getInstance().execute(this._symbolAudio.getValue(symbolId));
            }
        };
        WinCycle.prototype.hideWin = function(indexes) {
            for (var _i = 0, indexes_1 = indexes; _i < indexes_1.length; _i++) {
                var index = indexes_1[_i];
                var highlight = this._outcomeHighlightPrizes[index];
                var lineName = highlight.name.replace(/\s/g, '');
                if (lineName.substring(0, 4) == "Line") {
                    this._payLinesController.hideLine(lineName);
                }
            }
            this._winBoxController.hideAllWinBoxes();
            this._onSymbolWinController.hideOnSymbolWin();
            this.handleFirstCycleDone();
        };
        WinCycle.prototype.hideAllWins = function() {
            var indexes = new Array();
            for (var i = 0; i < this._outcomeHighlightPrizes.length; i++) {
                indexes.push(i);
            }
            this.hideWin(indexes);
        };
        WinCycle.prototype.handleFirstCycleDone = function() {
            if (this._firstCycleDone) {
                this._firstCycleDone = false;
                this._firstCycleHit = true;
                this.dispatchEvent(new events_2.events.Event(WinCycle.FIRST_CYCLE_DONE, null, this));
            }
        };
        Object.defineProperty(WinCycle.prototype, "firstCycleDone", {
            get: function() {
                return this.firstCycleDone;
            },
            enumerable: true,
            configurable: true
        });
        WinCycle.prototype.onSequenceDone = function(evt) {
            this._winSequencer.removeEventListener(ISequenceItem_2.sequencers.SEQUENCE_END, this.onSequenceDone, this);
            if (!this._hasBonusWinSequence) {
                this.hideAllWins();
            } else {
                this._hasBonusWinSequence = false;
            }
            this.dispatchEndEvents();
        };
        WinCycle.prototype.dispatchEndEvents = function() {
            if (!this.isSequenceDone) {
                this._isSequenceDone = true;
                this.dispatchEvent(new events_2.events.Event(ISequenceItem_2.sequencers.SEQUENCE_DONE, null, this));
            }
            this._isSequenceStarted = false;
            if (!this.isSequenceEnded) {
                this._isSequenceEnded = true;
                this.dispatchEvent(new events_2.events.Event(ISequenceItem_2.sequencers.SEQUENCE_END, null, this));
            }
        };
        WinCycle.prototype.startSequence = function(forceRestart) {
            if (forceRestart === void 0) {
                forceRestart = false;
            }
            if (forceRestart || !this._isSequenceStarted) {
                this.resetSequence();
                this._isSequenceStarted = true;
                this.dispatchEvent(new events_2.events.Event(ISequenceItem_2.sequencers.SEQUENCE_START, null, this));
                if (this._winSequencer != null) {
                    this._winSequencer.addEventListener(ISequenceItem_2.sequencers.SEQUENCE_END, this.onSequenceDone, this);
                    this._winSequencer.startSequence(forceRestart);
                } else {
                    this.dispatchEndEvents();
                }
            }
        };
        WinCycle.prototype.resetSequence = function() {
            this._isSequenceDone = false;
            this._isSequenceEnded = false;
            this._isSequenceStarted = false;
            if (this._winSequencer != null) {
                this._winSequencer.resetSequence();
            }
        };
        WinCycle.prototype.stopSequence = function(forceStop) {
            if (forceStop === void 0) {
                forceStop = false;
            }
            if (this._winSequencer != null) {
                this._winSequencer.stopSequence(forceStop);
            }
        };
        Object.defineProperty(WinCycle.prototype, "isSequenceDone", {
            get: function() {
                return this._isSequenceDone;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WinCycle.prototype, "isSequenceEnded", {
            get: function() {
                return this._isSequenceEnded;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WinCycle.prototype, "isSequenceStarted", {
            get: function() {
                return this._isSequenceStarted;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WinCycle.prototype, "symbolAudio", {
            set: function(value) {
                this._symbolAudio = value;
            },
            enumerable: true,
            configurable: true
        });
        return WinCycle;
    }(events_2.events.EventDispatcher));
    WinCycle.FIRST_CYCLE_DONE = "WinCycleFirstCycleDone";
    exports.WinCycle = WinCycle;
});
define("SoundSequenceItem", ["require", "exports", "wcgf/core/events", "wcgf/sequencers/ISequenceItem", "wcgf/sounds/SoundManager"], function(require, exports, events_3, ISequenceItem_3, SoundManager_3) {
    "use strict";
    var SoundSequenceItem = (function(_super) {
        __extends(SoundSequenceItem, _super);

        function SoundSequenceItem(soundName) {
            var _this = _super.call(this) || this;
            _this._isSequenceDone = false;
            _this._isSequenceEnded = false;
            _this._isSequenceStarted = false;
            _this._soundManager = SoundManager_3.SoundManager.getInstance();
            _this._soundName = soundName;
            return _this;
        }
        SoundSequenceItem.prototype.startSequence = function(forceRestart) {
            if (forceRestart === void 0) {
                forceRestart = false;
            }
            this.dispatchEvent(new events_3.events.Event(ISequenceItem_3.sequencers.SEQUENCE_START, null, this));
            this._isSequenceStarted = true;
            this._soundManager.execute(this._soundName);
            this.stopSequence();
        };
        SoundSequenceItem.prototype.resetSequence = function() {
            this._isSequenceEnded = false;
            this._isSequenceDone = false;
            this._isSequenceStarted = false;
        };
        SoundSequenceItem.prototype.stopSequence = function(forceStop) {
            if (forceStop === void 0) {
                forceStop = false;
            }
            this._isSequenceDone = true;
            this.dispatchEvent(new events_3.events.Event(ISequenceItem_3.sequencers.SEQUENCE_DONE, null, this));
            this._isSequenceStarted = false;
            this._isSequenceEnded = true;
            this.dispatchEvent(new events_3.events.Event(ISequenceItem_3.sequencers.SEQUENCE_END, null, this));
        };
        Object.defineProperty(SoundSequenceItem.prototype, "isSequenceDone", {
            get: function() {
                return this._isSequenceDone;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(SoundSequenceItem.prototype, "isSequenceEnded", {
            get: function() {
                return this._isSequenceEnded;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(SoundSequenceItem.prototype, "isSequenceStarted", {
            get: function() {
                return this._isSequenceStarted;
            },
            enumerable: true,
            configurable: true
        });
        return SoundSequenceItem;
    }(events_3.events.EventDispatcher));
    exports.SoundSequenceItem = SoundSequenceItem;
});
define("expandingSymbols/SymbolOverlayAnimations", ["require", "exports", "wcgf/core/datamodel", "wcgf/core/events", "wcgf/core/AssetManager", "wcgf/gameComponents/MovieClipSequenceItem", "wcgf/sequencers/ISequenceItem", "wcgf/sequencers/ParallelSequencer", "wcgf/vendors/typescript_collections/Dictionary", "SoundSequenceItem", "wcgf/sequencers/LinearSequencer"], function(require, exports, datamodel_1, events_4, AssetManager_3, MovieClipSequenceItem_1, ISequenceItem_4, ParallelSequencer_2, Dictionary_2, SoundSequenceItem_1, LinearSequencer_2) {
    "use strict";
    var SymbolOverlayAnimations = (function(_super) {
        __extends(SymbolOverlayAnimations, _super);

        function SymbolOverlayAnimations() {
            var _this = _super.call(this) || this;
            _this.numberOfColumns = 5;
            _this.numberOfRows = 3;
            _this.defaultSoundName = "BaseSymbolTwoReels";
            _this.soundNames = new Dictionary_2.default();
            _this.skinName = "GameViewSkin.symbolOverlayAnimations";
            _this._reelSkinPrefix = "reel";
            _this._populationEntryName = "Reel";
            _this.minimumSymbolsForSound = 6;
            _this._symbolOverlayMovieClips = [];
            _this._assetManager = AssetManager_3.AssetManager.getInstance();
            return _this;
        }
        SymbolOverlayAnimations.prototype.symbolOverlaySequencer = function() {
            return this._symbolOverlaySequencer;
        };
        SymbolOverlayAnimations.prototype.init = function() {
            this._skin = this._assetManager.getAsset(this.skinName);
            this._symbolOverlayMovieClips = [];
            for (var i = 0; i < this.numberOfColumns; i++) {
                this._symbolOverlayMovieClips[i] = this._skin[this._reelSkinPrefix + i];
                this._symbolOverlayMovieClips[i].gotoAndStop(SymbolOverlayAnimations.OFF_LABEL);
            }
        };
        SymbolOverlayAnimations.prototype.createSequence = function(populationOutcome, highlight) {
            this._populationOutcome = populationOutcome;
            var columnIndex;
            var overlaySoundName;
            var symbolOverlaySequenceItems = [];
            var allAwardsHighlight = this.getAllAwardsHighlight(highlight);
            var columnValues = this.buildSymbolMatchData(allAwardsHighlight);
            for (columnIndex = 0; columnIndex < this.numberOfColumns; columnIndex++) {
                var currentSymbolName = columnValues[columnIndex];
                if (currentSymbolName != SymbolOverlayAnimations.NO_MATCH) {
                    var count = 1;
                    for (var i = columnIndex + 1; i < this.numberOfColumns; i++) {
                        var symbolName = columnValues[i];
                        if (currentSymbolName == symbolName) {
                            count++;
                        } else {
                            break;
                        }
                    }
                    var numberOfSymbols = count * this.numberOfRows;
                    var prize = numberOfSymbols + " " + currentSymbolName;
                    var startLabel = this.labelNames[prize];
                    var endLabel = startLabel + SymbolOverlayAnimations.DONE_LABEL;
                    console.log("Expanding symbols animation, using label: " + startLabel);
                    var symbolOverlaySequence = new MovieClipSequenceItem_1.MovieClipSequenceItem(this._symbolOverlayMovieClips[columnIndex], startLabel, endLabel, 1);
                    symbolOverlaySequence.addEventListener(ISequenceItem_4.sequencers.SEQUENCE_END, this.onAnimationComplete, this);
                    console.log("SymbolOverlayAnimations - reel" + columnIndex + " ready to play " + startLabel);
                    symbolOverlaySequenceItems.push(symbolOverlaySequence);
                    if (numberOfSymbols >= this.minimumSymbolsForSound) {
                        var soundName = this.soundNames.getValue(currentSymbolName);
                        if (soundName) {
                            overlaySoundName = soundName;
                            console.log("[SymbolOverlayAnimations] Playing expanding sound name: " + overlaySoundName + " for " + currentSymbolName);
                        } else {
                            overlaySoundName = this.defaultSoundName;
                            console.log("[SymbolOverlayAnimations] Playing default sound name: " + overlaySoundName + " for " + currentSymbolName);
                        }
                    }
                    columnIndex += count - 1;
                }
            }
            if (symbolOverlaySequenceItems.length > 0) {
                console.log("[SymbolOverlayAnimations] Expanding symbols: " + symbolOverlaySequenceItems.length + " animations created.");
                var soundSequencer = new SoundSequenceItem_1.SoundSequenceItem(overlaySoundName);
                var parallelSymbolSequencer = new ParallelSequencer_2.ParallelSequencer(symbolOverlaySequenceItems, 1);
                this._symbolOverlaySequencer = new LinearSequencer_2.LinearSequencer([soundSequencer, parallelSymbolSequencer], 1);
                return this._symbolOverlaySequencer;
            }
            return null;
        };
        SymbolOverlayAnimations.prototype.getAllAwardsHighlight = function(highlights) {
            var allAwardsHighlight = new datamodel_1.datamodel.HighlightDef;
            for (var i = 0; i < highlights.length; i++) {
                var cells = highlights[i].cells;
                for (var j = 0; j < cells.length; j++) {
                    var cell = cells[j];
                    if (!this.highlightHasCell(allAwardsHighlight, cell.name)) {
                        allAwardsHighlight.cells.push(cell);
                    }
                }
            }
            return allAwardsHighlight;
        };
        SymbolOverlayAnimations.prototype.buildSymbolMatchData = function(highlight) {
            var cellName;
            var columnIndex;
            var rowIndex;
            var columnValues = [];
            for (columnIndex = 0; columnIndex < this.numberOfColumns; columnIndex++) {
                var winCount = 0;
                columnValues[columnIndex] = SymbolOverlayAnimations.NO_MATCH;
                for (rowIndex = 0; rowIndex < this.numberOfRows; rowIndex++) {
                    cellName = "L0C" + columnIndex + "R" + rowIndex;
                    if (this.highlightHasCell(highlight, cellName)) {
                        winCount++;
                    }
                }
                if (winCount != this.numberOfRows) {
                    continue;
                }
                var columnSymbolName = "";
                for (rowIndex = 0; rowIndex < this.numberOfRows; rowIndex++) {
                    cellName = "L0C" + columnIndex + "R" + rowIndex;
                    var cellSymbolName = this.getCellSymbolName(cellName);
                    if (columnSymbolName == "") {
                        columnSymbolName = cellSymbolName;
                    } else if (columnSymbolName != cellSymbolName) {
                        columnSymbolName = SymbolOverlayAnimations.NO_MATCH;
                        break;
                    }
                }
                columnValues[columnIndex] = columnSymbolName;
            }
            return columnValues;
        };
        SymbolOverlayAnimations.prototype.onSymbolOverlayAnimationComplete = function(evt) {
            this.dispatchEvent(new events_4.events.Event(ISequenceItem_4.sequencers.SEQUENCE_END, null, this));
        };
        SymbolOverlayAnimations.prototype.highlightHasCell = function(highlight, cellName) {
            var numCells = highlight.cells.length;
            for (var i = 0; i < numCells; i++) {
                var cell = highlight.cells[i];
                if (cell.name == cellName) {
                    return true;
                }
            }
            return false;
        };
        SymbolOverlayAnimations.prototype.getCellSymbolName = function(cellName) {
            var cell;
            var columnCharIndex = cellName.indexOf("C");
            var rowCharIndex = cellName.indexOf("R");
            var reelIndex = Number(cellName.substring(columnCharIndex + 1, rowCharIndex));
            var rowIndex = Number(cellName.substring(rowCharIndex + 1));
            if (this._populationOutcome.reels.containsKey(this._populationEntryName + reelIndex)) {
                var populationEntry = this._populationOutcome.reels.getValue(this._populationEntryName + reelIndex);
                cell = this.getCell(populationEntry, rowIndex, reelIndex);
                return cell.symbolId;
            }
            return "";
        };
        SymbolOverlayAnimations.prototype.getCell = function(populationEntry, rowIndex, reelIndex) {
            var numCells = populationEntry.cells.length;
            for (var i = 0; i < numCells; i++) {
                var cell = populationEntry.cells[i];
                var cellName = "L0C" + reelIndex + "R" + rowIndex;
                if (cell.name == cellName) {
                    return cell;
                }
            }
            return null;
        };
        SymbolOverlayAnimations.prototype.stop = function() {
            if (this._symbolOverlaySequencer) {
                if (!this._symbolOverlaySequencer.isSequenceDone) {
                    this._symbolOverlaySequencer.removeEventListener(ISequenceItem_4.sequencers.SEQUENCE_END, this.onSymbolOverlayAnimationComplete, this);
                    this._symbolOverlaySequencer.stopSequence(true);
                    for (var i = 0; i < this.numberOfColumns; i++) {
                        this._symbolOverlayMovieClips[i].gotoAndStop(SymbolOverlayAnimations.OFF_LABEL);
                    }
                    this.dispatchEvent(new events_4.events.Event(ISequenceItem_4.sequencers.SEQUENCE_END, null, this));
                }
            }
        };
        SymbolOverlayAnimations.prototype.onAnimationComplete = function(evt) {
            evt.target.removeEventListener(ISequenceItem_4.sequencers.SEQUENCE_END, this.onAnimationComplete, this);
            var movieClipSequenceItem = evt.target;
            movieClipSequenceItem.mc.gotoAndStop(SymbolOverlayAnimations.OFF_LABEL);
        };
        return SymbolOverlayAnimations;
    }(events_4.events.EventDispatcher));
    SymbolOverlayAnimations.NO_MATCH = "noMatch";
    SymbolOverlayAnimations.DONE_LABEL = "Done";
    SymbolOverlayAnimations.OFF_LABEL = "static";
    exports.SymbolOverlayAnimations = SymbolOverlayAnimations;
});
define("WinSequencer", ["require", "exports", "WinCycleHelper", "WinCycle", "wcgf/gameComponents/BigWinController", "wcgf/sequencers/ISequenceItem", "wcgf/sequencers/LinearSequencer", "wcgf/sequencers/ParallelSequencer", "wcgf/core/events"], function(require, exports, WinCycleHelper_1, WinCycle_1, BigWinController_1, ISequenceItem_5, LinearSequencer_3, ParallelSequencer_3, events_5) {
    "use strict";
    var WinSequencer = (function(_super) {
        __extends(WinSequencer, _super);

        function WinSequencer(reelSet, stageName) {
            var _this = _super.call(this) || this;
            _this._isSequenceDone = false;
            _this._isSequenceEnded = false;
            _this._isSequenceStarted = false;
            _this._rollUp = null;
            _this._isAboveBet = false;
            _this._rgPresentation = false;
            _this._stageName = stageName;
            _this._bigWinController = new BigWinController_1.BigWinController();
            _this._winCycle = new WinCycle_1.WinCycle(reelSet);
            _this._winCycleHelper = new WinCycleHelper_1.WinCycleHelper();
            return _this;
        }
        WinSequencer.prototype.init = function(data, prizeNames) {
            this._rgPresentation = data.gameConfig ? (data.gameConfig.rgPresentation ? data.gameConfig.rgPresentation : false) : false;
            this._bigWinController.init(data);
            this.winCycle.init(data);
            this._winCycleHelper.prizeNames = prizeNames;
        };
        WinSequencer.prototype.setWinCelebration = function(evt, rollup, rollupIndex) {
            var basicWinCelebrationSeq = new Array();
            var bigWinCelebrationSeq = new Array();
            var winCelebrationSeq = new Array();
            this._rollUp = rollup;
            var totalBet = evt.data.gameLogicResponse.patternSliderInput.patternsBet * evt.data.gameLogicResponse.patternSliderInput.betPerPattern;
            this._isAboveBet = this._rollUp.targetValue > totalBet;
            var bigWinCelebrationSequence;
            var basicWinCelebrationSequence;
            var winSymbolExpansion;
            this._winCycle.setHighlights(this._outcomeHighlightPrizes, this._isAboveBet);
            this._winCycle.setPayout(evt.data, this._stageName);
            if (this._stageName == "BaseGame") {
                this._bigWinController.setPayout(evt.data);
            }
            if (this._symbolOverlayAnimations && !this.isReturningToBaseGame(evt)) {
                var populationOutcome = evt.data.gameLogicResponse.populationOutcomes.getValue(this._stageName + ".Reels");
                winSymbolExpansion = this._symbolOverlayAnimations.createSequence(populationOutcome, this._outcomeHighlightPrizes);
            }
            if (this._stageName == "BaseGame" && this._bigWinController.thresholdReached()) {
                bigWinCelebrationSeq.push(this._bigWinController, this._rollUp);
                bigWinCelebrationSequence = new ParallelSequencer_3.ParallelSequencer(bigWinCelebrationSeq, 1);
                basicWinCelebrationSeq.push(this._winCycle);
            } else {
                bigWinCelebrationSequence = null;
                basicWinCelebrationSeq.push(this._rollUp, this._winCycle);
            }
            basicWinCelebrationSequence = new ParallelSequencer_3.ParallelSequencer(basicWinCelebrationSeq, 1);
            if (winSymbolExpansion != null && (this._isAboveBet || !this._rgPresentation)) {
                winCelebrationSeq.push(winSymbolExpansion);
            }
            if (bigWinCelebrationSequence != null) {
                winCelebrationSeq.push(bigWinCelebrationSequence);
            }
            if (basicWinCelebrationSeq != null) {
                winCelebrationSeq.push(basicWinCelebrationSequence);
            }
            this._winCelebrationSequence = new LinearSequencer_3.LinearSequencer(winCelebrationSeq, 1);
        };
        WinSequencer.prototype.isReturningToBaseGame = function(evt) {
            return (this._stageName == "BaseGame" &&
                evt.data.gameLogicResponse.outcomeDetail.stage == "FreeSpin" &&
                evt.data.gameLogicResponse.outcomeDetail.nextStage == "BaseGame");
        };
        WinSequencer.prototype.setBonusSequence = function() {
            var basicWinCelebrationSeq = new Array();
            basicWinCelebrationSeq.push(this._winCycle);
            this._winCycle.setBonusHighlights(this._outcomeHighlightPrizes);
            this._winCelebrationSequence = new LinearSequencer_3.LinearSequencer(basicWinCelebrationSeq, 1);
        };
        WinSequencer.prototype.skipSequence = function() {
            if (this._symbolOverlayAnimations) {
                this._symbolOverlayAnimations.stop();
            }
            if (this._bigWinController != null) {
                this._bigWinController.skipRollup();
            }
        };
        WinSequencer.prototype.clearEvents = function() {
            if (this._symbolOverlayAnimations) {
                this._symbolOverlayAnimations.stop();
            }
            if (this._winCelebrationSequence != null) {
                this._winCelebrationSequence.stopSequence(true);
                this.resetSequence();
                this._winCelebrationSequence = null;
            }
        };
        WinSequencer.prototype.setWinOutcome = function(evt) {
            this._outcomeHighlights = this._winCycleHelper.getOutcomeHighlights(evt.data);
            this._outcomePrizes = this._winCycleHelper.getOutcomePrizes(evt.data);
            this._outcomeHighlightPrizes = this._winCycleHelper.setHighlightPrizeOutcome(this._outcomeHighlights, this._outcomePrizes);
            this._winCycleHelper.sortHighlightPrizeOutcome();
            this._winCycleHelper.sortLineNumber();
            this._outcomeHighlightPrizes = this._winCycleHelper.highlightPrizeOutcomes;
        };
        WinSequencer.prototype.onSequenceDone = function(evt) {
            this._winCelebrationSequence.removeEventListener(ISequenceItem_5.sequencers.SEQUENCE_END, this.onSequenceDone, this);
            this.dispatchEndEvents();
        };
        WinSequencer.prototype.dispatchEndEvents = function() {
            if (!this.isSequenceDone) {
                this._isSequenceDone = true;
                this.dispatchEvent(new events_5.events.Event(ISequenceItem_5.sequencers.SEQUENCE_DONE, null, this));
            }
            this._isSequenceStarted = false;
            if (!this.isSequenceEnded) {
                this._isSequenceEnded = true;
                this.dispatchEvent(new events_5.events.Event(ISequenceItem_5.sequencers.SEQUENCE_END, null, this));
            }
        };
        WinSequencer.prototype.startSequence = function(forceRestart) {
            if (forceRestart === void 0) {
                forceRestart = false;
            }
            if (forceRestart || !this._isSequenceStarted) {
                this.resetSequence();
                this._isSequenceStarted = true;
                this.dispatchEvent(new events_5.events.Event(ISequenceItem_5.sequencers.SEQUENCE_START, null, this));
                if (this._winCelebrationSequence != null) {
                    this._winCelebrationSequence.addEventListener(ISequenceItem_5.sequencers.SEQUENCE_END, this.onSequenceDone, this);
                    this._winCelebrationSequence.startSequence(forceRestart);
                    if (!this._isAboveBet && this._rgPresentation) {
                        this._rollUp.stopSequence(true);
                    }
                    this._rollUp = null;
                } else {
                    this.dispatchEndEvents();
                }
            }
        };
        WinSequencer.prototype.resetSequence = function() {
            this._isSequenceEnded = false;
            this._isSequenceDone = false;
            this._isSequenceStarted = false;
            if (this._winCelebrationSequence != null) {
                this._winCelebrationSequence.resetSequence();
            }
        };
        WinSequencer.prototype.stopSequence = function(forceStop) {
            if (forceStop === void 0) {
                forceStop = false;
            }
            if (this._winCelebrationSequence != null) {
                this._winCelebrationSequence.stopSequence(forceStop);
                this._winCelebrationSequence = null;
            }
        };
        Object.defineProperty(WinSequencer.prototype, "isSequenceDone", {
            get: function() {
                return this._isSequenceDone;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WinSequencer.prototype, "isSequenceEnded", {
            get: function() {
                return this._isSequenceEnded;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WinSequencer.prototype, "winCycle", {
            get: function() {
                return this._winCycle;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WinSequencer.prototype, "winCycleHelper", {
            get: function() {
                return this._winCycleHelper;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WinSequencer.prototype, "isSequenceStarted", {
            get: function() {
                return this._isSequenceStarted;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(WinSequencer.prototype, "symbolOverlayAnimations", {
            get: function() {
                return this._symbolOverlayAnimations;
            },
            set: function(data) {
                this._symbolOverlayAnimations = data;
            },
            enumerable: true,
            configurable: true
        });
        return WinSequencer;
    }(events_5.events.EventDispatcher));
    exports.WinSequencer = WinSequencer;
});
define("SpinStrategy", ["require", "exports", "wcgf/gameComponents/reels/spinStrategies"], function(require, exports, spinStrategies_1) {
    "use strict";
    var SpinStrategy = (function() {
        function SpinStrategy() {
            this.spinSpeed = 2;
            this.symbolPadding = 2;
            this.stopOffset = {
                x: 0,
                y: -250
            };
            this.startOffset = {
                x: 0,
                y: 250
            };
        }
        SpinStrategy.prototype.startSpin = function(symbols, callBack) {
            spinStrategies_1.spinStrategies.quadIn(symbols, callBack, 200);
        };
        SpinStrategy.prototype.stopSpin = function(symbols, callBack) {
            spinStrategies_1.spinStrategies.backOut(symbols, callBack, 100);
        };
        return SpinStrategy;
    }());
    exports.SpinStrategy = SpinStrategy;
});
define("stages/picker/PickItem", ["require", "exports", "wcgf/core/AssetManager", "wcgf/core/events", "wcgf/coreComponents/BasicButtonController", "wcgf/gameComponents/MovieClipSequenceItem"], function(require, exports, AssetManager_4, events_6, BasicButtonController_1, MovieClipSequenceItem_2) {
    "use strict";
    var PickItemState;
    (function(PickItemState) {
        PickItemState[PickItemState["Picked"] = 0] = "Picked";
        PickItemState[PickItemState["Hide"] = 1] = "Hide";
        PickItemState[PickItemState["Idle"] = 2] = "Idle";
    })(PickItemState = exports.PickItemState || (exports.PickItemState = {}));
    var PickItem = (function(_super) {
        __extends(PickItem, _super);

        function PickItem(pickButtonName, skinName, pickLocation) {
            var _this = _super.call(this) || this;
            _this._assetManager = AssetManager_4.AssetManager.getInstance();
            _this.skin = _this._assetManager.getSkin(skinName);
            _this._pickButtonName = pickButtonName;
            _this._pickLocation = pickLocation;
            _this.init();
            return _this;
        }
        Object.defineProperty(PickItem.prototype, "pickLocation", {
            get: function() {
                return this._pickLocation;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PickItem.prototype, "pickButton", {
            get: function() {
                return this._pickButton;
            },
            enumerable: true,
            configurable: true
        });
        PickItem.prototype.init = function() {
            if (this._assetManager.getAsset(this._pickButtonName) != null) {
                this._pickButtonMovieClip = this._assetManager.getAsset(this._pickButtonName);
                this._pickButtonMovieClip["anim"].gotoAndStop("static");
                this._pickButton = new BasicButtonController_1.BasicButtonController(this._pickButtonMovieClip["pickButton"]);
                this._pickButton.addEventListener(BasicButtonController_1.BasicButtonController.MOUSE_CLICK, this.onPickButtonClick, this);
                this._pickButton.init();
            }
        };
        PickItem.prototype.enable = function(value) {
            this._pickButtonMovieClip.visible = value;
            if (value) {
                this._pickAnimLoopSequence = new MovieClipSequenceItem_2.MovieClipSequenceItem(this._pickButtonMovieClip, "unrevealedActiveLoop", "unrevealedActiveDone", 0);
                this._pickAnimLoopSequence.startSequence();
            } else if (this._pickAnimLoopSequence) {
                this._pickAnimLoopSequence.stopSequence();
                this._pickButtonMovieClip["anim"].gotoAndStop("static");
            }
        };
        PickItem.prototype.onPickButtonClick = function(evt) {
            this.dispatchEvent(new events_6.events.Event(PickItem.PICKER_CLICK, null, this));
        };
        PickItem.prototype.setState = function(state) {
            this._state = state;
            switch (this._state) {
                case PickItemState.Idle:
                    if (this._pickButton != null) {
                        this._pickButton.enable = true;
                    }
                    break;
                case PickItemState.Picked:
                    if (this._pickButton != null) {
                        this._pickButton.enable = false;
                        this._pickAnimLoopSequence.stopSequence();
                    }
                    break;
            }
        };
        return PickItem;
    }(events_6.events.EventDispatcher));
    PickItem.PICKER_CLICK = "PickItemClicked";
    exports.PickItem = PickItem;
});
define("stages/picker/PickerViewController", ["require", "exports", "wcgf/messageBus/GameMsgBus", "wcgf/core/AssetManager", "wcgf/core/events", "stages/picker/PickItem", "wcgf/gameComponents/MovieClipSequenceItem", "wcgf/sounds/SoundManager", "wcgf/sequencers/LinearSequencer", "wcgf/sequencers/TimerEventSequenceItem", "wcgf/sequencers/ISequenceItem", "wcgf/coreComponents/LabeledViewController", "wcgf/core/TextManager"], function(require, exports, GameMsgBus_2, AssetManager_5, events_7, PickItem_1, MovieClipSequenceItem_3, SoundManager_4, LinearSequencer_4, TimerEventSequenceItem_2, ISequenceItem_6, LabeledViewController_1, TextManager_2) {
    "use strict";
    var ControlsState;
    (function(ControlsState) {
        ControlsState[ControlsState["Picked"] = 0] = "Picked";
        ControlsState[ControlsState["Idle"] = 1] = "Idle";
    })(ControlsState = exports.ControlsState || (exports.ControlsState = {}));
    var PickerViewController = (function(_super) {
        __extends(PickerViewController, _super);

        function PickerViewController() {
            var _this = _super.call(this) || this;
            _this.stageName = "Picker";
            _this._isInit = false;
            _this._enable = false;
            _this._pickItems = Array();
            _this._pickSelected = false;
            _this._skinList = [];
            _this._msgBus = GameMsgBus_2.GameMsgBus.getInstance();
            _this._assetManager = AssetManager_5.AssetManager.getInstance();
            _this._soundManager = SoundManager_4.SoundManager.getInstance();
            _this.skin = _this._assetManager.getSkin("PickerSkin");
            if (_this.skin["picker"]["sendReceive"] != null) {
                _this._sendReceive = _this.skin["picker"]["sendReceive"];
                _this._sendReceiveLoopSequence = new MovieClipSequenceItem_3.MovieClipSequenceItem(_this._sendReceive, "onLoop", "onDone");
                _this._sendReceiveTimer = new TimerEventSequenceItem_2.TimerEventSequenceItem(3000);
                _this._sendReceiveTimer.addEventListener(ISequenceItem_6.sequencers.SEQUENCE_END, _this._sendReceiveLoopSequence.startSequence, _this._sendReceiveLoopSequence);
            }
            return _this;
        }
        PickerViewController.prototype.init = function(data) {
            this._isInit = true;
            this._totalPickItems = PickerViewController.PICK_ITEM_LOCATIONS.length;
            this._pickSelected = false;
            if (this._sendReceive != null) {
                this._sendReceive.gotoAndStop("off");
            }
            this._selectSymbolLabel = new LabeledViewController_1.LabeledViewController(this.skin["pickerSelectBar"]);
            this._selectSymbolLabel.init();
            this._selectSymbolLabel.label = TextManager_2.TextManager.getInstance().getText("selectSymbol");
            this.createPickButtons();
        };
        PickerViewController.prototype.createPickButtons = function() {
            for (var index = 0; index < this._totalPickItems; index++) {
                this._pickItems[index] = new PickItem_1.PickItem("pick" + index, "PickerSkin", PickerViewController.PICK_ITEM_LOCATIONS[index]);
                this._pickItems[index].init();
            }
        };
        PickerViewController.prototype.setPickerButtonsEnabled = function() {
            for (var index = 0; index < this._totalPickItems; index++) {
                if (this._pickItems[index]) {
                    this._pickItems[index].enable(true);
                    this._pickItems[index].setState(PickItem_1.PickItemState.Idle);
                    this._pickItems[index].addEventListener(PickItem_1.PickItem.PICKER_CLICK, this.onPickButtonClick, this);
                }
            }
        };
        PickerViewController.prototype.removePickButtonEventListeners = function() {
            for (var itemIndex = 0; itemIndex < this._totalPickItems; itemIndex++) {
                this._pickItems[itemIndex].removeEventListener(PickItem_1.PickItem.PICKER_CLICK, this.onPickButtonClick, this);
            }
        };
        PickerViewController.prototype.setPickButtonStates = function(state) {
            for (var itemIndex = 0; itemIndex < this._totalPickItems; itemIndex++) {
                this._pickItems[itemIndex].setState(state);
            }
        };
        PickerViewController.prototype.onPickButtonClick = function(evt) {
            console.log("[Picker pick button click " + this._pickSelected + "]");
            if (!this._pickSelected) {
                this.removePickButtonEventListeners();
                this._pickItemLocation = evt.target.pickLocation;
                this.setState(ControlsState.Picked);
                this._pickSelected = true;
                this.nextStage();
            }
        };
        PickerViewController.prototype.onEnterNextStage = function(evt) {
            console.log("[PickerGameView onEnterNextStage]");
        };
        PickerViewController.prototype.onBeforeRequest = function(evt) {
            console.log("[PickerGameView onBeforeRequest]");
            console.log("pick selected is " + this._pickSelected);
            if (this._pickSelected) {
                this.setState(ControlsState.Picked);
                this.nextStage();
            }
        };
        PickerViewController.prototype.onMakeRequest = function(evt) {
            var betPerPattern;
            var patternsBet;
            if (evt.data.gameLogicResponse.patternSliderInput) {
                betPerPattern = evt.data.gameLogicResponse.patternSliderInput.betPerPattern;
                patternsBet = evt.data.gameLogicResponse.patternSliderInput.patternsBet;
            } else {
                betPerPattern = evt.data.paytableResponse.patternSliderInfo.betInfo.steps[0];
                patternsBet = evt.data.paytableResponse.patternSliderInfo.patternInfo.steps[0];
            }
            console.log("[PickerGameView onMakeRequest]");
            this._msgBus.dispatchEvent(new events_7.events.Event(GameMsgBus_2.GameMsgBus.PLAY_DATA, {
                ActionInput: {
                    Action: "play"
                },
                PickerInput: {
                    Pick: {
                        '@name': this._pickItemLocation
                    }
                },
                PatternSliderInput: {
                    BetPerPattern: betPerPattern,
                    PatternsBet: patternsBet
                }
            }));
            this.nextStage();
            this._sendReceiveTimer.startSequence();
        };
        PickerViewController.prototype.onResolveStage = function(evt) {
            console.log("[PickerGameView onResolveStage]");
            this._sendReceiveTimer.stopSequence();
            this._sendReceiveLoopSequence.stopSequence();
            this._sendReceive.gotoAndStop("off");
            if (evt.data.gameLogicResponse.outcomeDetail.stage == "Picker") {
                var pickLocation = evt.data.gameLogicResponse.pickerInput;
                var pickOutcome = evt.data.gameLogicResponse.pickerOutcome.getValue(pickLocation);
                this._pickedIndex = PickerViewController.PICK_ITEM_LOCATIONS.indexOf(pickLocation);
                var pick = this._assetManager.getAsset("pick" + this._pickedIndex)["anim"];
                var revealSequence = new MovieClipSequenceItem_3.MovieClipSequenceItem(pick, pickOutcome.value, pickOutcome.value + "Done", 1);
                var sequenceItems = new Array();
                sequenceItems.push(revealSequence);
                this._revealSequencer = new LinearSequencer_4.LinearSequencer(sequenceItems, 1);
                this._revealSequencer.addEventListener(ISequenceItem_6.sequencers.SEQUENCE_END, this.pickRevealComplete, this);
                this._revealSequencer.startSequence();
                this._soundManager.execute("BonusSymbol01Select");
            }
        };
        PickerViewController.prototype.pickRevealComplete = function(evt) {
            this._revealSequencer.removeEventListener(ISequenceItem_6.sequencers.SEQUENCE_END, this.pickRevealComplete, this);
            var sequenceItems = new Array();
            var pauseSq = new TimerEventSequenceItem_2.TimerEventSequenceItem(1000);
            sequenceItems.push(pauseSq);
            this._revealSequencer = new LinearSequencer_4.LinearSequencer(sequenceItems, 1);
            this._revealSequencer.addEventListener(ISequenceItem_6.sequencers.SEQUENCE_END, this.revealUnpickedComplete, this);
            this._revealSequencer.startSequence();
        };
        PickerViewController.prototype.revealUnpickedComplete = function(evt) {
            this._revealSequencer.removeEventListener(ISequenceItem_6.sequencers.SEQUENCE_END, this.revealUnpickedComplete, this);
            this.nextStage();
        };
        PickerViewController.prototype.onBeforeShowStage = function(evt) {
            console.log("[PickerGameView onBeforeShowStage]");
        };
        PickerViewController.prototype.onStartGameInProgressStage = function(evt) {
            console.log("[PickerGameView onStartGameInProgressStage]");
            this.setState(ControlsState.Idle);
            this.nextStage();
        };
        PickerViewController.prototype.onStartGameInProgressNextStage = function(evt) {
            console.log("[PickerGameView onStartGameInProgressNextStage]");
            this.setState(ControlsState.Idle);
            if (this._pickSelected) {
                this.setState(ControlsState.Picked);
                this.nextStage();
            }
        };
        PickerViewController.prototype.onAbortNextStage = function(evt) {
            console.log("[PickerGameView onAbortStage]");
            this.nextStage();
        };
        PickerViewController.prototype.onResetNextStage = function(evt) {
            this.setPickerButtonsEnabled();
            this.setState(ControlsState.Idle);
            this._pickSelected = false;
            console.log("[PickerGameView onResetStage]");
        };
        PickerViewController.prototype.onExitStage = function(evt) {
            console.log("[PickerGameView onExitStage]");
            this.nextStage();
        };
        PickerViewController.prototype.setState = function(state) {
            switch (state) {
                case ControlsState.Idle:
                    this.setPickButtonStates(PickItem_1.PickItemState.Idle);
                    break;
                case ControlsState.Picked:
                    this.setPickButtonStates(PickItem_1.PickItemState.Picked);
                    break;
            }
        };
        PickerViewController.prototype.addToStage = function(container) {
            container.addChild(this.skin);
            for (var _i = 0, _a = this._skinList; _i < _a.length; _i++) {
                var skinName = _a[_i];
                container.addChild(this._assetManager.getSkin(skinName));
            }
            this.enable = true;
        };
        PickerViewController.prototype.removeFromStage = function(container) {
            console.log(this.skin);
            container.removeChild(this.skin);
            for (var _i = 0, _a = this._skinList; _i < _a.length; _i++) {
                var skinName = _a[_i];
                container.removeChild(this._assetManager.getSkin(skinName));
            }
            this.enable = false;
        };
        Object.defineProperty(PickerViewController.prototype, "enable", {
            get: function() {
                return this._enable;
            },
            set: function(value) {
                this.skin.visible = value;
                console.log("Picker view enabled was " + this._enable + ", now is " + value);
                if (this._enable != value) {
                    this._enable = value;
                    if (value) {
                        this.addBusListeners();
                        this.setPickerButtonsEnabled();
                        this._soundManager.execute("PreBonusMusicLoop");
                    } else {
                        this.removeBusListeners();
                    }
                }
            },
            enumerable: true,
            configurable: true
        });
        PickerViewController.prototype.addBusListeners = function() {
            this._msgBus.addEventListener(GameMsgBus_2.GameMsgBus.BEFORE_REQUEST, this.onBeforeRequest, this);
            this._msgBus.addEventListener(GameMsgBus_2.GameMsgBus.MAKE_REQUEST, this.onMakeRequest, this);
            this._msgBus.addEventListener(GameMsgBus_2.GameMsgBus.RESOLVE_STAGE, this.onResolveStage, this);
            this._msgBus.addEventListener(GameMsgBus_2.GameMsgBus.BEFORE_SHOW_STAGE, this.onBeforeShowStage, this);
            this._msgBus.addEventListener(GameMsgBus_2.GameMsgBus.ENTER_NEXT_STAGE, this.onEnterNextStage, this);
            this._msgBus.addEventListener(GameMsgBus_2.GameMsgBus.START_GAME_IN_PROGRESS_STAGE, this.onStartGameInProgressStage, this);
            this._msgBus.addEventListener(GameMsgBus_2.GameMsgBus.START_GAME_IN_PROGRESS_NEXT_STAGE, this.onStartGameInProgressNextStage, this);
            this._msgBus.addEventListener(GameMsgBus_2.GameMsgBus.EXIT_STAGE, this.onExitStage, this);
            this._msgBus.addEventListener(GameMsgBus_2.GameMsgBus.ABORT_NEXT_STAGE, this.onAbortNextStage, this);
            this._msgBus.addEventListener(GameMsgBus_2.GameMsgBus.RESET_NEXT_STAGE, this.onResetNextStage, this);
        };
        PickerViewController.prototype.removeBusListeners = function() {
            this._msgBus.removeEventListener(GameMsgBus_2.GameMsgBus.BEFORE_REQUEST, this.onBeforeRequest, this);
            this._msgBus.removeEventListener(GameMsgBus_2.GameMsgBus.MAKE_REQUEST, this.onMakeRequest, this);
            this._msgBus.removeEventListener(GameMsgBus_2.GameMsgBus.RESOLVE_STAGE, this.onResolveStage, this);
            this._msgBus.removeEventListener(GameMsgBus_2.GameMsgBus.BEFORE_SHOW_STAGE, this.onBeforeShowStage, this);
            this._msgBus.removeEventListener(GameMsgBus_2.GameMsgBus.ENTER_NEXT_STAGE, this.onEnterNextStage, this);
            this._msgBus.removeEventListener(GameMsgBus_2.GameMsgBus.START_GAME_IN_PROGRESS_STAGE, this.onStartGameInProgressStage, this);
            this._msgBus.removeEventListener(GameMsgBus_2.GameMsgBus.START_GAME_IN_PROGRESS_NEXT_STAGE, this.onStartGameInProgressNextStage, this);
            this._msgBus.removeEventListener(GameMsgBus_2.GameMsgBus.EXIT_STAGE, this.onExitStage, this);
            this._msgBus.removeEventListener(GameMsgBus_2.GameMsgBus.ABORT_NEXT_STAGE, this.onAbortNextStage, this);
            this._msgBus.removeEventListener(GameMsgBus_2.GameMsgBus.RESET_NEXT_STAGE, this.onResetNextStage, this);
        };
        PickerViewController.prototype.nextStage = function() {
            this._msgBus.dispatchEvent(new events_7.events.Event(GameMsgBus_2.GameMsgBus.NEXT_STAGE));
        };
        PickerViewController.prototype.removeEventListeners = function() {
            if (this._isInit) {
                for (var itemIndex = 0; itemIndex < this._totalPickItems; itemIndex++) {
                    this._pickItems[itemIndex].removeEventListener(PickItem_1.PickItem.PICKER_CLICK, this.onPickButtonClick, this);
                }
            }
        };
        return PickerViewController;
    }(events_7.events.EventDispatcher));
    PickerViewController.PICK_ITEM_LOCATIONS = ["L0C0R0", "L0C0R1", "L0C0R2",
        "L0C1R0", "L0C1R1", "L0C1R2",
        "L0C2R0", "L0C2R1", "L0C2R2"
    ];
    PickerViewController.SPIN_NAME = "spins";
    PickerViewController.MULTIPLIER_NAME = "multiplier";
    PickerViewController.TRIGGER_NAME = "trigger";
    exports.PickerViewController = PickerViewController;
});
define("selectiveStacking/SelectiveStackingSymbolChanger", ["require", "exports", "wcgf/vendors/typescript_collections/Dictionary"], function(require, exports, Dictionary_3) {
    "use strict";
    var SelectiveStackingSymbolChanger = (function() {
        function SelectiveStackingSymbolChanger() {
            this.mapOutcomeName = "SchemaSet";
            this.defaultSwappingInfo = "12345";
            this.selectiveStackingInfoName = "SelectiveStackingInfo";
            this.keyValuePairInfoName = "SchemaDigitReplacement";
            this.modifiedSymbolNames = new Dictionary_3.default();
        }
        SelectiveStackingSymbolChanger.prototype.getSubstituteSymbolNames = function(data, forceStage) {
            if (forceStage === void 0) {
                forceStage = null;
            }
            var REEL_PREFIX = "r0";
            var value;
            if (data.gameLogicResponse.patternSliderInput && data.gameLogicResponse.keyValuePairInfo) {
                var betPerPattern = data.gameLogicResponse.patternSliderInput.betPerPattern;
                var stageName = void 0;
                if (forceStage) {
                    stageName = forceStage;
                } else {
                    stageName = data.gameLogicResponse.outcomeDetail.nextStage;
                }
                var keyValueSchema = data.gameLogicResponse.keyValuePairInfo.getValue(stageName + "." + this.mapOutcomeName);
                var mappings = keyValueSchema.mapping;
                if (mappings && mappings.getValue(betPerPattern.toString()) == null) {
                    console.log("[SelectiveStackingSymbolChanger] ERROR: no mapping data. Using default value.");
                    value = this.defaultSwappingInfo;
                } else {
                    value = mappings.getValue(betPerPattern.toString()).value;
                }
            } else {
                value = this.defaultSwappingInfo;
                console.log("[SelectiveStackingSymbolChanger] ERROR: no mapping data. Using default values.");
            }
            var characterCount = value.length;
            var substituteSymbolNames = new Dictionary_3.default();
            for (var i = 0; i < characterCount; i++) {
                var key = value.substr(i, 1);
                var substituteName = this.modifiedSymbolNames.getValue(key);
                substituteSymbolNames.setValue(REEL_PREFIX + (i + 1), substituteName);
                console.log("change " + REEL_PREFIX + i + " from " + key + " to " + substituteName);
            }
            return substituteSymbolNames;
        };
        SelectiveStackingSymbolChanger.prototype.setSubstituteSymbolNames = function(reelSet, data, forceStage) {
            if (forceStage === void 0) {
                forceStage = null;
            }
            reelSet.dynamicSymbols = this.getSubstituteSymbolNames(data, forceStage);
        };
        return SelectiveStackingSymbolChanger;
    }());
    exports.SelectiveStackingSymbolChanger = SelectiveStackingSymbolChanger;
});
define("ReelsHelper", ["require", "exports", "wcgf/sounds/SoundManager"], function(require, exports, SoundManager_5) {
    "use strict";
    var ReelsHelper = (function() {
        function ReelsHelper() {}
        ReelsHelper.prototype.setNewData = function(data) {
            this._curData = data;
            this._bonusSmartSoundsPlayed = 0;
        };
        ReelsHelper.prototype.getSpinDurationsForAllReels = function(spinDurations) {
            spinDurations = this.addAnticipationToSpinDurations(spinDurations);
            return spinDurations;
        };
        ReelsHelper.prototype.addAnticipationToSpinDurations = function(spinDuration) {
            for (var i = 0; i < ReelsHelper.NUM_COLS; i++) {
                if (this.getPossibleBonusForReel(i)) {
                    for (var j = i; j < ReelsHelper.NUM_COLS; j++) {
                        spinDuration[j] += ReelsHelper.ANTICIPATION_DURATION;
                    }
                }
            }
            return spinDuration;
        };
        ReelsHelper.prototype.getPossibleBonusForReel = function(reelIndex) {
            var bonusSymbolCountOnPreviousReels;
            var mjpSymbolCountOnPreviousReels;
            var populationOutcome = this._curData.gameLogicResponse.populationOutcomes.getValue(this._curData.gameLogicResponse.outcomeDetail.stage + ".Reels");
            if (reelIndex == 0 || reelIndex >= ReelsHelper.NUM_COLS) {
                return true;
            } else {
                var bonusPossible = false;
                bonusSymbolCountOnPreviousReels = this.getSymbolCountOnAllPreviousReels(populationOutcome, reelIndex - 1, "b01");
                mjpSymbolCountOnPreviousReels = this.getSymbolCountOnAllPreviousReels(populationOutcome, reelIndex - 1, "w02");
                if ((reelIndex == 2 && bonusSymbolCountOnPreviousReels == ReelsHelper.NUM_ROWS) ||
                    (reelIndex == 3 && bonusSymbolCountOnPreviousReels == ReelsHelper.NUM_ROWS * 2)) {
                    bonusPossible = true;
                } else if ((reelIndex == 1 && mjpSymbolCountOnPreviousReels == ReelsHelper.NUM_ROWS) ||
                    (reelIndex == 2 && mjpSymbolCountOnPreviousReels == ReelsHelper.NUM_ROWS * 2) ||
                    (reelIndex == 3 && mjpSymbolCountOnPreviousReels == ReelsHelper.NUM_ROWS * 3) ||
                    (reelIndex == 4 && mjpSymbolCountOnPreviousReels == ReelsHelper.NUM_ROWS * 4) ||
                    (reelIndex == 5 && mjpSymbolCountOnPreviousReels == ReelsHelper.NUM_ROWS * 5)) {
                    bonusPossible = true;
                }
                return bonusPossible;
            }
        };
        ReelsHelper.prototype.getSymbolCountOnAllPreviousReels = function(populationOutcome, reelIndex, symbol) {
            if (reelIndex == 0) {
                return (this.getSymbolCountOnReel(populationOutcome, reelIndex, symbol));
            } else {
                var symbolCountOnReel = this.getSymbolCountOnReel(populationOutcome, reelIndex, symbol);
                return (symbolCountOnReel + this.getSymbolCountOnAllPreviousReels(populationOutcome, reelIndex - 1, symbol));
            }
        };
        ReelsHelper.prototype.getSymbolCountOnReel = function(populationOutcome, reelIndex, symbol) {
            var count = 0;
            var populationEntry = populationOutcome.reels.getValue("Reel" + reelIndex);
            for (var _i = 0, _a = populationEntry.cells; _i < _a.length; _i++) {
                var cell = _a[_i];
                if (cell.symbolId == symbol) {
                    count++;
                }
            }
            return count;
        };
        ReelsHelper.prototype.playReelStopSound = function() {
            var populationOutcome = this._curData.gameLogicResponse.populationOutcomes.getValue(this._curData.gameLogicResponse.outcomeDetail.stage + ".Reels");
            if (this.getSymbolCountOnReel(populationOutcome, this.currentReelIndex, "b01") &&
                this.getPossibleBonusForReel(this.currentReelIndex)) {
                this._bonusSmartSoundsPlayed++;
                SoundManager_5.SoundManager.getInstance().execute("SmartSound" + this._bonusSmartSoundsPlayed);
            } else {
                SoundManager_5.SoundManager.getInstance().execute("ReelStop");
            }
        };
        Object.defineProperty(ReelsHelper.prototype, "currentReelIndex", {
            get: function() {
                return this._currentReelIndex;
            },
            set: function(value) {
                this._currentReelIndex = value;
            },
            enumerable: true,
            configurable: true
        });
        return ReelsHelper;
    }());
    ReelsHelper.NUM_ROWS = 3;
    ReelsHelper.NUM_COLS = 5;
    ReelsHelper.ANTICIPATION_DURATION = 1600;
    exports.ReelsHelper = ReelsHelper;
});
define("MiniSpinStrategy", ["require", "exports", "wcgf/gameComponents/reels/spinStrategies"], function(require, exports, spinStrategies_2) {
    "use strict";
    var MiniSpinStrategy = (function() {
        function MiniSpinStrategy() {
            this.spinSpeed = 1;
            this.symbolPadding = 2;
            this.stopOffset = {
                x: 0,
                y: -50
            };
            this.startOffset = {
                x: 0,
                y: 0
            };
        }
        MiniSpinStrategy.prototype.startSpin = function(symbols, callBack) {
            spinStrategies_2.spinStrategies.quadIn(symbols, callBack, 200);
        };
        MiniSpinStrategy.prototype.stopSpin = function(symbols, callBack) {
            spinStrategies_2.spinStrategies.backOut(symbols, callBack, 100);
        };
        return MiniSpinStrategy;
    }());
    exports.MiniSpinStrategy = MiniSpinStrategy;
});
define("BaseGameViewController", ["require", "exports", "wcgf/messageBus/GameMsgBus", "wcgf/core/AssetManager", "wcgf/gameComponents/reels/slotsReelSet/SlotsReelSet", "BaseGameControlsViewController", "wcgf/core/events", "WinSequencer", "wcgf/coreComponents/GenericMessageController", "wcgf/coreComponents/GenericStepperController", "wcgf/sounds/SoundManager", "SpinStrategy", "wcgf/coreComponents/GenericPlaqueController", "wcgf/gameComponents/RollupIncrementer", "wcgf/sequencers/ISequenceItem", "wcgf/sequencers/TimerEventSequenceItem", "wcgf/vendors/typescript_collections/Dictionary", "wcgf/messageBus/ConsoleBusProxy", "stages/picker/PickerViewController", "wcgf/gameComponents/MovieClipSequenceItem", "expandingSymbols/SymbolOverlayAnimations", "selectiveStacking/SelectiveStackingSymbolChanger", "WinCycle", "wcgf/coreComponents/TextFieldController", "wcgf/gameComponents/BetManager", "ReelsHelper", "MiniSpinStrategy", "wcgf/core/TextManager"], function(require, exports, GameMsgBus_3, AssetManager_6, SlotsReelSet_1, BaseGameControlsViewController_1, events_8, WinSequencer_1, GenericMessageController_1, GenericStepperController_2, SoundManager_6, SpinStrategy_1, GenericPlaqueController_2, RollupIncrementer_2, ISequenceItem_7, TimerEventSequenceItem_3, Dictionary_4, ConsoleBusProxy_2, PickerViewController_1, MovieClipSequenceItem_4, SymbolOverlayAnimations_1, SelectiveStackingSymbolChanger_1, WinCycle_2, TextFieldController_2, BetManager_2, ReelsHelper_1, MiniSpinStrategy_1, TextManager_3) {
    "use strict";
    var BaseGameViewController = (function(_super) {
        __extends(BaseGameViewController, _super);

        function BaseGameViewController() {
            var _this = _super.call(this) || this;
            _this.stageName = "BaseGame";
            _this._symbolNames = ["s01", "s02", "s03", "s04", "s05", "s06", "s07", "s08", "s09", "b01", "w01"];
            _this._prizeNames = ["BaseGame.Lines", "BaseGame.Scatter"];
            _this._isInit = false;
            _this._enable = false;
            _this._spinStarted = false;
            _this._rollupComplete = false;
            _this._firstCycleComplete = false;
            _this._exitStage = false;
            _this._autoSpinPauseSeq = new TimerEventSequenceItem_3.TimerEventSequenceItem(1000);
            _this._inactivityTimer = new TimerEventSequenceItem_3.TimerEventSequenceItem(BaseGameViewController.INACTIVITY_DELAY);
            _this._skinList = ["WinBoxes",
                "Paylines",
                "Messages",
                "Plaques",
                "PickerSkin",
                "ControlSkin"
            ];
            _this._msgBus = GameMsgBus_3.GameMsgBus.getInstance();
            _this._soundManager = SoundManager_6.SoundManager.getInstance();
            _this._assetManager = AssetManager_6.AssetManager.getInstance();
            _this.skin = _this._assetManager.getSkin("GameViewSkin");
            _this._messageContainer = new createjs.Container();
            _this._reelsHelper = new ReelsHelper_1.ReelsHelper();
            _this._baseGameControlsView = new BaseGameControlsViewController_1.BaseGameControlsViewController();
            _this._reelSet = new SlotsReelSet_1.SlotsReelSet("Symbols", _this._assetManager.getAsset("ReelsContainer"));
            _this._messageController = new GenericMessageController_1.GenericMessageController();
            _this._plaqueController = new GenericPlaqueController_2.GenericPlaqueController();
            _this._picker = new PickerViewController_1.PickerViewController();
            _this._symbolOverlayAnimations = new SymbolOverlayAnimations_1.SymbolOverlayAnimations();
            _this._symbolOverlayAnimations.soundNames.setValue("s01", "BaseSymbolS01");
            _this._symbolOverlayAnimations.soundNames.setValue("s02", "BaseSymbolS02");
            _this._symbolOverlayAnimations.soundNames.setValue("s03", "BaseSymbolS03");
            _this._symbolOverlayAnimations.soundNames.setValue("s04", "BaseSymbolS04"); {
                var labelNames = []; {
                    labelNames["15 w01"] = "w01_5x3";
                    labelNames["15 w02"] = "w02_5x3";
                    labelNames["15 s01"] = "s01_5x3";
                    labelNames["15 s02"] = "s02_5x3";
                    labelNames["15 s03"] = "s03_5x3";
                    labelNames["15 s04"] = "s04_5x3";
                    labelNames["15 s05"] = "s05_5x3";
                    labelNames["15 s06"] = "s06_5x3";
                    labelNames["15 s07"] = "s07_5x3";
                    labelNames["15 s08"] = "s08_5x3";
                    labelNames["15 s09"] = "s09_5x3";
                    labelNames["12 w01"] = "w01_4x3";
                    labelNames["12 w02"] = "w02_4x3";
                    labelNames["12 s01"] = "s01_4x3";
                    labelNames["12 s02"] = "s02_4x3";
                    labelNames["12 s03"] = "s03_4x3";
                    labelNames["12 s04"] = "s04_4x3";
                    labelNames["12 s05"] = "s05_4x3";
                    labelNames["12 s06"] = "s06_4x3";
                    labelNames["12 s07"] = "s07_4x3";
                    labelNames["12 s08"] = "s08_4x3";
                    labelNames["12 s09"] = "s09_4x3";
                    labelNames["9 b01"] = "b01_3x3";
                    labelNames["9 w01"] = "w01_3x3";
                    labelNames["9 w02"] = "w02_3x3";
                    labelNames["9 s01"] = "s01_3x3";
                    labelNames["9 s02"] = "s02_3x3";
                    labelNames["9 s03"] = "s03_3x3";
                    labelNames["9 s04"] = "s04_3x3";
                    labelNames["9 s05"] = "s05_3x3";
                    labelNames["9 s06"] = "s06_3x3";
                    labelNames["9 s07"] = "s07_3x3";
                    labelNames["9 s08"] = "s08_3x3";
                    labelNames["9 s09"] = "s09_3x3";
                    labelNames["6 w01"] = "any_2x3";
                    labelNames["6 w02"] = "any_2x3";
                    labelNames["6 s01"] = "any_2x3";
                    labelNames["6 s02"] = "any_2x3";
                    labelNames["6 s03"] = "any_2x3";
                    labelNames["6 s04"] = "any_2x3";
                    labelNames["6 s05"] = "any_2x3";
                    labelNames["6 s06"] = "any_2x3";
                    labelNames["6 s07"] = "any_2x3";
                    labelNames["6 s08"] = "any_2x3";
                    labelNames["6 s09"] = "any_2x3";
                    labelNames["3 w01"] = "any_1x3";
                    labelNames["3 w02"] = "any_1x3";
                    labelNames["3 s01"] = "any_1x3";
                    labelNames["3 s02"] = "any_1x3";
                    labelNames["3 s03"] = "any_1x3";
                    labelNames["3 s04"] = "any_1x3";
                    labelNames["3 s05"] = "any_1x3";
                    labelNames["3 s06"] = "any_1x3";
                    labelNames["3 s07"] = "any_1x3";
                    labelNames["3 s08"] = "any_1x3";
                    labelNames["3 s09"] = "any_1x3";
                }
                _this._symbolOverlayAnimations.labelNames = labelNames;
                _this._symbolOverlayAnimations.numberOfColumns = 5;
                _this._symbolOverlayAnimations.numberOfRows = 3;
                _this._symbolOverlayAnimations.skinName = "GameViewSkin.symbolOverlayAnimations";
            }
            _this._winSequencer = new WinSequencer_1.WinSequencer(_this._reelSet, _this.stageName);
            _this._winSequencer.symbolOverlayAnimations = _this._symbolOverlayAnimations;
            var winSymbolAudio = new Dictionary_4.default();
            winSymbolAudio.setValue("b01", "BaseSymbolB01");
            winSymbolAudio.setValue("s01", "BaseSymbolS01");
            winSymbolAudio.setValue("s02", "BaseSymbolS02");
            winSymbolAudio.setValue("s03", "BaseSymbolS03");
            winSymbolAudio.setValue("s04", "BaseSymbolS04");
            winSymbolAudio.setValue("s05", "BaseSymbolLow");
            winSymbolAudio.setValue("s06", "BaseSymbolLow");
            winSymbolAudio.setValue("s07", "BaseSymbolLow");
            winSymbolAudio.setValue("s08", "BaseSymbolLow");
            winSymbolAudio.setValue("s09", "BaseSymbolLow");
            winSymbolAudio.setValue("w01", "BaseSymbolWild");
            _this._winSequencer.winCycle.symbolAudio = winSymbolAudio;
            var modifiedSymbolNames = new Dictionary_4.default();
            modifiedSymbolNames.setValue("1", "s01");
            modifiedSymbolNames.setValue("2", "s02");
            modifiedSymbolNames.setValue("3", "s03");
            modifiedSymbolNames.setValue("4", "s04");
            modifiedSymbolNames.setValue("5", "s05");
            modifiedSymbolNames.setValue("6", "s06");
            modifiedSymbolNames.setValue("7", "s07");
            modifiedSymbolNames.setValue("8", "s08");
            modifiedSymbolNames.setValue("9", "s09");
            modifiedSymbolNames.setValue("0", "w01");
            modifiedSymbolNames.setValue("B", "b01");
            modifiedSymbolNames.setValue("W", "w01");
            _this.selectiveStackingSymbolChanger = new SelectiveStackingSymbolChanger_1.SelectiveStackingSymbolChanger();
            _this.selectiveStackingSymbolChanger.modifiedSymbolNames = modifiedSymbolNames;
            var fpsSkin = _this.skin["txtFps"];
            if (fpsSkin != null) {
                _this._fpsTextController = new TextFieldController_2.TextFieldController(fpsSkin);
                _this._fpsTextController.setAutoCache(false);
            }
            return _this;
        }
        BaseGameViewController.prototype.init = function(data) {
            this._picker.init(data);
            if (!this._isInit) {
                this._isInit = true;
                if (this._fpsTextController != null) {
                    this._fpsTextController.init();
                    var t_1 = this;
                    var timer = setInterval(function() {
                        t_1._fpsTextController.setText("FPS:" + createjs.Ticker.getMeasuredFPS().toFixed(0));
                    }, 500);
                }
                this._nextStageName = data.gameLogicResponse.outcomeDetail.nextStage;
                this._baseGameControlsView.init(data);
                this._reelSet.stripInfoName = this.stageName;
                this._reelSet.populationOutcomeName = this.stageName + ".Reels";
                this._spinStrategies = this.getSpinStrategies(5);
                var dynamicSymbols = void 0;
                if (data.gameLogicResponse.outcomeDetail.nextStage == "BaseGame") {
                    dynamicSymbols = this.selectiveStackingSymbolChanger.getSubstituteSymbolNames(data);
                } else if (data.gameLogicResponse.outcomeDetail.nextStage == "Picker") {
                    dynamicSymbols = this.selectiveStackingSymbolChanger.getSubstituteSymbolNames(data, "BaseGame");
                }
                this._reelSet.init(this._spinStrategies, data.paytableResponse.stripsInfo, data.gameLogicResponse.populationOutcomes, this.getPoolSymbols(20), dynamicSymbols);
                this._messageController.init();
                this._plaqueController.init(data);
                this._winSequencer.init(data, this._prizeNames);
                this._symbolOverlayAnimations.init();
                this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.Disable;
            }
            this.addEventListeners();
        };
        BaseGameViewController.prototype.enableGame = function() {
            this._picker.enable = false;
            SoundManager_6.SoundManager.getInstance().execute("BaseGameStart");
            this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.Idle;
            ConsoleBusProxy_2.ConsoleBusProxy.getInstance().enableBetControlConsole();
            this._assetManager.getAsset("messageLoader").stop();
            this._assetManager.getAsset("messageLoader").visible = false;
        };
        BaseGameViewController.prototype.getSpinStrategies = function(numberOfReels) {
            var spinStrategies = new Dictionary_4.default();
            for (var reelIndex = 0; reelIndex < numberOfReels; reelIndex++) {
                if (AssetManager_6.AssetManager.getInstance().clientConfigData.assetPack == "desktopmini" ||
                    AssetManager_6.AssetManager.getInstance().clientConfigData.assetPack == "tabletmini") {
                    spinStrategies.setValue("Reel" + reelIndex, new MiniSpinStrategy_1.MiniSpinStrategy());
                } else {
                    spinStrategies.setValue("Reel" + reelIndex, new SpinStrategy_1.SpinStrategy());
                }
            }
            return spinStrategies;
        };
        BaseGameViewController.prototype.getPoolSymbols = function(symbolsPooled) {
            var pool = new Dictionary_4.default();
            for (var _i = 0, _a = this._symbolNames; _i < _a.length; _i++) {
                var symbolName = _a[_i];
                pool.setValue(symbolName, symbolsPooled);
            }
            return pool;
        };
        BaseGameViewController.prototype.onBeforeShowStage = function(evt) {
            console.log("[BaseGameView onBeforeShowStage]");
        };
        BaseGameViewController.prototype.onSpinButtonClick = function(evt) {
            this.startSpin();
        };
        BaseGameViewController.prototype.startSpin = function() {
            this.clearEvents();
            this._plaqueController.hideCurrentPlaque();
            this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.Spinning;
            this._baseGameControlsView.resetWin();
            this._reelsHelper.currentReelIndex = 0;
            this._firstCycleComplete = false;
            this._rollupComplete = false;
            this.nextStage();
            this._spinStarted = true;
            this._soundManager.execute("BaseMusicLoop");
            this._reelSet.spin();
        };
        BaseGameViewController.prototype.onSkipButtonClick = function(evt) {
            this._winSequencer.skipSequence();
            this._baseGameControlsView.skipRollup();
        };
        BaseGameViewController.prototype.onAutoPlayChoicesClick = function(evt) {
            this.startSpin();
        };
        BaseGameViewController.prototype.onAutoPlayStopClick = function(evt) {
            if (this._autoSpinPauseSeq.hasEventListener(ISequenceItem_7.sequencers.SEQUENCE_END, this.startSpin, this)) {
                this._autoSpinPauseSeq.removeEventListener(ISequenceItem_7.sequencers.SEQUENCE_END, this.startSpin, this);
            }
            if (this._baseGameControlsView.state == BaseGameControlsViewController_1.ControlsState.AutoSpinIdle) {
                this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.Idle;
            }
            this.startMusicInactivityTimer();
        };
        BaseGameViewController.prototype.onAutoPlayClick = function(event) {
            this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.Disable;
        };
        BaseGameViewController.prototype.onAutoPlayChoicesCancelClick = function(event) {
            this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.Idle;
        };
        BaseGameViewController.prototype.onBetLineValueChange = function(evt) {
            this.clearEvents();
            this._baseGameControlsView.resetWin();
        };
        BaseGameViewController.prototype.onAccountBalance = function(evt) {};
        BaseGameViewController.prototype.onStartGameInitial = function(evt) {
            console.log("[BaseGameView onStartGameInitial]");
        };
        BaseGameViewController.prototype.onBeforeRequest = function(evt) {
            console.log("[BaseGameView onBeforeRequest]");
            this.selectiveStackingSymbolChanger.setSubstituteSymbolNames(this._reelSet, evt.data, "BaseGame");
            if (this._symbolOverlayAnimations) {
                this._symbolOverlayAnimations.stop();
            }
            this.nextStage();
        };
        BaseGameViewController.prototype.onMakeRequest = function(evt) {
            console.log("[BaseGameView onMakeRequest]");
            BetManager_2.BetManager.getInstance().playAction();
            this.nextStage();
        };
        BaseGameViewController.prototype.onResolveStage = function(evt) {
            console.log("[BaseGameView onResolveStage]");
            this._nextStageName = evt.data.gameLogicResponse.outcomeDetail.nextStage;
            this._reelSet.stripInfoName = this.stageName;
            this._reelSet.populationOutcomeName = this.stageName + ".Reels";
            this._winSequencer.setWinOutcome(evt);
            this._eventData = evt;
            if (evt.data.gameLogicResponse.outcomeDetail.nextStage != this.stageName) {
                this._exitStage = true;
            }
            this._reelsHelper.setNewData(evt.data);
            if (evt.data.gameLogicResponse.promotionalFreeSpin != null) {
                var spinValue = evt.data.gameLogicResponse.promotionalFreeSpin.count.toString();
                this._baseGameControlsView.updatePromoFS(spinValue);
                this._baseGameControlsView.setPromoFSCount(evt.data);
            }
            if (this._spinStarted) {
                this._spinStarted = false;
                var spinDuration = BaseGameViewController.DEFAULT_SPIN_DURATION.concat();
                spinDuration = this._reelsHelper.getSpinDurationsForAllReels(spinDuration);
                this._reelSet.stopSpin(evt.data.gameLogicResponse.populationOutcomes, spinDuration);
            } else {
                this.handleExitStage();
            }
        };
        BaseGameViewController.prototype.handleExitStage = function() {
            console.log("[BaseGameView handleExitStage] exitStage:" + this._exitStage);
            if (!this._exitStage) {
                this.nextStage();
            } else {
                this._exitStage = false;
                this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.BonusTransition;
                var mc = this.skin["symbolOverlayAnimations"]["reel1"];
                this.setFreeSpinText(mc);
                var freeSpinsAwardedSequence = new MovieClipSequenceItem_4.MovieClipSequenceItem(mc, "b01_3x3", "b01_3x3Done", 1);
                freeSpinsAwardedSequence.addEventListener(ISequenceItem_7.sequencers.SEQUENCE_END, this.freeSpinsAwardedAnimationComplete, this);
                freeSpinsAwardedSequence.startSequence();
            }
        };
        BaseGameViewController.prototype.setFreeSpinText = function(mc) {
            var freeTextFields = ["Free", "Spins", "Awarded"];
            mc.gotoAndStop("b01_3x3");
            for (var _i = 0, freeTextFields_1 = freeTextFields; _i < freeTextFields_1.length; _i++) {
                var text = freeTextFields_1[_i];
                this._freeSpinMessage = new TextFieldController_2.TextFieldController(mc["freeSpinSymbol"]["text" + text]["text" + text + "Text"]["textField"]);
                this._freeSpinMessage.init();
                this._freeSpinMessage.setText(TextManager_3.TextManager.getInstance().getText(text.toLowerCase()));
            }
        };
        BaseGameViewController.prototype.freeSpinsAwardedAnimationComplete = function(evt) {
            var freeSpinsAwardedSequence = evt.target;
            freeSpinsAwardedSequence.removeEventListener(ISequenceItem_7.sequencers.SEQUENCE_END, this.freeSpinsAwardedAnimationComplete, this);
            freeSpinsAwardedSequence.mc.gotoAndStop("static");
            this.nextStage();
        };
        BaseGameViewController.prototype.onReelStopSpinBegin = function(evt) {
            this._reelsHelper.playReelStopSound();
            this._reelsHelper.currentReelIndex++;
        };
        BaseGameViewController.prototype.onReelStopSpinEnd = function(evt) {};
        BaseGameViewController.prototype.onAllReelStop = function(evt) {
            console.log("[BaseGameView onAllReelStop] exitStage:" + this._exitStage);
            if (this._eventData.data.gameLogicResponse.outcomeDetail.nextStage == "Picker") {
                this.nextStage();
            } else {
                if (this._exitStage) {
                    this.handleExitStage();
                } else {
                    this.handleEndGame(this._eventData);
                }
            }
        };
        BaseGameViewController.prototype.handleEndGame = function(evt) {
            console.log("[BaseGameView handleEndGame]");
            if (evt.data.gameLogicResponse.outcomeDetail.stage == "FreeSpin") {
                this._winSequencer.setWinOutcome(evt);
                this._assetManager.getAsset("messageLoader").visible = false;
                this._assetManager.getAsset("messageLoader").gotoAndStop(0);
            }
            if (evt.data.gameLogicResponse.awardCapOutcome.awardCapExceeded) {
                this._plaqueController.displayLabeledTextField(this._plaqueController.maxAwardPlaque, evt.data.paytableResponse.awardCapInfo.currencyCap.awardCap);
                this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.Idle;
                this._baseGameControlsView.updateWin(evt.data);
                this.nextStage();
            } else if (evt.data.gameLogicResponse.awardCapOutcome.awardCapExceeded &&
                evt.data.gameLogicResponse.outcomeDetail.stage == "FreeSpin") {
                this._plaqueController.displayLabeledTextField(this._plaqueController.maxAwardPlaque, evt.data.paytableResponse.awardCapInfo.currencyCap.awardCap);
                this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.Idle;
                this._baseGameControlsView.updateWin(evt.data);
                this.nextStage();
            } else {
                this.handleWinCelebration(evt);
            }
        };
        BaseGameViewController.prototype.onEndGame = function(evt) {
            console.log("[BaseGameView onEndGame]");
            this.nextStage();
        };
        BaseGameViewController.prototype.startMusicInactivityTimer = function() {
            if (!this._baseGameControlsView.autoSpinIsActive()) {
                this._inactivityTimer.addEventListener(ISequenceItem_7.sequencers.SEQUENCE_END, this.inactivityFadeMusic, this);
                this._inactivityTimer.startSequence();
            }
        };
        BaseGameViewController.prototype.inactivityFadeMusic = function(evt) {
            this._inactivityTimer.removeEventListener(ISequenceItem_7.sequencers.SEQUENCE_END, this.inactivityFadeMusic, this);
            this._soundManager.execute("BaseMusicLoopFadeOut");
        };
        BaseGameViewController.prototype.handleWinCelebration = function(evt) {
            if (this._winSequencer.winCycleHelper.hasPrize(evt.data)) {
                this._baseGameControlsView.setPayout(evt.data);
                this._baseGameControlsView.setRollupSequence();
                this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.Rollup;
                this._baseGameControlsView.rollup.addEventListener(RollupIncrementer_2.RollupIncrementer.ROLLUP_COMPLETE, this.onRollupComplete, this);
                if (this._baseGameControlsView.autoSpinIsActive()) {
                    this._winSequencer.winCycle.addEventListener(WinCycle_2.WinCycle.FIRST_CYCLE_DONE, this.onFirstCycleComplete, this);
                }
                this._winSequencer.setWinCelebration(evt, this._baseGameControlsView.rollup, this._baseGameControlsView.rollupIndex);
                this._winSequencer.startSequence();
                var totalBet = evt.data.gameLogicResponse.patternSliderInput.betPerPattern * evt.data.gameLogicResponse.patternSliderInput.patternsBet;
                var payout = evt.data.gameLogicResponse.prizeOutcomes.getValue("Game.Total").pay;
                var rgPresentation = evt.data.gameConfig ? (evt.data.gameConfig.rgPresentation ? evt.data.gameConfig.rgPresentation : false) : false;
                var isAboveBet = payout > totalBet;
                if (!isAboveBet && rgPresentation) {
                    this._winSequencer.skipSequence();
                }
            } else {
                this.startMusicInactivityTimer();
                this._firstCycleComplete = true;
                this._rollupComplete = true;
                this.nextStage();
            }
        };
        BaseGameViewController.prototype.onFirstCycleComplete = function(evt) {
            console.log("[BaseGameView onFirstCycleComplete]");
            this._firstCycleComplete = true;
            if (this._baseGameControlsView.autoSpinIsActive()) {
                this._winSequencer.clearEvents();
                this.handlePromoFreeSpin();
                if (this._rollupComplete) {
                    this.handleAutoSpin();
                }
            }
        };
        BaseGameViewController.prototype.onRollupComplete = function(evt) {
            console.log("[BaseGameView onRollupComplete]");
            this.startMusicInactivityTimer();
            this._rollupComplete = true;
            this.nextStage();
        };
        BaseGameViewController.prototype.handleAutoSpin = function() {
            if (this._baseGameControlsView.autoSpinIsActive() && this._firstCycleComplete && this._rollupComplete) {
                this._winSequencer.clearEvents();
                this._autoSpinPauseSeq.addEventListener(ISequenceItem_7.sequencers.SEQUENCE_END, this.startSpin, this);
                this._autoSpinPauseSeq.startSequence();
            }
        };
        BaseGameViewController.prototype.handlePromoFreeSpin = function() {
            if (this._baseGameControlsView.promoFSCount <= 0) {
                this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.Disable;
            }
        };
        BaseGameViewController.prototype.clearEvents = function() {
            this._winSequencer.clearEvents();
            if (this._winSequencer.winCycle.hasEventListener(WinCycle_2.WinCycle.FIRST_CYCLE_DONE, this.onFirstCycleComplete, this)) {
                this._winSequencer.winCycle.removeEventListener(WinCycle_2.WinCycle.FIRST_CYCLE_DONE, this.onFirstCycleComplete, this);
            }
            if (this._baseGameControlsView.rollup.hasEventListener(RollupIncrementer_2.RollupIncrementer.ROLLUP_COMPLETE, this.onRollupComplete, this)) {
                this._baseGameControlsView.rollup.removeEventListener(RollupIncrementer_2.RollupIncrementer.ROLLUP_COMPLETE, this.onRollupComplete, this);
            }
            if (this._autoSpinPauseSeq.hasEventListener(ISequenceItem_7.sequencers.SEQUENCE_END, this.startSpin, this)) {
                this._autoSpinPauseSeq.removeEventListener(ISequenceItem_7.sequencers.SEQUENCE_END, this.startSpin, this);
            }
        };
        BaseGameViewController.prototype.handleIdleControlState = function() {
            this._baseGameControlsView.handleAutoPlayEnd();
            if (this._baseGameControlsView.promoFSCount <= 0) {
                this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.Disable;
            } else if (this._baseGameControlsView.autoSpinIsActive()) {
                this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.AutoSpinIdle;
                this.startMusicInactivityTimer();
            } else {
                this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.Idle;
            }
        };
        BaseGameViewController.prototype.onBeginNewGame = function(evt) {
            console.log("[BaseGameView onBeginNewGame]");
            this.handleIdleControlState();
            this.handleAutoSpin();
        };
        BaseGameViewController.prototype.onEnterNextStage = function(evt) {
            console.log("[BaseGameView onEnterNextStage]");
            this.nextStage();
        };
        BaseGameViewController.prototype.onExitStage = function(evt) {
            console.log("[BaseGameView onExitStage]");
            this._plaqueController.hideCurrentPlaque();
            this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.BonusTransition;
            this.handleExitStage();
        };
        BaseGameViewController.prototype.onAbortNextStage = function(evt) {
            this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.Disable;
            this._reelSet.reset(evt.data.gameLogicResponse.populationOutcomes);
            this.nextStage();
        };
        BaseGameViewController.prototype.onResetNextStage = function(evt) {
            this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.Idle;
        };
        BaseGameViewController.prototype.enableControls = function(enable) {
            if (enable === void 0) {
                enable = true;
            }
            if (enable && this._nextStageName != "Picker") {
                this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.Idle;
            } else {
                this._baseGameControlsView.state = BaseGameControlsViewController_1.ControlsState.Disable;
            }
        };
        BaseGameViewController.prototype.addBusListeners = function() {
            this._msgBus.addEventListener(GameMsgBus_3.GameMsgBus.START_GAME_INITIAL, this.onStartGameInitial, this);
            this._msgBus.addEventListener(GameMsgBus_3.GameMsgBus.BEFORE_REQUEST, this.onBeforeRequest, this);
            this._msgBus.addEventListener(GameMsgBus_3.GameMsgBus.MAKE_REQUEST, this.onMakeRequest, this);
            this._msgBus.addEventListener(GameMsgBus_3.GameMsgBus.RESOLVE_STAGE, this.onResolveStage, this);
            this._msgBus.addEventListener(GameMsgBus_3.GameMsgBus.END_GAME, this.onEndGame, this);
            this._msgBus.addEventListener(GameMsgBus_3.GameMsgBus.BEGIN_NEW_GAME, this.onBeginNewGame, this);
            this._msgBus.addEventListener(GameMsgBus_3.GameMsgBus.ACCOUNT_BALANCES, this.onAccountBalance, this);
            this._msgBus.addEventListener(GameMsgBus_3.GameMsgBus.BEFORE_SHOW_STAGE, this.onBeforeShowStage, this);
            this._msgBus.addEventListener(GameMsgBus_3.GameMsgBus.ENTER_NEXT_STAGE, this.onEnterNextStage, this);
            this._msgBus.addEventListener(GameMsgBus_3.GameMsgBus.EXIT_STAGE, this.onExitStage, this);
            this._msgBus.addEventListener(GameMsgBus_3.GameMsgBus.ABORT_NEXT_STAGE, this.onAbortNextStage, this);
            this._msgBus.addEventListener(GameMsgBus_3.GameMsgBus.RESET_NEXT_STAGE, this.onResetNextStage, this);
        };
        BaseGameViewController.prototype.removeBusListeners = function() {
            this._msgBus.removeEventListener(GameMsgBus_3.GameMsgBus.START_GAME_INITIAL, this.onStartGameInitial, this);
            this._msgBus.removeEventListener(GameMsgBus_3.GameMsgBus.BEFORE_REQUEST, this.onBeforeRequest, this);
            this._msgBus.removeEventListener(GameMsgBus_3.GameMsgBus.MAKE_REQUEST, this.onMakeRequest, this);
            this._msgBus.removeEventListener(GameMsgBus_3.GameMsgBus.RESOLVE_STAGE, this.onResolveStage, this);
            this._msgBus.removeEventListener(GameMsgBus_3.GameMsgBus.END_GAME, this.onEndGame, this);
            this._msgBus.removeEventListener(GameMsgBus_3.GameMsgBus.BEGIN_NEW_GAME, this.onBeginNewGame, this);
            this._msgBus.removeEventListener(GameMsgBus_3.GameMsgBus.ACCOUNT_BALANCES, this.onAccountBalance, this);
            this._msgBus.removeEventListener(GameMsgBus_3.GameMsgBus.BEFORE_SHOW_STAGE, this.onBeforeShowStage, this);
            this._msgBus.removeEventListener(GameMsgBus_3.GameMsgBus.ENTER_NEXT_STAGE, this.onEnterNextStage, this);
            this._msgBus.removeEventListener(GameMsgBus_3.GameMsgBus.EXIT_STAGE, this.onExitStage, this);
            this._msgBus.removeEventListener(GameMsgBus_3.GameMsgBus.ABORT_NEXT_STAGE, this.onAbortNextStage, this);
            this._msgBus.removeEventListener(GameMsgBus_3.GameMsgBus.RESET_NEXT_STAGE, this.onResetNextStage, this);
        };
        BaseGameViewController.prototype.nextStage = function() {
            this._msgBus.dispatchEvent(new events_8.events.Event(GameMsgBus_3.GameMsgBus.NEXT_STAGE));
        };
        BaseGameViewController.prototype.addToStage = function(container) {
            container.addChild(this.skin);
            for (var _i = 0, _a = this._skinList; _i < _a.length; _i++) {
                var skinName = _a[_i];
                container.addChild(this._assetManager.getSkin(skinName));
            }
            container.addChild(this._messageContainer);
            this.enable = true;
        };
        BaseGameViewController.prototype.removeFromStage = function(container) {
            console.log(this.skin);
            container.removeChild(this.skin);
            for (var _i = 0, _a = this._skinList; _i < _a.length; _i++) {
                var skinName = _a[_i];
                container.removeChild(this._assetManager.getSkin(skinName));
            }
            this.removeEventListeners();
            this.enable = false;
        };
        BaseGameViewController.prototype.removeChild = function(childName) {
            this.skin.removeChild(this._assetManager.getSkin(childName));
        };
        Object.defineProperty(BaseGameViewController.prototype, "enable", {
            get: function() {
                return this._enable;
            },
            set: function(value) {
                if (this._enable != value) {
                    this._enable = value;
                    if (value) {
                        this.addBusListeners();
                        this.enableControls(true);
                    } else {
                        this.removeBusListeners();
                        this.enableControls(false);
                    }
                    if (this.skin["baseGameLogo"]) {
                        if (this._nextStageName == this.stageName) {
                            this.skin["baseGameLogo"].visible = true;
                        } else {
                            this.skin["baseGameLogo"].visible = value;
                        }
                    }
                }
            },
            enumerable: true,
            configurable: true
        });
        BaseGameViewController.prototype.addEventListeners = function() {
            if (this._isInit) {
                this._baseGameControlsView.addEventListener(BaseGameControlsViewController_1.BaseGameControlsViewController.SPIN_BUTTON_CLICK, this.onSpinButtonClick, this);
                this._baseGameControlsView.addEventListener(BaseGameControlsViewController_1.BaseGameControlsViewController.SKIP_BUTTON_CLICK, this.onSkipButtonClick, this);
                this._baseGameControlsView.addEventListener(BaseGameControlsViewController_1.BaseGameControlsViewController.AUTO_PLAY_CHOICES_CLICK, this.onAutoPlayChoicesClick, this);
                this._baseGameControlsView.addEventListener(BaseGameControlsViewController_1.BaseGameControlsViewController.AUTO_PLAY_STOP_CLICK, this.onAutoPlayStopClick, this);
                this._baseGameControlsView.addEventListener(BaseGameControlsViewController_1.BaseGameControlsViewController.AUTO_PLAY_CLICK, this.onAutoPlayClick, this);
                this._baseGameControlsView.addEventListener(BaseGameControlsViewController_1.BaseGameControlsViewController.AUTO_PLAY_CHOICES_CANCEL_CLICK, this.onAutoPlayChoicesCancelClick, this);
                this._baseGameControlsView.addEventListener(GenericStepperController_2.GenericStepperController.VALUE_CHANGE, this.onBetLineValueChange, this);
                this._reelSet.addEventListener(SlotsReelSet_1.SlotsReelSet.ALL_REEL_STOP, this.onAllReelStop, this);
                this._reelSet.addEventListener(SlotsReelSet_1.SlotsReelSet.REEL_STOP_SPIN_BEGIN, this.onReelStopSpinBegin, this);
                this._reelSet.addEventListener(SlotsReelSet_1.SlotsReelSet.REEL_STOP_SPIN_END, this.onReelStopSpinEnd, this);
                this._baseGameControlsView.addEventListeners();
            }
        };
        BaseGameViewController.prototype.removeEventListeners = function() {
            if (this._isInit) {
                this._baseGameControlsView.removeEventListener(BaseGameControlsViewController_1.BaseGameControlsViewController.SPIN_BUTTON_CLICK, this.onSpinButtonClick, this);
                this._baseGameControlsView.removeEventListener(BaseGameControlsViewController_1.BaseGameControlsViewController.SKIP_BUTTON_CLICK, this.onSkipButtonClick, this);
                this._baseGameControlsView.removeEventListener(BaseGameControlsViewController_1.BaseGameControlsViewController.AUTO_PLAY_CHOICES_CLICK, this.onAutoPlayChoicesClick, this);
                this._baseGameControlsView.removeEventListener(BaseGameControlsViewController_1.BaseGameControlsViewController.AUTO_PLAY_STOP_CLICK, this.onAutoPlayStopClick, this);
                this._baseGameControlsView.removeEventListener(BaseGameControlsViewController_1.BaseGameControlsViewController.AUTO_PLAY_CLICK, this.onAutoPlayClick, this);
                this._baseGameControlsView.removeEventListener(BaseGameControlsViewController_1.BaseGameControlsViewController.AUTO_PLAY_CHOICES_CANCEL_CLICK, this.onAutoPlayChoicesCancelClick, this);
                this._baseGameControlsView.removeEventListener(GenericStepperController_2.GenericStepperController.VALUE_CHANGE, this.onBetLineValueChange, this);
                this._reelSet.removeEventListener(SlotsReelSet_1.SlotsReelSet.ALL_REEL_STOP, this.onAllReelStop, this);
                this._reelSet.removeEventListener(SlotsReelSet_1.SlotsReelSet.REEL_STOP_SPIN_BEGIN, this.onReelStopSpinBegin, this);
                this._reelSet.removeEventListener(SlotsReelSet_1.SlotsReelSet.REEL_STOP_SPIN_END, this.onReelStopSpinEnd, this);
                this._baseGameControlsView.removeEventListeners();
            }
        };
        Object.defineProperty(BaseGameViewController.prototype, "picker", {
            get: function() {
                return this._picker;
            },
            enumerable: true,
            configurable: true
        });
        return BaseGameViewController;
    }(events_8.events.EventDispatcher));
    BaseGameViewController.DEFAULT_SPIN_DURATION = [800, 1100, 1400, 1700, 2000];
    BaseGameViewController.INACTIVITY_DELAY = 5000;
    exports.BaseGameViewController = BaseGameViewController;
});
define("stages/freeSpin/FreeSpinControlsViewController", ["require", "exports", "wcgf/core/events", "wcgf/coreComponents/PlayButtonController", "wcgf/coreComponents/LabeledTextFieldController", "wcgf/core/AssetManager", "wcgf/core/TextManager", "wcgf/core/CurrencyFormatter", "wcgf/gameComponents/RollupIncrementer", "wcgf/sequencers/ISequenceItem", "wcgf/sounds/SoundManager", "wcgf/messageBus/ConsoleBusProxy"], function(require, exports, events_9, PlayButtonController_2, LabeledTextFieldController_2, AssetManager_7, TextManager_4, CurrencyFormatter_2, RollupIncrementer_3, ISequenceItem_8, SoundManager_7, ConsoleBusProxy_3) {
    "use strict";
    var ControlsState;
    (function(ControlsState) {
        ControlsState[ControlsState["StartIdle"] = 0] = "StartIdle";
        ControlsState[ControlsState["Spinning"] = 1] = "Spinning";
        ControlsState[ControlsState["Idle"] = 2] = "Idle";
        ControlsState[ControlsState["Rollup"] = 3] = "Rollup";
        ControlsState[ControlsState["Disable"] = 4] = "Disable";
        ControlsState[ControlsState["BonusIdle"] = 5] = "BonusIdle";
        ControlsState[ControlsState["BonusTransition"] = 6] = "BonusTransition";
    })(ControlsState = exports.ControlsState || (exports.ControlsState = {}));
    var FreeSpinControlsViewController = (function(_super) {
        __extends(FreeSpinControlsViewController, _super);

        function FreeSpinControlsViewController() {
            var _this = _super.call(this) || this;
            _this._rollupIndex = 0;
            _this._totalBet = 0;
            _this._count = 0;
            _this._countDown = 0;
            _this._rgPresentation = false;
            _this._assetManager = AssetManager_7.AssetManager.getInstance();
            _this._consoleProxy = ConsoleBusProxy_3.ConsoleBusProxy.getInstance();
            return _this;
        }
        FreeSpinControlsViewController.prototype.init = function(data) {
            if (data === void 0) {
                data = null;
            }
            this.setTotalBet(data);
            this.setDenomination(data);
            this.setPlayButton();
            this.setSpinsPlayedMeter(data);
            this.setBonusWinMeter();
            this.setPayout(data);
            this.resetWin();
            this.setRollup();
        };
        FreeSpinControlsViewController.prototype.setPlayButton = function() {
            this._playButton = new PlayButtonController_2.PlayButtonController(this._assetManager.getAsset("freeSpinPlayButton"));
            this._playButton.init();
            this._playButton.state = PlayButtonController_2.PlayButtonState.Spin;
        };
        FreeSpinControlsViewController.prototype.setSpinsPlayedMeter = function(data) {
            this._spinsPlayedMeter = new LabeledTextFieldController_2.LabeledTextFieldController(this._assetManager.getAsset("spinsPlayedMeter"));
            this._spinsPlayedMeter.init();
            this._spinsPlayedMeter.label = TextManager_4.TextManager.getInstance().getText("spinsPlayed");
            this.initSpinsPlayedMeter(data);
        };
        FreeSpinControlsViewController.prototype.initSpinsPlayedMeter = function(data) {
            var freeSpinOutcome = data.gameLogicResponse.freeSpinOutcomes.getValue("");
            this._count = freeSpinOutcome.count;
            this._countDown = this._count + freeSpinOutcome.countdown;
            this._spinsPlayedMeter.setText(this._count + "/" + this._countDown);
        };
        FreeSpinControlsViewController.prototype.incremenetCount = function() {
            this._count++;
            this._spinsPlayedMeter.setText(this._count + "/" + this._countDown);
        };
        FreeSpinControlsViewController.prototype.setBonusWinMeter = function() {
            this._bonusWinMeter = new LabeledTextFieldController_2.LabeledTextFieldController(this._assetManager.getAsset("bonusWinMeter"));
            this._bonusWinMeter.init();
            this._bonusWinMeter.label = TextManager_4.TextManager.getInstance().getText("bonusWin");
        };
        FreeSpinControlsViewController.prototype.setDenomination = function(data) {
            if (data != null && data.paytableResponse != null && data.paytableResponse.denominationList != null) {
                this._denomination = data.paytableResponse.denominationList[0].value;
            }
        };
        FreeSpinControlsViewController.prototype.setTotalBet = function(data) {
            this._rgPresentation = data.gameConfig ? (data.gameConfig.rgPresentation ? data.gameConfig.rgPresentation : false) : false;
            this._totalBet = data.gameLogicResponse.patternSliderInput.betPerPattern *
                data.gameLogicResponse.patternSliderInput.patternsBet;
        };
        FreeSpinControlsViewController.prototype.setRollup = function() {
            this._rollup = new RollupIncrementer_3.RollupIncrementer();
            this._rollup.denomination = this._denomination;
            this._rollup.textField = this._bonusWinMeter;
            this._rollup.addOnTargetValue = true;
            this._rollup.currentValue = this._payout;
        };
        FreeSpinControlsViewController.prototype.skipRollup = function() {
            if (this.hasPayout()) {
                this._rollup.stopSequence();
            }
        };
        FreeSpinControlsViewController.prototype.setRollupSequence = function() {
            if (this.hasPayout()) {
                this._rollup.targetValue = this._payout;
                this.calculateThreshold();
                this._rollup.addEventListener(ISequenceItem_8.sequencers.SEQUENCE_END, this.onRollupComplete, this);
                this._rollup.addEventListener(ISequenceItem_8.sequencers.SEQUENCE_START, this.onRollupStart, this);
            }
        };
        FreeSpinControlsViewController.prototype.onRollupStart = function(evt) {
            this._rollup.removeEventListener(ISequenceItem_8.sequencers.SEQUENCE_START, this.onRollupStart, this);
            if (this._rollup.targetValue > this._totalBet || !this._rgPresentation) {
                SoundManager_7.SoundManager.getInstance().execute("BonusRollupLoop");
            }
        };
        FreeSpinControlsViewController.prototype.onRollupComplete = function(evt) {
            this._rollup.removeEventListener(ISequenceItem_8.sequencers.SEQUENCE_END, this.onRollupComplete, this);
            if (this._rollup.targetValue > this._totalBet || !this._rgPresentation) {
                SoundManager_7.SoundManager.getInstance().execute("BonusRollupLoopTerm");
            } else {
                SoundManager_7.SoundManager.getInstance().execute("RollupLow");
            }
        };
        Object.defineProperty(FreeSpinControlsViewController.prototype, "rollup", {
            get: function() {
                return this._rollup;
            },
            enumerable: true,
            configurable: true
        });
        FreeSpinControlsViewController.prototype.calculateThreshold = function() {
            if (this.thresholdReached(1000, FreeSpinControlsViewController.BIG_WIN_MULTIPLIER)) {
                this._rollupIndex = 2;
            } else if (this.thresholdReached(100, FreeSpinControlsViewController.MID_WIN_MULTIPLIER)) {
                this._rollupIndex = 1;
            } else {
                this._rollupIndex = 0;
            }
        };
        FreeSpinControlsViewController.prototype.thresholdReached = function(threshold, multiplier) {
            return (this._win >= threshold &&
                this._win >= (this._totalBet * multiplier));
        };
        FreeSpinControlsViewController.prototype.updateWin = function(data) {
            this.setPayout(data);
            this.setWin(data);
            this.updateWinField(this.formatValue(this._payout, this._denomination));
        };
        FreeSpinControlsViewController.prototype.resetWin = function() {
            this.updateWinField("");
        };
        FreeSpinControlsViewController.prototype.updateWinField = function(win) {
            if (this._payout > 0) {
                this._bonusWinMeter.setText(win);
            } else {
                this._bonusWinMeter.setText("");
            }
        };
        FreeSpinControlsViewController.prototype.setPayout = function(data) {
            if (data != null && data.gameLogicResponse.prizeOutcomes.getValue("Game.Total")) {
                this._payout = data.gameLogicResponse.prizeOutcomes.getValue("Game.Total").pay;
            } else {
                this._payout = 0;
            }
        };
        FreeSpinControlsViewController.prototype.setWin = function(data) {
            this._win = 0;
            if (data != null && data.gameLogicResponse.prizeOutcomes.getValue("FreeSpin.Lines")) {
                this._win += data.gameLogicResponse.prizeOutcomes.getValue("FreeSpin.Lines").pay;
            }
            if (data != null && data.gameLogicResponse.prizeOutcomes.getValue("FreeSpin.Scatter")) {
                this._win += data.gameLogicResponse.prizeOutcomes.getValue("FreeSpin.Scatter").pay;
            }
        };
        FreeSpinControlsViewController.prototype.hasPayout = function() {
            return (this._payout == 0 ? false : true);
        };
        Object.defineProperty(FreeSpinControlsViewController.prototype, "state", {
            get: function() {
                return this._state;
            },
            set: function(value) {
                this._state = value;
                switch (this._state) {
                    case ControlsState.Idle:
                        this._playButton.enable = true;
                        this._playButton.state = PlayButtonController_2.PlayButtonState.Spin;
                        this._playButton.sendReceiveEnable = false;
                        this._consoleProxy.disableControlConsole();
                        break;
                    case ControlsState.Rollup:
                        this._playButton.enable = true;
                        this._playButton.state = PlayButtonController_2.PlayButtonState.Skip;
                        this._playButton.sendReceiveEnable = false;
                        this._consoleProxy.disableControlConsole();
                        break;
                    case ControlsState.Spinning:
                        this._playButton.state = PlayButtonController_2.PlayButtonState.Spin;
                        this._playButton.enable = false;
                        this._playButton.sendReceiveEnable = true;
                        this._consoleProxy.disableControlConsole();
                        break;
                    case ControlsState.BonusIdle:
                        this._playButton.state = PlayButtonController_2.PlayButtonState.Start;
                        this._playButton.enable = true;
                        this._playButton.sendReceiveEnable = false;
                        this._consoleProxy.disableControlConsole();
                        break;
                    case ControlsState.BonusTransition:
                        this._playButton.state = PlayButtonController_2.PlayButtonState.Start;
                        this._playButton.enable = false;
                        this._playButton.sendReceiveEnable = false;
                        this._consoleProxy.disableControlConsole();
                        break;
                    case ControlsState.Disable:
                        this._playButton.state = PlayButtonController_2.PlayButtonState.Spin;
                        this._playButton.enable = false;
                        this._playButton.sendReceiveEnable = false;
                        this._consoleProxy.disableControlConsole();
                        break;
                    case ControlsState.StartIdle:
                        this._playButton.state = PlayButtonController_2.PlayButtonState.Start;
                        this._playButton.enable = true;
                        this._playButton.sendReceiveEnable = false;
                        this._consoleProxy.disableControlConsole();
                        break;
                    default:
                        break;
                }
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(FreeSpinControlsViewController.prototype, "rollupIndex", {
            get: function() {
                return this._rollupIndex;
            },
            enumerable: true,
            configurable: true
        });
        FreeSpinControlsViewController.prototype.onSkipButtonClick = function(evt) {
            this.dispatchEvent(new events_9.events.Event(FreeSpinControlsViewController.SKIP_BUTTON_CLICK, null, this));
        };
        FreeSpinControlsViewController.prototype.onStartButtonClick = function(evt) {
            this.dispatchEvent(new events_9.events.Event(FreeSpinControlsViewController.START_BUTTON_CLICK, null, this));
        };
        FreeSpinControlsViewController.prototype.onSpinButtonClick = function(evt) {
            SoundManager_7.SoundManager.getInstance().execute("ControlsSpin");
            this.dispatchEvent(new events_9.events.Event(FreeSpinControlsViewController.SPIN_BUTTON_CLICK, null, this));
        };
        FreeSpinControlsViewController.prototype.formatValue = function(value, denomination) {
            if (denomination === void 0) {
                denomination = this._denomination;
            }
            return CurrencyFormatter_2.CurrencyFormatter.getInstance().format(value, denomination);
        };
        FreeSpinControlsViewController.prototype.addEventListeners = function() {
            this._playButton.addEventListener(PlayButtonController_2.PlayButtonController.SKIP_BUTTON_CLICK, this.onSkipButtonClick, this);
            this._playButton.addEventListener(PlayButtonController_2.PlayButtonController.SPIN_BUTTON_CLICK, this.onSpinButtonClick, this);
            this._playButton.addEventListener(PlayButtonController_2.PlayButtonController.START_BUTTON_CLICK, this.onStartButtonClick, this);
        };
        FreeSpinControlsViewController.prototype.removeEventListeners = function() {
            this._playButton.removeEventListener(PlayButtonController_2.PlayButtonController.SKIP_BUTTON_CLICK, this.onSkipButtonClick, this);
            this._playButton.removeEventListener(PlayButtonController_2.PlayButtonController.SPIN_BUTTON_CLICK, this.onSpinButtonClick, this);
            this._playButton.removeEventListener(PlayButtonController_2.PlayButtonController.START_BUTTON_CLICK, this.onStartButtonClick, this);
        };
        return FreeSpinControlsViewController;
    }(events_9.events.EventDispatcher));
    FreeSpinControlsViewController.SPIN_BUTTON_CLICK = "FreeSpinControlsViewSpinClick";
    FreeSpinControlsViewController.SKIP_BUTTON_CLICK = "FreeSpinControlsViewSkipClick";
    FreeSpinControlsViewController.START_BUTTON_CLICK = "FreeSpinControlsViewStartClick";
    FreeSpinControlsViewController.AUTO_PLAY_CLICK = "FreeSpinControlsViewAutoPlayClick";
    FreeSpinControlsViewController.AUTO_PLAY_CHOICES_CLICK = "FreeSpinControlsViewAutoPlayChoicesClick";
    FreeSpinControlsViewController.AUTO_PLAY_STOP_CLICK = "FreeSpinControlsViewAutoPlayStopClick";
    FreeSpinControlsViewController.BIG_WIN_MULTIPLIER = 10;
    FreeSpinControlsViewController.MID_WIN_MULTIPLIER = 5;
    exports.FreeSpinControlsViewController = FreeSpinControlsViewController;
});
define("stages/freeSpin/FreeSpinViewController", ["require", "exports", "wcgf/messageBus/GameMsgBus", "wcgf/core/AssetManager", "wcgf/core/events", "wcgf/vendors/typescript_collections/Dictionary", "wcgf/gameComponents/reels/slotsReelSet/SlotsReelSet", "stages/freeSpin/FreeSpinControlsViewController", "WinCycle", "wcgf/coreComponents/GenericMessageController", "wcgf/sounds/SoundManager", "wcgf/sequencers/ISequenceItem", "wcgf/sequencers/TimerEventSequenceItem", "ReelsHelper", "SpinStrategy", "wcgf/coreComponents/GenericPlaqueController", "wcgf/gameComponents/RollupIncrementer", "WinSequencer", "wcgf/sequencers/LinearSequencer", "expandingSymbols/SymbolOverlayAnimations", "selectiveStacking/SelectiveStackingSymbolChanger", "wcgf/core/TextManager", "wcgf/coreComponents/LabeledViewController", "MiniSpinStrategy"], function(require, exports, GameMsgBus_4, AssetManager_8, events_10, Dictionary_5, SlotsReelSet_2, FreeSpinControlsViewController_1, WinCycle_3, GenericMessageController_2, SoundManager_8, ISequenceItem_9, TimerEventSequenceItem_4, ReelsHelper_2, SpinStrategy_2, GenericPlaqueController_3, RollupIncrementer_4, WinSequencer_2, LinearSequencer_5, SymbolOverlayAnimations_2, SelectiveStackingSymbolChanger_2, TextManager_5, LabeledViewController_2, MiniSpinStrategy_2) {
    "use strict";
    var FreeSpinViewController = (function(_super) {
        __extends(FreeSpinViewController, _super);

        function FreeSpinViewController() {
            var _this = _super.call(this) || this;
            _this.stageName = "FreeSpin";
            _this._symbolNames = ["s01", "s02", "s03", "s04", "s05",
                "s06", "s07", "s08", "s09", "w01", "w02"
            ];
            _this._prizeNames = ["FreeSpin.Lines"];
            _this._isInit = false;
            _this._enable = false;
            _this._spinStarted = false;
            _this._rollupComplete = false;
            _this._firstCycleComplete = false;
            _this._resetStageHit = false;
            _this._inProgressStageHit = false;
            _this._exitStage = false;
            _this._autoSpinPauseSeq = new TimerEventSequenceItem_4.TimerEventSequenceItem(1000);
            _this._skinList = [
                "Paylines",
                "WinBoxes",
                "Messages",
                "Plaques",
                "FreeSpinControlSkin"
            ];
            _this._msgBus = GameMsgBus_4.GameMsgBus.getInstance();
            _this._assetManager = AssetManager_8.AssetManager.getInstance();
            _this.skin = _this._assetManager.getSkin("FreeSpinSkin");
            _this._freeSpinControlsView = new FreeSpinControlsViewController_1.FreeSpinControlsViewController();
            _this._reelSet = new SlotsReelSet_2.SlotsReelSet("Symbols", _this._assetManager.getAsset("FreeSpinReelsContainer"), "FreeSpin_");
            _this._symbolOverlayAnimations = new SymbolOverlayAnimations_2.SymbolOverlayAnimations();
            _this._symbolOverlayAnimations.soundNames.setValue("s01", "BaseSymbolS01");
            _this._symbolOverlayAnimations.soundNames.setValue("s02", "BaseSymbolS02");
            _this._symbolOverlayAnimations.soundNames.setValue("s03", "BaseSymbolS03");
            _this._symbolOverlayAnimations.soundNames.setValue("s04", "BaseSymbolS04"); {
                var labelNames = []; {
                    labelNames["15 w01"] = "w01_5x3";
                    labelNames["15 w02"] = "w02_5x3";
                    labelNames["15 s01"] = "s01_5x3";
                    labelNames["15 s02"] = "s02_5x3";
                    labelNames["15 s03"] = "s03_5x3";
                    labelNames["15 s04"] = "s04_5x3";
                    labelNames["15 s05"] = "s05_5x3";
                    labelNames["15 s06"] = "s06_5x3";
                    labelNames["15 s07"] = "s07_5x3";
                    labelNames["15 s08"] = "s08_5x3";
                    labelNames["15 s09"] = "s09_5x3";
                    labelNames["12 w01"] = "w01_4x3";
                    labelNames["12 w02"] = "w02_4x3";
                    labelNames["12 s01"] = "s01_4x3";
                    labelNames["12 s02"] = "s02_4x3";
                    labelNames["12 s03"] = "s03_4x3";
                    labelNames["12 s04"] = "s04_4x3";
                    labelNames["12 s05"] = "s05_4x3";
                    labelNames["12 s06"] = "s06_4x3";
                    labelNames["12 s07"] = "s07_4x3";
                    labelNames["12 s08"] = "s08_4x3";
                    labelNames["12 s09"] = "s09_4x3";
                    labelNames["9 b01"] = "b01_3x3";
                    labelNames["9 w01"] = "w01_3x3";
                    labelNames["9 w02"] = "w02_3x3";
                    labelNames["9 s01"] = "s01_3x3";
                    labelNames["9 s02"] = "s02_3x3";
                    labelNames["9 s03"] = "s03_3x3";
                    labelNames["9 s04"] = "s04_3x3";
                    labelNames["9 s05"] = "s05_3x3";
                    labelNames["9 s06"] = "s06_3x3";
                    labelNames["9 s07"] = "s07_3x3";
                    labelNames["9 s08"] = "s08_3x3";
                    labelNames["9 s09"] = "s09_3x3";
                    labelNames["6 w01"] = "any_2x3";
                    labelNames["6 w02"] = "any_2x3";
                    labelNames["6 s01"] = "any_2x3";
                    labelNames["6 s02"] = "any_2x3";
                    labelNames["6 s03"] = "any_2x3";
                    labelNames["6 s04"] = "any_2x3";
                    labelNames["6 s05"] = "any_2x3";
                    labelNames["6 s06"] = "any_2x3";
                    labelNames["6 s07"] = "any_2x3";
                    labelNames["6 s08"] = "any_2x3";
                    labelNames["6 s09"] = "any_2x3";
                    labelNames["3 w01"] = "any_1x3";
                    labelNames["3 w02"] = "any_1x3";
                    labelNames["3 s01"] = "any_1x3";
                    labelNames["3 s02"] = "any_1x3";
                    labelNames["3 s03"] = "any_1x3";
                    labelNames["3 s04"] = "any_1x3";
                    labelNames["3 s05"] = "any_1x3";
                    labelNames["3 s06"] = "any_1x3";
                    labelNames["3 s07"] = "any_1x3";
                    labelNames["3 s08"] = "any_1x3";
                    labelNames["3 s09"] = "any_1x3";
                }
                _this._symbolOverlayAnimations.labelNames = labelNames;
                _this._symbolOverlayAnimations.numberOfColumns = 5;
                _this._symbolOverlayAnimations.numberOfRows = 3;
                _this._symbolOverlayAnimations.skinName = "FreeSpinSkin.symbolOverlayAnimations";
            }
            _this._messageController = new GenericMessageController_2.GenericMessageController();
            _this._reelsHelper = new ReelsHelper_2.ReelsHelper();
            _this._plaqueController = new GenericPlaqueController_3.GenericPlaqueController();
            _this._winSequencer = new WinSequencer_2.WinSequencer(_this._reelSet, _this.stageName);
            _this._winSequencer.symbolOverlayAnimations = _this._symbolOverlayAnimations;
            var modifiedSymbolNames = new Dictionary_5.default();
            modifiedSymbolNames.setValue("1", "s01");
            modifiedSymbolNames.setValue("2", "s02");
            modifiedSymbolNames.setValue("3", "s03");
            modifiedSymbolNames.setValue("4", "s04");
            modifiedSymbolNames.setValue("5", "s05");
            modifiedSymbolNames.setValue("6", "s06");
            modifiedSymbolNames.setValue("7", "s07");
            modifiedSymbolNames.setValue("8", "s08");
            modifiedSymbolNames.setValue("9", "s09");
            modifiedSymbolNames.setValue("0", "w01");
            modifiedSymbolNames.setValue("B", "b01");
            modifiedSymbolNames.setValue("W", "w01");
            modifiedSymbolNames.setValue("M", "w02");
            _this.selectiveStackingSymbolChanger = new SelectiveStackingSymbolChanger_2.SelectiveStackingSymbolChanger();
            _this.selectiveStackingSymbolChanger.modifiedSymbolNames = modifiedSymbolNames;
            return _this;
        }
        FreeSpinViewController.prototype.init = function(data) {
            if (!this._isInit) {
                this._isInit = true;
                this._reelSet.stripInfoName = this.stageName;
                this._reelSet.populationOutcomeName = this.stageName + ".Reels";
                this._spinStrategies = this.getSpinStrategies(5);
                var dynamicSymbols = this.selectiveStackingSymbolChanger.getSubstituteSymbolNames(data);
                this._symbolOverlayAnimations.init();
                this._reelSet.init(this._spinStrategies, data.paytableResponse.stripsInfo, data.gameLogicResponse.populationOutcomes, this.getPoolSymbols(10), dynamicSymbols);
                this._messageController.init();
                this._plaqueController.init(data);
                this._winSequencer.init(data, this._prizeNames);
                this._superStackedLabel = new LabeledViewController_2.LabeledViewController(this._assetManager.getAsset("stackedSymbolLabel"));
                this._superStackedLabel.init();
                this._superStackedLabel.label = TextManager_5.TextManager.getInstance().getText("superStackedFreeSpin");
            }
            this.setSuperStackedHeader(data);
            this._freeSpinControlsView.init(data);
            this._rollupComplete = true;
            this._firstCycleComplete = true;
            this._freeSpinControlsView.state = FreeSpinControlsViewController_1.ControlsState.Disable;
            this.addEventListeners();
            SoundManager_8.SoundManager.getInstance().execute("onFreeSpinStart");
        };
        FreeSpinViewController.prototype.enableGame = function() {
            console.log("[Freespins enablegame]");
            this._freeSpinControlsView.state = FreeSpinControlsViewController_1.ControlsState.BonusIdle;
        };
        FreeSpinViewController.prototype.getSpinStrategies = function(numberOfReels) {
            var spinStrategies = new Dictionary_5.default();
            for (var reelIndex = 0; reelIndex < numberOfReels; reelIndex++) {
                if (AssetManager_8.AssetManager.getInstance().clientConfigData.assetPack == "desktopmini" ||
                    AssetManager_8.AssetManager.getInstance().clientConfigData.assetPack == "tabletmini") {
                    spinStrategies.setValue("Reel" + reelIndex, new MiniSpinStrategy_2.MiniSpinStrategy());
                } else {
                    spinStrategies.setValue("Reel" + reelIndex, new SpinStrategy_2.SpinStrategy());
                }
            }
            return spinStrategies;
        };
        FreeSpinViewController.prototype.getPoolSymbols = function(symbolsPooled) {
            var pool = new Dictionary_5.default();
            for (var _i = 0, _a = this._symbolNames; _i < _a.length; _i++) {
                var symbolName = _a[_i];
                pool.setValue(symbolName, symbolsPooled);
            }
            return pool;
        };
        FreeSpinViewController.prototype.onBeforeShowStage = function(evt) {
            console.log("[FreeSpinView onBeforeShowStage]");
        };
        FreeSpinViewController.prototype.onSpinButtonClick = function(evt) {
            this.startSpin();
        };
        FreeSpinViewController.prototype.startSpin = function(evt) {
            if (evt === void 0) {
                evt = null;
            }
            console.log("[Freespin start spin]");
            this.clearEvents();
            this._reelsHelper.currentReelIndex = 0;
            this._firstCycleComplete = false;
            this._rollupComplete = false;
            this._freeSpinControlsView.state = FreeSpinControlsViewController_1.ControlsState.Spinning;
            this.nextStage();
            this._spinStarted = true;
            this._reelSet.spin();
            SoundManager_8.SoundManager.getInstance().execute("BonusMusicLoop");
        };
        FreeSpinViewController.prototype.onSkipButtonClick = function(evt) {
            this._winSequencer.skipSequence();
            this._freeSpinControlsView.skipRollup();
        };
        FreeSpinViewController.prototype.onStartGameInitial = function(evt) {
            console.log("[FreeSpinView onStartGameInitial] ");
        };
        FreeSpinViewController.prototype.onBeforeRequest = function(evt) {
            console.log("[FreeSpinView onBeforeRequest]");
            if (this._inProgressStageHit) {
                this._inProgressStageHit = false;
                this.nextStage();
            } else if (this._resetStageHit) {
                this._resetStageHit = false;
            } else {
                this.selectiveStackingSymbolChanger.setSubstituteSymbolNames(this._reelSet, evt.data);
                this._freeSpinControlsView.updateWin(evt.data);
                this.handleAutoSpin();
            }
        };
        FreeSpinViewController.prototype.setSuperStackedHeader = function(data) {
            var symbolId = data.gameLogicResponse.populationOutcomes.getValue("Picker.FreeSpinSymbol").reels.getValue("FreeSpinSymbol").cells[0].symbolId;
            if (this.skin["stackedSymbolPlaque"]["symbolPlaque_S01"] &&
                this.skin["stackedSymbolPlaque"]["symbolPlaque_S02"] &&
                this.skin["stackedSymbolPlaque"]["symbolPlaque_S03"] &&
                this.skin["stackedSymbolPlaque"]["symbolPlaque_S04"]) {
                this.skin["stackedSymbolPlaque"]["symbolPlaque_S01"].visible = false;
                this.skin["stackedSymbolPlaque"]["symbolPlaque_S02"].visible = false;
                this.skin["stackedSymbolPlaque"]["symbolPlaque_S03"].visible = false;
                this.skin["stackedSymbolPlaque"]["symbolPlaque_S04"].visible = false;
                this.skin["stackedSymbolPlaque"]["symbolPlaque_" + symbolId.toUpperCase()].visible = true;
            } else {
                console.log("[FreeSpinView] !!! Asset Error: stackedSymbolPlaque children not found");
            }
        };
        FreeSpinViewController.prototype.onMakeRequest = function(evt) {
            console.log("[FreeSpinView onMakeRequest]");
            var betPerPattern;
            var patternsBet;
            if (evt.data.gameLogicResponse.patternSliderInput) {
                betPerPattern = evt.data.gameLogicResponse.patternSliderInput.betPerPattern;
                patternsBet = evt.data.gameLogicResponse.patternSliderInput.patternsBet;
            } else {
                betPerPattern = evt.data.paytableResponse.patternSliderInfo.betInfo.steps[0];
                patternsBet = evt.data.paytableResponse.patternSliderInfo.patternInfo.steps[0];
            }
            this._msgBus.dispatchEvent(new events_10.events.Event(GameMsgBus_4.GameMsgBus.PLAY_DATA, {
                ActionInput: {
                    Action: "play"
                },
                PatternSliderInput: {
                    BetPerPattern: betPerPattern,
                    PatternsBet: patternsBet
                }
            }));
            this.nextStage();
        };
        FreeSpinViewController.prototype.onResolveStage = function(evt) {
            console.log(evt.data);
            this._reelSet.stripInfoName = this.stageName;
            this._reelSet.populationOutcomeName = this.stageName + ".Reels";
            this._winSequencer.setWinOutcome(evt);
            this._freeSpinControlsView.setWin(evt.data);
            this._freeSpinControlsView.incremenetCount();
            this._reelsHelper.setNewData(evt.data);
            if (evt.data.gameLogicResponse.outcomeDetail.nextStage != this.stageName) {
                this._exitStage = true;
            }
            if (this._spinStarted) {
                this._spinStarted = false;
                var spinDuration = FreeSpinViewController.DEFAULT_SPIN_DURATION.concat();
                spinDuration = this._reelsHelper.getSpinDurationsForAllReels(spinDuration);
                this._reelSet.stopSpin(evt.data.gameLogicResponse.populationOutcomes, spinDuration);
            } else {
                this.nextStage();
            }
        };
        FreeSpinViewController.prototype.onReelStopSpinBegin = function(evt) {
            this._reelsHelper.playReelStopSound();
            this._reelsHelper.currentReelIndex++;
        };
        FreeSpinViewController.prototype.onAllReelStop = function(evt) {
            this.nextStage();
        };
        FreeSpinViewController.prototype.onEndGame = function(evt) {
            console.log("[FreeSpinView onEndGame]");
            this.handleAllWins(evt);
        };
        FreeSpinViewController.prototype.onExitStage = function(evt) {
            console.log("[FreeSpinView onExitStage]");
            SoundManager_8.SoundManager.getInstance().execute("BonusMusicLoopTerm");
            if (evt.data.gameLogicResponse.awardCapOutcome.awardCapExceeded) {
                this.showMaxCapAward(evt);
                this.addTransitionPause();
            } else {
                this.handleWinCelebration(evt);
            }
        };
        FreeSpinViewController.prototype.onInProgressStage = function(evt) {
            console.log("[FreeSpinView onInProgressStage]");
            this.handleAllWins(evt);
        };
        FreeSpinViewController.prototype.handleAllWins = function(evt) {
            if (evt.data.gameLogicResponse.awardCapOutcome.awardCapExceeded) {
                this.showMaxCapAward(evt);
            } else {
                this.handleWinCelebration(evt);
            }
        };
        FreeSpinViewController.prototype.showMaxCapAward = function(evt) {
            this._plaqueController.displayMultiLabeledView(this._plaqueController.maxAwardPlaqueBonus);
            this._freeSpinControlsView.state = FreeSpinControlsViewController_1.ControlsState.Disable;
            this._freeSpinControlsView.updateWin(evt.data);
        };
        FreeSpinViewController.prototype.onStartGameInProgressStage = function(evt) {
            console.log("[FreeSpinView onStartGameInProgressStage]");
            this.nextStage();
        };
        FreeSpinViewController.prototype.onStartGameInProgressNextStage = function(evt) {
            console.log("[FreeSpinView onStartGameInProgressNextStage]");
            this._freeSpinControlsView.updateWin(evt.data);
        };
        FreeSpinViewController.prototype.handleWinCelebration = function(evt) {
            if (this._winSequencer.winCycleHelper.hasPrize()) {
                this._freeSpinControlsView.setPayout(evt.data);
                this._freeSpinControlsView.setRollupSequence();
                this._freeSpinControlsView.state = FreeSpinControlsViewController_1.ControlsState.Rollup;
                this._freeSpinControlsView.rollup.addEventListener(RollupIncrementer_4.RollupIncrementer.ROLLUP_COMPLETE, this.onRollupComplete, this);
                this._winSequencer.winCycle.addEventListener(WinCycle_3.WinCycle.FIRST_CYCLE_DONE, this.onFirstCycleComplete, this);
                this._winSequencer.setWinCelebration(evt, this._freeSpinControlsView.rollup, this._freeSpinControlsView.rollupIndex);
                this._winSequencer.startSequence();
            } else {
                this._firstCycleComplete = true;
                this._rollupComplete = true;
                if (!this._exitStage) {
                    this._freeSpinControlsView.state = FreeSpinControlsViewController_1.ControlsState.Idle;
                    this.nextStage();
                } else {
                    this._freeSpinControlsView.state = FreeSpinControlsViewController_1.ControlsState.BonusTransition;
                    this.addTransitionPause();
                }
            }
        };
        FreeSpinViewController.prototype.onFirstCycleComplete = function(evt) {
            this._firstCycleComplete = true;
            if (!this._exitStage) {
                this.handleAutoSpin();
            } else if (this._rollupComplete) {
                this._freeSpinControlsView.state = FreeSpinControlsViewController_1.ControlsState.BonusTransition;
                this.addTransitionPause();
            }
        };
        FreeSpinViewController.prototype.onRollupComplete = function(evt) {
            this._rollupComplete = true;
            if (!this._exitStage) {
                this._freeSpinControlsView.state = FreeSpinControlsViewController_1.ControlsState.Idle;
                this.nextStage();
            } else {
                this._freeSpinControlsView.state = FreeSpinControlsViewController_1.ControlsState.Disable;
                if (this._firstCycleComplete) {
                    this.addTransitionPause();
                }
            }
        };
        FreeSpinViewController.prototype.handleAutoSpin = function() {
            if (this._firstCycleComplete && this._rollupComplete) {
                this._winSequencer.clearEvents();
                this._autoSpinPauseSeq.addEventListener(ISequenceItem_9.sequencers.SEQUENCE_END, this.startSpin, this);
                this._autoSpinPauseSeq.startSequence();
            }
        };
        FreeSpinViewController.prototype.clearEvents = function() {
            this._winSequencer.clearEvents();
            if (this._winSequencer.winCycle.hasEventListener(WinCycle_3.WinCycle.FIRST_CYCLE_DONE, this.onFirstCycleComplete, this)) {
                this._winSequencer.winCycle.removeEventListener(WinCycle_3.WinCycle.FIRST_CYCLE_DONE, this.onFirstCycleComplete, this);
            }
            if (this._freeSpinControlsView.rollup.hasEventListener(RollupIncrementer_4.RollupIncrementer.ROLLUP_COMPLETE, this.onRollupComplete, this)) {
                this._freeSpinControlsView.rollup.removeEventListener(RollupIncrementer_4.RollupIncrementer.ROLLUP_COMPLETE, this.onRollupComplete, this);
            }
            if (this._autoSpinPauseSeq.hasEventListener(ISequenceItem_9.sequencers.SEQUENCE_END, this.startSpin, this)) {
                this._autoSpinPauseSeq.removeEventListener(ISequenceItem_9.sequencers.SEQUENCE_END, this.startSpin, this);
            }
        };
        FreeSpinViewController.prototype.onBeginNewGame = function(evt) {
            console.log("[FreeSpinView onBeginNewGame]");
            this._freeSpinControlsView.state = FreeSpinControlsViewController_1.ControlsState.Idle;
            this.handleAutoSpin();
        };
        FreeSpinViewController.prototype.onEnterNextStage = function(evt) {
            console.log("[FreeSpinView onEnterNextStage]");
            this._exitStage = false;
            this.clearEvents();
        };
        FreeSpinViewController.prototype.addTransitionPause = function() {
            var transitionPauseSeq = new TimerEventSequenceItem_4.TimerEventSequenceItem(2000);
            var sequenceItems = new Array(transitionPauseSeq);
            var transitionPauseSequence = new LinearSequencer_5.LinearSequencer(sequenceItems, 1);
            transitionPauseSequence.addEventListener(ISequenceItem_9.sequencers.SEQUENCE_END, this.onTransitionPause_complete, this);
            transitionPauseSequence.startSequence();
        };
        FreeSpinViewController.prototype.onTransitionPause_complete = function(evt) {
            evt.target.removeEventListener(ISequenceItem_9.sequencers.SEQUENCE_END, this.onTransitionPause_complete, this);
            this._plaqueController.hideCurrentPlaque();
            this.nextStage();
            SoundManager_8.SoundManager.getInstance().execute("BonusMusicLoopTerm");
        };
        FreeSpinViewController.prototype.onStartButtonClick = function(evt) {
            console.log("[Freespin start button click]");
            if (!this._exitStage) {
                this._inProgressStageHit = true;
                this.startSpin();
            } else {
                this.clearEvents();
                this._freeSpinControlsView.state = FreeSpinControlsViewController_1.ControlsState.BonusTransition;
                this.nextStage();
                SoundManager_8.SoundManager.getInstance().execute("StartButton");
            }
        };
        FreeSpinViewController.prototype.onAbortNextStage = function(evt) {
            console.log("[FreeSpin onAbortNextStage]");
            this._freeSpinControlsView.state = FreeSpinControlsViewController_1.ControlsState.Disable;
            this._reelSet.reset(evt.data.gameLogicResponse.populationOutcomes);
            this.nextStage();
        };
        FreeSpinViewController.prototype.onResetNextStage = function(event) {
            console.log("[FreeSpinView onResetNextStage]");
            this._freeSpinControlsView.state = FreeSpinControlsViewController_1.ControlsState.Idle;
            this._resetStageHit = true;
            this.nextStage();
        };
        FreeSpinViewController.prototype.nextStage = function() {
            console.log("[Freespins Next Stage]");
            this._msgBus.dispatchEvent(new events_10.events.Event(GameMsgBus_4.GameMsgBus.NEXT_STAGE));
        };
        FreeSpinViewController.prototype.addToStage = function(container) {
            container.addChild(this.skin);
            for (var _i = 0, _a = this._skinList; _i < _a.length; _i++) {
                var skinName = _a[_i];
                container.addChild(this._assetManager.getSkin(skinName));
            }
            this.addBusListeners();
        };
        FreeSpinViewController.prototype.removeFromStage = function(container) {
            container.removeChild(this.skin);
            for (var _i = 0, _a = this._skinList; _i < _a.length; _i++) {
                var skinName = _a[_i];
                container.removeChild(this._assetManager.getSkin(skinName));
            }
            this.removeBusListeners();
            this.removeEventListeners();
        };
        FreeSpinViewController.prototype.removeChild = function(childName) {
            this.skin.removeChild(this._assetManager.getSkin(childName));
        };
        Object.defineProperty(FreeSpinViewController.prototype, "enable", {
            get: function() {
                return this._enable;
            },
            set: function(value) {
                if (this._enable != value) {
                    this._enable = value;
                    if (value) {
                        this._freeSpinControlsView.state = FreeSpinControlsViewController_1.ControlsState.Idle;
                    } else {
                        this._freeSpinControlsView.state = FreeSpinControlsViewController_1.ControlsState.Disable;
                    }
                }
            },
            enumerable: true,
            configurable: true
        });
        FreeSpinViewController.prototype.addEventListeners = function() {
            if (this._isInit) {
                this._freeSpinControlsView.addEventListener(FreeSpinControlsViewController_1.FreeSpinControlsViewController.SPIN_BUTTON_CLICK, this.onSpinButtonClick, this);
                this._freeSpinControlsView.addEventListener(FreeSpinControlsViewController_1.FreeSpinControlsViewController.SKIP_BUTTON_CLICK, this.onSkipButtonClick, this);
                this._freeSpinControlsView.addEventListener(FreeSpinControlsViewController_1.FreeSpinControlsViewController.START_BUTTON_CLICK, this.onStartButtonClick, this);
                this._reelSet.addEventListener(SlotsReelSet_2.SlotsReelSet.ALL_REEL_STOP, this.onAllReelStop, this);
                this._reelSet.addEventListener(SlotsReelSet_2.SlotsReelSet.REEL_STOP_SPIN_BEGIN, this.onReelStopSpinBegin, this);
                this._freeSpinControlsView.addEventListeners();
            }
        };
        FreeSpinViewController.prototype.removeEventListeners = function() {
            if (this._isInit) {
                this._freeSpinControlsView.removeEventListener(FreeSpinControlsViewController_1.FreeSpinControlsViewController.SPIN_BUTTON_CLICK, this.onSpinButtonClick, this);
                this._freeSpinControlsView.removeEventListener(FreeSpinControlsViewController_1.FreeSpinControlsViewController.SKIP_BUTTON_CLICK, this.onSkipButtonClick, this);
                this._freeSpinControlsView.removeEventListener(FreeSpinControlsViewController_1.FreeSpinControlsViewController.START_BUTTON_CLICK, this.onStartButtonClick, this);
                this._reelSet.removeEventListener(SlotsReelSet_2.SlotsReelSet.ALL_REEL_STOP, this.onAllReelStop, this);
                this._reelSet.removeEventListener(SlotsReelSet_2.SlotsReelSet.REEL_STOP_SPIN_BEGIN, this.onReelStopSpinBegin, this);
                this._freeSpinControlsView.removeEventListeners();
            }
        };
        FreeSpinViewController.prototype.addBusListeners = function() {
            this._msgBus.addEventListener(GameMsgBus_4.GameMsgBus.START_GAME_INITIAL, this.onStartGameInitial, this);
            this._msgBus.addEventListener(GameMsgBus_4.GameMsgBus.BEFORE_REQUEST, this.onBeforeRequest, this);
            this._msgBus.addEventListener(GameMsgBus_4.GameMsgBus.MAKE_REQUEST, this.onMakeRequest, this);
            this._msgBus.addEventListener(GameMsgBus_4.GameMsgBus.RESOLVE_STAGE, this.onResolveStage, this);
            this._msgBus.addEventListener(GameMsgBus_4.GameMsgBus.END_GAME, this.onEndGame, this);
            this._msgBus.addEventListener(GameMsgBus_4.GameMsgBus.BEGIN_NEW_GAME, this.onBeginNewGame, this);
            this._msgBus.addEventListener(GameMsgBus_4.GameMsgBus.BEFORE_SHOW_STAGE, this.onBeforeShowStage, this);
            this._msgBus.addEventListener(GameMsgBus_4.GameMsgBus.ENTER_NEXT_STAGE, this.onEnterNextStage, this);
            this._msgBus.addEventListener(GameMsgBus_4.GameMsgBus.IN_PROGRESS_STAGE, this.onInProgressStage, this);
            this._msgBus.addEventListener(GameMsgBus_4.GameMsgBus.START_GAME_IN_PROGRESS_STAGE, this.onStartGameInProgressStage, this);
            this._msgBus.addEventListener(GameMsgBus_4.GameMsgBus.START_GAME_IN_PROGRESS_NEXT_STAGE, this.onStartGameInProgressNextStage, this);
            this._msgBus.addEventListener(GameMsgBus_4.GameMsgBus.EXIT_STAGE, this.onExitStage, this);
            this._msgBus.addEventListener(GameMsgBus_4.GameMsgBus.ABORT_NEXT_STAGE, this.onAbortNextStage, this);
            this._msgBus.addEventListener(GameMsgBus_4.GameMsgBus.RESET_NEXT_STAGE, this.onResetNextStage, this);
        };
        FreeSpinViewController.prototype.removeBusListeners = function() {
            this._msgBus.removeEventListener(GameMsgBus_4.GameMsgBus.START_GAME_INITIAL, this.onStartGameInitial, this);
            this._msgBus.removeEventListener(GameMsgBus_4.GameMsgBus.BEFORE_REQUEST, this.onBeforeRequest, this);
            this._msgBus.removeEventListener(GameMsgBus_4.GameMsgBus.MAKE_REQUEST, this.onMakeRequest, this);
            this._msgBus.removeEventListener(GameMsgBus_4.GameMsgBus.RESOLVE_STAGE, this.onResolveStage, this);
            this._msgBus.removeEventListener(GameMsgBus_4.GameMsgBus.END_GAME, this.onEndGame, this);
            this._msgBus.removeEventListener(GameMsgBus_4.GameMsgBus.BEGIN_NEW_GAME, this.onBeginNewGame, this);
            this._msgBus.removeEventListener(GameMsgBus_4.GameMsgBus.BEFORE_SHOW_STAGE, this.onBeforeShowStage, this);
            this._msgBus.removeEventListener(GameMsgBus_4.GameMsgBus.ENTER_NEXT_STAGE, this.onEnterNextStage, this);
            this._msgBus.removeEventListener(GameMsgBus_4.GameMsgBus.IN_PROGRESS_STAGE, this.onInProgressStage, this);
            this._msgBus.removeEventListener(GameMsgBus_4.GameMsgBus.START_GAME_IN_PROGRESS_STAGE, this.onStartGameInProgressStage, this);
            this._msgBus.removeEventListener(GameMsgBus_4.GameMsgBus.START_GAME_IN_PROGRESS_NEXT_STAGE, this.onStartGameInProgressNextStage, this);
            this._msgBus.removeEventListener(GameMsgBus_4.GameMsgBus.EXIT_STAGE, this.onExitStage, this);
            this._msgBus.removeEventListener(GameMsgBus_4.GameMsgBus.ABORT_NEXT_STAGE, this.onAbortNextStage, this);
            this._msgBus.removeEventListener(GameMsgBus_4.GameMsgBus.RESET_NEXT_STAGE, this.onResetNextStage, this);
        };
        return FreeSpinViewController;
    }(events_10.events.EventDispatcher));
    FreeSpinViewController.DEFAULT_SPIN_DURATION = [800, 1100, 1400, 1700, 2000];
    exports.FreeSpinViewController = FreeSpinViewController;
});
define("TransitionViewController", ["require", "exports", "wcgf/messageBus/GameMsgBus", "wcgf/core/AssetManager", "wcgf/core/events", "wcgf/coreComponents/LabeledTextFieldController", "wcgf/coreComponents/LabeledViewController", "wcgf/gameComponents/MovieClipSequenceItem", "wcgf/sequencers/LinearSequencer", "wcgf/sequencers/ISequenceItem", "wcgf/core/TextManager", "wcgf/core/CurrencyFormatter", "wcgf/sequencers/TimerEventSequenceItem"], function(require, exports, GameMsgBus_5, AssetManager_9, events_11, LabeledTextFieldController_3, LabeledViewController_3, MovieClipSequenceItem_5, LinearSequencer_6, ISequenceItem_10, TextManager_6, CurrencyFormatter_3, TimerEventSequenceItem_5) {
    "use strict";
    var TransitionViewController = (function(_super) {
        __extends(TransitionViewController, _super);

        function TransitionViewController() {
            var _this = _super.call(this) || this;
            _this.stageName = "Transition";
            _this._isInit = false;
            _this._enable = false;
            _this._denomination = 0;
            _this._bonusWin = 0;
            _this._isSequenceDone = false;
            _this._isSequenceEnded = false;
            _this._isSequenceStarted = false;
            _this._rgPresentation = false;
            _this._msgBus = GameMsgBus_5.GameMsgBus.getInstance();
            _this._assetManager = AssetManager_9.AssetManager.getInstance();
            _this._skin = _this._assetManager.getSkin("TransitionSkin");
            return _this;
        }
        TransitionViewController.prototype.init = function(data) {
            this._model = data;
            this._isInit = true;
            this._rgPresentation = data.gameConfig ? (data.gameConfig.rgPresentation ? data.gameConfig.rgPresentation : false) : false;
            this._bonusCompleteTransitionOut = this._assetManager.getAsset("bonusCompleteTransitionOut");
            this._pickerS01TransitionOut = this._assetManager.getAsset("pickerS01TransitionOut");
            this._pickerS02TransitionOut = this._assetManager.getAsset("pickerS02TransitionOut");
            this._pickerS03TransitionOut = this._assetManager.getAsset("pickerS03TransitionOut");
            this._pickerS04TransitionOut = this._assetManager.getAsset("pickerS04TransitionOut");
            this.hideAllTransitions();
            this.setTextLabels();
        };
        TransitionViewController.prototype.hideAllTransitions = function(evt) {
            if (evt === void 0) {
                evt = null;
            }
            this.hideTransition(this._bonusCompleteTransitionOut);
            this.hideTransition(this._pickerS01TransitionOut);
            this.hideTransition(this._pickerS02TransitionOut);
            this.hideTransition(this._pickerS03TransitionOut);
            this.hideTransition(this._pickerS04TransitionOut);
            this.hideLabels();
        };
        TransitionViewController.prototype.setTextLabels = function() {
            this._freeGamesLabel = new LabeledViewController_3.LabeledViewController(this._assetManager.getAsset("freeGamesLabel"));
            this._freeGamesLabel.init();
            this._freeGamesLabel.label = TextManager_6.TextManager.getInstance().getText("freeGames");
            this._awardedLabel = new LabeledViewController_3.LabeledViewController(this._assetManager.getAsset("awardedLabel"));
            this._awardedLabel.init();
            this._awardedLabel.label = TextManager_6.TextManager.getInstance().getText("awarded");
            this._superStackedLabel = new LabeledViewController_3.LabeledViewController(this._assetManager.getAsset("superStackedLabel"));
            this._superStackedLabel.init();
            this._superStackedLabel.label = TextManager_6.TextManager.getInstance().getText("superStacked");
            this._freeSpinsAwarded = new LabeledTextFieldController_3.LabeledTextFieldController(this._assetManager.getAsset("freeSpinsAwardedLabel"));
            this._freeSpinsAwarded.init();
            this._congratulationsLabel = new LabeledViewController_3.LabeledViewController(this._assetManager.getAsset("bonusCongratulationsLabel"));
            this._congratulationsLabel.init();
            this._congratulationsLabel.label = TextManager_6.TextManager.getInstance().getText("congratulations");
            this._youWonLabel = new LabeledTextFieldController_3.LabeledTextFieldController(this._assetManager.getAsset("bonusYouWonLabel"));
            this._youWonLabel.init();
            this._youWonLabel.label = TextManager_6.TextManager.getInstance().getText("youWon");
            this._bonusAwardedLabel = new LabeledTextFieldController_3.LabeledTextFieldController(this._assetManager.getAsset("bonusAwardedLabel"));
            this._bonusAwardedLabel.init();
        };
        TransitionViewController.prototype.hideLabels = function() {
            this._assetManager.getAsset("freeSpinsLabels").visible = false;
            this._assetManager.getAsset("bonusLabelComplete").visible = false;
        };
        TransitionViewController.prototype.getPickerTransitionMovieClip = function() {
            var pickLocation = this._model.gameLogicResponse.pickerInput;
            var pickOutcome = this._model.gameLogicResponse.pickerOutcome.getValue(pickLocation);
            var pickerSymbol = pickOutcome.value.toUpperCase();
            var pickSymbolTransition = "_picker" + pickerSymbol + "TransitionOut";
            return this[pickSymbolTransition];
        };
        TransitionViewController.prototype.transitionOut = function() {
            console.log("transition out " + this._model.gameLogicResponse.outcomeDetail.stage + " to " +
                this._model.gameLogicResponse.outcomeDetail.nextStage);
            if (this._model.gameLogicResponse.outcomeDetail.stage == "Picker") {
                this._freeSpinsAwarded.setText("");
                var transitionOutSequenceShow = new MovieClipSequenceItem_5.MovieClipSequenceItem(this.getPickerTransitionMovieClip(), "startFadeIn", "endFadeIn", 1);
                var transitionPauseSeq = new TimerEventSequenceItem_5.TimerEventSequenceItem(3000);
                var transitionOutSequenceHide = new MovieClipSequenceItem_5.MovieClipSequenceItem(this.getPickerTransitionMovieClip(), "startFadeOut", "endFadeOut", 1);
                this._transitionSeqItems = new Array();
                this._transitionSeqItems.push(transitionOutSequenceShow);
                this._transitionSeqItems.push(transitionPauseSeq);
                this._transitionSeqItems.push(transitionOutSequenceHide);
                this._transitionSequencer = new LinearSequencer_6.LinearSequencer(this._transitionSeqItems);
                transitionOutSequenceShow.addEventListener(ISequenceItem_10.sequencers.SEQUENCE_END, this.showBonusText, this);
                transitionPauseSeq.addEventListener(ISequenceItem_10.sequencers.SEQUENCE_END, this.hideBonusText, this);
                this._transitionSequencer.addEventListener(ISequenceItem_10.sequencers.SEQUENCE_END, this.onTransitionOutEnd, this);
                this._transitionSequencer.startSequence();
            } else if (this._model.gameLogicResponse.outcomeDetail.stage == "FreeSpin") {
                var transitionOutSequenceShow = new MovieClipSequenceItem_5.MovieClipSequenceItem(this._bonusCompleteTransitionOut, "startFadeIn", "endFadeIn", 1);
                var transitionPauseSeq = new TimerEventSequenceItem_5.TimerEventSequenceItem(2000);
                var transitionOutSequenceHide = new MovieClipSequenceItem_5.MovieClipSequenceItem(this._bonusCompleteTransitionOut, "startFadeOut", "endFadeOut", 1);
                this._transitionSeqItems = new Array();
                this._transitionSeqItems.push(transitionOutSequenceShow);
                this._transitionSeqItems.push(transitionPauseSeq);
                this._transitionSeqItems.push(transitionOutSequenceHide);
                this._transitionSequencer = new LinearSequencer_6.LinearSequencer(this._transitionSeqItems);
                transitionOutSequenceShow.addEventListener(ISequenceItem_10.sequencers.SEQUENCE_END, this.showBonusText, this);
                transitionPauseSeq.addEventListener(ISequenceItem_10.sequencers.SEQUENCE_END, this.hideBonusText, this);
                this._transitionSequencer.addEventListener(ISequenceItem_10.sequencers.SEQUENCE_END, this.onTransitionOutEnd, this);
                this._transitionSequencer.startSequence();
            } else {
                this.dispatchComplete();
            }
        };
        TransitionViewController.prototype.showBonusText = function(evt) {
            evt.target.removeEventListener(ISequenceItem_10.sequencers.SEQUENCE_START, this.showBonusText, this);
            if (this._model.gameLogicResponse.outcomeDetail.stage == "Picker") {
                var freeSpinOutcome = this._model.gameLogicResponse.freeSpinOutcomes.getValue("");
                var spinsAwarded = freeSpinOutcome.awarded;
                this._freeSpinsAwarded.setText(spinsAwarded.toString());
                this._assetManager.getAsset("freeSpinsLabels").visible = true;
            } else if (this._model.gameLogicResponse.outcomeDetail.stage == "FreeSpin") {
                var isAboveBet = true;
                if (this._model != null && this._model.gameLogicResponse.prizeOutcomes.getValue("Game.Total")) {
                    this._bonusWin = this._model.gameLogicResponse.prizeOutcomes.getValue("Game.Total").pay;
                    var totalBet = this._model.gameLogicResponse.patternSliderInput.betPerPattern * this._model.gameLogicResponse.patternSliderInput.patternsBet;
                    isAboveBet = this._bonusWin > totalBet;
                }
                if (this._model != null && this._model.paytableResponse != null &&
                    this._model.paytableResponse.denominationList != null &&
                    this._model.paytableResponse.denominationList.length > 0) {
                    this._denomination = this._model.paytableResponse.denominationList[0].value;
                }
                if (this._bonusWin <= 0) {
                    this._congratulationsLabel.label = "";
                    this._youWonLabel.label = TextManager_6.TextManager.getInstance().getText("bonusComplete");
                    this._bonusAwardedLabel.setText("");
                } else {
                    if (!isAboveBet && this._rgPresentation) {
                        this._congratulationsLabel.label = "";
                    }
                    this._bonusAwardedLabel.setText(CurrencyFormatter_3.CurrencyFormatter.getInstance().format(this._bonusWin, this._denomination));
                }
                this._assetManager.getAsset("bonusLabelComplete").visible = true;
            }
        };
        TransitionViewController.prototype.hideBonusText = function(evt) {
            this.hideLabels();
            this.dispatchComplete();
        };
        TransitionViewController.prototype.onTransitionOutEnd = function(evt) {
            this._transitionSequencer.removeEventListener(ISequenceItem_10.sequencers.SEQUENCE_END, this.onTransitionOutEnd, this);
            this.hideAllTransitions();
        };
        TransitionViewController.prototype.transitionIn = function() {
            this.dispatchComplete();
        };
        TransitionViewController.prototype.startSequence = function(forceRestart) {
            if (forceRestart === void 0) {
                forceRestart = false;
            }
            if (forceRestart || !this._isSequenceStarted) {
                this.resetSequence();
                this._isSequenceStarted = true;
                this.dispatchEvent(new events_11.events.Event(ISequenceItem_10.sequencers.SEQUENCE_START, null, this));
                this._transitionSequencer.addEventListener(ISequenceItem_10.sequencers.SEQUENCE_END, this.onTransitionOutEnd, this);
                this._transitionSequencer.startSequence();
            }
        };
        TransitionViewController.prototype.dispatchComplete = function() {
            this._isSequenceDone = true;
            this.dispatchEvent(new events_11.events.Event(ISequenceItem_10.sequencers.SEQUENCE_DONE, null, this));
            this._isSequenceStarted = false;
            this._isSequenceEnded = true;
            this.dispatchEvent(new events_11.events.Event(ISequenceItem_10.sequencers.SEQUENCE_END, null, this));
        };
        TransitionViewController.prototype.resetSequence = function() {
            this._isSequenceDone = false;
            this._isSequenceEnded = false;
            this._isSequenceStarted = false;
            if (this._transitionSequencer != null) {
                this._transitionSequencer.resetSequence();
            }
        };
        TransitionViewController.prototype.hideTransition = function(mc) {
            mc.gotoAndStop("end");
        };
        TransitionViewController.prototype.addToStage = function(stage) {
            stage.addChild(this._skin);
            this.enable = true;
        };
        TransitionViewController.prototype.removeFromStage = function(stage) {
            stage.removeChild(this._skin);
            this.enable = false;
        };
        Object.defineProperty(TransitionViewController.prototype, "enable", {
            get: function() {
                return this._enable;
            },
            set: function(value) {
                if (this._enable != value) {
                    this._enable = value;
                }
            },
            enumerable: true,
            configurable: true
        });
        return TransitionViewController;
    }(events_11.events.EventDispatcher));
    exports.TransitionViewController = TransitionViewController;
});
define("WebFontHelper", ["require", "exports", "wcgf/core/events", "wcgf/vendors/typescript_collections/util", "wcgf/vendors/webfontloader/webfont"], function(require, exports, events_12, util_1, WebFont) {
    "use strict";
    var WebFontHelper = (function(_super) {
        __extends(WebFontHelper, _super);

        function WebFontHelper() {
            var _this = _super.call(this) || this;
            _this.fontServiceHandlers = {
                custom: _this.handleCustomService,
                google: _this.handleGoogleService,
                typekit: null,
                fontdeck: null,
                monotype: null
            };
            _this.onLoadComplete = function() {
                _this.dispatchEvent(new events_12.events.Event(WebFontHelper.FONT_LOAD_COMPLETE, null, _this));
            };
            _this.onLoadFail = function() {
                _this.dispatchEvent(new events_12.events.Event(WebFontHelper.FONT_LOAD_COMPLETE, null, _this));
            };
            _this.onFontInactive = function(familyName, fvd) {
                console.log("WebFont font inactive: " + familyName + ":" + fvd);
                _this.dispatchEvent(new events_12.events.Event(WebFontHelper.FONT_ERROR, {
                    familyName: familyName,
                    fvd: fvd
                }, _this));
            };
            _this.initWebFontConfig();
            return _this;
        }
        WebFontHelper.prototype.initWebFontConfig = function() {
            this.webFontConfig = {
                timeout: 20000,
                active: this.onLoadComplete,
                inactive: this.onLoadFail,
                fontinactive: this.onFontInactive
            };
        };
        WebFontHelper.prototype.parse = function(data) {
            for (var serviceName in this.fontServiceHandlers) {
                if (util_1.has(this.fontServiceHandlers, serviceName) && data[serviceName] != null) {
                    if (this.fontServiceHandlers[serviceName] != null) {
                        this.fontServiceHandlers[serviceName].call(this, data[serviceName]);
                    } else {
                        console.warn("No framework support for webfont service '" + serviceName + "'");
                    }
                }
            }
        };
        WebFontHelper.prototype.handleGoogleService = function(serviceData) {
            if (this.webFontConfig.google == null) {
                this.webFontConfig.google = {
                    families: []
                };
            }
            if (typeof serviceData !== "object") {
                throw new Error("Google font information is invalid");
            } else if (serviceData instanceof Array) {
                this.addGoogleFamilies(serviceData);
            } else {
                this.addGoogleFamilies(serviceData.families);
                if (serviceData.text != null) {
                    if (typeof serviceData.text !== "string") {
                        throw new Error("Google font explicit character data is invalid");
                    }
                    this.webFontConfig.google.text = serviceData.text;
                }
            }
        };
        WebFontHelper.prototype.addGoogleFamilies = function(familiesData) {
            this.webFontConfig.google.families =
                this.validateAndCombineArrays(this.webFontConfig.google.families, familiesData, "Google font families");
        };
        WebFontHelper.prototype.validateAndCombineArrays = function(master, contributor, errorId) {
            if (!(contributor instanceof Array) || contributor.length == 0) {
                throw new Error("Invalid list of " + errorId);
            }
            if (master.length == 0) {
                master = contributor;
            } else {
                master = master.concat(contributor);
            }
            return master;
        };
        WebFontHelper.prototype.handleCustomService = function(serviceData) {
            if (this.webFontConfig.custom == null) {
                this.webFontConfig.custom = {};
            }
            this.addCustomFamilies(serviceData.families);
            this.addCustomUrls(serviceData.urls);
            this.addCustomTestStrings(serviceData.testStrings);
        };
        WebFontHelper.prototype.addCustomFamilies = function(familiesData) {
            if (this.webFontConfig.custom.families == null) {
                this.webFontConfig.custom.families = [];
            }
            this.webFontConfig.custom.families =
                this.validateAndCombineArrays(this.webFontConfig.custom.families, familiesData, "custom font families");
        };
        WebFontHelper.prototype.addCustomUrls = function(urlsData) {
            if (this.webFontConfig.custom.urls == null) {
                this.webFontConfig.custom.urls = [];
            }
            this.webFontConfig.custom.urls =
                this.validateAndCombineArrays(this.webFontConfig.custom.urls, urlsData, "custom font urls");
        };
        WebFontHelper.prototype.addCustomTestStrings = function(testStringsData) {
            if (testStringsData == null)
                return;
            if (typeof testStringsData !== "object") {
                throw new Error("Invalid list of custom font test strings");
            }
            var newTestStrings = this.webFontConfig.custom.testStrings;
            if (newTestStrings == null) {
                newTestStrings = {};
            }
            for (var testFamilyName in testStringsData) {
                if (util_1.has(testStringsData, testFamilyName)) {
                    newTestStrings[testFamilyName] =
                        this.mergeTestStrings(newTestStrings[testFamilyName], testStringsData[testFamilyName]);
                }
            }
            this.webFontConfig.custom.testStrings = newTestStrings;
        };
        WebFontHelper.prototype.mergeTestStrings = function(master, contributor) {
            if (typeof contributor !== "string") {
                throw new Error("Invalid test string format: " + contributor);
            }
            if (master == null) {
                return contributor;
            } else {
                return master + contributor;
            }
        };
        WebFontHelper.prototype.loadFonts = function() {
            WebFont.load(this.webFontConfig);
        };
        return WebFontHelper;
    }(events_12.events.EventDispatcher));
    WebFontHelper.FONT_LOAD_COMPLETE = "WebFontHelper_FontLoadComplete";
    WebFontHelper.FONT_ERROR = "WebFontHelper_FontError";
    exports.WebFontHelper = WebFontHelper;
});
define("GameConfigDataTranslator", ["require", "exports"], function(require, exports) {
    "use strict";
    var GameConfigDataTranslator = (function() {
        function GameConfigDataTranslator() {
            this._gameConfig = null;
        }
        GameConfigDataTranslator.prototype.translate = function(platformData, translatedData) {
            if (platformData != null && platformData.gameConfig != null) {
                this._gameConfig = platformData.gameConfig;
            }
            translatedData.gameConfig = this._gameConfig;
            return translatedData;
        };
        return GameConfigDataTranslator;
    }());
    exports.GameConfigDataTranslator = GameConfigDataTranslator;
});
define("Game", ["require", "exports", "wcgf/messageBus/GameMsgBus", "wcgf/core/events", "wcgf/core/AssetManager", "wcgf/gameComponents/GameController", "wcgf/dataTranslators/GleDataTranslator", "BaseGameViewController", "stages/freeSpin/FreeSpinViewController", "TransitionViewController", "wcgf/sequencers/ISequenceItem", "wcgf/gameComponents/StageController", "WebFontHelper", "GameConfigDataTranslator"], function(require, exports, GameMsgBus_6, events_13, AssetManager_10, GameController_1, GleDataTranslator_1, BaseGameViewController_1, FreeSpinViewController_1, TransitionViewController_1, ISequenceItem_11, StageController_1, WebFontHelper_1, GameConfigDataTranslator_1) {
    "use strict";
    var Game = (function(_super) {
        __extends(Game, _super);

        function Game() {
            var _this = _super.call(this) || this;
            _this._lockOrientation = false;
            _this._assetManager = AssetManager_10.AssetManager.getInstance();
            return _this;
        }
        Game.prototype.handleFonts = function() {
            if (this.assetMap.fonts != null) {
                this._webFontHelper = new WebFontHelper_1.WebFontHelper();
                this._webFontHelper.addEventListener(WebFontHelper_1.WebFontHelper.FONT_LOAD_COMPLETE, this.onWebFontLoadComplete, this);
                this._webFontHelper.parse(this.assetMap.fonts);
                this._webFontHelper.loadFonts();
                return false;
            }
            return true;
        };
        Game.prototype.onWebFontLoadComplete = function(evt) {
            this._webFontHelper.removeEventListener(WebFontHelper_1.WebFontHelper.FONT_LOAD_COMPLETE, this.onWebFontLoadComplete, this);
            this._webFontHelper = null;
            this.setFontLoaded();
        };
        Game.prototype.onMsgBusInitialize = function(evt) {
            _super.prototype.onMsgBusInitialize.call(this, evt);
            this.msgBus.dataTranslators.push(new GleDataTranslator_1.GleDataTranslator(), new GameConfigDataTranslator_1.GameConfigDataTranslator());
        };
        Game.prototype.onGameInit = function(evt) {
            _super.prototype.onGameInit.call(this, evt);
            console.log(" ========= GOLDEN GODDESS =========");
            this._baseGame = new BaseGameViewController_1.BaseGameViewController();
            this._freeSpin = new FreeSpinViewController_1.FreeSpinViewController();
            this._transition = new TransitionViewController_1.TransitionViewController();
            this._gameContainer = new createjs.Container;
            this.stage.addChild(this._gameContainer);
            this._transitionContainer = new createjs.Container;
            this.stage.addChild(this._transitionContainer);
            this.viewHandler(evt);
            this.msgBus.dispatchEvent(new events_13.events.Event(GameMsgBus_6.GameMsgBus.GAME_INIT_DONE, {
                version: {
                    gameVersion: "1,0",
                    gleVersion: "1.0"
                }
            }));
            StageController_1.StageController.getInstance().addEventListener(StageController_1.StageController.ON_ENABLE_GAME, this.enableGame, this);
            AssetManager_10.AssetManager.getInstance().addEventListener(AssetManager_10.AssetManager.ORIENTATION_CHANGE, this.onOrientationChange, this);
        };
        Game.prototype.onBeforeShowStage = function(evt) {
            console.log("[GameView onBeforeShowStage]");
            this.viewHandler(evt);
            this._currentStageView.enable = false;
            this.checkOrientationLock();
            _super.prototype.onBeforeShowStage.call(this, evt);
            this.nextStage();
        };
        Game.prototype.onBeforeRequest = function(evt) {
            _super.prototype.onBeforeRequest.call(this, evt);
        };
        Game.prototype.onStartGameInitial = function(evt) {
            _super.prototype.onStartGameInitial.call(this, evt);
        };
        Game.prototype.enableGame = function() {
            StageController_1.StageController.getInstance().removeEventListener(StageController_1.StageController.ON_ENABLE_GAME, this.enableGame, this);
            this._currentStageView.enable = true;
            if (this._nextStage == this._baseGame.stageName) {
                this._baseGame.enableGame();
            } else if (this._nextStage == this._freeSpin.stageName) {
                this._freeSpin.enableGame();
            }
        };
        Game.prototype.onEnterNextStage = function(evt) {
            _super.prototype.onEnterNextStage.call(this, evt);
            console.log("[GameView onEnterNextStage]");
            this._lockOrientation = false;
            this._transition.addToStage(this._transitionContainer);
            this.stage.update();
            this._transition.init(evt.data);
            this._transition.addEventListener(ISequenceItem_11.sequencers.SEQUENCE_END, this.transitionOutDone, this);
            this._exitStageEvent = evt;
            this._transition.transitionOut();
            this.checkOrientationLock();
        };
        Game.prototype.onExitStage = function(evt) {
            console.log("[GameView onExitStage]");
            _super.prototype.onExitStage.call(this, evt);
        };
        Game.prototype.transitionOutDone = function(evt) {
            console.log("[GameView transition out done]");
            this._transition.removeEventListener(ISequenceItem_11.sequencers.SEQUENCE_END, this.transitionOutDone, this);
            this.viewHandler(this._exitStageEvent);
            this._transition.addEventListener(ISequenceItem_11.sequencers.SEQUENCE_END, this.transitionInDone, this);
            this._transition.transitionIn();
        };
        Game.prototype.transitionInDone = function(evt) {
            this._transition.removeEventListener(ISequenceItem_11.sequencers.SEQUENCE_END, this.transitionInDone, this);
            if (this._currentStageView == this._baseGame) {
                this._baseGame.handleEndGame(this._exitStageEvent);
            } else {
                this.nextStage();
            }
        };
        Game.prototype.viewHandler = function(evt) {
            this._nextStage = evt.data.gameLogicResponse.outcomeDetail.nextStage;
            console.log("-------- CHANGING STAGE TO: " + this._nextStage);
            if (this._currentStageView != null) {
                this._currentStageView.removeFromStage(this._gameContainer);
            }
            switch (this._nextStage) {
                case this._baseGame.stageName:
                    this._currentStageView = this._baseGame;
                    this._freeSpin.removeFromStage(this._gameContainer);
                    this._baseGame.addToStage(this._gameContainer);
                    this._baseGame.enable = true;
                    this._baseGame.picker.enable = false;
                    this._freeSpin.enable = false;
                    this.stage.update();
                    this._currentStageView.init(evt.data);
                    this._baseGame.picker.enable = false;
                    break;
                case this._baseGame.picker.stageName:
                    this._currentStageView = this._baseGame.picker;
                    this._freeSpin.removeFromStage(this._gameContainer);
                    this._baseGame.addToStage(this._gameContainer);
                    this.stage.update();
                    this._currentStageView.init(evt.data);
                    this._baseGame.init(evt.data);
                    this._baseGame.enable = false;
                    this._freeSpin.enable = false;
                    this._baseGame.picker.enable = true;
                    break;
                case this._freeSpin.stageName:
                    this._currentStageView = this._freeSpin;
                    this._baseGame.removeFromStage(this._gameContainer);
                    this._freeSpin.addToStage(this._gameContainer);
                    this._baseGame.enable = false;
                    this._baseGame.picker.enable = false;
                    this.stage.update();
                    this._currentStageView.init(evt.data);
                    this._freeSpin.enable = true;
                default:
                    break;
            }
        };
        Game.prototype.onOrientationChange = function(evt) {
            this.checkOrientationLock();
        };
        Game.prototype.checkOrientationLock = function() {
            if (this.clientConfigData.assetPack == "mobile") {
                if (this._lockOrientation &&
                    AssetManager_10.AssetManager.getInstance().getOrientation() == "portrait") {
                    this.setPause(true);
                } else if (AssetManager_10.AssetManager.getInstance().getOrientation() == "landscape") {
                    this.setPause(false);
                }
            }
            if (this.clientConfigData.assetPack == "tablet") {
                if (AssetManager_10.AssetManager.getInstance().getOrientation() == "portrait") {
                    this.setPause(true);
                } else if (AssetManager_10.AssetManager.getInstance().getOrientation() == "landscape") {
                    this.setPause(false);
                }
            }
        };
        Game.prototype.nextStage = function() {
            this.msgBus.dispatchEvent(new events_13.events.Event(GameMsgBus_6.GameMsgBus.NEXT_STAGE));
        };
        return Game;
    }(GameController_1.GameController));
    exports.Game = Game;
    new Game();
});