define("reels", ["viewBuilderApi", "componentmodelComponentApi", "clientkernelLoaderApi", "slotModelApi", "displayEngineApi", "reelsApi", "clientkernelTestableApi", "displayEngineUtils", "gameLayoutApi", "clientkernelEventbusApi", "clientkernelModulesApi", "moneyApi"],
    function(viewBuilderApi, componentmodelComponentApi, clientkernelLoaderApi, slotModelApi, displayEngineApi, reelsApi, clientkernelTestableApi, displayEngineUtils, gameLayoutApi, clientkernelEventbusApi, clientkernelModulesApi, moneyApi) {
        "use strict";

        function $iterator(o) {
            if (o instanceof Array) return function() {
                return {
                    cur: 0,
                    arr: o,
                    hasNext: function() {
                        return this.cur < this.arr.length;
                    },
                    next: function() {
                        return this.arr[this.cur++];
                    }
                };
            };
            return typeof(o.iterator) == 'function' ? $bind(o, o.iterator) : o.iterator;
        };;
        var $fid = 0;

        function $bind(o, m) {
            if (m == null) return null;
            if (m.__id__ == null) m.__id__ = $fid++;
            var f;
            if (o.hx__closures__ == null) o.hx__closures__ = {};
            else f = o.hx__closures__[m.__id__];
            if (f == null) {
                f = function() {
                    return f.method.apply(f.scope, arguments);
                };
                f.scope = o;
                f.method = m;
                o.hx__closures__[m.__id__] = f;
            }
            return f;
        };
        var $_;
        var $estr = function() {
            return _hcmn_.js_Boot.__string_rec(this, '');
        };
        if (typeof haxe == 'undefined') {
            var haxe = {};
        };

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

            get: function(k) {
                return {
                    arguments: ["*"],
                    returns: "null"
                };
            }
        };
        if (typeof reels == 'undefined') {
            var reels = {};
        };
        reels.Activator = function(context) {};
        reels.Activator = ck_implements(reels.Activator, clientkernelModulesApi.IModuleActivator);
        reels.Activator.__interfaces__ = [clientkernelModulesApi.IModuleActivator];
        reels.Activator.__name__ = ["reels", "Activator"];
        reels.Activator.prototype.start = function(context) {
            context.getServiceTracker([displayEngineApi.IDisplayProvider, clientkernelTestableApi.ITestable, viewBuilderApi.IViewBuilderFactory]).then(function(context1) {
                reels.ExternalService.initialize(context1);
                context1.registerService(new reels.ReelFactory(context1.getAnyService(viewBuilderApi.IViewBuilderFactory, null)), reelsApi.ReelsDeclaration, null);
            });
        };
        reels.Activator.prototype.stop = function(context) {};
        reels.Activator.main = function() {};
        reels.Activator.prototype.__class__ = reels.Activator;
        reels.ExternalService = function() {};
        reels.ExternalService.__name__ = ["reels", "ExternalService"];
        reels.ExternalService.displayProvider = null;
        reels.ExternalService.assetRegistry = null;
        reels.ExternalService.loadedAssets = null;
        reels.ExternalService.testableLogger = null;
        reels.ExternalService.initialize = function(context) {
            reels.ExternalService.displayProvider = context.getAnyService(displayEngineApi.IDisplayProvider, null);
            reels.ExternalService.assetRegistry = context.getAnyService(clientkernelLoaderApi.IAssetRegistry, null);
            var testable = context.getAnyService(clientkernelTestableApi.ITestable, null);
            reels.ExternalService.testableLogger = testable.getLogger(context);
        };
        reels.ExternalService.loadConfig = function(config_id, configCallback) {
            reels.ExternalService.assetRegistry.getAsset(config_id).getContent().then(function(data) {
                configCallback(data);
            });
        };
        reels.ExternalService.prototype.__class__ = reels.ExternalService;
        reels.Reel = function(pos, parent, stripes_arr) {
            this.component = parent;
            this.pos = pos;
            this.view = new reels.ReelView(pos, parent.config);
            parent.view.addReel(this);
            this.state = reels.ReelState.IDLE;
            this.animator = new reels.ReelAnimator(this, parent.config, stripes_arr);
        };
        reels.Reel.__name__ = ["reels", "Reel"];
        reels.Reel.prototype.pos = null;
        reels.Reel.prototype.view = null;
        reels.Reel.prototype.animator = null;
        reels.Reel.prototype.component = null;
        reels.Reel.prototype.state = null;
        reels.Reel.prototype.updateReel = function(elapsed_ms, current_time) {
            if (this.state != reels.ReelState.IDLE) this.animator.updateReel(elapsed_ms, current_time);
        };
        reels.Reel.prototype.start = function(stripe_layer_id) {
            this.view.setAllVisible();
            this.animator.start(stripe_layer_id);
        };
        reels.Reel.prototype.onReelStopped = function() {
            this.component.onReelStopped(this.pos);
        };
        reels.Reel.prototype.onSpinStopped = function() {
            this.component.onSpinStopped();
        };
        reels.Reel.prototype.__class__ = reels.Reel;
        reels.ReelAnimator = function(reel, config, stripes_arr) {
            this.stopped = false;
            this.reelPos = 0;
            this.reelIndex = 0;
            this.config = config;
            this.reel = reel;
            this.reel_config = config.reels[reel.pos];
            this.default_speed_px_ms = this.reel_config.defaultSpeed * this.reel_config.cellHeight * 0.001;
            this.tension_speed_px_ms = this.reel_config.extendedSpinSpeed * this.reel_config.cellHeight * 0.001;
            this.reelPicture = new reels.ReelPicture();
            this.stoppingFunction = new reels.CubicSpline(this.reel_config.stoppingFunction, this.reel_config.cellHeight);
            this.startingFunction = new reels.CubicSpline(this.reel_config.startingFunction, this.reel_config.cellHeight);
            this.stripes = [];
            var _g1 = 0;
            var _g = stripes_arr.length;
            while (_g1 < _g) {
                var i = _g1++;
                this.stripes.push(stripes_arr[i].symbols);
            }
        };
        reels.ReelAnimator.__name__ = ["reels", "ReelAnimator"];
        reels.ReelAnimator.prototype.reel = null;
        reels.ReelAnimator.prototype.config = null;
        reels.ReelAnimator.prototype.default_speed_px_ms = null;
        reels.ReelAnimator.prototype.tension_speed_px_ms = null;
        reels.ReelAnimator.prototype.reelPicture = null;
        reels.ReelAnimator.prototype.reelIndex = null;
        reels.ReelAnimator.prototype.reelPos = null;
        reels.ReelAnimator.prototype.stripes = null;
        reels.ReelAnimator.prototype.active_stripe = null;
        reels.ReelAnimator.prototype.used_stripe = null;
        reels.ReelAnimator.prototype.used_stripe_length = null;
        reels.ReelAnimator.prototype.used_stripe_length_px = null;
        reels.ReelAnimator.prototype.buffer = null;
        reels.ReelAnimator.prototype.stopPosition = null;
        reels.ReelAnimator.prototype.bufferIndex = null;
        reels.ReelAnimator.prototype.bufferPos = null;
        reels.ReelAnimator.prototype.stopped = null;
        reels.ReelAnimator.prototype.lastStopReelPos = null;
        reels.ReelAnimator.prototype.reel_config = null;
        reels.ReelAnimator.prototype.stoppingFunction = null;
        reels.ReelAnimator.prototype.startingFunction = null;
        reels.ReelAnimator.prototype.stopDuration = null;
        reels.ReelAnimator.prototype.startDuration = null;
        reels.ReelAnimator.prototype.stop_time_bookmark = null;
        reels.ReelAnimator.prototype.start_time_bookmark = null;
        reels.ReelAnimator.prototype.stop_time_buffer_pos = null;
        reels.ReelAnimator.prototype.start_time_buffer_pos = null;
        reels.ReelAnimator.prototype.time1 = null;
        reels.ReelAnimator.prototype.dist1 = null;
        reels.ReelAnimator.prototype.time2 = null;
        reels.ReelAnimator.prototype.dist2 = null;
        reels.ReelAnimator.prototype.time3 = null;
        reels.ReelAnimator.prototype.dist3 = null;
        reels.ReelAnimator.prototype.total_stopping_time = null;
        reels.ReelAnimator.prototype.total_starting_time = null;
        reels.ReelAnimator.prototype.outcomeExitDist = null;
        reels.ReelAnimator.prototype.outcomeEnterDist = null;
        reels.ReelAnimator.prototype.currentTime = null;
        reels.ReelAnimator.prototype.forceReelPicture = function(picture) {
            this.reelPicture.cells = picture.slice();
            while (this.reelPicture.cells.length < this.config.inGameRPSize) {
                var len = this.reelPicture.cells.length;
                var dif = this.config.inGameRPSize % len;
                if (dif == 1) {
                    var symbol_id = this.reelPicture.cells[len - 1];
                    var block = this.config.symbolMap.get(symbol_id).block;
                    if (block != null) {
                        var symbolInBlock = _hcmn_.HxOverrides.lastIndexOf(block, symbol_id, block.length - 1) + 1;
                        if (symbolInBlock == block.length) this.reelPicture.cells.push(this.getRandomNonBlockSymbol());
                        else this.reelPicture.cells.push(block[symbolInBlock]);
                    } else this.reelPicture.cells.push(this.getRandomNonBlockSymbol());
                } else this.reelPicture.cells.unshift(this.getRandomNonBlockSymbol());
            }
            this.reelPicture.offset = 0;
            this.reel.view.update(this.reelPicture);
        };
        reels.ReelAnimator.prototype.activateReelStripe = function(stripe_id) {
            this.active_stripe = stripe_id;
            this.setUsedStripe();
        };
        reels.ReelAnimator.prototype.changeReelState = function(state) {
            this.reel.state = state;
            this.setUsedStripe();
        };
        reels.ReelAnimator.prototype.setUsedStripe = function() {
            var _g = this.reel.state;
            switch (_g[1]) {
                case 0:
                case 2:
                    this.used_stripe = this.stripes[this.active_stripe];
                    break;
                case 1:
                case 3:
                    this.used_stripe = this.buffer;
                    break;
                default:
                    this.used_stripe = this.stripes[this.active_stripe];
            }
            this.used_stripe_length = this.used_stripe.length;
            this.used_stripe_length_px = this.used_stripe_length * this.reel_config.cellHeight;
        };
        reels.ReelAnimator.prototype.calculateReelPicture = function(stripe_index, stripe_pos) {
            this.reelPicture.cells = this.getImageFromUsedStripe(stripe_index);
            this.reelPicture.offset = stripe_pos % this.reel_config.cellHeight;
            this.reel.view.update(this.reelPicture);
        };
        reels.ReelAnimator.prototype.getImageFromUsedStripe = function(stripe_index) {
            var image = [];
            var _g1 = 0;
            var _g = this.config.inGameRPSize;
            while (_g1 < _g) {
                var i = _g1++;
                var index = this.checkIndex(stripe_index + i - 1, this.used_stripe_length);
                image[i] = this.used_stripe[index];
            }
            return image;
        };
        reels.ReelAnimator.prototype.getImageFromStripe = function(stripe_index, stripe) {
            var arr_len = stripe.length;
            var image = [];
            var _g1 = 0;
            var _g = this.config.inGameRPSize;
            while (_g1 < _g) {
                var i = _g1++;
                var index = this.checkIndex(stripe_index + i - 1, arr_len);
                image[i] = stripe[index];
            }
            return image;
        };
        reels.ReelAnimator.prototype.stop = function(img, desiredTimeToStop, firstReelInTensionTime) {
            if (firstReelInTensionTime != 0) {
                this.time1 = firstReelInTensionTime;
                this.dist1 = this.time1 * this.default_speed_px_ms;
                this.time2 = desiredTimeToStop - this.time1 - this.stoppingFunction.total_time;
                this.dist2 = this.time2 * this.tension_speed_px_ms | 0;
            } else {
                this.time2 = 0;
                this.dist2 = 0;
                this.time1 = desiredTimeToStop - this.stoppingFunction.total_time;
                this.dist1 = this.time1 * this.default_speed_px_ms;
            }
            var symbols_total = _hcmn_.Math.ceil((this.dist1 + this.dist2 + this.stoppingFunction.distance) / this.reel_config.cellHeight);
            if (symbols_total < img.length) symbols_total = img.length;
            var offset;
            if (this.config.bleedOn) offset = 0;
            else offset = 1;
            var total_dist = (symbols_total + offset) * this.reel_config.cellHeight + this.reelPicture.offset;
            this.dist1 = total_dist - this.stoppingFunction.distance - this.dist2;
            this.time1 = this.dist1 / this.default_speed_px_ms | 0;
            this.buffer = [];
            var stopPositionFound = this.findStopPositionIndex(img);
            if (stopPositionFound) {
                this.buffer.push(this.used_stripe[this.checkIndex(this.reelIndex - 3, this.used_stripe_length)]);
                this.buffer.push(this.used_stripe[this.checkIndex(this.reelIndex - 2, this.used_stripe_length)]);
                this.buffer.push(this.used_stripe[this.checkIndex(this.reelIndex - 1, this.used_stripe_length)]);
            } else {
                this.buffer.push(this.getRandomNonBlockSymbol());
                this.buffer.push(this.getRandomNonBlockSymbol());
                this.buffer.push(this.getRandomNonBlockSymbol());
            }
            this.buffer = this.buffer.concat(img.slice());
            var symbols_to_add = symbols_total - img.length;
            var lastSymbolInOutcome = this.buffer[this.buffer.length - 1];
            if (this.config.symbolMap.get(lastSymbolInOutcome).block != null) {
                var _block = this.config.symbolMap.get(lastSymbolInOutcome).block;
                var _blockPartToAdd = _block.slice(_hcmn_.HxOverrides.indexOf(_block, lastSymbolInOutcome, 0) + 1);
                if (_blockPartToAdd.length > 0) {
                    this.buffer = this.buffer.concat(_blockPartToAdd);
                    symbols_to_add -= _blockPartToAdd.length;
                }
            }
            var blockCandidateInReelPicture = this.reelPicture.cells[0];
            var blockCandidate = [];
            if (this.config.symbolMap.get(blockCandidateInReelPicture).block != null) {
                var _block1 = this.config.symbolMap.get(blockCandidateInReelPicture).block;
                blockCandidate = _block1.slice(0, _hcmn_.HxOverrides.indexOf(_block1, blockCandidateInReelPicture, 0));
                if (blockCandidate.length > 0) symbols_to_add -= blockCandidate.length;
            }
            if (symbols_to_add < 0) {
                var distanceToAdd = -symbols_to_add * this.reel_config.cellHeight;
                this.dist1 += distanceToAdd;
                var addedTime = distanceToAdd / this.default_speed_px_ms | 0;
                this.time1 += addedTime;
                this.total_stopping_time + addedTime;
            } else
                while (symbols_to_add > 0) {
                    this.buffer.push(this.getRandomNonBlockSymbol());
                    symbols_to_add--;
                }
            if (blockCandidate.length > 0) this.buffer = this.buffer.concat(blockCandidate);
            this.buffer = this.buffer.concat(this.reelPicture.cells);
            this.bufferIndex = this.buffer.length - this.reelPicture.cells.length + 1;
            this.bufferPos = this.bufferIndex * this.reel_config.cellHeight + this.reelPicture.offset;
            this.total_stopping_time = this.time1 + this.time2 + this.stoppingFunction.total_time;
            this.stop_time_bookmark = this.currentTime;
            this.stop_time_buffer_pos = this.bufferPos;
            this.outcomeEnterDist = total_dist - this.reel_config.cellHeight * (this.reel_config.cellsNum - 0.5);
            this.changeReelState(reels.ReelState.STOPPING);
            return this.total_stopping_time;
        };
        reels.ReelAnimator.prototype.start = function(stripe_id) {
            this.activateReelStripe(stripe_id);
            this.buffer = [];
            this.buffer = this.reelPicture.cells.slice();
            this.reelIndex -= this.reelPicture.cells.length;
            this.reelIndex = this.checkIndex(this.reelIndex, this.used_stripe_length);
            var added_symbols = 0;
            var blockCandidateInReelPicture = this.reelPicture.cells[0];
            if (this.config.symbolMap.get(blockCandidateInReelPicture).block != null) {
                var _block = this.config.symbolMap.get(blockCandidateInReelPicture).block;
                if (blockCandidateInReelPicture != _block[0]) {
                    var blockCandidate = _block.slice(0, _hcmn_.HxOverrides.indexOf(_block, blockCandidateInReelPicture, 0));
                    this.buffer = blockCandidate.concat(this.buffer);
                    added_symbols += blockCandidate.length;
                }
            }
            var activeStripeCandidate = this.getImageFromStripe(this.reelIndex, this.used_stripe);
            var activeStripeLastSymbol = activeStripeCandidate[activeStripeCandidate.length - 1];
            while (this.config.symbolMap.get(activeStripeLastSymbol).block != null) {
                this.reelIndex--;
                activeStripeCandidate = this.getImageFromStripe(this.reelIndex, this.used_stripe);
                activeStripeLastSymbol = activeStripeCandidate[activeStripeCandidate.length - 1];
            }
            activeStripeCandidate.unshift(this.used_stripe[this.checkIndex(this.reelIndex - 2, this.used_stripe_length)]);
            this.buffer = activeStripeCandidate.concat(this.buffer);
            this.bufferIndex = this.buffer.length - this.reelPicture.cells.length + 1;
            this.bufferPos = this.bufferIndex * this.reel_config.cellHeight;
            this.reelPos = this.reelIndex * this.reel_config.cellHeight;
            var symbols_to_travel = this.reelPicture.cells.length + added_symbols;
            var total_starting_distance = symbols_to_travel * this.reel_config.cellHeight;
            this.dist1 = total_starting_distance - this.startingFunction.distance;
            this.time1 = this.dist1 / this.default_speed_px_ms | 0;
            this.start_time_bookmark = new _hcmn_.Date().getTime();
            this.start_time_buffer_pos = this.bufferPos;
            this.outcomeExitDist = this.reel_config.cellHeight * (this.reel_config.cellsNum + 1);
            this.changeReelState(reels.ReelState.STARTING);
        };
        reels.ReelAnimator.prototype.updateReel = function(elapsed_ms, currentTime) {
            this.currentTime = currentTime;
            if (this.used_stripe == null) return;
            if (this.reel.state == reels.ReelState.STOPPING) {
                var elapsed_from_stop = currentTime - this.stop_time_bookmark | 0;
                var end = false;
                var elapsed_dist;
                if (elapsed_from_stop < this.time1) elapsed_dist = elapsed_from_stop * this.default_speed_px_ms;
                else if (elapsed_from_stop < this.time1 + this.time2) elapsed_dist = this.dist1 + (elapsed_from_stop - this.time1) * this.tension_speed_px_ms;
                else if (elapsed_from_stop < this.total_stopping_time) elapsed_dist = this.dist1 + this.dist2 + this.stoppingFunction.map.h[elapsed_from_stop - this.time1 - this.time2];
                else {
                    elapsed_dist = this.dist1 + this.dist2 + this.stoppingFunction.distance;
                    end = true;
                }
                this.bufferPos = this.stop_time_buffer_pos - elapsed_dist;
                this.bufferIndex = _hcmn_.Math.floor(this.bufferPos / this.reel_config.cellHeight);
                if (end) {
                    this.bufferPos = _hcmn_.Math.round(this.bufferPos);
                    this.bufferIndex = _hcmn_.Math.floor(this.bufferPos / this.reel_config.cellHeight);
                    this.calculateReelPicture(this.bufferIndex, this.bufferPos);
                    this.publishStop();
                } else this.calculateReelPicture(this.bufferIndex, this.bufferPos);
                if (this.outcomeEnterDist != 0 && elapsed_dist > this.outcomeEnterDist) {
                    this.outcomeEnterDist = 0;
                    this.publishOutcomeEnter();
                }
                return;
            }
            if (this.reel.state == reels.ReelState.STARTING) {
                var elapsed_from_start = currentTime - this.start_time_bookmark | 0;
                var end_start = false;
                var elapsed_dist1;
                if (elapsed_from_start < this.startingFunction.total_time) elapsed_dist1 = this.startingFunction.map.h[elapsed_from_start];
                else if (elapsed_from_start <= this.time1 + this.startingFunction.total_time) elapsed_dist1 = this.startingFunction.distance + (elapsed_from_start - this.startingFunction.total_time) * this.default_speed_px_ms;
                else {
                    var overPos = (elapsed_from_start - this.time1 - this.startingFunction.total_time) * this.default_speed_px_ms;
                    elapsed_dist1 = this.dist1 + this.startingFunction.distance + overPos;
                    this.reelPos -= overPos;
                    end_start = true;
                }
                this.bufferPos = this.start_time_buffer_pos - elapsed_dist1;
                this.bufferIndex = _hcmn_.Math.floor(this.bufferPos / this.reel_config.cellHeight);
                this.calculateReelPicture(this.bufferIndex, this.bufferPos);
                if (end_start) this.changeReelState(reels.ReelState.SPINNING);
                else {}
                if (this.outcomeExitDist != 0 && elapsed_dist1 > this.outcomeExitDist) {
                    this.outcomeExitDist = 0;
                    this.publishOutcomeExit();
                }
                return;
            }
            this.reelPos -= this.default_speed_px_ms * elapsed_ms;
            this.reelPos = this.checkPosition(this.reelPos, this.used_stripe_length_px);
            this.reelIndex = _hcmn_.Math.floor(this.reelPos / this.reel_config.cellHeight);
            this.calculateReelPicture(this.reelIndex, this.reelPos);
        };
        reels.ReelAnimator.prototype.resetOnAbortEnd = function() {
            this.changeReelState(reels.ReelState.IDLE);
            this.activateReelStripe(this.active_stripe);
        };
        reels.ReelAnimator.prototype.findStopPositionIndex = function(arr) {
            var _g1 = 0;
            var _g = this.used_stripe_length;
            while (_g1 < _g) {
                var i = _g1++;
                var found = true;
                var _g3 = 0;
                var _g2 = arr.length;
                while (_g3 < _g2) {
                    var r = _g3++;
                    var _ind = this.checkIndex(i + r, this.used_stripe_length);
                    if (this.used_stripe[_ind] != arr[r]) {
                        found = false;
                        continue;
                    }
                }
                if (found) {
                    this.reelIndex = i;
                    this.reelPos = this.reelIndex * this.reel_config.cellHeight;
                    this.lastStopReelPos = this.reelPos;
                    return true;
                }
            }
            return false;
        };
        reels.ReelAnimator.prototype.getRandomNonBlockSymbol = function() {
            return this.config.nonBlockSymbols[_hcmn_.Std.random(this.config.nonBlockSymbols.length)];
        };
        reels.ReelAnimator.prototype.publishStop = function() {
            this.changeReelState(reels.ReelState.IDLE);
            this.reel.onReelStopped();
            if (this.reel.pos == this.config.reels.length - 1) this.reel.onSpinStopped();
        };
        reels.ReelAnimator.prototype.publishOutcomeExit = function() {
            this.reel.component.port.onStartSpinReelPictureExit().publish(this.reel.pos);
        };
        reels.ReelAnimator.prototype.publishOutcomeEnter = function() {};
        reels.ReelAnimator.prototype.checkIndex = function(value, maxValue) {
            while (value < 0) value += maxValue;
            return value % maxValue;
        };
        reels.ReelAnimator.prototype.checkPosition = function(value, maxValue) {
            while (value < 0) value += maxValue;
            return value % maxValue;
        };
        reels.ReelAnimator.prototype.get_stopDuration = function() {
            return this.stoppingFunction.total_time;
        };
        reels.ReelAnimator.prototype.get_startDuration = function() {
            return this.startingFunction.total_time;
        };
        reels.ReelAnimator.prototype.__class__ = reels.ReelAnimator;
        reels.ReelComponent = function(context, vbFactory) {
            this.serverMinSpinDuration = 3000;
            this.reelsInitialized = false;
            this.reels = [];
            var _g = this;
            this.context = context;
            this.port = context.getImplementedPort(reelsApi.IReelsImplementationPort);
            this.slotModelPort = context.getUsedPort(slotModelApi.ISlotModelPort);
            this.layoutPort = context.getUsedPort(gameLayoutApi.IGameLayoutPort);
            this.vbFactory = vbFactory;
            this.port.startSpin().subscribe($bind(this, this.handleStartSpin));
            this.port.stopSpin().subscribe($bind(this, this.handleStopSpin));
            this.port.setReelPicture().subscribe($bind(this, this.handleSetReelPicture));
            this.port.setReelCellsVisibility().subscribe($bind(this, this.handleSetReelCellsVisibility));
            this.port.show().subscribe($bind(this, this.handleShow));
            this.port.hide().subscribe($bind(this, this.handleHide));
            this.slotModelPort.getStages().getInitStage().getInitializeGamePhase().getInitializeGame().subscribe($bind(this, this.handleModelInit));
            this.slotModelPort.getStages().getResumeStage().getPrepareResume().subscribe($bind(this, this.handleResumeGame));
            this.layoutPort.getUpdateComponentLayout().subscribe($bind(this, this.updateLayout));
            reels.ExternalService.assetRegistry.getAsset("reel-config").getContent().then(function(data) {
                _g.config = data;
                reels.ExternalService.assetRegistry.getAsset(_g.config.configs[0]).getContent().then(function(vb) {
                    reels.ExternalService.loadedAssets = vb;
                    _g.initialize();
                });
            });
        };
        reels.ReelComponent.__name__ = ["reels", "ReelComponent"];
        reels.ReelComponent.prototype.context = null;
        reels.ReelComponent.prototype.vbFactory = null;
        reels.ReelComponent.prototype.port = null;
        reels.ReelComponent.prototype.slotModelPort = null;
        reels.ReelComponent.prototype.layoutPort = null;
        reels.ReelComponent.prototype.state = null;
        reels.ReelComponent.prototype.config = null;
        reels.ReelComponent.prototype.view = null;
        reels.ReelComponent.prototype.stage = null;
        reels.ReelComponent.prototype.layoutPayload = null;
        reels.ReelComponent.prototype.tensionArray = null;
        reels.ReelComponent.prototype.reels = null;
        reels.ReelComponent.prototype._outcomeReelPicture = null;
        reels.ReelComponent.prototype._lastBaseGameOutcome = null;
        reels.ReelComponent.prototype.oldTime = null;
        reels.ReelComponent.prototype.timer = null;
        reels.ReelComponent.prototype.spinStartTime = null;
        reels.ReelComponent.prototype.reelStopTimer = null;
        reels.ReelComponent.prototype.reelPictureVisibility = null;
        reels.ReelComponent.prototype.reelsInitialized = null;
        reels.ReelComponent.prototype.setReelPicturePayload = null;
        reels.ReelComponent.prototype.firstReelInTension = null;
        reels.ReelComponent.prototype.serverMinSpinDuration = null;
        reels.ReelComponent.prototype.outcomeSize = null;
        reels.ReelComponent.prototype.outcomeStartIndex = null;
        reels.ReelComponent.prototype.initProperties = null;
        reels.ReelComponent.prototype.handleResumeGame = function(e) {
            this.continueInit(e.getPayload().initializationProperties);
        };
        reels.ReelComponent.prototype.handleModelInit = function(e) {
            this.continueInit(e.getPayload());
        };
        reels.ReelComponent.prototype.continueInit = function(initProperties) {
            this.initProperties = initProperties;
            this.outcomeSize = initProperties.slotDefinition.reelPictureSize.reelLength;
            if (this.outcomeSize == this.config.defaultReelConfig.cellsNum) {
                this.config.bleedOn = false;
                this.outcomeStartIndex = 1;
                this.config.inGameRPSize = this.outcomeSize + 2;
            } else {
                this.config.bleedOn = true;
                this.outcomeStartIndex = 0;
                this.config.inGameRPSize = this.outcomeSize + 1;
            }
            this.reelPictureVisibility = initProperties.slotDefinition.reelPictureVisibility.reelsInfo;
            this.initialize();
        };
        reels.ReelComponent.prototype.updateLayout = function(e) {
            this.layoutPayload = e.getPayload();
            this.layoutPort.getComponentLayoutUpdated().publish(this.context.getInstance());
            if (this.reelsInitialized) this.view.onLayoutUpdate(this.layoutPayload);
            else this.initialize();
        };
        reels.ReelComponent.prototype.initialize = function() {
            if (!this.reelsInitialized && this.layoutPayload != null && reels.ExternalService.loadedAssets != null && this.initProperties != null) this.initReels();
        };
        reels.ReelComponent.prototype.initReels = function() {
            var _view = this.vbFactory.createView(reels.ExternalService.loadedAssets);
            this.config.viewBuilder = _view;
            this.config.symbolMap = new _hcmn_.haxe_ds_StringMap();
            var _g1 = 0;
            var _g = this.initProperties.slotDefinition.symbols.length;
            while (_g1 < _g) {
                var s = _g1++;
                this.config.symbolMap.set(this.initProperties.slotDefinition.symbols[s].id, this.initProperties.slotDefinition.symbols[s]);
            }
            if (this.config.nonBlockSymbols == null) {
                this.config.nonBlockSymbols = [];
                var $it0 = this.config.symbolMap.keys();
                while ($it0.hasNext()) {
                    var key = $it0.next();
                    if (this.config.symbolMap.get(key).block == null) this.config.nonBlockSymbols.push(key);
                }
            }
            var this1 = reels.ExternalService.displayProvider.getStages();
            var key1 = this.layoutPayload.containers.get("layout").stage;
            this.stage = this1.get(key1);
            this.view = new reels.ReelComponentView(this.config);
            this.view.onLayoutUpdate(this.layoutPayload);
            var _g11 = 0;
            var _g2 = this.config.reels.length;
            while (_g11 < _g2) {
                var i = _g11++;
                var _reel = new reels.Reel(i, this, this.initProperties.slotDefinition.reels[i].stripes);
                this.reels.push(_reel);
                _reel.view.addCellToBleedLayer = ($_ = this.view, $bind($_, $_.addCellToBleedLayer));
                _reel.view.removeCellFromBleedLayer = ($_ = this.view, $bind($_, $_.removeCellFromBleedLayer));
            }
            if (this.setReelPicturePayload != null) this.forceReelPicture(this.setReelPicturePayload);
            this.changeState(reels.ReelComponentState.IDLE);
            this.stage.on(displayEngineApi.DisplayObjectEvents.ENTER_FRAME, $bind(this, this.updateReels));
            this.reelsInitialized = true;
        };
        reels.ReelComponent.prototype.handleStartSpin = function(e) {
            if (this.state != reels.ReelComponentState.IDLE) return;
            this.changeState(reels.ReelComponentState.SPINNING);
            this.oldTime = new _hcmn_.Date().getTime();
            this.spinStartTime = _hcmn_.Std["int"](new _hcmn_.Date().getTime());
            var stripe_layer_ids = e.getPayload().stripeLayerIds;
            var _g1 = 0;
            var _g = this.reels.length;
            while (_g1 < _g) {
                var i = _g1++;
                this.reels[i].start(stripe_layer_ids[i]);
            }
        };
        reels.ReelComponent.prototype.handleShow = function(e) {
            this.view.setVisible(true);
        };
        reels.ReelComponent.prototype.handleHide = function(e) {
            this.view.setVisible(false);
        };
        reels.ReelComponent.prototype.handleStopSpin = function(e) {
            if (this.state != reels.ReelComponentState.SPINNING) return;
            this.changeState(reels.ReelComponentState.STOPPING);
            this._outcomeReelPicture = e.getPayload().reelPicture;
            this.tensionArray = e.getPayload().tensionReels;
            this.firstReelInTension = _hcmn_.HxOverrides.indexOf(this.tensionArray, 1, 0);
            var reelsInTension = 0;
            var _g1 = 0;
            var _g = this.tensionArray.length;
            while (_g1 < _g) {
                var t = _g1++;
                if (this.tensionArray[t] == 1) reelsInTension++;
            }
            var startDuration = this.config.reels[0].cellsNum * this.config.reels[0].cellHeight / (this.config.reels[0].defaultSpeed * this.config.reels[0].cellHeight) * 1000 | 0;
            var elapsedFromStart = _hcmn_.Std["int"](new _hcmn_.Date().getTime()) - this.spinStartTime;
            var timeForStopAll = this.reels[0].animator.get_stopDuration() + (this.config.reels.length - 1 - reelsInTension) * this.config.defaultReelConfig.stopDelay + reelsInTension * this.config.defaultReelConfig.extendedSpinDuration;
            var delay = this.serverMinSpinDuration - timeForStopAll - elapsedFromStart;
            if (delay > 0) _hcmn_.haxe_Timer.delay($bind(this, this.triggerStopping), delay);
            else this.triggerStopping();
        };
        reels.ReelComponent.prototype.triggerStopping = function() {
            this.port.onStoppingStarted().publish(null);
            var desiredTimeToStop = 0;
            var time = new _hcmn_.Date().getTime();
            var firstReelInTensionTime = 0;
            var _g1 = 0;
            var _g = this.reels.length;
            while (_g1 < _g) {
                var i = _g1++;
                if (firstReelInTensionTime != 0) desiredTimeToStop += this.config.reels[i].extendedSpinDuration;
                else if (i != 0) desiredTimeToStop += this.config.reels[i].stopDelay;
                else desiredTimeToStop = this.reels[0].animator.get_stopDuration();
                desiredTimeToStop = this.reels[i].animator.stop(this._outcomeReelPicture[i], desiredTimeToStop, firstReelInTensionTime);
                if (i == this.firstReelInTension - 1) firstReelInTensionTime = desiredTimeToStop;
            }
        };
        reels.ReelComponent.prototype.updateReels = function() {
            if (this.state == reels.ReelComponentState.IDLE) return;
            var currentTime = new _hcmn_.Date().getTime();
            var elapsed_ms = currentTime - this.oldTime | 0;
            var elapsed = (currentTime - this.oldTime) * 0.001;
            this.oldTime = currentTime;
            var _g1 = 0;
            var _g = this.reels.length;
            while (_g1 < _g) {
                var i = _g1++;
                var _reel = this.reels[i];
                _reel.updateReel(elapsed_ms, currentTime);
            }
        };
        reels.ReelComponent.prototype.onReelStopped = function(pos) {
            var stoppedPicture = this.reels[pos].animator.reelPicture.cells.slice(this.outcomeStartIndex, this.outcomeStartIndex + this.outcomeSize);
            reels.ExternalService.testableLogger.info("reelPicture", {
                pos: pos,
                cells: stoppedPicture
            });
            var resultOK = this._outcomeReelPicture[pos].toString() == stoppedPicture.toString();
            var msg;
            msg = "[mj][stopped " + pos + "] server:" + _hcmn_.Std.string(this._outcomeReelPicture[pos]) + " > " + _hcmn_.Std.string(stoppedPicture) + " > " + (resultOK ? "OK" : "ERROR");
            if (resultOK) null;
            else console.log("%c" + msg, "color:white;background:red;");
            this.port.onReelStopped().publish(pos);
        };
        reels.ReelComponent.prototype.onSpinStopped = function() {
            this.changeState(reels.ReelComponentState.IDLE);
            var dur = _hcmn_.Std["int"](new _hcmn_.Date().getTime()) - this.spinStartTime;
            this.port.onSpinStopped().publish(null);
        };
        reels.ReelComponent.prototype.handleSetReelPicture = function(e) {
            this.setReelPicturePayload = e.getPayload();
            if (!this.reelsInitialized) return;
            if (this.state != reels.ReelComponentState.IDLE) {
                this.changeState(reels.ReelComponentState.IDLE);
                var _g1 = 0;
                var _g = this.reels.length;
                while (_g1 < _g) {
                    var i = _g1++;
                    this.reels[i].animator.resetOnAbortEnd();
                }
            }
            this.forceReelPicture(this.setReelPicturePayload);
            this.setReelPicturePayload = null;
        };
        reels.ReelComponent.prototype.forceReelPicture = function(pic) {
            this.view.cacheAsBitmap(false);
            var _g1 = 0;
            var _g = this.reels.length;
            while (_g1 < _g) {
                var i = _g1++;
                this.reels[i].animator.forceReelPicture(pic[i]);
            }
            this.view.cacheAsBitmap(true);
        };
        reels.ReelComponent.prototype.handleSetReelCellsVisibility = function(e) {
            var visibility_info = e.getPayload();
            this.view.cacheAsBitmap(false);
            var _g1 = 0;
            var _g = this.reels.length;
            while (_g1 < _g) {
                var i = _g1++;
                var cells = this.reels[i].view.cells;
                var _g3 = 0;
                var _g2 = cells.length;
                while (_g3 < _g2) {
                    var j = _g3++;
                    var vis_info = visibility_info[i][j - 1];
                    if (vis_info != null && vis_info == 1) {
                        var cell = cells[j];
                        cell.displayObject.setVisible(false);
                        var block;
                        block = ((function($this) {
                            var $r;
                            var key = cell.getSymbolId();
                            $r = $this.config.symbolMap.get(key);
                            return $r;
                        }(this))).block;
                        if (block != null) {
                            var symbolInBlock;
                            symbolInBlock = (function($this) {
                                var $r;
                                var x = cell.getSymbolId();
                                $r = _hcmn_.HxOverrides.lastIndexOf(block, x, block.length - 1);
                                return $r;
                            }(this)) + 1;
                            var m = j + 1;
                            while (symbolInBlock < block.length && cells[m] != null) {
                                cells[m].displayObject.setVisible(false);
                                m++;
                                symbolInBlock++;
                            }
                        }
                    }
                }
            }
            this.view.cacheAsBitmap(true);
        };
        reels.ReelComponent.prototype.changeState = function(state) {
            this.state = state;
            if (state == reels.ReelComponentState.IDLE) this.view.cacheAsBitmap(true);
            else this.view.cacheAsBitmap(false);
        };
        reels.ReelComponent.prototype.__class__ = reels.ReelComponent;
        reels.ReelFactory = function(vbf) {
            this.vbf = vbf;
        };
        reels.ReelFactory = ck_implements(reels.ReelFactory, clientkernelModulesApi.IService);
        reels.ReelFactory = ck_implements(reels.ReelFactory, componentmodelComponentApi.IComponentFactory);
        reels.ReelFactory.__interfaces__ = [clientkernelModulesApi.IService, componentmodelComponentApi.IComponentFactory];
        reels.ReelFactory.__name__ = ["reels", "ReelFactory"];
        reels.ReelFactory.prototype.vbf = null;
        reels.ReelFactory.prototype.getComponentDeclaration = function() {
            return reelsApi.ReelsDeclaration;
        };
        reels.ReelFactory.prototype.createComponent = function(context) {
            new reels.ReelComponent(context, this.vbf);
        };
        reels.ReelFactory.prototype.__class__ = reels.ReelFactory;
        reels.ReelPicture = function() {
            this.offset = 0;
            this.cells = [];
        };
        reels.ReelPicture.__name__ = ["reels", "ReelPicture"];
        reels.ReelPicture.prototype.cells = null;
        reels.ReelPicture.prototype.offset = null;
        reels.ReelPicture.prototype.toString = function() {
            return _hcmn_.Std.string(this.cells) + ":" + this.offset;
        };
        reels.ReelPicture.prototype.__class__ = reels.ReelPicture;
        reels.ReelsConfig = function() {
            this.bleedOffscreen = true;
            this.reelOffscreen = true;
        };
        reels.ReelsConfig.__name__ = ["reels", "ReelsConfig"];
        reels.ReelsConfig.prototype.configs = null;
        reels.ReelsConfig.prototype.defaultReelConfig = null;
        reels.ReelsConfig.prototype.reels = null;
        reels.ReelsConfig.prototype.symbolMap = null;
        reels.ReelsConfig.prototype.nonBlockSymbols = null;
        reels.ReelsConfig.prototype.boundsWidth = null;
        reels.ReelsConfig.prototype.boundsHeight = null;
        reels.ReelsConfig.prototype.viewBuilder = null;
        reels.ReelsConfig.prototype.inGameRPSize = null;
        reels.ReelsConfig.prototype.bleedOn = null;
        reels.ReelsConfig.prototype.reelOffscreen = null;
        reels.ReelsConfig.prototype.bleedOffscreen = null;
        reels.ReelsConfig.prototype.deserializeObjects = function() {};
        reels.ReelsConfig.getEasingFunc = function(type) {
            switch (type) {
                case "backIn":
                    return displayEngineUtils.EaseX.backIn;
                case "backInOut":
                    return displayEngineUtils.EaseX.backInOut;
                case "backOut":
                    return displayEngineUtils.EaseX.backOut;
                case "backOutIn":
                    return displayEngineUtils.EaseX.backOutIn;
                case "bounceIn":
                    return displayEngineUtils.EaseX.bounceIn;
                case "bounceInOut":
                    return displayEngineUtils.EaseX.bounceInOut;
                case "bounceOut":
                    return displayEngineUtils.EaseX.bounceOut;
                case "bounceOutIn":
                    return displayEngineUtils.EaseX.bounceOutIn;
                case "circIn":
                    return displayEngineUtils.EaseX.circIn;
                case "circInOut":
                    return displayEngineUtils.EaseX.circInOut;
                case "circOut":
                    return displayEngineUtils.EaseX.circOut;
                case "circOutIn":
                    return displayEngineUtils.EaseX.circOutIn;
                case "cubicIn":
                    return displayEngineUtils.EaseX.cubicIn;
                case "cubicInOut":
                    return displayEngineUtils.EaseX.cubicInOut;
                case "cubicOut":
                    return displayEngineUtils.EaseX.cubicOut;
                case "cubicOutIn":
                    return displayEngineUtils.EaseX.cubicOutIn;
                case "elasticIn":
                    return displayEngineUtils.EaseX.elasticIn;
                case "elasticInOut":
                    return displayEngineUtils.EaseX.elasticInOut;
                case "elasticOut":
                    return displayEngineUtils.EaseX.elasticOut;
                case "elasticOutIn":
                    return displayEngineUtils.EaseX.elasticOutIn;
                case "expoIn":
                    return displayEngineUtils.EaseX.expoIn;
                case "expoInOut":
                    return displayEngineUtils.EaseX.expoInOut;
                case "expoOut":
                    return displayEngineUtils.EaseX.expoOut;
                case "expoOutIn":
                    return displayEngineUtils.EaseX.expoOutIn;
                case "linear":
                    return displayEngineUtils.EaseX.linear;
                case "quadIn":
                    return displayEngineUtils.EaseX.quadIn;
                case "quadInOut":
                    return displayEngineUtils.EaseX.quadInOut;
                case "quadOut":
                    return displayEngineUtils.EaseX.quadOut;
                case "quadOutIn":
                    return displayEngineUtils.EaseX.quadOutIn;
                case "quartIn":
                    return displayEngineUtils.EaseX.quartIn;
                case "quartInOut":
                    return displayEngineUtils.EaseX.quartInOut;
                case "quartOut":
                    return displayEngineUtils.EaseX.quartOut;
                case "quartOutIn":
                    return displayEngineUtils.EaseX.quartOutIn;
                case "quintIn":
                    return displayEngineUtils.EaseX.quintIn;
                case "quintInOut":
                    return displayEngineUtils.EaseX.quintInOut;
                case "quintOut":
                    return displayEngineUtils.EaseX.quintOut;
                case "quintOutIn":
                    return displayEngineUtils.EaseX.quintOutIn;
                case "sineIn":
                    return displayEngineUtils.EaseX.sineIn;
                case "sineInOut":
                    return displayEngineUtils.EaseX.sineInOut;
                case "sineOut":
                    return displayEngineUtils.EaseX.sineOut;
                case "sineOutIn":
                    return displayEngineUtils.EaseX.sineOutIn;
                default:
                    return displayEngineUtils.EaseX.linear;
            }
        };
        reels.ReelsConfig.prototype.__class__ = reels.ReelsConfig;
        reels.ReelComponentState = {
            __ename__: ["reels", "ReelComponentState"],
            __constructs__: ["IDLE", "SPINNING", "STOPPING"]
        };
        reels.ReelComponentState.IDLE = ["IDLE", 0];
        reels.ReelComponentState.IDLE.toString = $estr;
        reels.ReelComponentState.IDLE.__enum__ = reels.ReelComponentState;
        reels.ReelComponentState.SPINNING = ["SPINNING", 1];
        reels.ReelComponentState.SPINNING.toString = $estr;
        reels.ReelComponentState.SPINNING.__enum__ = reels.ReelComponentState;
        reels.ReelComponentState.STOPPING = ["STOPPING", 2];
        reels.ReelComponentState.STOPPING.toString = $estr;
        reels.ReelComponentState.STOPPING.__enum__ = reels.ReelComponentState;
        reels.ReelState = {
            __ename__: ["reels", "ReelState"],
            __constructs__: ["IDLE", "STARTING", "SPINNING", "STOPPING", "TENSION", "SLOWING"]
        };
        reels.ReelState.SLOWING = ["SLOWING", 5];
        reels.ReelState.SLOWING.toString = $estr;
        reels.ReelState.SLOWING.__enum__ = reels.ReelState;
        reels.ReelState.IDLE = ["IDLE", 0];
        reels.ReelState.IDLE.toString = $estr;
        reels.ReelState.IDLE.__enum__ = reels.ReelState;
        reels.ReelState.STARTING = ["STARTING", 1];
        reels.ReelState.STARTING.toString = $estr;
        reels.ReelState.STARTING.__enum__ = reels.ReelState;
        reels.ReelState.SPINNING = ["SPINNING", 2];
        reels.ReelState.SPINNING.toString = $estr;
        reels.ReelState.SPINNING.__enum__ = reels.ReelState;
        reels.ReelState.STOPPING = ["STOPPING", 3];
        reels.ReelState.STOPPING.toString = $estr;
        reels.ReelState.STOPPING.__enum__ = reels.ReelState;
        reels.ReelState.TENSION = ["TENSION", 4];
        reels.ReelState.TENSION.toString = $estr;
        reels.ReelState.TENSION.__enum__ = reels.ReelState;
        reels.Cell = function(config) {
            this.visible_symbol_name = "";
            this.visible_symbol_id = "";
            this.config = config;
            this.displayObject = reels.ExternalService.displayProvider.getFactory().createDisplayObjectContainer();
            this.symbols = new _hcmn_.haxe_ds_StringMap();
            var _disp;
            var $it0 = config.symbolMap.keys();
            while ($it0.hasNext()) {
                var id = $it0.next();
                var symbol_map_id = config.symbolMap.get(id).asset;
                if (!this.symbols.exists(symbol_map_id)) {
                    var vbCont = config.viewBuilder.createContainerFromStoredConfig(symbol_map_id);
                    var innerBmp = vbCont.getComponentById("innerBmp");
                    if (innerBmp != null) _disp = innerBmp.getDisplayObject();
                    else _disp = vbCont.getDisplayObject();
                    _disp.setX(0);
                    _disp.setY(0);
                    _disp.setName(symbol_map_id);
                    this.symbols.set(symbol_map_id, _disp);
                    _disp.setVisible(false);
                    this.displayObject.addChild(_disp);
                }
            }
        };
        reels.Cell.__name__ = ["reels", "Cell"];
        reels.Cell.prototype.displayObject = null;
        reels.Cell.prototype.initialY = null;
        reels.Cell.prototype.visible_symbol_id = null;
        reels.Cell.prototype.visible_symbol_name = null;
        reels.Cell.prototype.symbols = null;
        reels.Cell.prototype.config = null;
        reels.Cell.prototype.setSymbol = function(id) {
            if (id == null) return;
            var symbolDef = this.config.symbolMap.get(id);
            var symbol_name = symbolDef.asset;
            if (this.visible_symbol_name == symbol_name) return;
            if (this.visible_symbol_name != "") this.symbols.get(this.visible_symbol_name).setVisible(false);
            this.visible_symbol_name = symbol_name;
            this.visible_symbol_id = id;
            this.symbols.get(this.visible_symbol_name).setVisible(true);
        };
        reels.Cell.prototype.getSymbolId = function() {
            return this.visible_symbol_id;
        };
        reels.Cell.prototype.__class__ = reels.Cell;
        reels.CubicSpline = function(points, cellHeight) {
            this.xs = [];
            this.ys = [];
            this.total_time = 0;
            var _g1 = 0;
            var _g = points.length;
            while (_g1 < _g) {
                var p = _g1++;
                var point = points[p].split(":");
                this.ys.push(parseFloat(point[0]));
                var xt = _hcmn_.Std.parseInt(point[1]);
                this.total_time += xt;
                this.xs.push(this.total_time);
            }
            this.ks = [];
            this.getNaturalKs();
            this.ks[0] = 0;
            this.ks[this.xs.length - 1] = 0;
            this.map = new _hcmn_.haxe_ds_IntMap();
            this.function_graph = reels.ExternalService.displayProvider.getFactory().createSprite();
            this.function_graph.setY(500);
            var graphics = this.function_graph.getGraphics();
            graphics.moveTo(0, 0);
            graphics.lineStyle(1, 16711680, 1);
            var _g11 = 0;
            var _g2 = this.total_time + 1;
            while (_g11 < _g2) {
                var t = _g11++;
                var sp = this.evalSpline(t);
                var dist = sp * cellHeight * 0.001;
                this.distance += dist;
                this.map.h[t] = this.distance;
                graphics.lineTo(t, -sp * 10);
            }
        };
        reels.CubicSpline.__name__ = ["reels", "CubicSpline"];
        reels.CubicSpline.prototype.xs = null;
        reels.CubicSpline.prototype.ys = null;
        reels.CubicSpline.prototype.ks = null;
        reels.CubicSpline.prototype.map = null;
        reels.CubicSpline.prototype.function_graph = null;
        reels.CubicSpline.prototype.total_time = null;
        reels.CubicSpline.prototype.distance = null;
        reels.CubicSpline.prototype.solve = function(A) {
            var m = A.length;
            var _g = 0;
            while (_g < m) {
                var k = _g++;
                var i_max = 0;
                var vali = -Infinity;
                var _g1 = k;
                while (_g1 < m) {
                    var i1 = _g1++;
                    if (A[i1][k] > vali) {
                        i_max = i1;
                        vali = A[i1][k];
                    }
                }
                this.swapRows(A, k, i_max);
                if (A[i_max][k] == 0) null;
                var _g11 = k + 1;
                while (_g11 < m) {
                    var i2 = _g11++;
                    var _g3 = k + 1;
                    var _g2 = m + 1;
                    while (_g3 < _g2) {
                        var j = _g3++;
                        A[i2][j] = A[i2][j] - A[k][j] * (A[i2][k] / A[k][k]);
                    }
                    A[i2][k] = 0;
                }
            }
            var i = m - 1;
            while (i >= 0) {
                var v = A[i][m] / A[i][i];
                this.ks[i] = v;
                var j1 = i - 1;
                while (j1 >= 0) {
                    A[j1][m] -= A[j1][i] * v;
                    A[j1][i] = 0;
                    j1--;
                }
                i--;
            }
        };
        reels.CubicSpline.prototype.zerosMat = function(r, c) {
            var A = [];
            var _g = 0;
            while (_g < r) {
                var i = _g++;
                A.push([]);
                var _g1 = 0;
                while (_g1 < c) {
                    var j = _g1++;
                    A[i].push(0);
                }
            }
            return A;
        };
        reels.CubicSpline.prototype.swapRows = function(m, k, l) {
            var p = m[k];
            m[k] = m[l];
            m[l] = p;
        };
        reels.CubicSpline.prototype.getNaturalKs = function() {
            var n = this.xs.length - 1;
            var A = this.zerosMat(n + 1, n + 2);
            var _g = 1;
            while (_g < n) {
                var i = _g++;
                A[i][i - 1] = 1 / (this.xs[i] - this.xs[i - 1]);
                A[i][i] = 2 * (1 / (this.xs[i] - this.xs[i - 1]) + 1 / (this.xs[i + 1] - this.xs[i]));
                A[i][i + 1] = 1 / (this.xs[i + 1] - this.xs[i]);
                A[i][n + 1] = 3 * ((this.ys[i] - this.ys[i - 1]) / ((this.xs[i] - this.xs[i - 1]) * (this.xs[i] - this.xs[i - 1])) + (this.ys[i + 1] - this.ys[i]) / ((this.xs[i + 1] - this.xs[i]) * (this.xs[i + 1] - this.xs[i])));
            }
            A[0][0] = 2 / (this.xs[1] - this.xs[0]);
            A[0][1] = 1 / (this.xs[1] - this.xs[0]);
            A[0][n + 1] = 3 * (this.ys[1] - this.ys[0]) / ((this.xs[1] - this.xs[0]) * (this.xs[1] - this.xs[0]));
            A[n][n - 1] = 1 / (this.xs[n] - this.xs[n - 1]);
            A[n][n] = 2 / (this.xs[n] - this.xs[n - 1]);
            A[n][n + 1] = 3 * (this.ys[n] - this.ys[n - 1]) / ((this.xs[n] - this.xs[n - 1]) * (this.xs[n] - this.xs[n - 1]));
            this.solve(A);
        };
        reels.CubicSpline.prototype.evalSpline = function(x) {
            var i = 1;
            while (this.xs[i] < x) i++;
            var t = (x - this.xs[i - 1]) / (this.xs[i] - this.xs[i - 1]);
            var a = this.ks[i - 1] * (this.xs[i] - this.xs[i - 1]) - (this.ys[i] - this.ys[i - 1]);
            var b = -this.ks[i] * (this.xs[i] - this.xs[i - 1]) + (this.ys[i] - this.ys[i - 1]);
            var q = (1 - t) * this.ys[i - 1] + t * this.ys[i] + t * (1 - t) * (a * (1 - t) + b * t);
            return q;
        };
        reels.CubicSpline.prototype.__class__ = reels.CubicSpline;
        reels.ReelComponentView = function(config) {
            this.addedToStage = false;
            this.BLEED_LAYER = "layout_top";
            this.SYMBOLS_LAYER = "layout";
            if (config.reelOffscreen == null) {
                if (window.location.search.indexOf("rof=true") != -1) config.reelOffscreen = true;
                if (window.location.search.indexOf("bof=true") != -1) config.bleedOffscreen = true;
            }
            this.config = config;
            this.displayObject = reels.ExternalService.displayProvider.getFactory().createDisplayObjectContainer();
            this.displayObject.setName("layout");
            this.displayObjectBleed = reels.ExternalService.displayProvider.getFactory().createDisplayObjectContainer();
            this.displayObjectBleed.setName("bleed");
            if (config.reelOffscreen) {
                this.layoutOS = reels.ExternalService.displayProvider.getFactory().createOffscreenStage(config.boundsWidth, config.boundsHeight);
                this.layoutBmp = reels.ExternalService.displayProvider.getFactory().createBitmap(this.layoutOS);
                this.layoutBmp.setName("bmpLayout");
                this.displayObject.addChild(this.layoutBmp);
                this.layoutOSTimingMode = this.layoutOS.getStage().getTimingMode();
            } else {
                var m1 = reels.ExternalService.displayProvider.getFactory().createGraphics();
                m1.beginFill(16711680).drawRect(0, 0, config.boundsWidth, config.boundsHeight);
                this.displayObject.setMask(m1);
            }
            if (config.bleedOffscreen) {
                this.bleedOS = reels.ExternalService.displayProvider.getFactory().createOffscreenStage(config.boundsWidth + 60, config.boundsHeight);
                this.bleedBmp = reels.ExternalService.displayProvider.getFactory().createBitmap(this.bleedOS);
                this.bleedBmp.setName("bmpBleed");
                this.displayObjectBleed.addChild(this.bleedBmp);
            } else {
                var m2 = reels.ExternalService.displayProvider.getFactory().createGraphics();
                m2.setX(-30);
                m2.beginFill(16711680).drawRect(0, 0, config.boundsWidth + 60, config.boundsHeight);
                this.displayObjectBleed.setMask(m2);
            }
        };
        reels.ReelComponentView.__name__ = ["reels", "ReelComponentView"];
        reels.ReelComponentView.prototype.SYMBOLS_LAYER = null;
        reels.ReelComponentView.prototype.BLEED_LAYER = null;
        reels.ReelComponentView.prototype.displayObjectsMap = null;
        reels.ReelComponentView.prototype.displayObject = null;
        reels.ReelComponentView.prototype.displayObjectBleed = null;
        reels.ReelComponentView.prototype.layoutOS = null;
        reels.ReelComponentView.prototype.bleedOS = null;
        reels.ReelComponentView.prototype.layoutBmp = null;
        reels.ReelComponentView.prototype.bleedBmp = null;
        reels.ReelComponentView.prototype.layoutOSTimingMode = null;
        reels.ReelComponentView.prototype.layout_containers = null;
        reels.ReelComponentView.prototype.display_objects = null;
        reels.ReelComponentView.prototype.reels = null;
        reels.ReelComponentView.prototype.config = null;
        reels.ReelComponentView.prototype.addedToStage = null;
        reels.ReelComponentView.prototype.addReel = function(reel) {
            var _g = 0;
            var _g1 = reel.view.cells;
            while (_g < _g1.length) {
                var c = _g1[_g];
                ++_g;
                if (this.config.reelOffscreen) this.layoutOS.getStage().addChildAt(c.displayObject, this.layoutOS.getStage().getNumChildren() - 1);
                else this.displayObject.addChildAt(c.displayObject, this.displayObject.getNumChildren() - 1);
            }
        };
        reels.ReelComponentView.prototype.onLayoutUpdate = function(layoutPayload) {
            this.layout_containers = layoutPayload.containers;
            var layoutContainer = this.layout_containers.get("layout");
            var layoutContainerTop = this.layout_containers.get("layout_top");
            if (!this.addedToStage) {
                ((function($this) {
                    var $r;
                    var this1 = reels.ExternalService.displayProvider.getStages();
                    $r = this1.get(layoutContainer.stage);
                    return $r;
                }(this))).addChild(this.displayObject);
                ((function($this) {
                    var $r;
                    var this2 = reels.ExternalService.displayProvider.getStages();
                    $r = this2.get(layoutContainerTop.stage);
                    return $r;
                }(this))).addChild(this.displayObjectBleed);
                this.addedToStage = true;
            }
            var scaleX = layoutContainer.width / this.config.boundsWidth;
            var scaleY = layoutContainer.height / this.config.boundsHeight;
            this.displayObject.setScaleX(scaleX);
            this.displayObject.setScaleY(scaleY);
            this.displayObject.setX(layoutContainer.left);
            this.displayObject.setY(layoutContainer.top);
            this.displayObject.setZIndex(layoutContainer.zIndex);
            this.displayObjectBleed.setScaleX(scaleX);
            this.displayObjectBleed.setScaleY(scaleY);
            this.displayObjectBleed.setX(layoutContainerTop.left);
            this.displayObjectBleed.setY(layoutContainerTop.top);
            this.displayObjectBleed.setZIndex(layoutContainerTop.zIndex);
        };
        reels.ReelComponentView.prototype.cacheAsBitmap = function(value) {
            if (this.config.reelOffscreen) {
                if (value) this.layoutOS.getStage().setTimingMode(displayEngineApi.TimingMode.ONCE);
                else this.layoutOS.getStage().setTimingMode(this.layoutOSTimingMode);
            } else this.displayObject.setCacheAsBitmap(value);
        };
        reels.ReelComponentView.prototype.setVisible = function(value) {
            this.displayObject.setVisible(value);
            this.displayObjectBleed.setVisible(value);
        };
        reels.ReelComponentView.prototype.addCellToBleedLayer = function(cell) {
            if (this.config.bleedOffscreen) this.bleedOS.getStage().addChildAt(cell, this.bleedOS.getStage().getNumChildren() - 1);
            else this.displayObjectBleed.addChildAt(cell, this.displayObjectBleed.getNumChildren() - 1);
            this.displayObjectBleed._obj.children.sort(function(a, b) {
                return a.x - b.x;
            });
        };
        reels.ReelComponentView.prototype.removeCellFromBleedLayer = function(cell) {
            if (this.config.reelOffscreen) this.layoutOS.getStage().addChildAt(cell, this.layoutOS.getStage().getNumChildren() - 1);
            else this.displayObject.addChildAt(cell, this.displayObject.getNumChildren() - 1);
        };
        reels.ReelComponentView.prototype.__class__ = reels.ReelComponentView;
        reels.ReelView = function(pos, config) {
            this.config = config;
            this.reel_config = config.reels[pos];
            this.cells = [];
            var _g1 = 0;
            var _g = config.inGameRPSize;
            while (_g1 < _g) {
                var i = _g1++;
                var _cell = new reels.Cell(config);
                _cell.displayObject.setName("R_" + pos + "_C" + i);
                this.cells.push(_cell);
                _cell.initialY = this.reel_config.cellHeight * (i - 1) | 0;
                _cell.displayObject.setX(pos * (this.reel_config.cellWidth + this.reel_config.leftMargin));
                _cell.displayObject.setY(_cell.initialY);
            }
        };
        reels.ReelView.__name__ = ["reels", "ReelView"];
        reels.ReelView.prototype.cells = null;
        reels.ReelView.prototype.reel_config = null;
        reels.ReelView.prototype.config = null;
        reels.ReelView.prototype.reelPicture = null;
        reels.ReelView.prototype.setAllVisible = function() {
            this.update(this.reelPicture);
        };
        reels.ReelView.prototype.update = function(reelPicture) {
            this.reelPicture = reelPicture;
            var rp_len = reelPicture.cells.length;
            var _g1 = 0;
            var _g = this.cells.length;
            while (_g1 < _g) {
                var i = _g1++;
                var cell = this.cells[i];
                cell.displayObject.setY(cell.initialY - reelPicture.offset);
                if (reelPicture.cells[i] == null) {
                    cell.displayObject.setVisible(false);
                    continue;
                }
                var symbol_id = reelPicture.cells[i];
                if (symbol_id != cell.getSymbolId()) {
                    cell.setSymbol(symbol_id);
                    this.setCellLayer(this.config.symbolMap.get(symbol_id).isBleed, cell.displayObject);
                }
                var showCell = true;
                if (this.config.symbolMap.get(symbol_id).block != null) {
                    var block = this.config.symbolMap.get(symbol_id).block;
                    var symbolInBlock = _hcmn_.HxOverrides.lastIndexOf(block, symbol_id, block.length - 1);
                    showCell = false;
                    if (symbolInBlock == block.length - 1) showCell = true;
                    else if (i + 1 == rp_len) showCell = true;
                } else if (i == 0) showCell = false;
                else if (i > this.reel_config.cellsNum) {
                    if (reelPicture.offset == 0) showCell = false;
                    else if (i - this.reel_config.cellsNum == 1) showCell = true;
                    else showCell = false;
                }
                cell.displayObject.setVisible(showCell);
            }
        };
        reels.ReelView.prototype.setCellLayer = function(isBleed, cell) {
            if (isBleed) this.addCellToBleedLayer(cell);
            else this.removeCellFromBleedLayer(cell);
        };
        reels.ReelView.prototype.addCellToBleedLayer = function(cell) {};
        reels.ReelView.prototype.removeCellFromBleedLayer = function(cell) {};
        reels.ReelView.prototype.__class__ = reels.ReelView;
        return {
            exports: reels,
            activator: reels.Activator
        };
    });
//# sourceURL=slotReels.js