/* knockback-full-stack.js 0.19.0 Copyright (c) 2011-2014 Kevin Malakoff. License: MIT (http://www.opensource.org/licenses/mit-license.php) Source: https://github.com/kmalakoff/knockback Dependencies: Knockout.js, Backbone.js, and Underscore.js (or LoDash.js). Optional dependencies: Backbone.ModelRef.js and BackboneORM. */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof exports?exports.kb=t(require("jquery")):e.kb=t(e.jQuery)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){n(1),n(2),n(3),n(4),n(5),n(6),n(7),n(8),n(9),n(10),n(11),n(13),n(14),n(15),n(16),n(17),e.exports=n(12)},function(e,t,n){var r,i,o,s,a,l,u=[].indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(t in this&&this[t]===e)return t;return-1};s=n(5),l=s._,a=s.ko,o=0,r=-1,i=1,s.compare=function(e,t){return l.isString(e)?e.localeCompare(""+t):l.isString(t)?t.localeCompare(""+e):e===t?o:t>e?r:i},s.CollectionObservable=function(){function e(e,t){return s.ignore(function(n){return function(){var r,i,o;return!l.isUndefined(t)||e instanceof s.Collection?l.isArray(e)&&(e=new s.Collection(e)):(o=[new s.Collection,e],e=o[0],t=o[1]),t||(t={}),i=s.utils.wrappedObservable(n,a.observableArray([])),i.__kb_is_co=!0,n.in_edit=0,n.__kb||(n.__kb={}),n.__kb._onCollectionChange=l.bind(n._onCollectionChange,n),t=s.utils.collapseOptions(t),t.auto_compact&&(n.auto_compact=!0),n._comparator=a.observable(t.sort_attribute?n._attributeComparator(t.sort_attribute):t.comparator),n._filters=a.observableArray(t.filters?l.isArray(t.filters)?t.filters:t.filters?[t.filters]:void 0:[]),r=n.create_options={store:s.Store.useOptionsOrCreate(t,e,i)},n.path=t.path,r.factory=s.utils.wrappedFactory(i,n._shareOrCreateFactory(t)),r.path=s.utils.pathJoin(t.path,"models"),r.creator=r.factory.creatorForPath(null,r.path),r.creator&&(n.models_only=r.creator.models_only),s.publishMethods(i,n,["destroy","shareOptions","filters","comparator","sortAttribute","viewModelByModel","hasViewModels"]),n._collection=a.observable(e),i.collection=n.collection=a.dependentObservable({read:function(){return n._collection()},write:function(e){return s.ignore(function(){var t;if((t=n._collection())!==e)return t&&t.unbind("all",n.__kb._onCollectionChange),e&&e.bind("all",n.__kb._onCollectionChange),n._collection(e)})}}),e&&e.bind("all",n.__kb._onCollectionChange),n._mapper=a.dependentObservable(function(){var e,t,r,o,u,c,d,p;if(e=n._comparator(),o=n._filters())for(d=0,p=o.length;p>d;d++)r=o[d],a.utils.unwrapObservable(r);return t=n._collection(),n.in_edit?void 0:(i=s.utils.wrappedObservable(n),t&&(u=t.models),u&&0!==t.models.length?(u=l.filter(u,function(e){return!o.length||n._selectModel(e)}),c=e?l.map(u,function(e){return n._createViewModel(e)}).sort(e):n.models_only?o.length?u:u.slice():l.map(u,function(e){return n._createViewModel(e)})):c=[],n.in_edit++,i(c),n.in_edit--)}),i.subscribe(l.bind(n._onObservableArrayChange,n)),!s.statistics||s.statistics.register("CollectionObservable",n),i}}(this))}return e.extend=s.extend,e.prototype.destroy=function(){var e,t,n;return n=s.utils.wrappedObservable(this),t=s.peek(this._collection),t&&(t.unbind("all",this.__kb._onCollectionChange),e=s.peek(n),e.splice(0,e.length)),this.collection.dispose(),this._collection=n.collection=this.collection=null,this._mapper.dispose(),this._mapper=null,s.release(this._filters),this._filters=null,this._comparator(null),this._comparator=null,this.create_options=null,n.collection=null,s.utils.wrappedDestroy(this),!s.statistics||s.statistics.unregister("CollectionObservable",this)},e.prototype.shareOptions=function(){var e;return e=s.utils.wrappedObservable(this),{store:s.utils.wrappedStore(e),factory:s.utils.wrappedFactory(e)}},e.prototype.filters=function(e){return this._filters(e?l.isArray(e)?e:[e]:[])},e.prototype.comparator=function(e){return this._comparator(e)},e.prototype.sortAttribute=function(e){return this._comparator(e?this._attributeComparator(e):null)},e.prototype.viewModelByModel=function(e){var t;return this.models_only?null:(t=e.hasOwnProperty(e.idAttribute)?e.idAttribute:"cid",l.find(s.peek(s.utils.wrappedObservable(this)),function(n){var r;return(null!=n&&null!=(r=n.__kb)?r.object:void 0)?n.__kb.object[t]===e[t]:!1}))},e.prototype.hasViewModels=function(){return!this.models_only},e.prototype.compact=function(){return s.ignore(function(e){return function(){var t;return t=s.utils.wrappedObservable(e),s.utils.wrappedStoreIsOwned(t)?(s.utils.wrappedStore(t).clear(),e._collection.notifySubscribers(e._collection())):void 0}}(this))},e.prototype._shareOrCreateFactory=function(e){var t,n,r,i;if(t=s.utils.pathJoin(e.path,"models"),r=e.factories,(i=e.factory)&&(n=i.creatorForPath(null,t))&&(!r||r.models===n)){if(!r)return i;if(i.hasPathMappings(r,e.path))return i}return i=new s.Factory(e.factory),r&&i.addPathMappings(r,e.path),i.creatorForPath(null,t)||(e.hasOwnProperty("models_only")?e.models_only?i.addPathMapping(t,{models_only:!0}):i.addPathMapping(t,s.ViewModel):e.view_model?i.addPathMapping(t,e.view_model):e.create?i.addPathMapping(t,{create:e.create}):i.addPathMapping(t,s.ViewModel)),i},e.prototype._onCollectionChange=function(e,t){return s.ignore(function(n){return function(){var r,i,o,a;if(!n.in_edit)switch(e){case"reset":n.auto_compact?n.compact():n._collection.notifySubscribers(n._collection());break;case"sort":case"resort":n._collection.notifySubscribers(n._collection());break;case"new":case"add":if(!n._selectModel(t))return;if(o=s.utils.wrappedObservable(n),r=n._collection(),-1===r.indexOf(t))return;if(a=n.viewModelByModel(t))return;n.in_edit++,a=n._createViewModel(t),(i=n._comparator())?(o().push(a),o.sort(i)):o.splice(r.indexOf(t),0,a),n.in_edit--;break;case"remove":case"destroy":n._onModelRemove(t);break;case"change":n._selectModel(t)?(a=n.models_only?t:n.viewModelByModel(t),a?(i=n._comparator())&&(o=s.utils.wrappedObservable(n),n.in_edit++,o.sort(i),n.in_edit--):n._onCollectionChange("add",t)):n._onModelRemove(t)}}}(this))},e.prototype._onModelRemove=function(e){var t,n;return(n=this.models_only?e:this.viewModelByModel(e))?(t=s.utils.wrappedObservable(this),this.in_edit++,t.remove(n),this.in_edit--):void 0},e.prototype._onObservableArrayChange=function(e){return s.ignore(function(t){return function(){var n,r,i,o,a,u,c,d,p;if(!t.in_edit&&(t.models_only&&(!e.length||s.utils.hasModelSignature(e[0]))||!t.models_only&&(!e.length||l.isObject(e[0])&&!s.utils.hasModelSignature(e[0]))||s._throwUnexpected(t,"incorrect type passed"),a=s.utils.wrappedObservable(t),n=s.peek(t._collection),r=s.peek(t._filters).length,n)){if(c=e,t.models_only)o=l.filter(e,function(e){return!r||t._selectModel(e)});else for(!r||(c=[]),o=[],d=0,p=e.length;p>d;d++){if(u=e[d],i=s.utils.wrappedObject(u),r){if(!t._selectModel(i))continue;c.push(u)}t.create_options.store.findOrReplace(i,t.create_options.creator,u),o.push(i)}t.in_edit++,e.length===c.length||a(c),l.isEqual(n.models,o)||n.reset(o),t.in_edit--}}}(this))},e.prototype._attributeComparator=function(e){var t;return t=function(t,n){var r;return r=a.utils.unwrapObservable(e),s.compare(t.get(r),n.get(r))},this.models_only?t:function(e,n){return t(s.utils.wrappedModel(e),s.utils.wrappedModel(n))}},e.prototype._createViewModel=function(e){return this.models_only?e:this.create_options.store.findOrCreate(e,this.create_options)},e.prototype._selectModel=function(e){var t,n,r,i,o;for(n=s.peek(this._filters),r=0,i=n.length;i>r;r++)if(t=n[r],t=s.peek(t),l.isFunction(t)){if(!t(e))return!1}else if(l.isArray(t)){if(o=e.id,u.call(t,o)<0)return!1}else if(e.id!==t)return!1;return!0},e}(),s.collectionObservable=function(e,t){return new s.CollectionObservable(e,t)}},function(e,t,n){var r,i,o,s=function(e,t){return function(){return e.apply(t,arguments)}},a=[].indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(t in this&&this[t]===e)return t;return-1};r=n(5),o=r._,i=r.ko,r.EventWatcher=function(){function e(e,t,n){this._onModelUnloaded=s(this._onModelUnloaded,this),this._onModelLoaded=s(this._onModelLoaded,this),this.__kb||(this.__kb={}),this.__kb.callbacks={},this.__kb._onModelLoaded=o.bind(this._onModelLoaded,this),this.__kb._onModelUnloaded=o.bind(this._onModelUnloaded,this),n&&this.registerCallbacks(t,n),e?this.emitter(e):this.ee=null}return e.useOptionsOrCreate=function(e,t,n,i){return e.event_watcher?(e.event_watcher.emitter()!==t&&e.event_watcher.model_ref!==t&&r._throwUnexpected(this,"emitter not matching"),r.utils.wrappedEventWatcher(n,e.event_watcher).registerCallbacks(n,i)):(r.utils.wrappedEventWatcherIsOwned(n,!0),r.utils.wrappedEventWatcher(n,new r.EventWatcher(t)).registerCallbacks(n,i))},e.prototype.destroy=function(){return this.emitter(null),this.__kb.callbacks=null,r.utils.wrappedDestroy(this)},e.prototype.emitter=function(e){var t,n,i,o,s,a,l,u;if(0===arguments.length||this.ee===e)return this.ee;this.model_ref&&(this.model_ref.unbind("loaded",this.__kb._onModelLoaded),this.model_ref.unbind("unloaded",this.__kb._onModelUnloaded),this.model_ref.release(),this.model_ref=null),r.Backbone&&r.Backbone.ModelRef&&e instanceof r.Backbone.ModelRef?(this.model_ref=e,this.model_ref.retain(),this.model_ref.bind("loaded",this.__kb._onModelLoaded),this.model_ref.bind("unloaded",this.__kb._onModelUnloaded),e=this.model_ref.model()):delete this.model_ref,s=this.ee,this.ee=e,u=this.__kb.callbacks;for(n in u)for(t=u[n],s&&s.unbind(n,t.fn),e&&this.ee.bind(n,t.fn),o=t.list,a=0,l=o.length;l>a;a++)i=o[a],i.emitter&&i.emitter(this.ee);return e},e.prototype.registerCallbacks=function(e,t){var n,s,l,u,c,d,p,f;for(e||r._throwMissing(this,"obj"),t||r._throwMissing(this,"info"),u=t.event_selector?t.event_selector:"change",l=u.split(" "),p=0,f=l.length;f>p;p++)s=l[p],s&&(n=this.__kb.callbacks[s],n||(d=[],n={list:d,fn:function(){return function(e){var t,n,o;for(n=0,o=d.length;o>n;n++)if(t=d[n],t.update&&!t.rel_fn){if(e&&t.key&&e.hasChanged&&!e.hasChanged(i.utils.unwrapObservable(t.key)))continue;!r.statistics||r.statistics.addModelEvent({name:s,model:e,key:t.key,path:t.path}),t.update()}return null}}(this)},this.__kb.callbacks[s]=n,this.ee&&this.ee.bind(s,n.fn)),c=o.defaults({obj:e},t),n.list.push(c));this.ee&&(a.call(l,"change")>=0&&(c.unbind_fn=r.orm.bind(this.ee,c.key,c.update,c.path)),c.emitter(this.ee)&&c.emitter)},e.prototype.releaseCallbacks=function(e){var t,n,i,o,s,a;if(this.__kb.callbacks&&this.ee){s=this.__kb.callbacks;for(n in s){t=s[n],a=t.list;for(i in a)if(o=a[i],o.obj===e)return t.list.splice(i,1),o.unbind_fn&&(o.unbind_fn(),o.unbind_fn=null),void(!r.wasReleased(e)&&o.emitter&&o.emitter(null))}}},e.prototype._onModelLoaded=function(e){var t,n,i,o,s,a,l;this.ee=e,a=this.__kb.callbacks;for(n in a)for(t=a[n],e.bind(n,t.fn),l=t.list,o=0,s=l.length;s>o;o++)i=l[o],i.unbind_fn=r.orm.bind(e,i.key,i.update,i.path),i.emitter&&i.emitter(e)},e.prototype._onModelUnloaded=function(e){var t,n,r,i,o,s,a;this.ee=null,a=this.__kb.callbacks;for(n in a)for(t=a[n],e.unbind(n,t.fn),i=t.list,o=0,s=i.length;s>o;o++)r=i[o],r.unbind_fn&&(r.unbind_fn(),r.unbind_fn=null),r.emitter&&r.emitter(null)},e}(),r.emitterObservable=function(e,t){return new r.EventWatcher(e,t)}},function(e,t,n){var r,i;r=n(5),i=r._,r.Factory=function(){function e(e){this.parent_factory=e,this.paths={}}return e.useOptionsOrCreate=function(e,t,n){var i;return e.factory&&(!e.factories||e.factories&&e.factory.hasPathMappings(e.factories,n))?r.utils.wrappedFactory(t,e.factory):(i=r.utils.wrappedFactory(t,new r.Factory(e.factory)),e.factories&&i.addPathMappings(e.factories,n),i)},e.prototype.hasPath=function(e){return this.paths.hasOwnProperty(e)||this.parent_factory&&this.parent_factory.hasPath(e)},e.prototype.addPathMapping=function(e,t){return this.paths[e]=t},e.prototype.addPathMappings=function(e,t){var n,i;for(i in e)n=e[i],this.paths[r.utils.pathJoin(t,i)]=n},e.prototype.hasPathMappings=function(e,t){var n,i,o,s;n=!0;for(s in e)i=e[s],n&=(o=this.creatorForPath(null,r.utils.pathJoin(t,s)))&&i===o;return n},e.prototype.creatorForPath=function(e,t){var n;return(n=this.paths[t])?n.view_model?n.view_model:n:this.parent_factory&&(n=this.parent_factory.creatorForPath(e,t))?n:null},e}()},function(e,t,n){(function(e){var t,r,i,o,s,a,l;s=null!=s?s:e,r=n(5),a=r._,i=r.ko,t=r.$,r.RECUSIVE_AUTO_INJECT=!0,i.bindingHandlers.inject={init:function(e,t,n,o){return r.Inject.inject(i.utils.unwrapObservable(t()),o,e,t,n)}},r.Inject=function(){function e(){}return e.inject=function(e,t,n,o,s,l){var u,c,d;return u=function(e){var i,u,c;if(a.isFunction(e))t=new e(t,n,o,s),r.releaseOnNodeRemove(t,n);else{e.view_model&&(t=new e.view_model(t,n,o,s),r.releaseOnNodeRemove(t,n));for(i in e)c=e[i],"view_model"!==i&&("create"===i?c(t,n,o,s):a.isObject(c)&&!a.isFunction(c)?(u=l||c&&c.create?{}:t,t[i]=r.Inject.inject(c,u,n,o,s,!0)):t[i]=c)}return t},l?u(e):(c=(d=i.dependentObservable(function(){return u(e)}))(),d.dispose(),c)},e.injectViewModels=function(e){var t,n,i,o,l,u,c,d,p,f;for(d=[],u=function(e){var t,n,r,i,o;for(e.__kb_injected||e.attributes&&(t=a.find(e.attributes,function(e){return"kb-inject"===e.name}))&&(e.__kb_injected=!0,d.push({el:e,view_model:{},binding:t.value})),o=e.childNodes,r=0,i=o.length;i>r;r++)n=o[r],u(n)},!e&&(null!=s?s.document:void 0)&&(e=s.document),u(e),p=0,f=d.length;f>p;p++)n=d[p],(l=n.binding)&&(l.search(/[:]/)<0||(l="{"+l+"}"),o=new Function("","return ( "+l+" )")(),o||(o={}),!o.options||(c=o.options,delete o.options),c||(c={}),n.view_model=r.Inject.inject(o,n.view_model,n.el,null,null,!0),t=n.view_model.afterBinding||c.afterBinding,i=n.view_model.beforeBinding||c.beforeBinding),i&&i(n.view_model,n.el,c),r.applyBindings(n.view_model,n.el,c),t&&t(n.view_model,n.el,c);return d},e}(),l=i.applyBindings,i.applyBindings=function(e,t){var n;return n=r.RECUSIVE_AUTO_INJECT?r.injectViewModels(t):[],n.length?void 0:l.apply(this,arguments)},r.injectViewModels=r.Inject.injectViewModels,"undefined"!=typeof document&&null!==document&&(t?t(function(){return r.injectViewModels()}):(o=function(){return"complete"!==document.readyState?setTimeout(o,0):r.injectViewModels()})())}).call(t,function(){return this}())},function(e,t,n){(function(t){var r,i,o,s,a,l;a=null!=a?a:t,s=n(23),i=function(e,t){var n,r;for(n in t)r=t[n],e[n]=r;return e};var u=function(){},c=function(e,t,n){var r;return r=t&&t.hasOwnProperty("constructor")?t.constructor:function(){e.apply(this,arguments)},i(r,e),u.prototype=e.prototype,r.prototype=new u,t&&i(r.prototype,t),n&&i(r,n),r.prototype.constructor=r,r.__super__=e.prototype,r},d=function(e,t){var n=c(this,e,t);return n.extend=this.extend,n};e.exports=o=function(){function e(){}var t;return e.VERSION="0.18.6",e.TYPE_UNKNOWN=0,e.TYPE_SIMPLE=1,e.TYPE_ARRAY=2,e.TYPE_MODEL=3,e.TYPE_COLLECTION=4,e.wasReleased=function(e){return!e||e.__kb_released},e.isReleaseable=function(t,n){var r,i;if(null==n&&(n=0),!t||t!==Object(t)||t.__kb_released)return!1;if(s.isObservable(t)||t instanceof e.ViewModel)return!0;if("function"==typeof t||t instanceof e.Model||t instanceof e.Collection)return!1;if("function"==typeof t.dispose||"function"==typeof t.destroy||"function"==typeof t.release)return!0;if(1>n)for(r in t)if(i=t[r],"__kb"!==r&&e.isReleaseable(i,n+1))return!0;return!1},e.release=function(t){var n,r,i;if(e.isReleaseable(t))if(l.isArray(t))for(r in t)i=t[r],e.isReleaseable(i)&&(t[r]=null,e.release(i));else if(t.__kb_released=!0,s.isObservable(t)&&l.isArray(n=e.peek(t))){if(t.__kb_is_co||t.__kb_is_o&&t.valueType()===e.TYPE_COLLECTION)t.destroy?t.destroy():t.dispose&&t.dispose();else if(n.length)for(r in n)i=n[r],e.isReleaseable(i)&&(n[r]=null,e.release(i))}else"function"==typeof t.release?t.release():"function"==typeof t.destroy?t.destroy():"function"==typeof t.dispose?t.dispose():s.isObservable(t)||this.releaseKeys(t)},e.releaseKeys=function(t){var n,r;for(n in t)r=t[n],"__kb"!==n&&e.isReleaseable(r)&&(t[n]=null,e.release(r))},e.releaseOnNodeRemove=function(t,n){return t||e._throwUnexpected(this,"missing view model"),n||e._throwUnexpected(this,"missing node"),s.utils.domNodeDisposal.addDisposeCallback(n,function(){return e.release(t)})},e.renderTemplate=function(t,n,r){var i,o,l;return null==r&&(r={}),(i=null!=a?a.document:void 0)?(o=i.createElement("div"),l=s.renderTemplate(t,n,r,o,"replaceChildren"),1===o.children.length&&(o=o.children[0]),e.releaseOnNodeRemove(n,o),l.dispose(),n.afterRender&&!r.afterRender&&n.afterRender(o),o):"undefined"!=typeof console&&null!==console?console.log("renderTemplate: document is undefined"):void 0},e.applyBindings=function(t,n){return s.applyBindings(t,n),e.releaseOnNodeRemove(t,n)},e.getValue=function(t,n,r){return t?l.isFunction(t[n])&&e.orm.useFunction(t,n)?t[n]():r?t.get.apply(t,l.map([n].concat(r),function(t){return e.peek(t)})):t.get(n):void 0},e.setValue=function(t,n,r){var i;if(t)return l.isFunction(t[n])&&e.orm.useFunction(t,n)?t[n](r):((i={})[n]=r,t.set(i))},e.ignore=(null!=(t=s.dependencyDetection)?t.ignore:void 0)||function(e,t,n){var r;return r=null,s.dependentObservable(function(){return r=e.apply(t,n||[])}).dispose(),r},e.extend=d,e._throwMissing=function(e,t){throw""+(l.isString(e)?e:e.constructor.name)+": "+t+" is missing"},e._throwUnexpected=function(e,t){throw""+(l.isString(e)?e:e.constructor.name)+": "+t+" is unexpected"},e.publishMethods=function(t,n,r){var i,o,s;for(o=0,s=r.length;s>o;o++)i=r[o],t[i]=e._.bind(n[i],n)},e.peek=function(t){return s.isObservable(t)?t.peek?t.peek():e.ignore(function(){return t()}):t},e}(),a.Parse?(r=o.Parse=a.Parse,l=o._=a.Parse._):(r=o.Backbone=n(21),l=o._=n(22)),o.ko=s,o.Collection=r.Collection,o.Model=r.Object||r.Model,o.Events=r.Events,o.$=a.jQuery||a.$;try{o.$||(o.$=n(18))}catch(p){}}).call(t,function(){return this}())},function(e,t,n){var r,i,o;r=n(5),o=r._,i=r.ko,r.Observable=function(){function e(e,t,n){return this._vm=null!=n?n:{},r.ignore(function(n){return function(){var s,a,l;return t||r._throwMissing(n,"options"),s=n.create_options=o.isString(t)||i.isObservable(t)?{key:t}:r.utils.collapseOptions(t),n.key=s.key,delete s.key,n.key||r._throwMissing(n,"key"),!s.args||(n.args=s.args,delete s.args),!s.read||(n.read=s.read,delete s.read),!s.write||(n.write=s.write,delete s.write),a=s.event_watcher,delete s.event_watcher,n._vo=i.observable(null),n._model=i.observable(),l=r.utils.wrappedObservable(n,i.dependentObservable({read:function(){var e,t,s,a,l,u;for(l=n._model(),u=t=[n.key].concat(n.args||[]),s=0,a=u.length;a>s;s++)e=u[s],i.utils.unwrapObservable(e);return n.read?n.update(n.read.apply(n._vm,t)):o.isUndefined(l)||r.ignore(function(){return n.update(r.getValue(l,r.peek(n.key),n.args))}),i.utils.unwrapObservable(n._vo())},write:function(e){return r.ignore(function(){var t,i;return t=r.utils.unwrapModels(e),i=r.peek(n._model),n.write?(n.write.call(n._vm,t),e=r.getValue(i,r.peek(n.key),n.args)):i&&r.setValue(i,r.peek(n.key),t),n.update(e)})},owner:n._vm})),l.__kb_is_o=!0,s.store=r.utils.wrappedStore(l,s.store),s.path=r.utils.pathJoin(s.path,n.key),s.factories&&("function"==typeof s.factories||s.factories.create)?(s.factory=r.utils.wrappedFactory(l,new r.Factory(s.factory)),s.factory.addPathMapping(s.path,s.factories)):s.factory=r.Factory.useOptionsOrCreate(s,l,s.path),delete s.factories,r.publishMethods(l,n,["value","valueType","destroy"]),l.model=n.model=i.dependentObservable({read:function(){return i.utils.unwrapObservable(n._model)},write:function(e){return r.ignore(function(){var t;if(!n.__kb_released&&r.peek(n._model)!==e)return t=r.getValue(e,r.peek(n.key),n.args),n._model(e),e?o.isUndefined(t)?void 0:n.update(t):n.update(null)})}}),r.EventWatcher.useOptionsOrCreate({event_watcher:a},e,n,{emitter:n.model,update:o.bind(n.update,n),key:n.key,path:s.path}),n.__kb_value||n.update(),r.LocalizedObservable&&s.localizer&&(l=new s.localizer(l),delete s.localizer),r.DefaultObservable&&s.hasOwnProperty("default")&&(l=r.defaultObservable(l,s["default"]),delete s["default"]),l}}(this))}return e.prototype.destroy=function(){var e;return e=r.utils.wrappedObservable(this),this.__kb_released=!0,r.release(this.__kb_value),this.__kb_value=null,this.model.dispose(),this.model=e.model=null,r.utils.wrappedDestroy(this)},e.prototype.value=function(){return this.__kb_value},e.prototype.valueType=function(){var e;return e=r.getValue(r.peek(this._model),r.peek(this.key)),this.value_type||this._updateValueObservable(e),this.value_type},e.prototype.update=function(e){var t,n;if(!this.__kb_released){if(arguments.length||(e=r.getValue(r.peek(this._model),r.peek(this.key))),void 0!==e||(e=null),t=r.utils.valueType(e),(!this.__kb_value||this.__kb_value.__kb_released||this.__kb_value.__kb_null&&e)&&(this.__kb_value=void 0,this.value_type=void 0),n=this.__kb_value,o.isUndefined(this.value_type)||this.value_type!==t&&t!==r.TYPE_UNKNOWN)return this.value_type===r.TYPE_COLLECTION&&t===r.TYPE_ARRAY?n(e):this._updateValueObservable(e);if(this.value_type===r.TYPE_MODEL){if("function"==typeof n.model){if(n.model()!==e)return n.model(e)}else if(r.utils.wrappedObject(n)!==e)return this._updateValueObservable(e)}else if(this.value_type===r.TYPE_COLLECTION){if(n.collection()!==e)return n.collection(e)}else if(n()!==e)return n(e)}},e.prototype._updateValueObservable=function(e){var t,n,s,a;return t=this.create_options,t.creator=r.utils.inferCreator(e,t.factory,t.path,r.peek(this._model),this.key),this.value_type=r.TYPE_UNKNOWN,n=t.creator,s=this.__kb_value,this.__kb_value=void 0,s&&r.release(s),n?t.store?a=t.store.findOrCreate(e,t):n.models_only?(a=e,this.value_type=r.TYPE_SIMPLE):a=n.create?n.create(e,t):new n(e,t):o.isArray(e)?(this.value_type=r.TYPE_ARRAY,a=i.observableArray(e)):(this.value_type=r.TYPE_SIMPLE,a=i.observable(e)),this.value_type===r.TYPE_UNKNOWN&&(i.isObservable(a)?this.value_type=a.__kb_is_co?r.TYPE_COLLECTION:r.TYPE_SIMPLE:(this.value_type=r.TYPE_MODEL,"function"!=typeof a.model&&r.utils.wrappedObject(a,e))),this.__kb_value=a,this._vo(a)},e}(),r.observable=function(e,t,n){return new r.Observable(e,t,n)}},function(e,t,n){(function(e){var t,r,i,o,s,a,l,u,c,d;c="undefined"!=typeof window&&null!==window?window:e,u=n(5),d=u._,r=function(){function e(){this.adapters=[]}return e.prototype.initialize=function(){return this.adapters=d.select(this.adapters,function(e){return e.isAvailable()}),this.initialized=!0},e.prototype.addAdapter=function(e){return this.adapters.push(e),this.initialized=!1},e.prototype.keys=function(){return this._call("keys",arguments)},e.prototype.bind=function(){return this._call("bind",arguments)},e.prototype.useFunction=function(){return this._call("useFunction",arguments)},e.prototype._call=function(e,t){var n,r,i,o,s;if(this.adapters.length)for(this.initialized||this.initialize(),s=this.adapters,i=0,o=s.length;o>i;i++)if(n=s[i],n[e]&&(r=n[e].apply(n,t)))return r},e}(),u.orm=new r,a=null,o=function(){function e(){}return e.prototype.isAvailable=function(){var e;return!!(a=null!=(e=u.Backbone)?e.RelationalModel:void 0)},e.prototype.relationType=function(e,t){var n;return e instanceof a&&(n=d.find(e.getRelations(),function(e){return e.key===t}))?n.collectionType||d.isArray(n.keyContents)?u.TYPE_COLLECTION:u.TYPE_MODEL:null},e.prototype.bind=function(e,t,n,r){var i,o,s,a,l,c;if(!(a=this.relationType(e,t)))return null;if(s=function(e){return!u.statistics||u.statistics.addModelEvent({name:"update (relational)",model:e,key:t,path:r}),n()},o=u.Backbone.Relation.prototype.sanitizeOptions?["update","add","remove"]:["change","add","remove"],a===u.TYPE_COLLECTION)for(l=0,c=o.length;c>l;l++)i=o[l],e.bind(""+i+":"+t,s);else e.bind(""+o[0]+":"+t,s);return function(){var n,r;if(a===u.TYPE_COLLECTION)for(n=0,r=o.length;r>n;n++)i=o[n],e.unbind(""+i+":"+t,s);else e.unbind(""+o[0]+":"+t,s)}},e}(),u.orm.addAdapter(new o),t=null,i=function(){function e(){}return e.prototype.isAvailable=function(){var e;return!!(t=null!=(e=u.Backbone)?e.AssociatedModel:void 0)},e.prototype.keys=function(e){return e instanceof t?d.map(e.relations,function(e){return e.key}):null},e.prototype.relationType=function(e,n){var r;return e instanceof t&&(r=d.find(e.relations,function(e){return e.key===n}))?"Many"===r.type?u.TYPE_COLLECTION:u.TYPE_MODEL:null},e}(),u.orm.addAdapter(new i),l=null,s=function(){function e(){}return e.prototype.isAvailable=function(){return!!(l=c.Supermodel)},e.prototype.keys=function(e){return e instanceof l.Model?d.keys(e.constructor.associations()):null},e.prototype.relationType=function(e,t){var n;return e instanceof l.Model&&(n=e.constructor.associations()[t])?n.add?u.TYPE_COLLECTION:u.TYPE_MODEL:null},e.prototype.bind=function(e,t,n,r){var i,o;return(o=this.relationType(e,t))?(i=function(e,i){var o,s;return!u.statistics||u.statistics.addModelEvent({name:"update (supermodel)",model:e,key:t,path:r}),s=e.constructor.associations()[t],o=e[s.store],e[s.store]=i,n(i),e[s.store]=o},o===u.TYPE_MODEL?(e.bind("associate:"+t,i),function(){return e.unbind("associate:"+t,i)}):void 0):null},e.prototype.useFunction=function(e,t){return!!this.relationType(e,t)},e}(),u.orm.addAdapter(new s)}).call(t,function(){return this}())},function(e,t,n){var r,i;r=n(5),i=r._,e.exports=r.Statistics=function(){function e(){this.model_events_tracker=[],this.registered_tracker={}}return e.prototype.clear=function(){return this.model_events_tracker=[]},e.prototype.addModelEvent=function(e){return this.model_events_tracker.push(e)},e.prototype.modelEventsStatsString=function(){var e,t,n,r;n="",n+="Total Count: "+this.model_events_tracker.length,e=i.groupBy(this.model_events_tracker,function(e){return"event name: '"+e.name+"', attribute name: '"+e.key+"'"});for(t in e)r=e[t],n+="\n "+t+", count: "+r.length;return n},e.prototype.register=function(e,t){return this.registeredTracker(e).push(t)},e.prototype.unregister=function(e,t){var n,r;return r=this.registeredTracker(e),n=i.indexOf(r,t),0>n&&"undefined"!=typeof console&&null!==console&&console.log("kb.Statistics: failed to unregister type: "+e),r.splice(n,1)},e.prototype.registeredCount=function(e){var t,n,r;if(e)return this.registeredTracker(e).length;t=0,r=this.registered_tracker[e];for(e in r)n=r[e],t+=n.length;return t},e.prototype.registeredStatsString=function(e){var t,n,r,i,o;t="",o=this.registered_tracker;for(n in o)r=o[n],r.length&&(i&&(t+="\n "),t+=""+(n?n:"No Name")+": "+r.length,i=!0);return t?t:e},e.prototype.registeredTracker=function(e){var t;return this.registered_tracker.hasOwnProperty(e)?this.registered_tracker[e]:(t=[],this.registered_tracker[e]=t,t)},e}()},function(e,t,n){var r,i,o;r=n(5),o=r._,i=r.ko,e.exports=r.Store=function(){function e(){this.observable_records=[],this.replaced_observables=[]}return e.useOptionsOrCreate=function(e,t,n){return e.store?(e.store.register(t,n,e),r.utils.wrappedStore(n,e.store)):(r.utils.wrappedStoreIsOwned(n,!0),r.utils.wrappedStore(n,new r.Store))},e.prototype.destroy=function(){return this.clear()},e.prototype.clear=function(){var e,t,n,i;for(i=this.observable_records.splice(0,this.observable_records.length),t=0,n=i.length;n>t;t++)e=i[t],r.release(e.observable);r.release(this.replaced_observables)},e.prototype.compact=function(){var e,t,n,r,i;n=[],r=this.observable_records;for(e in r)t=r[e],(null!=(i=t.observable)?i.__kb_released:void 0)&&n.push(t);n.length&&(this.observable_records=o.difference(this.observable_records,n))},e.prototype.register=function(e,t,n){var o;if(t&&!i.isObservable(t)&&!t.__kb_is_co)return r.utils.wrappedObject(t,e),e||(t.__kb_null=!0),o=n.creator?n.creator:n.path&&n.factory?n.factory.creatorForPath(e,n.path):null,o||(o=t.constructor),this.observable_records.push({obj:e,observable:t,creator:o}),t},e.prototype.findIndex=function(e,t){var n,i,s,a;if(s=[],!e||e instanceof r.Model){a=this.observable_records;for(n in a)if(i=a[n],i.observable)if(i.observable.__kb_released)s.push(i);else if((e||i.observable.__kb_null)&&(!e||!i.observable.__kb_null&&i.obj===e)&&(i.creator===t||i.creator.create&&i.creator.create===t.create))return s.length?(this.observable_records=o.difference(this.observable_records,s),o.indexOf(this.observable_records,i)):n}return s.length&&(this.observable_records=o.difference(this.observable_records,s)),-1},e.prototype.find=function(e,t){var n;return(n=this.findIndex(e,t))<0?null:this.observable_records[n].observable},e.prototype.isRegistered=function(e){var t,n,r,i;for(i=this.observable_records,n=0,r=i.length;r>n;n++)if(t=i[n],t.observable===e)return!0;return!1},e.prototype.findOrCreate=function(e,t){var n,o;return t.store=this,t.creator||(t.creator=r.utils.inferCreator(e,t.factory,t.path)),!t.creator&&e instanceof r.Model&&(t.creator=r.ViewModel),(n=t.creator)?n.models_only?e:(n&&(o=this.find(e,n)),o?o:(o=r.ignore(function(){return function(){return o=n.create?n.create(e,t):new n(e,t),o||i.observable(null)}}(this)),i.isObservable(o)||this.isRegistered(o)||this.register(e,o,t),o)):r.utils.createFromDefaultCreator(e,t)},e.prototype.findOrReplace=function(e,t,n){var i,o;return e||r._throwUnexpected(this,"obj missing"),(i=this.findIndex(e,t))<0?this.register(e,n,{creator:t}):(o=this.observable_records[i],r.utils.wrappedObject(o.observable)===e||r._throwUnexpected(this,"different object"),o.observable!==n&&(o.observable.constructor===n.constructor||r._throwUnexpected(this,"replacing different type"),this.replaced_observables.push(o.observable),o.observable=n),n)},e}()},function(e,t,n){var r,i,o,s,a,l,u,c;r=n(5),o=r._,i=r.ko,c=r._wrappedKey=function(e,t,n){return 2===arguments.length?e&&e.__kb&&e.__kb.hasOwnProperty(t)?e.__kb[t]:void 0:(e||r._throwUnexpected(this,"no obj for wrapping "+t),e.__kb||(e.__kb={}),e.__kb[t]=n,n)},s=function(e,t){return Array.prototype.splice.call(e,1,0,t),e},l=function(e,t,n){return e[t]||(e[t]=[]),o.isArray(n)||(n=[n]),e[t]=e[t].length?o.union(e[t],n):n,e},u=function(e,t,n){return e[t]||(e[t]={}),o.extend(e[t],n)},a=function(e){var t,n,r,i;for(n={},r=0,i=e.length;i>r;r++)t=e[r],n[t]={key:t};return n},r.utils=function(){function e(){}return e.wrappedObservable=function(){return c.apply(this,s(arguments,"observable"))},e.wrappedObject=function(){return c.apply(this,s(arguments,"object"))},e.wrappedModel=function(e,t){return 1===arguments.length?(t=c(e,"object"),o.isUndefined(t)?e:t):c(e,"object",t)},e.wrappedStore=function(){return c.apply(this,s(arguments,"store"))},e.wrappedStoreIsOwned=function(){return c.apply(this,s(arguments,"store_is_owned"))},e.wrappedFactory=function(){return c.apply(this,s(arguments,"factory"))},e.wrappedEventWatcher=function(){return c.apply(this,s(arguments,"event_watcher"))},e.wrappedEventWatcherIsOwned=function(){return c.apply(this,s(arguments,"event_watcher_is_owned"))},e.wrappedDestroy=function(e){var t;if(e.__kb)return e.__kb.event_watcher&&e.__kb.event_watcher.releaseCallbacks(e),t=e.__kb,e.__kb=null,t.observable&&(t.observable.destroy=t.observable.release=null,this.wrappedDestroy(t.observable),t.observable=null),t.factory=null,t.event_watcher_is_owned&&t.event_watcher.destroy(),t.event_watcher=null,t.store_is_owned&&t.store.destroy(),t.store=null},e.valueType=function(e){return e?e.__kb_is_o?e.valueType():e.__kb_is_co||e instanceof r.Collection?r.TYPE_COLLECTION:e instanceof r.ViewModel||e instanceof r.Model?r.TYPE_MODEL:o.isArray(e)?r.TYPE_ARRAY:r.TYPE_SIMPLE:r.TYPE_UNKNOWN},e.pathJoin=function(e,t){return(e?"."!==e[e.length-1]?""+e+".":e:"")+t},e.optionsPathJoin=function(e,t){return o.defaults({path:this.pathJoin(e.path,t)},e)},e.inferCreator=function(e,t,n){var i;return t&&(i=t.creatorForPath(e,n)),i?i:e?e instanceof r.Model?r.ViewModel:e instanceof r.Collection?r.CollectionObservable:null:null},e.createFromDefaultCreator=function(e,t){return e instanceof r.Model?r.viewModel(e,t):e instanceof r.Collection?r.collectionObservable(e,t):o.isArray(e)?i.observableArray(e):i.observable(e)},e.hasModelSignature=function(e){return e&&e.attributes&&!e.models&&"function"==typeof e.get&&"function"==typeof e.trigger},e.hasCollectionSignature=function(e){return e&&e.models&&"function"==typeof e.get&&"function"==typeof e.trigger},e.collapseOptions=function(e){var t,n,r,i;for(n={},e={options:e};e.options;){i=e.options;for(t in i)switch(r=i[t],t){case"internals":case"requires":case"excludes":case"statics":l(n,t,r);break; case"keys":o.isObject(r)&&!o.isArray(r)||o.isObject(n[t])&&!o.isArray(n[t])?(o.isObject(r)||(r=[r]),o.isArray(r)&&(r=a(r)),o.isArray(n[t])&&(n[t]=a(n[t])),u(n,t,r)):l(n,t,r);break;case"factories":o.isFunction(r)?n[t]=r:u(n,t,r);break;case"static_defaults":u(n,t,r);break;case"options":break;default:n[t]=r}e=e.options}return n},e.unwrapModels=function(e){var t,n,i;if(!e)return e;if(e.__kb)return"object"in e.__kb?e.__kb.object:e;if(o.isArray(e))return o.map(e,function(e){return r.utils.unwrapModels(e)});if(o.isObject(e)&&e.constructor==={}.constructor){n={};for(t in e)i=e[t],n[t]=r.utils.unwrapModels(i);return n}return e},e}()},function(e,t,n){var r,i,o;r=n(5),o=r._,i=r.ko,r.ViewModel=function(){function e(e,t,n){return r.ignore(function(s){return function(){var a,l,u,c,d,p,f,h,v,b;if(!e||e instanceof r.Model||"function"==typeof e.get&&"function"==typeof e.bind||r._throwUnexpected(s,"not a model"),t||(t={}),n||(n={}),t=o.isArray(t)?{keys:t}:r.utils.collapseOptions(t),s.__kb||(s.__kb={}),s.__kb.vm_keys={},s.__kb.model_keys={},s.__kb.view_model=o.isUndefined(n)?s:n,!t.internals||(s.__kb.internals=t.internals),!t.excludes||(s.__kb.excludes=t.excludes),!t.statics||(s.__kb.statics=t.statics),!t.static_defaults||(s.__kb.static_defaults=t.static_defaults),r.Store.useOptionsOrCreate(t,e,s),s.__kb.path=t.path,r.Factory.useOptionsOrCreate(t,s,t.path),v=r._wrappedKey(s,"_mdl",i.observable()),s.model=i.dependentObservable({read:function(){return v(),r.utils.wrappedObject(s)},write:function(e){return r.ignore(function(){var t,n,i,a;if(r.utils.wrappedObject(s)!==e){if(s.__kb_null)return void(!e||r._throwUnexpected(s,"model set on shared null"));if(r.utils.wrappedObject(s,e),t=r.utils.wrappedEventWatcher(s),!t)return void v(e);t.emitter(e),!s.__kb.keys&&e&&e.attributes&&(n=o.keys(e.attributes),e&&(a=r.orm.keys(e))&&(n=o.union(n,a)),i=o.difference(n,o.keys(s.__kb.model_keys)),i&&s.createObservables(e,i)),v(e)}})}}),u=r.utils.wrappedEventWatcher(s,new r.EventWatcher(e,s,{emitter:s.model})),c=t.requires,s.__kb.internals&&(c=o.union(c||[],s.__kb.internals)),e&&(f=r.orm.keys(e))&&(c=o.union(c||[],f)),t.keys)if(o.isObject(t.keys)&&!o.isArray(t.keys)){d={},b=t.keys;for(h in b)p=b[h],d[o.isString(p)?p:p.key?p.key:h]=!0;s.__kb.keys=o.keys(d)}else s.__kb.keys=t.keys,c=c?o.union(c,s.__kb.keys):o.clone(s.__kb.keys);else l=u.emitter(),l&&l.attributes&&(a=o.keys(l.attributes),c=c?o.union(c,a):a);return c&&s.__kb.excludes&&(c=o.difference(c,s.__kb.excludes)),c&&s.__kb.statics&&(c=o.difference(c,s.__kb.statics)),o.isObject(t.keys)&&!o.isArray(t.keys)&&s.mapObservables(e,t.keys),o.isObject(t.requires)&&!o.isArray(t.requires)&&s.mapObservables(e,t.requires),!t.mappings||s.mapObservables(e,t.mappings),!c||s.createObservables(e,c),!s.__kb.statics||s.createObservables(e,s.__kb.statics,!0),!r.statistics||r.statistics.register("ViewModel",s),s}}(this))}return e.extend=r.extend,e.prototype.destroy=function(){var e;if(this.__kb.view_model!==this)for(e in this.__kb.vm_keys)this.__kb.view_model[e]=null;return this.__kb.view_model=null,r.releaseKeys(this),r.utils.wrappedDestroy(this),!r.statistics||r.statistics.unregister("ViewModel",this)},e.prototype.shareOptions=function(){return{store:r.utils.wrappedStore(this),factory:r.utils.wrappedFactory(this)}},e.prototype.createObservables=function(e,t,n){var i,s,a,l,u,c;for(n?a=this.__kb.static_defaults||{}:i={store:r.utils.wrappedStore(this),factory:r.utils.wrappedFactory(this),path:this.__kb.path,event_watcher:r.utils.wrappedEventWatcher(this)},u=0,c=t.length;c>u;u++)s=t[u],l=this.__kb.internals&&o.contains(this.__kb.internals,s)?"_"+s:s,this[l]||(this.__kb.vm_keys[l]=this.__kb.model_keys[s]=!0,n?e.has(l)?this[l]=this.__kb.view_model[l]=e.get(l):l in a&&(this[l]=this.__kb.view_model[l]=a[l]):(i.key=s,this[l]=this.__kb.view_model[l]=r.observable(e,i,this)))},e.prototype.mapObservables=function(e,t){var n,i,s;n={store:r.utils.wrappedStore(this),factory:r.utils.wrappedFactory(this),path:this.__kb.path,event_watcher:r.utils.wrappedEventWatcher(this)};for(s in t)i=t[s],this[s]||(i=o.isString(i)?{key:i}:o.clone(i),i.key||(i.key=s),this.__kb.vm_keys[s]=this.__kb.model_keys[i.key]=!0,this[s]=this.__kb.view_model[s]=r.observable(e,o.defaults(i,n),this))},e}(),r.viewModel=function(e,t,n){return new r.ViewModel(e,t,n)}},function(e,t,n){var r,i,o,s,a;if(e.exports=r=n(5),r.modules={underscore:r._,backbone:r.Parse||r.Backbone,knockout:r.ko},"undefined"!=typeof window&&null!==window)for(a=["_","Backbone","Parse","ko","$"],o=0,s=a.length;s>o;o++)i=a[o],r[i]&&!window.hasOwnProperty(i)&&(window[i]=r[i])},function(e,t,n){var r,i,o;r=n(5),o=r._,i=r.ko,n(19),e.exports=r.DefaultObservable=function(){function e(e,t){var n;return this.dv=t,n=r.utils.wrappedObservable(this,i.dependentObservable({read:function(t){return function(){var n;return(n=i.utils.unwrapObservable(e()))?n:i.utils.unwrapObservable(t.dv)}}(this),write:function(t){return e(t)}})),r.publishMethods(n,this,["destroy","setToDefault"]),n}return e.prototype.destroy=function(){return r.utils.wrappedDestroy(this)},e.prototype.setToDefault=function(){return r.utils.wrappedObservable(this)(this.dv)},e}(),r.defaultObservable=function(e,t){return new r.DefaultObservable(e,t)}},function(e,t,n){var r,i,o,s;i=n(5),s=i._,o=i.ko,r=Array.prototype.slice,i.toFormattedString=function(e){var t,n,i,a,l,u;l=e.slice(),n=r.call(arguments,1);for(i in n)for(t=n[i],u=o.utils.unwrapObservable(t),(s.isUndefined(u)||s.isNull(u))&&(u=""),a=e.indexOf("{"+i+"}");a>=0;)l=l.replace("{"+i+"}",u),a=e.indexOf("{"+i+"}",a+1);return l},i.parseFormattedString=function(e,t){var n,r,i,o,a,l,u,c,d,p,f,h,v;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(n=i,d=new RegExp(p),a=d.exec(e),a&&a.shift(),!a||a.length!==l){for(f=[];n-->0;)f.push("");return f}v=s.sortBy(s.keys(c),function(e){return parseInt(e,10)}),r={};for(o in v)u=v[o],i=c[u],r.hasOwnProperty(i)||(r[i]=o);for(h=[],i=0;n>i;)h.push(a[r[i]]),i++;return h},e.exports=i.FormattedObservable=function(){function e(e,t){var n,a;return s.isArray(t)?(e=e,a=t):a=r.call(arguments,1),n=i.utils.wrappedObservable(this,o.dependentObservable({read:function(){var n,r,s;for(t=[o.utils.unwrapObservable(e)],r=0,s=a.length;s>r;r++)n=a[r],t.push(o.utils.unwrapObservable(n));return i.toFormattedString.apply(null,t)},write:function(t){var n,r,s;for(r=i.parseFormattedString(t,o.utils.unwrapObservable(e)),s=Math.min(a.length,r.length),n=0;s>n;)a[n](r[n]),n++}}))}return e.prototype.destroy=function(){return i.utils.wrappedDestroy(this)},e}(),i.formattedObservable=function(e){return new i.FormattedObservable(e,r.call(arguments,1))}},function(e,t,n){var r,i,o;r=n(5),o=r._,i=r.ko,r.locale_manager||(r.locale_manager=void 0),e.exports=r.LocalizedObservable=function(){function e(e,t,n){var s;return this.value=e,this.vm=n,t||(t={}),this.vm||(this.vm={}),this.read||r._throwMissing(this,"read"),r.locale_manager||r._throwMissing(this,"kb.locale_manager"),this.__kb||(this.__kb={}),this.__kb._onLocaleChange=o.bind(this._onLocaleChange,this),this.__kb._onChange=t.onChange,this.value&&(e=i.utils.unwrapObservable(this.value)),this.vo=i.observable(e?this.read(e,null):null),s=r.utils.wrappedObservable(this,i.dependentObservable({read:function(e){return function(){return e.value&&i.utils.unwrapObservable(e.value),e.vo(),e.read(i.utils.unwrapObservable(e.value))}}(this),write:function(e){return function(t){return e.write||r._throwUnexpected(e,"writing to read-only"),e.write(t,i.utils.unwrapObservable(e.value)),e.vo(t),e.__kb._onChange?e.__kb._onChange(t):void 0}}(this),owner:this.vm})),r.publishMethods(s,this,["destroy","observedValue","resetToCurrent"]),r.locale_manager.bind("change",this.__kb._onLocaleChange),t.hasOwnProperty("default")&&(s=r.DefaultObservable&&i.defaultObservable(s,t["default"])),s}return e.extend=r.extend,e.prototype.destroy=function(){return r.locale_manager.unbind("change",this.__kb._onLocaleChange),this.vm=null,r.utils.wrappedDestroy(this)},e.prototype.resetToCurrent=function(){var e,t;return t=r.utils.wrappedObservable(this),e=this.value?this.read(i.utils.unwrapObservable(this.value)):null,t()!==e?t(e):void 0},e.prototype.observedValue=function(e){return 0===arguments.length?this.value:(this.value=e,void this._onLocaleChange())},e.prototype._onLocaleChange=function(){var e;return e=this.read(i.utils.unwrapObservable(this.value)),this.vo(e),this.__kb._onChange?this.__kb._onChange(e):void 0},e}(),r.localizedObservable=function(e,t,n){return new r.LocalizedObservable(e,t,n)}},function(e,t,n){var r,i,o;r=n(5),o=r._,i=r.ko,e.exports=r.TriggeredObservable=function(){function e(e,t){var n;return this.event_selector=t,e||r._throwMissing(this,"emitter"),this.event_selector||r._throwMissing(this,"event_selector"),this.vo=i.observable(),n=r.utils.wrappedObservable(this,i.dependentObservable(function(e){return function(){return e.vo()}}(this))),r.publishMethods(n,this,["destroy"]),r.utils.wrappedEventWatcher(this,new r.EventWatcher(e,this,{emitter:o.bind(this.emitter,this),update:o.bind(this.update,this),event_selector:this.event_selector})),n}return e.prototype.destroy=function(){return r.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}(),r.triggeredObservable=function(e,t){return new r.TriggeredObservable(e,t)}},function(e,t,n){var r,i,o,s,a;o=n(5),a=o._,s=o.ko,r=o.$,n(20),i=function(e){return e=s.utils.unwrapObservable(e),"function"==typeof e?e.apply(null,Array.prototype.slice.call(arguments,1)):e},e.exports=o.Validation=function(){function e(){}return e}(),o.valueValidator=function(e,t,n){return null==n&&(n={}),n&&!("function"==typeof n)||(n={}),s.dependentObservable(function(){var r,o,l,u,c,d,p,f;p={$error_count:0},o=s.utils.unwrapObservable(e),!("disable"in n)||(l=i(n.disable)),!("enable"in n)||(l=!i(n.enable)),d=n.priorities||[],a.isArray(d)||(d=[d]),r=d.length+1;for(u in t)f=t[u],p[u]=!l&&i(f,o),p[u]&&(p.$error_count++,(c=a.indexOf(d,u)>=0)||(c=d.length),p.$active_error&&r>c?(p.$active_error=u,r=c):p.$active_error||(p.$active_error=u,r=c));return p.$enabled=!l,p.$disable=!!l,p.$valid=0===p.$error_count,p})},o.inputValidator=function(e,t,n){var i,s,l,u,c,d,p,f,h,v;if(null==n&&(n={}),n&&!("function"==typeof n)||(n={}),h=o.valid,i=r(t),(u=i.attr("name"))&&!a.isString(u)&&(u=null),!(s=i.attr("data-bind")))return null;if(c=new Function("sc","with(sc[0]) { return { "+s+" } }")([e]),!c||!c.value)return null;if(!c.validation_options||(a.defaults(c.validation_options,n),n=c.validation_options),s={},!h[p=i.attr("type")]||(s[p]=h[p]),!i.attr("required")||(s.required=h.required),c.validations){v=c.validations;for(l in v)f=v[l],s[l]=f}return d=o.valueValidator(c.value,s,n),!u&&!n.no_attach||(e["$"+u]=d),d},o.formValidator=function(e,t){var n,i,l,u,c,d,p,f,h,v,b,m,g;for(p={},v=[],n=r(t),(l=n.attr("name"))&&!a.isString(l)&&(l=null),(i=n.attr("data-bind"))&&(d=new Function("sc","with(sc[0]) { return { "+i+" } }")([e]),f=d.validation_options),f||(f={}),f.no_attach=!!l,g=n.find("input"),b=0,m=g.length;m>b;b++)u=g[b],(c=r(u).attr("name"))&&(h=o.inputValidator(e,u,f),!h||v.push(p[c]=h));return p.$error_count=s.dependentObservable(function(){var e,t,n;for(e=0,t=0,n=v.length;n>t;t++)h=v[t],e+=h().$error_count;return e}),p.$valid=s.dependentObservable(function(){return 0===p.$error_count()}),p.$enabled=s.dependentObservable(function(){var e,t,n;for(e=!0,t=0,n=v.length;n>t;t++)h=v[t],e&=h().$enabled;return e}),p.$disabled=s.dependentObservable(function(){return!p.$enabled()}),l&&(e["$"+l]=p),p}},function(t){t.exports=e},function(e,t,n){var r,i,o;r=n(5),o=r._,i=r.ko,r.Observable.prototype.setToDefault=function(){var e;null!=(e=this.__kb_value)&&"function"==typeof e.setToDefault&&e.setToDefault()},r.ViewModel.prototype.setToDefault=function(){var e,t;for(e in this.__kb.vm_keys)null!=(t=this[e])&&"function"==typeof t.setToDefault&&t.setToDefault()},r.utils.setToDefault=function(e){var t,n;if(e){if(i.isObservable(e))"function"==typeof e.setToDefault&&e.setToDefault();else if(o.isObject(e))for(t in e)n=e[t],!n||!i.isObservable(n)&&"function"==typeof n||"_"===t[0]&&!t.search("__kb")||this.setToDefault(n);return e}}},function(e,t,n){var r,i,o,s,a,l,u;a=n(5),u=a._,l=a.ko,r=a.$,s=/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/,i=/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/,o=/^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/,a.valid={required:function(e){return!e},url:function(e){return!s.test(e)},email:function(e){return!i.test(e)},number:function(e){return!o.test(e)}},a.hasChangedFn=function(e){var t,n;return n=null,t=null,function(){var r;return n!==(r=l.utils.unwrapObservable(e))?(n=r,t=n?n.toJSON():null,!1):n&&t?!u.isEqual(n.toJSON(),t):!1}},a.minLengthFn=function(e){return function(t){return!t||t.lengthl;l++)if(e=a[l],s=this._events[e]){if(this._events[e]=i=[],t||r)for(d=0,p=s.length;p>d;d++)o=s[d],(t&&t!==o.callback&&t!==o.callback._callback||r&&r!==o.context)&&i.push(o);i.length||delete this._events[e]}return this},trigger:function(e){if(!this._events)return this;var t=s.call(arguments,1);if(!u(this,"trigger",e,t))return this;var n=this._events[e],r=this._events.all;return n&&c(n,t),r&&c(r,arguments),this},stopListening:function(e,t,r){var i=this._listeningTo;if(!i)return this;var o=!t&&!r;r||"object"!=typeof t||(r=this),e&&((i={})[e._listenId]=e);for(var s in i)e=i[s],e.off(t,r,this),(o||n.isEmpty(e._events))&&delete this._listeningTo[s];return this}},l=/\s+/,u=function(e,t,n,r){if(!n)return!0;if("object"==typeof n){for(var i in n)e[t].apply(e,[i,n[i]].concat(r));return!1}if(l.test(n)){for(var o=n.split(l),s=0,a=o.length;a>s;s++)e[t].apply(e,[o[s]].concat(r));return!1}return!0},c=function(e,t){var n,r=-1,i=e.length,o=t[0],s=t[1],a=t[2];switch(t.length){case 0:for(;++rp;p++)this.trigger("change:"+a[p],this,d[a[p]],r)}if(u)return this;if(!l)for(;this._pending;)r=this._pending,this._pending=!1,this.trigger("change",this,r);return this._pending=!1,this._changing=!1,this},unset:function(e,t){return this.set(e,void 0,n.extend({},t,{unset:!0}))},clear:function(e){var t={};for(var r in this.attributes)t[r]=void 0;return this.set(t,n.extend({},e,{unset:!0}))},hasChanged:function(e){return null==e?!n.isEmpty(this.changed):n.has(this.changed,e)},changedAttributes:function(e){if(!e)return this.hasChanged()?n.clone(this.changed):!1;var t,r=!1,i=this._changing?this._previousAttributes:this.attributes;for(var o in e)n.isEqual(i[o],t=e[o])||((r||(r={}))[o]=t);return r},previous:function(e){return null!=e&&this._previousAttributes?this._previousAttributes[e]:null},previousAttributes:function(){return n.clone(this._previousAttributes)},fetch:function(e){e=e?n.clone(e):{},void 0===e.parse&&(e.parse=!0);var t=this,r=e.success;return e.success=function(n){return t.set(t.parse(n,e),e)?(r&&r(t,n,e),void t.trigger("sync",t,n,e)):!1},I(this,e),this.sync("read",this,e)},save:function(e,t,r){var i,o,s,a=this.attributes;if(null==e||"object"==typeof e?(i=e,r=t):(i={})[e]=t,r=n.extend({validate:!0},r),i&&!r.wait){if(!this.set(i,r))return!1}else if(!this._validate(i,r))return!1;i&&r.wait&&(this.attributes=n.extend({},a,i)),void 0===r.parse&&(r.parse=!0);var l=this,u=r.success;return r.success=function(e){l.attributes=a;var t=l.parse(e,r);return r.wait&&(t=n.extend(i||{},t)),n.isObject(t)&&!l.set(t,r)?!1:(u&&u(l,e,r),void l.trigger("sync",l,e,r))},I(this,r),o=this.isNew()?"create":r.patch?"patch":"update","patch"===o&&(r.attrs=i),s=this.sync(o,this,r),i&&r.wait&&(this.attributes=a),s},destroy:function(e){e=e?n.clone(e):{};var t=this,r=e.success,i=function(){t.trigger("destroy",t,t.collection,e)};if(e.success=function(n){(e.wait||t.isNew())&&i(),r&&r(t,n,e),t.isNew()||t.trigger("sync",t,n,e)},this.isNew())return e.success(),!1;I(this,e);var o=this.sync("delete",this,e);return e.wait||i(),o},url:function(){var e=n.result(this,"urlRoot")||n.result(this.collection,"url")||F();return this.isNew()?e:e.replace(/([^\/])$/,"$1/")+encodeURIComponent(this.id)},parse:function(e){return e},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return!this.has(this.idAttribute)},isValid:function(e){return this._validate({},n.extend(e||{},{validate:!0}))},_validate:function(e,t){if(!t.validate||!this.validate)return!0;e=n.extend({},this.attributes,e);var r=this.validationError=this.validate(e,t)||null;return r?(this.trigger("invalid",this,r,n.extend(t,{validationError:r})),!1):!0}});var f=["keys","values","pairs","invert","pick","omit"];n.each(f,function(e){p.prototype[e]=function(){var t=s.call(arguments);return t.unshift(this.attributes),n[e].apply(n,t)}});var h=t.Collection=function(e,t){t||(t={}),t.model&&(this.model=t.model),void 0!==t.comparator&&(this.comparator=t.comparator),this._reset(),this.initialize.apply(this,arguments),e&&this.reset(e,n.extend({silent:!0},t))},v={add:!0,remove:!0,merge:!0},b={add:!0,remove:!1};n.extend(h.prototype,a,{model:p,initialize:function(){},toJSON:function(e){return this.map(function(t){return t.toJSON(e)})},sync:function(){return t.sync.apply(this,arguments)},add:function(e,t){return this.set(e,n.extend({merge:!1},t,b))},remove:function(e,t){var r=!n.isArray(e);e=r?[e]:n.clone(e),t||(t={});var i,o,s,a;for(i=0,o=e.length;o>i;i++)a=e[i]=this.get(e[i]),a&&(delete this._byId[a.id],delete this._byId[a.cid],s=this.indexOf(a),this.models.splice(s,1),this.length--,t.silent||(t.index=s,a.trigger("remove",a,this,t)),this._removeReference(a,t));return r?e[0]:e},set:function(e,t){t=n.defaults({},t,v),t.parse&&(e=this.parse(e,t));var r=!n.isArray(e);e=r?e?[e]:[]:n.clone(e);var i,o,s,a,l,u,c,d=t.at,f=this.model,h=this.comparator&&null==d&&t.sort!==!1,b=n.isString(this.comparator)?this.comparator:null,m=[],g=[],y={},_=t.add,w=t.merge,x=t.remove,k=!h&&_&&x?[]:!1;for(i=0,o=e.length;o>i;i++){if(l=e[i]||{},s=l instanceof p?a=l:l[f.prototype.idAttribute||"id"],u=this.get(s))x&&(y[u.cid]=!0),w&&(l=l===a?a.attributes:l,t.parse&&(l=u.parse(l,t)),u.set(l,t),h&&!c&&u.hasChanged(b)&&(c=!0)),e[i]=u;else if(_){if(a=e[i]=this._prepareModel(l,t),!a)continue;m.push(a),this._addReference(a,t)}a=u||a,!k||!a.isNew()&&y[a.id]||k.push(a),y[a.id]=!0}if(x){for(i=0,o=this.length;o>i;++i)y[(a=this.models[i]).cid]||g.push(a);g.length&&this.remove(g,t)}if(m.length||k&&k.length)if(h&&(c=!0),this.length+=m.length,null!=d)for(i=0,o=m.length;o>i;i++)this.models.splice(d+i,0,m[i]);else{k&&(this.models.length=0);var O=k||m;for(i=0,o=O.length;o>i;i++)this.models.push(O[i])}if(c&&this.sort({silent:!0}),!t.silent){for(i=0,o=m.length;o>i;i++)(a=m[i]).trigger("add",a,this,t);(c||k&&k.length)&&this.trigger("sort",this,t)}return r?e[0]:e},reset:function(e,t){t||(t={});for(var r=0,i=this.models.length;i>r;r++)this._removeReference(this.models[r],t);return t.previousModels=this.models,this._reset(),e=this.add(e,n.extend({silent:!0},t)),t.silent||this.trigger("reset",this,t),e},push:function(e,t){return this.add(e,n.extend({at:this.length},t))},pop:function(e){var t=this.at(this.length-1);return this.remove(t,e),t},unshift:function(e,t){return this.add(e,n.extend({at:0},t))},shift:function(e){var t=this.at(0);return this.remove(t,e),t},slice:function(){return s.apply(this.models,arguments)},get:function(e){return null==e?void 0:this._byId[e]||this._byId[e.id]||this._byId[e.cid]},at:function(e){return this.models[e]},where:function(e,t){return n.isEmpty(e)?t?void 0:[]:this[t?"find":"filter"](function(t){for(var n in e)if(e[n]!==t.get(n))return!1;return!0})},findWhere:function(e){return this.where(e,!0)},sort:function(e){if(!this.comparator)throw new Error("Cannot sort a set without a comparator");return e||(e={}),n.isString(this.comparator)||1===this.comparator.length?this.models=this.sortBy(this.comparator,this):this.models.sort(n.bind(this.comparator,this)),e.silent||this.trigger("sort",this,e),this},pluck:function(e){return n.invoke(this.models,"get",e)},fetch:function(e){e=e?n.clone(e):{},void 0===e.parse&&(e.parse=!0);var t=e.success,r=this;return e.success=function(n){var i=e.reset?"reset":"set";r[i](n,e),t&&t(r,n,e),r.trigger("sync",r,n,e)},I(this,e),this.sync("read",this,e)},create:function(e,t){if(t=t?n.clone(t):{},!(e=this._prepareModel(e,t)))return!1;t.wait||this.add(e,t);var r=this,i=t.success;return t.success=function(e,n){t.wait&&r.add(e,t),i&&i(e,n,t)},e.save(null,t),e},parse:function(e){return e},clone:function(){return new this.constructor(this.models)},_reset:function(){this.length=0,this.models=[],this._byId={}},_prepareModel:function(e,t){if(e instanceof p)return e;t=t?n.clone(t):{},t.collection=this;var r=new this.model(e,t);return r.validationError?(this.trigger("invalid",this,r.validationError,t),!1):r},_addReference:function(e){this._byId[e.cid]=e,null!=e.id&&(this._byId[e.id]=e),e.collection||(e.collection=this),e.on("all",this._onModelEvent,this)},_removeReference:function(e){this===e.collection&&delete e.collection,e.off("all",this._onModelEvent,this)},_onModelEvent:function(e,t,n,r){("add"!==e&&"remove"!==e||n===this)&&("destroy"===e&&this.remove(t,r),t&&e==="change:"+t.idAttribute&&(delete this._byId[t.previous(t.idAttribute)],null!=t.id&&(this._byId[t.id]=t)),this.trigger.apply(this,arguments))}});var m=["forEach","each","map","collect","reduce","foldl","inject","reduceRight","foldr","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","toArray","size","first","head","take","initial","rest","tail","drop","last","without","difference","indexOf","shuffle","lastIndexOf","isEmpty","chain","sample"];n.each(m,function(e){h.prototype[e]=function(){var t=s.call(arguments);return t.unshift(this.models),n[e].apply(n,t)}});var g=["groupBy","countBy","sortBy","indexBy"];n.each(g,function(e){h.prototype[e]=function(t,r){var i=n.isFunction(t)?t:function(e){return e.get(t)};return n[e](this.models,i,r)}});var y=t.View=function(e){this.cid=n.uniqueId("view"),e||(e={}),n.extend(this,n.pick(e,w)),this._ensureElement(),this.initialize.apply(this,arguments),this.delegateEvents()},_=/^(\S+)\s*(.*)$/,w=["model","collection","el","id","attributes","className","tagName","events"];n.extend(y.prototype,a,{tagName:"div",$:function(e){return this.$el.find(e)},initialize:function(){},render:function(){return this},remove:function(){return this.$el.remove(),this.stopListening(),this},setElement:function(e,n){return this.$el&&this.undelegateEvents(),this.$el=e instanceof t.$?e:t.$(e),this.el=this.$el[0],n!==!1&&this.delegateEvents(),this},delegateEvents:function(e){if(!e&&!(e=n.result(this,"events")))return this;this.undelegateEvents();for(var t in e){var r=e[t];if(n.isFunction(r)||(r=this[e[t]]),r){var i=t.match(_),o=i[1],s=i[2];r=n.bind(r,this),o+=".delegateEvents"+this.cid,""===s?this.$el.on(o,r):this.$el.on(o,s,r)}}return this},undelegateEvents:function(){return this.$el.off(".delegateEvents"+this.cid),this},_ensureElement:function(){if(this.el)this.setElement(n.result(this,"el"),!1);else{var e=n.extend({},n.result(this,"attributes"));this.id&&(e.id=n.result(this,"id")),this.className&&(e["class"]=n.result(this,"className"));var r=t.$("<"+n.result(this,"tagName")+">").attr(e);this.setElement(r,!1)}}}),t.sync=function(e,r,i){var o=k[e];n.defaults(i||(i={}),{emulateHTTP:t.emulateHTTP,emulateJSON:t.emulateJSON});var s={type:o,dataType:"json"};if(i.url||(s.url=n.result(r,"url")||F()),null!=i.data||!r||"create"!==e&&"update"!==e&&"patch"!==e||(s.contentType="application/json",s.data=JSON.stringify(i.attrs||r.toJSON(i))),i.emulateJSON&&(s.contentType="application/x-www-form-urlencoded",s.data=s.data?{model:s.data}:{}),i.emulateHTTP&&("PUT"===o||"DELETE"===o||"PATCH"===o)){s.type="POST",i.emulateJSON&&(s.data._method=o);var a=i.beforeSend;i.beforeSend=function(e){return e.setRequestHeader("X-HTTP-Method-Override",o),a?a.apply(this,arguments):void 0}}"GET"===s.type||i.emulateJSON||(s.processData=!1),"PATCH"===s.type&&x&&(s.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")});var l=i.xhr=t.ajax(n.extend(s,i));return r.trigger("request",r,l,i),l};var x=!("undefined"==typeof window||!window.ActiveXObject||window.XMLHttpRequest&&(new XMLHttpRequest).dispatchEvent),k={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};t.ajax=function(){return t.$.ajax.apply(t.$,arguments)};var O=t.Router=function(e){e||(e={}),e.routes&&(this.routes=e.routes),this._bindRoutes(),this.initialize.apply(this,arguments)},E=/\((.*?)\)/g,S=/(\(\?)?:\w+/g,T=/\*\w+/g,C=/[\-{}\[\]+?.,\\\^$|#\s]/g;n.extend(O.prototype,a,{initialize:function(){},route:function(e,r,i){n.isRegExp(e)||(e=this._routeToRegExp(e)),n.isFunction(r)&&(i=r,r=""),i||(i=this[r]);var o=this;return t.history.route(e,function(n){var s=o._extractParameters(e,n);o.execute(i,s),o.trigger.apply(o,["route:"+r].concat(s)),o.trigger("route",r,s),t.history.trigger("route",o,r,s)}),this},execute:function(e,t){e&&e.apply(this,t)},navigate:function(e,n){return t.history.navigate(e,n),this},_bindRoutes:function(){if(this.routes){this.routes=n.result(this,"routes");for(var e,t=n.keys(this.routes);null!=(e=t.pop());)this.route(e,this.routes[e])}},_routeToRegExp:function(e){return e=e.replace(C,"\\$&").replace(E,"(?:$1)?").replace(S,function(e,t){return t?e:"([^/?]+)"}).replace(T,"([^?]*?)"),new RegExp("^"+e+"(?:\\?([\\s\\S]*))?$")},_extractParameters:function(e,t){var r=e.exec(t).slice(1);return n.map(r,function(e,t){return t===r.length-1?e||null:e?decodeURIComponent(e):null})}});var N=t.History=function(){this.handlers=[],n.bindAll(this,"checkUrl"),"undefined"!=typeof window&&(this.location=window.location,this.history=window.history)},D=/^[#\/]|\s+$/g,M=/^\/+|\/+$/g,A=/msie [\w.]+/,P=/\/$/,R=/#.*$/;N.started=!1,n.extend(N.prototype,a,{interval:50,atRoot:function(){return this.location.pathname.replace(/[^\/]$/,"$&/")===this.root},getHash:function(e){var t=(e||this).location.href.match(/#(.*)$/);return t?t[1]:""},getFragment:function(e,t){if(null==e)if(this._hasPushState||!this._wantsHashChange||t){e=decodeURI(this.location.pathname+this.location.search);var n=this.root.replace(P,"");e.indexOf(n)||(e=e.slice(n.length))}else e=this.getHash();return e.replace(D,"")},start:function(e){if(N.started)throw new Error("Backbone.history has already been started");N.started=!0,this.options=n.extend({root:"/"},this.options,e),this.root=this.options.root,this._wantsHashChange=this.options.hashChange!==!1,this._wantsPushState=!!this.options.pushState,this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var r=this.getFragment(),i=document.documentMode,o=A.exec(navigator.userAgent.toLowerCase())&&(!i||7>=i);if(this.root=("/"+this.root+"/").replace(M,"/"),o&&this._wantsHashChange){var s=t.$('