/* knockback.js 0.20.3 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("knockout"),require("backbone"),require("underscore"),function(){try{return require("jquery")}catch(e){}}()):"function"==typeof define&&define.amd?define(["knockout","backbone","underscore"],function(r,n,o){return t(r,n,o,e.jQuery)}):"object"==typeof exports?exports.kb=t(require("knockout"),require("backbone"),require("underscore"),function(){try{return require("jquery")}catch(e){}}()):e.kb=t(e.ko,e.Backbone,e._,e.jQuery)}(this,function(e,t,r,n){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){r(1),r(2),r(3),r(4),r(5),r(6),r(7),r(8),r(9),r(10),r(11),r(12),r(13),r(15),r(16),r(17),r(18),r(19),e.exports=r(14)},function(e,t,r){var n,o,i,s,a,l,u,c,d=function(e,t){return function(){return e.apply(t,arguments)}},p=[].indexOf||function(e){for(var t=0,r=this.length;r>t;t++)if(t in this&&this[t]===e)return t;return-1};c=a=r(6),u=c._,l=c.ko,i=0,n=-1,o=1,s=["destroy","shareOptions","filters","comparator","sortAttribute","viewModelByModel","hasViewModels"],a.compare=function(e,t){return u.isString(e)?e.localeCompare(""+t):u.isString(t)?t.localeCompare(""+e):e===t?i:t>e?n:o},a.CollectionObservable=function(){function e(e,t,r){this._onCollectionChange=d(this._onCollectionChange,this);var n;return n=Array.prototype.slice.call(u.isArguments(e)?e:arguments),a.ignore(function(t){return function(){var o,i,c,d,p;for(e=n[0]instanceof a.Collection?n.shift():u.isArray(n[0])?new a.Collection(n.shift()):new a.Collection,u.isFunction(n[0])&&(n[0]={view_model:n[0]}),r={},d=0,p=n.length;p>d;d++)o=n[d],u.extend(r,o);return c=a.utils.wrappedObservable(t,l.observableArray([])),c.__kb_is_co=!0,t.in_edit=0,t.__kb||(t.__kb={}),r=a.utils.collapseOptions(r),r.auto_compact&&(t.auto_compact=!0),t._comparator=l.observable(r.sort_attribute?t._attributeComparator(r.sort_attribute):r.comparator),t._filters=l.observableArray(r.filters?u.isArray(r.filters)?r.filters:r.filters?[r.filters]:void 0:[]),i=t.create_options={store:a.Store.useOptionsOrCreate(r,e,c)},a.utils.wrappedObject(c,e),t.path=r.path,i.factory=a.utils.wrappedFactory(c,t._shareOrCreateFactory(r)),i.path=a.utils.pathJoin(r.path,"models"),i.creator=i.factory.creatorForPath(null,i.path),i.creator&&(t.models_only=i.creator.models_only),a.publishMethods(c,t,s),t._collection=l.observable(e),c.collection=t.collection=l.computed({read:function(){return t._collection()},write:function(e){return a.ignore(function(){var r;if((r=t._collection())!==e)return a.utils.wrappedObject(c,e),r&&r.unbind("all",t._onCollectionChange),e&&e.bind("all",t._onCollectionChange),t._collection(e)})}}),e&&e.bind("all",t._onCollectionChange),t._mapper=l.computed(function(){var e,r,n,o,i,s,d,p,f;if(e=t._comparator(),o=t._filters())for(p=0,f=o.length;f>p;p++)n=o[p],l.utils.unwrapObservable(n);r=t._collection(),t.in_edit||(c=a.utils.wrappedObservable(t),s=a.peek(c),r&&(i=r.models),i&&0!==r.models.length?(i=u.filter(i,function(e){return!o.length||t._selectModel(e)}),d=e?u.map(i,function(e){return t._createViewModel(e)}).sort(e):t.models_only?o.length?i:i.slice():u.map(i,function(e){return t._createViewModel(e)})):d=[],t.in_edit++,c(d),t.in_edit--)}),c.subscribe(u.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,r;return this.__kb_released=!0,r=a.utils.wrappedObservable(this),t=a.peek(this._collection),a.utils.wrappedObject(r,null),t&&(t.unbind("all",this._onCollectionChange),e=a.peek(r),e.splice(0,e.length)),this.collection.dispose(),this._collection=r.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,r.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?u.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",u.find(a.peek(a.utils.wrappedObservable(this)),function(r){var n;return(null!=r&&null!=(n=r.__kb)?n.object:void 0)?r.__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,r,n,o;if(t=a.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 a.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,a.ViewModel):e.view_model?o.addPathMapping(t,e.view_model):e.create?o.addPathMapping(t,{create:e.create}):o.addPathMapping(t,a.ViewModel)),o},e.prototype._onCollectionChange=function(e,t){return a.ignore(function(r){return function(){var n,o,i,s;if(!r.in_edit)switch(e){case"reset":r.auto_compact?r.compact():r._collection.notifySubscribers(r._collection());break;case"sort":case"resort":r._collection.notifySubscribers(r._collection());break;case"new":case"add":if(!r._selectModel(t))return;if(i=a.utils.wrappedObservable(r),n=r._collection(),-1===n.indexOf(t))return;if(s=r.viewModelByModel(t))return;r.in_edit++,(o=r._comparator())?(i().push(r._createViewModel(t)),i.sort(o)):i.splice(n.indexOf(t),0,r._createViewModel(t)),r.in_edit--;break;case"remove":case"destroy":r._onModelRemove(t);break;case"change":if(!r._selectModel(t))return r._onModelRemove(t);if(s=r.models_only?t:r.viewModelByModel(t),!s)return r._onCollectionChange("add",t);if(!(o=r._comparator()))return;r.in_edit++,a.utils.wrappedObservable(r).sort(o),r.in_edit--}}}(this))},e.prototype._onModelRemove=function(e){var t,r;return(r=this.models_only?e:this.viewModelByModel(e))?(t=a.utils.wrappedObservable(this),this.in_edit++,t.remove(r),this.in_edit--):void 0},e.prototype._onObservableArrayChange=function(e){return a.ignore(function(t){return function(){var r,n,o,i,s,l,c,d,p,f;if(!t.in_edit&&(t.models_only&&(!e.length||a.isModel(e[0]))||!t.models_only&&(!e.length||u.isObject(e[0])&&!a.isModel(e[0]))||a._throwUnexpected(t,"incorrect type passed"),l=a.utils.wrappedObservable(t),r=a.peek(t._collection),o=a.peek(t._filters).length,r)){if(d=e,t.models_only)s=u.filter(e,function(e){return!o||t._selectModel(e)});else for(!o||(d=[]),s=[],p=0,f=e.length;f>p;p++){if(c=e[p],i=a.utils.wrappedObject(c),o){if(!t._selectModel(i))continue;d.push(c)}(n=t.create_options.store.find(i,t.create_options.creator))&&(n.constructor===c.constructor||a._throwUnexpected(t,"replacing different type of view model")),t.create_options.store.retain(c,i,t.create_options.creator),s.push(i)}t.in_edit++,e.length===d.length||l(d),u.isEqual(r.models,s)||r.reset(s),t.in_edit--}}}(this))},e.prototype._attributeComparator=function(e){var t;return t=function(t,r){var n;return n=l.utils.unwrapObservable(e),a.compare(t.get(n),r.get(n))},this.models_only?t:function(e,r){return t(a.utils.wrappedModel(e),a.utils.wrappedModel(r))}},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,r,n,o,i;for(r=a.peek(this._filters),n=0,o=r.length;o>n;n++)if(t=r[n],t=a.peek(t),u.isFunction(t)){if(!t(e))return!1}else if(u.isArray(t)){if(i=e.id,p.call(t,i)<0)return!1}else if(e.id!==t)return!1;return!0},e}(),a.collectionObservable=function(){return new a.CollectionObservable(arguments)}},function(e,t,r){var n,o,i,s,a,l,u;u=o=r(6),l=u._,s=u.ko,n={"default":null,"backbone-orm":null,"backbone-associations":r(26),"backbone-relational":r(27),supermodel:r(28)},o.orm=n["default"];for(i in n)if(a=n[i],a&&a.isAvailable()){o.orm=a;break}e.exports=function(e){var t;null==e&&(e={});for(i in e)switch(a=e[i],i){case"orm":if(l.isString(a)){if(!n.hasOwnProperty(a)){console.log("Knockback configure: could not find orm: "+a+". Available: "+l.keys(n).join(", "));continue}if((t=n[a])&&!t.isAvailable()){console.log("Knockback configure: could not enable orm "+a+". Make sure it is included before Knockback");continue}o.orm=t;continue}o.orm=a;break;default:o[i]=a}}},function(e,t,r){var n,o,i,s,a=function(e,t){return function(){return e.apply(t,arguments)}};s=n=r(6),i=s._,o=s.ko,n.EventWatcher=function(){function e(e,t,r){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,r&&this.registerCallbacks(t,r),e&&this.emitter(e)}return e.useOptionsOrCreate=function(e,t,r,o){return e.event_watcher?(e.event_watcher.emitter()!==t&&e.event_watcher.model_ref!==t&&n._throwUnexpected(this,"emitter not matching"),n.utils.wrappedEventWatcher(r,e.event_watcher).registerCallbacks(r,o)):(n.utils.wrappedEventWatcherIsOwned(r,!0),n.utils.wrappedEventWatcher(r,new n.EventWatcher(t)).registerCallbacks(r,o))},e.prototype.destroy=function(){return this.emitter(null),this.__kb.callbacks=null,n.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),n.Backbone&&n.Backbone.ModelRef&&e instanceof n.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 r,s,a,l,u,c;for(e||n._throwMissing(this,"obj"),t||n._throwMissing(this,"callback_info"),s=t.event_selector?t.event_selector.split(" "):["change"],a=this.ee,l=function(r){return function(s){var l,u;return(l=r.__kb.callbacks[s])||(l=r.__kb.callbacks[s]={model:null,list:[],fn:function(e){var t,r,i,a;for(a=l.list,r=0,i=a.length;i>r;r++)t=a[r],t.update&&(e&&t.key&&e.hasChanged&&!e.hasChanged(o.utils.unwrapObservable(t.key))||(!n.statistics||n.statistics.addModelEvent({name:s,model:e,key:t.key,path:t.path}),t.update()));return null}}),l.list.push(u=i.defaults({obj:e},t)),a?r._onModelLoaded(a):void 0}}(this),u=0,c=s.length;c>u;u++)r=s[u],r&&l(r);return this},e.prototype.releaseCallbacks=function(e){var t,r,o;this.ee=null,o=this.__kb.callbacks;for(r in o)t=o[r],this._unbindCallbacks(r,t,n.wasReleased(e));return delete this.__kb.callbacks},e.prototype._onModelLoaded=function(e){var t,r,o,i,s,a,l,u;this.ee=e,a=this.__kb.callbacks;for(r in a)for(t=a[r],t.model&&t.model!==e&&this._unbindCallbacks(r,t,!0),t.model||(t.model=e,e.bind(r,t.fn)),l=t.list,i=0,s=l.length;s>i;i++)o=l[i],o.unbind_fn||(o.unbind_fn=null!=(u=n.orm)?u.bind(e,o.key,o.update,o.path):void 0),o.emitter&&o.emitter(e)},e.prototype._onModelUnloaded=function(e){var t,r,n;if(this.ee===e){this.ee=null,n=this.__kb.callbacks;for(r in n)t=n[r],this._unbindCallbacks(r,t)}},e.prototype._unbindCallbacks=function(e,t,r){var o,i,s,a;for(t.model&&(t.model.unbind(e,t.fn),t.model=null),a=t.list,i=0,s=a.length;s>i;i++)o=a[i],o.unbind_fn&&(o.unbind_fn(),o.unbind_fn=null),!o.emitter||r||n.wasReleased(o.obj)||o.emitter(null)},e}(),n.emitterObservable=function(e,t){return new n.EventWatcher(e,t)}},function(e,t,r){var n,o;o=(n=r(6))._,n.Factory=function(){function e(e){this.paths={},e&&(this.parent_factory=e)}return e.useOptionsOrCreate=function(e,t,r){var o;return e.factory&&(!e.factories||e.factories&&e.factory.hasPathMappings(e.factories,r))?n.utils.wrappedFactory(t,e.factory):(o=n.utils.wrappedFactory(t,new n.Factory(e.factory)),e.factories&&o.addPathMappings(e.factories,r),o)},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 r,o;for(o in e)r=e[o],this.paths[n.utils.pathJoin(t,o)]=r},e.prototype.hasPathMappings=function(e,t){var r,o,i,s;r=!0;for(s in e)o=e[s],r&=(i=this.creatorForPath(null,n.utils.pathJoin(t,s)))&&o===i;return r},e.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},e}()},function(e,t,r){(function(e){var t,n,o,i,s,a,l,u;s=null!=s?s:e,u=n=r(6),a=u._,o=u.ko,t=u.$,n.RECUSIVE_AUTO_INJECT=!0,o.bindingHandlers.inject={init:function(e,t,r,i){return n.Inject.inject(o.utils.unwrapObservable(t()),i,e,t,r)}},n.Inject=function(){function e(){}return e.inject=function(e,t,r,o,i,s){var l;return l=function(e){var l,u,c;if(a.isFunction(e))t=new e(t,r,o,i),n.releaseOnNodeRemove(t,r);else{e.view_model&&(t=new e.view_model(t,r,o,i),n.releaseOnNodeRemove(t,r));for(l in e)c=e[l],"view_model"!==l&&("create"===l?c(t,r,o,i):a.isObject(c)&&!a.isFunction(c)?(u=s||c&&c.create?{}:t,t[l]=n.Inject.inject(c,u,r,o,i,!0)):t[l]=c)}return t},s?l(e):n.ignore(function(){return l(e)})},e.injectViewModels=function(e){var t,r,o,i,l,u,c,d,p,f;for(d=[],u=function(e){var t,r,n,o,i;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})),i=e.childNodes,n=0,o=i.length;o>n;n++)r=i[n],u(r)},!e&&(null!=s?s.document:void 0)&&(e=s.document),u(e),p=0,f=d.length;f>p;p++)r=d[p],(l=r.binding)&&(l.search(/[:]/)<0||(l="{"+l+"}"),i=new Function("","return ( "+l+" )")(),i||(i={}),!i.options||(c=i.options,delete i.options),c||(c={}),r.view_model=n.Inject.inject(i,r.view_model,r.el,null,null,!0),t=r.view_model.afterBinding||c.afterBinding,o=r.view_model.beforeBinding||c.beforeBinding),o&&o.call(r.view_model,r.view_model,r.el,c),n.applyBindings(r.view_model,r.el,c),t&&t.call(r.view_model,r.view_model,r.el,c);return d},e}(),l=o.applyBindings,o.applyBindings=function(e,t){var r;return r=n.RECUSIVE_AUTO_INJECT?n.injectViewModels(t):[],r.length?void 0:l.apply(this,arguments)},n.injectViewModels=n.Inject.injectViewModels,"undefined"!=typeof document&&null!==document&&(t?t(function(){return n.injectViewModels()}):(i=function(){return"complete"!==document.readyState?setTimeout(i,0):n.injectViewModels()})())}).call(t,function(){return this}())},function(e,t,r){(function(t){var n,o,i,s,a,l;a=null!=a?a:t,s=r(20),o=["release","destroy","dispose"],e.exports=i=function(){function e(){}var t;return e.VERSION="0.20.3",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,r){var n,i,a,l,u;if(null==r&&(r=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(l=0,u=o.length;u>l;l++)if(i=o[l],"function"==typeof t[i])return!0;if(r>0)return!1;for(n in t)if(a=t[n],"__kb"!==n&&e.isReleaseable(a,r+1))return!0;return!1},e.release=function(t){var r,n,i,a,u,c;if(e.isReleaseable(t)){if(t.__kb_released=!0,!l.isArray(t)){if(s.isObservable(t)&&l.isArray(r=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(n in r)a=r[n],e.isReleaseable(a)&&(r[n]=null,e.release(a));return void("function"==typeof t.dispose&&t.dispose())}for(u=0,c=o.length;c>u;u++)if(i=o[u],"function"==typeof t[i])return t[i].call(t);return s.isObservable(t)?void 0:this.releaseKeys(t)}for(n in t)a=t[n],e.isReleaseable(a)&&(t[n]=null,e.release(a))}},e.releaseKeys=function(t){var r,n;for(r in t)n=t[r],"__kb"!==r&&e.isReleaseable(n)&&(t[r]=null,e.release(n))},e.releaseOnNodeRemove=function(t,r){return t||e._throwUnexpected(this,"missing view model"),r||e._throwUnexpected(this,"missing node"),s.utils.domNodeDisposal.addDisposeCallback(r,function(){return e.release(t)})},e.renderTemplate=function(t,r,n){var o,i,l;return null==n&&(n={}),(o=null!=a?a.document:void 0)?(i=o.createElement("div"),l=s.renderTemplate(t,r,n,i,"replaceChildren"),1===i.childNodes.length?i=i.childNodes[0]:i.childNodes.length&&s.storedBindingContextForNode(i,s.contextFor(i.childNodes[0])),e.releaseOnNodeRemove(r,i),l.dispose(),r.afterRender&&!n.afterRender&&r.afterRender(i),i):"undefined"!=typeof console&&null!==console?console.log("renderTemplate: document is undefined"):void 0},e.applyBindings=function(t,r){var n,o,i,a,l;if(r.length)for(l=[document.createElement("div"),r],r=l[0],o=l[1],i=0,a=o.length;a>i;i++)n=o[i],r.appendChild(n);return s.applyBindings(t,r),e.releaseOnNodeRemove(t,r),r},e.getValue=function(t,r,n){var o;if(t)return l.isFunction(t[r])&&(null!=(o=e.orm)?o.useFunction(t,r):void 0)?t[r]():n?t.get.apply(t,l.map([r].concat(n),function(t){return e.peek(t)})):t.get(r)},e.setValue=function(t,r,n){var o,i;if(t)return l.isFunction(t[r])&&(null!=(i=e.orm)?i.useFunction(t,r):void 0)?t[r](n):((o={})[r]=n,t.set(o))},e.ignore=(null!=(t=s.dependencyDetection)?t.ignore:void 0)||function(e,t,r){var n;return n=null,s.computed(function(){return n=e.apply(t,r||[])}).dispose(),n},e.extend=r(29),e._throwMissing=function(e,t){throw""+(l.isString(e)?e:e.constructor.name)+": "+t+" is missing"},e._throwUnexpected=function(e,t){throw""+(l.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"},e.publishMethods=function(t,r,n){var o,i,s;for(i=0,s=n.length;s>i;i++)o=n[i],t[o]=e._.bind(r[o],r)},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?(n=i.Parse=a.Parse,l=i._=a.Parse._):(n=i.Backbone=r(21),l=i._=r(22)),i.ko=s,i.Collection=n.Collection,i.Model=n.Object||n.Model,i.Events=n.Events,i.$=a.jQuery||a.$;try{i.$||(i.$=r(23))}catch(u){}}).call(t,function(){return this}())},function(e,t,r){var n,o,i,s,a;o=(n=r(6)).ko,(null!=(s=o.subscribable)&&null!=(a=s.fn)?a.extend:void 0)&&(i=o.subscribable.fn.extend,o.subscribable.fn.extend=function(){var e,t;return e=i.apply(this,arguments),e!==this&&n.isReleaseable(this)&&(t=e.dispose,e.dispose=function(r){return function(){return null!=t&&t.apply(e,arguments),n.release(r)}}(this)),e})},function(e,t,r){var n,o,i,s,a,l,u;u=s=r(6),l=u._,a=u.ko,i=r(11),o=["value","valueType","destroy"],n=["args","read","write"],s.Observable=function(){function e(e,t,r,u){return this._vm=null!=u?u:{},s.ignore(function(u){return function(){var c,d,p,f,_,h;for(t||s._throwMissing(u,"key_or_info"),u.key=t.key||t,_=0,h=n.length;h>_;_++)p=n[_],t[p]&&(u[p]=t[p]);return c=s.utils.collapseOptions(r),d=c.event_watcher,delete c.event_watcher,u._value=new i(c),u._model=a.observable(),f=s.utils.wrappedObservable(u,a.computed({read:function(){var e,t,r,n,o,i,c;for(o=u._model(),i=t=[u.key].concat(u.args||[]),r=0,n=i.length;n>r;r++)e=i[r],a.utils.unwrapObservable(e);return null!=(c=s.utils.wrappedEventWatcher(u))&&c.emitter(o||null),u.read?u.update(u.read.apply(u._vm,t)):l.isUndefined(o)||s.ignore(function(){return u.update(s.getValue(o,s.peek(u.key),u.args))}),u._value.value()},write:function(e){return s.ignore(function(){var t,r;return t=s.utils.unwrapModels(e),r=s.peek(u._model),u.write?(u.write.call(u._vm,t),e=s.getValue(r,s.peek(u.key),u.args)):r&&s.setValue(r,s.peek(u.key),t),u.update(e)})},owner:u._vm})),f.__kb_is_o=!0,c.store=s.utils.wrappedStore(f,c.store),c.path=s.utils.pathJoin(c.path,u.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,u,o),f.model=u.model=a.computed({read:function(){return a.utils.unwrapObservable(u._model)},write:function(e){return s.ignore(function(){var t;if(!u.__kb_released&&s.peek(u._model)!==e)return t=s.getValue(e,s.peek(u.key),u.args),u._model(e),e?l.isUndefined(t)?void 0:u.update(t):u.update(null)})}}),s.EventWatcher.useOptionsOrCreate({event_watcher:d},e||null,u,{emitter:u.model,update:function(){return s.ignore(function(){return u.update()})},key:u.key,path:c.path}),u._value.rawValue()||u._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,r,n){return new s.Observable(e,t,r,n)}},function(e,t,r){var n,o;o=(n=r(6))._,e.exports=n.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,r,n;r="",r+="Total Count: "+this.model_events_tracker.length,e=o.groupBy(this.model_events_tracker,function(e){return"event name: '"+e.name+"', attribute name: '"+e.key+"'"});for(t in e)n=e[t],r+="\n "+t+", count: "+n.length;return r},e.prototype.register=function(e,t){return this.registeredTracker(e).push(t)},e.prototype.unregister=function(e,t){var r,n;return n=this.registeredTracker(e),(r=o.indexOf(n,t))<0?"undefined"!=typeof console&&null!==console?console.log("kb.Statistics: failed to unregister type: "+e):void 0:n.splice(r,1)},e.prototype.registeredCount=function(e){var t,r,n;if(e)return this.registeredTracker(e).length;t=0,n=this.registered_tracker[e];for(e in n)r=n[e],t+=r.length;return t},e.prototype.registeredStatsString=function(e){var t,r,n,o,i;t="",i=this.registered_tracker;for(r in i)n=i[r],n.length&&(o&&(t+="\n "),t+=""+(r?r:"No Name")+": "+n.length,o=!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 r,n,i,s,a,l,u;for(i={count:0},r=e._events||e._callbacks||{},u=t?[t]:o.keys(r),a=0,l=u.length;l>a;a++)if(t=u[a],n=r[t]){if(o.isArray(n))i[t]=o.compact(n).length;else for(i[t]=0,s=n.tail;(n=n.next)!==s;)i[t]++;i.count+=i[t]}return i},e}()},function(e,t,r){var n,o,i,s;s=n=r(6),i=s._,o=s.ko,e.exports=n.Store=function(){function e(){this.observable_records={},this.replaced_observables=[],n.Store.instances.push(this)}return e.instances=[],e.useOptionsOrCreate=function(e,t,r){var o;return e.store||n.utils.wrappedStoreIsOwned(r,!0),o=n.utils.wrappedStore(r,e.store||new n.Store),o.retain(r,t,e.creator),o},e.prototype.destroy=function(){var e;return this.__kb_released=!0,this.clear(),(e=i.indexOf(n.Store.instances,this))>=0?n.Store.instances.splice(e,1):void 0},e.prototype.clear=function(){var e,t,r,n,o,i,s,a,l,u;l=[this.observable_records,{}],n=l[0],this.observable_records=l[1];for(t in n){o=n[t];for(e in o)r=o[e],this.release(r,!0)}for(u=[this.replaced_observables,[]],i=u[0],this.replaced_observables=u[1],s=0,a=i.length;a>s;s++)r=i[s],r.__kb_released||this.release(r,!0)},e.prototype.compact=function(){var e,t,r,n,o;o=this.observable_records;for(t in o){n=o[t];for(e in n)r=n[e],r.__kb_released&&delete n[e]}},e.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}},e.prototype.retainOrCreate=function(e,t){var r,s;if(!(r=this._creator(e,t)))return n.utils.createFromDefaultCreator(e,t);if(r.models_only)return e;if(s=this.find(e,r))return s;if(!i.isFunction(r.create||r))throw new Error('Invalid factory for "'+t.path+'"');return s=n.ignore(function(n){return function(){return t=i.defaults({store:n,creator:r},t),s=r.create?r.create(e,t):new r(e,t),s||o.observable(null)}}(this)),this.retain(s,e,r),s},e.prototype.reuse=function(e,t){var r,o,s;if((o=n.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=n.utils.wrappedCreator(e)||e.constructor,i.isUndefined(o)||(s=this.find(o,r)),this.retain(e,t,r),s&&this.release(s)}},e.prototype.release=function(e,t){var r;if(!this._canRegister(e))return n.release(e);if(r=this._storeReferences(e)){if(!t&&--r.ref_count>0)return;this._clearStoreReferences(e)}return this._remove(e),e.__kb_released?void 0:t||this._refCount(e)<=1?n.release(e):void 0},e.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},e.prototype._refCount=function(e){var t;return e.__kb_released?("undefined"!=typeof console&&null!==console&&console.log("Observable already released"),0):(t=n.utils.get(e,"stores_references"))?i.reduce(t,function(e,t){return e+t.ref_count},0):1},e.prototype._canRegister=function(e){return e&&!o.isObservable(e)&&!e.__kb_is_co},e.prototype._cid=function(e){var t;return t=e?e.cid||(e.cid=i.uniqueId("c")):"null"},e.prototype._creatorId=function(e){var t,r,n,o,s;for(t=e.create||e,t.__kb_cids||(t.__kb_cids=[]),s=t.__kb_cids,n=0,o=s.length;o>n;n++)if(r=s[n],r.create===t)return r.cid;return t.__kb_cids.push(r={create:t,cid:i.uniqueId("kb")}),r.cid},e.prototype._storeReferences=function(e){var t;if(t=n.utils.get(e,"stores_references"))return i.find(t,function(e){return function(t){return t.store===e}}(this))},e.prototype._getOrCreateStoreReferences=function(e){var t,r;return r=n.utils.orSet(e,"stores_references",[]),(t=i.find(r,function(e){return function(t){return t.store===e}}(this)))||r.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,r,o,i;if(o=n.utils.get(e,"stores_references")){i=e.__kb.stores_references;for(t in i)if(r=i[t],r.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,r){var o,i;return r||(r=e.constructor),n.utils.wrappedObject(e,t),n.utils.wrappedCreator(e,r),((o=this.observable_records)[i=this._creatorId(r)]||(o[i]={}))[this._cid(t)]=e},e.prototype._remove=function(e){var t,r,o;return t=n.utils.wrappedCreator(e)||e.constructor,(r=this.find(o=n.utils.wrappedObject(e),t))&&r===e&&delete this.observable_records[this._creatorId(t)][this._cid(o)],n.utils.wrappedObject(e,null),n.utils.wrappedCreator(e,null)},e.prototype._creator=function(e,t){var r;return t.creator?t.creator:(r=n.utils.inferCreator(e,t.factory,t.path))?r:n.isModel(e)?n.ViewModel:void 0},e}()},function(e,t,r){var n,o,i,s,a;a=o=r(6),s=a._,i=a.ko,e.exports=n=function(){function e(e){this.create_options=e,this._vo=i.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&&o.utils.wrappedCreator(e)?this.create_options.store.release(e):o.release(e)),this.create_options=null},e.prototype.value=function(){return i.utils.unwrapObservable(this._vo())},e.prototype.rawValue=function(){return this.__kb_value},e.prototype.valueType=function(e,t){var r;return r=o.getValue(e,t),this.value_type||this._updateValueObservable(r),this.value_type},e.prototype.update=function(e){var t,r,n;if(!this.__kb_released){switch(void 0!==e||(e=null),t=o.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 o.TYPE_COLLECTION:if(this.value_type===o.TYPE_COLLECTION&&t===o.TYPE_ARRAY)return r(e);if(t===o.TYPE_COLLECTION||s.isNull(e))return void(e&&e instanceof o.CollectionObservable?this._updateValueObservable(o.utils.wrappedObject(e),e):o.peek(r.collection)!==e&&r.collection(e));break;case o.TYPE_MODEL:if(t===o.TYPE_MODEL||s.isNull(e))return void(e&&!o.isModel(e)?this._updateValueObservable(o.utils.wrappedObject(e),e):o.utils.wrappedObject(r)!==o.utils.resolveModel(e)&&this._updateValueObservable(e))}if(this.value_type!==t||s.isUndefined(this.value_type)){if(o.peek(r)!==e)return this._updateValueObservable(e)}else if(o.peek(r)!==e)return r(e)}},e.prototype._updateValueObservable=function(e,t){var r,n,a,l,u,c;return r=this.create_options,n=o.utils.inferCreator(e,r.factory,r.path),null!==e||n||(this.value_type===o.TYPE_MODEL?n=o.ViewModel:this.value_type===o.TYPE_COLLECTION&&(n=o.CollectionObservable)),r.creator=n,u=o.TYPE_UNKNOWN,c=[this.__kb_value,void 0],a=c[0],this.__kb_value=c[1],t?(l=t,r.store&&r.store.retain(t,e,n)):n?r.store?l=r.store.retainOrCreate(e,r):n.models_only?(l=e,u=o.TYPE_SIMPLE):l=n.create?n.create(e,r):new n(e,r):s.isArray(e)?(u=o.TYPE_ARRAY,l=i.observableArray(e)):(u=o.TYPE_SIMPLE,l=i.observable(e)),(this.value_type=u)===o.TYPE_UNKNOWN&&(i.isObservable(l)?l.__kb_is_co?(this.value_type=o.TYPE_COLLECTION,o.utils.wrappedObject(l,e)):this.value_type||(this.value_type=o.TYPE_SIMPLE):(this.value_type=o.TYPE_MODEL,o.utils.wrappedObject(l,o.utils.resolveModel(e)))),a&&(this.create_options.store?this.create_options.store.release(a):o.release(a)),this.__kb_value=l,this._vo(l)},e.prototype._inferType=function(){},e}()},function(e,t,r){var n,o,i,s;s=n=r(6),i=s._,o=s.ko,n.utils=function(){function e(){}return e.get=function(e,t,r){return e.__kb&&e.__kb.hasOwnProperty(t)?e.__kb[t]:r},e.set=function(e,t,r){return(e.__kb||(e.__kb={}))[t]=r},e.orSet=function(e,t,r){return(e.__kb||(e.__kb={})).hasOwnProperty(t)||(e.__kb[t]=r),e.__kb[t]},e.has=function(e,t){return e.__kb&&e.__kb.hasOwnProperty(t)},e.wrappedObservable=function(e,t){return 1===arguments.length?n.utils.get(e,"observable"):n.utils.set(e,"observable",t)},e.wrappedObject=function(e,t){return 1===arguments.length?n.utils.get(e,"object"):n.utils.set(e,"object",t)},e.wrappedCreator=function(e,t){return 1===arguments.length?n.utils.get(e,"creator"):n.utils.set(e,"creator",t)},e.wrappedModel=function(e,t){return 1===arguments.length?i.isUndefined(t=n.utils.get(e,"object"))?e:t:n.utils.set(e,"object",t)},e.wrappedStore=function(e,t){return 1===arguments.length?n.utils.get(e,"store"):n.utils.set(e,"store",t)},e.wrappedStoreIsOwned=function(e,t){return 1===arguments.length?n.utils.get(e,"store_is_owned"):n.utils.set(e,"store_is_owned",t)},e.wrappedFactory=function(e,t){return 1===arguments.length?n.utils.get(e,"factory"):n.utils.set(e,"factory",t)},e.wrappedEventWatcher=function(e,t){return 1===arguments.length?n.utils.get(e,"event_watcher"):n.utils.set(e,"event_watcher",t) },e.wrappedEventWatcherIsOwned=function(e,t){return 1===arguments.length?n.utils.get(e,"event_watcher_is_owned"):n.utils.set(e,"event_watcher_is_owned",t)},e.wrappedDestroy=r(30),e.valueType=function(e){return e?e.__kb_is_o?e.valueType():e.__kb_is_co||e instanceof n.Collection?n.TYPE_COLLECTION:e instanceof n.ViewModel||e instanceof n.Model?n.TYPE_MODEL:i.isArray(e)?n.TYPE_ARRAY:n.TYPE_SIMPLE:n.TYPE_UNKNOWN},e.pathJoin=function(e,t){return(e?"."!==e[e.length-1]?""+e+".":e:"")+t},e.optionsPathJoin=function(e,t){return i.defaults({path:this.pathJoin(e.path,t)},e)},e.inferCreator=function(e,t,r){var o;return t&&(o=t.creatorForPath(e,r))?o:e?e instanceof n.Model?n.ViewModel:e instanceof n.Collection?n.CollectionObservable:null:null},e.createFromDefaultCreator=function(e,t){return n.isModel(e)?n.viewModel(e,t):n.isCollection(e)?n.collectionObservable(e,t):i.isArray(e)?o.observableArray(e):o.observable(e)},e.collapseOptions=r(31),e.unwrapModels=r(32),e.resolveModel=function(e){return e&&n.Backbone&&n.Backbone.ModelRef&&e instanceof n.Backbone.ModelRef?e.model():e},e}()},function(e,t,r){var n,o,i,s,a,l,u,c;c=a=r(6),u=c._,l=c.ko,o=function(e,t){var r;return r=e.__kb.internals&&u.contains(e.__kb.internals,t)?"_"+t:t,e.__kb.view_model.hasOwnProperty(r)?void 0:(e.__kb.view_model[r]=null,r)},i=function(e,t,r,n){var i;if(!(e.__kb.excludes&&u.contains(e.__kb.excludes,r)||e.__kb.statics&&u.contains(e.__kb.statics,r)||!(i=o(e,r))))return e[i]=e.__kb.view_model[i]=a.observable(t,r,n,e)},s=function(e,t){var r,n,i,s,a;for(a=e.__kb.statics,i=0,s=a.length;s>i;i++)r=a[i],(n=o(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])},n=["keys","internals","excludes","statics","static_defaults"],a.ViewModel=function(){function e(e,t){var r;return null==t&&(t={}),r=Array.prototype.slice.call(u.isArguments(e)?e:arguments),a.ignore(function(o){return function(){var i,c,d,p,f,_,h,b;for(!(e=r.shift())||a.isModel(e)||a._throwUnexpected(o,"not a model"),u.isArray(r[0])&&(r[0]={keys:r[0]}),o.__kb||(o.__kb={}),o.__kb.view_model=r.length>1?r.pop():o,t={},p=0,_=r.length;_>p;p++)i=r[p],u.extend(t,i);for(t=a.utils.collapseOptions(t),f=0,h=n.length;h>f;f++)d=n[f],t.hasOwnProperty(d)&&(o.__kb[d]=t[d]);return a.Store.useOptionsOrCreate(t,e,o),o.__kb.path=t.path,a.Factory.useOptionsOrCreate(t,o,t.path),b=a.utils.set(o,"_model",l.observable()),o.model=l.computed({read:function(){return l.utils.unwrapObservable(b)},write:function(e){return a.ignore(function(){return a.utils.wrappedObject(o)!==e&&!a.wasReleased(o)&&c?(o.__kb.store.reuse(o,a.utils.resolveModel(e)),c.emitter(e),b(c.ee),!c.ee||o.createObservables(c.ee)):void 0})}}),c=a.utils.wrappedEventWatcher(o,new a.EventWatcher(e,o,{emitter:o._model,update:function(){return a.ignore(function(){return!(null!=c?c.ee:void 0)||o.createObservables(null!=c?c.ee:void 0)})}})),a.utils.wrappedObject(o,e=c.ee),b(c.ee),o.__kb.create_options={store:a.utils.wrappedStore(o),factory:a.utils.wrappedFactory(o),path:o.__kb.path,event_watcher:a.utils.wrappedEventWatcher(o)},!t.requires||o.createObservables(e,t.requires),!o.__kb.internals||o.createObservables(e,o.__kb.internals),!t.mappings||o.createObservables(e,t.mappings),!o.__kb.statics||s(o,e),o.createObservables(e,o.__kb.keys),!a.statistics||a.statistics.register("ViewModel",o),o}}(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 r,n,s,l,c,d,p,f,_;if(t)if(u.isArray(t))for(d=0,f=t.length;f>d;d++)r=t[d],i(this,e,r,this.__kb.create_options);else for(r in t)n=t[r],(l=o(this,r))&&(u.isString(n)||n.key||(n.key=l),this[l]=this.__kb.view_model[l]=a.observable(e,n,this.__kb.create_options,this));else{if(this.__kb.keys||!e)return;for(r in e.attributes)i(this,e,r,this.__kb.create_options);if(s=null!=(_=a.orm)&&"function"==typeof _.keys?_.keys(e):void 0)for(c=0,p=s.length;p>c;c++)r=s[c],i(this,e,r,this.__kb.create_options)}},e}(),a.viewModel=function(){return new a.ViewModel(arguments)}},function(e,t,r){var n,o,i,s,a;if(e.exports=n=r(6),n.configure=r(2),n.modules={underscore:n._,backbone:n.Parse||n.Backbone,knockout:n.ko},"undefined"!=typeof window&&null!==window)for(a=["_","Backbone","Parse","ko","$"],i=0,s=a.length;s>i;i++)o=a[i],n[o]&&!window.hasOwnProperty(o)&&(window[o]=n[o])},function(e,t,r){var n,o,i,s,a;a=o=r(6),s=a._,i=a.ko,r(24),n=["destroy","setToDefault"],e.exports=o.DefaultObservable=function(){function e(e,t){var r;return this.dv=t,r=o.utils.wrappedObservable(this,i.computed({read:function(t){return function(){var r;return r=i.utils.unwrapObservable(e()),s.isNull(r)||s.isUndefined(r)?i.utils.unwrapObservable(t.dv):r}}(this),write:function(t){return e(t)}})),o.publishMethods(r,this,n),r}return e.prototype.destroy=function(){return o.utils.wrappedDestroy(this)},e.prototype.setToDefault=function(){return o.utils.wrappedObservable(this)(this.dv)},e}(),o.defaultObservable=function(e,t){return new o.DefaultObservable(e,t)}},function(e,t,r){var n,o,i,s,a;a=o=r(6),s=a._,i=a.ko,n=Array.prototype.slice,o.toFormattedString=function(e){var t,r,o,a,l,u;l=e.slice(),r=n.call(arguments,1);for(o in r)for(t=r[o],u=i.utils.unwrapObservable(t),(s.isUndefined(u)||s.isNull(u))&&(u=""),a=e.indexOf("{"+o+"}");a>=0;)l=l.replace("{"+o+"}",u),a=e.indexOf("{"+o+"}",a+1);return l},o.parseFormattedString=function(e,t){var r,n,o,i,a,l,u,c,d,p,f,_,h;for(p=t.slice(),o=0,l=0,c={};p.search("\\{"+o+"\\}")>=0;){for(u=t.indexOf("{"+o+"}");u>=0;)p=p.replace("{"+o+"}","(.*)"),c[u]=o,l++,u=t.indexOf("{"+o+"}",u+1);o++}if(r=o,d=new RegExp(p),a=d.exec(e),a&&a.shift(),!a||a.length!==l){for(f=[];r-->0;)f.push("");return f}h=s.sortBy(s.keys(c),function(e){return parseInt(e,10)}),n={};for(i in h)u=h[i],o=c[u],n.hasOwnProperty(o)||(n[o]=i);for(_=[],o=0;r>o;)_.push(a[n[o]]),o++;return _},e.exports=o.FormattedObservable=function(){function e(e,t){var r,a;return s.isArray(t)?(e=e,a=t):a=n.call(arguments,1),r=o.utils.wrappedObservable(this,i.computed({read:function(){var r,n,s;for(t=[i.utils.unwrapObservable(e)],n=0,s=a.length;s>n;n++)r=a[n],t.push(i.utils.unwrapObservable(r));return o.toFormattedString.apply(null,t)},write:function(t){var r,n,s;for(n=o.parseFormattedString(t,i.utils.unwrapObservable(e)),s=Math.min(a.length,n.length),r=0;s>r;)a[r](n[r]),r++}}))}return e.prototype.destroy=function(){return o.utils.wrappedDestroy(this)},e}(),o.formattedObservable=function(e){return new o.FormattedObservable(e,n.call(arguments,1))}},function(e,t,r){var n,o,i,s,a;a=o=r(6),s=a._,i=a.ko,n=["destroy","observedValue","resetToCurrent"],o.locale_manager||(o.locale_manager=void 0),e.exports=o.LocalizedObservable=function(){function e(e,t,r){var a;return this.value=e,this.vm=r,t||(t={}),this.vm||(this.vm={}),this.read||o._throwMissing(this,"read"),o.locale_manager||o._throwMissing(this,"kb.locale_manager"),this.__kb||(this.__kb={}),this.__kb._onLocaleChange=s.bind(this._onLocaleChange,this),this.__kb._onChange=t.onChange,this.value&&(e=i.utils.unwrapObservable(this.value)),this.vo=i.observable(e?this.read(e,null):null),a=o.utils.wrappedObservable(this,i.computed({read:function(e){return function(){return e.value&&i.utils.unwrapObservable(e.value),e.vo(),e.read(i.utils.unwrapObservable(e.value))}}(this),write:function(e){return function(t){return e.write||o._throwUnexpected(e,"writing to read-only"),e.write(t,i.utils.unwrapObservable(e.value)),e.vo(t),e.__kb._onChange?e.__kb._onChange(t):void 0}}(this),owner:this.vm})),o.publishMethods(a,this,n),o.locale_manager.bind("change",this.__kb._onLocaleChange),t.hasOwnProperty("default")&&(a=o.DefaultObservable&&i.defaultObservable(a,t["default"])),a}return e.extend=o.extend,e.prototype.destroy=function(){return o.locale_manager.unbind("change",this.__kb._onLocaleChange),this.vm=null,o.utils.wrappedDestroy(this)},e.prototype.resetToCurrent=function(){var e,t;return t=o.utils.wrappedObservable(this),e=this.value?this.read(i.utils.unwrapObservable(this.value)):null,t()!==e?t(e):void 0},e.prototype.observedValue=function(e){return 0===arguments.length?this.value:(this.value=e,void this._onLocaleChange())},e.prototype._onLocaleChange=function(){var e;return e=this.read(i.utils.unwrapObservable(this.value)),this.vo(e),this.__kb._onChange?this.__kb._onChange(e):void 0},e}(),o.localizedObservable=function(e,t,r){return new o.LocalizedObservable(e,t,r)}},function(e,t,r){var n,o,i,s,a;a=o=r(6),s=a._,i=a.ko,n=["destroy"],e.exports=o.TriggeredObservable=function(){function e(e,t){var r;return this.event_selector=t,e||o._throwMissing(this,"emitter"),this.event_selector||o._throwMissing(this,"event_selector"),this.vo=i.observable(),r=o.utils.wrappedObservable(this,i.computed(function(e){return function(){return e.vo()}}(this))),o.publishMethods(r,this,n),o.utils.wrappedEventWatcher(this,new o.EventWatcher(e,this,{emitter:s.bind(this.emitter,this),update:s.bind(this.update,this),event_selector:this.event_selector})),r}return e.prototype.destroy=function(){return o.utils.wrappedDestroy(this)},e.prototype.emitter=function(e){return 0===arguments.length||this.ee===e?this.ee:(this.ee=e)?this.update():void 0},e.prototype.update=function(){return this.ee?this.vo()!==this.ee?this.vo(this.ee):this.vo.valueHasMutated():void 0},e}(),o.triggeredObservable=function(e,t){return new o.TriggeredObservable(e,t)}},function(e,t,r){var n,o,i,s,a,l;l=i=r(6),a=l._,s=l.ko,n=l.$,r(25),o=function(e){return e=s.utils.unwrapObservable(e),"function"==typeof e?e.apply(null,Array.prototype.slice.call(arguments,1)):e},e.exports=i.Validation=function(){function e(){}return e}(),i.valueValidator=function(e,t,r){return null==r&&(r={}),r&&!("function"==typeof r)||(r={}),s.computed(function(){var n,i,l,u,c,d,p,f;p={$error_count:0},i=s.utils.unwrapObservable(e),!("disable"in r)||(l=o(r.disable)),!("enable"in r)||(l=!o(r.enable)),d=r.priorities||[],a.isArray(d)||(d=[d]),n=d.length+1;for(u in t)f=t[u],p[u]=!l&&o(f,i),p[u]&&(p.$error_count++,(c=a.indexOf(d,u)>=0)||(c=d.length),p.$active_error&&n>c?(p.$active_error=u,n=c):p.$active_error||(p.$active_error=u,n=c));return p.$enabled=!l,p.$disable=!!l,p.$valid=0===p.$error_count,p})},i.inputValidator=function(e,t,r){var o,s,l,u,c,d,p,f,_,h;if(null==r&&(r={}),r&&!("function"==typeof r)||(r={}),_=i.valid,o=n(t),(u=o.attr("name"))&&!a.isString(u)&&(u=null),!(s=o.attr("data-bind")))return null;if(c=new Function("sc","with(sc[0]) { return { "+s+" } }")([e]),!c||!c.value)return null;if(!c.validation_options||(a.defaults(c.validation_options,r),r=c.validation_options),s={},!_[p=o.attr("type")]||(s[p]=_[p]),!o.attr("required")||(s.required=_.required),c.validations){h=c.validations;for(l in h)f=h[l],s[l]=f}return d=i.valueValidator(c.value,s,r),!u&&!r.no_attach||(e["$"+u]=d),d},i.formValidator=function(e,t){var r,o,l,u,c,d,p,f,_,h,b,v,y;for(p={},h=[],r=n(t),(l=r.attr("name"))&&!a.isString(l)&&(l=null),(o=r.attr("data-bind"))&&(d=new Function("sc","with(sc[0]) { return { "+o+" } }")([e]),f=d.validation_options),f||(f={}),f.no_attach=!!l,y=r.find("input"),b=0,v=y.length;v>b;b++)u=y[b],(c=n(u).attr("name"))&&(_=i.inputValidator(e,u,f),!_||h.push(p[c]=_));return p.$error_count=s.computed(function(){var e,t,r;for(e=0,t=0,r=h.length;r>t;t++)_=h[t],e+=_().$error_count;return e}),p.$valid=s.computed(function(){return 0===p.$error_count()}),p.$enabled=s.computed(function(){var e,t,r;for(e=!0,t=0,r=h.length;r>t;t++)_=h[t],e&=_().$enabled;return e}),p.$disabled=s.computed(function(){return!p.$enabled()}),l&&(e["$"+l]=p),p}},function(t){t.exports=e},function(e){e.exports=t},function(e){e.exports=r},function(e){if("undefined"==typeof n){var t=new Error('Cannot find module "undefined"');throw t.code="MODULE_NOT_FOUND",t}e.exports=n},function(e,t,r){var n,o,i,s;s=n=r(6),i=s._,o=s.ko,n.Observable.prototype.setToDefault=function(){var e;null!=(e=this.__kb_value)&&"function"==typeof e.setToDefault&&e.setToDefault()},n.ViewModel.prototype.setToDefault=function(){var e,t;for(e in this.__kb.vm_keys)null!=(t=this[e])&&"function"==typeof t.setToDefault&&t.setToDefault()},n.utils.setToDefault=function(e){var t,r;if(e){if(o.isObservable(e))"function"==typeof e.setToDefault&&e.setToDefault();else if(i.isObject(e))for(t in e)r=e[t],!r||!o.isObservable(r)&&"function"==typeof r||"_"===t[0]&&!t.search("__kb")||this.setToDefault(r);return e}}},function(e,t,r){var n,o,i,s,a,l,u,c;c=a=r(6),u=c._,l=c.ko,n=c.$,s=/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/,o=/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/,i=/^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/,a.valid={required:function(e){return!e},url:function(e){return!s.test(e)},email:function(e){return!o.test(e)},number:function(e){return!i.test(e)}},a.hasChangedFn=function(e){var t,r;return r=null,t=null,function(){var n;return r!==(n=l.utils.unwrapObservable(e))?(r=n,t=r?r.toJSON():null,!1):r&&t?!u.isEqual(r.toJSON(),t):!1}},a.minLengthFn=function(e){return function(t){return!t||t.lengthu;u++)o=i[u],e.bind(""+o+":"+t,a);else e.bind(""+i[0]+":"+t,a);return function(){var r,n;if(l===s.TYPE_COLLECTION)for(r=0,n=i.length;n>r;r++)o=i[r],e.unbind(""+o+":"+t,a);else e.unbind(""+i[0]+":"+t,a)}},e.useFunction=function(){return!1},e}()},function(e,t,r){(function(t){var n,o,i,s;i="undefined"!=typeof window&&null!==window?window:t,s=(o=r(6))._,n=null,e.exports=n=function(){function e(){}return e.isAvailable=function(){return!!(e=i.Supermodel)},e.keys=function(t){return t instanceof e.Model?s.keys(t.constructor.associations()):null},e.relationType=function(t,r){var n;return t instanceof e.Model&&(n=t.constructor.associations()[r])?n.add?o.TYPE_COLLECTION:o.TYPE_MODEL:null},e.bind=function(e,t,r,n){var i,s;return(s=this.relationType(e,t))?(i=function(e,i){var s,a;return!o.statistics||o.statistics.addModelEvent({name:"update (supermodel)",model:e,key:t,path:n}),a=e.constructor.associations()[t],s=e[a.store],e[a.store]=i,r(i),e[a.store]=s},s===o.TYPE_MODEL?(e.bind("associate:"+t,i),function(){return e.unbind("associate:"+t,i)}):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 r,n;for(r in t)n=t[r],e[r]=n;return e};var r=function(){},n=function(e,n,o){var i;return i=n&&n.hasOwnProperty("constructor")?n.constructor:function(){e.apply(this,arguments)},t(i,e),r.prototype=e.prototype,i.prototype=new r,n&&t(i.prototype,n),o&&t(i,o),i.prototype.constructor=i,i.__super__=e.prototype,i},o=function(e,t){var r=n(this,e,t);return r.extend=this.extend,r};e.exports=o},function(e,t,r){var n,o;o=r(6)._,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;n=r(6)._,i=function(e,t,r){return e[t]||(e[t]=[]),n.isArray(r)||(r=[r]),e[t]=e[t].length?n.union(e[t],r):r,e},s=function(e,t,r){return e[t]||(e[t]={}),n.extend(e[t],r)},o=function(e){var t,r,n,o;for(r={},n=0,o=e.length;o>n;n++)t=e[n],r[t]={key:t};return r},a=function(e,t){var r,l;if(!t)return e;for(r in t)switch(l=t[r],r){case"internals":case"requires":case"excludes":case"statics":i(e,r,l);break;case"keys":n.isObject(l)&&!n.isArray(l)||n.isObject(e[r])&&!n.isArray(e[r])?(n.isObject(l)||(l=[l]),n.isArray(l)&&(l=o(l)),n.isArray(e[r])&&(e[r]=o(e[r])),s(e,r,l)):i(e,r,l);break;case"factories":n.isFunction(l)?e[r]=l:s(e,r,l);break;case"static_defaults":s(e,r,l);break;case"options":break;default:e[r]=l}return a(e,t.options)},e.exports=function(e){return a({},e)}},function(e,t,r){var n,o;o=r(6)._,e.exports=n=function(e){var t,r,i;if(!e)return e;if(e.__kb)return e.__kb.hasOwnProperty("object")?e.__kb.object:e;if(o.isArray(e))return o.map(e,function(e){return n(e)});if(o.isObject(e)&&e.constructor==={}.constructor){r={};for(t in e)i=e[t],r[t]=n(i);return r}return e}}])});