define("uiHelper", ["viewBuilderApi", "displayEngineApi", "PIXI", "BABYLON"],
    function(viewBuilderApi, displayEngineApi, PIXI, BABYLON) {
        "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 _List == 'undefined') {
            var _List = {};
        };
        _List.ListIterator = function(head) {
            this.head = head;
            this.val = null;
        };
        _List.ListIterator.__name__ = ["_List", "ListIterator"];
        _List.ListIterator.prototype.head = null;
        _List.ListIterator.prototype.val = null;
        _List.ListIterator.prototype.hasNext = function() {
            return this.head != null;
        };
        _List.ListIterator.prototype.next = function() {
            this.val = this.head[0];
            this.head = this.head[1];
            return this.val;
        };
        _List.ListIterator.prototype.__class__ = _List.ListIterator;
        if (typeof haxe == 'undefined') {
            var haxe = {};
        };

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

            get: function(k) {
                return {
                    arguments: ["*"],
                    returns: "null"
                };
            }
        };
        if (typeof js == 'undefined') {
            var js = {};
        };
        if (!js._Boot) {
            js._Boot = {};
        };
        js._Boot.HaxeError = function(val) {
            Error.call(this);
            this.val = val;
            this.message = String(val);
            if (Error.captureStackTrace) Error.captureStackTrace(this, js._Boot.HaxeError);
        };
        js._Boot.HaxeError.__name__ = ["js", "_Boot", "HaxeError"];
        js._Boot.HaxeError.__super__ = Error;
        for (var k in Error.prototype) js._Boot.HaxeError.prototype[k] = Error.prototype[k];
        js._Boot.HaxeError.prototype.val = null;
        js._Boot.HaxeError.prototype.__class__ = js._Boot.HaxeError;
        if (typeof uiHelper == 'undefined') {
            var uiHelper = {};
        };
        uiHelper.CacheHelper = function(stage, useAsGlobal) {
            if (useAsGlobal == null) useAsGlobal = false;
            this.stage = stage;
            if (useAsGlobal) this.cachedItems = uiHelper.CacheHelper.GLOBAL_CACHED_ITEMS;
            else this.cachedItems = new _hcmn_.List();
            this.uiHelper = uiHelper.UiHelper.getSimpleHelper();
        };
        uiHelper.CacheHelper.__name__ = ["uiHelper", "CacheHelper"];
        uiHelper.CacheHelper.prototype.stage = null;
        uiHelper.CacheHelper.prototype.cachedItems = null;
        uiHelper.CacheHelper.prototype.uiHelper = null;
        uiHelper.CacheHelper.prototype.unCacheAll = function() {
            _hcmn_.Lambda.iter(this.cachedItems, $bind(this, this.unCacheDisplayObject));
            this.cachedItems.clear();
            return this;
        };
        uiHelper.CacheHelper.prototype.cacheAll = function() {
            this.cacheAllExcept([]);
            return this;
        };
        uiHelper.CacheHelper.prototype.cacheOnly = function(childNames) {
            _hcmn_.Lambda.iter(this.getChildrenInclude(childNames), $bind(this, this.cacheDisplayObject));
            return this;
        };
        uiHelper.CacheHelper.prototype.cacheAllExcept = function(childNames) {
            _hcmn_.Lambda.iter(this.getChildrenExcept(childNames), $bind(this, this.cacheDisplayObject));
            return this;
        };
        uiHelper.CacheHelper.prototype.unCacheDisplayObject = function(displayObject) {
            displayObject.setCacheAsBitmap(false);
        };
        uiHelper.CacheHelper.prototype.cacheDisplayObject = function(displayObject) {
            this.cachedItems.push(displayObject);
            displayObject.setCacheAsBitmap(true);
        };
        uiHelper.CacheHelper.prototype.getChildrenExcept = function(names) {
            return this.getChildren().filter(this.getNotContainsNameOfDisplayObjectInListFilter(names));
        };
        uiHelper.CacheHelper.prototype.getChildrenInclude = function(names) {
            return this.getChildren().filter(this.getContainsNameOfDisplayObjectInListFilter(names));
        };
        uiHelper.CacheHelper.prototype.getChildren = function() {
            return _hcmn_.Lambda.filter(this.stage.getChildren(), $bind(this, this.isDisplayObjectAbleToCache));
        };
        uiHelper.CacheHelper.prototype.isDisplayObjectAbleToCache = function(displaObject) {
            return displaObject.getVisible() && !this.uiHelper.isCacheAsBitmap(displaObject);
        };
        uiHelper.CacheHelper.prototype.getContainsNameOfDisplayObjectInListFilter = function(names) {
            return function(displaObject) {
                return (function($this) {
                    var $r;
                    var x = displaObject.getName();
                    $r = _hcmn_.HxOverrides.indexOf(names, x, 0);
                    return $r;
                }(this)) != -1;
            };
        };
        uiHelper.CacheHelper.prototype.getNotContainsNameOfDisplayObjectInListFilter = function(names) {
            return function(displaObject) {
                return (function($this) {
                    var $r;
                    var x = displaObject.getName();
                    $r = _hcmn_.HxOverrides.indexOf(names, x, 0);
                    return $r;
                }(this)) == -1;
            };
        };
        uiHelper.CacheHelper.prototype.__class__ = uiHelper.CacheHelper;
        uiHelper.GuiMath = function() {};
        uiHelper.GuiMath.__name__ = ["uiHelper", "GuiMath"];
        uiHelper.GuiMath.rotatePointAroundPoint = function(point, arroundPoint, angle) {
            return uiHelper.GuiMath.addPoints(uiHelper.GuiMath.rotatePoint(uiHelper.GuiMath.subtractPoint(point, arroundPoint), angle), arroundPoint);
        };
        uiHelper.GuiMath.rotatePoint = function(point, angle) {
            angle = uiHelper.GuiMath.converGradToRad(angle);
            return uiHelper.GuiMath.calcRotation(new displayEngineApi.Point(point.x, point.y), _hcmn_.Math.sin(angle), _hcmn_.Math.cos(angle));
        };
        uiHelper.GuiMath.calcRotation = function(point, sinA, cosA) {
            var xx = point.x * cosA - point.y * sinA;
            point.y = point.y * cosA + point.x * sinA;
            point.x = xx;
            return point;
        };
        uiHelper.GuiMath.addPoints = function(v1, v2) {
            return new displayEngineApi.Point(v1.x + v2.x, v1.y + v2.y);
        };
        uiHelper.GuiMath.angleOfVector = function(vector) {
            var unitVector = uiHelper.GuiMath.getUnitVector(vector);
            var a = _hcmn_.Math.acos(unitVector.x);
            if (unitVector.y < 0) a = _hcmn_.Math.PI * 2 - a;
            return uiHelper.GuiMath.converRadToGrad(a);
        };
        uiHelper.GuiMath.converGradToRad = function(angle) {
            return (angle + 360) / 360 * (_hcmn_.Math.PI * 2);
        };
        uiHelper.GuiMath.converRadToGrad = function(angle) {
            return angle / (2 * _hcmn_.Math.PI) * 360;
        };
        uiHelper.GuiMath.subtractPoint = function(v1, v2) {
            return new displayEngineApi.Point(v1.x - v2.x, v1.y - v2.y);
        };
        uiHelper.GuiMath.getPointLength = function(point) {
            return _hcmn_.Math.sqrt(point.x * point.x + point.y * point.y);
        };
        uiHelper.GuiMath.getUnitVector = function(vector) {
            var length = uiHelper.GuiMath.getPointLength(vector);
            return new displayEngineApi.Point(vector.x / length, vector.y / length);
        };
        uiHelper.GuiMath.getDistance = function(point1, point2) {
            return _hcmn_.Math.sqrt(_hcmn_.Math.pow(point2.x - point1.x, 2) + _hcmn_.Math.pow(point2.y - point1.y, 2));
        };
        uiHelper.GuiMath.movePointByVector = function(point, vector, distance) {
            var length = _hcmn_.Math.sqrt(vector.x * vector.x + vector.y * vector.y);
            var unitVector = new displayEngineApi.Point(vector.x / length, vector.y / length);
            return new displayEngineApi.Point(point.x + unitVector.x * distance, point.y + unitVector.y * distance);
        };
        uiHelper.GuiMath.prototype.__class__ = uiHelper.GuiMath;

        uiHelper.ISimpleUiHelper = function() {}
        uiHelper.ISimpleUiHelper.prototype = {

            getHitAreaPolygon: function(radius, steps, startAngle) {
                return {
                    arguments: ["number", "number", {
                        type: "number",
                        opt: true
                    }],
                    returns: "array"
                };
            },
            getMaskPolygon: function(radius, steps, startAngle) {
                return {
                    arguments: ["number", "number", {
                        type: "number",
                        opt: true
                    }],
                    returns: "array"
                };
            },
            clearMask: function(container) {
                return {
                    arguments: ["*"],
                    returns: "void"
                };
            },
            getUserDataFromVBContainer: function(viewBuilderContainer) {
                return {
                    arguments: ["*"],
                    returns: "null"
                };
            },
            getUserData: function(dispayObject) {
                return {
                    arguments: ["*"],
                    returns: "null"
                };
            },
            setFps: function(dispayObject, fps) {
                return {
                    arguments: ["*", "number"],
                    returns: "void"
                };
            },
            isCacheAsBitmap: function(dispayObject) {
                return {
                    arguments: ["*"],
                    returns: "boolean"
                };
            },
            wrapAsMovieClip: function(dispayObject) {
                return {
                    arguments: ["*"],
                    returns: "*"
                };
            }
        };

        uiHelper.IUiHelper = function() {}
        uiHelper.IUiHelper.prototype = {

            getNewDisplaObjectContainer: function(name) {
                return {
                    arguments: [{
                        type: "string",
                        opt: true
                    }],
                    returns: "*"
                };
            },
            getGraphics: function(points, colour, alpha) {
                return {
                    arguments: ["array", {
                        type: "number",
                        opt: true
                    }, {
                        type: "number",
                        opt: true
                    }],
                    returns: "*"
                };
            },
            showMask: function(container, points, paddingX, paddingY) {
                return {
                    arguments: ["*", "array", {
                        type: "number",
                        opt: true
                    }, {
                        type: "number",
                        opt: true
                    }],
                    returns: "void"
                };
            },
            showRectMask: function(container, width, height, paddingX, paddingY) {
                return {
                    arguments: ["*", "number", "number", {
                        type: "number",
                        opt: true
                    }, {
                        type: "number",
                        opt: true
                    }],
                    returns: "void"
                };
            },
            addMask: function(container, points, paddingX, paddingY) {
                return {
                    arguments: ["*", "array", {
                        type: "number",
                        opt: true
                    }, {
                        type: "number",
                        opt: true
                    }],
                    returns: "void"
                };
            },
            addRectMask: function(container, width, height, paddingX, paddingY) {
                return {
                    arguments: ["*", "number", "number", {
                        type: "number",
                        opt: true
                    }, {
                        type: "number",
                        opt: true
                    }],
                    returns: "void"
                };
            },
            getMask: function(points, paddingX, paddingY, alpha) {
                return {
                    arguments: ["array", {
                        type: "number",
                        opt: true
                    }, {
                        type: "number",
                        opt: true
                    }, {
                        type: "number",
                        opt: true
                    }],
                    returns: "*"
                };
            },
            getCacheHelper: function(useAsGlobal, stageName) {
                return {
                    arguments: [{
                        type: "boolean",
                        opt: true
                    }, {
                        type: "*",
                        opt: true
                    }],
                    returns: "*"
                };
            }
        };
        uiHelper.UiHelper = function(displayProvider) {
            this.displayProvider = displayProvider;
            if (displayProvider != null) this.factory = displayProvider.getFactory();
            else this.factory = null;
        };
        uiHelper.UiHelper = ck_implements(uiHelper.UiHelper, uiHelper.IUiHelper);
        uiHelper.UiHelper.__interfaces__ = [uiHelper.IUiHelper];
        uiHelper.UiHelper.__name__ = ["uiHelper", "UiHelper"];
        uiHelper.UiHelper.prototype.factory = null;
        uiHelper.UiHelper.prototype.displayProvider = null;
        uiHelper.UiHelper.prototype.getCacheHelper = function(useAsGlobal, stageName) {
            if (useAsGlobal == null) useAsGlobal = false;
            var stage;
            if (stageName == null) stage = this.displayProvider.getDefaultStage();
            else {
                var this1 = this.displayProvider.getStages();
                stage = this1.get(stageName);
            }
            if (stage == null) throw new js._Boot.HaxeError("Could not get stage by name: " + stageName);
            return new uiHelper.CacheHelper(stage, useAsGlobal);
        };
        uiHelper.UiHelper.prototype.showRectMask = function(container, width, height, paddingX, paddingY) {
            if (paddingY == null) paddingY = 0;
            if (paddingX == null) paddingX = 0;
            var maskPoints = [
                [0, 0],
                [width, 0],
                [width, height],
                [0, height],
                [0, 0]
            ];
            this.showMask(container, maskPoints, paddingX, paddingY);
        };
        uiHelper.UiHelper.prototype.showMask = function(container, points, paddingX, paddingY) {
            if (paddingY == null) paddingY = 0;
            if (paddingX == null) paddingX = 0;
            this.clearMask(container);
            var mask = this.getMask(points, paddingX, paddingY, .5);
            mask.setName("mask");
            if (container.getChildByName("mask") != null) container.removeChild(container.getChildByName("mask"));
            container.setCacheAsBitmap(false);
            container.addChildAt(mask, 0);
        };
        uiHelper.UiHelper.prototype.clearMask = function(container) {
            var mask = container.getMask();
            if (mask != null) {
                container.removeChild(mask);
                container._obj._mask = null;
            }
        };
        uiHelper.UiHelper.prototype.addRectMask = function(container, width, height, paddingX, paddingY) {
            if (paddingY == null) paddingY = 0;
            if (paddingX == null) paddingX = 0;
            var maskPoints = [
                [0, 0],
                [width, 0],
                [width, height],
                [0, height],
                [0, 0]
            ];
            this.addMask(container, maskPoints, paddingX, paddingY);
        };
        uiHelper.UiHelper.prototype.addMask = function(container, points, paddingX, paddingY) {
            if (paddingY == null) paddingY = 0;
            if (paddingX == null) paddingX = 0;
            var mask = this.getMask(points, paddingX, paddingY, 1);
            var isCachedAsBitmap = this.isCacheAsBitmap(container);
            container.setCacheAsBitmap(false);
            this.clearMask(container);
            container.setMask(mask);
            container.setCacheAsBitmap(isCachedAsBitmap);
        };
        uiHelper.UiHelper.prototype.getMask = function(points, paddingX, paddingY, alpha) {
            if (alpha == null) alpha = 0;
            if (paddingY == null) paddingY = 0;
            if (paddingX == null) paddingX = 0;
            var mask = this.getGraphics(points, 16711680, alpha);
            mask.setX(paddingX);
            mask.setY(paddingY);
            return mask;
        };
        uiHelper.UiHelper.prototype.getNewDisplaObjectContainer = function(name) {
            if (name == null) name = "NewDisplaObjectContainer";
            var container = this.factory.createDisplayObjectContainer();
            container.setName(name);
            return container;
        };
        uiHelper.UiHelper.prototype.getGraphics = function(points, colour, alpha) {
            if (alpha == null) alpha = 1;
            if (colour == null) colour = 16711680;
            var graphics = this.factory.createGraphics();
            graphics.beginFill(colour, alpha);
            graphics.moveTo(points[0][0], points[0][1]);
            var _g = 0;
            while (_g < points.length) {
                var point = points[_g];
                ++_g;
                graphics.lineTo(point[0], point[1]);
            }
            graphics.endFill();
            return graphics;
        };
        uiHelper.UiHelper.prototype.getHitAreaPolygon = function(radius, steps, startAngle) {
            if (startAngle == null) startAngle = 0.0;
            var polygon = [];
            var angle = startAngle;
            var angleStep = 2 * _hcmn_.Math.PI / steps;
            var _g = 0;
            while (_g < steps) {
                var i = _g++;
                var point = new displayEngineApi.Point(_hcmn_.Math.cos(angle) * radius, _hcmn_.Math.sin(angle) * radius);
                polygon.push(point.x + radius);
                polygon.push(point.y + radius);
                angle += angleStep;
            }
            return polygon;
        };
        uiHelper.UiHelper.prototype.getMaskPolygon = function(radius, steps, startAngle) {
            if (startAngle == null) startAngle = 0.0;
            var polygon = [];
            var angle = startAngle;
            var angleStep = 2 * _hcmn_.Math.PI / steps;
            var _g = 0;
            while (_g < steps) {
                var i = _g++;
                var point = new displayEngineApi.Point(_hcmn_.Math.cos(angle) * radius, _hcmn_.Math.sin(angle) * radius);
                polygon.push([_hcmn_.Math.round(point.x + radius), _hcmn_.Math.round(point.y + radius)]);
                angle += angleStep;
            }
            return polygon;
        };
        uiHelper.UiHelper.prototype.getUserDataFromVBContainer = function(viewBuilderContainer) {
            return this.getUserData(viewBuilderContainer.getDisplayObject());
        };
        uiHelper.UiHelper.prototype.getUserData = function(dispayObject) {
            return dispayObject.getUserData();
        };
        uiHelper.UiHelper.prototype.setFps = function(dispayObject, fps) {
            dispayObject.fps = fps;
        };
        uiHelper.UiHelper.prototype.isCacheAsBitmap = function(dispayObject) {
            return dispayObject._obj.cacheAsBitmap;
        };
        uiHelper.UiHelper.prototype.wrapAsMovieClip = function(animation) {
            var result = animation;
            var wrapResult = result;
            if (wrapResult.getFramesAmount != null) return wrapResult;
            wrapResult.getFramesAmount = function() {
                if (result.hasFrames) return result.frames.length;
                var layerContainers = result.getChildComponents();
                var $it0 = layerContainers.keys();
                while ($it0.hasNext()) {
                    var layerId = $it0.next();
                    var child = result.getVBAnimationById(layerId);
                    if (child.hasFrames) return child.frames.length;
                }
                return 0;
            };
            wrapResult.gotoAndPlayOnFrame = function(frame) {
                result.gotoAndStopOnFrame(frame);
                result.play(false);
            };
            wrapResult.gotoAndStopOnFrame = function(frame1) {
                var fixedFrame = _hcmn_.Math.round(_hcmn_.Math.min(frame1, result.getFramesAmount()));
                result.frameCount = fixedFrame;
                result.playingState = true;
                result.playParticles = false;
                var layerContainers1 = result.getChildComponents();
                var $it1 = layerContainers1.keys();
                while ($it1.hasNext()) {
                    var layerId1 = $it1.next();
                    var child1 = result.getVBAnimationById(layerId1);
                    child1.frameCount = _hcmn_.Math.round(_hcmn_.Math.max(0, fixedFrame - 1));
                    child1.playingState = true;
                }
                result.playAnimationContainer(result, result, true, true);
                result.playingState = false;
            };
            return result;
        };
        uiHelper.UiHelper.getUiHelper = function(displayProvider) {
            return new uiHelper.UiHelper(displayProvider);
        };
        uiHelper.UiHelper.getSimpleHelper = function() {
            return uiHelper.UiHelper.getUiHelper(null);
        };
        uiHelper.UiHelper.prototype.__class__ = uiHelper.UiHelper;
        uiHelper.CacheHelper.GLOBAL_CACHED_ITEMS = new _hcmn_.List();;
        return {
            exports: uiHelper
        };
    });
//# sourceURL=wildFuryUiHelper.js