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