-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathknockback-core.min.js
9 lines (9 loc) · 39.3 KB
/
knockback-core.min.js
1
2
3
4
5
6
7
8
9
/*
knockback-core.js 1.2.3
Copyright (c) 2011-2019 Kevin Malakoff.
License: MIT (http://www.opensource.org/licenses/mit-license.php)
Source: https://github.com/kmalakoff/knockback
Dependencies: Knockout.js, Backbone.js, and Underscore.js (or LoDash.js).
Optional dependencies: Backbone.ModelRef.js and BackboneORM.
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("backbone"),require("underscore"),require("knockout")):"function"==typeof define&&define.amd?define(["backbone","underscore","knockout"],t):"object"==typeof exports?exports.kb=t(require("backbone"),require("underscore"),require("knockout")):e.kb=t(e.Backbone,e._,e.ko)}(this,function(d,e,f){return h={},i.m=g=[function(o,e,i){(function(e){var t,a,r,u,c,l,n;function d(){}c=null!=c?c:e,u=i(23),a=["release","destroy","dispose"],o.exports=(d.VERSION="1.2.3",d.TYPE_UNKNOWN=0,d.TYPE_SIMPLE=1,d.TYPE_ARRAY=2,d.TYPE_MODEL=3,d.TYPE_COLLECTION=4,d.wasReleased=function(e){return!e||e.__kb_released},d.isReleaseable=function(e,t){var r,n,o,i;if(null==t&&(t=0),!e||e!==Object(e)||e.__kb_released)return!1;if(u.isObservable(e)||e instanceof d.ViewModel)return!0;if("function"==typeof e||d.isModel(e)||d.isCollection(e))return!1;for(o=0,i=a.length;o<i;o++)if("function"==typeof e[a[o]])return!0;if(0<t)return!1;for(r in e)if(n=e[r],"__kb"!==r&&d.isReleaseable(n,t+1))return!0;return!1},d.release=function(e){var t,r,n,o,i,s;if(d.isReleaseable(e))if(e.__kb_released=!0,l.isArray(e))for(r in e)o=e[r],d.isReleaseable(o)&&(e[r]=null,d.release(o));else{if(!u.isObservable(e)||!l.isArray(t=d.peek(e))){for(i=0,s=a.length;i<s;i++)if("function"==typeof e[n=a[i]])return e[n].call(e);return u.isObservable(e)?void 0:this.releaseKeys(e)}if(e.__kb_is_co||e.__kb_is_o&&e.valueType()===d.TYPE_COLLECTION)return"function"==typeof e.destroy?e.destroy():void 0;for(r in t)o=t[r],d.isReleaseable(o)&&(t[r]=null,d.release(o));"function"==typeof e.dispose&&e.dispose()}},d.releaseKeys=function(e){var t,r;for(t in e)r=e[t],"__kb"!==t&&d.isReleaseable(r)&&(e[t]=null,d.release(r))},d.releaseOnNodeRemove=function(e,t){return e||d._throwUnexpected(this,"missing view model"),t||d._throwUnexpected(this,"missing node"),u.utils.domNodeDisposal.addDisposeCallback(t,function(){return d.release(e)})},d.renderTemplate=function(e,t,r){var n,o,i,s,a,l;if(null==r&&(r={}),!(n=null!=c?c.document:void 0))return"undefined"!=typeof console&&null!==console?console.log("renderTemplate: document is undefined"):void 0;if(o=n.createElement("div"),s=u.renderTemplate(e,t,r,o,"replaceChildren"),1===o.childNodes.length)o=o.childNodes[0];else if(o.childNodes.length)for(i=a=0,l=o.childNodes.length;0<=l?a<=l:l<=a;i=0<=l?++a:--a)try{u.storedBindingContextForNode(o,u.contextFor(o.childNodes[i]));break}catch(e){}return d.releaseOnNodeRemove(t,o),s.dispose(),t.afterRender&&!r.afterRender&&t.afterRender(o),o},d.applyBindings=function(e,t){var r,n,o,i,s;if(t.length)for(t=(s=[document.createElement("div"),t])[0],o=0,i=(n=s[1]).length;o<i;o++)r=n[o],t.appendChild(r);return u.applyBindings(e,t),d.releaseOnNodeRemove(e,t),t},d.getValue=function(e,t,r){var n;if(e)return l.isFunction(e[t])&&(null!=(n=d.settings.orm)?n.useFunction(e,t):void 0)?e[t]():r?e.get.apply(e,l.map([t].concat(r),function(e){return d.peek(e)})):e.get(t)},d.setValue=function(e,t,r){var n,o;if(e)return l.isFunction(e[t])&&(null!=(o=d.settings.orm)?o.useFunction(e,t):void 0)?e[t](r):((n={})[t]=r,e.set(n))},d.ignore=(null!=(n=u.dependencyDetection)?n.ignore:void 0)||function(e,t,r){var n;return n=null,u.computed(function(){return n=e.apply(t,r||[])}).dispose(),n},d.extend=i(16),d._throwMissing=function(e,t){throw(l.isString(e)?e:e.constructor.name)+": "+t+" is missing"},d._throwUnexpected=function(e,t){throw(l.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"},d.publishMethods=function(e,t,r){var n,o,i;for(o=0,i=r.length;o<i;o++)e[n=r[o]]=d._.bind(t[n],t)},d.peek=function(e){return u.isObservable(e)?e.peek?e.peek():d.ignore(function(){return e()}):e},d.isModel=function(e){return e&&(e instanceof d.Model||"function"==typeof e.get&&"function"==typeof e.bind)},d.isCollection=function(e){return e&&e instanceof d.Collection},r=d),l=c.Parse?(t=r.Parse=c.Parse,r._=c.Parse._):(t=r.Backbone=i(21),r._=i(22)),r.ko=u,r.Collection=t.Collection,r.Model=t.Object||t.Model,r.Events=t.Events}).call(e,i(3))},function(e,t,r){var n,o,i,s,a,l;for(i in l=o=r(0),a=l._,l.ko,n={default:null,"backbone-orm":null,"backbone-associations":r(19),"backbone-relational":r(20)},o.settings={orm:n.default},n)if((s=n[i])&&s.isAvailable()){o.settings.orm=s;break}e.exports=function(e){var t;for(i in null==e&&(e={}),e)switch(s=e[i],i){case"orm":if(a.isString(s)){if(!n.hasOwnProperty(s)){console.log("Knockback configure: could not find orm: "+s+". Available: "+a.keys(n).join(", "));continue}if((t=n[s])&&!t.isAvailable()){console.log("Knockback configure: could not enable orm "+s+". Make sure it is included before Knockback");continue}o.settings.orm=t;continue}o.settings.orm=s;break;default:o.settings[i]=s}}},function(e,t,r){var l,u,c,n;function o(e){this.create_options=e,this._vo=u.observable(null)}n=l=r(0),c=n._,u=n.ko,e.exports=(o.prototype.destroy=function(){var e;return this.__kb_released=!0,(e=this.__kb_value)&&(this.__kb_value=null,this.create_options.store&&l.utils.wrappedCreator(e)?this.create_options.store.release(e):l.release(e)),this.create_options=null},o.prototype.value=function(){return u.utils.unwrapObservable(this._vo())},o.prototype.rawValue=function(){return this.__kb_value},o.prototype.valueType=function(e,t){var r;return r=l.getValue(e,t),this.value_type||this._updateValueObservable(r),this.value_type},o.prototype.update=function(e){var t,r,n;if(!this.__kb_released){switch(void 0!==e||(e=null),t=l.utils.valueType(e),(null!=(n=this.__kb_value)?n.__kb_released:void 0)&&(this.__kb_value=this.value_type=void 0),r=this.__kb_value,this.value_type){case l.TYPE_COLLECTION:if(this.value_type===l.TYPE_COLLECTION&&t===l.TYPE_ARRAY)return r(e);if(t===l.TYPE_COLLECTION||c.isNull(e))return void(e&&e instanceof l.CollectionObservable?this._updateValueObservable(l.utils.wrappedObject(e),e):l.peek(r.collection)!==e&&r.collection(e));break;case l.TYPE_MODEL:if(t===l.TYPE_MODEL||c.isNull(e))return void(e&&!l.isModel(e)?this._updateValueObservable(l.utils.wrappedObject(e),e):l.utils.wrappedObject(r)!==l.utils.resolveModel(e)&&this._updateValueObservable(e))}if(this.value_type!==t||c.isUndefined(this.value_type)){if(l.peek(r)!==e)return this._updateValueObservable(e)}else if(l.peek(r)!==e)return r(e)}},o.prototype._updateValueObservable=function(e,t){var r,n,o,i,s,a;return r=this.create_options,n=l.utils.inferCreator(e,r.factory,r.path),null!==e||n||(this.value_type===l.TYPE_MODEL?n=l.ViewModel:this.value_type===l.TYPE_COLLECTION&&(n=l.CollectionObservable)),r.creator=n,s=l.TYPE_UNKNOWN,o=(a=[this.__kb_value,void 0])[0],this.__kb_value=a[1],t?(i=t,r.store&&r.store.retain(t,e,n)):n?r.store?i=r.store.retainOrCreate(e,r,!0):n.models_only?(i=e,s=l.TYPE_SIMPLE):i=n.create?n.create(e,r):new n(e,r):i=c.isArray(e)?(s=l.TYPE_ARRAY,u.observableArray(e)):(s=l.TYPE_SIMPLE,u.observable(e)),(this.value_type=s)===l.TYPE_UNKNOWN&&(u.isObservable(i)?i.__kb_is_co?(this.value_type=l.TYPE_COLLECTION,l.utils.wrappedObject(i,e)):this.value_type||(this.value_type=l.TYPE_SIMPLE):(this.value_type=l.TYPE_MODEL,l.utils.wrappedObject(i,l.utils.resolveModel(e)))),o&&(this.create_options.store?this.create_options.store.release(o):l.release(o)),this.__kb_value=i,this._vo(i)},o.prototype._inferType=function(e){},o)},function(Cb,Db){var Eb;Eb=function(){return this}();try{Eb=Eb||Function("return this")()||eval("this")}catch(e){"object"==typeof window&&(Eb=window)}Cb.exports=Eb},function(e,t,r){var a,_,c,p,n,s=[].indexOf||function(e){for(var t=0,r=this.length;t<r;t++)if(t in this&&this[t]===e)return t;return-1};function o(o,e,i){this._onCollectionChange=function(e,t){return function(){return e.apply(t,arguments)}}(this._onCollectionChange,this);var s,u=this;return s=Array.prototype.slice.call(p.isArguments(o)?o:arguments),_.ignore(function(){var e,t,l,r,n;for(o=s[0]instanceof _.Collection?s.shift():p.isArray(s[0])?new _.Collection(s.shift()):new _.Collection,p.isFunction(s[0])&&(s[0]={view_model:s[0]}),i={},r=0,n=s.length;r<n;r++)e=s[r],p.extend(i,e);return(l=_.utils.wrappedObservable(u,c.observableArray([]))).__kb_is_co=!0,u.in_edit=0,u.__kb||(u.__kb={}),(i=_.utils.collapseOptions(i)).auto_compact&&(u.auto_compact=!0),i.sort_attribute?u._comparator=c.observable(u._attributeComparator(i.sort_attribute)):u._comparator=c.observable(i.comparator),i.filters?u._filters=c.observableArray(p.isArray(i.filters)?i.filters:i.filters?[i.filters]:void 0):u._filters=c.observableArray([]),t=u.create_options={store:_.Store.useOptionsOrCreate(i,o,l)},_.utils.wrappedObject(l,o),u.path=i.path,t.factory=_.utils.wrappedFactory(l,u._shareOrCreateFactory(i)),t.path=_.utils.pathJoin(i.path,"models"),t.creator=t.factory.creatorForPath(null,t.path),t.creator&&(u.models_only=t.creator.models_only),_.publishMethods(l,u,a),u._collection=c.observable(o),l.collection=u.collection=c.computed({read:function(){return u._collection()},write:function(t){return _.ignore(function(){var e;if((e=u._collection())!==t)return _.utils.wrappedObject(l,t),e&&e.unbind("all",u._onCollectionChange),t&&t.bind("all",u._onCollectionChange),u._collection(t)})}}),o&&o.bind("all",u._onCollectionChange),u._mapper=c.computed(function(){var e,t,r,n,o,i,s,a;if(e=u._comparator(),n=u._filters())for(s=0,a=n.length;s<a;s++)r=n[s],c.utils.unwrapObservable(r);t=u._collection(),u.in_edit||(l=_.utils.wrappedObservable(u),_.peek(l),t&&(o=t.models),i=o&&0!==t.models.length?(o=p.filter(o,function(e){return!n.length||u._selectModel(e)}),e?p.map(o,function(e){return u._createViewModel(e)}).sort(e):u.models_only?n.length?o:o.slice():p.map(o,function(e){return u._createViewModel(e)})):[],u.in_edit++,l(i),u.in_edit--)}),l.subscribe(p.bind(u._onObservableArrayChange,u)),_.statistics&&_.statistics.register("CollectionObservable",u),l})}n=_=r(0),p=n._,c=n.ko,a=["destroy","shareOptions","filters","comparator","sortAttribute","viewModelByModel","hasViewModels"],_.compare=function(e,t){return p.isString(e)?e.localeCompare(""+t):p.isString(t)?t.localeCompare(""+e):e===t?0:e<t?-1:1},_.CollectionObservable=(o.extend=_.extend,o.prototype.destroy=function(){var e,t,r;return this.__kb_released=!0,r=_.utils.wrappedObservable(this),t=_.peek(this._collection),_.utils.wrappedObject(r,null),t&&(t.unbind("all",this._onCollectionChange),(e=_.peek(r)).splice(0,e.length)),this.collection.dispose(),this._collection=r.collection=this.collection=null,this._mapper.dispose(),this._mapper=null,_.release(this._filters),this._filters=null,this._comparator(null),this._comparator=null,this.create_options=null,r.collection=null,_.utils.wrappedDestroy(this),!_.statistics||_.statistics.unregister("CollectionObservable",this)},o.prototype.shareOptions=function(){var e;return e=_.utils.wrappedObservable(this),{store:_.utils.wrappedStore(e),factory:_.utils.wrappedFactory(e)}},o.prototype.filters=function(e){return e?this._filters(p.isArray(e)?e:[e]):this._filters([])},o.prototype.comparator=function(e){return this._comparator(e)},o.prototype.sortAttribute=function(e){return this._comparator(e?this._attributeComparator(e):null)},o.prototype.viewModelByModel=function(r){var n;return this.models_only?null:(n=r.hasOwnProperty(r.idAttribute)?r.idAttribute:"cid",p.find(_.peek(_.utils.wrappedObservable(this)),function(e){var t;return!(null==e||null==(t=e.__kb)||!t.object)&&e.__kb.object[n]===r[n]}))},o.prototype.hasViewModels=function(){return!this.models_only},o.prototype.compact=function(){var t=this;return _.ignore(function(){var e;if(e=_.utils.wrappedObservable(t),_.utils.wrappedStoreIsOwned(e))return _.utils.wrappedStore(e).clear(),t._collection.notifySubscribers(t._collection())})},o.prototype._shareOrCreateFactory=function(e){var t,r,n,o;if(t=_.utils.pathJoin(e.path,"models"),n=e.factories,(o=e.factory)&&(r=o.creatorForPath(null,t))&&(!n||n.models===r)){if(!n)return o;if(o.hasPathMappings(n,e.path))return o}return o=new _.Factory(e.factory),n&&o.addPathMappings(n,e.path),o.creatorForPath(null,t)||(e.hasOwnProperty("models_only")?e.models_only?o.addPathMapping(t,{models_only:!0}):o.addPathMapping(t,_.ViewModel):e.view_model?o.addPathMapping(t,e.view_model):e.create?o.addPathMapping(t,{create:e.create}):o.addPathMapping(t,_.ViewModel)),o},o.prototype._onCollectionChange=function(n,o){var i=this;return _.ignore(function(){var e,t,r;if(!i.in_edit&&!_.wasReleased(i))switch(n){case"reset":i.auto_compact?i.compact():i._collection.notifySubscribers(i._collection());break;case"sort":case"resort":i._collection.notifySubscribers(i._collection());break;case"new":case"add":if(!i._selectModel(o))return;if(r=_.utils.wrappedObservable(i),-1===(e=i._collection()).indexOf(o))return;if(i.viewModelByModel(o))return;i.in_edit++,(t=i._comparator())?(r().push(i._createViewModel(o)),r.sort(t)):r.splice(e.indexOf(o),0,i._createViewModel(o)),i.in_edit--;break;case"remove":case"destroy":i._onModelRemove(o);break;case"change":if(!i._selectModel(o))return i._onModelRemove(o);if(!(i.models_only?o:i.viewModelByModel(o)))return i._onCollectionChange("add",o);if(!(t=i._comparator()))return;i.in_edit++,_.utils.wrappedObservable(i).sort(t),i.in_edit--}})},o.prototype._onModelRemove=function(e){var t,r;if(r=this.models_only?e:this.viewModelByModel(e))return t=_.utils.wrappedObservable(this),this.in_edit++,t.remove(r),this.in_edit--},o.prototype._onObservableArrayChange=function(c){var d=this;return _.ignore(function(){var e,t,r,n,o,i,s,a,l,u;if(!d.in_edit&&(d.models_only&&(!c.length||_.isModel(c[0]))||!d.models_only&&(!c.length||p.isObject(c[0])&&!_.isModel(c[0]))||_._throwUnexpected(d,"incorrect type passed"),i=_.utils.wrappedObservable(d),e=_.peek(d._collection),r=_.peek(d._filters).length,e)){if(a=c,d.models_only)o=p.filter(c,function(e){return!r||d._selectModel(e)});else for(r&&(a=[]),o=[],l=0,u=c.length;l<u;l++){if(s=c[l],n=_.utils.wrappedObject(s),r){if(!d._selectModel(n))continue;a.push(s)}(t=d.create_options.store.find(n,d.create_options.creator))&&(t.constructor===s.constructor||_._throwUnexpected(d,"replacing different type of view model")),d.create_options.store.retain(s,n,d.create_options.creator),o.push(n)}d.in_edit++,c.length===a.length||i(a),p.isEqual(e.models,o)||e.reset(o),d.in_edit--}})},o.prototype._attributeComparator=function(n){var r;return r=function(e,t){var r;return r=c.utils.unwrapObservable(n),_.compare(e.get(r),t.get(r))},this.models_only?r:function(e,t){return r(_.utils.wrappedModel(e),_.utils.wrappedModel(t))}},o.prototype._createViewModel=function(e){return this.models_only?e:this.create_options.store.retainOrCreate(e,this.create_options)},o.prototype._selectModel=function(e){var t,r,n,o,i;for(n=0,o=(r=_.peek(this._filters)).length;n<o;n++)if(t=r[n],t=_.peek(t),p.isFunction(t)){if(!t(e))return!1}else if(p.isArray(t)){if(i=e.id,s.call(t,i)<0)return!1}else if(e.id!==t)return!1;return!0},o),_.collectionObservable=function(e,t,r){return new _.CollectionObservable(arguments)},_.observableCollection=_.collectionObservable},function(e,t,r){function n(e,t){return function(){return e.apply(t,arguments)}}var u,c,d,o;function i(e,t,r){this._unbindCallbacks=n(this._unbindCallbacks,this),this._onModelUnloaded=n(this._onModelUnloaded,this),this._onModelLoaded=n(this._onModelLoaded,this),this.__kb||(this.__kb={}),this.__kb.callbacks={},this.ee=null,r&&this.registerCallbacks(t,r),e&&this.emitter(e)}o=u=r(0),d=o._,c=o.ko,u.EventWatcher=(i.useOptionsOrCreate=function(e,t,r,n){return e.event_watcher?(e.event_watcher.emitter()!==t&&e.event_watcher.model_ref!==t&&u._throwUnexpected(this,"emitter not matching"),u.utils.wrappedEventWatcher(r,e.event_watcher).registerCallbacks(r,n)):(u.utils.wrappedEventWatcherIsOwned(r,!0),u.utils.wrappedEventWatcher(r,new u.EventWatcher(t)).registerCallbacks(r,n))},i.prototype.destroy=function(){return this.emitter(null),this.__kb.callbacks=null,u.utils.wrappedDestroy(this)},i.prototype.emitter=function(e){return 0===arguments.length||this.ee===e?this.ee:(this.model_ref&&(this.model_ref.unbind("loaded",this._onModelLoaded),this.model_ref.unbind("unloaded",this._onModelUnloaded),this.model_ref.release(),this.model_ref=null),u.Backbone&&u.Backbone.ModelRef&&e instanceof u.Backbone.ModelRef?(this.model_ref=e,this.model_ref.retain(),this.model_ref.bind("loaded",this._onModelLoaded),this.model_ref.bind("unloaded",this._onModelUnloaded),e=this.model_ref.model()||null):delete this.model_ref,this.ee!==e&&(e?this._onModelLoaded(e):this._onModelUnloaded(this.ee)),e)},i.prototype.registerCallbacks=function(e,t){var r,n,o,i,s,a,l=this;for(e||u._throwMissing(this,"obj"),t||u._throwMissing(this,"callback_info"),n=t.event_selector?t.event_selector.split(" "):["change"],o=this.ee,i=function(i){var s;if((s=l.__kb.callbacks[i])||(s=l.__kb.callbacks[i]={model:null,list:[],fn:function(e){var t,r,n,o;for(r=0,n=(o=s.list).length;r<n;r++)(t=o[r]).update&&(e&&t.key&&e.hasChanged&&!e.hasChanged(c.utils.unwrapObservable(t.key))||(u.statistics&&u.statistics.addModelEvent({name:i,model:e,key:t.key,path:t.path}),t.update()));return null}}),s.list.push(d.defaults({obj:e},t)),o)return l._onModelLoaded(o)},s=0,a=n.length;s<a;s++)(r=n[s])&&i(r);return this},i.prototype.releaseCallbacks=function(e){var t,r,n;for(r in this.ee=null,n=this.__kb.callbacks)t=n[r],this._unbindCallbacks(r,t,u.wasReleased(e));return delete this.__kb.callbacks},i.prototype._onModelLoaded=function(e){var t,r,n,o,i,s,a,l;for(r in this.ee=e,s=this.__kb.callbacks)for((t=s[r]).model&&t.model!==e&&this._unbindCallbacks(r,t,!0),t.model||(t.model=e).bind(r,t.fn),o=0,i=(a=t.list).length;o<i;o++)(n=a[o]).unbind_fn||(n.unbind_fn=null!=(l=u.settings.orm)?l.bind(e,n.key,n.update,n.path):void 0),n.emitter&&n.emitter(e)},i.prototype._onModelUnloaded=function(e){var t,r,n;if(this.ee===e)for(r in this.ee=null,n=this.__kb.callbacks)t=n[r],this._unbindCallbacks(r,t)},i.prototype._unbindCallbacks=function(e,t,r){var n,o,i,s;for(t.model&&(t.model.unbind(e,t.fn),t.model=null),o=0,i=(s=t.list).length;o<i;o++)(n=s[o]).unbind_fn&&(n.unbind_fn(),n.unbind_fn=null),!n.emitter||r||u.wasReleased(n.obj)||n.emitter(null)},i),u.emitterObservable=function(e,t){return new u.EventWatcher(e,t)}},function(e,t,r){var s;function n(e){this.paths={},e&&(this.parent_factory=e)}(s=r(0))._,s.Factory=(n.useOptionsOrCreate=function(e,t,r){var n;return e.factory&&(!e.factories||e.factories&&e.factory.hasPathMappings(e.factories,r))?s.utils.wrappedFactory(t,e.factory):(n=s.utils.wrappedFactory(t,new s.Factory(e.factory)),e.factories&&n.addPathMappings(e.factories,r),n)},n.prototype.hasPath=function(e){var t;return this.paths.hasOwnProperty(e)||(null!=(t=this.parent_factory)?t.hasPath(e):void 0)},n.prototype.addPathMapping=function(e,t){return this.paths[e]=t},n.prototype.addPathMappings=function(e,t){var r,n;for(n in e)r=e[n],this.paths[s.utils.pathJoin(t,n)]=r},n.prototype.hasPathMappings=function(e,t){var r,n,o,i;for(i in r=!0,e)n=e[i],r&=(o=this.creatorForPath(null,s.utils.pathJoin(t,i)))&&n===o;return r},n.prototype.creatorForPath=function(e,t){var r,n;return(r=this.paths[t])?r.view_model?r.view_model:r:(r=null!=(n=this.parent_factory)?n.creatorForPath(e,t):void 0)?r:null},n)},function(e,t,r){var n;e.exports=n=r(0),n.configure=r(1),n.modules={underscore:n._,backbone:n.Parse||n.Backbone,knockout:n.ko}},function(e,t,s){(function(e){var d,o,t,_,p,r,n;function i(){}_=null!=_?_:e,n=d=s(0),p=n._,o=n.ko,d.RECUSIVE_AUTO_INJECT=!0,o.bindingHandlers.inject={init:function(e,t,r,n){return d.Inject.inject(o.utils.unwrapObservable(t()),n,e,t,r)}},d.Inject=(i.inject=function(e,o,i,s,a,l){var t;return t=function(e){var t,r,n;if(p.isFunction(e))o=new e(o,i,s,a),d.releaseOnNodeRemove(o,i);else for(t in e.view_model&&(o=new e.view_model(o,i,s,a),d.releaseOnNodeRemove(o,i)),e)n=e[t],"view_model"!==t&&("create"===t?n(o,i,s,a):p.isObject(n)&&!p.isFunction(n)?(r=l||n&&n.create?{}:o,o[t]=d.Inject.inject(n,r,i,s,a,!0)):o[t]=n);return o},l?t(e):d.ignore(function(){return t(e)})},i.injectViewModels=function(e){var t,r,n,o,i,s,a,l,u,c;for(l=[],s=function(e){var t,r,n,o,i;for(e.__kb_injected||e.attributes&&(t=p.find(e.attributes,function(e){return"kb-inject"===e.name}))&&(e.__kb_injected=!0,l.push({el:e,view_model:{},binding:t.value})),n=0,o=(i=e.childNodes).length;n<o;n++)r=i[n],s(r)},!e&&(null!=_?_.document:void 0)&&(e=_.document),s(e),u=0,c=l.length;u<c;u++)(i=(r=l[u]).binding)&&(i.search(/[:]/)<0||(i="{"+i+"}"),(o=new Function("","return ( "+i+" )")())||(o={}),o.options&&(a=o.options,delete o.options),a||(a={}),r.view_model=d.Inject.inject(o,r.view_model,r.el,null,null,!0),t=r.view_model.afterBinding||a.afterBinding,n=r.view_model.beforeBinding||a.beforeBinding),n&&n.call(r.view_model,r.view_model,r.el,a),d.applyBindings(r.view_model,r.el,a),t&&t.call(r.view_model,r.view_model,r.el,a);return l},i),r=o.applyBindings,o.applyBindings=function(e,t){if(!(d.RECUSIVE_AUTO_INJECT?d.injectViewModels(t):[]).length)return r.apply(this,arguments)},d.injectViewModels=d.Inject.injectViewModels,"undefined"!=typeof document&&null!==document&&(t=function(){return"complete"!==document.readyState?setTimeout(t,0):d.injectViewModels()})()}).call(t,s(3))},function(e,t,r){var n,o,i,s,a;(null!=(s=(o=(n=r(0)).ko).subscribable)&&null!=(a=s.fn)?a.extend:void 0)&&(i=o.subscribable.fn.extend,o.subscribable.fn.extend=function(){var e,t,r=this;return(e=i.apply(this,arguments))!==this&&n.isReleaseable(this)&&(t=e.dispose,e.dispose=function(){return null!=t&&t.apply(e,arguments),n.release(r)}),e})},function(e,t,r){var c,d,_,p,f,h,n;function o(s,a,l,e){var u=this;return this._vm=null!=e?e:{},p.ignore(function(){var e,t,r,n,o,i;for(a||p._throwMissing(u,"key_or_info"),u.key=a.key||a,o=0,i=c.length;o<i;o++)a[r=c[o]]&&(u[r]=a[r]);return t=(e=p.utils.collapseOptions(l)).event_watcher,delete e.event_watcher,u._value=new _(e),u._model=f.observable(),(n=p.utils.wrappedObservable(u,f.computed({read:function(){var e,t,r,n,o,i,s;for(o=u._model(),r=0,n=(i=t=[u.key].concat(u.args||[])).length;r<n;r++)e=i[r],f.utils.unwrapObservable(e);return null!=(s=p.utils.wrappedEventWatcher(u))&&s.emitter(o||null),u.read?u.update(u.read.apply(u._vm,t)):h.isUndefined(o)||p.ignore(function(){return u.update(p.getValue(o,p.peek(u.key),u.args))}),u._value.value()},write:function(r){return p.ignore(function(){var e,t;return e=p.utils.unwrapModels(r),t=p.peek(u._model),u.write?(u.write.call(u._vm,e),r=p.getValue(t,p.peek(u.key),u.args)):t&&p.setValue(t,p.peek(u.key),e),u.update(r)})},owner:u._vm}))).__kb_is_o=!0,e.store=p.utils.wrappedStore(n,e.store),e.path=p.utils.pathJoin(e.path,u.key),e.factories&&("function"==typeof e.factories||e.factories.create)?(e.factory=p.utils.wrappedFactory(n,new p.Factory(e.factory)),e.factory.addPathMapping(e.path,e.factories)):e.factory=p.Factory.useOptionsOrCreate(e,n,e.path),delete e.factories,p.publishMethods(n,u,d),n.model=u.model=f.computed({read:function(){return f.utils.unwrapObservable(u._model)},write:function(t){return p.ignore(function(){var e;if(!u.__kb_released&&p.peek(u._model)!==t)return e=p.getValue(t,p.peek(u.key),u.args),u._model(t),t?h.isUndefined(e)?void 0:u.update(e):u.update(null)})}}),p.EventWatcher.useOptionsOrCreate({event_watcher:t},s||null,u,{emitter:u.model,update:function(){return p.ignore(function(){return u.update()})},key:u.key,path:e.path}),u._value.rawValue()||u._value.update(),p.LocalizedObservable&&a.localizer&&(n=new a.localizer(n)),p.DefaultObservable&&a.hasOwnProperty("default")&&(n=p.defaultObservable(n,a.default)),n})}n=p=r(0),h=n._,f=n.ko,_=r(2),d=["value","valueType","destroy"],c=["args","read","write"],p.Observable=(o.prototype.destroy=function(){var e;return e=p.utils.wrappedObservable(this),this.__kb_released=!0,this._value.destroy(),this._value=null,this.model.dispose(),this.model=e.model=null,p.utils.wrappedDestroy(this)},o.prototype.value=function(){return this._value.rawValue()},o.prototype.valueType=function(){return this._value.valueType(p.peek(this._model),p.peek(this.key))},o.prototype.update=function(e){if(!this.__kb_released)return arguments.length||(e=p.getValue(p.peek(this._model),p.peek(this.key))),this._value.update(e)},o),p.observable=function(e,t,r,n){return new p.Observable(e,t,r,n)}},function(e,t,r){var n,u;function o(){this.model_events_tracker=[],this.registered_tracker={}}u=(n=r(0))._,e.exports=n.Statistics=(o.prototype.clear=function(){return this.model_events_tracker=[]},o.prototype.addModelEvent=function(e){return this.model_events_tracker.push(e)},o.prototype.modelEventsStatsString=function(){var e,t,r;for(t in r="",r+="Total Count: "+this.model_events_tracker.length,e=u.groupBy(this.model_events_tracker,function(e){return"event name: '"+e.name+"', attribute name: '"+e.key+"'"}))r+="\n "+t+", count: "+e[t].length;return r},o.prototype.register=function(e,t){return this.registeredTracker(e).push(t)},o.prototype.unregister=function(e,t){var r,n;return n=this.registeredTracker(e),(r=u.indexOf(n,t))<0?"undefined"!=typeof console&&null!==console?console.log("kb.Statistics: failed to unregister type: "+e):void 0:n.splice(r,1)},o.prototype.registeredCount=function(e){var t,r;if(e)return this.registeredTracker(e).length;for(e in t=0,r=this.registered_tracker[e])t+=r[e].length;return t},o.prototype.registeredStatsString=function(e){var t,r,n,o,i;for(r in t="",i=this.registered_tracker)(n=i[r]).length&&(o&&(t+="\n "),t+=(r||"No Name")+": "+n.length,o=!0);return t||e},o.prototype.registeredTracker=function(e){var t;return this.registered_tracker.hasOwnProperty(e)?this.registered_tracker[e]:(t=[],this.registered_tracker[e]=t)},o.eventsStats=function(e,t){var r,n,o,i,s,a,l;for(o={count:0},r=e._events||e._callbacks||{},s=0,a=(l=t?[t]:u.keys(r)).length;s<a;s++)if(n=r[t=l[s]]){if(u.isArray(n))o[t]=u.compact(n).length;else for(o[t]=0,i=n.tail;(n=n.next)!==i;)o[t]++;o.count+=o[t]}return o},o)},function(e,t,r){var s,a,l,n;function o(){this.observable_records={},this.replaced_observables=[],s.Store.instances.push(this)}n=s=r(0),l=n._,a=n.ko,e.exports=s.Store=(o.instances=[],o.useOptionsOrCreate=function(e,t,r){var n;return e.store||s.utils.wrappedStoreIsOwned(r,!0),(n=s.utils.wrappedStore(r,e.store||new s.Store)).retain(r,t,e.creator),n},o.prototype.destroy=function(){var e;if(this.__kb_released=!0,this.clear(),0<=(e=l.indexOf(s.Store.instances,this)))return s.Store.instances.splice(e,1)},o.prototype.clear=function(){var e,t,r,n,o,i,s,a,l,u;for(t in n=(l=[this.observable_records,{}])[0],this.observable_records=l[1],n)for(e in o=n[t])r=o[e],this.release(r,!0);for(i=(u=[this.replaced_observables,[]])[0],this.replaced_observables=u[1],s=0,a=i.length;s<a;s++)(r=i[s]).__kb_released||this.release(r,!0)},o.prototype.compact=function(){var e,t,r,n;for(t in n=this.observable_records)for(e in r=n[t])r[e].__kb_released&&delete r[e]},o.prototype.retain=function(e,t,r){var n;if(this._canRegister(e)){if(r||(r=e.constructor),n=this.find(t,r)){if(n===e)return this._getOrCreateStoreReferences(e).ref_count++,e;this._retire(n)}return this._add(e,t,r),this._getOrCreateStoreReferences(e).ref_count++,e}},o.prototype.retainOrCreate=function(e,t,r){var n,o,i=this;if(!(n=this._creator(e,t)))return s.utils.createFromDefaultCreator(e,t);if(n.models_only)return e;if(o=this.find(e,n))return r&&s.settings.deep_retain?this.retain(o,e,n):o;if(!l.isFunction(n.create||n))throw new Error('Invalid factory for "'+t.path+'"');return o=s.ignore(function(){return t=l.defaults({store:i,creator:n},t),(o=n.create?n.create(e,t):new n(e,t))||a.observable(null)}),this.retain(o,e,n),o},o.prototype.reuse=function(e,t){var r,n,o;if((n=s.utils.wrappedObject(e))!==t){if(!this._canRegister(e))throw new Error("Cannot reuse a simple observable");if(1!==this._refCount(e))throw new Error("Trying to change a shared view model. Ref count: "+this._refCount(e));r=s.utils.wrappedCreator(e)||e.constructor,l.isUndefined(n)||(o=this.find(n,r)),this.retain(e,t,r),o&&this.release(o)}},o.prototype.release=function(e,t){var r;if(!this._canRegister(e))return s.release(e);if(r=this._storeReferences(e)){if(!t&&0<--r.ref_count)return;this._clearStoreReferences(e)}return this._remove(e),e.__kb_released?void 0:t||this._refCount(e)<=1?s.release(e):void 0},o.prototype.find=function(e,t){var r,n,o;return(n=this.observable_records[this._creatorId(t)])?(null!=(o=r=n[this._cid(e)])?o.__kb_released:void 0)?(delete n[this._cid(e)],null):r:null},o.prototype._refCount=function(e){var t;return e.__kb_released?("undefined"!=typeof console&&null!==console&&console.log("Observable already released"),0):(t=s.utils.get(e,"stores_references"))?l.reduce(t,function(e,t){return e+t.ref_count},0):1},o.prototype._canRegister=function(e){return e&&!a.isObservable(e)&&!e.__kb_is_co},o.prototype._cid=function(e){return e?e.cid||(e.cid=l.uniqueId("c")):"null"},o.prototype._creatorId=function(e){var t,r,n,o,i;for((t=e.create||e).__kb_cids||(t.__kb_cids=[]),n=0,o=(i=t.__kb_cids).length;n<o;n++)if((r=i[n]).create===t)return r.cid;return t.__kb_cids.push(r={create:t,cid:l.uniqueId("kb")}),r.cid},o.prototype._storeReferences=function(e){var t,r=this;if(t=s.utils.get(e,"stores_references"))return l.find(t,function(e){return e.store===r})},o.prototype._getOrCreateStoreReferences=function(e){var t,r,n=this;return r=s.utils.orSet(e,"stores_references",[]),(t=l.find(r,function(e){return e.store===n}))||r.push(t={store:this,ref_count:0,release:function(){return n.release(e)}}),t},o.prototype._clearStoreReferences=function(e){var t,r;if(s.utils.get(e,"stores_references"))for(t in r=e.__kb.stores_references)if(r[t].store===this){e.__kb.stores_references.splice(t,1);break}},o.prototype._retire=function(e){return this._clearStoreReferences(e),this.replaced_observables.push(e),this._remove(e)},o.prototype._add=function(e,t,r){var n,o;return r||(r=e.constructor),s.utils.wrappedObject(e,t),s.utils.wrappedCreator(e,r),((n=this.observable_records)[o=this._creatorId(r)]||(n[o]={}))[this._cid(t)]=e},o.prototype._remove=function(e){var t,r,n;return t=s.utils.wrappedCreator(e)||e.constructor,(r=this.find(n=s.utils.wrappedObject(e),t))&&r===e&&delete this.observable_records[this._creatorId(t)][this._cid(n)],s.utils.wrappedObject(e,null),s.utils.wrappedCreator(e,null)},o.prototype._creator=function(e,t){var r;return t.creator?t.creator:(r=s.utils.inferCreator(e,t.factory,t.path))?r:s.isModel(e)?s.ViewModel:void 0},o)},function(e,t,r){var o,n,i,s;function a(){}s=o=r(0),i=s._,n=s.ko,o.utils=(a.get=function(e,t,r){return e.__kb&&e.__kb.hasOwnProperty(t)?e.__kb[t]:r},a.set=function(e,t,r){return(e.__kb||(e.__kb={}))[t]=r},a.orSet=function(e,t,r){return(e.__kb||(e.__kb={})).hasOwnProperty(t)||(e.__kb[t]=r),e.__kb[t]},a.has=function(e,t){return e.__kb&&e.__kb.hasOwnProperty(t)},a.wrappedObservable=function(e,t){return 1===arguments.length?o.utils.get(e,"observable"):o.utils.set(e,"observable",t)},a.wrappedObject=function(e,t){return 1===arguments.length?o.utils.get(e,"object"):o.utils.set(e,"object",t)},a.wrappedCreator=function(e,t){return 1===arguments.length?o.utils.get(e,"creator"):o.utils.set(e,"creator",t)},a.wrappedModel=function(e,t){return 1===arguments.length?i.isUndefined(t=o.utils.get(e,"object"))?e:t:o.utils.set(e,"object",t)},a.wrappedStore=function(e,t){return 1===arguments.length?o.utils.get(e,"store"):o.utils.set(e,"store",t)},a.wrappedStoreIsOwned=function(e,t){return 1===arguments.length?o.utils.get(e,"store_is_owned"):o.utils.set(e,"store_is_owned",t)},a.wrappedFactory=function(e,t){return 1===arguments.length?o.utils.get(e,"factory"):o.utils.set(e,"factory",t)},a.wrappedEventWatcher=function(e,t){return 1===arguments.length?o.utils.get(e,"event_watcher"):o.utils.set(e,"event_watcher",t)},a.wrappedEventWatcherIsOwned=function(e,t){return 1===arguments.length?o.utils.get(e,"event_watcher_is_owned"):o.utils.set(e,"event_watcher_is_owned",t)},a.wrappedDestroy=r(18),a.valueType=function(e){return e?e.__kb_is_o?e.valueType():e.__kb_is_co||e instanceof o.Collection?o.TYPE_COLLECTION:e instanceof o.ViewModel||e instanceof o.Model?o.TYPE_MODEL:i.isArray(e)?o.TYPE_ARRAY:o.TYPE_SIMPLE:o.TYPE_UNKNOWN},a.pathJoin=function(e,t){return(e?"."!==e[e.length-1]?e+".":e:"")+t},a.optionsPathJoin=function(e,t){return i.defaults({path:this.pathJoin(e.path,t)},e)},a.inferCreator=function(e,t,r){var n;return t&&(n=t.creatorForPath(e,r))?n:e?e instanceof o.Model?o.ViewModel:e instanceof o.Collection?o.CollectionObservable:null:null},a.createFromDefaultCreator=function(e,t){return o.isModel(e)?o.viewModel(e,t):o.isCollection(e)?o.collectionObservable(e,t):i.isArray(e)?n.observableArray(e):n.observable(e)},a.collapseOptions=r(15),a.unwrapModels=r(17),a.resolveModel=function(e){return e&&o.Backbone&&o.Backbone.ModelRef&&e instanceof o.Backbone.ModelRef?e.model():e},a)},function(e,t,r){var _,d,p,f,h,b,v,n;function o(l,u,e){var c,d=this;return null==u&&(u={}),c=Array.prototype.slice.call(v.isArguments(l)?l:arguments),h.ignore(function(){var e,t,r,n,o,i,s,a;for(!(l=c.shift())||h.isModel(l)||h._throwUnexpected(d,"not a model"),v.isArray(c[0])&&(c[0]={keys:c[0]}),d.__kb||(d.__kb={}),d.__kb.view_model=1<c.length?c.pop():d,u={},n=0,i=c.length;n<i;n++)e=c[n],v.extend(u,e);for(u=h.utils.collapseOptions(u),o=0,s=_.length;o<s;o++)r=_[o],u.hasOwnProperty(r)&&(d.__kb[r]=u[r]);return h.Store.useOptionsOrCreate(u,l,d),d.__kb.path=u.path,h.Factory.useOptionsOrCreate(u,d,u.path),a=h.utils.set(d,"_model",b.observable()),d.model=b.computed({read:function(){return b.utils.unwrapObservable(a)},write:function(e){return h.ignore(function(){if(!h.wasReleased(d)&&t)return d.__kb.store.reuse(d,h.utils.resolveModel(e)),t.emitter(e),a(t.ee),!t.ee||d.createObservables(t.ee)})}}),t=h.utils.wrappedEventWatcher(d,new h.EventWatcher(l,d,{emitter:d._model,update:function(){return h.ignore(function(){return!(null!=t?t.ee:void 0)||d.createObservables(null!=t?t.ee:void 0)})}})),h.utils.wrappedObject(d,l=t.ee),a(t.ee),d.__kb.create_options={store:h.utils.wrappedStore(d),factory:h.utils.wrappedFactory(d),path:d.__kb.path,event_watcher:h.utils.wrappedEventWatcher(d)},u.requires&&d.createObservables(l,u.requires),d.__kb.internals&&d.createObservables(l,d.__kb.internals),u.mappings&&d.createObservables(l,u.mappings),d.__kb.statics&&f(d,l),d.createObservables(l,d.__kb.keys),h.statistics&&h.statistics.register("ViewModel",d),d})}n=h=r(0),v=n._,b=n.ko,d=function(e,t){var r;if(r=e.__kb.internals&&~v.indexOf(e.__kb.internals,t)?"_"+t:t,!e.__kb.view_model.hasOwnProperty(r))return e.__kb.view_model[r]=null,r},p=function(e,t,r,n){var o;if((!e.__kb.excludes||!~v.indexOf(e.__kb.excludes,r))&&(!e.__kb.statics||!~v.indexOf(e.__kb.statics,r))&&(o=d(e,r)))return e[o]=e.__kb.view_model[o]=h.observable(t,r,n,e)},f=function(e,t){var r,n,o,i,s;for(o=0,i=(s=e.__kb.statics).length;o<i;o++)r=s[o],(n=d(e,r))&&(t.has(n)?e[n]=e.__kb.view_model[n]=t.get(n):e.__kb.static_defaults&&n in e.__kb.static_defaults?e[n]=e.__kb.view_model[n]=e.__kb.static_defaults[n]:delete e.__kb.view_model[n])},_=["keys","internals","excludes","statics","static_defaults"],h.ViewModel=(o.extend=h.extend,o.prototype.destroy=function(){var e;if(this.__kb_released=!0,this.__kb.view_model!==this)for(e in this.__kb.vm_keys)this.__kb.view_model[e]=null;return this.__kb.view_model=this.__kb.create_options=null,h.releaseKeys(this),h.utils.wrappedDestroy(this),!h.statistics||h.statistics.unregister("ViewModel",this)},o.prototype.shareOptions=function(){return{store:h.utils.wrappedStore(this),factory:h.utils.wrappedFactory(this)}},o.prototype.createObservables=function(e,t){var r,n,o,i,s,a,l,u,c;if(t)if(v.isArray(t))for(a=0,u=t.length;a<u;a++)r=t[a],p(this,e,r,this.__kb.create_options);else for(r in t)n=t[r],(i=d(this,r))&&(v.isString(n)||n.key||(n.key=i),this[i]=this.__kb.view_model[i]=h.observable(e,n,this.__kb.create_options,this));else{if(this.__kb.keys||!e)return;for(r in e.attributes)p(this,e,r,this.__kb.create_options);if(o=null!=(c=h.settings.orm)&&"function"==typeof c.keys?c.keys(e):void 0)for(s=0,l=o.length;s<l;s++)r=o[s],p(this,e,r,this.__kb.create_options)}},o),h.viewModel=function(e,t,r){return new h.ViewModel(arguments)}},function(e,t,r){var o,i,s,a,l;o=r(0)._,s=function(e,t,r){return e[t]||(e[t]=[]),o.isArray(r)||(r=[r]),e[t]=e[t].length?o.union(e[t],r):r,e},a=function(e,t,r){return e[t]||(e[t]={}),o.extend(e[t],r)},i=function(e){var t,r,n,o;for(r={},n=0,o=e.length;n<o;n++)r[t=e[n]]={key:t};return r},l=function(e,t){var r,n;if(!t)return e;for(r in t)switch(n=t[r],r){case"internals":case"requires":case"excludes":case"statics":s(e,r,n);break;case"keys":o.isObject(n)&&!o.isArray(n)||o.isObject(e[r])&&!o.isArray(e[r])?(o.isObject(n)||(n=[n]),o.isArray(n)&&(n=i(n)),o.isArray(e[r])&&(e[r]=i(e[r])),a(e,r,n)):s(e,r,n);break;case"factories":o.isFunction(n)?e[r]=n:a(e,r,n);break;case"static_defaults":a(e,r,n);break;case"options":break;default:e[r]=n}return l(e,t.options)},e.exports=function(e){return l({},e)}},function(e,t){var o;o=function(e,t){var r,n;for(r in t)n=t[r],e[r]=n;return e};function i(){}e.exports=function(e,t){var r=function(e,t,r){var n;return n=t&&t.hasOwnProperty("constructor")?t.constructor:function(){e.apply(this,arguments)},o(n,e),i.prototype=e.prototype,n.prototype=new i,t&&o(n.prototype,t),r&&o(n,r),(n.prototype.constructor=n).__super__=e.prototype,n}(this,e,t);return r.extend=this.extend,r}},function(e,t,r){var o,i;i=r(0)._,e.exports=o=function(e){var t,r,n;if(!e)return e;if(e.__kb)return e.__kb.hasOwnProperty("object")?e.__kb.object:e;if(i.isArray(e))return i.map(e,function(e){return o(e)});if(i.isObject(e)&&e.constructor==={}.constructor){for(t in r={},e)n=e[t],r[t]=o(n);return r}return e}},function(e,t,r){var n;r(0)._,e.exports=n=function(e){var t,r;if(e.__kb&&(e.__kb.event_watcher&&e.__kb.event_watcher.releaseCallbacks(e),r=e.__kb,e.__kb=null,r.observable&&(r.observable.destroy=r.observable.release=null,n(r.observable),r.observable=null),r.factory=null,r.event_watcher_is_owned&&r.event_watcher.destroy(),r.event_watcher=null,r.store_is_owned&&r.store.destroy(),r.store=null,r.stores_references))for(;t=r.stores_references.pop();)t.store.__kb_released||t.store.release(e)}},function(e,t,r){var n,o,i,s,a;function l(){}a=i=r(0),s=a._,o=a.Backbone,n=null,e.exports=(l.isAvailable=function(){return!!(n=null!=o?o.AssociatedModel:void 0)},l.keys=function(e){return e instanceof n?s.map(e.relations,function(e){return e.key}):null},l.relationType=function(e,t){var r;return e instanceof n&&(r=s.find(e.relations,function(e){return e.key===t}))?"Many"===r.type?i.TYPE_COLLECTION:i.TYPE_MODEL:null},l.useFunction=function(){return!1},l)},function(e,t,r){var n,o,c,i,s;function a(){}s=c=r(0),i=s._,n=s.Backbone,o=null,e.exports=(a.isAvailable=function(){return!!(o=null!=n?n.RelationalModel:void 0)},a.relationType=function(e,t){var r;return e instanceof o&&(r=i.find(e.getRelations(),function(e){return e.key===t}))?r.collectionType||i.isArray(r.keyContents)?c.TYPE_COLLECTION:c.TYPE_MODEL:null},a.bind=function(r,n,t,o){var i,s,a,l,e,u;if(!(l=this.relationType(r,n)))return null;if(a=function(e){return c.statistics&&c.statistics.addModelEvent({name:"update (relational)",model:e,key:n,path:o}),t()},s=c.Backbone.Relation.prototype.sanitizeOptions?["update","add","remove"]:["change","add","remove"],l===c.TYPE_COLLECTION)for(e=0,u=s.length;e<u;e++)i=s[e],r.bind(i+":"+n,a);else r.bind(s[0]+":"+n,a);return function(){var e,t;if(l===c.TYPE_COLLECTION)for(e=0,t=s.length;e<t;e++)i=s[e],r.unbind(i+":"+n,a);else r.unbind(s[0]+":"+n,a)}},a.useFunction=function(){return!1},a)},function(e,t){e.exports=d},function(t,r){t.exports=e},function(e,t){e.exports=f},function(e,t,r){r(4),r(1),r(5),r(6),r(8),r(0),r(9),r(10),r(11),r(12),r(2),r(13),r(14),e.exports=r(7)}],i.c=h,i.i=function(e){return e},i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=24);function i(e){if(h[e])return h[e].exports;var t=h[e]={i:e,l:!1,exports:{}};return g[e].call(t.exports,t,t.exports,i),t.l=!0,t.exports}var g,h});