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