var __bind=function(e,t){return function(){return e.apply(t,arguments)}},__hasProp={}.hasOwnProperty,__extends=function(e,t){function r(){this.constructor=e}for(var n in t)__hasProp.call(t,n)&&(e[n]=t[n]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e};define(["environ","mediator","jquery","underscore","backbone","serrano","charts"],function(e,t,n,r,i,s,o){var u,a;return a=r.template('<button class=btn title="Add Chart"><i class=icon-signal alt="Add Chart"></i></button>'),u=function(e){function r(){return this.updateCharts=__bind(this.updateCharts,this),r.__super__.constructor.apply(this,arguments)}return __extends(r,e),r.prototype.id="analysis-area",r.prototype.deferred={updateCharts:!0},r.prototype.initialize=function(){var e,i=this;return r.__super__.initialize.apply(this,arguments),this.charts=[],this.$toolbar=n("<ul>").addClass("nav pull-right").hide().appendTo("#subnav .container-fluid"),this.$el.hide().appendTo("#main-area .inner").addClass("row-fluid").sortable({items:"> .area-container",handle:".heading",update:function(e,t){var n,r,s,o,u,a,f;n=i.$el.children(".chart-container"),a=i.charts,f=[];for(o=0,u=a.length;o<u;o++)s=a[o],r=n.index(s.el),f.push(s.model.set({order:r}));return f}}),e=n(a()).on("click",function(e){return i.addChart()}),this.$toolbar.append(e),this.distributions=new o.Distributions,this.distributions.when(function(){var e,t,n,r,s;r=i.distibution.models,s=[];for(t=0,n=r.length;t<n;t++)e=r[t],s.push(i.addChart(e));return s}),t.subscribe(s.DATACONTEXT_SYNCED,this.updateCharts)},r.prototype.updateCharts=function(){var e,t,n,r;r=this.charts;for(t=0,n=r.length;t<n;t++)e=r[t],e.updateChart()},r.prototype.load=function(){return this.$el.show(),this.$toolbar.show()},r.prototype.unload=function(){return this.$el.hide(),this.$toolbar.hide()},r.prototype.addChart=function(e){var t,n;return!e instanceof o.Distribution?t=e:t=this.distributions.create(e),n=new o.DistributionChart({model:t,collection:App.DataField}),this.charts.push(n),this.$el.append(n.$el),n.changeChart()},r}(i.View)})