/* knockback.js 0.19.0 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,i){return t(r,n,i,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 i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.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(13),r(14),r(15),r(16),r(17),e.exports=r(12)},function(e,t,r){var n,i,o,s,a,l,u=[].indexOf||function(e){for(var t=0,r=this.length;r>t;t++)if(t in this&&this[t]===e)return t;return-1};s=r(5),l=s._,a=s.ko,o=0,n=-1,i=1,s.compare=function(e,t){return l.isString(e)?e.localeCompare(""+t):l.isString(t)?t.localeCompare(""+e):e===t?o:t>e?n:i},s.CollectionObservable=function(){function e(e,t){return s.ignore(function(r){return function(){var n,i,o;return!l.isUndefined(t)||e instanceof s.Collection?l.isArray(e)&&(e=new s.Collection(e)):(o=[new s.Collection,e],e=o[0],t=o[1]),t||(t={}),i=s.utils.wrappedObservable(r,a.observableArray([])),i.__kb_is_co=!0,r.in_edit=0,r.__kb||(r.__kb={}),r.__kb._onCollectionChange=l.bind(r._onCollectionChange,r),t=s.utils.collapseOptions(t),t.auto_compact&&(r.auto_compact=!0),r._comparator=a.observable(t.sort_attribute?r._attributeComparator(t.sort_attribute):t.comparator),r._filters=a.observableArray(t.filters?l.isArray(t.filters)?t.filters:t.filters?[t.filters]:void 0:[]),n=r.create_options={store:s.Store.useOptionsOrCreate(t,e,i)},r.path=t.path,n.factory=s.utils.wrappedFactory(i,r._shareOrCreateFactory(t)),n.path=s.utils.pathJoin(t.path,"models"),n.creator=n.factory.creatorForPath(null,n.path),n.creator&&(r.models_only=n.creator.models_only),s.publishMethods(i,r,["destroy","shareOptions","filters","comparator","sortAttribute","viewModelByModel","hasViewModels"]),r._collection=a.observable(e),i.collection=r.collection=a.dependentObservable({read:function(){return r._collection()},write:function(e){return s.ignore(function(){var t;if((t=r._collection())!==e)return t&&t.unbind("all",r.__kb._onCollectionChange),e&&e.bind("all",r.__kb._onCollectionChange),r._collection(e)})}}),e&&e.bind("all",r.__kb._onCollectionChange),r._mapper=a.dependentObservable(function(){var e,t,n,o,u,c,d,p;if(e=r._comparator(),o=r._filters())for(d=0,p=o.length;p>d;d++)n=o[d],a.utils.unwrapObservable(n);return t=r._collection(),r.in_edit?void 0:(i=s.utils.wrappedObservable(r),t&&(u=t.models),u&&0!==t.models.length?(u=l.filter(u,function(e){return!o.length||r._selectModel(e)}),c=e?l.map(u,function(e){return r._createViewModel(e)}).sort(e):r.models_only?o.length?u:u.slice():l.map(u,function(e){return r._createViewModel(e)})):c=[],r.in_edit++,i(c),r.in_edit--)}),i.subscribe(l.bind(r._onObservableArrayChange,r)),!s.statistics||s.statistics.register("CollectionObservable",r),i}}(this))}return e.extend=s.extend,e.prototype.destroy=function(){var e,t,r;return r=s.utils.wrappedObservable(this),t=s.peek(this._collection),t&&(t.unbind("all",this.__kb._onCollectionChange),e=s.peek(r),e.splice(0,e.length)),this.collection.dispose(),this._collection=r.collection=this.collection=null,this._mapper.dispose(),this._mapper=null,s.release(this._filters),this._filters=null,this._comparator(null),this._comparator=null,this.create_options=null,r.collection=null,s.utils.wrappedDestroy(this),!s.statistics||s.statistics.unregister("CollectionObservable",this)},e.prototype.shareOptions=function(){var e;return e=s.utils.wrappedObservable(this),{store:s.utils.wrappedStore(e),factory:s.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(s.peek(s.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 s.ignore(function(e){return function(){var t;return t=s.utils.wrappedObservable(e),s.utils.wrappedStoreIsOwned(t)?(s.utils.wrappedStore(t).clear(),e._collection.notifySubscribers(e._collection())):void 0}}(this))},e.prototype._shareOrCreateFactory=function(e){var t,r,n,i;if(t=s.utils.pathJoin(e.path,"models"),n=e.factories,(i=e.factory)&&(r=i.creatorForPath(null,t))&&(!n||n.models===r)){if(!n)return i;if(i.hasPathMappings(n,e.path))return i}return i=new s.Factory(e.factory),n&&i.addPathMappings(n,e.path),i.creatorForPath(null,t)||(e.hasOwnProperty("models_only")?e.models_only?i.addPathMapping(t,{models_only:!0}):i.addPathMapping(t,s.ViewModel):e.view_model?i.addPathMapping(t,e.view_model):e.create?i.addPathMapping(t,{create:e.create}):i.addPathMapping(t,s.ViewModel)),i},e.prototype._onCollectionChange=function(e,t){return s.ignore(function(r){return function(){var n,i,o,a;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(o=s.utils.wrappedObservable(r),n=r._collection(),-1===n.indexOf(t))return;if(a=r.viewModelByModel(t))return;r.in_edit++,a=r._createViewModel(t),(i=r._comparator())?(o().push(a),o.sort(i)):o.splice(n.indexOf(t),0,a),r.in_edit--;break;case"remove":case"destroy":r._onModelRemove(t);break;case"change":r._selectModel(t)?(a=r.models_only?t:r.viewModelByModel(t),a?(i=r._comparator())&&(o=s.utils.wrappedObservable(r),r.in_edit++,o.sort(i),r.in_edit--):r._onCollectionChange("add",t)):r._onModelRemove(t)}}}(this))},e.prototype._onModelRemove=function(e){var t,r;return(r=this.models_only?e:this.viewModelByModel(e))?(t=s.utils.wrappedObservable(this),this.in_edit++,t.remove(r),this.in_edit--):void 0},e.prototype._onObservableArrayChange=function(e){return s.ignore(function(t){return function(){var r,n,i,o,a,u,c,d,p;if(!t.in_edit&&(t.models_only&&(!e.length||s.utils.hasModelSignature(e[0]))||!t.models_only&&(!e.length||l.isObject(e[0])&&!s.utils.hasModelSignature(e[0]))||s._throwUnexpected(t,"incorrect type passed"),a=s.utils.wrappedObservable(t),r=s.peek(t._collection),n=s.peek(t._filters).length,r)){if(c=e,t.models_only)o=l.filter(e,function(e){return!n||t._selectModel(e)});else for(!n||(c=[]),o=[],d=0,p=e.length;p>d;d++){if(u=e[d],i=s.utils.wrappedObject(u),n){if(!t._selectModel(i))continue;c.push(u)}t.create_options.store.findOrReplace(i,t.create_options.creator,u),o.push(i)}t.in_edit++,e.length===c.length||a(c),l.isEqual(r.models,o)||r.reset(o),t.in_edit--}}}(this))},e.prototype._attributeComparator=function(e){var t;return t=function(t,r){var n;return n=a.utils.unwrapObservable(e),s.compare(t.get(n),r.get(n))},this.models_only?t:function(e,r){return t(s.utils.wrappedModel(e),s.utils.wrappedModel(r))}},e.prototype._createViewModel=function(e){return this.models_only?e:this.create_options.store.findOrCreate(e,this.create_options)},e.prototype._selectModel=function(e){var t,r,n,i,o;for(r=s.peek(this._filters),n=0,i=r.length;i>n;n++)if(t=r[n],t=s.peek(t),l.isFunction(t)){if(!t(e))return!1}else if(l.isArray(t)){if(o=e.id,u.call(t,o)<0)return!1}else if(e.id!==t)return!1;return!0},e}(),s.collectionObservable=function(e,t){return new s.CollectionObservable(e,t)}},function(e,t,r){var n,i,o,s=function(e,t){return function(){return e.apply(t,arguments)}},a=[].indexOf||function(e){for(var t=0,r=this.length;r>t;t++)if(t in this&&this[t]===e)return t;return-1};n=r(5),o=n._,i=n.ko,n.EventWatcher=function(){function e(e,t,r){this._onModelUnloaded=s(this._onModelUnloaded,this),this._onModelLoaded=s(this._onModelLoaded,this),this.__kb||(this.__kb={}),this.__kb.callbacks={},this.__kb._onModelLoaded=o.bind(this._onModelLoaded,this),this.__kb._onModelUnloaded=o.bind(this._onModelUnloaded,this),r&&this.registerCallbacks(t,r),e?this.emitter(e):this.ee=null}return e.useOptionsOrCreate=function(e,t,r,i){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,i)):(n.utils.wrappedEventWatcherIsOwned(r,!0),n.utils.wrappedEventWatcher(r,new n.EventWatcher(t)).registerCallbacks(r,i))},e.prototype.destroy=function(){return this.emitter(null),this.__kb.callbacks=null,n.utils.wrappedDestroy(this)},e.prototype.emitter=function(e){var t,r,i,o,s,a,l,u;if(0===arguments.length||this.ee===e)return this.ee;this.model_ref&&(this.model_ref.unbind("loaded",this.__kb._onModelLoaded),this.model_ref.unbind("unloaded",this.__kb._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.__kb._onModelLoaded),this.model_ref.bind("unloaded",this.__kb._onModelUnloaded),e=this.model_ref.model()):delete this.model_ref,s=this.ee,this.ee=e,u=this.__kb.callbacks;for(r in u)for(t=u[r],s&&s.unbind(r,t.fn),e&&this.ee.bind(r,t.fn),o=t.list,a=0,l=o.length;l>a;a++)i=o[a],i.emitter&&i.emitter(this.ee);return e},e.prototype.registerCallbacks=function(e,t){var r,s,l,u,c,d,p,f;for(e||n._throwMissing(this,"obj"),t||n._throwMissing(this,"info"),u=t.event_selector?t.event_selector:"change",l=u.split(" "),p=0,f=l.length;f>p;p++)s=l[p],s&&(r=this.__kb.callbacks[s],r||(d=[],r={list:d,fn:function(){return function(e){var t,r,o;for(r=0,o=d.length;o>r;r++)if(t=d[r],t.update&&!t.rel_fn){if(e&&t.key&&e.hasChanged&&!e.hasChanged(i.utils.unwrapObservable(t.key)))continue;!n.statistics||n.statistics.addModelEvent({name:s,model:e,key:t.key,path:t.path}),t.update()}return null}}(this)},this.__kb.callbacks[s]=r,this.ee&&this.ee.bind(s,r.fn)),c=o.defaults({obj:e},t),r.list.push(c));this.ee&&(a.call(l,"change")>=0&&(c.unbind_fn=n.orm.bind(this.ee,c.key,c.update,c.path)),c.emitter(this.ee)&&c.emitter)},e.prototype.releaseCallbacks=function(e){var t,r,i,o,s,a;if(this.__kb.callbacks&&this.ee){s=this.__kb.callbacks;for(r in s){t=s[r],a=t.list;for(i in a)if(o=a[i],o.obj===e)return t.list.splice(i,1),o.unbind_fn&&(o.unbind_fn(),o.unbind_fn=null),void(!n.wasReleased(e)&&o.emitter&&o.emitter(null))}}},e.prototype._onModelLoaded=function(e){var t,r,i,o,s,a,l;this.ee=e,a=this.__kb.callbacks;for(r in a)for(t=a[r],e.bind(r,t.fn),l=t.list,o=0,s=l.length;s>o;o++)i=l[o],i.unbind_fn=n.orm.bind(e,i.key,i.update,i.path),i.emitter&&i.emitter(e)},e.prototype._onModelUnloaded=function(e){var t,r,n,i,o,s,a;this.ee=null,a=this.__kb.callbacks;for(r in a)for(t=a[r],e.unbind(r,t.fn),i=t.list,o=0,s=i.length;s>o;o++)n=i[o],n.unbind_fn&&(n.unbind_fn(),n.unbind_fn=null),n.emitter&&n.emitter(null)},e}(),n.emitterObservable=function(e,t){return new n.EventWatcher(e,t)}},function(e,t,r){var n,i;n=r(5),i=n._,n.Factory=function(){function e(e){this.parent_factory=e,this.paths={}}return e.useOptionsOrCreate=function(e,t,r){var i;return e.factory&&(!e.factories||e.factories&&e.factory.hasPathMappings(e.factories,r))?n.utils.wrappedFactory(t,e.factory):(i=n.utils.wrappedFactory(t,new n.Factory(e.factory)),e.factories&&i.addPathMappings(e.factories,r),i)},e.prototype.hasPath=function(e){return this.paths.hasOwnProperty(e)||this.parent_factory&&this.parent_factory.hasPath(e)},e.prototype.addPathMapping=function(e,t){return this.paths[e]=t},e.prototype.addPathMappings=function(e,t){var r,i;for(i in e)r=e[i],this.paths[n.utils.pathJoin(t,i)]=r},e.prototype.hasPathMappings=function(e,t){var r,i,o,s;r=!0;for(s in e)i=e[s],r&=(o=this.creatorForPath(null,n.utils.pathJoin(t,s)))&&i===o;return r},e.prototype.creatorForPath=function(e,t){var r;return(r=this.paths[t])?r.view_model?r.view_model:r:this.parent_factory&&(r=this.parent_factory.creatorForPath(e,t))?r:null},e}()},function(e,t,r){(function(e){var t,n,i,o,s,a,l;s=null!=s?s:e,n=r(5),a=n._,i=n.ko,t=n.$,n.RECUSIVE_AUTO_INJECT=!0,i.bindingHandlers.inject={init:function(e,t,r,o){return n.Inject.inject(i.utils.unwrapObservable(t()),o,e,t,r)}},n.Inject=function(){function e(){}return e.inject=function(e,t,r,o,s,l){var u,c,d;return u=function(e){var i,u,c;if(a.isFunction(e))t=new e(t,r,o,s),n.releaseOnNodeRemove(t,r);else{e.view_model&&(t=new e.view_model(t,r,o,s),n.releaseOnNodeRemove(t,r));for(i in e)c=e[i],"view_model"!==i&&("create"===i?c(t,r,o,s):a.isObject(c)&&!a.isFunction(c)?(u=l||c&&c.create?{}:t,t[i]=n.Inject.inject(c,u,r,o,s,!0)):t[i]=c)}return t},l?u(e):(c=(d=i.dependentObservable(function(){return u(e)}))(),d.dispose(),c)},e.injectViewModels=function(e){var t,r,i,o,l,u,c,d,p,f;for(d=[],u=function(e){var t,r,n,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,n=0,i=o.length;i>n;n++)r=o[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+"}"),o=new Function("","return ( "+l+" )")(),o||(o={}),!o.options||(c=o.options,delete o.options),c||(c={}),r.view_model=n.Inject.inject(o,r.view_model,r.el,null,null,!0),t=r.view_model.afterBinding||c.afterBinding,i=r.view_model.beforeBinding||c.beforeBinding),i&&i(r.view_model,r.el,c),n.applyBindings(r.view_model,r.el,c),t&&t(r.view_model,r.el,c);return d},e}(),l=i.applyBindings,i.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()}):(o=function(){return"complete"!==document.readyState?setTimeout(o,0):n.injectViewModels()})())}).call(t,function(){return this}())},function(e,t,r){(function(t){var n,i,o,s,a,l;a=null!=a?a:t,s=r(18),i=function(e,t){var r,n;for(r in t)n=t[r],e[r]=n;return e};var u=function(){},c=function(e,t,r){var n;return n=t&&t.hasOwnProperty("constructor")?t.constructor:function(){e.apply(this,arguments)},i(n,e),u.prototype=e.prototype,n.prototype=new u,t&&i(n.prototype,t),r&&i(n,r),n.prototype.constructor=n,n.__super__=e.prototype,n},d=function(e,t){var r=c(this,e,t);return r.extend=this.extend,r};e.exports=o=function(){function e(){}var t;return e.VERSION="0.18.6",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;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||t instanceof e.Model||t instanceof e.Collection)return!1;if("function"==typeof t.dispose||"function"==typeof t.destroy||"function"==typeof t.release)return!0;if(1>r)for(n in t)if(i=t[n],"__kb"!==n&&e.isReleaseable(i,r+1))return!0;return!1},e.release=function(t){var r,n,i;if(e.isReleaseable(t))if(l.isArray(t))for(n in t)i=t[n],e.isReleaseable(i)&&(t[n]=null,e.release(i));else if(t.__kb_released=!0,s.isObservable(t)&&l.isArray(r=e.peek(t))){if(t.__kb_is_co||t.__kb_is_o&&t.valueType()===e.TYPE_COLLECTION)t.destroy?t.destroy():t.dispose&&t.dispose();else if(r.length)for(n in r)i=r[n],e.isReleaseable(i)&&(r[n]=null,e.release(i))}else"function"==typeof t.release?t.release():"function"==typeof t.destroy?t.destroy():"function"==typeof t.dispose?t.dispose():s.isObservable(t)||this.releaseKeys(t)},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 i,o,l;return null==n&&(n={}),(i=null!=a?a.document:void 0)?(o=i.createElement("div"),l=s.renderTemplate(t,r,n,o,"replaceChildren"),1===o.children.length&&(o=o.children[0]),e.releaseOnNodeRemove(r,o),l.dispose(),r.afterRender&&!n.afterRender&&r.afterRender(o),o):"undefined"!=typeof console&&null!==console?console.log("renderTemplate: document is undefined"):void 0},e.applyBindings=function(t,r){return s.applyBindings(t,r),e.releaseOnNodeRemove(t,r)},e.getValue=function(t,r,n){return t?l.isFunction(t[r])&&e.orm.useFunction(t,r)?t[r]():n?t.get.apply(t,l.map([r].concat(n),function(t){return e.peek(t)})):t.get(r):void 0},e.setValue=function(t,r,n){var i;if(t)return l.isFunction(t[r])&&e.orm.useFunction(t,r)?t[r](n):((i={})[r]=n,t.set(i))},e.ignore=(null!=(t=s.dependencyDetection)?t.ignore:void 0)||function(e,t,r){var n;return n=null,s.dependentObservable(function(){return n=e.apply(t,r||[])}).dispose(),n},e.extend=d,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 i,o,s;for(o=0,s=n.length;s>o;o++)i=n[o],t[i]=e._.bind(r[i],r)},e.peek=function(t){return s.isObservable(t)?t.peek?t.peek():e.ignore(function(){return t()}):t},e}(),a.Parse?(n=o.Parse=a.Parse,l=o._=a.Parse._):(n=o.Backbone=r(19),l=o._=r(20)),o.ko=s,o.Collection=n.Collection,o.Model=n.Object||n.Model,o.Events=n.Events,o.$=a.jQuery||a.$;try{o.$||(o.$=r(21))}catch(p){}}).call(t,function(){return this}())},function(e,t,r){var n,i,o;n=r(5),o=n._,i=n.ko,n.Observable=function(){function e(e,t,r){return this._vm=null!=r?r:{},n.ignore(function(r){return function(){var s,a,l;return t||n._throwMissing(r,"options"),s=r.create_options=o.isString(t)||i.isObservable(t)?{key:t}:n.utils.collapseOptions(t),r.key=s.key,delete s.key,r.key||n._throwMissing(r,"key"),!s.args||(r.args=s.args,delete s.args),!s.read||(r.read=s.read,delete s.read),!s.write||(r.write=s.write,delete s.write),a=s.event_watcher,delete s.event_watcher,r._vo=i.observable(null),r._model=i.observable(),l=n.utils.wrappedObservable(r,i.dependentObservable({read:function(){var e,t,s,a,l,u;for(l=r._model(),u=t=[r.key].concat(r.args||[]),s=0,a=u.length;a>s;s++)e=u[s],i.utils.unwrapObservable(e);return r.read?r.update(r.read.apply(r._vm,t)):o.isUndefined(l)||n.ignore(function(){return r.update(n.getValue(l,n.peek(r.key),r.args))}),i.utils.unwrapObservable(r._vo())},write:function(e){return n.ignore(function(){var t,i;return t=n.utils.unwrapModels(e),i=n.peek(r._model),r.write?(r.write.call(r._vm,t),e=n.getValue(i,n.peek(r.key),r.args)):i&&n.setValue(i,n.peek(r.key),t),r.update(e)})},owner:r._vm})),l.__kb_is_o=!0,s.store=n.utils.wrappedStore(l,s.store),s.path=n.utils.pathJoin(s.path,r.key),s.factories&&("function"==typeof s.factories||s.factories.create)?(s.factory=n.utils.wrappedFactory(l,new n.Factory(s.factory)),s.factory.addPathMapping(s.path,s.factories)):s.factory=n.Factory.useOptionsOrCreate(s,l,s.path),delete s.factories,n.publishMethods(l,r,["value","valueType","destroy"]),l.model=r.model=i.dependentObservable({read:function(){return i.utils.unwrapObservable(r._model)},write:function(e){return n.ignore(function(){var t;if(!r.__kb_released&&n.peek(r._model)!==e)return t=n.getValue(e,n.peek(r.key),r.args),r._model(e),e?o.isUndefined(t)?void 0:r.update(t):r.update(null)})}}),n.EventWatcher.useOptionsOrCreate({event_watcher:a},e,r,{emitter:r.model,update:o.bind(r.update,r),key:r.key,path:s.path}),r.__kb_value||r.update(),n.LocalizedObservable&&s.localizer&&(l=new s.localizer(l),delete s.localizer),n.DefaultObservable&&s.hasOwnProperty("default")&&(l=n.defaultObservable(l,s["default"]),delete s["default"]),l}}(this))}return e.prototype.destroy=function(){var e;return e=n.utils.wrappedObservable(this),this.__kb_released=!0,n.release(this.__kb_value),this.__kb_value=null,this.model.dispose(),this.model=e.model=null,n.utils.wrappedDestroy(this)},e.prototype.value=function(){return this.__kb_value},e.prototype.valueType=function(){var e;return e=n.getValue(n.peek(this._model),n.peek(this.key)),this.value_type||this._updateValueObservable(e),this.value_type},e.prototype.update=function(e){var t,r;if(!this.__kb_released){if(arguments.length||(e=n.getValue(n.peek(this._model),n.peek(this.key))),void 0!==e||(e=null),t=n.utils.valueType(e),(!this.__kb_value||this.__kb_value.__kb_released||this.__kb_value.__kb_null&&e)&&(this.__kb_value=void 0,this.value_type=void 0),r=this.__kb_value,o.isUndefined(this.value_type)||this.value_type!==t&&t!==n.TYPE_UNKNOWN)return this.value_type===n.TYPE_COLLECTION&&t===n.TYPE_ARRAY?r(e):this._updateValueObservable(e);if(this.value_type===n.TYPE_MODEL){if("function"==typeof r.model){if(r.model()!==e)return r.model(e)}else if(n.utils.wrappedObject(r)!==e)return this._updateValueObservable(e)}else if(this.value_type===n.TYPE_COLLECTION){if(r.collection()!==e)return r.collection(e)}else if(r()!==e)return r(e)}},e.prototype._updateValueObservable=function(e){var t,r,s,a;return t=this.create_options,t.creator=n.utils.inferCreator(e,t.factory,t.path,n.peek(this._model),this.key),this.value_type=n.TYPE_UNKNOWN,r=t.creator,s=this.__kb_value,this.__kb_value=void 0,s&&n.release(s),r?t.store?a=t.store.findOrCreate(e,t):r.models_only?(a=e,this.value_type=n.TYPE_SIMPLE):a=r.create?r.create(e,t):new r(e,t):o.isArray(e)?(this.value_type=n.TYPE_ARRAY,a=i.observableArray(e)):(this.value_type=n.TYPE_SIMPLE,a=i.observable(e)),this.value_type===n.TYPE_UNKNOWN&&(i.isObservable(a)?this.value_type=a.__kb_is_co?n.TYPE_COLLECTION:n.TYPE_SIMPLE:(this.value_type=n.TYPE_MODEL,"function"!=typeof a.model&&n.utils.wrappedObject(a,e))),this.__kb_value=a,this._vo(a)},e}(),n.observable=function(e,t,r){return new n.Observable(e,t,r)}},function(e,t,r){(function(e){var t,n,i,o,s,a,l,u,c,d;c="undefined"!=typeof window&&null!==window?window:e,u=r(5),d=u._,n=function(){function e(){this.adapters=[]}return e.prototype.initialize=function(){return this.adapters=d.select(this.adapters,function(e){return e.isAvailable()}),this.initialized=!0},e.prototype.addAdapter=function(e){return this.adapters.push(e),this.initialized=!1},e.prototype.keys=function(){return this._call("keys",arguments)},e.prototype.bind=function(){return this._call("bind",arguments)},e.prototype.useFunction=function(){return this._call("useFunction",arguments)},e.prototype._call=function(e,t){var r,n,i,o,s;if(this.adapters.length)for(this.initialized||this.initialize(),s=this.adapters,i=0,o=s.length;o>i;i++)if(r=s[i],r[e]&&(n=r[e].apply(r,t)))return n},e}(),u.orm=new n,a=null,o=function(){function e(){}return e.prototype.isAvailable=function(){var e;return!!(a=null!=(e=u.Backbone)?e.RelationalModel:void 0)},e.prototype.relationType=function(e,t){var r;return e instanceof a&&(r=d.find(e.getRelations(),function(e){return e.key===t}))?r.collectionType||d.isArray(r.keyContents)?u.TYPE_COLLECTION:u.TYPE_MODEL:null},e.prototype.bind=function(e,t,r,n){var i,o,s,a,l,c;if(!(a=this.relationType(e,t)))return null;if(s=function(e){return!u.statistics||u.statistics.addModelEvent({name:"update (relational)",model:e,key:t,path:n}),r()},o=u.Backbone.Relation.prototype.sanitizeOptions?["update","add","remove"]:["change","add","remove"],a===u.TYPE_COLLECTION)for(l=0,c=o.length;c>l;l++)i=o[l],e.bind(""+i+":"+t,s);else e.bind(""+o[0]+":"+t,s);return function(){var r,n;if(a===u.TYPE_COLLECTION)for(r=0,n=o.length;n>r;r++)i=o[r],e.unbind(""+i+":"+t,s);else e.unbind(""+o[0]+":"+t,s)}},e}(),u.orm.addAdapter(new o),t=null,i=function(){function e(){}return e.prototype.isAvailable=function(){var e;return!!(t=null!=(e=u.Backbone)?e.AssociatedModel:void 0)},e.prototype.keys=function(e){return e instanceof t?d.map(e.relations,function(e){return e.key}):null},e.prototype.relationType=function(e,r){var n;return e instanceof t&&(n=d.find(e.relations,function(e){return e.key===r}))?"Many"===n.type?u.TYPE_COLLECTION:u.TYPE_MODEL:null},e}(),u.orm.addAdapter(new i),l=null,s=function(){function e(){}return e.prototype.isAvailable=function(){return!!(l=c.Supermodel)},e.prototype.keys=function(e){return e instanceof l.Model?d.keys(e.constructor.associations()):null},e.prototype.relationType=function(e,t){var r;return e instanceof l.Model&&(r=e.constructor.associations()[t])?r.add?u.TYPE_COLLECTION:u.TYPE_MODEL:null},e.prototype.bind=function(e,t,r,n){var i,o;return(o=this.relationType(e,t))?(i=function(e,i){var o,s;return!u.statistics||u.statistics.addModelEvent({name:"update (supermodel)",model:e,key:t,path:n}),s=e.constructor.associations()[t],o=e[s.store],e[s.store]=i,r(i),e[s.store]=o},o===u.TYPE_MODEL?(e.bind("associate:"+t,i),function(){return e.unbind("associate:"+t,i)}):void 0):null},e.prototype.useFunction=function(e,t){return!!this.relationType(e,t)},e}(),u.orm.addAdapter(new s)}).call(t,function(){return this}())},function(e,t,r){var n,i;n=r(5),i=n._,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=i.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=i.indexOf(n,t),0>r&&"undefined"!=typeof console&&null!==console&&console.log("kb.Statistics: failed to unregister type: "+e),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,i,o;t="",o=this.registered_tracker;for(r in o)n=o[r],n.length&&(i&&(t+="\n "),t+=""+(r?r:"No Name")+": "+n.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}()},function(e,t,r){var n,i,o;n=r(5),o=n._,i=n.ko,e.exports=n.Store=function(){function e(){this.observable_records=[],this.replaced_observables=[]}return e.useOptionsOrCreate=function(e,t,r){return e.store?(e.store.register(t,r,e),n.utils.wrappedStore(r,e.store)):(n.utils.wrappedStoreIsOwned(r,!0),n.utils.wrappedStore(r,new n.Store))},e.prototype.destroy=function(){return this.clear()},e.prototype.clear=function(){var e,t,r,i;for(i=this.observable_records.splice(0,this.observable_records.length),t=0,r=i.length;r>t;t++)e=i[t],n.release(e.observable);n.release(this.replaced_observables)},e.prototype.compact=function(){var e,t,r,n,i;r=[],n=this.observable_records;for(e in n)t=n[e],(null!=(i=t.observable)?i.__kb_released:void 0)&&r.push(t);r.length&&(this.observable_records=o.difference(this.observable_records,r))},e.prototype.register=function(e,t,r){var o;if(t&&!i.isObservable(t)&&!t.__kb_is_co)return n.utils.wrappedObject(t,e),e||(t.__kb_null=!0),o=r.creator?r.creator:r.path&&r.factory?r.factory.creatorForPath(e,r.path):null,o||(o=t.constructor),this.observable_records.push({obj:e,observable:t,creator:o}),t},e.prototype.findIndex=function(e,t){var r,i,s,a;if(s=[],!e||e instanceof n.Model){a=this.observable_records;for(r in a)if(i=a[r],i.observable)if(i.observable.__kb_released)s.push(i);else if((e||i.observable.__kb_null)&&(!e||!i.observable.__kb_null&&i.obj===e)&&(i.creator===t||i.creator.create&&i.creator.create===t.create))return s.length?(this.observable_records=o.difference(this.observable_records,s),o.indexOf(this.observable_records,i)):r}return s.length&&(this.observable_records=o.difference(this.observable_records,s)),-1},e.prototype.find=function(e,t){var r;return(r=this.findIndex(e,t))<0?null:this.observable_records[r].observable},e.prototype.isRegistered=function(e){var t,r,n,i;for(i=this.observable_records,r=0,n=i.length;n>r;r++)if(t=i[r],t.observable===e)return!0;return!1},e.prototype.findOrCreate=function(e,t){var r,o;return t.store=this,t.creator||(t.creator=n.utils.inferCreator(e,t.factory,t.path)),!t.creator&&e instanceof n.Model&&(t.creator=n.ViewModel),(r=t.creator)?r.models_only?e:(r&&(o=this.find(e,r)),o?o:(o=n.ignore(function(){return function(){return o=r.create?r.create(e,t):new r(e,t),o||i.observable(null)}}(this)),i.isObservable(o)||this.isRegistered(o)||this.register(e,o,t),o)):n.utils.createFromDefaultCreator(e,t)},e.prototype.findOrReplace=function(e,t,r){var i,o;return e||n._throwUnexpected(this,"obj missing"),(i=this.findIndex(e,t))<0?this.register(e,r,{creator:t}):(o=this.observable_records[i],n.utils.wrappedObject(o.observable)===e||n._throwUnexpected(this,"different object"),o.observable!==r&&(o.observable.constructor===r.constructor||n._throwUnexpected(this,"replacing different type"),this.replaced_observables.push(o.observable),o.observable=r),r)},e}()},function(e,t,r){var n,i,o,s,a,l,u,c;n=r(5),o=n._,i=n.ko,c=n._wrappedKey=function(e,t,r){return 2===arguments.length?e&&e.__kb&&e.__kb.hasOwnProperty(t)?e.__kb[t]:void 0:(e||n._throwUnexpected(this,"no obj for wrapping "+t),e.__kb||(e.__kb={}),e.__kb[t]=r,r)},s=function(e,t){return Array.prototype.splice.call(e,1,0,t),e},l=function(e,t,r){return e[t]||(e[t]=[]),o.isArray(r)||(r=[r]),e[t]=e[t].length?o.union(e[t],r):r,e},u=function(e,t,r){return e[t]||(e[t]={}),o.extend(e[t],r)},a=function(e){var t,r,n,i;for(r={},n=0,i=e.length;i>n;n++)t=e[n],r[t]={key:t};return r},n.utils=function(){function e(){}return e.wrappedObservable=function(){return c.apply(this,s(arguments,"observable"))},e.wrappedObject=function(){return c.apply(this,s(arguments,"object"))},e.wrappedModel=function(e,t){return 1===arguments.length?(t=c(e,"object"),o.isUndefined(t)?e:t):c(e,"object",t)},e.wrappedStore=function(){return c.apply(this,s(arguments,"store"))},e.wrappedStoreIsOwned=function(){return c.apply(this,s(arguments,"store_is_owned"))},e.wrappedFactory=function(){return c.apply(this,s(arguments,"factory"))},e.wrappedEventWatcher=function(){return c.apply(this,s(arguments,"event_watcher"))},e.wrappedEventWatcherIsOwned=function(){return c.apply(this,s(arguments,"event_watcher_is_owned"))},e.wrappedDestroy=function(e){var t;if(e.__kb)return e.__kb.event_watcher&&e.__kb.event_watcher.releaseCallbacks(e),t=e.__kb,e.__kb=null,t.observable&&(t.observable.destroy=t.observable.release=null,this.wrappedDestroy(t.observable),t.observable=null),t.factory=null,t.event_watcher_is_owned&&t.event_watcher.destroy(),t.event_watcher=null,t.store_is_owned&&t.store.destroy(),t.store=null},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:o.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 o.defaults({path:this.pathJoin(e.path,t)},e)},e.inferCreator=function(e,t,r){var i;return t&&(i=t.creatorForPath(e,r)),i?i:e?e instanceof n.Model?n.ViewModel:e instanceof n.Collection?n.CollectionObservable:null:null},e.createFromDefaultCreator=function(e,t){return e instanceof n.Model?n.viewModel(e,t):e instanceof n.Collection?n.collectionObservable(e,t):o.isArray(e)?i.observableArray(e):i.observable(e)},e.hasModelSignature=function(e){return e&&e.attributes&&!e.models&&"function"==typeof e.get&&"function"==typeof e.trigger},e.hasCollectionSignature=function(e){return e&&e.models&&"function"==typeof e.get&&"function"==typeof e.trigger },e.collapseOptions=function(e){var t,r,n,i;for(r={},e={options:e};e.options;){i=e.options;for(t in i)switch(n=i[t],t){case"internals":case"requires":case"excludes":case"statics":l(r,t,n);break;case"keys":o.isObject(n)&&!o.isArray(n)||o.isObject(r[t])&&!o.isArray(r[t])?(o.isObject(n)||(n=[n]),o.isArray(n)&&(n=a(n)),o.isArray(r[t])&&(r[t]=a(r[t])),u(r,t,n)):l(r,t,n);break;case"factories":o.isFunction(n)?r[t]=n:u(r,t,n);break;case"static_defaults":u(r,t,n);break;case"options":break;default:r[t]=n}e=e.options}return r},e.unwrapModels=function(e){var t,r,i;if(!e)return e;if(e.__kb)return"object"in e.__kb?e.__kb.object:e;if(o.isArray(e))return o.map(e,function(e){return n.utils.unwrapModels(e)});if(o.isObject(e)&&e.constructor==={}.constructor){r={};for(t in e)i=e[t],r[t]=n.utils.unwrapModels(i);return r}return e},e}()},function(e,t,r){var n,i,o;n=r(5),o=n._,i=n.ko,n.ViewModel=function(){function e(e,t,r){return n.ignore(function(s){return function(){var a,l,u,c,d,p,f,_,b,h;if(!e||e instanceof n.Model||"function"==typeof e.get&&"function"==typeof e.bind||n._throwUnexpected(s,"not a model"),t||(t={}),r||(r={}),t=o.isArray(t)?{keys:t}:n.utils.collapseOptions(t),s.__kb||(s.__kb={}),s.__kb.vm_keys={},s.__kb.model_keys={},s.__kb.view_model=o.isUndefined(r)?s:r,!t.internals||(s.__kb.internals=t.internals),!t.excludes||(s.__kb.excludes=t.excludes),!t.statics||(s.__kb.statics=t.statics),!t.static_defaults||(s.__kb.static_defaults=t.static_defaults),n.Store.useOptionsOrCreate(t,e,s),s.__kb.path=t.path,n.Factory.useOptionsOrCreate(t,s,t.path),b=n._wrappedKey(s,"_mdl",i.observable()),s.model=i.dependentObservable({read:function(){return b(),n.utils.wrappedObject(s)},write:function(e){return n.ignore(function(){var t,r,i,a;if(n.utils.wrappedObject(s)!==e){if(s.__kb_null)return void(!e||n._throwUnexpected(s,"model set on shared null"));if(n.utils.wrappedObject(s,e),t=n.utils.wrappedEventWatcher(s),!t)return void b(e);t.emitter(e),!s.__kb.keys&&e&&e.attributes&&(r=o.keys(e.attributes),e&&(a=n.orm.keys(e))&&(r=o.union(r,a)),i=o.difference(r,o.keys(s.__kb.model_keys)),i&&s.createObservables(e,i)),b(e)}})}}),u=n.utils.wrappedEventWatcher(s,new n.EventWatcher(e,s,{emitter:s.model})),c=t.requires,s.__kb.internals&&(c=o.union(c||[],s.__kb.internals)),e&&(f=n.orm.keys(e))&&(c=o.union(c||[],f)),t.keys)if(o.isObject(t.keys)&&!o.isArray(t.keys)){d={},h=t.keys;for(_ in h)p=h[_],d[o.isString(p)?p:p.key?p.key:_]=!0;s.__kb.keys=o.keys(d)}else s.__kb.keys=t.keys,c=c?o.union(c,s.__kb.keys):o.clone(s.__kb.keys);else l=u.emitter(),l&&l.attributes&&(a=o.keys(l.attributes),c=c?o.union(c,a):a);return c&&s.__kb.excludes&&(c=o.difference(c,s.__kb.excludes)),c&&s.__kb.statics&&(c=o.difference(c,s.__kb.statics)),o.isObject(t.keys)&&!o.isArray(t.keys)&&s.mapObservables(e,t.keys),o.isObject(t.requires)&&!o.isArray(t.requires)&&s.mapObservables(e,t.requires),!t.mappings||s.mapObservables(e,t.mappings),!c||s.createObservables(e,c),!s.__kb.statics||s.createObservables(e,s.__kb.statics,!0),!n.statistics||n.statistics.register("ViewModel",s),s}}(this))}return e.extend=n.extend,e.prototype.destroy=function(){var e;if(this.__kb.view_model!==this)for(e in this.__kb.vm_keys)this.__kb.view_model[e]=null;return this.__kb.view_model=null,n.releaseKeys(this),n.utils.wrappedDestroy(this),!n.statistics||n.statistics.unregister("ViewModel",this)},e.prototype.shareOptions=function(){return{store:n.utils.wrappedStore(this),factory:n.utils.wrappedFactory(this)}},e.prototype.createObservables=function(e,t,r){var i,s,a,l,u,c;for(r?a=this.__kb.static_defaults||{}:i={store:n.utils.wrappedStore(this),factory:n.utils.wrappedFactory(this),path:this.__kb.path,event_watcher:n.utils.wrappedEventWatcher(this)},u=0,c=t.length;c>u;u++)s=t[u],l=this.__kb.internals&&o.contains(this.__kb.internals,s)?"_"+s:s,this[l]||(this.__kb.vm_keys[l]=this.__kb.model_keys[s]=!0,r?e.has(l)?this[l]=this.__kb.view_model[l]=e.get(l):l in a&&(this[l]=this.__kb.view_model[l]=a[l]):(i.key=s,this[l]=this.__kb.view_model[l]=n.observable(e,i,this)))},e.prototype.mapObservables=function(e,t){var r,i,s;r={store:n.utils.wrappedStore(this),factory:n.utils.wrappedFactory(this),path:this.__kb.path,event_watcher:n.utils.wrappedEventWatcher(this)};for(s in t)i=t[s],this[s]||(i=o.isString(i)?{key:i}:o.clone(i),i.key||(i.key=s),this.__kb.vm_keys[s]=this.__kb.model_keys[i.key]=!0,this[s]=this.__kb.view_model[s]=n.observable(e,o.defaults(i,r),this))},e}(),n.viewModel=function(e,t,r){return new n.ViewModel(e,t,r)}},function(e,t,r){var n,i,o,s,a;if(e.exports=n=r(5),n.modules={underscore:n._,backbone:n.Parse||n.Backbone,knockout:n.ko},"undefined"!=typeof window&&null!==window)for(a=["_","Backbone","Parse","ko","$"],o=0,s=a.length;s>o;o++)i=a[o],n[i]&&!window.hasOwnProperty(i)&&(window[i]=n[i])},function(e,t,r){var n,i,o;n=r(5),o=n._,i=n.ko,r(22),e.exports=n.DefaultObservable=function(){function e(e,t){var r;return this.dv=t,r=n.utils.wrappedObservable(this,i.dependentObservable({read:function(t){return function(){var r;return(r=i.utils.unwrapObservable(e()))?r:i.utils.unwrapObservable(t.dv)}}(this),write:function(t){return e(t)}})),n.publishMethods(r,this,["destroy","setToDefault"]),r}return e.prototype.destroy=function(){return n.utils.wrappedDestroy(this)},e.prototype.setToDefault=function(){return n.utils.wrappedObservable(this)(this.dv)},e}(),n.defaultObservable=function(e,t){return new n.DefaultObservable(e,t)}},function(e,t,r){var n,i,o,s;i=r(5),s=i._,o=i.ko,n=Array.prototype.slice,i.toFormattedString=function(e){var t,r,i,a,l,u;l=e.slice(),r=n.call(arguments,1);for(i in r)for(t=r[i],u=o.utils.unwrapObservable(t),(s.isUndefined(u)||s.isNull(u))&&(u=""),a=e.indexOf("{"+i+"}");a>=0;)l=l.replace("{"+i+"}",u),a=e.indexOf("{"+i+"}",a+1);return l},i.parseFormattedString=function(e,t){var r,n,i,o,a,l,u,c,d,p,f,_,b;for(p=t.slice(),i=0,l=0,c={};p.search("\\{"+i+"\\}")>=0;){for(u=t.indexOf("{"+i+"}");u>=0;)p=p.replace("{"+i+"}","(.*)"),c[u]=i,l++,u=t.indexOf("{"+i+"}",u+1);i++}if(r=i,d=new RegExp(p),a=d.exec(e),a&&a.shift(),!a||a.length!==l){for(f=[];r-->0;)f.push("");return f}b=s.sortBy(s.keys(c),function(e){return parseInt(e,10)}),n={};for(o in b)u=b[o],i=c[u],n.hasOwnProperty(i)||(n[i]=o);for(_=[],i=0;r>i;)_.push(a[n[i]]),i++;return _},e.exports=i.FormattedObservable=function(){function e(e,t){var r,a;return s.isArray(t)?(e=e,a=t):a=n.call(arguments,1),r=i.utils.wrappedObservable(this,o.dependentObservable({read:function(){var r,n,s;for(t=[o.utils.unwrapObservable(e)],n=0,s=a.length;s>n;n++)r=a[n],t.push(o.utils.unwrapObservable(r));return i.toFormattedString.apply(null,t)},write:function(t){var r,n,s;for(n=i.parseFormattedString(t,o.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 i.utils.wrappedDestroy(this)},e}(),i.formattedObservable=function(e){return new i.FormattedObservable(e,n.call(arguments,1))}},function(e,t,r){var n,i,o;n=r(5),o=n._,i=n.ko,n.locale_manager||(n.locale_manager=void 0),e.exports=n.LocalizedObservable=function(){function e(e,t,r){var s;return this.value=e,this.vm=r,t||(t={}),this.vm||(this.vm={}),this.read||n._throwMissing(this,"read"),n.locale_manager||n._throwMissing(this,"kb.locale_manager"),this.__kb||(this.__kb={}),this.__kb._onLocaleChange=o.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),s=n.utils.wrappedObservable(this,i.dependentObservable({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||n._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})),n.publishMethods(s,this,["destroy","observedValue","resetToCurrent"]),n.locale_manager.bind("change",this.__kb._onLocaleChange),t.hasOwnProperty("default")&&(s=n.DefaultObservable&&i.defaultObservable(s,t["default"])),s}return e.extend=n.extend,e.prototype.destroy=function(){return n.locale_manager.unbind("change",this.__kb._onLocaleChange),this.vm=null,n.utils.wrappedDestroy(this)},e.prototype.resetToCurrent=function(){var e,t;return t=n.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}(),n.localizedObservable=function(e,t,r){return new n.LocalizedObservable(e,t,r)}},function(e,t,r){var n,i,o;n=r(5),o=n._,i=n.ko,e.exports=n.TriggeredObservable=function(){function e(e,t){var r;return this.event_selector=t,e||n._throwMissing(this,"emitter"),this.event_selector||n._throwMissing(this,"event_selector"),this.vo=i.observable(),r=n.utils.wrappedObservable(this,i.dependentObservable(function(e){return function(){return e.vo()}}(this))),n.publishMethods(r,this,["destroy"]),n.utils.wrappedEventWatcher(this,new n.EventWatcher(e,this,{emitter:o.bind(this.emitter,this),update:o.bind(this.update,this),event_selector:this.event_selector})),r}return e.prototype.destroy=function(){return n.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}(),n.triggeredObservable=function(e,t){return new n.TriggeredObservable(e,t)}},function(e,t,r){var n,i,o,s,a;o=r(5),a=o._,s=o.ko,n=o.$,r(23),i=function(e){return e=s.utils.unwrapObservable(e),"function"==typeof e?e.apply(null,Array.prototype.slice.call(arguments,1)):e},e.exports=o.Validation=function(){function e(){}return e}(),o.valueValidator=function(e,t,r){return null==r&&(r={}),r&&!("function"==typeof r)||(r={}),s.dependentObservable(function(){var n,o,l,u,c,d,p,f;p={$error_count:0},o=s.utils.unwrapObservable(e),!("disable"in r)||(l=i(r.disable)),!("enable"in r)||(l=!i(r.enable)),d=r.priorities||[],a.isArray(d)||(d=[d]),n=d.length+1;for(u in t)f=t[u],p[u]=!l&&i(f,o),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})},o.inputValidator=function(e,t,r){var i,s,l,u,c,d,p,f,_,b;if(null==r&&(r={}),r&&!("function"==typeof r)||(r={}),_=o.valid,i=n(t),(u=i.attr("name"))&&!a.isString(u)&&(u=null),!(s=i.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=i.attr("type")]||(s[p]=_[p]),!i.attr("required")||(s.required=_.required),c.validations){b=c.validations;for(l in b)f=b[l],s[l]=f}return d=o.valueValidator(c.value,s,r),!u&&!r.no_attach||(e["$"+u]=d),d},o.formValidator=function(e,t){var r,i,l,u,c,d,p,f,_,b,h,v,y;for(p={},b=[],r=n(t),(l=r.attr("name"))&&!a.isString(l)&&(l=null),(i=r.attr("data-bind"))&&(d=new Function("sc","with(sc[0]) { return { "+i+" } }")([e]),f=d.validation_options),f||(f={}),f.no_attach=!!l,y=r.find("input"),h=0,v=y.length;v>h;h++)u=y[h],(c=n(u).attr("name"))&&(_=o.inputValidator(e,u,f),!_||b.push(p[c]=_));return p.$error_count=s.dependentObservable(function(){var e,t,r;for(e=0,t=0,r=b.length;r>t;t++)_=b[t],e+=_().$error_count;return e}),p.$valid=s.dependentObservable(function(){return 0===p.$error_count()}),p.$enabled=s.dependentObservable(function(){var e,t,r;for(e=!0,t=0,r=b.length;r>t;t++)_=b[t],e&=_().$enabled;return e}),p.$disabled=s.dependentObservable(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,i,o;n=r(5),o=n._,i=n.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(i.isObservable(e))"function"==typeof e.setToDefault&&e.setToDefault();else if(o.isObject(e))for(t in e)r=e[t],!r||!i.isObservable(r)&&"function"==typeof r||"_"===t[0]&&!t.search("__kb")||this.setToDefault(r);return e}}},function(e,t,r){var n,i,o,s,a,l,u;a=r(5),u=a._,l=a.ko,n=a.$,s=/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/,i=/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/,o=/^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/,a.valid={required:function(e){return!e},url:function(e){return!s.test(e)},email:function(e){return!i.test(e)},number:function(e){return!o.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.length