var Alloy=require("alloy"),Backbone=Alloy.Backbone,_=Alloy._,Controller=function(){function e(){return r.__widgetId?{widgetId:r.__widgetId,name:r.__controllerPath}:r.__controllerPath}var t=[],r=this;this.__iamalloy=!0,_.extend(this,Backbone.Events,{__views:{},__proxyProperties:{},setParent:function(e){var r=t.length;if(r){this.parent=e.__iamalloy?e.parent:e;for(var o=0;r>o;o++)t[o].__iamalloy?t[o].setParent(this.parent):this.parent.add(t[o])}},addTopLevelView:function(e){t.push(e)},addProxyProperty:function(e,t){this.__proxyProperties[e]=t},removeProxyProperty:function(e){delete this.__proxyProperties[e]},getTopLevelViews:function(){return t},getView:function(e){return"undefined"==typeof e||null===e?t[0]:this.__views[e]},removeView:function(e){delete this[e],delete this.__views[e]},getProxyProperty:function(e){return this.__proxyProperties[e]},getViews:function(){return this.__views},destroy:function(){},getViewEx:function(e){var t=e.recurse||!1;if(t){var r=this.getView();return r?r.__iamalloy?r.getViewEx({recurse:!0}):r:null}return this.getView()},getProxyPropertyEx:function(e,t){var r=t.recurse||!1;if(r){var o=this.getProxyProperty(e);return o?o.__iamalloy?o.getProxyProperty(e,{recurse:!0}):o:null}return this.getView(e)},createStyle:function(t){return Alloy.createStyle(e(),t)},UI:{create:function(t,r){return Alloy.UI.create(e(),t,r)}},addClass:function(t,r,o){return Alloy.addClass(e(),t,r,o)},removeClass:function(t,r,o){return Alloy.removeClass(e(),t,r,o)},resetClass:function(t,r,o){return Alloy.resetClass(e(),t,r,o)}})};module.exports=Controller;