// Generated by CoffeeScript 1.3.3
var __hasProp = {}.hasOwnProperty,
  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

define(['environ', 'mediator', 'channels', 'underscore', 'backbone'], function(environ, mediator, channels, _, Backbone) {
  var Distribution, Distributions;
  Distribution = (function(_super) {

    __extends(Distribution, _super);

    function Distribution() {
      return Distribution.__super__.constructor.apply(this, arguments);
    }

    Distribution.prototype.defaults = {
      xAxis: null,
      yAxis: null,
      series: null,
      expanded: false
    };

    Distribution.prototype.sync = function(method, model, options) {};

    return Distribution;

  })(Backbone.Model);
  Distributions = (function(_super) {

    __extends(Distributions, _super);

    function Distributions() {
      return Distributions.__super__.constructor.apply(this, arguments);
    }

    Distributions.prototype.model = Distribution;

    Distributions.prototype.comparator = function(model) {
      return model.get('order');
    };

    Distributions.prototype.initialize = function() {
      var channel,
        _this = this;
      Distributions.__super__.initialize.apply(this, arguments);
      channel = _.template(channels.SESSION_LOAD, {
        key: 'distributions'
      });
      mediator.subscribe(channel, function(distributions) {
        _this.add(distributions, {
          silent: true
        });
        return _this.resolve();
      });
      return this.on('all', _.debounce(function() {
        return mediator.publish(channels.SESSION_SET, 'distributions', _this.toJSON());
      }));
    };

    Distributions.prototype.sync = function(method, model, options) {};

    return Distributions;

  })(Backbone.Collection);
  return {
    Distribution: Distribution,
    Distributions: Distributions
  };
});
