forked from VoliJS/NestedTypes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnestedtypes.min.js
More file actions
11 lines (11 loc) · 21.8 KB
/
Copy pathnestedtypes.min.js
File metadata and controls
11 lines (11 loc) · 21.8 KB
1
2
3
4
5
6
7
8
9
10
11
/**
* Backbone.NestedTypes 1.0.0 <https://github.com/Volicon/backbone.nestedTypes>
* (c) 2015 Vlad Balin & Volicon
* Released under MIT @license
*/
/**
* Date.parse with progressive enhancement for ISO 8601 <https://github.com/csnover/js-iso8601>
* � 2011 Colin Snover <http://zetafleet.com>
* Released under MIT @license
*/
!function(t,e){"object"==typeof exports?module.exports=e(require("underscore"),require("backbone")):"function"==typeof define&&define.amd?define(["underscore","backbone"],e):t.Nested=e(t._,t.Backbone)}(this,function(t,e){var n=function(n){return{underscore:t,backbone:e}[n]};return(n=function t(e,r,i){function o(u,a){if(!r[u]){if(!e[u]){var c="function"==typeof n&&n;if(!a&&c)return c(u,!0);if(s)return s(u,!0);var l=new Error("Cannot find module '"+u+"'");throw l.code="MODULE_NOT_FOUND",l}var f=r[u]={exports:{}};e[u][0].call(f.exports,function(t){var n=e[u][1][t];return o(n?n:t)},f,f.exports,t,e,r,i)}return r[u].exports}for(var s="function"==typeof n&&n,u=0;u<i.length;u++)o(i[u]);return o}({1:[function(t,e,n){function r(t){var e=t.length;return 1===e?t[0]:function(n,r){for(var i=n,o=0;e>o;o++)i=t[o].call(this,i,r);return i}}function i(t){return new f(t)}t("./object+");var o=t("./backbone+").Events.trigger3,s=t("./modelset"),u=s.isChanged,a=s.setSingleAttr,c={string:String,number:Number,boolean:Boolean},l=["triggerWhenChanged","changeEvents","parse","clone","toJSON","value","cast","create","name","value","type"],f=Object.extend({_options:{},Attribute:null,properties:{has:function(){return this}},constructor:function(t){if("typeOrValue"in t){var e=t.typeOrValue,n=c[typeof e];t=n?{type:n,value:e}:"function"==typeof e?{type:e}:{value:e}}this._options={},this.options(t)},get:function(t){var e=this._options;return e.get=e.get?e.get.unshift(t):[t],this},set:function(t){var e=this._options;return e.set=e.set?e.set.push(t):[t],this},events:function(t){return this._options.events=Object.assign(this._options.events||{},t),this},options:function(t){for(var e in t)this[e](t[e]);return this},createAttribute:function(t){var e=this._options,n=e.type?e.type.Attribute:this.Attribute;return e.changeEvents&&(e.triggerWhenChanged=e.changeEvents),new n(t,e)}});l.forEach(function(t){f.prototype[t]=function(e){return this._options[t]=e,this}});var h={hookAndCast:function(t,e,n,r){var i=this.cast(t,e,n,r),o=n.attributes[r];return this.isChanged(i,o)?(i=this.set.call(n,i,r),void 0===i?o:this.cast(i,e,n)):i},hook:function(t,e,n,r){var i=n.attributes[r];if(this.isChanged(t,i)){var o=this.set.call(n,t,r);return void 0===o?i:o}return t},delegateAndMore:function(t,e,n,r){return this.delegateEvents(this._transform(t,e,n,r),e,n,r)}},p=Object.extend({name:null,type:null,value:void 0,cast:null,get:null,set:null,events:null,__events:null,create:function(t){return new this.type},isChanged:u,clone:function(t,e){if(t&&"object"==typeof t){var n=Object.getPrototypeOf(t);if(n.clone)return t.clone(e);if(e&&e.deep&&n===Object.prototype||n===Array.prototype)return JSON.parse(JSON.stringify(t))}return t},toJSON:function(t,e){return t&&t.toJSON?t.toJSON():t},createPropertySpec:function(){return function(t,e,n){return{set:function(n){a(this,e,n,t)},get:n?function(){return n.call(this,this.attributes[e],e)}:function(){return this.attributes[e]}}}(this,this.name,this.get)},_transform:null,transform:function(t){return t},delegateEvents:function(t,e,n,r){var i=n.attributes[r];return this.isChanged(i,t)&&(i&&i.trigger&&n.stopListening(i),t&&t.trigger&&(this.events&&n.listenTo(t,this.events),this.__events&&n.listenTo(t,this.__events)),o(n,"replace:"+r,n,t,i)),t},constructor:function(t,e){this.name=t,Object.transform(this,e,function(t,e){return"events"===e&&this.events?Object.assign(this.events,t):"get"===e?(this.get&&t.unshift(this.get),r(t)):"set"===e?(this.set&&t.push(this.set),r(t)):t},this),this.initialize(e),this.cast&&(this.transform=this._transform=this.cast),this.set&&(this.transform=this._transform=this.cast?h.hookAndCast:h.hook),(this.events||this.__events)&&(this.transform=this._transform?h.delegateAndMore:this.delegateEvents)}},{attach:function(){function t(t){return t||(t={}),t.type||(t.type=this),new f(t)}function e(t){return new f({type:this,value:t})}return function(){for(var n=0;n<arguments.length;n++){var r=arguments[n];r.attribute=r.options=t,r.value=e,r.Attribute=this,Object.defineProperty(r,"has",{get:function(){return this._has||this.options()},set:function(t){this._has=t}})}}}()});f.prototype.Attribute=p,f.prototype.attribute=f.prototype.options,i.Type=p,i.create=function(t,e){return t&&t instanceof f||(t=new f({typeOrValue:t})),t.createAttribute(e)},e.exports=i},{"./backbone+":2,"./modelset":7,"./object+":8}],2:[function(t,e,n){function r(t,e,n){if(t)for(var r,i=0,o=t.length;o>i;i++)(r=t[i]).callback.call(r.ctx,e,n)}function i(t,e,n,r){if(t)for(var i,o=0,s=t.length;s>o;o++)(i=t[o]).callback.call(i.ctx,e,n,r)}function o(t,e,n,r,i){if(t)for(var o,s=0,u=t.length;u>s;s++)(o=t[s]).callback.call(o.ctx,e,n,r,i)}var s=t("./object+"),u=t("backbone");e.exports=u;var a=u.Events,c=a.listenTo;a.listenTo=function(t,e){if("object"==typeof e){for(var n in e)c.call(this,t,n,e[n]);return this}return c.apply(this,arguments)},["Model","Collection","View","Router","History"].forEach(function(t){var e=u[t];e.prototype.listenTo=a.listenTo,Object.extend.attach(e)}),Object.assign(s.prototype,a),a.trigger2=function(t,e,n,o){var s=t._events;s&&(r(s[e],n,o),i(s.all,e,n,o))},a.trigger3=function(t,e,n,r,s){var u=t._events;u&&(i(u[e],n,r,s),o(u.all,e,n,r,s))}},{"./object+":8,backbone:"backbone"}],3:[function(t,e,n){function r(t){return function(){this.__changing++||this.trigger("before:change");var e=t.apply(this,arguments);return--this.__changing||this.trigger("after:change"),e}}var i=t("./backbone+"),o=t("./model"),s=t("./errors"),u=t("underscore"),a=i.Collection.prototype;e.exports=i.Collection.extend({triggerWhenChanged:i.VERSION>="1.2.0"?"update change reset":"add remove change reset",__class:"Collection",model:o,isValid:function(t){return this.every(function(e){return e.isValid(t)})},get:function(t){return null==t?void 0:"object"==typeof t?this._byId[t.id]||this._byId[t.cid]:this._byId[t]},deepClone:function(){return this.clone({deep:!0})},clone:function(t){var e=t&&t.deep?this.map(function(e){return e.clone(t)}):this.models;return new this.constructor(e)},__changing:0,set:r(function(t,e){return t&&("object"==typeof t&&(t instanceof Array||t instanceof o||Object.getPrototypeOf(t)===Object.prototype)||s.wrongCollectionSetArg(this,t)),a.set.call(this,t,e)}),remove:r(a.remove),add:r(a.add),reset:r(a.reset),sort:r(a.sort),getModelIds:function(){return u.pluck(this.models,"id")}},{__subsetOf:null,defaults:function(t){return this.prototype.model.extend({defaults:t}).Collection},extend:function(){var t=i.Collection.extend.apply(this,arguments);return t.__subsetOf=null,t}})},{"./backbone+":2,"./errors":4,"./model":6,underscore:"underscore"}],4:[function(t,e,n){function r(t){return"string"==typeof t?'"'+t+'"':t}t("./object+"),Object.assign(Object.extend.error,{argumentIsNotAnObject:function(t,e){console.error("[Type Error] Attribute hash is not an object in "+t.__class+".set(",r(e),"); this =",t)},unknownAttribute:function(t,e,n){t.suppressTypeErrors||console.warn("[Type Error] Attribute has no default value in "+t.__class+'.set( "'+e+'",',r(n),"); this =",t)},wrongCollectionSetArg:function(t,e){console.error("[Type Error] Wrong argument type in "+t.__class+".set(",r(e),"); this =",t)}}),e.exports=Object.extend.error},{"./object+":8}],5:[function(t,e,n){function r(t){var e,n,r,i=0;if(e=c.exec(t))n=Number(e[1]);else if(r=l.exec(t)){for(var o,s=0;o=a[s];++s)r[o]=+r[o]||0;r[2]=(+r[2]||1)-1,r[3]=+r[3]||1,"Z"!==r[8]&&void 0!==r[9]&&(i=60*r[10]+r[11],"+"===r[9]&&(i=0-i)),n=Date.UTC(r[1],r[2],r[3],r[4],r[5]+i,r[6],r[7])}else n=Date.parse(t);return n}var i=t("./attribute"),o=t("./modelset"),s=t("./model"),u=t("./collection");i.Type.extend({cast:function(t){return null==t||t instanceof this.type?t:new this.type(t)},clone:function(t,e){return t.clone?t.clone(t,e):this.cast(JSON.parse(JSON.stringify(t)))}}).attach(Function.prototype);var a=[1,4,5,6,7,10,11],c=/\/Date\(([0-9]+)\)\//,l=/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/;i.Type.extend({cast:function(t){return null==t||t instanceof Date?t:new Date("string"==typeof t?r(t):t)},toJSON:function(t){return t&&t.toJSON()},isChanged:function(t,e){return(t&&+t)!==(e&&+e)},clone:function(t){return new Date(+t)}}).attach(Date),Integer=function(t){return t?Math.round(t):0},i.Type.extend({create:function(){return this.type()},toJSON:function(t){return t},cast:function(t){return null==t?null:this.type(t)},isChanged:function(t,e){return t!==e},clone:function(t){return t}}).attach(Number,Boolean,String,Integer),i.Type.extend({toJSON:function(t){return t},cast:function(t){return null==t||t instanceof Array?t:[t]}}).attach(Array);var f=new(i.Type.extend({isChanged:function(){return!0}})),h=o.setAttrs,p=o.setSingleAttr;i.Type.extend({create:function(t){return new this.type(null,t)},clone:function(t,e){return t&&t.clone(e)},toJSON:function(t){return t&&t.toJSON()},isChanged:function(t,e){return t!==e},isBackboneType:!0,isModel:!0,createPropertySpec:function(){return this.__events?function(t,e,n){return{set:function(t){var n={};n[e]=t,h(this,n)},get:n?function(){return n.call(this,this.attributes[e],e)}:function(){return this.attributes[e]}}}(this,this.name,this.get):i.Type.prototype.createPropertySpec.call(this)},cast:function(t,e,n,r){var i=null!=t&&!(t instanceof this.type),o=n.attributes[r];return i&&(o?(e&&e.parse&&this.isModel&&(t=o.parse(t)),o.set(t,e),t=o):t=new this.type(t,e)),t},initialize:function(t){var e=this.name,n=this.triggerWhenChanged||t.type.prototype.triggerWhenChanged;this.isModel=this.type.prototype instanceof s,n&&(this.__events=this.isModel?{}:{"before:change":o.__begin,"after:change":o.__commit},this.__events[n]=function(){var t=this.attributes[e];this.__duringSet?this.__nestedChanges[e]=t:p(this,e,t,f)})}}).attach(s,u)},{"./attribute":1,"./collection":3,"./model":6,"./modelset":7}],6:[function(t,e,n){function r(t,e,n){for(var r in e)e[r]=t[r].clone(e[r],n);return e}function i(t,e){var n=t.defaults||t.attributes||{},r="function"==typeof n&&n,i=e.prototype.__attributes;r&&(n=n());var u=Object.transform({},n,h.create),l=t.idAttribute;l&&!u[l]&&(u[l]=h({value:void 0}).createAttribute(l)),u.id&&(u.id.createPropertySpec=!1);var f=d.defaults({},u,i),p=s(f);return d.extend(d.omit(t,"collection","attributes"),{__attributes:new p(f),_parse:o(f,u)||e.prototype._parse,defaults:r||a(f),properties:c(t.properties,u),Attributes:p})}function o(t,e){var n=["var a = this.__attributes;"],r=!1;for(var i in t)if(e[i]&&e[i].parse&&(r=!0),t[i].parse){var o='if("'+i+'" in r) r.'+i+"=a."+i+".parse.call(this,r."+i+',"'+i+'");';n.push(o)}return n.push("return r;"),r?new Function("r",n.join("")):null}function s(t){var e=[];for(var n in t)e.push("this."+n+"=x."+n+";");var r=new Function("x",e.join(""));return r.prototype=Object.prototype,r}function u(t){if(null===t)return!0;switch(typeof t){case"number":case"string":case"boolean":return!0;case"object":var e=Object.getPrototypeOf(t);if(e===Object.prototype||e===Array.prototype)return d.every(t,u)}return!1}function a(t){var e=[],n={},r={};d.each(t,function(t,i){void 0===t.value&&t.type?(n[i]=t,e.push("this."+i+"=i."+i+".create( o );")):u(t.value)?e.push("this."+i+"="+JSON.stringify(t.value)+";"):void 0===t.value?e.push("this."+i+"=undefined;"):(r[i]=t.value,e.push("this."+i+"=r."+i+";"))});var i=new Function("r","i","o",e.join(""));return i.prototype=Object.prototype,function(t,e){var o,s=e;if(e&&(e.collection||e.parse)){s={};for(o in e)"collection"!==o&&"parse"!==o&&(s[o]=e[o])}var u=new i(r,n,s);for(var o in t)u[o]=t[o];return u}}function c(t,e){return t===!1?{}:(t||(t={}),Object.transform(t,e,function(e,n){return!t[n]&&e.createPropertySpec?e.createPropertySpec():void 0}))}var l=t("./backbone+").Model,f=t("./modelset"),h=t("./attribute"),p=t("./errors"),d=t("underscore"),g=l.prototype,v=f.setSingleAttr,b=f.setAttrs,y=f.transform,_=l.extend({triggerWhenChanged:"change",properties:{id:{get:function(){var t=this.idAttribute;return"id"===t?this.attributes.id:this[t]},set:function(t){var e=this.idAttribute;v(this,e,t,this.__attributes[e])}}},__attributes:{id:h({value:void 0}).createAttribute("id")},__class:"Model",__duringSet:0,defaults:function(){return{}},__begin:f.__begin,__commit:f.__commit,set:function(t,e,n){switch(typeof t){case"string":var r=this.__attributes[t];if(r&&!r.isBackboneType&&!n)return v(this,t,e,r);var i={};return i[t]=e,b(this,i,n);case"object":if(t&&Object.getPrototypeOf(t)===Object.prototype)return b(this,t,e);default:p.argumentIsNotAnObject(this,t)}},deepGet:function(t){for(var e=t.split("."),n=this,r=0,i=e.length;n&&i>r;r++)n=n.get?n.get(e[r]):n[e[r]];return n},deepSet:function(t,e,n){for(var r=t.split("."),i=r.length-1,o=this,s=r[i],u=0;i>u;u++){var a=r[u],c=o.get?o.get(a):o[a];if(!c){var l=o.__attributes;if(!l)return;var f=l[a].create(n);if(n&&n.nullify&&f.__attributes){var h=new f.Attributes({});for(var p in h)h[p]=null;f.set(h)}o[a]=c=f}o=c}return o.set?o.set(s,e,n):o[s]=e},constructor:function(t,e){var n=this.__attributes,i=t||{},o=e||{};this.cid=d.uniqueId("c"),this.attributes={},o.collection&&(this.collection=o.collection),o.parse&&(i=this.parse(i,o)||{}),("object"!=typeof i||Object.getPrototypeOf(i)!==Object.prototype)&&(p.argumentIsNotAnObject(this,i),i={}),i=o.deep?r(n,new this.Attributes(i),o):this.defaults(i,o),y(this,i,n,o),this.attributes=i,this.changed={},this.initialize.apply(this,arguments)},get:function(t){return this[t]},clone:function(t){return new this.constructor(this.attributes,t)},deepClone:function(){return this.clone({deep:!0})},toJSON:function(){var t={},e=this.attributes,n=this.__attributes;for(var r in e){var i=e[r],o=n[r],s=o&&o.toJSON;s&&(t[r]=s.call(this,i,r))}return t},parse:function(t){return this._parse(t)},_parse:d.identity,isValid:function(t){return g.isValid.call(this,t)&&d.every(this.attributes,function(e){return e&&e.isValid?e.isValid(t):e instanceof Date?!d.isNaN(e.getTime()):!d.isNaN(e)})},_:d},{defaults:function(t){return this.extend({defaults:t})},extend:function(t,e){var n=Object.extend.call(this);return n.Collection=this.Collection.extend(),t?n.define(t,e):n},define:function(t,e){var n=Object.getPrototypeOf(this.prototype).constructor,r=i(t,n),o=this;Object.extend.Class.define.call(o,r,e);var s={model:o};return r.urlRoot&&(s.url=r.urlRoot),o.Collection.define(d.defaults(t.collection||{},s)),o}});e.exports=_},{"./attribute":1,"./backbone+":2,"./errors":4,"./modelset":7,underscore:"underscore"}],7:[function(t,e,n){function r(t,e){return!(t===e||t&&e&&"object"==typeof t&&"object"==typeof e&&l.isEqual(t,e))}function i(t,e,n,r){"use strict";var i=t._changing,o=t.attributes;t._changing=!0,i||(t._previousAttributes=new t.Attributes(o),t.changed={});var s=t._previousAttributes,u={},a=r.transform(n,u,t,e),c=r.isChanged;if(c(s[e],a)?t.changed[e]=a:delete t.changed[e],c(o[e],a)&&(o[e]=a,t._pending=u,d(t,"change:"+e,t,a,u)),i)return t;for(;t._pending;)u=t._pending,t._pending=!1,p(t,"change",t,u);return t._pending=!1,t._changing=!1,t}function o(t,e,n){"use strict";var i=n||{};if(!t._validate(e,i))return!1;var o=i.unset,s=i.silent,u=[],a=t._changing,c=t.attributes,l=t.__attributes;t._changing=!0,a||(t._previousAttributes=new t.Attributes(c),t.changed={});var f=t._previousAttributes;for(var h in e){var g=l[h],v=g?g.isChanged:r,b=e[h];v(c[h],b)&&u.push(h),v(f[h],b)?t.changed[h]=b:delete t.changed[h],o?delete c[h]:c[h]=b}if(!s){u.length&&(t._pending=i);for(var y=0,_=u.length;_>y;y++)h=u[y],d(t,"change:"+h,t,c[h],i)}if(a)return t;if(!s)for(;t._pending;)i=t._pending,t._pending=!1,p(t,"change",t,i);return t._pending=!1,t._changing=!1,t}function s(t,e,n){return t.__begin(),u(t,e,t.__attributes,n),t.__commit(e,n),t}function u(t,e,n,r){for(var i in e){var o=n[i],s=e[i];o?e[i]=o.transform(s,r,t,i):h.unknownAttribute(t,i,s)}}function a(){this.__duringSet++||(this.__nestedChanges={})}function c(t,e){var n=t;if(!--this.__duringSet){var r=this.__nestedChanges,i=this.attributes;n||(n={});for(var s in r){var u=s in n?n[s]:n[s]=r[s];u===i[s]&&(i[s]=null)}this.__nestedChanges={}}n&&o(this,n,e)}var l=t("underscore"),f=t("./backbone+").Events,h=t("./errors"),p=f.trigger2,d=f.trigger3;e.exports={isChanged:r,setSingleAttr:i,setAttrs:s,transform:u,__begin:a,__commit:c}},{"./backbone+":2,"./errors":4,underscore:"underscore"}],8:[function(t,e,n){!function(t){for(var e in t)Object[e]||Object.defineProperty(Object,e,{enumerable:!1,configurable:!0,writable:!0,value:t[e]})}({assign:function(t,e){if(null==t)throw new TypeError("Cannot convert first argument to object");for(var n=Object(t),r=1;r<arguments.length;r++){var i=arguments[r];if(null!=i)for(var o=Object.keys(Object(i)),s=0,u=o.length;u>s;s++){var a=o[s],c=Object.getOwnPropertyDescriptor(i,a);void 0!==c&&c.enumerable&&(n[a]=i[a])}}return n},transform:function(t,e,n,r){for(var i in e)if(e.hasOwnProperty(i)){var o=n.call(r,e[i],i);"undefined"==typeof o||(t[i]=o)}return t},getPropertyDescriptor:function(t,e){for(var n;!n&&t;t=Object.getPrototypeOf(t))n=Object.getOwnPropertyDescriptor(t,e);return n},extend:function(){function t(){this.initialize.apply(this,arguments)}function e(e,n){var r,i=this===Object?t:this;return"function"==typeof e?(r=e,e=null):r=e&&e.hasOwnProperty("constructor")?e.constructor:function(){return i.apply(this,arguments)},Object.assign(r,i),r.prototype=Object.create(i.prototype),r.prototype.constructor=r,r.__super__=i.prototype,e&&r.define(e,n),r}function n(t,e){var n=Object.getPropertyDescriptor(this.prototype,e);if(n){var r="function"==typeof n.value,i="function"==typeof t;r&&!i&&o.overrideMethodWithValue(this,e,n)}return t}function r(t,e){var n=Object.getPropertyDescriptor(this.prototype,e);return n&&"function"==typeof n.value&&o.overrideMethodWithValue(this,e,n),t instanceof Function?{get:t}:t}function i(t,e){return Object.transform(this.prototype,t,n,this),Object.transform(this,e,n,this),t&&Object.defineProperties(this.prototype,Object.transform({},t.properties,r,this)),this}var o={overrideMethodWithValue:function(t,e,n){console.warn("[Type Warning] Base class method overriden with value in Object.extend({ "+e+" : "+n+" }); Object =",t.prototype)}};return e.attach=function(){for(var t=0;t<arguments.length;t++){var n=arguments[t];n.extend=e,n.define=i,n.prototype.initialize||(n.prototype.initialize=function(){})}},e.attach(t),e.Class=t,e.error=o,e}()}),e.exports=Object.extend.Class},{}],9:[function(t,n,r){function i(t){switch(typeof t){case"function":return t;case"object":return function(){return t};case"string":return new Function("return this."+t)}}var o=t("backbone").VERSION,s=t("./attribute"),u=t("./collection"),a=t("underscore");r.from=function(t){function e(t){return t&&"object"==typeof t?t.id:t}var n=i(t),r=s.Type.extend({toJSON:e,clone:e,isChanged:function(t,e){var n=t&&"object"==typeof t?t.id:t,r=e&&"object"==typeof e?e.id:e;return n!==r},get:function(t,e){if("object"!=typeof t){var r=n.call(this);if(r&&r.length){t=r.get(t)||null,this.attributes[e]=t;var i=this.__attributes[e];t&&i.events&&this.listenTo(t,i.events)}else t=null}return t}}),o=s({value:null});return o.Attribute=r,o};var c=u.prototype,l={triggerWhenChanged:o>="1.2.0"?"update reset":"add remove reset",__class:"Collection.SubsetOf",resolvedWith:null,refs:null,toJSON:function(){return this.refs||a.pluck(this.models,"id")},clone:function(t){var e=c.clone.call(this,a.omit(t,"deep"));return e.resolvedWith=this.resolvedWith,e.refs=this.refs,e},parse:function(t){var e=[];return this.resolvedWith?e=a.compact(a.map(t,function(t){return this.resolvedWith.get(t)},this)):this.refs=t,e},toggle:function(t){var e=this.resolvedWith.get(t);this.get(e)?this.remove(e):this.add(e)},addAll:function(){this.reset(this.resolvedWith.models)},removeAll:function(){this.reset()},justOne:function(t){var n=t instanceof e.Model?t:this.resolvedWith.get(t);this.set([n])},set:function(t,e){var n={merge:!1};t&&t instanceof Array&&t.length&&"object"!=typeof t[0]&&(n.merge=n.parse=!0),c.set.call(this,t,a.defaults(n,e))},resolve:function(t){return t&&t.length&&(this.resolvedWith=t,this.refs&&(this.reset(this.refs,{silent:!0}),this.refs=null)),this}};r.subsetOf=function(t){var e=this.__subsetOf||(this.__subsetOf=this.extend(l)),n=i(t);return s({type:e,get:function(t){return!t||t.resolvedWith||t.resolve(n.call(this)),t}})}},{"./attribute":1,"./collection":3,backbone:"backbone",underscore:"underscore"}],10:[function(t,e,n){var r=t("./backbone+"),i=t("./model"),o=t("./collection"),s=t("underscore"),u=null;n.get=function(){return u},n.set=function(t){s.each(t,function(e,n){e.options&&(t[n]=e.options({get:function(t){return this.resolved[n]||(t.fetch&&t.fetch(),this.resolved[n]=!0),t},set:function(t){return t.length||(this.resolved[n]=!1),t}}))});var e=r.$,n=i.extend({attributes:t,resolved:{},initialize:function(){this.resolved={},this.installHooks()},installHooks:function(){var t=this;s.each(this.attributes,function(e,n){if(e){var r=e.fetch;r&&(e.fetch=function(){return t.resolved[n]=!0,r.apply(this,arguments)}),e instanceof o&&e.length&&(this.resolved[n]=!0)}},this)},fetch:function(){var t=[],n=arguments.length?arguments:s.keys(this.resolved);return s.each(n,function(e){var n=this.attributes[e];n.fetch&&t.push(n.fetch())},this),e&&e.when&&e.when.apply(r.$,t)},clear:function(){var t=this.defaults();return arguments.length&&(t=s.pick(t,s.toArray(arguments))),this.set(t),this.installHooks(),this}});i.prototype.store=u=new n}},{"./backbone+":2,"./collection":3,"./model":6,underscore:"underscore"}],nestedtypes:[function(t,e,n){var r=t("./model"),i=t("./collection"),o=t("./relations"),s=t("./attribute");t("./metatypes"),i.subsetOf=o.subsetOf,r.from=o.from,r.Collection=i,Object.defineProperty(n,"store",t("./store")),Object.assign(n,{Class:t("./object+"),error:t("./errors"),attribute:s,options:s,value:function(t){return s({value:t})},Collection:i,Model:r,defaults:function(t){return r.defaults(t)}})},{"./attribute":1,"./collection":3,"./errors":4,"./metatypes":5,"./model":6,"./object+":8,"./relations":9,"./store":10}]},{},[]))("nestedtypes")});