/* knockback-core-stack.js 0.20.2 Copyright (c) 2011-2014 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("jquery")):"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof exports?exports.kb=t(require("jquery")):e.kb=t(e.jQuery)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){n(1),n(2),n(3),n(4),n(5),n(6),n(7),n(8),n(9),n(10),n(11),n(12),n(13),e.exports=n(14)},function(e,t,n){var r,i,o,s,a,u,l,c,d=function(e,t){return function(){return e.apply(t,arguments)}},p=[].indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(t in this&&this[t]===e)return t;return-1};c=a=n(6),l=c._,u=c.ko,o=0,r=-1,i=1,s=["destroy","shareOptions","filters","comparator","sortAttribute","viewModelByModel","hasViewModels"],a.compare=function(e,t){return l.isString(e)?e.localeCompare(""+t):l.isString(t)?t.localeCompare(""+e):e===t?o:t>e?r:i},a.CollectionObservable=function(){function e(e,t,n){this._onCollectionChange=d(this._onCollectionChange,this);var r;return r=Array.prototype.slice.call(l.isArguments(e)?e:arguments),a.ignore(function(t){return function(){var i,o,c,d,p;for(e=r[0]instanceof a.Collection?r.shift():l.isArray(r[0])?new a.Collection(r.shift()):new a.Collection,l.isFunction(r[0])&&(r[0]={view_model:r[0]}),n={},d=0,p=r.length;p>d;d++)i=r[d],l.extend(n,i);return c=a.utils.wrappedObservable(t,u.observableArray([])),c.__kb_is_co=!0,t.in_edit=0,t.__kb||(t.__kb={}),n=a.utils.collapseOptions(n),n.auto_compact&&(t.auto_compact=!0),t._comparator=u.observable(n.sort_attribute?t._attributeComparator(n.sort_attribute):n.comparator),t._filters=u.observableArray(n.filters?l.isArray(n.filters)?n.filters:n.filters?[n.filters]:void 0:[]),o=t.create_options={store:a.Store.useOptionsOrCreate(n,e,c)},t.path=n.path,o.factory=a.utils.wrappedFactory(c,t._shareOrCreateFactory(n)),o.path=a.utils.pathJoin(n.path,"models"),o.creator=o.factory.creatorForPath(null,o.path),o.creator&&(t.models_only=o.creator.models_only),a.publishMethods(c,t,s),t._collection=u.observable(e),c.collection=t.collection=u.computed({read:function(){return t._collection()},write:function(e){return a.ignore(function(){var n;if((n=t._collection())!==e)return t.create_options.store.reuse(t,e),n&&n.unbind("all",t._onCollectionChange),e&&e.bind("all",t._onCollectionChange),t._collection(e)})}}),e&&e.bind("all",t._onCollectionChange),t._mapper=u.computed(function(){var e,n,r,i,o,s,d,p,f;if(e=t._comparator(),i=t._filters())for(p=0,f=i.length;f>p;p++)r=i[p],u.utils.unwrapObservable(r);n=t._collection(),t.in_edit||(c=a.utils.wrappedObservable(t),s=a.peek(c),n&&(o=n.models),o&&0!==n.models.length?(o=l.filter(o,function(e){return!i.length||t._selectModel(e)}),d=e?l.map(o,function(e){return t._createViewModel(e)}).sort(e):t.models_only?i.length?o:o.slice():l.map(o,function(e){return t._createViewModel(e)})):d=[],t.in_edit++,c(d),t.in_edit--)}),c.subscribe(l.bind(t._onObservableArrayChange,t)),!a.statistics||a.statistics.register("CollectionObservable",t),c}}(this))}return e.extend=a.extend,e.prototype.destroy=function(){var e,t,n;return this.__kb_released=!0,n=a.utils.wrappedObservable(this),t=a.peek(this._collection),t&&(t.unbind("all",this._onCollectionChange),e=a.peek(n),e.splice(0,e.length)),this.collection.dispose(),this._collection=n.collection=this.collection=null,this._mapper.dispose(),this._mapper=null,a.release(this._filters),this._filters=null,this._comparator(null),this._comparator=null,this.create_options=null,n.collection=null,a.utils.wrappedDestroy(this),!a.statistics||a.statistics.unregister("CollectionObservable",this)},e.prototype.shareOptions=function(){var e;return e=a.utils.wrappedObservable(this),{store:a.utils.wrappedStore(e),factory:a.utils.wrappedFactory(e)}},e.prototype.filters=function(e){return this._filters(e?l.isArray(e)?e:[e]:[])},e.prototype.comparator=function(e){return this._comparator(e)},e.prototype.sortAttribute=function(e){return this._comparator(e?this._attributeComparator(e):null)},e.prototype.viewModelByModel=function(e){var t;return this.models_only?null:(t=e.hasOwnProperty(e.idAttribute)?e.idAttribute:"cid",l.find(a.peek(a.utils.wrappedObservable(this)),function(n){var r;return(null!=n&&null!=(r=n.__kb)?r.object:void 0)?n.__kb.object[t]===e[t]:!1}))},e.prototype.hasViewModels=function(){return!this.models_only},e.prototype.compact=function(){return a.ignore(function(e){return function(){var t;return t=a.utils.wrappedObservable(e),a.utils.wrappedStoreIsOwned(t)?(a.utils.wrappedStore(t).clear(),e._collection.notifySubscribers(e._collection())):void 0}}(this))},e.prototype._shareOrCreateFactory=function(e){var t,n,r,i;if(t=a.utils.pathJoin(e.path,"models"),r=e.factories,(i=e.factory)&&(n=i.creatorForPath(null,t))&&(!r||r.models===n)){if(!r)return i;if(i.hasPathMappings(r,e.path))return i}return i=new a.Factory(e.factory),r&&i.addPathMappings(r,e.path),i.creatorForPath(null,t)||(e.hasOwnProperty("models_only")?e.models_only?i.addPathMapping(t,{models_only:!0}):i.addPathMapping(t,a.ViewModel):e.view_model?i.addPathMapping(t,e.view_model):e.create?i.addPathMapping(t,{create:e.create}):i.addPathMapping(t,a.ViewModel)),i},e.prototype._onCollectionChange=function(e,t){return a.ignore(function(n){return function(){var r,i,o,s;if(!n.in_edit)switch(e){case"reset":n.auto_compact?n.compact():n._collection.notifySubscribers(n._collection());break;case"sort":case"resort":n._collection.notifySubscribers(n._collection());break;case"new":case"add":if(!n._selectModel(t))return;if(o=a.utils.wrappedObservable(n),r=n._collection(),-1===r.indexOf(t))return;if(s=n.viewModelByModel(t))return;n.in_edit++,(i=n._comparator())?(o().push(n._createViewModel(t)),o.sort(i)):o.splice(r.indexOf(t),0,n._createViewModel(t)),n.in_edit--;break;case"remove":case"destroy":n._onModelRemove(t);break;case"change":if(!n._selectModel(t))return n._onModelRemove(t);if(s=n.models_only?t:n.viewModelByModel(t),!s)return n._onCollectionChange("add",t);if(!(i=n._comparator()))return;n.in_edit++,a.utils.wrappedObservable(n).sort(i),n.in_edit--}}}(this))},e.prototype._onModelRemove=function(e){var t,n;return(n=this.models_only?e:this.viewModelByModel(e))?(t=a.utils.wrappedObservable(this),this.in_edit++,t.remove(n),this.in_edit--):void 0},e.prototype._onObservableArrayChange=function(e){return a.ignore(function(t){return function(){var n,r,i,o,s,u,c,d,p,f;if(!t.in_edit&&(t.models_only&&(!e.length||a.isModel(e[0]))||!t.models_only&&(!e.length||l.isObject(e[0])&&!a.isModel(e[0]))||a._throwUnexpected(t,"incorrect type passed"),u=a.utils.wrappedObservable(t),n=a.peek(t._collection),i=a.peek(t._filters).length,n)){if(d=e,t.models_only)s=l.filter(e,function(e){return!i||t._selectModel(e)});else for(!i||(d=[]),s=[],p=0,f=e.length;f>p;p++){if(c=e[p],o=a.utils.wrappedObject(c),i){if(!t._selectModel(o))continue;d.push(c)}(r=t.create_options.store.find(o,t.create_options.creator))&&(r.constructor===c.constructor||a._throwUnexpected(t,"replacing different type of view model")),t.create_options.store.retain(c,o,t.create_options.creator),s.push(o)}t.in_edit++,e.length===d.length||u(d),l.isEqual(n.models,s)||n.reset(s),t.in_edit--}}}(this))},e.prototype._attributeComparator=function(e){var t;return t=function(t,n){var r;return r=u.utils.unwrapObservable(e),a.compare(t.get(r),n.get(r))},this.models_only?t:function(e,n){return t(a.utils.wrappedModel(e),a.utils.wrappedModel(n))}},e.prototype._createViewModel=function(e){return this.models_only?e:this.create_options.store.retainOrCreate(e,this.create_options)},e.prototype._selectModel=function(e){var t,n,r,i,o;for(n=a.peek(this._filters),r=0,i=n.length;i>r;r++)if(t=n[r],t=a.peek(t),l.isFunction(t)){if(!t(e))return!1}else if(l.isArray(t)){if(o=e.id,p.call(t,o)<0)return!1}else if(e.id!==t)return!1;return!0},e}(),a.collectionObservable=function(){return new a.CollectionObservable(arguments)}},function(e,t,n){var r,i,o,s,a,u,l;l=i=n(6),u=l._,s=l.ko,r={"default":null,"backbone-orm":null,"backbone-associations":n(16),"backbone-relational":n(17),supermodel:n(18)},i.orm=r["default"];for(o in r)if(a=r[o],a&&a.isAvailable()){i.orm=a;break}e.exports=function(e){var t;null==e&&(e={});for(o in e)switch(a=e[o],o){case"orm":if(u.isString(a)){if(!r.hasOwnProperty(a)){console.log("Knockback configure: could not find orm: "+a+". Available: "+u.keys(r).join(", "));continue}if((t=r[a])&&!t.isAvailable()){console.log("Knockback configure: could not enable orm "+a+". Make sure it is included before Knockback");continue}i.orm=t;continue}i.orm=a;break;default:i[o]=a}}},function(e,t,n){var r,i,o,s,a=function(e,t){return function(){return e.apply(t,arguments)}};s=r=n(6),o=s._,i=s.ko,r.EventWatcher=function(){function e(e,t,n){this._unbindCallbacks=a(this._unbindCallbacks,this),this._onModelUnloaded=a(this._onModelUnloaded,this),this._onModelLoaded=a(this._onModelLoaded,this),this.__kb||(this.__kb={}),this.__kb.callbacks={},this.ee=null,n&&this.registerCallbacks(t,n),e&&this.emitter(e)}return e.useOptionsOrCreate=function(e,t,n,i){return e.event_watcher?(e.event_watcher.emitter()!==t&&e.event_watcher.model_ref!==t&&r._throwUnexpected(this,"emitter not matching"),r.utils.wrappedEventWatcher(n,e.event_watcher).registerCallbacks(n,i)):(r.utils.wrappedEventWatcherIsOwned(n,!0),r.utils.wrappedEventWatcher(n,new r.EventWatcher(t)).registerCallbacks(n,i))},e.prototype.destroy=function(){return this.emitter(null),this.__kb.callbacks=null,r.utils.wrappedDestroy(this)},e.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),r.Backbone&&r.Backbone.ModelRef&&e instanceof r.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)},e.prototype.registerCallbacks=function(e,t){var n,s,a,u,l,c;for(e||r._throwMissing(this,"obj"),t||r._throwMissing(this,"callback_info"),s=t.event_selector?t.event_selector.split(" "):["change"],a=this.ee,u=function(n){return function(s){var u,l;return(u=n.__kb.callbacks[s])||(u=n.__kb.callbacks[s]={model:null,list:[],fn:function(e){var t,n,o,a;for(a=u.list,n=0,o=a.length;o>n;n++)t=a[n],t.update&&(e&&t.key&&e.hasChanged&&!e.hasChanged(i.utils.unwrapObservable(t.key))||(!r.statistics||r.statistics.addModelEvent({name:s,model:e,key:t.key,path:t.path}),t.update()));return null}}),u.list.push(l=o.defaults({obj:e},t)),a?n._onModelLoaded(a):void 0}}(this),l=0,c=s.length;c>l;l++)n=s[l],n&&u(n);return this},e.prototype.releaseCallbacks=function(e){var t,n,i;this.ee=null,i=this.__kb.callbacks;for(n in i)t=i[n],this._unbindCallbacks(n,t,r.wasReleased(e));return delete this.__kb.callbacks},e.prototype._onModelLoaded=function(e){var t,n,i,o,s,a,u,l;this.ee=e,a=this.__kb.callbacks;for(n in a)for(t=a[n],t.model&&t.model!==e&&this._unbindCallbacks(n,t,!0),t.model||(t.model=e,e.bind(n,t.fn)),u=t.list,o=0,s=u.length;s>o;o++)i=u[o],i.unbind_fn||(i.unbind_fn=null!=(l=r.orm)?l.bind(e,i.key,i.update,i.path):void 0),i.emitter&&i.emitter(e)},e.prototype._onModelUnloaded=function(e){var t,n,r;if(this.ee===e){this.ee=null,r=this.__kb.callbacks;for(n in r)t=r[n],this._unbindCallbacks(n,t)}},e.prototype._unbindCallbacks=function(e,t,n){var i,o,s,a;for(t.model&&(t.model.unbind(e,t.fn),t.model=null),a=t.list,o=0,s=a.length;s>o;o++)i=a[o],i.unbind_fn&&(i.unbind_fn(),i.unbind_fn=null),!i.emitter||n||r.wasReleased(i.obj)||i.emitter(null)},e}(),r.emitterObservable=function(e,t){return new r.EventWatcher(e,t)}},function(e,t,n){var r,i;i=(r=n(6))._,r.Factory=function(){function e(e){this.paths={},e&&(this.parent_factory=e)}return e.useOptionsOrCreate=function(e,t,n){var i;return e.factory&&(!e.factories||e.factories&&e.factory.hasPathMappings(e.factories,n))?r.utils.wrappedFactory(t,e.factory):(i=r.utils.wrappedFactory(t,new r.Factory(e.factory)),e.factories&&i.addPathMappings(e.factories,n),i)},e.prototype.hasPath=function(e){var t;return this.paths.hasOwnProperty(e)||(null!=(t=this.parent_factory)?t.hasPath(e):void 0)},e.prototype.addPathMapping=function(e,t){return this.paths[e]=t},e.prototype.addPathMappings=function(e,t){var n,i;for(i in e)n=e[i],this.paths[r.utils.pathJoin(t,i)]=n},e.prototype.hasPathMappings=function(e,t){var n,i,o,s;n=!0;for(s in e)i=e[s],n&=(o=this.creatorForPath(null,r.utils.pathJoin(t,s)))&&i===o;return n},e.prototype.creatorForPath=function(e,t){var n,r;return(n=this.paths[t])?n.view_model?n.view_model:n:(n=null!=(r=this.parent_factory)?r.creatorForPath(e,t):void 0)?n:null},e}()},function(e,t,n){(function(e){var t,r,i,o,s,a,u,l;s=null!=s?s:e,l=r=n(6),a=l._,i=l.ko,t=l.$,r.RECUSIVE_AUTO_INJECT=!0,i.bindingHandlers.inject={init:function(e,t,n,o){return r.Inject.inject(i.utils.unwrapObservable(t()),o,e,t,n)}},r.Inject=function(){function e(){}return e.inject=function(e,t,n,i,o,s){var u;return u=function(e){var u,l,c;if(a.isFunction(e))t=new e(t,n,i,o),r.releaseOnNodeRemove(t,n);else{e.view_model&&(t=new e.view_model(t,n,i,o),r.releaseOnNodeRemove(t,n));for(u in e)c=e[u],"view_model"!==u&&("create"===u?c(t,n,i,o):a.isObject(c)&&!a.isFunction(c)?(l=s||c&&c.create?{}:t,t[u]=r.Inject.inject(c,l,n,i,o,!0)):t[u]=c)}return t},s?u(e):r.ignore(function(){return u(e)})},e.injectViewModels=function(e){var t,n,i,o,u,l,c,d,p,f;for(d=[],l=function(e){var t,n,r,i,o;for(e.__kb_injected||e.attributes&&(t=a.find(e.attributes,function(e){return"kb-inject"===e.name}))&&(e.__kb_injected=!0,d.push({el:e,view_model:{},binding:t.value})),o=e.childNodes,r=0,i=o.length;i>r;r++)n=o[r],l(n)},!e&&(null!=s?s.document:void 0)&&(e=s.document),l(e),p=0,f=d.length;f>p;p++)n=d[p],(u=n.binding)&&(u.search(/[:]/)<0||(u="{"+u+"}"),o=new Function("","return ( "+u+" )")(),o||(o={}),!o.options||(c=o.options,delete o.options),c||(c={}),n.view_model=r.Inject.inject(o,n.view_model,n.el,null,null,!0),t=n.view_model.afterBinding||c.afterBinding,i=n.view_model.beforeBinding||c.beforeBinding),i&&i.call(n.view_model,n.view_model,n.el,c),r.applyBindings(n.view_model,n.el,c),t&&t.call(n.view_model,n.view_model,n.el,c);return d},e}(),u=i.applyBindings,i.applyBindings=function(e,t){var n;return n=r.RECUSIVE_AUTO_INJECT?r.injectViewModels(t):[],n.length?void 0:u.apply(this,arguments)},r.injectViewModels=r.Inject.injectViewModels,"undefined"!=typeof document&&null!==document&&(t?t(function(){return r.injectViewModels()}):(o=function(){return"complete"!==document.readyState?setTimeout(o,0):r.injectViewModels()})())}).call(t,function(){return this}())},function(e,t,n){(function(t){var r,i,o,s,a,u;a=null!=a?a:t,s=n(25),i=["release","destroy","dispose"],e.exports=o=function(){function e(){}var t;return e.VERSION="0.20.2",e.TYPE_UNKNOWN=0,e.TYPE_SIMPLE=1,e.TYPE_ARRAY=2,e.TYPE_MODEL=3,e.TYPE_COLLECTION=4,e.wasReleased=function(e){return!e||e.__kb_released},e.isReleaseable=function(t,n){var r,o,a,u,l;if(null==n&&(n=0),!t||t!==Object(t)||t.__kb_released)return!1;if(s.isObservable(t)||t instanceof e.ViewModel)return!0;if("function"==typeof t||e.isModel(t)||e.isCollection(t))return!1;for(u=0,l=i.length;l>u;u++)if(o=i[u],"function"==typeof t[o])return!0;if(n>0)return!1;for(r in t)if(a=t[r],"__kb"!==r&&e.isReleaseable(a,n+1))return!0;return!1},e.release=function(t){var n,r,o,a,l,c;if(e.isReleaseable(t)){if(t.__kb_released=!0,!u.isArray(t)){if(s.isObservable(t)&&u.isArray(n=e.peek(t))){if(t.__kb_is_co||t.__kb_is_o&&t.valueType()===e.TYPE_COLLECTION)return"function"==typeof t.destroy?t.destroy():void 0;for(r in n)a=n[r],e.isReleaseable(a)&&(n[r]=null,e.release(a));return void("function"==typeof t.dispose&&t.dispose())}for(l=0,c=i.length;c>l;l++)if(o=i[l],"function"==typeof t[o])return t[o].call(t);return s.isObservable(t)?void 0:this.releaseKeys(t)}for(r in t)a=t[r],e.isReleaseable(a)&&(t[r]=null,e.release(a))}},e.releaseKeys=function(t){var n,r;for(n in t)r=t[n],"__kb"!==n&&e.isReleaseable(r)&&(t[n]=null,e.release(r))},e.releaseOnNodeRemove=function(t,n){return t||e._throwUnexpected(this,"missing view model"),n||e._throwUnexpected(this,"missing node"),s.utils.domNodeDisposal.addDisposeCallback(n,function(){return e.release(t)})},e.renderTemplate=function(t,n,r){var i,o,u;return null==r&&(r={}),(i=null!=a?a.document:void 0)?(o=i.createElement("div"),u=s.renderTemplate(t,n,r,o,"replaceChildren"),1===o.childNodes.length?o=o.childNodes[0]:o.childNodes.length&&s.storedBindingContextForNode(o,s.contextFor(o.childNodes[0])),e.releaseOnNodeRemove(n,o),u.dispose(),n.afterRender&&!r.afterRender&&n.afterRender(o),o):"undefined"!=typeof console&&null!==console?console.log("renderTemplate: document is undefined"):void 0},e.applyBindings=function(t,n){var r,i,o,a,u;if(n.length)for(u=[document.createElement("div"),n],n=u[0],i=u[1],o=0,a=i.length;a>o;o++)r=i[o],n.appendChild(r);return s.applyBindings(t,n),e.releaseOnNodeRemove(t,n),n},e.getValue=function(t,n,r){var i;if(t)return u.isFunction(t[n])&&(null!=(i=e.orm)?i.useFunction(t,n):void 0)?t[n]():r?t.get.apply(t,u.map([n].concat(r),function(t){return e.peek(t)})):t.get(n)},e.setValue=function(t,n,r){var i,o;if(t)return u.isFunction(t[n])&&(null!=(o=e.orm)?o.useFunction(t,n):void 0)?t[n](r):((i={})[n]=r,t.set(i))},e.ignore=(null!=(t=s.dependencyDetection)?t.ignore:void 0)||function(e,t,n){var r;return r=null,s.computed(function(){return r=e.apply(t,n||[])}).dispose(),r},e.extend=n(19),e._throwMissing=function(e,t){throw""+(u.isString(e)?e:e.constructor.name)+": "+t+" is missing"},e._throwUnexpected=function(e,t){throw""+(u.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"},e.publishMethods=function(t,n,r){var i,o,s;for(o=0,s=r.length;s>o;o++)i=r[o],t[i]=e._.bind(n[i],n)},e.peek=function(t){return s.isObservable(t)?t.peek?t.peek():e.ignore(function(){return t()}):t},e.isModel=function(t){return t&&(t instanceof e.Model||"function"==typeof t.get&&"function"==typeof t.bind)},e.isCollection=function(t){return t&&t instanceof e.Collection},e}(),a.Parse?(r=o.Parse=a.Parse,u=o._=a.Parse._):(r=o.Backbone=n(23),u=o._=n(24)),o.ko=s,o.Collection=r.Collection,o.Model=r.Object||r.Model,o.Events=r.Events,o.$=a.jQuery||a.$;try{o.$||(o.$=n(15))}catch(l){}}).call(t,function(){return this}())},function(e,t,n){var r,i,o,s,a;i=(r=n(6)).ko,(null!=(s=i.subscribable)&&null!=(a=s.fn)?a.extend:void 0)&&(o=i.subscribable.fn.extend,i.subscribable.fn.extend=function(){var e,t;return e=o.apply(this,arguments),e!==this&&r.isReleaseable(this)&&(t=e.dispose,e.dispose=function(n){return function(){return null!=t&&t.apply(e,arguments),r.release(n)}}(this)),e})},function(e,t,n){var r,i,o,s,a,u,l;l=s=n(6),u=l._,a=l.ko,o=n(11),i=["value","valueType","destroy"],r=["args","read","write"],s.Observable=function(){function e(e,t,n,l){return this._vm=null!=l?l:{},s.ignore(function(l){return function(){var c,d,p,f,h,m;for(t||s._throwMissing(l,"key_or_info"),l.key=t.key||t,h=0,m=r.length;m>h;h++)p=r[h],t[p]&&(l[p]=t[p]);return c=s.utils.collapseOptions(n),d=c.event_watcher,delete c.event_watcher,l._value=new o(c),l._model=a.observable(),f=s.utils.wrappedObservable(l,a.computed({read:function(){var e,t,n,r,i,o,c;for(i=l._model(),o=t=[l.key].concat(l.args||[]),n=0,r=o.length;r>n;n++)e=o[n],a.utils.unwrapObservable(e);return null!=(c=s.utils.wrappedEventWatcher(l))&&c.emitter(i||null),l.read?l.update(l.read.apply(l._vm,t)):u.isUndefined(i)||s.ignore(function(){return l.update(s.getValue(i,s.peek(l.key),l.args))}),l._value.value()},write:function(e){return s.ignore(function(){var t,n;return t=s.utils.unwrapModels(e),n=s.peek(l._model),l.write?(l.write.call(l._vm,t),e=s.getValue(n,s.peek(l.key),l.args)):n&&s.setValue(n,s.peek(l.key),t),l.update(e)})},owner:l._vm})),f.__kb_is_o=!0,c.store=s.utils.wrappedStore(f,c.store),c.path=s.utils.pathJoin(c.path,l.key),c.factories&&("function"==typeof c.factories||c.factories.create)?(c.factory=s.utils.wrappedFactory(f,new s.Factory(c.factory)),c.factory.addPathMapping(c.path,c.factories)):c.factory=s.Factory.useOptionsOrCreate(c,f,c.path),delete c.factories,s.publishMethods(f,l,i),f.model=l.model=a.computed({read:function(){return a.utils.unwrapObservable(l._model)},write:function(e){return s.ignore(function(){var t;if(!l.__kb_released&&s.peek(l._model)!==e)return t=s.getValue(e,s.peek(l.key),l.args),l._model(e),e?u.isUndefined(t)?void 0:l.update(t):l.update(null)})}}),s.EventWatcher.useOptionsOrCreate({event_watcher:d},e||null,l,{emitter:l.model,update:function(){return s.ignore(function(){return l.update()})},key:l.key,path:c.path}),l._value.rawValue()||l._value.update(),s.LocalizedObservable&&t.localizer&&(f=new t.localizer(f)),s.DefaultObservable&&t.hasOwnProperty("default")&&(f=s.defaultObservable(f,t["default"])),f}}(this))}return e.prototype.destroy=function(){var e;return e=s.utils.wrappedObservable(this),this.__kb_released=!0,this._value.destroy(),this._value=null,this.model.dispose(),this.model=e.model=null,s.utils.wrappedDestroy(this)},e.prototype.value=function(){return this._value.rawValue()},e.prototype.valueType=function(){return this._value.valueType(s.peek(this._model),s.peek(this.key))},e.prototype.update=function(e){return this.__kb_released?void 0:(arguments.length||(e=s.getValue(s.peek(this._model),s.peek(this.key))),this._value.update(e))},e}(),s.observable=function(e,t,n,r){return new s.Observable(e,t,n,r)}},function(e,t,n){var r,i;i=(r=n(6))._,e.exports=r.Statistics=function(){function e(){this.model_events_tracker=[],this.registered_tracker={}}return e.prototype.clear=function(){return this.model_events_tracker=[]},e.prototype.addModelEvent=function(e){return this.model_events_tracker.push(e)},e.prototype.modelEventsStatsString=function(){var e,t,n,r;n="",n+="Total Count: "+this.model_events_tracker.length,e=i.groupBy(this.model_events_tracker,function(e){return"event name: '"+e.name+"', attribute name: '"+e.key+"'"});for(t in e)r=e[t],n+="\n "+t+", count: "+r.length;return n},e.prototype.register=function(e,t){return this.registeredTracker(e).push(t)},e.prototype.unregister=function(e,t){var n,r;return r=this.registeredTracker(e),(n=i.indexOf(r,t))<0?"undefined"!=typeof console&&null!==console?console.log("kb.Statistics: failed to unregister type: "+e):void 0:r.splice(n,1)},e.prototype.registeredCount=function(e){var t,n,r;if(e)return this.registeredTracker(e).length;t=0,r=this.registered_tracker[e];for(e in r)n=r[e],t+=n.length;return t},e.prototype.registeredStatsString=function(e){var t,n,r,i,o;t="",o=this.registered_tracker;for(n in o)r=o[n],r.length&&(i&&(t+="\n "),t+=""+(n?n:"No Name")+": "+r.length,i=!0);return t?t:e},e.prototype.registeredTracker=function(e){var t;return this.registered_tracker.hasOwnProperty(e)?this.registered_tracker[e]:(t=[],this.registered_tracker[e]=t,t)},e.eventsStats=function(e,t){var n,r,o,s,a,u,l;for(o={count:0},n=e._events||e._callbacks||{},l=t?[t]:i.keys(n),a=0,u=l.length;u>a;a++)if(t=l[a],r=n[t]){if(i.isArray(r))o[t]=i.compact(r).length;else for(o[t]=0,s=r.tail;(r=r.next)!==s;)o[t]++;o.count+=o[t]}return o},e}()},function(e,t,n){var r,i,o,s;s=r=n(6),o=s._,i=s.ko,e.exports=r.Store=function(){function e(){this.observable_records={},this.replaced_observables=[],r.Store.instances.push(this)}return e.instances=[],e.useOptionsOrCreate=function(e,t,n){var i;return e.store||r.utils.wrappedStoreIsOwned(n,!0),i=r.utils.wrappedStore(n,e.store||new r.Store),i.retain(n,t,e.creator),i},e.prototype.destroy=function(){var e;return this.__kb_released=!0,this.clear(),(e=o.indexOf(r.Store.instances,this))>=0?r.Store.instances.splice(e,1):void 0},e.prototype.clear=function(){var e,t,n,r,i,o,s,a,u,l;u=[this.observable_records,{}],r=u[0],this.observable_records=u[1];for(t in r){i=r[t];for(e in i)n=i[e],this.release(n,!0)}for(l=[this.replaced_observables,[]],o=l[0],this.replaced_observables=l[1],s=0,a=o.length;a>s;s++)n=o[s],n.__kb_released||this.release(n,!0)},e.prototype.compact=function(){var e,t,n,r,i;i=this.observable_records;for(t in i){r=i[t];for(e in r)n=r[e],n.__kb_released&&delete r[e]}},e.prototype.retain=function(e,t,n){var r;if(this._canRegister(e)){if(n||(n=e.constructor),r=this.find(t,n)){if(r===e)return this._getOrCreateStoreReferences(e).ref_count++,e;this._retire(r)}return this._add(e,t,n),this._getOrCreateStoreReferences(e).ref_count++,e}},e.prototype.retainOrCreate=function(e,t){var n,s;if(!(n=this._creator(e,t)))return r.utils.createFromDefaultCreator(e,t);if(n.models_only)return e;if(s=this.find(e,n))return s;if(!o.isFunction(n.create||n))throw new Error('Invalid factory for "'+t.path+'"');return s=r.ignore(function(r){return function(){return t=o.defaults({store:r,creator:n},t),s=n.create?n.create(e,t):new n(e,t),s||i.observable(null)}}(this)),this.retain(s,e,n),s},e.prototype.reuse=function(e,t){var n,i,s;if((i=r.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));n=r.utils.wrappedCreator(e)||e.constructor,o.isUndefined(i)||(s=this.find(i,n)),this.retain(e,t,n),s&&this.release(s)}},e.prototype.release=function(e,t){var n;if(!this._canRegister(e))return r.release(e);if(n=this._storeReferences(e)){if(!t&&--n.ref_count>0)return;this._clearStoreReferences(e)}return this._remove(e),e.__kb_released?void 0:t||this._refCount(e)<=1?r.release(e):void 0},e.prototype.find=function(e,t){var n,r,i;return(r=this.observable_records[this._creatorId(t)])?(null!=(i=n=r[this._cid(e)])?i.__kb_released:void 0)?(delete r[this._cid(e)],null):n:null},e.prototype._refCount=function(e){var t;return e.__kb_released?("undefined"!=typeof console&&null!==console&&console.log("Observable already released"),0):(t=r.utils.get(e,"stores_references"))?o.reduce(t,function(e,t){return e+t.ref_count},0):1},e.prototype._canRegister=function(e){return e&&!i.isObservable(e)&&!e.__kb_is_co},e.prototype._cid=function(e){var t;return t=e?e.cid||(e.cid=o.uniqueId("c")):"null"},e.prototype._creatorId=function(e){var t,n,r,i,s;for(t=e.create||e,t.__kb_cids||(t.__kb_cids=[]),s=t.__kb_cids,r=0,i=s.length;i>r;r++)if(n=s[r],n.create===t)return n.cid;return t.__kb_cids.push(n={create:t,cid:o.uniqueId("kb")}),n.cid},e.prototype._storeReferences=function(e){var t;if(t=r.utils.get(e,"stores_references"))return o.find(t,function(e){return function(t){return t.store===e}}(this))},e.prototype._getOrCreateStoreReferences=function(e){var t,n;return n=r.utils.orSet(e,"stores_references",[]),(t=o.find(n,function(e){return function(t){return t.store===e}}(this)))||n.push(t={store:this,ref_count:0,release:function(t){return function(){return t.release(e)}}(this)}),t},e.prototype._clearStoreReferences=function(e){var t,n,i,o;if(i=r.utils.get(e,"stores_references")){o=e.__kb.stores_references;for(t in o)if(n=o[t],n.store===this){e.__kb.stores_references.splice(t,1);break}}},e.prototype._retire=function(e){return this._clearStoreReferences(e),this.replaced_observables.push(e),this._remove(e)},e.prototype._add=function(e,t,n){var i,o;return n||(n=e.constructor),r.utils.wrappedObject(e,t),r.utils.wrappedCreator(e,n),((i=this.observable_records)[o=this._creatorId(n)]||(i[o]={}))[this._cid(t)]=e},e.prototype._remove=function(e){var t,n,i;return t=r.utils.wrappedCreator(e)||e.constructor,(n=this.find(i=r.utils.wrappedObject(e),t))&&n===e&&delete this.observable_records[this._creatorId(t)][this._cid(i)],r.utils.wrappedObject(e,null),r.utils.wrappedCreator(e,null)},e.prototype._creator=function(e,t){var n;return t.creator?t.creator:(n=r.utils.inferCreator(e,t.factory,t.path))?n:r.isModel(e)?r.ViewModel:void 0},e}()},function(e,t,n){var r,i,o,s,a;a=i=n(6),s=a._,o=a.ko,e.exports=r=function(){function e(e){this.create_options=e,this._vo=o.observable(null)}return e.prototype.destroy=function(){var e;return this.__kb_released=!0,(e=this.__kb_value)&&(this.__kb_value=null,this.create_options.store&&i.utils.wrappedCreator(e)?this.create_options.store.release(e):i.release(e)),this.create_options=null},e.prototype.value=function(){return o.utils.unwrapObservable(this._vo())},e.prototype.rawValue=function(){return this.__kb_value},e.prototype.valueType=function(e,t){var n;return n=i.getValue(e,t),this.value_type||this._updateValueObservable(n),this.value_type},e.prototype.update=function(e){var t,n,r;if(!this.__kb_released){switch(void 0!==e||(e=null),t=i.utils.valueType(e),(null!=(r=this.__kb_value)?r.__kb_released:void 0)&&(this.__kb_value=this.value_type=void 0),n=this.__kb_value,this.value_type){case i.TYPE_COLLECTION:if(this.value_type===i.TYPE_COLLECTION&&t===i.TYPE_ARRAY)return n(e);if(t===i.TYPE_COLLECTION||s.isNull(e))return void(e&&e instanceof i.CollectionObservable?this._updateValueObservable(i.utils.wrappedObject(e),e):i.peek(n.collection)!==e&&n.collection(e));break;case i.TYPE_MODEL:if(t===i.TYPE_MODEL||s.isNull(e))return void(e&&!i.isModel(e)?this._updateValueObservable(i.utils.wrappedObject(e),e):i.utils.wrappedObject(n)!==i.utils.resolveModel(e)&&this._updateValueObservable(e))}if(this.value_type!==t||s.isUndefined(this.value_type)){if(i.peek(n)!==e)return this._updateValueObservable(e)}else if(i.peek(n)!==e)return n(e)}},e.prototype._updateValueObservable=function(e,t){var n,r,a,u,l,c;return n=this.create_options,r=i.utils.inferCreator(e,n.factory,n.path),null!==e||r||(this.value_type===i.TYPE_MODEL?r=i.ViewModel:this.value_type===i.TYPE_COLLECTION&&(r=i.CollectionObservable)),n.creator=r,l=i.TYPE_UNKNOWN,c=[this.__kb_value,void 0],a=c[0],this.__kb_value=c[1],t?(u=t,n.store&&n.store.retain(t,e,r)):r?n.store?u=n.store.retainOrCreate(e,n):r.models_only?(u=e,l=i.TYPE_SIMPLE):u=r.create?r.create(e,n):new r(e,n):s.isArray(e)?(l=i.TYPE_ARRAY,u=o.observableArray(e)):(l=i.TYPE_SIMPLE,u=o.observable(e)),(this.value_type=l)===i.TYPE_UNKNOWN&&(o.isObservable(u)?u.__kb_is_co?(this.value_type=i.TYPE_COLLECTION,i.utils.wrappedObject(u,e)):this.value_type||(this.value_type=i.TYPE_SIMPLE):(this.value_type=i.TYPE_MODEL,i.utils.wrappedObject(u,i.utils.resolveModel(e)))),a&&(this.create_options.store?this.create_options.store.release(a):i.release(a)),this.__kb_value=u,this._vo(u)},e.prototype._inferType=function(){},e}()},function(e,t,n){var r,i,o,s;s=r=n(6),o=s._,i=s.ko,r.utils=function(){function e(){}return e.get=function(e,t,n){return e.__kb&&e.__kb.hasOwnProperty(t)?e.__kb[t]:n},e.set=function(e,t,n){return(e.__kb||(e.__kb={}))[t]=n},e.orSet=function(e,t,n){return(e.__kb||(e.__kb={})).hasOwnProperty(t)||(e.__kb[t]=n),e.__kb[t]},e.has=function(e,t){return e.__kb&&e.__kb.hasOwnProperty(t)},e.wrappedObservable=function(e,t){return 1===arguments.length?r.utils.get(e,"observable"):r.utils.set(e,"observable",t)},e.wrappedObject=function(e,t){return 1===arguments.length?r.utils.get(e,"object"):r.utils.set(e,"object",t)},e.wrappedCreator=function(e,t){return 1===arguments.length?r.utils.get(e,"creator"):r.utils.set(e,"creator",t)},e.wrappedModel=function(e,t){return 1===arguments.length?o.isUndefined(t=r.utils.get(e,"object"))?e:t:r.utils.set(e,"object",t)},e.wrappedStore=function(e,t){return 1===arguments.length?r.utils.get(e,"store"):r.utils.set(e,"store",t)},e.wrappedStoreIsOwned=function(e,t){return 1===arguments.length?r.utils.get(e,"store_is_owned"):r.utils.set(e,"store_is_owned",t)},e.wrappedFactory=function(e,t){return 1===arguments.length?r.utils.get(e,"factory"):r.utils.set(e,"factory",t)},e.wrappedEventWatcher=function(e,t){return 1===arguments.length?r.utils.get(e,"event_watcher"):r.utils.set(e,"event_watcher",t)},e.wrappedEventWatcherIsOwned=function(e,t){return 1===arguments.length?r.utils.get(e,"event_watcher_is_owned"):r.utils.set(e,"event_watcher_is_owned",t)},e.wrappedDestroy=n(20),e.valueType=function(e){return e?e.__kb_is_o?e.valueType():e.__kb_is_co||e instanceof r.Collection?r.TYPE_COLLECTION:e instanceof r.ViewModel||e instanceof r.Model?r.TYPE_MODEL:o.isArray(e)?r.TYPE_ARRAY:r.TYPE_SIMPLE:r.TYPE_UNKNOWN },e.pathJoin=function(e,t){return(e?"."!==e[e.length-1]?""+e+".":e:"")+t},e.optionsPathJoin=function(e,t){return o.defaults({path:this.pathJoin(e.path,t)},e)},e.inferCreator=function(e,t,n){var i;return t&&(i=t.creatorForPath(e,n))?i:e?e instanceof r.Model?r.ViewModel:e instanceof r.Collection?r.CollectionObservable:null:null},e.createFromDefaultCreator=function(e,t){return r.isModel(e)?r.viewModel(e,t):r.isCollection(e)?r.collectionObservable(e,t):o.isArray(e)?i.observableArray(e):i.observable(e)},e.collapseOptions=n(21),e.unwrapModels=n(22),e.resolveModel=function(e){return e&&r.Backbone&&r.Backbone.ModelRef&&e instanceof r.Backbone.ModelRef?e.model():e},e}()},function(e,t,n){var r,i,o,s,a,u,l,c;c=a=n(6),l=c._,u=c.ko,i=function(e,t){var n;return n=e.__kb.internals&&l.contains(e.__kb.internals,t)?"_"+t:t,e.__kb.view_model.hasOwnProperty(n)?void 0:(e.__kb.view_model[n]=null,n)},o=function(e,t,n,r){var o;if(!(e.__kb.excludes&&l.contains(e.__kb.excludes,n)||e.__kb.statics&&l.contains(e.__kb.statics,n)||!(o=i(e,n))))return e[o]=e.__kb.view_model[o]=a.observable(t,n,r,e)},s=function(e,t){var n,r,o,s,a;for(a=e.__kb.statics,o=0,s=a.length;s>o;o++)n=a[o],(r=i(e,n))&&(t.has(r)?e[r]=e.__kb.view_model[r]=t.get(r):e.__kb.static_defaults&&r in e.__kb.static_defaults?e[r]=e.__kb.view_model[r]=e.__kb.static_defaults[r]:delete e.__kb.view_model[r])},r=["keys","internals","excludes","statics","static_defaults"],a.ViewModel=function(){function e(e,t){var n;return null==t&&(t={}),n=Array.prototype.slice.call(l.isArguments(e)?e:arguments),a.ignore(function(i){return function(){var o,c,d,p,f,h,m,v;for(!(e=n.shift())||a.isModel(e)||a._throwUnexpected(i,"not a model"),l.isArray(n[0])&&(n[0]={keys:n[0]}),i.__kb||(i.__kb={}),i.__kb.view_model=n.length>1?n.pop():i,t={},p=0,h=n.length;h>p;p++)o=n[p],l.extend(t,o);for(t=a.utils.collapseOptions(t),f=0,m=r.length;m>f;f++)d=r[f],t.hasOwnProperty(d)&&(i.__kb[d]=t[d]);return a.Store.useOptionsOrCreate(t,e,i),i.__kb.path=t.path,a.Factory.useOptionsOrCreate(t,i,t.path),v=a.utils.set(i,"_model",u.observable()),i.model=u.computed({read:function(){return u.utils.unwrapObservable(v)},write:function(e){return a.ignore(function(){return a.utils.wrappedObject(i)!==e&&!a.wasReleased(i)&&c?(i.__kb.store.reuse(i,a.utils.resolveModel(e)),c.emitter(e),v(c.ee),!c.ee||i.createObservables(c.ee)):void 0})}}),c=a.utils.wrappedEventWatcher(i,new a.EventWatcher(e,i,{emitter:i._model,update:function(){return a.ignore(function(){return!(null!=c?c.ee:void 0)||i.createObservables(null!=c?c.ee:void 0)})}})),a.utils.wrappedObject(i,e=c.ee),v(c.ee),i.__kb.create_options={store:a.utils.wrappedStore(i),factory:a.utils.wrappedFactory(i),path:i.__kb.path,event_watcher:a.utils.wrappedEventWatcher(i)},!t.requires||i.createObservables(e,t.requires),!i.__kb.internals||i.createObservables(e,i.__kb.internals),!t.mappings||i.createObservables(e,t.mappings),!i.__kb.statics||s(i,e),i.createObservables(e,i.__kb.keys),!a.statistics||a.statistics.register("ViewModel",i),i}}(this))}return e.extend=a.extend,e.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,a.releaseKeys(this),a.utils.wrappedDestroy(this),!a.statistics||a.statistics.unregister("ViewModel",this)},e.prototype.shareOptions=function(){return{store:a.utils.wrappedStore(this),factory:a.utils.wrappedFactory(this)}},e.prototype.createObservables=function(e,t){var n,r,s,u,c,d,p,f,h;if(t)if(l.isArray(t))for(d=0,f=t.length;f>d;d++)n=t[d],o(this,e,n,this.__kb.create_options);else for(n in t)r=t[n],(u=i(this,n))&&(l.isString(r)||r.key||(r.key=u),this[u]=this.__kb.view_model[u]=a.observable(e,r,this.__kb.create_options,this));else{if(this.__kb.keys||!e)return;for(n in e.attributes)o(this,e,n,this.__kb.create_options);if(s=null!=(h=a.orm)&&"function"==typeof h.keys?h.keys(e):void 0)for(c=0,p=s.length;p>c;c++)n=s[c],o(this,e,n,this.__kb.create_options)}},e}(),a.viewModel=function(){return new a.ViewModel(arguments)}},function(e,t,n){var r,i,o,s,a;if(e.exports=r=n(6),r.configure=n(2),r.modules={underscore:r._,backbone:r.Parse||r.Backbone,knockout:r.ko},"undefined"!=typeof window&&null!==window)for(a=["_","Backbone","Parse","ko","$"],o=0,s=a.length;s>o;o++)i=a[o],r[i]&&!window.hasOwnProperty(i)&&(window[i]=r[i])},function(t){t.exports=e},function(e,t,n){var r,i,o,s,a,u;u=s=n(6),a=u._,i=u.Backbone,r=null,e.exports=o=function(){function e(){}return e.isAvailable=function(){return!!(r=null!=i?i.AssociatedModel:void 0)},e.keys=function(e){return e instanceof r?a.map(e.relations,function(e){return e.key}):null},e.relationType=function(e,t){var n;return e instanceof r&&(n=a.find(e.relations,function(e){return e.key===t}))?"Many"===n.type?s.TYPE_COLLECTION:s.TYPE_MODEL:null},e.useFunction=function(){return!1},e}()},function(e,t,n){var r,i,o,s,a,u;u=s=n(6),a=u._,r=u.Backbone,o=null,e.exports=i=function(){function e(){}return e.isAvailable=function(){return!!(o=null!=r?r.RelationalModel:void 0)},e.relationType=function(e,t){var n;return e instanceof o&&(n=a.find(e.getRelations(),function(e){return e.key===t}))?n.collectionType||a.isArray(n.keyContents)?s.TYPE_COLLECTION:s.TYPE_MODEL:null},e.bind=function(e,t,n,r){var i,o,a,u,l,c;if(!(u=this.relationType(e,t)))return null;if(a=function(e){return!s.statistics||s.statistics.addModelEvent({name:"update (relational)",model:e,key:t,path:r}),n()},o=s.Backbone.Relation.prototype.sanitizeOptions?["update","add","remove"]:["change","add","remove"],u===s.TYPE_COLLECTION)for(l=0,c=o.length;c>l;l++)i=o[l],e.bind(""+i+":"+t,a);else e.bind(""+o[0]+":"+t,a);return function(){var n,r;if(u===s.TYPE_COLLECTION)for(n=0,r=o.length;r>n;n++)i=o[n],e.unbind(""+i+":"+t,a);else e.unbind(""+o[0]+":"+t,a)}},e.useFunction=function(){return!1},e}()},function(e,t,n){(function(t){var r,i,o,s;o="undefined"!=typeof window&&null!==window?window:t,s=(i=n(6))._,r=null,e.exports=r=function(){function e(){}return e.isAvailable=function(){return!!(e=o.Supermodel)},e.keys=function(t){return t instanceof e.Model?s.keys(t.constructor.associations()):null},e.relationType=function(t,n){var r;return t instanceof e.Model&&(r=t.constructor.associations()[n])?r.add?i.TYPE_COLLECTION:i.TYPE_MODEL:null},e.bind=function(e,t,n,r){var o,s;return(s=this.relationType(e,t))?(o=function(e,o){var s,a;return!i.statistics||i.statistics.addModelEvent({name:"update (supermodel)",model:e,key:t,path:r}),a=e.constructor.associations()[t],s=e[a.store],e[a.store]=o,n(o),e[a.store]=s},s===i.TYPE_MODEL?(e.bind("associate:"+t,o),function(){return e.unbind("associate:"+t,o)}):void 0):null},e.useFunction=function(e,t){return!!this.relationType(e,t)},e}()}).call(t,function(){return this}())},function(e){var t;t=function(e,t){var n,r;for(n in t)r=t[n],e[n]=r;return e};var n=function(){},r=function(e,r,i){var o;return o=r&&r.hasOwnProperty("constructor")?r.constructor:function(){e.apply(this,arguments)},t(o,e),n.prototype=e.prototype,o.prototype=new n,r&&t(o.prototype,r),i&&t(o,i),o.prototype.constructor=o,o.__super__=e.prototype,o},i=function(e,t){var n=r(this,e,t);return n.extend=this.extend,n};e.exports=i},function(e,t,n){var r,i;i=n(6)._,e.exports=r=function(e){var t,n;if(e.__kb&&(e.__kb.event_watcher&&e.__kb.event_watcher.releaseCallbacks(e),n=e.__kb,e.__kb=null,n.observable&&(n.observable.destroy=n.observable.release=null,r(n.observable),n.observable=null),n.factory=null,n.event_watcher_is_owned&&n.event_watcher.destroy(),n.event_watcher=null,n.store_is_owned&&n.store.destroy(),n.store=null,n.stores_references))for(;t=n.stores_references.pop();)t.store.__kb_released||t.store.release(e)}},function(e,t,n){var r,i,o,s,a;r=n(6)._,o=function(e,t,n){return e[t]||(e[t]=[]),r.isArray(n)||(n=[n]),e[t]=e[t].length?r.union(e[t],n):n,e},s=function(e,t,n){return e[t]||(e[t]={}),r.extend(e[t],n)},i=function(e){var t,n,r,i;for(n={},r=0,i=e.length;i>r;r++)t=e[r],n[t]={key:t};return n},a=function(e,t){var n,u;if(!t)return e;for(n in t)switch(u=t[n],n){case"internals":case"requires":case"excludes":case"statics":o(e,n,u);break;case"keys":r.isObject(u)&&!r.isArray(u)||r.isObject(e[n])&&!r.isArray(e[n])?(r.isObject(u)||(u=[u]),r.isArray(u)&&(u=i(u)),r.isArray(e[n])&&(e[n]=i(e[n])),s(e,n,u)):o(e,n,u);break;case"factories":r.isFunction(u)?e[n]=u:s(e,n,u);break;case"static_defaults":s(e,n,u);break;case"options":break;default:e[n]=u}return a(e,t.options)},e.exports=function(e){return a({},e)}},function(e,t,n){var r,i;i=n(6)._,e.exports=r=function(e){var t,n,o;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 r(e)});if(i.isObject(e)&&e.constructor==={}.constructor){n={};for(t in e)o=e[t],n[t]=r(o);return n}return e}},function(e,t,n){var r,i;!function(o,s){r=[n(24),n(15),t],i=function(e,t,n){o.Backbone=s(o,n,e,t)}.apply(t,r),!(void 0!==i&&(e.exports=i))}(this,function(e,t,n,r){{var i=e.Backbone,o=[],s=(o.push,o.slice);o.splice}t.VERSION="1.1.2",t.$=r,t.noConflict=function(){return e.Backbone=i,this},t.emulateHTTP=!1,t.emulateJSON=!1;var a=t.Events={on:function(e,t,n){if(!l(this,"on",e,[t,n])||!t)return this;this._events||(this._events={});var r=this._events[e]||(this._events[e]=[]);return r.push({callback:t,context:n,ctx:n||this}),this},once:function(e,t,r){if(!l(this,"once",e,[t,r])||!t)return this;var i=this,o=n.once(function(){i.off(e,o),t.apply(this,arguments)});return o._callback=t,this.on(e,o,r)},off:function(e,t,r){var i,o,s,a,u,c,d,p;if(!this._events||!l(this,"off",e,[t,r]))return this;if(!e&&!t&&!r)return this._events=void 0,this;for(a=e?[e]:n.keys(this._events),u=0,c=a.length;c>u;u++)if(e=a[u],s=this._events[e]){if(this._events[e]=i=[],t||r)for(d=0,p=s.length;p>d;d++)o=s[d],(t&&t!==o.callback&&t!==o.callback._callback||r&&r!==o.context)&&i.push(o);i.length||delete this._events[e]}return this},trigger:function(e){if(!this._events)return this;var t=s.call(arguments,1);if(!l(this,"trigger",e,t))return this;var n=this._events[e],r=this._events.all;return n&&c(n,t),r&&c(r,arguments),this},stopListening:function(e,t,r){var i=this._listeningTo;if(!i)return this;var o=!t&&!r;r||"object"!=typeof t||(r=this),e&&((i={})[e._listenId]=e);for(var s in i)e=i[s],e.off(t,r,this),(o||n.isEmpty(e._events))&&delete this._listeningTo[s];return this}},u=/\s+/,l=function(e,t,n,r){if(!n)return!0;if("object"==typeof n){for(var i in n)e[t].apply(e,[i,n[i]].concat(r));return!1}if(u.test(n)){for(var o=n.split(u),s=0,a=o.length;a>s;s++)e[t].apply(e,[o[s]].concat(r));return!1}return!0},c=function(e,t){var n,r=-1,i=e.length,o=t[0],s=t[1],a=t[2];switch(t.length){case 0:for(;++rp;p++)this.trigger("change:"+a[p],this,d[a[p]],r)}if(l)return this;if(!u)for(;this._pending;)r=this._pending,this._pending=!1,this.trigger("change",this,r);return this._pending=!1,this._changing=!1,this},unset:function(e,t){return this.set(e,void 0,n.extend({},t,{unset:!0}))},clear:function(e){var t={};for(var r in this.attributes)t[r]=void 0;return this.set(t,n.extend({},e,{unset:!0}))},hasChanged:function(e){return null==e?!n.isEmpty(this.changed):n.has(this.changed,e)},changedAttributes:function(e){if(!e)return this.hasChanged()?n.clone(this.changed):!1;var t,r=!1,i=this._changing?this._previousAttributes:this.attributes;for(var o in e)n.isEqual(i[o],t=e[o])||((r||(r={}))[o]=t);return r},previous:function(e){return null!=e&&this._previousAttributes?this._previousAttributes[e]:null},previousAttributes:function(){return n.clone(this._previousAttributes)},fetch:function(e){e=e?n.clone(e):{},void 0===e.parse&&(e.parse=!0);var t=this,r=e.success;return e.success=function(n){return t.set(t.parse(n,e),e)?(r&&r(t,n,e),void t.trigger("sync",t,n,e)):!1},j(this,e),this.sync("read",this,e)},save:function(e,t,r){var i,o,s,a=this.attributes;if(null==e||"object"==typeof e?(i=e,r=t):(i={})[e]=t,r=n.extend({validate:!0},r),i&&!r.wait){if(!this.set(i,r))return!1}else if(!this._validate(i,r))return!1;i&&r.wait&&(this.attributes=n.extend({},a,i)),void 0===r.parse&&(r.parse=!0);var u=this,l=r.success;return r.success=function(e){u.attributes=a;var t=u.parse(e,r);return r.wait&&(t=n.extend(i||{},t)),n.isObject(t)&&!u.set(t,r)?!1:(l&&l(u,e,r),void u.trigger("sync",u,e,r))},j(this,r),o=this.isNew()?"create":r.patch?"patch":"update","patch"===o&&(r.attrs=i),s=this.sync(o,this,r),i&&r.wait&&(this.attributes=a),s},destroy:function(e){e=e?n.clone(e):{};var t=this,r=e.success,i=function(){t.trigger("destroy",t,t.collection,e)};if(e.success=function(n){(e.wait||t.isNew())&&i(),r&&r(t,n,e),t.isNew()||t.trigger("sync",t,n,e)},this.isNew())return e.success(),!1;j(this,e);var o=this.sync("delete",this,e);return e.wait||i(),o},url:function(){var e=n.result(this,"urlRoot")||n.result(this.collection,"url")||F();return this.isNew()?e:e.replace(/([^\/])$/,"$1/")+encodeURIComponent(this.id)},parse:function(e){return e},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return!this.has(this.idAttribute)},isValid:function(e){return this._validate({},n.extend(e||{},{validate:!0}))},_validate:function(e,t){if(!t.validate||!this.validate)return!0;e=n.extend({},this.attributes,e);var r=this.validationError=this.validate(e,t)||null;return r?(this.trigger("invalid",this,r,n.extend(t,{validationError:r})),!1):!0}});var f=["keys","values","pairs","invert","pick","omit"];n.each(f,function(e){p.prototype[e]=function(){var t=s.call(arguments);return t.unshift(this.attributes),n[e].apply(n,t)}});var h=t.Collection=function(e,t){t||(t={}),t.model&&(this.model=t.model),void 0!==t.comparator&&(this.comparator=t.comparator),this._reset(),this.initialize.apply(this,arguments),e&&this.reset(e,n.extend({silent:!0},t))},m={add:!0,remove:!0,merge:!0},v={add:!0,remove:!1};n.extend(h.prototype,a,{model:p,initialize:function(){},toJSON:function(e){return this.map(function(t){return t.toJSON(e)})},sync:function(){return t.sync.apply(this,arguments)},add:function(e,t){return this.set(e,n.extend({merge:!1},t,v))},remove:function(e,t){var r=!n.isArray(e);e=r?[e]:n.clone(e),t||(t={});var i,o,s,a;for(i=0,o=e.length;o>i;i++)a=e[i]=this.get(e[i]),a&&(delete this._byId[a.id],delete this._byId[a.cid],s=this.indexOf(a),this.models.splice(s,1),this.length--,t.silent||(t.index=s,a.trigger("remove",a,this,t)),this._removeReference(a,t));return r?e[0]:e},set:function(e,t){t=n.defaults({},t,m),t.parse&&(e=this.parse(e,t));var r=!n.isArray(e);e=r?e?[e]:[]:n.clone(e);var i,o,s,a,u,l,c,d=t.at,f=this.model,h=this.comparator&&null==d&&t.sort!==!1,v=n.isString(this.comparator)?this.comparator:null,b=[],g=[],y={},_=t.add,w=t.merge,x=t.remove,k=!h&&_&&x?[]:!1;for(i=0,o=e.length;o>i;i++){if(u=e[i]||{},s=u instanceof p?a=u:u[f.prototype.idAttribute||"id"],l=this.get(s))x&&(y[l.cid]=!0),w&&(u=u===a?a.attributes:u,t.parse&&(u=l.parse(u,t)),l.set(u,t),h&&!c&&l.hasChanged(v)&&(c=!0)),e[i]=l;else if(_){if(a=e[i]=this._prepareModel(u,t),!a)continue;b.push(a),this._addReference(a,t)}a=l||a,!k||!a.isNew()&&y[a.id]||k.push(a),y[a.id]=!0}if(x){for(i=0,o=this.length;o>i;++i)y[(a=this.models[i]).cid]||g.push(a);g.length&&this.remove(g,t)}if(b.length||k&&k.length)if(h&&(c=!0),this.length+=b.length,null!=d)for(i=0,o=b.length;o>i;i++)this.models.splice(d+i,0,b[i]);else{k&&(this.models.length=0);var E=k||b;for(i=0,o=E.length;o>i;i++)this.models.push(E[i])}if(c&&this.sort({silent:!0}),!t.silent){for(i=0,o=b.length;o>i;i++)(a=b[i]).trigger("add",a,this,t);(c||k&&k.length)&&this.trigger("sort",this,t)}return r?e[0]:e},reset:function(e,t){t||(t={});for(var r=0,i=this.models.length;i>r;r++)this._removeReference(this.models[r],t);return t.previousModels=this.models,this._reset(),e=this.add(e,n.extend({silent:!0},t)),t.silent||this.trigger("reset",this,t),e},push:function(e,t){return this.add(e,n.extend({at:this.length},t))},pop:function(e){var t=this.at(this.length-1);return this.remove(t,e),t},unshift:function(e,t){return this.add(e,n.extend({at:0},t))},shift:function(e){var t=this.at(0);return this.remove(t,e),t},slice:function(){return s.apply(this.models,arguments)},get:function(e){return null==e?void 0:this._byId[e]||this._byId[e.id]||this._byId[e.cid]},at:function(e){return this.models[e]},where:function(e,t){return n.isEmpty(e)?t?void 0:[]:this[t?"find":"filter"](function(t){for(var n in e)if(e[n]!==t.get(n))return!1;return!0})},findWhere:function(e){return this.where(e,!0)},sort:function(e){if(!this.comparator)throw new Error("Cannot sort a set without a comparator");return e||(e={}),n.isString(this.comparator)||1===this.comparator.length?this.models=this.sortBy(this.comparator,this):this.models.sort(n.bind(this.comparator,this)),e.silent||this.trigger("sort",this,e),this},pluck:function(e){return n.invoke(this.models,"get",e)},fetch:function(e){e=e?n.clone(e):{},void 0===e.parse&&(e.parse=!0);var t=e.success,r=this;return e.success=function(n){var i=e.reset?"reset":"set";r[i](n,e),t&&t(r,n,e),r.trigger("sync",r,n,e)},j(this,e),this.sync("read",this,e)},create:function(e,t){if(t=t?n.clone(t):{},!(e=this._prepareModel(e,t)))return!1;t.wait||this.add(e,t);var r=this,i=t.success;return t.success=function(e,n){t.wait&&r.add(e,t),i&&i(e,n,t)},e.save(null,t),e},parse:function(e){return e},clone:function(){return new this.constructor(this.models)},_reset:function(){this.length=0,this.models=[],this._byId={}},_prepareModel:function(e,t){if(e instanceof p)return e;t=t?n.clone(t):{},t.collection=this;var r=new this.model(e,t);return r.validationError?(this.trigger("invalid",this,r.validationError,t),!1):r},_addReference:function(e){this._byId[e.cid]=e,null!=e.id&&(this._byId[e.id]=e),e.collection||(e.collection=this),e.on("all",this._onModelEvent,this)},_removeReference:function(e){this===e.collection&&delete e.collection,e.off("all",this._onModelEvent,this)},_onModelEvent:function(e,t,n,r){("add"!==e&&"remove"!==e||n===this)&&("destroy"===e&&this.remove(t,r),t&&e==="change:"+t.idAttribute&&(delete this._byId[t.previous(t.idAttribute)],null!=t.id&&(this._byId[t.id]=t)),this.trigger.apply(this,arguments))}});var b=["forEach","each","map","collect","reduce","foldl","inject","reduceRight","foldr","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","toArray","size","first","head","take","initial","rest","tail","drop","last","without","difference","indexOf","shuffle","lastIndexOf","isEmpty","chain","sample"];n.each(b,function(e){h.prototype[e]=function(){var t=s.call(arguments);return t.unshift(this.models),n[e].apply(n,t)}});var g=["groupBy","countBy","sortBy","indexBy"];n.each(g,function(e){h.prototype[e]=function(t,r){var i=n.isFunction(t)?t:function(e){return e.get(t)};return n[e](this.models,i,r)}});var y=t.View=function(e){this.cid=n.uniqueId("view"),e||(e={}),n.extend(this,n.pick(e,w)),this._ensureElement(),this.initialize.apply(this,arguments),this.delegateEvents()},_=/^(\S+)\s*(.*)$/,w=["model","collection","el","id","attributes","className","tagName","events"];n.extend(y.prototype,a,{tagName:"div",$:function(e){return this.$el.find(e)},initialize:function(){},render:function(){return this},remove:function(){return this.$el.remove(),this.stopListening(),this},setElement:function(e,n){return this.$el&&this.undelegateEvents(),this.$el=e instanceof t.$?e:t.$(e),this.el=this.$el[0],n!==!1&&this.delegateEvents(),this},delegateEvents:function(e){if(!e&&!(e=n.result(this,"events")))return this;this.undelegateEvents();for(var t in e){var r=e[t];if(n.isFunction(r)||(r=this[e[t]]),r){var i=t.match(_),o=i[1],s=i[2];r=n.bind(r,this),o+=".delegateEvents"+this.cid,""===s?this.$el.on(o,r):this.$el.on(o,s,r)}}return this},undelegateEvents:function(){return this.$el.off(".delegateEvents"+this.cid),this},_ensureElement:function(){if(this.el)this.setElement(n.result(this,"el"),!1);else{var e=n.extend({},n.result(this,"attributes"));this.id&&(e.id=n.result(this,"id")),this.className&&(e["class"]=n.result(this,"className"));var r=t.$("<"+n.result(this,"tagName")+">").attr(e);this.setElement(r,!1)}}}),t.sync=function(e,r,i){var o=k[e];n.defaults(i||(i={}),{emulateHTTP:t.emulateHTTP,emulateJSON:t.emulateJSON});var s={type:o,dataType:"json"};if(i.url||(s.url=n.result(r,"url")||F()),null!=i.data||!r||"create"!==e&&"update"!==e&&"patch"!==e||(s.contentType="application/json",s.data=JSON.stringify(i.attrs||r.toJSON(i))),i.emulateJSON&&(s.contentType="application/x-www-form-urlencoded",s.data=s.data?{model:s.data}:{}),i.emulateHTTP&&("PUT"===o||"DELETE"===o||"PATCH"===o)){s.type="POST",i.emulateJSON&&(s.data._method=o);var a=i.beforeSend;i.beforeSend=function(e){return e.setRequestHeader("X-HTTP-Method-Override",o),a?a.apply(this,arguments):void 0}}"GET"===s.type||i.emulateJSON||(s.processData=!1),"PATCH"===s.type&&x&&(s.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")});var u=i.xhr=t.ajax(n.extend(s,i));return r.trigger("request",r,u,i),u};var x=!("undefined"==typeof window||!window.ActiveXObject||window.XMLHttpRequest&&(new XMLHttpRequest).dispatchEvent),k={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};t.ajax=function(){return t.$.ajax.apply(t.$,arguments)};var E=t.Router=function(e){e||(e={}),e.routes&&(this.routes=e.routes),this._bindRoutes(),this.initialize.apply(this,arguments)},O=/\((.*?)\)/g,C=/(\(\?)?:\w+/g,S=/\*\w+/g,T=/[\-{}\[\]+?.,\\\^$|#\s]/g;n.extend(E.prototype,a,{initialize:function(){},route:function(e,r,i){n.isRegExp(e)||(e=this._routeToRegExp(e)),n.isFunction(r)&&(i=r,r=""),i||(i=this[r]);var o=this;return t.history.route(e,function(n){var s=o._extractParameters(e,n);o.execute(i,s),o.trigger.apply(o,["route:"+r].concat(s)),o.trigger("route",r,s),t.history.trigger("route",o,r,s)}),this},execute:function(e,t){e&&e.apply(this,t)},navigate:function(e,n){return t.history.navigate(e,n),this},_bindRoutes:function(){if(this.routes){this.routes=n.result(this,"routes");for(var e,t=n.keys(this.routes);null!=(e=t.pop());)this.route(e,this.routes[e])}},_routeToRegExp:function(e){return e=e.replace(T,"\\$&").replace(O,"(?:$1)?").replace(C,function(e,t){return t?e:"([^/?]+)"}).replace(S,"([^?]*?)"),new RegExp("^"+e+"(?:\\?([\\s\\S]*))?$")},_extractParameters:function(e,t){var r=e.exec(t).slice(1);return n.map(r,function(e,t){return t===r.length-1?e||null:e?decodeURIComponent(e):null})}});var N=t.History=function(){this.handlers=[],n.bindAll(this,"checkUrl"),"undefined"!=typeof window&&(this.location=window.location,this.history=window.history)},D=/^[#\/]|\s+$/g,M=/^\/+|\/+$/g,A=/msie [\w.]+/,R=/\/$/,P=/#.*$/;N.started=!1,n.extend(N.prototype,a,{interval:50,atRoot:function(){return this.location.pathname.replace(/[^\/]$/,"$&/")===this.root},getHash:function(e){var t=(e||this).location.href.match(/#(.*)$/);return t?t[1]:""},getFragment:function(e,t){if(null==e)if(this._hasPushState||!this._wantsHashChange||t){e=decodeURI(this.location.pathname+this.location.search);var n=this.root.replace(R,"");e.indexOf(n)||(e=e.slice(n.length))}else e=this.getHash();return e.replace(D,"")},start:function(e){if(N.started)throw new Error("Backbone.history has already been started");N.started=!0,this.options=n.extend({root:"/"},this.options,e),this.root=this.options.root,this._wantsHashChange=this.options.hashChange!==!1,this._wantsPushState=!!this.options.pushState,this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var r=this.getFragment(),i=document.documentMode,o=A.exec(navigator.userAgent.toLowerCase())&&(!i||7>=i);if(this.root=("/"+this.root+"/").replace(M,"/"),o&&this._wantsHashChange){var s=t.$('