!function(a,b){"function"==typeof define&&define.amd?define(["react","react-dom","backbone","underscore"],b):"undefined"!=typeof module&&module.exports?module.exports=b(require("react"),require("react-dom"),require("backbone"),require("underscore")):b(a.React,a.ReactDOM,a.Backbone,a._)}(this,function(a,b,c,d){"use strict";function e(a,b,c){this.state={},this.component=a;var d,e,f=c||a.props||{};d=a.overrideModel&&"function"==typeof a.overrideModel?a.overrideModel():f.model,e=a.overrideCollection&&"function"==typeof a.overrideCollection?a.overrideCollection():f.collection,this.setModels(d,b),this.setCollections(e,b)}c.React||(c.React={}),c.React.Component||(c.React.Component={});var f=c.React.Component.mixin={childContextTypes:{hasParentBackboneMixin:a.PropTypes.bool.isRequired,parentModel:a.PropTypes.any,parentCollection:a.PropTypes.any},contextTypes:{hasParentBackboneMixin:a.PropTypes.bool,parentModel:a.PropTypes.any,parentCollection:a.PropTypes.any},getChildContext:function(){return{hasParentBackboneMixin:!0,parentModel:this.getModel(),parentCollection:this.getCollection()}},componentDidMount:function(){this.setElement(b.findDOMNode(this))},componentDidUpdate:function(){this.setElement(b.findDOMNode(this))},getInitialState:function(){var a={};return this.wrapper||(this.wrapper=new e(this,a)),a},componentWillMount:function(){this.wrapper||(this.wrapper=new e(this))},componentWillUnmount:function(){this.wrapper&&(this.wrapper.stopListening(),delete this.wrapper)},componentWillReceiveProps:function(a){var b=a.model,c=a.collection;this.wrapper.model&&b?this.wrapper.model!==b&&(this.wrapper.stopListening(),this.wrapper=new e(this,void 0,a)):b&&(this.wrapper=new e(this,void 0,a)),this.wrapper.collection&&c?this.wrapper.collection!==c&&(this.wrapper.stopListening(),this.wrapper=new e(this,void 0,a)):c&&(this.wrapper=new e(this,void 0,a))},$:function(){var a;if(this.$el)a=this.$el.find.apply(this.$el,arguments);else{var c=b.findDOMNode(this);a=c.querySelector.apply(c,arguments)}return a},getCollection:function(){return this.wrapper.collection||this.context.parentCollection},getModel:function(){return this.wrapper.model||this.context.parentModel},setElement:function(a){if(a&&c.$&&a instanceof c.$){if(a.length>1)throw new Error("You can only assign one element to a component");this.el=a[0],this.$el=a}else a&&(this.el=a,c.$&&(this.$el=c.$(a)));return this}};return d.extend(e.prototype,c.Events,{onError:function(a,b,c){c.silent||this.component.setState({isRequesting:!1,hasError:!0,error:b})},onInvalid:function(a,b,c){c.silent||this.component.setState({isInvalid:!0})},onRequest:function(a,b,c){c.silent||this.component.setState({isRequesting:!0,hasError:!1,isInvalid:!1})},onSync:function(a,b,c){c.silent||this.component.setState({isRequesting:!1})},setModels:function(a,b,c){var e="undefined"!=typeof a;if(e&&!a.attributes)if("object"==typeof a){var f=d.values(a);e=f.length>0&&f[0].attributes}else e=!1;e&&(this.model=a,this.setStateBackbone(a,void 0,b,c),this.startModelListeners(a))},setCollections:function(a,b,c){"undefined"!=typeof a&&(a.models||"object"==typeof a&&d.values(a)[0].models)&&(this.collection=a,this.setStateBackbone(a,void 0,b,c),this.startCollectionListeners(a))},setStateBackbone:function(a,b,c,d){if(a.models||a.attributes)this.setState.apply(this,arguments);else for(b in a)this.setStateBackbone(a[b],b,c)},getAttributes:function(a){var b=[];if(a instanceof c.Collection){for(var e=0;e