forked from mWater/minimongo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminimongo.min.js
More file actions
3 lines (3 loc) · 75.1 KB
/
Copy pathminimongo.min.js
File metadata and controls
3 lines (3 loc) · 75.1 KB
1
2
3
require=function t(n,e,r){function o(u,c){if(!e[u]){if(!n[u]){var s="function"==typeof require&&require;if(!c&&s)return s(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var a=e[u]={exports:{}};n[u][0].call(a.exports,function(t){var e=n[u][1][t];return o(e?e:t)},a,a.exports,t,n,e,r)}return e[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({minimongo:[function(t,n){n.exports=t("1+WUYb")},{}],"1+WUYb":[function(t,n,e){e.MemoryDb=t("./lib/MemoryDb"),e.LocalStorageDb=t("./lib/LocalStorageDb"),e.IndexedDb=t("./lib/IndexedDb"),e.WebSQLDb=t("./lib/WebSQLDb"),e.RemoteDb=t("./lib/RemoteDb"),e.HybridDb=t("./lib/HybridDb"),e.ReplicatingDb=t("./lib/ReplicatingDb"),e.utils=t("./lib/utils")},{"./lib/HybridDb":6,"./lib/IndexedDb":7,"./lib/LocalStorageDb":8,"./lib/MemoryDb":9,"./lib/RemoteDb":10,"./lib/ReplicatingDb":11,"./lib/WebSQLDb":12,"./lib/utils":15}],dsrzUy:[function(t,n){n.exports=window.$},{}],jquery:[function(t,n){n.exports=t("dsrzUy")},{}],5:[function(t,n){var e=t("lodash");EJSON={};var r={};EJSON.addType=function(t,n){if(e.has(r,t))throw new Error("Type "+t+" already present");r[t]=n};var o=[{matchJSONValue:function(t){return e.has(t,"$date")&&1===e.size(t)},matchObject:function(t){return t instanceof Date},toJSONValue:function(t){return{$date:t.getTime()}},fromJSONValue:function(t){return new Date(t.$date)}},{matchJSONValue:function(t){return e.has(t,"$binary")&&1===e.size(t)},matchObject:function(t){return"undefined"!=typeof Uint8Array&&t instanceof Uint8Array||t&&e.has(t,"$Uint8ArrayPolyfill")},toJSONValue:function(t){return{$binary:EJSON._base64Encode(t)}},fromJSONValue:function(t){return EJSON._base64Decode(t.$binary)}},{matchJSONValue:function(t){return e.has(t,"$escape")&&1===e.size(t)},matchObject:function(t){return e.isEmpty(t)||e.size(t)>2?!1:e.any(o,function(n){return n.matchJSONValue(t)})},toJSONValue:function(t){var n={};return e.each(t,function(t,e){n[e]=EJSON.toJSONValue(t)}),{$escape:n}},fromJSONValue:function(t){var n={};return e.each(t.$escape,function(t,e){n[e]=EJSON.fromJSONValue(t)}),n}},{matchJSONValue:function(t){return e.has(t,"$type")&&e.has(t,"$value")&&2===e.size(t)},matchObject:function(t){return EJSON._isCustomType(t)},toJSONValue:function(t){return{$type:t.typeName(),$value:t.toJSONValue()}},fromJSONValue:function(t){var n=t.$type,e=r[n];return e(t.$value)}}];EJSON._isCustomType=function(t){return t&&"function"==typeof t.toJSONValue&&"function"==typeof t.typeName&&e.has(r,t.typeName())};var i=EJSON._adjustTypesToJSONValue=function(t){if(null===t)return null;var n=u(t);return void 0!==n?n:(e.each(t,function(n,e){if("object"==typeof n||void 0===n){var r=u(n);return r?void(t[e]=r):void i(n)}}),t)},u=function(t){for(var n=0;n<o.length;n++){var e=o[n];if(e.matchObject(t))return e.toJSONValue(t)}return void 0};EJSON.toJSONValue=function(t){var n=u(t);return void 0!==n?n:("object"==typeof t&&(t=EJSON.clone(t),i(t)),t)};var c=EJSON._adjustTypesFromJSONValue=function(t){if(null===t)return null;var n=s(t);return n!==t?n:(e.each(t,function(n,e){if("object"==typeof n){var r=s(n);if(n!==r)return void(t[e]=r);c(n)}}),t)},s=function(t){if("object"==typeof t&&null!==t&&e.size(t)<=2&&e.all(t,function(t,n){return"string"==typeof n&&"$"===n.substr(0,1)}))for(var n=0;n<o.length;n++){var r=o[n];if(r.matchJSONValue(t))return r.fromJSONValue(t)}return t};EJSON.fromJSONValue=function(t){var n=s(t);return n===t&&"object"==typeof t?(t=EJSON.clone(t),c(t),t):n},EJSON.stringify=function(t){return JSON.stringify(EJSON.toJSONValue(t))},EJSON.parse=function(t){return EJSON.fromJSONValue(JSON.parse(t))},EJSON.isBinary=function(t){return"undefined"!=typeof Uint8Array&&t instanceof Uint8Array||t&&t.$Uint8ArrayPolyfill},EJSON.equals=function(t,n,r){var o,i=!(!r||!r.keyOrderSensitive);if(t===n)return!0;if(!t||!n)return!1;if("object"!=typeof t||"object"!=typeof n)return!1;if(t instanceof Date&&n instanceof Date)return t.valueOf()===n.valueOf();if(EJSON.isBinary(t)&&EJSON.isBinary(n)){if(t.length!==n.length)return!1;for(o=0;o<t.length;o++)if(t[o]!==n[o])return!1;return!0}if("function"==typeof t.equals)return t.equals(n,r);if(t instanceof Array){if(!(n instanceof Array))return!1;if(t.length!==n.length)return!1;for(o=0;o<t.length;o++)if(!EJSON.equals(t[o],n[o],r))return!1;return!0}var u;if(i){var c=[];return e.each(n,function(t,n){c.push(n)}),o=0,u=e.all(t,function(t,e){return o>=c.length?!1:e!==c[o]?!1:EJSON.equals(t,n[c[o]],r)?(o++,!0):!1}),u&&o===c.length}return o=0,u=e.all(t,function(t,i){return e.has(n,i)&&EJSON.equals(t,n[i],r)?(o++,!0):!1}),u&&e.size(n)===o},EJSON.clone=function(t){var n;if("object"!=typeof t)return t;if(null===t)return null;if(t instanceof Date)return new Date(t.getTime());if(EJSON.isBinary(t)){n=EJSON.newBinary(t.length);for(var r=0;r<t.length;r++)n[r]=t[r];return n}if(e.isArray(t)||e.isArguments(t)){for(n=[],r=0;r<t.length;r++)n[r]=EJSON.clone(t[r]);return n}return"function"==typeof t.clone?t.clone():(n={},e.each(t,function(t,e){n[e]=EJSON.clone(t)}),n)},n.exports=EJSON},{lodash:"z2coUu"}],6:[function(t,n){var e,r,o,i,u;u=t("lodash"),o=t("./utils").processFind,i=t("./utils"),n.exports=r=function(){function t(t,n){this.localDb=t,this.remoteDb=n,this.collections={}}return t.prototype.addCollection=function(t,n,r,o){var i,c;return u.isFunction(n)&&(c=[{},n,r],n=c[0],r=c[1],o=c[2]),i=new e(t,this.localDb[t],this.remoteDb[t],n),this[t]=i,this.collections[t]=i,null!=r?r():void 0},t.prototype.removeCollection=function(t,n){return delete this[t],delete this.collections[t],null!=n?n():void 0},t.prototype.upload=function(t,n){var e,r;return e=u.values(this.collections),(r=function(t,n,e){var o;return o=u.first(t),o?o.upload(function(){return r(u.rest(t),n,e)},function(t){return e(t)}):n()})(e,t,n)},t}(),e=function(){function t(t,n,e,r){this.name=t,this.localCol=n,this.remoteCol=e,this.options=r||{},u.defaults(this.options,{cacheFind:!0,cacheFindOne:!0,interim:!0,useLocalOnRemoteError:!0,shortcut:!1,timeout:0,sortUpserts:null})}return t.prototype.find=function(t,n){return null==n&&(n={}),{fetch:function(e){return function(r,o){return e._findFetch(t,n,r,o)}}(this)}},t.prototype.findOne=function(t,n,e,r){var o,i;return null==n&&(n={}),u.isFunction(n)&&(i=[{},n,e],n=i[0],e=i[1],r=i[2]),u.defaults(n,this.options),o=function(o){return function(i){var c;return c=u.cloneDeep(n),c.interim=!1,c.cacheFind=n.cacheFindOne,t._id?c.limit=1:delete c.limit,o.find(t,c).fetch(function(t){return t.length>0?u.isEqual(i,t[0])?void 0:e(t[0]):e(null)},r)}}(this),n.interim||n.shortcut?this.localCol.findOne(t,n,function(t){return t&&(e(u.cloneDeep(t)),n.shortcut)?void 0:o(t)},r):o()},t.prototype._findFetch=function(t,n,e,r){var i,c;return u.defaults(n,this.options),c=function(i){return function(c){var s,a,l,f,d;return a=u.cloneDeep(n),n.cacheFind&&delete a.fields,d=null,f=!1,l=function(s){var a,l;return d&&clearTimeout(d),f?void(n.cacheFind&&i.localCol.cache(s,t,n,function(){},r)):n.cacheFind?(a=function(){var o;return o=function(t){return u.isEqual(c,t)?void 0:e(t)},i.localCol.find(t,n).fetch(o,r)},i.localCol.cache(s,t,n,a,r)):(l=s,i.localCol.pendingRemoves(function(a){var f;return a.length>0&&(f=u.object(u.map(a,function(t){return[t,t]})),l=u.filter(s,function(t){return!u.has(f,t._id)})),i.localCol.pendingUpserts(function(r){var i;return r.length>0&&(i=u.object(u.map(r,function(t){return t.doc._id}),u.map(r,function(t){return t.doc._id})),l=u.filter(l,function(t){return!u.has(i,t._id)}),l=l.concat(u.pluck(r,"doc")),l=o(l,t,n)),u.isEqual(c,l)?void 0:e(l)},r)},r))},s=function(o){if(d&&clearTimeout(d),!f&&!n.interim){if(n.useLocalOnRemoteError)return i.localCol.find(t,n).fetch(e,r);if(r)return r(o)}},n.timeout&&(d=setTimeout(function(){if(d=null,f=!0,!n.interim){if(n.useLocalOnRemoteError)return i.localCol.find(t,n).fetch(e,r);if(r)return r(new Error("Remote timed out"))}},n.timeout)),i.remoteCol.find(t,a).fetch(l,s)}}(this),n.interim?(i=function(t){return e(t),c(t)},this.localCol.find(t,n).fetch(i,r)):c()},t.prototype.upsert=function(t,n,e,r){return this.localCol.upsert(t,n,function(){return u.isFunction(n)&&(e=n),"function"==typeof e?e(t):void 0},r)},t.prototype.remove=function(t,n,e){return this.localCol.remove(t,function(){return null!=n?n():void 0},e)},t.prototype.upload=function(t,n){var e,r;return r=function(t){return function(n,e,o){var i;return i=u.first(n),i?t.remoteCol.upsert(i.doc,i.base,function(c){return t.localCol.resolveUpserts([i],function(){return c?t.localCol.cacheOne(c,function(){return r(u.rest(n),e,o)},o):t.localCol.remove(i.doc._id,function(){return t.localCol.resolveRemove(i.doc._id,function(){return r(u.rest(n),e,o)},o)},o)},o)},function(c){return 410===c.status||403===c.status?t.localCol.remove(i.doc._id,function(){return t.localCol.resolveRemove(i.doc._id,function(){return 410===c.status?r(u.rest(n),e,o):o(c)},o)},o):o(c)}):e()}}(this),e=function(t){return function(n,r,o){var i;return i=u.first(n),i?t.remoteCol.remove(i,function(){return t.localCol.resolveRemove(i,function(){return e(u.rest(n),r,o)},o)},function(c){return 410===c.status||403===c.status?t.localCol.resolveRemove(i,function(){return 410===c.status?e(u.rest(n),r,o):o(c)},o):o(c)},o):r()}}(this),this.localCol.pendingUpserts(function(o){return function(i){return o.options.sortUpserts&&i.sort(o.options.sortUpserts),r(i,function(){return o.localCol.pendingRemoves(function(r){return e(r,t,n)},n)},n)}}(this),n)},t}()},{"./utils":15,lodash:"z2coUu"}],7:[function(t,n){var e,r,o,i,u,c,s,a;a=t("lodash"),i=t("async"),r=t("idb-wrapper"),s=t("./utils"),c=t("./utils").processFind,u=t("./selector").compileSort,n.exports=o=function(){function t(t,n,e){var o;this.collections={};try{this.store=new r({dbVersion:1,storeName:"minimongo_"+t.namespace,keyPath:["col","doc._id"],autoIncrement:!1,onStoreReady:function(t){return function(){return n?n(t):void 0}}(this),onError:e,indexes:[{name:"col",keyPath:"col",unique:!1,multiEntry:!1},{name:"col-state",keyPath:["col","state"],unique:!1,multiEntry:!1}]})}catch(i){return o=i,void(e&&e(o))}}return t.prototype.addCollection=function(t,n){var r;return r=new e(t,this.store),this[t]=r,this.collections[t]=r,n?n():void 0},t.prototype.removeCollection=function(t,n,e){return delete this[t],delete this.collections[t],this.store.query(function(t){return function(r){var o;return o=a.map(r,function(t){return[t.col,t.doc._id]}),o.length>0?t.store.removeBatch(o,function(){return null!=n?n():void 0},e):null!=n?n():void 0}}(this),{index:"col",keyRange:this.store.makeKeyRange({only:t}),onError:e})},t}(),e=function(){function t(t,n){this.name=t,this.store=n}return t.prototype.find=function(t,n){return{fetch:function(e){return function(r,o){return e._findFetch(t,n,r,o)}}(this)}},t.prototype.findOne=function(t,n,e,r){var o;return a.isFunction(n)&&(o=[{},n,e],n=o[0],e=o[1],r=o[2]),this.find(t,n).fetch(function(t){return null!=e?e(t.length>0?t[0]:null):void 0},r)},t.prototype._findFetch=function(t,n,e,r){return this.store.query(function(r){return r=a.filter(r,function(t){return"removed"!==t.state}),null!=e?e(c(a.pluck(r,"doc"),t,n)):void 0},{index:"col",keyRange:this.store.makeKeyRange({only:this.name}),onError:r})},t.prototype.upsert=function(t,n,e,r){var o,i,u;return u=s.regularizeUpsert(t,n,e,r),o=u[0],e=u[1],r=u[2],i=a.map(o,function(t){return function(n){return[t.name,n.doc._id]}}(this)),this.store.getBatch(i,function(n){return function(i){var u;return u=a.map(o,function(t,e){var r;return r=void 0!==t.base?t.base:i[e]&&i[e].doc&&"cached"===i[e].state?i[e].doc:i[e]&&i[e].doc&&"upserted"===i[e].state?i[e].base:null,{col:n.name,state:"upserted",doc:t.doc,base:r}}),n.store.putBatch(u,function(){return e?e(t):void 0},r)}}(this),r)},t.prototype.remove=function(t,n,e){return this.store.get([this.name,t],function(r){return function(o){return null==o&&(o={col:r.name,doc:{_id:t}}),o.state="removed",r.store.put(o,function(){return n?n(t):void 0},e)}}(this))},t.prototype.cache=function(t,n,e,r,o){var i,c,s;return s=function(i){return function(){var c,s;return c=a.object(a.pluck(t,"_id"),t),e.sort&&(s=u(e.sort)),i.find(n,e).fetch(function(n){var u,l;return l=[],u=a.map(n,function(t){return[i.name,t._id]}),0===u.length?void(null!=r&&r()):i.store.getBatch(u,function(u){var f,d,h,p,m;for(f=p=0,m=u.length;m>=0?m>p:p>m;f=m>=0?++p:--p)if(d=u[f],h=n[f],!c[h._id]&&d&&"cached"===d.state){if(e.sort&&e.limit&&t.length===e.limit&&s(h,a.last(t))>=0)continue;l.push([i.name,h._id])}return l.length>0?i.store.removeBatch(l,function(){return null!=r?r():void 0},o):null!=r?r():void 0},o)},o)}}(this),0===t.length?s():(i=a.map(t,function(t){return function(n){return[t.name,n._id]}}(this)),c=[],this.store.getBatch(i,function(n){return function(e){var r,i,u,a,l;for(i=a=0,l=e.length;l>=0?l>a:a>l;i=l>=0?++a:--a)u=e[i],r=t[i],(null==u||"cached"===u.state)&&(!u||!r._rev||!u.doc._rev||r._rev>=u.doc._rev)&&c.push({col:n.name,state:"cached",doc:r});return c.length>0?n.store.putBatch(c,s,o):s()}}(this),o))},t.prototype.pendingUpserts=function(t,n){return this.store.query(function(n){var e;return e=a.map(n,function(t){return{doc:t.doc,base:t.base||null}}),null!=t?t(e):void 0},{index:"col-state",keyRange:this.store.makeKeyRange({only:[this.name,"upserted"]}),onError:n})},t.prototype.pendingRemoves=function(t,n){return this.store.query(function(n){return null!=t?t(a.pluck(a.pluck(n,"doc"),"_id")):void 0},{index:"col-state",keyRange:this.store.makeKeyRange({only:[this.name,"removed"]}),onError:n})},t.prototype.resolveUpserts=function(t,n,e){var r;return r=a.map(t,function(t){return function(n){return[t.name,n.doc._id]}}(this)),this.store.getBatch(r,function(r){return function(o){var i,u,c,s,l;for(u=[],i=s=0,l=t.length;l>=0?l>s:s>l;i=l>=0?++s:--s)c=o[i],c&&"upserted"===c.state&&(a.isEqual(c.doc,t[i].doc)?(c.state="cached",u.push(c)):(c.base=t[i].doc,u.push(c)));return u.length>0?r.store.putBatch(u,function(){return n?n():void 0},e):n?n():void 0}}(this),e)},t.prototype.resolveRemove=function(t,n,e){return this.store.get([this.name,t],function(r){return function(o){return o?"removed"===o.state?r.store.remove([r.name,t],function(){return null!=n?n():void 0},e):void 0:void(null!=n&&n())}}(this))},t.prototype.seed=function(t,n,e){var r,o;return a.isArray(t)||(t=[t]),r=a.map(t,function(t){return function(n){return[t.name,n._id]}}(this)),o=[],this.store.getBatch(r,function(r){return function(i){var u,c,s,a,l;for(c=a=0,l=i.length;l>=0?l>a:a>l;c=l>=0?++a:--a)s=i[c],u=t[c],null==s&&o.push({col:r.name,state:"cached",doc:u});return o.length>0?r.store.putBatch(o,function(){return null!=n?n():void 0},e):null!=n?n():void 0}}(this),e)},t.prototype.cacheOne=function(t,n,e){return this.store.get([this.name,t._id],function(r){return function(o){return o&&t._rev&&o.doc._rev&&t._rev<o.doc._rev?void(null!=n&&n()):(null==o&&(o={col:r.name,state:"cached",doc:t}),"cached"===o.state?(o.doc=t,r.store.put(o,function(){return null!=n?n():void 0},e)):null!=n?n():void 0)}}(this))},t.prototype.uncache=function(t,n,e){var r;return r=s.compileDocumentSelector(t),this.store.query(function(t){return function(o){var i;return o=a.filter(o,function(t){return"cached"===t.state&&r(t.doc)}),i=a.map(o,function(n){return[t.name,n.doc._id]}),i.length>0?t.store.removeBatch(i,function(){return null!=n?n():void 0},e):null!=n?n():void 0}}(this),{index:"col",keyRange:this.store.makeKeyRange({only:this.name}),onError:e})},t}()},{"./selector":14,"./utils":15,async:18,"idb-wrapper":21,lodash:"z2coUu"}],8:[function(t,n){var e,r,o,i,u,c;c=t("lodash"),u=t("./utils"),i=t("./utils").processFind,o=t("./selector").compileSort,n.exports=r=function(){function t(t,n){this.collections={},t&&t.namespace&&window.localStorage&&(this.namespace=t.namespace),n&&n(this)}return t.prototype.addCollection=function(t,n){var r,o;return this.namespace&&(o=this.namespace+"."+t),r=new e(t,o),this[t]=r,this.collections[t]=r,null!=n?n():void 0},t.prototype.removeCollection=function(t,n){var e,r,o,i,u,c,s,a;if(this.namespace&&window.localStorage){for(i=[],e=u=0,a=window.localStorage.length;a>=0?a>u:u>a;e=a>=0?++u:--u)i.push(window.localStorage.key(e));for(c=0,s=i.length;s>c;c++)r=i[c],o=this.namespace+"."+t,r.substring(0,o.length)===o&&window.localStorage.removeItem(r)}return delete this[t],delete this.collections[t],null!=n?n():void 0},t}(),e=function(){function t(t,n){this.name=t,this.namespace=n,this.items={},this.upserts={},this.removes={},window.localStorage&&null!=n&&this.loadStorage()}return t.prototype.loadStorage=function(){var t,n,e,r,o,i,u,s,a,l;for(this.itemNamespace=this.namespace+"_",n=u=0,l=window.localStorage.length;l>=0?l>u:u>l;n=l>=0?++u:--u)r=window.localStorage.key(n),r.substring(0,this.itemNamespace.length)===this.itemNamespace&&(e=JSON.parse(window.localStorage[r]),this.items[e._id]=e);for(i=window.localStorage[this.namespace+"upserts"]?JSON.parse(window.localStorage[this.namespace+"upserts"]):[],s=0,a=i.length;a>s;s++)r=i[s],this.upserts[r]={doc:this.items[r]},t=window.localStorage[this.namespace+"upsertbase_"+r]?JSON.parse(window.localStorage[this.namespace+"upsertbase_"+r]):null,this.upserts[r].base=t;return o=window.localStorage[this.namespace+"removes"]?JSON.parse(window.localStorage[this.namespace+"removes"]):[],this.removes=c.object(c.pluck(o,"_id"),o)},t.prototype.find=function(t,n){return{fetch:function(e){return function(r,o){return e._findFetch(t,n,r,o)}}(this)}},t.prototype.findOne=function(t,n,e,r){var o;return c.isFunction(n)&&(o=[{},n,e],n=o[0],e=o[1],r=o[2]),this.find(t,n).fetch(function(t){return null!=e?e(t.length>0?t[0]:null):void 0},r)},t.prototype._findFetch=function(t,n,e){return null!=e?e(i(c.cloneDeep(c.values(this.items)),t,n)):void 0},t.prototype.upsert=function(t,n,e,r){var o,i,s,a,l;for(l=u.regularizeUpsert(t,n,e,r),i=l[0],e=l[1],r=l[2],s=0,a=i.length;a>s;s++)o=i[s],void 0===o.base&&(o.base=this.upserts[o.doc._id]?this.upserts[o.doc._id].base:this.items[o.doc._id]||null),o=c.cloneDeep(o),this._putItem(o.doc),this._putUpsert(o);return e?e(t):void 0},t.prototype.remove=function(t,n){return c.has(this.items,t)?(this._putRemove(this.items[t]),this._deleteItem(t),this._deleteUpsert(t)):this._putRemove({_id:t}),null!=n?n():void 0},t.prototype._putItem=function(t){return this.items[t._id]=t,this.namespace?window.localStorage[this.itemNamespace+t._id]=JSON.stringify(t):void 0},t.prototype._deleteItem=function(t){return delete this.items[t],this.namespace?window.localStorage.removeItem(this.itemNamespace+t):void 0},t.prototype._putUpsert=function(t){return this.upserts[t.doc._id]=t,this.namespace?(window.localStorage[this.namespace+"upserts"]=JSON.stringify(c.keys(this.upserts)),window.localStorage[this.namespace+"upsertbase_"+t.doc._id]=JSON.stringify(t.base)):void 0},t.prototype._deleteUpsert=function(t){return delete this.upserts[t],this.namespace?window.localStorage[this.namespace+"upserts"]=JSON.stringify(c.keys(this.upserts)):void 0},t.prototype._putRemove=function(t){return this.removes[t._id]=t,this.namespace?window.localStorage[this.namespace+"removes"]=JSON.stringify(c.values(this.removes)):void 0},t.prototype._deleteRemove=function(t){return delete this.removes[t],this.namespace?window.localStorage[this.namespace+"removes"]=JSON.stringify(c.values(this.removes)):void 0},t.prototype.cache=function(t,n,e,r,i){var u,s,a,l,f;for(l=0,f=t.length;f>l;l++)u=t[l],this.cacheOne(u);return s=c.object(c.pluck(t,"_id"),t),e.sort&&(a=o(e.sort)),this.find(n,e).fetch(function(n){return function(o){var i,u,l;for(u=0,l=o.length;l>u;u++)if(i=o[u],!s[i._id]&&!c.has(n.upserts,i._id)){if(e.sort&&e.limit&&t.length===e.limit&&a(i,c.last(t))>=0)continue;n._deleteItem(i._id)}return null!=r?r():void 0}}(this),i)},t.prototype.pendingUpserts=function(t){return t(c.values(this.upserts))},t.prototype.pendingRemoves=function(t){return t(c.pluck(this.removes,"_id"))},t.prototype.resolveUpserts=function(t,n){var e,r,o;for(r=0,o=t.length;o>r;r++)e=t[r],this.upserts[e.doc._id]&&(c.isEqual(e.doc,this.upserts[e.doc._id].doc)?this._deleteUpsert(e.doc._id):(this.upserts[e.doc._id].base=e.doc,this._putUpsert(this.upserts[e.doc._id])));return null!=n?n():void 0},t.prototype.resolveRemove=function(t,n){return this._deleteRemove(t),null!=n?n():void 0},t.prototype.seed=function(t,n){var e,r,o;for(c.isArray(t)||(t=[t]),r=0,o=t.length;o>r;r++)e=t[r],c.has(this.items,e._id)||c.has(this.removes,e._id)||this._putItem(e);return null!=n?n():void 0},t.prototype.cacheOne=function(t,n){var e;return c.has(this.upserts,t._id)||c.has(this.removes,t._id)||(e=this.items[t._id],(!e||!t._rev||!e._rev||t._rev>=e._rev)&&this._putItem(t)),null!=n?n():void 0},t.prototype.uncache=function(t,n){var e,r,o,i,s;for(e=u.compileDocumentSelector(t),s=c.values(this.items),o=0,i=s.length;i>o;o++)r=s[o],null==this.upserts[r._id]&&e(r)&&this._deleteItem(r._id);return null!=n?n():void 0},t}()},{"./selector":14,"./utils":15,lodash:"z2coUu"}],9:[function(t,n){var e,r,o,i,u,c;c=t("lodash"),u=t("./utils"),i=t("./utils").processFind,o=t("./selector").compileSort,n.exports=r=function(){function t(t,n){this.collections={},n&&n(this)}return t.prototype.addCollection=function(t,n){var r;return r=new e(t),this[t]=r,this.collections[t]=r,null!=n?n():void 0},t.prototype.removeCollection=function(t,n){return delete this[t],delete this.collections[t],null!=n?n():void 0},t}(),e=function(){function t(t){this.name=t,this.items={},this.upserts={},this.removes={}}return t.prototype.find=function(t,n){return{fetch:function(e){return function(r,o){return e._findFetch(t,n,r,o)}}(this)}},t.prototype.findOne=function(t,n,e,r){var o;return c.isFunction(n)&&(o=[{},n,e],n=o[0],e=o[1],r=o[2]),this.find(t,n).fetch(function(t){return null!=e?e(t.length>0?t[0]:null):void 0},r)},t.prototype._findFetch=function(t,n,e){return setTimeout(function(r){return function(){var o;return o=i(c.values(r.items),t,n),null!=e?e(o):void 0}}(this),0)},t.prototype.upsert=function(t,n,e,r){var o,i,c,s,a;for(a=u.regularizeUpsert(t,n,e,r),i=a[0],e=a[1],r=a[2],c=0,s=i.length;s>c;c++)o=i[c],void 0===o.base&&(o.base=this.upserts[o.doc._id]?this.upserts[o.doc._id].base:this.items[o.doc._id]||null),this.items[o.doc._id]=o.doc,this.upserts[o.doc._id]=o;return e?e(t):void 0},t.prototype.remove=function(t,n){return c.has(this.items,t)?(this.removes[t]=this.items[t],delete this.items[t],delete this.upserts[t]):this.removes[t]={_id:t},null!=n?n():void 0},t.prototype.cache=function(t,n,e,r,i){var u,s,a,l,f;for(l=0,f=t.length;f>l;l++)u=t[l],this.cacheOne(u);return s=c.object(c.pluck(t,"_id"),t),e.sort&&(a=o(e.sort)),this.find(n,e).fetch(function(n){return function(o){var i,u,l;for(u=0,l=o.length;l>u;u++)if(i=o[u],!s[i._id]&&!c.has(n.upserts,i._id)){if(e.sort&&e.limit&&t.length===e.limit&&a(i,c.last(t))>=0)continue;delete n.items[i._id]}return null!=r?r():void 0}}(this),i)},t.prototype.pendingUpserts=function(t){return t(c.values(this.upserts))},t.prototype.pendingRemoves=function(t){return t(c.pluck(this.removes,"_id"))},t.prototype.resolveUpserts=function(t,n){var e,r,o,i;for(o=0,i=t.length;i>o;o++)r=t[o],e=r.doc._id,this.upserts[e]&&(c.isEqual(r.doc,this.upserts[e].doc)?delete this.upserts[e]:this.upserts[e].base=r.doc);return null!=n?n():void 0},t.prototype.resolveRemove=function(t,n){return delete this.removes[t],null!=n?n():void 0},t.prototype.seed=function(t,n){var e,r,o;for(c.isArray(t)||(t=[t]),r=0,o=t.length;o>r;r++)e=t[r],c.has(this.items,e._id)||c.has(this.removes,e._id)||(this.items[e._id]=e);return null!=n?n():void 0},t.prototype.cacheOne=function(t,n){var e;return c.has(this.upserts,t._id)||c.has(this.removes,t._id)||(e=this.items[t._id],(!e||!t._rev||!e._rev||t._rev>=e._rev)&&(this.items[t._id]=t)),null!=n?n():void 0},t.prototype.uncache=function(t,n){var e,r;return e=u.compileDocumentSelector(t),r=c.filter(c.values(this.items),function(t){return function(n){return null!=t.upserts[n._id]||!e(n)}}(this)),this.items=c.object(c.pluck(r,"_id"),r),null!=n?n():void 0},t}()},{"./selector":14,"./utils":15,lodash:"z2coUu"}],10:[function(t,n){var e,r,o,i,u,c,s;s=t("lodash"),e=t("jquery"),i=t("async"),c=t("./utils"),u=t("./jQueryHttpClient"),n.exports=o=function(){function t(t,n,e){this.url=t,this.client=n,this.collections={},this.httpClient=e||u}return t.prototype.addCollection=function(t,n,e,o){var i,u,c;return null==n&&(n={}),s.isFunction(n)&&(c=[{},n,e],n=c[0],e=c[1],o=c[2]),u=n.url||this.url+t,i=new r(t,u,this.client,this.httpClient),this[t]=i,this.collections[t]=i,null!=e?e():void 0},t.prototype.removeCollection=function(t,n){return delete this[t],delete this.collections[t],null!=n?n():void 0},t}(),r=function(){function t(t,n,e,r){this.name=t,this.url=n,this.client=e,this.httpClient=r}return t.prototype.find=function(t,n){return null==n&&(n={}),{fetch:function(e){return function(r,o){var i;return i={},n.sort&&(i.sort=JSON.stringify(n.sort)),n.limit&&(i.limit=n.limit),n.skip&&(i.skip=n.skip),n.fields&&(i.fields=JSON.stringify(n.fields)),e.client&&(i.client=e.client),i.selector=JSON.stringify(t||{}),"undefined"!=typeof navigator&&null!==navigator&&-1!==navigator.userAgent.toLowerCase().indexOf("android 2.3")&&(i._=(new Date).getTime()),e.httpClient("GET",e.url,i,null,r,o)}}(this)}},t.prototype.findOne=function(t,n,e,r){var o,i;return null==n&&(n={}),s.isFunction(n)&&(i=[{},n,e],n=i[0],e=i[1],r=i[2]),o={},n.sort&&(o.sort=JSON.stringify(n.sort)),o.limit=1,this.client&&(o.client=this.client),o.selector=JSON.stringify(t||{}),"undefined"!=typeof navigator&&null!==navigator&&-1!==navigator.userAgent.toLowerCase().indexOf("android 2.3")&&(o._=(new Date).getTime()),this.httpClient("GET",this.url,o,null,function(t){return e(t&&t.length>0?t[0]:null)},r)},t.prototype.upsert=function(t,n,e,r){var o,u,a;if(a=c.regularizeUpsert(t,n,e,r),o=a[0],e=a[1],r=a[2],!this.client)throw new Error("Client required to upsert");return u=[],i.eachLimit(o,8,function(t){return function(n,e){var r;return n.doc._id||(n.doc._id=c.createUid()),r={client:t.client},"undefined"!=typeof navigator&&null!==navigator&&-1!==navigator.userAgent.toLowerCase().indexOf("android 2.3")&&(r._=(new Date).getTime()),n.base?t.httpClient("PATCH",t.url+"/"+n.doc._id,r,n,function(t){return u.push(t),e()},function(t){return e(t)}):t.httpClient("POST",t.url,r,n.doc,function(t){return u.push(t),e()},function(t){return e(t)})}}(this),function(n){if(n)return void(r&&r(n));if(s.isArray(t)){if(e)return e(u)}else if(e)return e(u[0])})},t.prototype.remove=function(t,n,e){var r;if(!this.client)throw new Error("Client required to remove");return r={client:this.client},this.httpClient("DELETE",this.url+"/"+t,r,null,n,function(t){return 410===t.status?n():e(t)})},t}()},{"./jQueryHttpClient":13,"./utils":15,async:18,jquery:"dsrzUy",lodash:"z2coUu"}],11:[function(t,n){var e,r,o,i;i=t("lodash"),o=t("./utils"),n.exports=r=function(){function t(t,n){this.collections={},this.masterDb=t,this.replicaDb=n}return t.prototype.addCollection=function(t,n){var r;return r=new e(t,this.masterDb[t],this.replicaDb[t]),this[t]=r,this.collections[t]=r,null!=n?n():void 0},t.prototype.removeCollection=function(t,n){return delete this[t],delete this.collections[t],null!=n?n():void 0},t}(),e=function(){function t(t,n,e){this.name=t,this.masterCol=n,this.replicaCol=e}return t.prototype.find=function(t,n){return this.masterCol.find(t,n)},t.prototype.findOne=function(t,n,e,r){return this.masterCol.findOne(t,n,e,r)},t.prototype.upsert=function(t,n,e,r){var u,c;return c=o.regularizeUpsert(t,n,e,r),u=c[0],e=c[1],r=c[2],this.masterCol.upsert(i.pluck(u,"doc"),i.pluck(u,"base"),function(n){return function(){return n.replicaCol.upsert(i.pluck(u,"doc"),i.pluck(u,"base"),function(){return e(t)},r)}}(this),r)},t.prototype.remove=function(t,n,e){return this.masterCol.remove(t,function(r){return function(){return r.replicaCol.remove(t,n,e)}}(this),e)},t.prototype.cache=function(t,n,e,r,o){return this.masterCol.cache(t,n,e,function(i){return function(){return i.replicaCol.cache(t,n,e,r,o)}}(this),o)},t.prototype.pendingUpserts=function(t,n){return this.masterCol.pendingUpserts(t,n)},t.prototype.pendingRemoves=function(t,n){return this.masterCol.pendingRemoves(t,n)},t.prototype.resolveUpserts=function(t,n,e){return this.masterCol.resolveUpserts(t,function(r){return function(){return r.replicaCol.resolveUpserts(t,n,e)}}(this),e)},t.prototype.resolveRemove=function(t,n,e){return this.masterCol.resolveRemove(t,function(r){return function(){return r.replicaCol.resolveRemove(t,n,e)}}(this),e)},t.prototype.seed=function(t,n,e){return this.masterCol.seed(t,function(r){return function(){return r.replicaCol.seed(t,n,e)}}(this),e)},t.prototype.cacheOne=function(t,n,e){return this.masterCol.cacheOne(t,function(r){return function(){return r.replicaCol.cacheOne(t,n,e)}}(this),e)},t.prototype.uncache=function(t,n,e){return this.masterCol.uncache(t,function(r){return function(){return r.replicaCol.uncache(t,n,e)}}(this),e)},t}()},{"./utils":15,lodash:"z2coUu"}],12:[function(t,n){var e,r,o,i,u,c,s,a;a=t("lodash"),o=t("async"),s=t("./utils"),c=t("./utils").processFind,i=t("./selector").compileSort,u=function(){},n.exports=r=function(){function t(t,n,e){var r,o,i,c;this.collections={};try{if(this.db=window.openDatabase("minimongo_"+t.namespace,"","Minimongo:"+t.namespace,5242880),!this.db)return e(new Error("Failed to create database"))}catch(s){return o=s,void(e&&e(o))}return i=function(t){return t.executeSql("CREATE TABLE docs (\n col TEXT NOT NULL,\n id TEXT NOT NULL,\n state TEXT NOT NULL,\n doc TEXT,\n PRIMARY KEY (col, id));",[],u,function(t,n){return e(n)})},c=function(t){return t.executeSql("ALTER TABLE docs ADD COLUMN base TEXT;",[],u,function(t,n){return e(n)})},r=function(t){return function(){return"1.0"===t.db.version?t.db.changeVersion("1.0","2.0",c,e,function(){return n?n(t):void 0}):"2.0"!==t.db.version?e("Unknown db version "+t.db.version):n?n(t):void 0}}(this),this.db.version?r():this.db.changeVersion("","1.0",i,e,r),this.db}return t.prototype.addCollection=function(t,n){var r;return r=new e(t,this.db),this[t]=r,this.collections[t]=r,n?n():void 0},t.prototype.removeCollection=function(t,n,e){return delete this[t],delete this.collections[t],this.db.transaction(function(r){return r.executeSql("DELETE FROM docs WHERE col = ?",[t],n,function(t,n){return e(n)})},e)},t}(),e=function(){function t(t,n){this.name=t,this.db=n}return t.prototype.find=function(t,n){return{fetch:function(e){return function(r,o){return e._findFetch(t,n,r,o)}}(this)}},t.prototype.findOne=function(t,n,e,r){var o;return a.isFunction(n)&&(o=[{},n,e],n=o[0],e=o[1],r=o[2]),this.find(t,n).fetch(function(t){return null!=e?e(t.length>0?t[0]:null):void 0},r)},t.prototype._findFetch=function(t,n,e,r){return r=r||function(){},this.db.readTransaction(function(o){return function(i){return i.executeSql("SELECT * FROM docs WHERE col = ?",[o.name],function(r,o){var i,u,s,a,l;for(i=[],u=a=0,l=o.rows.length;l>=0?l>a:a>l;u=l>=0?++a:--a)s=o.rows.item(u),"removed"!==s.state&&i.push(JSON.parse(s.doc));return null!=e?e(c(i,t,n)):void 0},function(t,n){return r(n)})}}(this),r)},t.prototype.upsert=function(t,n,e,r){var i,c;return c=s.regularizeUpsert(t,n,e,r),i=c[0],e=c[1],r=c[2],r=r||function(){},this.db.transaction(function(t){return function(e){var c;return c=a.map(i,function(t){return t.doc._id}),n={},o.eachSeries(c,function(o,i){return e.executeSql("SELECT * FROM docs WHERE col = ? AND id = ?",[t.name,o],function(t,r){var o;return e=t,r.rows.length>0&&(o=r.rows.item(0),"upserted"===o.state?n[o.id]=o.base?JSON.parse(o.base):null:"cached"===o.state&&(n[o.id]=JSON.parse(o.doc))),i()},function(t,n){return r(n)})},function(){var o,c,s,a,l,f;for(f=[],a=0,l=i.length;l>a;a++)s=i[a],c=s.doc._id,o=void 0!==s.base?s.base:n[c]?n[c]:null,f.push(e.executeSql("INSERT OR REPLACE INTO docs (col, id, state, doc, base) VALUES (?, ?, ?, ?, ?)",[t.name,s.doc._id,"upserted",JSON.stringify(s.doc),JSON.stringify(o)],u,function(t,n){return r(n)}));return f})}}(this),r,function(){return e?e(t):void 0})},t.prototype.remove=function(t,n,e){return e=e||function(){},this.db.transaction(function(r){return function(o){return o.executeSql("SELECT * FROM docs WHERE col = ? AND id = ?",[r.name,t],function(o,i){return i.rows.length>0?o.executeSql('UPDATE docs SET state="removed" WHERE col = ? AND id = ?',[r.name,t],function(){return n?n(t):void 0
},function(t,n){return e(n)}):o.executeSql("INSERT INTO docs (col, id, state, doc) VALUES (?, ?, ?, ?)",[r.name,t,"removed",JSON.stringify({_id:t})],function(){return n?n(t):void 0},function(t,n){return e(n)})},function(t,n){return e(n)})}}(this),e)},t.prototype.cache=function(t,n,e,r,u){return u=u||function(){},this.db.transaction(function(c){return function(s){return o.eachSeries(t,function(t,n){return s.executeSql("SELECT * FROM docs WHERE col = ? AND id = ?",[c.name,t._id],function(e,r){var o;return 0===r.rows.length||"cached"===r.rows.item(0).state?(o=r.rows.length>0?JSON.parse(r.rows.item(0).doc):null,!o||!t._rev||!o._rev||t._rev>=o._rev?e.executeSql("INSERT OR REPLACE INTO docs (col, id, state, doc) VALUES (?, ?, ?, ?)",[c.name,t._id,"cached",JSON.stringify(t)],function(){return n()},function(t,n){return u(n)}):n()):n()},function(t,n){return u(n)})},function(s){var l,f;return s?void(u&&u(s)):(l=a.object(a.pluck(t,"_id"),t),e.sort&&(f=i(e.sort)),c.find(n,e).fetch(function(n){return c.db.transaction(function(i){return o.eachSeries(n,function(n,r){return i.executeSql("SELECT * FROM docs WHERE col = ? AND id = ?",[c.name,n._id],function(o,i){return!l[n._id]&&i.rows.length>0&&"cached"===i.rows.item(0).state?e.sort&&e.limit&&t.length===e.limit&&f(n,a.last(t))>=0?r():o.executeSql("DELETE FROM docs WHERE col = ? AND id = ?",[c.name,n._id],function(){return r()},function(t,n){return u(n)}):r()},function(t,n){return u(n)})},function(t){return null!=t?void(null!=u&&u(t)):null!=r?r():void 0})},u)},u))})}}(this),u)},t.prototype.pendingUpserts=function(t,n){return n=n||function(){},this.db.readTransaction(function(e){return function(r){return r.executeSql("SELECT * FROM docs WHERE col = ? AND state = ?",[e.name,"upserted"],function(n,e){var r,o,i,u,c;for(r=[],o=u=0,c=e.rows.length;c>=0?c>u:u>c;o=c>=0?++u:--u)i=e.rows.item(o),r.push({doc:JSON.parse(i.doc),base:i.base?JSON.parse(i.base):null});return null!=t?t(r):void 0},function(t,e){return n(e)})}}(this),n)},t.prototype.pendingRemoves=function(t,n){return n=n||function(){},this.db.readTransaction(function(e){return function(r){return r.executeSql("SELECT * FROM docs WHERE col = ? AND state = ?",[e.name,"removed"],function(n,e){var r,o,i,u,c;for(r=[],o=u=0,c=e.rows.length;c>=0?c>u:u>c;o=c>=0?++u:--u)i=e.rows.item(o),r.push(JSON.parse(i.doc)._id);return null!=t?t(r):void 0},function(t,e){return n(e)})}}(this),n)},t.prototype.resolveUpserts=function(t,n,e){return e=e||function(){},this.db.transaction(function(r){return function(i){return o.eachSeries(t,function(t,n){return i.executeSql("SELECT * FROM docs WHERE col = ? AND id = ?",[r.name,t.doc._id],function(o,i){return i.rows.length>0&&"upserted"===i.rows.item(0).state?a.isEqual(JSON.parse(i.rows.item(0).doc),t.doc)?(o.executeSql('UPDATE docs SET state="cached" WHERE col = ? AND id = ?',[r.name,t.doc._id],u,function(t,n){return e(n)}),n()):(o.executeSql("UPDATE docs SET base=? WHERE col = ? AND id = ?",[JSON.stringify(t.doc),r.name,t.doc._id],u,function(t,n){return e(n)}),n()):n()},function(t,n){return e(n)})},function(t){return t?e(t):n?n():void 0})}}(this),e)},t.prototype.resolveRemove=function(t,n,e){return e=e||function(){},this.db.transaction(function(r){return function(o){return o.executeSql('DELETE FROM docs WHERE state="removed" AND col = ? AND id = ?',[r.name,t],function(){return n?n(t):void 0},function(t,n){return e(n)})}}(this),e)},t.prototype.seed=function(t,n,e){return a.isArray(t)||(t=[t]),e=e||function(){},this.db.transaction(function(r){return function(i){return o.eachSeries(t,function(t,n){return i.executeSql("SELECT * FROM docs WHERE col = ? AND id = ?",[r.name,t._id],function(o,i){return 0===i.rows.length?o.executeSql("INSERT OR REPLACE INTO docs (col, id, state, doc) VALUES (?, ?, ?, ?)",[r.name,t._id,"cached",JSON.stringify(t)],function(){return n()},function(t,n){return e(n)}):n()},function(t,n){return e(n)})},function(t){if(t){if(e)return e(t)}else if(n)return n()})}}(this),e)},t.prototype.cacheOne=function(t,n,e){return e=e||function(){},this.db.transaction(function(r){return function(o){return o.executeSql("SELECT * FROM docs WHERE col = ? AND id = ?",[r.name,t._id],function(o,i){var u;if(0===i.rows.length||"cached"===i.rows.item(0).state){if(u=i.rows.length>0?JSON.parse(i.rows.item(0).doc):null,!u||!t._rev||!u._rev||t._rev>=u._rev)return o.executeSql("INSERT OR REPLACE INTO docs (col, id, state, doc) VALUES (?, ?, ?, ?)",[r.name,t._id,"cached",JSON.stringify(t)],function(){return n?n(t):void 0},function(t,n){return e(n)});if(n)return n(t)}else if(n)return n(t)},function(t,n){return e(n)})}}(this),e)},t.prototype.uncache=function(t,n,e){var r;return r=s.compileDocumentSelector(t),e=e||function(){},this.db.transaction(function(t){return function(i){return i.executeSql("SELECT * FROM docs WHERE col = ? AND state = ?",[t.name,"cached"],function(i,u){var c,s,a,l,f,d;for(l=[],s=f=0,d=u.rows.length;d>=0?d>f:f>d;s=d>=0?++f:--f)a=u.rows.item(s),c=JSON.parse(a.doc),r(c)&&l.push(c._id);return o.eachSeries(l,function(n,r){return i.executeSql('DELETE FROM docs WHERE state="cached" AND col = ? AND id = ?',[t.name,n],function(){return r()},function(t,n){return e(n)})},function(t){if(t){if(e)return e(t)}else if(n)return n()})},function(t,n){return e(n)})}}(this),e)},t}()},{"./selector":14,"./utils":15,async:18,lodash:"z2coUu"}],13:[function(t,n){n.exports=function(t,n,e,r,o,i){var u,c;if(u=n+"?"+$.param(e),"GET"===t)c=$.getJSON(u);else if("DELETE"===t)c=$.ajax(u,{type:"DELETE"});else{if("POST"!==t&&"PATCH"!==t)throw new Error("Unknown method "+t);c=$.ajax(u,{data:JSON.stringify(r),contentType:"application/json",type:t})}return c.done(function(t){return o(t||null)}),c.fail(function(t){return i?i(t):void 0})}},{}],14:[function(t,n,e){LocalCollection={},EJSON=t("./EJSON");var r=t("lodash"),o=function(t){return r.isArray(t)&&!EJSON.isBinary(t)},i=function(t,n){return o(t)?r.any(t,n):n(t)},u=function(t,n){return n(t)?!0:o(t)&&r.any(t,n)},c=function(t){var n=void 0;for(var e in t){var r="$"===e.substr(0,1);if(void 0===n)n=r;else if(n!==r)throw new Error("Inconsistent selector: "+t)}return!!n},s=function(t){if(null==t)return function(t){return i(t,function(t){return null==t})};if(!r.isObject(t))return function(n){return i(n,function(n){return n===t})};if(t instanceof RegExp)return function(n){return void 0===n?!1:i(n,function(n){return t.test(n)})};if(o(t))return function(n){return o(n)?u(n,function(n){return LocalCollection._f._equal(t,n)}):!1};if(c(t)){var n=[];return r.each(t,function(e,o){if(!r.has(l,o))throw new Error("Unrecognized operator: "+o);n.push(l[o](e,t.$options))}),function(t){return r.all(n,function(n){return n(t)})}}return function(n){return i(n,function(n){return LocalCollection._f._equal(t,n)})}},a={$and:function(t){if(!o(t)||r.isEmpty(t))throw Error("$and/$or/$nor must be nonempty array");var n=r.map(t,f);return function(t){return r.all(n,function(n){return n(t)})}},$or:function(t){if(!o(t)||r.isEmpty(t))throw Error("$and/$or/$nor must be nonempty array");var n=r.map(t,f);return function(t){return r.any(n,function(n){return n(t)})}},$nor:function(t){if(!o(t)||r.isEmpty(t))throw Error("$and/$or/$nor must be nonempty array");var n=r.map(t,f);return function(t){return r.all(n,function(n){return!n(t)})}},$where:function(t){return t instanceof Function||(t=Function("return "+t)),function(n){return t.call(n)}}},l={$in:function(t){if(!o(t))throw new Error("Argument to $in must be array");var n=null;return r.all(t,r.isString)&&(n=r.indexBy(t)),function(e){return u(e,function(e){return r.isString(e)&&null!==n?void 0!=n[e]:r.any(t,function(t){return LocalCollection._f._equal(t,e)})})}},$all:function(t){if(!o(t))throw new Error("Argument to $all must be array");return function(n){return o(n)?r.all(t,function(t){return r.any(n,function(n){return LocalCollection._f._equal(t,n)})}):!1}},$lt:function(t){return function(n){return i(n,function(n){return LocalCollection._f._cmp(n,t)<0})}},$lte:function(t){return function(n){return i(n,function(n){return LocalCollection._f._cmp(n,t)<=0})}},$gt:function(t){return function(n){return i(n,function(n){return LocalCollection._f._cmp(n,t)>0})}},$gte:function(t){return function(n){return i(n,function(n){return LocalCollection._f._cmp(n,t)>=0})}},$ne:function(t){return function(n){return!u(n,function(n){return LocalCollection._f._equal(n,t)})}},$nin:function(t){if(!o(t))throw new Error("Argument to $nin must be array");var n=l.$in(t);return function(t){return void 0===t?!0:!n(t)}},$exists:function(t){return function(n){return t===(void 0!==n)}},$mod:function(t){var n=t[0],e=t[1];return function(t){return i(t,function(t){return t%n===e})}},$size:function(t){return function(n){return o(n)&&t===n.length}},$type:function(t){return function(n){return void 0===n?!1:i(n,function(n){return LocalCollection._f._type(n)===t})}},$regex:function(t,n){if(void 0!==n){if(/[^gim]/.test(n))throw new Error("Only the i, m, and g regexp options are supported");var e=t instanceof RegExp?t.source:t;t=new RegExp(e,n)}else t instanceof RegExp||(t=new RegExp(t));return function(n){return void 0===n?!1:i(n,function(n){return t.test(n)})}},$options:function(){return function(){return!0}},$elemMatch:function(t){var n=f(t);return function(t){return o(t)?r.any(t,function(t){return n(t)}):!1}},$not:function(t){var n=s(t);return function(t){return!n(t)}},$near:function(){return function(){return!0}},$geoIntersects:function(){return function(){return!0}}};LocalCollection._f={_type:function(t){return"number"==typeof t?1:"string"==typeof t?2:"boolean"==typeof t?8:o(t)?4:null===t?10:t instanceof RegExp?11:"function"==typeof t?13:t instanceof Date?9:EJSON.isBinary(t)?5:t instanceof Meteor.Collection.ObjectID?7:3},_equal:function(t,n){return EJSON.equals(t,n,{keyOrderSensitive:!0})},_typeorder:function(t){return[-1,1,2,3,4,5,-1,6,7,8,0,9,-1,100,2,100,1,8,1][t]},_cmp:function(t,n){if(void 0===t)return void 0===n?0:-1;if(void 0===n)return 1;var e=LocalCollection._f._type(t),r=LocalCollection._f._type(n),o=LocalCollection._f._typeorder(e),i=LocalCollection._f._typeorder(r);if(o!==i)return i>o?-1:1;if(e!==r)throw Error("Missing type coercion logic in _cmp");if(7===e&&(e=r=2,t=t.toHexString(),n=n.toHexString()),9===e&&(e=r=1,t=t.getTime(),n=n.getTime()),1===e)return t-n;if(2===r)return n>t?-1:t===n?0:1;if(3===e){var u=function(t){var n=[];for(var e in t)n.push(e),n.push(t[e]);return n};return LocalCollection._f._cmp(u(t),u(n))}if(4===e)for(var c=0;;c++){if(c===t.length)return c===n.length?0:-1;if(c===n.length)return 1;var s=LocalCollection._f._cmp(t[c],n[c]);if(0!==s)return s}if(5===e){if(t.length!==n.length)return t.length-n.length;for(c=0;c<t.length;c++){if(t[c]<n[c])return-1;if(t[c]>n[c])return 1}return 0}if(8===e)return t?n?0:1:n?-1:0;if(10===e)return 0;if(11===e)throw Error("Sorting not supported on regular expression");if(13===e)throw Error("Sorting not supported on Javascript code");throw Error("Unknown type to sort")}},LocalCollection._matches=function(t,n){return LocalCollection._compileSelector(t)(n)},LocalCollection._makeLookupFunction=function(t){var n,e,i,u=t.indexOf(".");if(-1===u)n=t;else{n=t.substr(0,u);var c=t.substr(u+1);e=LocalCollection._makeLookupFunction(c),i=/^\d+(\.|$)/.test(c)}return function(t){if(null==t)return[void 0];var u=t[n];return e?o(u)&&0===u.length?[void 0]:((!o(u)||i)&&(u=[u]),Array.prototype.concat.apply([],r.map(u,e))):[u]}};var f=function(t){var n=[];return r.each(t,function(t,e){if("$"===e.substr(0,1)){if(!r.has(a,e))throw new Error("Unrecognized logical operator: "+e);n.push(a[e](t))}else{var o=LocalCollection._makeLookupFunction(e),i=s(t);n.push(function(t){var n=o(t);return r.any(n,i)})}}),function(t){return r.all(n,function(n){return n(t)})}};LocalCollection._compileSelector=function(t){if(t instanceof Function)return function(n){return t.call(n)};if(LocalCollection._selectorIsId(t))return function(n){return EJSON.equals(n._id,t)};if(!t||"_id"in t&&!t._id)return function(){return!1};if("boolean"==typeof t||o(t)||EJSON.isBinary(t))throw new Error("Invalid selector: "+t);return f(t)},LocalCollection._compileSort=function(t){var n=[];if(t instanceof Array)for(var e=0;e<t.length;e++)n.push("string"==typeof t[e]?{lookup:LocalCollection._makeLookupFunction(t[e]),ascending:!0}:{lookup:LocalCollection._makeLookupFunction(t[e][0]),ascending:"desc"!==t[e][1]});else{if("object"!=typeof t)throw Error("Bad sort specification: ",JSON.stringify(t));for(var i in t)n.push({lookup:LocalCollection._makeLookupFunction(i),ascending:t[i]>=0})}if(0===n.length)return function(){return 0};var u=function(t,n){var e,i=!0;return r.each(t,function(t){o(t)||(t=[t]),o(t)&&0===t.length&&(t=[void 0]),r.each(t,function(t){if(i)e=t,i=!1;else{var r=LocalCollection._f._cmp(e,t);(n&&r>0||!n&&0>r)&&(e=t)}})}),e};return function(t,e){for(var r=0;r<n.length;++r){var o=n[r],i=u(o.lookup(t),o.ascending),c=u(o.lookup(e),o.ascending),s=LocalCollection._f._cmp(i,c);if(0!==s)return o.ascending?s:-s}return 0}},e.compileDocumentSelector=f,e.compileSort=LocalCollection._compileSort},{"./EJSON":5,lodash:"z2coUu"}],15:[function(t,n,e){var r,o,i,u,c,s,a,l,f,d,h;h=t("lodash"),r=t("async"),o=t("bowser"),i=t("./selector").compileDocumentSelector,u=t("./selector").compileSort,a=function(){var t;if(!window.localStorage)return!1;try{return window.localStorage.setItem("test","test"),window.localStorage.removeItem("test"),!0}catch(n){return t=n,!1}},e.compileDocumentSelector=i,e.autoselectLocalDb=function(n,e,r){var i,u,c,s,l;return i=t("./IndexedDb"),s=t("./WebSQLDb"),u=t("./LocalStorageDb"),c=t("./MemoryDb"),l=o.browser,a()?window.cordova?(console.log("Selecting WebSQLDb for Cordova"),new s(n,e,r)):l.android||l.ios||l.chrome||l.safari||l.opera||l.blackberry?(console.log("Selecting WebSQLDb for browser"),new s(n,e,function(){return function(t){return console.log("Failed to create WebSQLDb: "+(t?t.message:void 0)),new i(n,e,function(t){return console.log("Failed to create IndexedDb: "+(t?t.message:void 0)),new c(n,e)})}}(this))):l.firefox&&l.version>=16?(console.log("Selecting IndexedDb for browser"),new i(n,e,function(){return function(t){return console.log("Failed to create IndexedDb: "+(t?t.message:void 0)),new c(n,e)}}(this))):(console.log("Selecting LocalStorageDb for fallback"),new u(n,e,r)):new c(n,e)},e.migrateLocalDb=function(n,e,r,o){var i,u,c,s,a;i=t("./HybridDb"),c=new i(n,e),a=n.collections;for(s in a)u=a[s],e[s]&&c.addCollection(s);return c.upload(r,o)},e.cloneLocalDb=function(t,n,e,o){var i,u,c;c=t.collections;for(u in c)i=c[u],n[u]||n.addCollection(u);return r.each(h.values(t.collections),function(){return function(t,e){var o;return o=n[t.name],t.find({}).fetch(function(n){return o.seed(n,function(){return t.pendingUpserts(function(n){return o.upsert(h.pluck(n,"doc"),h.pluck(n,"base"),function(){return t.pendingRemoves(function(t){return r.eachSeries(t,function(t,n){return o.remove(t,function(){return n()},n)},e)},e)},e)},e)},e)},e)}}(this),function(){return function(t){return t?o(t):e()}}(this))},e.processFind=function(t,n,r){var o;return o=h.filter(t,i(n)),o=d(n,o),o=f(n,o),r&&r.sort&&o.sort(u(r.sort)),r&&r.skip&&(o=h.slice(o,r.skip)),r&&r.limit&&(o=h.take(o,r.limit)),r&&r.fields&&(o=e.filterFields(o,r.fields)),o},e.filterFields=function(t,n){return null==n&&(n={}),0===h.keys(n).length?t:h.map(t,function(t){var e,r,o,i,u,c,s,a,l,f,d,p,m,v,y,g,b,E,w,S,_;if(o={},1===h.first(h.values(n))){for(E=h.keys(n).concat(["_id"]),a=0,p=E.length;p>a;a++){for(e=E[a],u=e.split("."),i=t,l=0,m=u.length;m>l;l++)c=u[l],i&&(i=i[c]);if(null!=i){for(r=t,s=o,w=h.initial(u),f=0,v=w.length;v>f;f++)c=w[f],s[c]=s[c]||{},s=s[c],r=r[c];s[h.last(u)]=r[h.last(u)]}}return o}for(t=h.cloneDeep(t),S=h.keys(n),d=0,y=S.length;y>d;d++){for(e=S[d],u=e.split("."),i=t,_=h.initial(u),b=0,g=_.length;g>b;b++)c=_[b],i&&(i=i[c]);null!=i&&delete i[h.last(u)]}return t})},e.createUid=function(){return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,function(t){var n,e;return n=16*Math.random()|0,e="x"===t?n:3&n|8,e.toString(16)})},d=function(t,n){var e,r,o,i;for(o in t)if(i=t[o],null!=i&&i.$near){if(r=i.$near.$geometry,"Point"!==r.type)break;n=h.filter(n,function(t){return t[o]&&"Point"===t[o].type}),e=h.map(n,function(t){return{doc:t,distance:s(r.coordinates[1],r.coordinates[0],t[o].coordinates[1],t[o].coordinates[0])}}),e=h.filter(e,function(t){return t.distance>=0}),e=h.sortBy(e,"distance"),i.$near.$maxDistance&&(e=h.filter(e,function(t){return t.distance<=i.$near.$maxDistance})),n=h.pluck(e,"doc")}return n},l=function(t,n){if(!h.isEqual(h.first(n.coordinates[0]),h.last(n.coordinates[0])))throw new Error("First must equal last");return t.coordinates[0]<Math.min.apply(this,h.map(n.coordinates[0],function(t){return t[0]}))?!1:t.coordinates[1]<Math.min.apply(this,h.map(n.coordinates[0],function(t){return t[1]}))?!1:t.coordinates[0]>Math.max.apply(this,h.map(n.coordinates[0],function(t){return t[0]}))?!1:t.coordinates[1]>Math.max.apply(this,h.map(n.coordinates[0],function(t){return t[1]}))?!1:!0},s=function(t,n,e,r){var o,i,u,s,a,l;return o=6370986,a=c(e-t),l=c(r-n),i=Math.sin(a/2)*Math.sin(a/2)+Math.cos(c(t))*Math.cos(c(e))*Math.sin(l/2)*Math.sin(l/2),u=2*Math.atan2(Math.sqrt(i),Math.sqrt(1-i)),s=o*u},c=function(t){return t*(Math.PI/180)},f=function(t,n){var e,r,o;for(r in t)if(o=t[r],null!=o&&o.$geoIntersects){if(e=o.$geoIntersects.$geometry,"Polygon"!==e.type)break;n=h.filter(n,function(t){return t[r]&&"Point"===t[r].type?l(t[r],e):!1})}return n},e.regularizeUpsert=function(t,n,r,o){var i,u,c,s,a;for(h.isFunction(n)&&(a=[void 0,n,r],n=a[0],r=a[1],o=a[2]),h.isArray(t)?n=n||[]:(t=[t],n=[n]),u=h.map(t,function(t,e){return{doc:t,base:e<n.length?n[e]:void 0}}),c=0,s=u.length;s>c;c++){if(i=u[c],i.doc._id||(i.doc._id=e.createUid()),i.base&&!i.base._id)throw new Error("Base needs _id");if(i.base&&i.base._id!==i.doc._id)throw new Error("Base needs same _id")}return[u,r,o]}},{"./HybridDb":6,"./IndexedDb":7,"./LocalStorageDb":8,"./MemoryDb":9,"./WebSQLDb":12,"./selector":14,async:18,bowser:19,lodash:"z2coUu"}],lodash:[function(t,n){n.exports=t("z2coUu")},{}],z2coUu:[function(t,n){n.exports=window._},{}],18:[function(t,n){(function(t,e){!function(){function r(){}function o(t){return t}function i(t){return!!t}function u(t){return!t}function c(t){return function(){if(null===t)throw new Error("Callback was already called.");t.apply(this,arguments),t=null}}function s(t){return function(){null!==t&&(t.apply(this,arguments),t=null)}}function a(t){return F(t)||"number"==typeof t.length&&t.length>=0&&t.length%1===0}function l(t,n){return a(t)?f(t,n):m(t,n)}function f(t,n){for(var e=-1,r=t.length;++e<r;)n(t[e],e,t)}function d(t,n){for(var e=-1,r=t.length,o=Array(r);++e<r;)o[e]=n(t[e],e,t);return o}function h(t){return d(Array(t),function(t,n){return n})}function p(t,n,e){return f(t,function(t,r,o){e=n(e,t,r,o)}),e}function m(t,n){f(z(t),function(e){n(t[e],e)})}function v(t,n){for(var e=0;e<t.length;e++)if(t[e]===n)return e;return-1}function y(t){var n,e,r=-1;return a(t)?(n=t.length,function(){return r++,n>r?r:null}):(e=z(t),n=e.length,function(){return r++,n>r?e[r]:null})}function g(t,n){return n=null==n?t.length-1:+n,function(){for(var e=Math.max(arguments.length-n,0),r=Array(e),o=0;e>o;o++)r[o]=arguments[o+n];switch(n){case 0:return t.call(this,r);case 1:return t.call(this,arguments[0],r)}}}function b(t){return function(n,e,r){return t(n,r)}}function E(t){return function(n,e,o){o=s(o||r),n=n||[];var i=y(n);if(0>=t)return o(null);var u=!1,a=0,l=!1;!function f(){if(u&&0>=a)return o(null);for(;t>a&&!l;){var r=i();if(null===r)return u=!0,void(0>=a&&o(null));a+=1,e(n[r],r,c(function(t){a-=1,t?(o(t),l=!0):f()}))}}()}}function w(t){return function(n,e,r){return t(q.eachOf,n,e,r)}}function S(t){return function(n,e,r,o){return t(E(e),n,r,o)}}function _(t){return function(n,e,r){return t(q.eachOfSeries,n,e,r)}}function O(t,n,e,o){o=s(o||r);var i=[];t(n,function(t,n,r){e(t,function(t,e){i[n]=e,r(t)})},function(t){o(t,i)})}function N(t,n,e,r){var o=[];t(n,function(t,n,r){e(t,function(e){e&&o.push({index:n,value:t}),r()})},function(){r(d(o.sort(function(t,n){return t.index-n.index}),function(t){return t.value}))})}function x(t,n,e,r){N(t,n,function(t,n){e(t,function(t){n(!t)})},r)}function k(t,n,e){return function(r,o,i,u){function c(){u&&u(e(!1,void 0))}function s(t,r,o){return u?void i(t,function(r){u&&n(r)&&(u(e(!0,t)),u=i=!1),o()}):o()}arguments.length>3?t(r,o,s,c):(u=i,i=o,t(r,s,c))}}function C(t,n){return n}function D(t,n,e){e=e||r;var o=a(n)?[]:{};t(n,function(t,n,e){t(g(function(t,r){r.length<=1&&(r=r[0]),o[n]=r,e(t)}))},function(t){e(t,o)})}function R(t,n,e,r){var o=[];t(n,function(t,n,r){e(t,function(t,n){o=o.concat(n||[]),r(t)})},function(t){r(t,o)})}function L(t,n,e){function o(t,n,e,o){if(null!=o&&"function"!=typeof o)throw new Error("task callback must be a function");return t.started=!0,F(n)||(n=[n]),0===n.length&&t.idle()?q.setImmediate(function(){t.drain()}):(f(n,function(n){var i={data:n,callback:o||r};e?t.tasks.unshift(i):t.tasks.push(i),t.tasks.length===t.concurrency&&t.saturated()}),void q.setImmediate(t.process))}function i(t,n){return function(){u-=1;var e=arguments;f(n,function(t){t.callback.apply(t,e)}),t.tasks.length+u===0&&t.drain(),t.process()}}if(null==n)n=1;else if(0===n)throw new Error("Concurrency must not be zero");var u=0,s={tasks:[],concurrency:n,payload:e,saturated:r,empty:r,drain:r,started:!1,paused:!1,push:function(t,n){o(s,t,!1,n)},kill:function(){s.drain=r,s.tasks=[]},unshift:function(t,n){o(s,t,!0,n)},process:function(){if(!s.paused&&u<s.concurrency&&s.tasks.length)for(;u<s.concurrency&&s.tasks.length;){var n=s.payload?s.tasks.splice(0,s.payload):s.tasks.splice(0,s.tasks.length),e=d(n,function(t){return t.data});0===s.tasks.length&&s.empty(),u+=1;var r=c(i(s,n));t(e,r)}},length:function(){return s.tasks.length},running:function(){return u},idle:function(){return s.tasks.length+u===0},pause:function(){s.paused=!0},resume:function(){if(s.paused!==!1){s.paused=!1;for(var t=Math.min(s.concurrency,s.tasks.length),n=1;t>=n;n++)q.setImmediate(s.process)}}};return s}function A(t){return g(function(n,e){n.apply(null,e.concat([g(function(n,e){"object"==typeof console&&(n?console.error&&console.error(n):console[t]&&f(e,function(n){console[t](n)}))})]))})}function I(t){return function(n,e,r){t(h(n),e,r)}}function T(t){return g(function(n,e){var r=g(function(e){var r=this,o=e.pop();return t(n,function(t,n,o){t.apply(r,e.concat([o]))},o)});return e.length?r.apply(this,e):r})}function J(t){return g(function(n){var e=n.pop();n.push(function(){var t=arguments;r?q.setImmediate(function(){e.apply(null,t)}):e.apply(null,t)});var r=!0;t.apply(this,n),r=!1})}var U,q={},j="object"==typeof self&&self.self===self&&self||"object"==typeof e&&e.global===e&&e||this;null!=j&&(U=j.async),q.noConflict=function(){return j.async=U,q};var $=Object.prototype.toString,F=Array.isArray||function(t){return"[object Array]"===$.call(t)},P=function(t){var n=typeof t;return"function"===n||"object"===n&&!!t},z=Object.keys||function(t){var n=[];for(var e in t)t.hasOwnProperty(e)&&n.push(e);return n},B="function"==typeof setImmediate&&setImmediate,V=B?function(t){B(t)}:function(t){setTimeout(t,0)};q.nextTick="object"==typeof t&&"function"==typeof t.nextTick?t.nextTick:V,q.setImmediate=B?V:q.nextTick,q.forEach=q.each=function(t,n,e){return q.eachOf(t,b(n),e)},q.forEachSeries=q.eachSeries=function(t,n,e){return q.eachOfSeries(t,b(n),e)},q.forEachLimit=q.eachLimit=function(t,n,e,r){return E(n)(t,b(e),r)},q.forEachOf=q.eachOf=function(t,n,e){function o(t){t?e(t):(u+=1,u>=i&&e(null))}e=s(e||r),t=t||[];var i=a(t)?t.length:z(t).length,u=0;return i?void l(t,function(e,r){n(t[r],r,c(o))}):e(null)},q.forEachOfSeries=q.eachOfSeries=function(t,n,e){function o(){var r=!0;return null===u?e(null):(n(t[u],u,c(function(t){if(t)e(t);else{if(u=i(),null===u)return e(null);r?q.nextTick(o):o()}})),void(r=!1))}e=s(e||r),t=t||[];var i=y(t),u=i();o()},q.forEachOfLimit=q.eachOfLimit=function(t,n,e,r){E(n)(t,e,r)},q.map=w(O),q.mapSeries=_(O),q.mapLimit=S(O),q.inject=q.foldl=q.reduce=function(t,n,e,r){q.eachOfSeries(t,function(t,r,o){e(n,t,function(t,e){n=e,o(t)})},function(t){r(t||null,n)})},q.foldr=q.reduceRight=function(t,n,e,r){var i=d(t,o).reverse();q.reduce(i,n,e,r)},q.select=q.filter=w(N),q.selectLimit=q.filterLimit=S(N),q.selectSeries=q.filterSeries=_(N),q.reject=w(x),q.rejectLimit=S(x),q.rejectSeries=_(x),q.any=q.some=k(q.eachOf,i,o),q.someLimit=k(q.eachOfLimit,i,o),q.all=q.every=k(q.eachOf,u,u),q.everyLimit=k(q.eachOfLimit,u,u),q.detect=k(q.eachOf,o,C),q.detectSeries=k(q.eachOfSeries,o,C),q.detectLimit=k(q.eachOfLimit,o,C),q.sortBy=function(t,n,e){function r(t,n){var e=t.criteria,r=n.criteria;return r>e?-1:e>r?1:0}q.map(t,function(t,e){n(t,function(n,r){n?e(n):e(null,{value:t,criteria:r})})},function(t,n){return t?e(t):void e(null,d(n.sort(r),function(t){return t.value}))})},q.auto=function(t,n){function e(t){l.unshift(t)}function o(t){var n=v(l,t);n>=0&&l.splice(n,1)}function i(){c--,f(l.slice(0),function(t){t()})}n=s(n||r);var u=z(t),c=u.length;if(!c)return n(null);var a={},l=[];e(function(){c||n(null,a)}),f(u,function(r){function u(){return p(d,function(t,n){return t&&a.hasOwnProperty(n)},!0)&&!a.hasOwnProperty(r)}function c(){u()&&(o(c),l[l.length-1](f,a))}for(var s,l=F(t[r])?t[r]:[t[r]],f=g(function(t,e){if(e.length<=1&&(e=e[0]),t){var o={};m(a,function(t,n){o[n]=t}),o[r]=e,n(t,o)}else a[r]=e,q.setImmediate(i)}),d=l.slice(0,l.length-1),h=d.length;h--;){if(!(s=t[d[h]]))throw new Error("Has inexistant dependency");if(F(s)&&v(s,r)>=0)throw new Error("Has cyclic dependencies")}u()?l[l.length-1](f,a):e(c)})},q.retry=function(t,n,e){function r(t,n){if("number"==typeof n)t.times=parseInt(n,10)||i;else{if("object"!=typeof n)throw new Error("Unsupported argument type for 'times': "+typeof n);t.times=parseInt(n.times,10)||i,t.interval=parseInt(n.interval,10)||u}}function o(t,n){function e(t,e){return function(r){t(function(t,n){r(!t||e,{err:t,result:n})},n)}}function r(t){return function(n){setTimeout(function(){n(null)},t)}}for(;s.times;){var o=!(s.times-=1);c.push(e(s.task,o)),!o&&s.interval>0&&c.push(r(s.interval))}q.series(c,function(n,e){e=e[e.length-1],(t||s.callback)(e.err,e.result)})}var i=5,u=0,c=[],s={times:i,interval:u},a=arguments.length;if(1>a||a>3)throw new Error("Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)");return 2>=a&&"function"==typeof t&&(e=n,n=t),"function"!=typeof t&&r(s,t),s.callback=e,s.task=n,s.callback?o():o},q.waterfall=function(t,n){function e(t){return g(function(r,o){if(r)n.apply(null,[r].concat(o));else{var i=t.next();o.push(i?e(i):n),J(t).apply(null,o)}})}if(n=s(n||r),!F(t)){var o=new Error("First argument to waterfall must be an array of functions");return n(o)}return t.length?void e(q.iterator(t))():n()},q.parallel=function(t,n){D(q.eachOf,t,n)},q.parallelLimit=function(t,n,e){D(E(n),t,e)},q.series=function(t,n){D(q.eachOfSeries,t,n)},q.iterator=function(t){function n(e){function r(){return t.length&&t[e].apply(null,arguments),r.next()}return r.next=function(){return e<t.length-1?n(e+1):null},r}return n(0)},q.apply=g(function(t,n){return g(function(e){return t.apply(null,n.concat(e))})}),q.concat=w(R),q.concatSeries=_(R),q.whilst=function(t,n,e){if(e=e||r,t()){var o=g(function(r,i){r?e(r):t.apply(this,i)?n(o):e(null)});n(o)}else e(null)},q.doWhilst=function(t,n,e){var r=0;return q.whilst(function(){return++r<=1||n.apply(this,arguments)},t,e)},q.until=function(t,n,e){return q.whilst(function(){return!t.apply(this,arguments)},n,e)},q.doUntil=function(t,n,e){return q.doWhilst(t,function(){return!n.apply(this,arguments)},e)},q.during=function(t,n,e){e=e||r;var o=g(function(n,r){n?e(n):(r.push(i),t.apply(this,r))}),i=function(t,r){t?e(t):r?n(o):e(null)};t(i)},q.doDuring=function(t,n,e){var r=0;q.during(function(t){r++<1?t(null,!0):n.apply(this,arguments)},t,e)},q.queue=function(t,n){var e=L(function(n,e){t(n[0],e)},n,1);return e},q.priorityQueue=function(t,n){function e(t,n){return t.priority-n.priority}function o(t,n,e){for(var r=-1,o=t.length-1;o>r;){var i=r+(o-r+1>>>1);e(n,t[i])>=0?r=i:o=i-1}return r}function i(t,n,i,u){if(null!=u&&"function"!=typeof u)throw new Error("task callback must be a function");return t.started=!0,F(n)||(n=[n]),0===n.length?q.setImmediate(function(){t.drain()}):void f(n,function(n){var c={data:n,priority:i,callback:"function"==typeof u?u:r};t.tasks.splice(o(t.tasks,c,e)+1,0,c),t.tasks.length===t.concurrency&&t.saturated(),q.setImmediate(t.process)})}var u=q.queue(t,n);return u.push=function(t,n,e){i(u,t,n,e)},delete u.unshift,u},q.cargo=function(t,n){return L(t,1,n)},q.log=A("log"),q.dir=A("dir"),q.memoize=function(t,n){var e={},r={};n=n||o;var i=g(function(o){var i=o.pop(),u=n.apply(null,o);u in e?q.nextTick(function(){i.apply(null,e[u])}):u in r?r[u].push(i):(r[u]=[i],t.apply(null,o.concat([g(function(t){e[u]=t;var n=r[u];delete r[u];for(var o=0,i=n.length;i>o;o++)n[o].apply(null,t)})])))});return i.memo=e,i.unmemoized=t,i},q.unmemoize=function(t){return function(){return(t.unmemoized||t).apply(null,arguments)}},q.times=I(q.map),q.timesSeries=I(q.mapSeries),q.timesLimit=function(t,n,e,r){return q.mapLimit(h(t),n,e,r)},q.seq=function(){var t=arguments;return g(function(n){var e=this,o=n[n.length-1];"function"==typeof o?n.pop():o=r,q.reduce(t,n,function(t,n,r){n.apply(e,t.concat([g(function(t,n){r(t,n)})]))},function(t,n){o.apply(e,[t].concat(n))})})},q.compose=function(){return q.seq.apply(null,Array.prototype.reverse.call(arguments))},q.applyEach=T(q.eachOf),q.applyEachSeries=T(q.eachOfSeries),q.forever=function(t,n){function e(t){return t?o(t):void i(e)}var o=c(n||r),i=J(t);e()},q.ensureAsync=J,q.constant=g(function(t){var n=[null].concat(t);return function(t){return t.apply(this,n)}}),q.wrapSync=q.asyncify=function(t){return g(function(n){var e,r=n.pop();try{e=t.apply(this,n)}catch(o){return r(o)}P(e)&&"function"==typeof e.then?e.then(function(t){r(null,t)})["catch"](function(t){r(t.message?t:new Error(t))}):r(null,e)})},"object"==typeof n&&n.exports?n.exports=q:"function"==typeof define&&define.amd?define([],function(){return q}):j.async=q}()}).call(this,t("/home/clayton/dev/mWater/minimongo/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"/home/clayton/dev/mWater/minimongo/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":20}],19:[function(t,n){!function(t,e){"undefined"!=typeof n&&n.exports?n.exports.browser=e():"function"==typeof define?define(e):this[t]=e()}("bowser",function(){function t(t){function e(n){var e=t.match(n);return e&&e.length>1&&e[1]||""}var r,o=e(/(ipod|iphone|ipad)/i).toLowerCase(),i=/like android/i.test(t),u=!i&&/android/i.test(t),c=e(/version\/(\d+(\.\d+)?)/i),s=/tablet/i.test(t),a=!s&&/[^-]mobi/i.test(t);/opera|opr/i.test(t)?r={name:"Opera",opera:n,version:c||e(/(?:opera|opr)[\s\/](\d+(\.\d+)?)/i)}:/windows phone/i.test(t)?r={name:"Windows Phone",windowsphone:n,msie:n,version:e(/iemobile\/(\d+(\.\d+)?)/i)}:/msie|trident/i.test(t)?r={name:"Internet Explorer",msie:n,version:e(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:/chrome|crios|crmo/i.test(t)?r={name:"Chrome",chrome:n,version:e(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:o?(r={name:"iphone"==o?"iPhone":"ipad"==o?"iPad":"iPod"},c&&(r.version=c)):/sailfish/i.test(t)?r={name:"Sailfish",sailfish:n,version:e(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(t)?r={name:"SeaMonkey",seamonkey:n,version:e(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel/i.test(t)?(r={name:"Firefox",firefox:n,version:e(/(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(t)&&(r.firefoxos=n)):/silk/i.test(t)?r={name:"Amazon Silk",silk:n,version:e(/silk\/(\d+(\.\d+)?)/i)}:u?r={name:"Android",version:c}:/phantom/i.test(t)?r={name:"PhantomJS",phantom:n,version:e(/phantomjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(t)||/rim\stablet/i.test(t)?r={name:"BlackBerry",blackberry:n,version:c||e(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:/(web|hpw)os/i.test(t)?(r={name:"WebOS",webos:n,version:c||e(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(t)&&(r.touchpad=n)):r=/bada/i.test(t)?{name:"Bada",bada:n,version:e(/dolfin\/(\d+(\.\d+)?)/i)}:/tizen/i.test(t)?{name:"Tizen",tizen:n,version:e(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||c}:/safari/i.test(t)?{name:"Safari",safari:n,version:c}:{},/(apple)?webkit/i.test(t)?(r.name=r.name||"Webkit",r.webkit=n,!r.version&&c&&(r.version=c)):!r.opera&&/gecko\//i.test(t)&&(r.name=r.name||"Gecko",r.gecko=n,r.version=r.version||e(/gecko\/(\d+(\.\d+)?)/i)),u||r.silk?r.android=n:o&&(r[o]=n,r.ios=n);
var l="";o?(l=e(/os (\d+([_\s]\d+)*) like mac os x/i),l=l.replace(/[_\s]/g,".")):u?l=e(/android[ \/-](\d+(\.\d+)*)/i):r.windowsphone?l=e(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):r.webos?l=e(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):r.blackberry?l=e(/rim\stablet\sos\s(\d+(\.\d+)*)/i):r.bada?l=e(/bada\/(\d+(\.\d+)*)/i):r.tizen&&(l=e(/tizen[\/\s](\d+(\.\d+)*)/i)),l&&(r.osversion=l);var f=l.split(".")[0];return s||"ipad"==o||u&&(3==f||4==f&&!a)||r.silk?r.tablet=n:(a||"iphone"==o||"ipod"==o||u||r.blackberry||r.webos||r.bada)&&(r.mobile=n),r.msie&&r.version>=10||r.chrome&&r.version>=20||r.firefox&&r.version>=20||r.safari&&r.version>=6||r.opera&&r.version>=10||r.ios&&r.osversion&&r.osversion.split(".")[0]>=6?r.a=n:r.msie&&r.version<10||r.chrome&&r.version<20||r.firefox&&r.version<20||r.safari&&r.version<6||r.opera&&r.version<10||r.ios&&r.osversion&&r.osversion.split(".")[0]<6?r.c=n:r.x=n,r}var n=!0,e=t("undefined"!=typeof navigator?navigator.userAgent:"");return e._detect=t,e})},{}],20:[function(t,n){var e=n.exports={};e.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,n="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(n){var e=[];return window.addEventListener("message",function(t){var n=t.source;if((n===window||null===n)&&"process-tick"===t.data&&(t.stopPropagation(),e.length>0)){var r=e.shift();r()}},!0),function(t){e.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),e.title="browser",e.browser=!0,e.env={},e.argv=[],e.binding=function(){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(){throw new Error("process.chdir is not supported")}},{}],21:[function(t,n){!function(t,e,r){"function"==typeof define?define(e):"undefined"!=typeof n&&n.exports?n.exports=e():r[t]=e()}("IDBStore",function(){"use strict";var t=function(t){throw t},n={storeName:"Store",storePrefix:"IDBWrapper-",dbVersion:1,keyPath:"id",autoIncrement:!0,onStoreReady:function(){},onError:t,indexes:[]},e=function(t,e){"undefined"==typeof e&&"function"==typeof t&&(e=t),"[object Object]"!=Object.prototype.toString.call(t)&&(t={});for(var r in n)this[r]="undefined"!=typeof t[r]?t[r]:n[r];this.dbName=this.storePrefix+this.storeName,this.dbVersion=parseInt(this.dbVersion,10)||1,e&&(this.onStoreReady=e);var o="object"==typeof window?window:self;this.idb=o.indexedDB||o.webkitIndexedDB||o.mozIndexedDB,this.keyRange=o.IDBKeyRange||o.webkitIDBKeyRange||o.mozIDBKeyRange,this.features={hasAutoIncrement:!o.mozIndexedDB},this.consts={READ_ONLY:"readonly",READ_WRITE:"readwrite",VERSION_CHANGE:"versionchange",NEXT:"next",NEXT_NO_DUPLICATE:"nextunique",PREV:"prev",PREV_NO_DUPLICATE:"prevunique"},this.openDB()};e.prototype={constructor:e,version:"1.4.1",db:null,dbName:null,dbVersion:null,store:null,storeName:null,keyPath:null,autoIncrement:null,indexes:null,features:null,onStoreReady:null,onError:null,_insertIdCount:0,openDB:function(){var t=this.idb.open(this.dbName,this.dbVersion),n=!1;t.onerror=function(t){var n=!1;"error"in t.target?n="VersionError"==t.target.error.name:"errorCode"in t.target&&(n=12==t.target.errorCode),this.onError(n?new Error("The version number provided is lower than the existing one."):t)}.bind(this),t.onsuccess=function(t){if(!n){if(this.db)return void this.onStoreReady();if(this.db=t.target.result,"string"==typeof this.db.version)return void this.onError(new Error("The IndexedDB implementation in this browser is outdated. Please upgrade your browser."));if(!this.db.objectStoreNames.contains(this.storeName))return void this.onError(new Error("Something is wrong with the IndexedDB implementation in this browser. Please upgrade your browser."));var e=this.db.transaction([this.storeName],this.consts.READ_ONLY);this.store=e.objectStore(this.storeName);var r=Array.prototype.slice.call(this.getIndexList());this.indexes.forEach(function(t){var e=t.name;if(!e)return n=!0,void this.onError(new Error("Cannot create index: No index name given."));if(this.normalizeIndexData(t),this.hasIndex(e)){var o=this.store.index(e),i=this.indexComplies(o,t);i||(n=!0,this.onError(new Error('Cannot modify index "'+e+'" for current version. Please bump version number to '+(this.dbVersion+1)+"."))),r.splice(r.indexOf(e),1)}else n=!0,this.onError(new Error('Cannot create new index "'+e+'" for current version. Please bump version number to '+(this.dbVersion+1)+"."))},this),r.length&&(n=!0,this.onError(new Error('Cannot delete index(es) "'+r.toString()+'" for current version. Please bump version number to '+(this.dbVersion+1)+"."))),n||this.onStoreReady()}}.bind(this),t.onupgradeneeded=function(t){if(this.db=t.target.result,this.db.objectStoreNames.contains(this.storeName))this.store=t.target.transaction.objectStore(this.storeName);else{var e={autoIncrement:this.autoIncrement};null!==this.keyPath&&(e.keyPath=this.keyPath),this.store=this.db.createObjectStore(this.storeName,e)}var r=Array.prototype.slice.call(this.getIndexList());this.indexes.forEach(function(t){var e=t.name;if(e||(n=!0,this.onError(new Error("Cannot create index: No index name given."))),this.normalizeIndexData(t),this.hasIndex(e)){var o=this.store.index(e),i=this.indexComplies(o,t);i||(this.store.deleteIndex(e),this.store.createIndex(e,t.keyPath,{unique:t.unique,multiEntry:t.multiEntry})),r.splice(r.indexOf(e),1)}else this.store.createIndex(e,t.keyPath,{unique:t.unique,multiEntry:t.multiEntry})},this),r.length&&r.forEach(function(t){this.store.deleteIndex(t)},this)}.bind(this)},deleteDatabase:function(){this.idb.deleteDatabase&&this.idb.deleteDatabase(this.dbName)},put:function(n,e,o,i){null!==this.keyPath&&(i=o,o=e,e=n),i||(i=t),o||(o=r);var u,c=!1,s=null,a=this.db.transaction([this.storeName],this.consts.READ_WRITE);return a.oncomplete=function(){var t=c?o:i;t(s)},a.onabort=i,a.onerror=i,null!==this.keyPath?(this._addIdPropertyIfNeeded(e),u=a.objectStore(this.storeName).put(e)):u=a.objectStore(this.storeName).put(e,n),u.onsuccess=function(t){c=!0,s=t.target.result},u.onerror=i,a},get:function(n,e,o){o||(o=t),e||(e=r);var i=!1,u=null,c=this.db.transaction([this.storeName],this.consts.READ_ONLY);c.oncomplete=function(){var t=i?e:o;t(u)},c.onabort=o,c.onerror=o;var s=c.objectStore(this.storeName).get(n);return s.onsuccess=function(t){i=!0,u=t.target.result},s.onerror=o,c},remove:function(n,e,o){o||(o=t),e||(e=r);var i=!1,u=null,c=this.db.transaction([this.storeName],this.consts.READ_WRITE);c.oncomplete=function(){var t=i?e:o;t(u)},c.onabort=o,c.onerror=o;var s=c.objectStore(this.storeName)["delete"](n);return s.onsuccess=function(t){i=!0,u=t.target.result},s.onerror=o,c},batch:function(n,e,o){o||(o=t),e||(e=r),"[object Array]"!=Object.prototype.toString.call(n)&&o(new Error("dataArray argument must be of type Array."));var i=this.db.transaction([this.storeName],this.consts.READ_WRITE);i.oncomplete=function(){var t=s?e:o;t(s)},i.onabort=o,i.onerror=o;var u=n.length,c=!1,s=!1,a=function(){u--,0!==u||c||(c=!0,s=!0)};return n.forEach(function(t){var n=t.type,e=t.key,r=t.value,u=function(t){i.abort(),c||(c=!0,o(t,n,e))};if("remove"==n){var s=i.objectStore(this.storeName)["delete"](e);s.onsuccess=a,s.onerror=u}else if("put"==n){var l;null!==this.keyPath?(this._addIdPropertyIfNeeded(r),l=i.objectStore(this.storeName).put(r)):l=i.objectStore(this.storeName).put(r,e),l.onsuccess=a,l.onerror=u}},this),i},putBatch:function(t,n,e){var r=t.map(function(t){return{type:"put",value:t}});return this.batch(r,n,e)},removeBatch:function(t,n,e){var r=t.map(function(t){return{type:"remove",key:t}});return this.batch(r,n,e)},getBatch:function(n,e,o,i){o||(o=t),e||(e=r),i||(i="sparse"),"[object Array]"!=Object.prototype.toString.call(n)&&o(new Error("keyArray argument must be of type Array."));var u=this.db.transaction([this.storeName],this.consts.READ_ONLY);u.oncomplete=function(){var t=l?e:o;t(f)},u.onabort=o,u.onerror=o;var c=[],s=n.length,a=!1,l=!1,f=null,d=function(t){t.target.result||"dense"==i?c.push(t.target.result):"sparse"==i&&c.length++,s--,0===s&&(a=!0,l=!0,f=c)};return n.forEach(function(t){var n=function(t){a=!0,f=t,o(t),u.abort()},e=u.objectStore(this.storeName).get(t);e.onsuccess=d,e.onerror=n},this),u},getAll:function(n,e){e||(e=t),n||(n=r);var o=this.db.transaction([this.storeName],this.consts.READ_ONLY),i=o.objectStore(this.storeName);return i.getAll?this._getAllNative(o,i,n,e):this._getAllCursor(o,i,n,e),o},_getAllNative:function(t,n,e,r){var o=!1,i=null;t.oncomplete=function(){var t=o?e:r;t(i)},t.onabort=r,t.onerror=r;var u=n.getAll();u.onsuccess=function(t){o=!0,i=t.target.result},u.onerror=r},_getAllCursor:function(t,n,e,r){var o=[],i=!1,u=null;t.oncomplete=function(){var t=i?e:r;t(u)},t.onabort=r,t.onerror=r;var c=n.openCursor();c.onsuccess=function(t){var n=t.target.result;n?(o.push(n.value),n["continue"]()):(i=!0,u=o)},c.onError=r},clear:function(n,e){e||(e=t),n||(n=r);var o=!1,i=null,u=this.db.transaction([this.storeName],this.consts.READ_WRITE);u.oncomplete=function(){var t=o?n:e;t(i)},u.onabort=e,u.onerror=e;var c=u.objectStore(this.storeName).clear();return c.onsuccess=function(t){o=!0,i=t.target.result},c.onerror=e,u},_addIdPropertyIfNeeded:function(t){this.features.hasAutoIncrement||"undefined"!=typeof t[this.keyPath]||(t[this.keyPath]=this._insertIdCount++ +Date.now())},getIndexList:function(){return this.store.indexNames},hasIndex:function(t){return this.store.indexNames.contains(t)},normalizeIndexData:function(t){t.keyPath=t.keyPath||t.name,t.unique=!!t.unique,t.multiEntry=!!t.multiEntry},indexComplies:function(t,n){var e=["keyPath","unique","multiEntry"].every(function(e){if("multiEntry"==e&&void 0===t[e]&&n[e]===!1)return!0;if("keyPath"==e&&"[object Array]"==Object.prototype.toString.call(n[e])){var r=n.keyPath,o=t.keyPath;if("string"==typeof o)return r.toString()==o;if("function"!=typeof o.contains&&"function"!=typeof o.indexOf)return!1;if(o.length!==r.length)return!1;for(var i=0,u=r.length;u>i;i++)if(!(o.contains&&o.contains(r[i])||o.indexOf(-1!==r[i])))return!1;return!0}return n[e]==t[e]});return e},iterate:function(n,e){e=i({index:null,order:"ASC",autoContinue:!0,filterDuplicates:!1,keyRange:null,writeAccess:!1,onEnd:null,onError:t},e||{});var r="desc"==e.order.toLowerCase()?"PREV":"NEXT";e.filterDuplicates&&(r+="_NO_DUPLICATE");var o=!1,u=this.db.transaction([this.storeName],this.consts[e.writeAccess?"READ_WRITE":"READ_ONLY"]),c=u.objectStore(this.storeName);e.index&&(c=c.index(e.index)),u.oncomplete=function(){return o?void(e.onEnd?e.onEnd():n(null)):void e.onError(null)},u.onabort=e.onError,u.onerror=e.onError;var s=c.openCursor(e.keyRange,this.consts[r]);return s.onerror=e.onError,s.onsuccess=function(t){var r=t.target.result;r?(n(r.value,r,u),e.autoContinue&&r["continue"]()):o=!0},u},query:function(t,n){var e=[];return n=n||{},n.onEnd=function(){t(e)},this.iterate(function(t){e.push(t)},n)},count:function(n,e){e=i({index:null,keyRange:null},e||{});var r=e.onError||t,o=!1,u=null,c=this.db.transaction([this.storeName],this.consts.READ_ONLY);c.oncomplete=function(){var t=o?n:r;t(u)},c.onabort=r,c.onerror=r;var s=c.objectStore(this.storeName);e.index&&(s=s.index(e.index));var a=s.count(e.keyRange);return a.onsuccess=function(t){o=!0,u=t.target.result},a.onError=r,c},makeKeyRange:function(t){var n,e="undefined"!=typeof t.lower,r="undefined"!=typeof t.upper,o="undefined"!=typeof t.only;switch(!0){case o:n=this.keyRange.only(t.only);break;case e&&r:n=this.keyRange.bound(t.lower,t.upper,t.excludeLower,t.excludeUpper);break;case e:n=this.keyRange.lowerBound(t.lower,t.excludeLower);break;case r:n=this.keyRange.upperBound(t.upper,t.excludeUpper);break;default:throw new Error('Cannot create KeyRange. Provide one or both of "lower" or "upper" value, or an "only" value.')}return n}};var r=function(){},o={},i=function(t,n){var e,r;for(e in n)r=n[e],r!==o[e]&&r!==t[e]&&(t[e]=r);return t};return e.version=e.prototype.version,e},this)},{}]},{},[]);