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