mongoose 3.8.36 → 3.8.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- !function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var c=r[s]={exports:{}};e[s][0].call(c.exports,function(t){var r=e[s][1][t];return i(r?r:t)},c,c.exports,t,e,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(t,e,r){function n(t){throw"Can't use ES6 promise with mpromise style constructor"}n.use=function(t){n.ES6=t},e.exports=n},{}],2:[function(t,e,r){(function(n){r.Error=t("./error"),r.Schema=t("./schema"),r.Types=t("./types"),r.VirtualType=t("./virtualtype"),r.SchemaType=t("./schematype.js"),r.utils=t("./utils.js"),r.Document=t("./document_provider.js")(),"undefined"!=typeof window&&(window.mongoose=e.exports,window.Buffer=n)}).call(this,t("buffer").Buffer)},{"./document_provider.js":6,"./error":12,"./schema":24,"./schematype.js":36,"./types":42,"./utils.js":45,"./virtualtype":46,buffer:49}],3:[function(t,e,r){function n(t,e,r,i,f){if(!(this instanceof n))return new n(t,e,r,i,f);if(!c.isObject(e)||e instanceof a||(e=new a(e)),e=this.schema||e,!this.schema&&e.options._id&&(t=t||{},void 0===t._id&&(t._id=new u)),!e)throw new s.MissingSchemaError;this.$__setSchema(e),this.$__=new h,this.$__.emitter=new o,this.isNew=!0,this.errors=void 0,"boolean"==typeof r?(this.$__.strictMode=r,r=void 0):(this.$__.strictMode=this.schema.options&&this.schema.options.strict,this.$__.selected=r);for(var l=this.schema.requiredPaths(),p=0;p<l.length;++p)this.$__.activePaths.require(l[p]);this.$__.emitter.setMaxListeners(0),this._doc=this.$__buildDoc(t,r,i),!f&&t&&this.init(t),this.$__registerHooksFromSchema();for(var d in e.methods)this[d]=e.methods[d];for(var _ in e.statics)this[_]=e.statics[_]}var i=t("./document"),o=t("events").EventEmitter,s=t("./error"),a=t("./schema"),u=t("./types/objectid"),c=t("./utils"),f=s.ValidationError,h=t("./internal");n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.ValidationError=f,e.exports=r=n},{"./document":5,"./error":12,"./internal":21,"./schema":24,"./types/objectid":43,"./utils":45,events:53}],4:[function(t,e,r){var n=t("./utils"),i=t("./schema/index"),o=e.exports=function(t,e){for(var r,s,a,u,c,f,h=Object.keys(e),l=h.length;l--;)if(u=h[l],f=e[u],"$or"===u||"$nor"===u||"$and"===u)for(var p=f.length;p--;)f[p]=o(t,f[p]);else{if("$where"===u){if(c=typeof f,"string"!==c&&"function"!==c)throw new Error("Must have a string or function for $where");"function"===c&&(e[u]=f.toString());continue}if("$elemMatch"===u)f=o(t,f);else{if(!t)continue;if(s=t.path(u)){if(null===f||void 0===f){e[u]=null;continue}if("Object"===f.constructor.name)if(r=Object.keys(f).some(function(t){return"$"===t.charAt(0)&&"$id"!==t&&"$ref"!==t})){var d,_=Object.keys(f);for(p=_.length;p--;)if(d=_[p],a=f[d],"$exists"!==d){if("$type"!==d)"$not"===d?o(t,a):f[d]=s.castForQuery(d,a);else if("number"!=typeof a)throw new Error("$type parameter must be Number")}else if("boolean"!=typeof a)throw new Error("$exists parameter must be Boolean")}else e[u]=s.castForQuery(f);else e[u]=s.castForQuery(f)}else{for(var y,v,g,m=u.split("."),b=m.length;b--&&(y=m.slice(0,b).join("."),!(s=t.path(y))););if(s){s.caster&&s.caster.schema?(g={},v=m.slice(b).join("."),g[v]=f,e[u]=o(s.caster.schema,g)[v]):e[u]=f;continue}if(n.isObject(f)){var w=f.$near?"$near":f.$nearSphere?"$nearSphere":f.$within?"$within":f.$geoIntersects?"$geoIntersects":"";if(!w)continue;var E=new i.Number("__QueryCasting__"),A=f[w];if(f.$maxDistance&&(f.$maxDistance=E.castForQuery(f.$maxDistance)),"$within"==w){var O=A.$center||A.$centerSphere||A.$box||A.$polygon;if(!O)throw new Error("Bad $within paramater: "+JSON.stringify(f));A=O}else"$near"==w&&"string"==typeof A.type&&Array.isArray(A.coordinates)?A=A.coordinates:("$near"==w||"$nearSphere"==w||"$geoIntersects"==w)&&A.$geometry&&"string"==typeof A.$geometry.type&&Array.isArray(A.$geometry.coordinates)&&(A=A.$geometry.coordinates);!function t(e){if(Array.isArray(e))e.forEach(function(r,i){return Array.isArray(r)||n.isObject(r)?t(r):void(e[i]=E.castForQuery(r))});else for(var r=Object.keys(e),i=r.length;i--;){var o=r[i],s=e[o];Array.isArray(s)||n.isObject(s)?(t(s),e[o]=s):e[o]=E.castForQuery(s)}}(A)}}}}return e}},{"./schema/index":31,"./utils":45}],5:[function(t,e,r){(function(n,i){function o(t,e,r){this.$__=new S,this.$__.emitter=new _,this.isNew=!0,this.errors=void 0;var n=this.schema;"boolean"==typeof e?(this.$__.strictMode=e,e=void 0):(this.$__.strictMode=n.options&&n.options.strict,this.$__.selected=e);for(var i=n.requiredPaths(!0),o=0;o<i.length;++o)this.$__.activePaths.require(i[o]);if(this.$__.emitter.setMaxListeners(0),this._doc=this.$__buildDoc(t,e,r),t&&this.set(t,void 0,!0),!n.options.strict&&t){var s=this,a=Object.keys(this._doc);a.forEach(function(t){t in n.tree||c(t,null,s)})}this.$__registerHooksFromSchema()}function s(t,e,r,n){n=n||"";for(var i,o,a,u=Object.keys(e),c=u.length;c--;)if(a=u[c],o=n+a,i=t.schema.path(o),i||!b.isObject(e[a])||e[a].constructor&&"Object"!=b.getFunctionName(e[a].constructor)){if(null===e[a])r[a]=null;else if(void 0!==e[a])if(i)try{r[a]=i.cast(e[a],t,!0)}catch(e){t.invalidate(e.path,new m({path:e.path,message:e.message,type:"cast",value:e.value}))}else r[a]=e[a];t.isModified(o)||t.$__.activePaths.init(o)}else r[a]||(r[a]={}),s(t,e[a],r[a],o+".")}function a(t,e,r,n){for(var i,o,s=Object.keys(t),a=s.length;a--;)o=s[a],i=t[o],c(o,"Object"===b.getFunctionName(i.constructor)&&Object.keys(i).length&&(!i[n.typeKey]||"type"===n.typeKey&&i.type.type)?i:null,e,r,s,n)}function u(t){var e={};return Object.getOwnPropertyNames(t).forEach(function(r){e[r]=Object.getOwnPropertyDescriptor(t,r),e[r].enumerable=!0}),e}function c(t,e,r,n,i,s){var c=(n?n+".":"")+t;n=n||"",e?Object.defineProperty(r,t,{enumerable:!0,configurable:!0,get:function(){var t=this;if(this.$__.getters||(this.$__.getters={}),!this.$__.getters[c]){var r=Object.create(Object.getPrototypeOf(this),u(this));n||(r.$__.scope=this);for(var o=0,f=i.length;f>o;++o)Object.defineProperty(r,i[o],{enumerable:!1,writable:!0,configurable:!0,value:void 0});r.toObject=function(){return t.get(c)},r.toJSON=r.toObject,r.$__isNested=!0,a(e,r,c,s),this.$__.getters[c]=r}return this.$__.getters[c]},set:function(t){return t instanceof o&&(t=t.toObject()),(this.$__.scope||this).set(c,t)}}):Object.defineProperty(r,t,{enumerable:!0,configurable:!0,get:function(){return this.get.call(this.$__.scope||this,c)},set:function(t){return this.set.call(this.$__.scope||this,c,t)}})}function f(t){for(var e,r,n,i=Object.keys(t),o=i.length;o--;)r=i[o],n=t[r],b.isObject(n)&&(t[r]=f(n)),void 0!==t[r]?e=!0:delete t[r];return e?t:void 0}function h(t,e,r,n){for(var i,o=t.schema,s=Object.keys(o[r]),a=s.length;a--;){i=s[a];for(var u,c=i.split("."),f=c.length,h=f-1,l=e,p=0;f>p;++p)u=c[p],p===h?l[u]=w(t.get(i),n):l=l[u]||(l[u]={})}return e}var l,p,d,_=t("events").EventEmitter,y=t("./error"),v=t("./schema/mixed"),g=t("./schema"),m=t("./schematype").ValidatorError,b=t("./utils"),w=b.clone,E=b.isMongooseObject,A=t("util").inspect,O=y.ValidationError,S=t("./internal"),j=b.deepEqual,N=t("hooks-fixed"),x=t("./promise_provider");b.each(["on","once","emit","listeners","removeListener","setMaxListeners","removeAllListeners","addListener"],function(t){o.prototype[t]=function(){return this.$__.emitter[t].apply(this.$__.emitter,arguments)}}),o.prototype.constructor=o,o.prototype.schema,o.prototype.isNew,o.prototype.id,o.prototype.errors,o.prototype.$__buildDoc=function(t,e,r){var n,i,o={},s=null,a=this;if(e&&"Object"===b.getFunctionName(e.constructor))if(n=Object.keys(e),i=n.length,1===i&&"_id"===n[0])s=!!e[n[i]];else for(;i--;)if("_id"!==n[i]&&(!e[n[i]]||"object"!=typeof e[n[i]])){s=!e[n[i]];break}for(var u=Object.keys(this.schema.paths),c=u.length,f=0;c>f;++f){var h=u[f];if("_id"==h){if(r)continue;if(t&&"_id"in t)continue}for(var l=this.schema.paths[h],p=h.split("."),d=p.length,_=d-1,y="",v=o,g=0,m=!1;d>g;++g){var w,E=p[g];if(y+=E,s===!0){if(y in e)break}else e&&y in e&&(m=!0);if(g===_)if(e&&null!==s)if(s===!0){if(h in e)continue;w=l.getDefault(a,!0),"undefined"!=typeof w&&(v[E]=w,a.$__.activePaths.default(h))}else m&&(w=l.getDefault(a,!0),"undefined"!=typeof w&&(v[E]=w,a.$__.activePaths.default(h)));else w=l.getDefault(a,!0),"undefined"!=typeof w&&(v[E]=w,a.$__.activePaths.default(h));else v=v[E]||(v[E]={}),y+="."}}return o},o.prototype.init=function(t,e,r){if("function"==typeof e&&(r=e,e=null),this.isNew=!1,null!=t._id&&e&&e.populated&&e.populated.length)for(var n=String(t._id),i=0;i<e.populated.length;++i){var o=e.populated[i];this.populated(o.path,o._docs[n],o)}return s(this,t,this._doc),this.$__storeShard(),this.emit("init",this),r&&r(null),this},o.prototype.$__storeShard=function(){var t=this.schema.options.shardKey||this.schema.options.shardkey;if(t&&"Object"==b.getFunctionName(t.constructor))for(var e,r=this.$__.shardval={},n=Object.keys(t),i=n.length,o=0;i>o;++o)e=this.getValue(n[o]),E(e)?r[n[o]]=e.toObject({depopulate:!0}):null==e||!e.valueOf||e.constructor&&"Date"===b.getFunctionName(e.constructor)?r[n[o]]=e:r[n[o]]=e.valueOf()};for(var B in N)o.prototype[B]=o[B]=N[B];o.prototype.update=function(){var t=b.args(arguments);return t.unshift({_id:this._id}),this.constructor.update.apply(this.constructor,t)},o.prototype.set=function(t,e,r,n){r&&"Object"==b.getFunctionName(r.constructor)&&(n=r,r=void 0);var i,s=n&&n.merge,a=r&&!0!==r,u=!0===r,c=n&&"strict"in n?n.strict:this.$__.strictMode;if(a&&(i=this.$__.adhocPaths||(this.$__.adhocPaths={}),i[t]=g.interpretAsType(t,r,this.schema.options)),"string"!=typeof t){if(null!==t&&void 0!==t){var f=e?e+".":"";t instanceof o&&(t=t.$__isNested?t.toObject():t._doc);for(var h,l,p=Object.keys(t),d=p.length;d--;){l=p[d];var _=f+l;if(h=this.schema.pathType(_),null==t[l]||!b.isObject(t[l])||t[l].constructor&&"Object"!=b.getFunctionName(t[l].constructor)||"virtual"===h||"real"===h||this.$__path(_)instanceof v||this.schema.paths[_]&&this.schema.paths[_].options&&this.schema.paths[_].options.ref)if(c){if("real"===h||"virtual"===h)this.set(f+l,t[l],u);else if("nested"===h&&t[l]instanceof o)this.set(f+l,t[l].toObject({virtuals:!1}),u);else if("throw"==c)throw new Error("Field `"+l+"` is not in schema.")}else void 0!==t[l]&&this.set(f+l,t[l],u);else this.set(t[l],f+l,u)}return this}var m=t;t=e,e=m}var w=this.schema.pathType(t);if("nested"==w&&e)return!b.isObject(e)||e.constructor&&"Object"!=b.getFunctionName(e.constructor)?(this.invalidate(t,new y.CastError("Object",e,t)),this):(s||this.setValue(t,null),this.set(e,t,u),this);var E,A=t.split(".");if("adhocOrUndefined"==w&&c){var O;for(d=0;d<A.length;++d){var S=A.slice(0,d+1).join(".");if(E=this.schema.path(S),E instanceof v){O=!0;break}}if(!O){if("throw"==c)throw new Error("Field `"+t+"` is not in schema.");return this}}else{if("virtual"==w)return E=this.schema.virtualpath(t),E.applySetters(e,this),this;E=this.$__path(t)}var j;if(A.length<=1)j=t;else{for(d=0;d<A.length;++d)if(S=A.slice(0,d+1).join("."),this.isDirectModified(S)||null===this.get(S)){j=S;break}j||(j=t)}var N=u?void 0:this.getValue(t);if(!E)return this.$__set(j,t,u,A,E,e,N),this;var x=!0;try{var B=!1;E.options&&E.options.ref&&e instanceof o&&E.options.ref===e.constructor.modelName&&(this.populated(t,e._id),B=!0),e=E.applySetters(e,this,!1,N),!B&&this.$__.populated&&delete this.$__.populated[t],this.$markValid(t)}catch(r){var T;r instanceof y.CastError||(T=r),this.invalidate(t,new y.CastError(E.instance,e,t,T)),x=!1}return x&&this.$__set(j,t,u,A,E,e,N),this},o.prototype.$__shouldModify=function(t,e,r,n,i,o,s){return this.isNew?!0:void 0!==o||this.isSelected(e)?void 0===o&&e in this.$__.activePaths.states.default?!1:j(o,s||this.get(e))?!r&&null!=o&&e in this.$__.activePaths.states.default&&j(o,i.getDefault(this,r))?!0:!1:!0:!0},o.prototype.$__set=function(e,r,n,i,o,s,a){d=d||t("./types/embedded");var u=this.$__shouldModify.apply(this,arguments),c=this;u&&(this.markModified(e,s),p||(p=t("./types/array")),s&&s.isMongooseArray&&(s._registerAtomic("$set",s),this.$__.activePaths.forEach(function(t){0===t.indexOf(r+".")&&c.$__.activePaths.ignore(t)})));for(var f=this._doc,h=0,l=i.length;l>h;h++){var _=h+1,y=_===l;y?f[i[h]]=s:f=f[i[h]]&&"Object"===b.getFunctionName(f[i[h]].constructor)?f[i[h]]:f[i[h]]&&f[i[h]]instanceof d?f[i[h]]:f[i[h]]&&Array.isArray(f[i[h]])?f[i[h]]:f[i[h]]={}}},o.prototype.getValue=function(t){return b.getValue(t,this._doc)},o.prototype.setValue=function(t,e){return b.setValue(t,e,this._doc),this},o.prototype.get=function(t,e){var r;e&&(r=g.interpretAsType(t,e,this.schema.options));for(var n=this.$__path(t)||this.schema.virtualpath(t),i=t.split("."),o=this._doc,s=0,a=i.length;a>s;s++)o=void 0===o||null===o?void 0:o[i[s]];return r&&(o=r.cast(o)),n&&!this.populated(t)&&(o=n.applyGetters(o,this)),o},o.prototype.$__path=function(t){var e=this.$__.adhocPaths,r=e&&e[t];return r?r:this.schema.path(t)},o.prototype.markModified=function(t){this.$__.activePaths.modify(t)},o.prototype.modifiedPaths=function(){var t=Object.keys(this.$__.activePaths.states.modify);return t.reduce(function(t,e){var r=e.split(".");return t.concat(r.reduce(function(t,e,n){return t.concat(r.slice(0,n).concat(e).join("."))},[]))},[])},o.prototype.isModified=function(t){return t?!!~this.modifiedPaths().indexOf(t):this.$__.activePaths.some("modify")},o.prototype.$isDefault=function(t){return t in this.$__.activePaths.states.default},o.prototype.isDirectModified=function(t){return t in this.$__.activePaths.states.modify},o.prototype.isInit=function(t){return t in this.$__.activePaths.states.init},o.prototype.isSelected=function(t){if(this.$__.selected){if("_id"===t)return 0!==this.$__.selected._id;var e,r=Object.keys(this.$__.selected),n=r.length,i=!1;if(1===n&&"_id"===r[0])return 0===this.$__.selected._id;for(;n--;)if(e=r[n],"_id"!=e){i=!!this.$__.selected[e];break}if(t in this.$__.selected)return i;n=r.length;for(var o=t+".";n--;)if(e=r[n],"_id"!=e){if(0===e.indexOf(o))return i;if(0===o.indexOf(e+"."))return i}return!i}return!0},o.prototype.validate=function(t,e){var r=this,n=x.get();return"function"==typeof t&&(e=t,t=null),t&&t.__noPromise?void this.$__validate(e):new n.ES6(function(t,n){r.$__validate(function(r){return e&&e(r),r?void n(r):void t()})})},o.prototype.$__validate=function(t){var e=this,r=function(){var t=e.$__.validationError;if(e.$__.validationError=void 0,e.emit("validate",e),t){for(var r in t.errors)!e.__parent&&t.errors[r]instanceof y.CastError&&e.invalidate(r,t.errors[r]);return t}},o=Object.keys(this.$__.activePaths.states.require).filter(function(t){return e.isSelected(t)||e.isModified(t)?!0:!1});o=o.concat(Object.keys(this.$__.activePaths.states.init)),o=o.concat(Object.keys(this.$__.activePaths.states.modify)),o=o.concat(Object.keys(this.$__.activePaths.states.default)),0===o.length&&n.nextTick(function(){var e=r();return e?void t(e):void t()});for(var s={},a=0,u=0;u<o.length;++u){var c=o[u],f=e.getValue(c);if(f&&f.isMongooseArray&&!i.isBuffer(f)&&!f.isMongooseDocumentArray)for(var h=f.length,l=0;h>l;++l)o.push(c+"."+l)}var p=function(){var e=r();return e?void t(e):void t()},d=function(t){s[t]||(s[t]=!0,a++,n.nextTick(function(){var r=e.schema.path(t);if(!r)return--a||p();if(!e.$isValid(t))return void(--a||p());var n=e.getValue(t);r.doValidate(n,function(r){r&&e.invalidate(t,r,void 0,!0),--a||p()},e)}))};o.forEach(d)},o.prototype.validateSync=function(t){var e=this;"string"==typeof t&&(t=t.split(" "));var r=Object.keys(this.$__.activePaths.states.require).filter(function(t){return e.isSelected(t)||e.isModified(t)?!0:!1});if(r=r.concat(Object.keys(this.$__.activePaths.states.init)),r=r.concat(Object.keys(this.$__.activePaths.states.modify)),r=r.concat(Object.keys(this.$__.activePaths.states.default)),t&&t.length){for(var n=[],i=0;i<r.length;++i)-1!==t.indexOf(r[i])&&n.push(r[i]);r=n}var o={};r.forEach(function(t){if(!o[t]){o[t]=!0;var r=e.schema.path(t);if(r&&e.$isValid(t)){var n=e.getValue(t),i=r.doValidateSync(n,e);i&&e.invalidate(t,i,void 0,!0)}}});var s=e.$__.validationError;if(e.$__.validationError=void 0,e.emit("validate",e),s)for(var a in s.errors)s.errors[a]instanceof y.CastError&&e.invalidate(a,s.errors[a]);return s},o.prototype.invalidate=function(t,e,r){this.$__.validationError||(this.$__.validationError=new O(this)),this.$__.validationError.errors[t]||(e&&"string"!=typeof e||(e=new m({path:t,message:e,type:"user defined",value:r})),this.$__.validationError!=e&&(this.$__.validationError.errors[t]=e))},o.prototype.$markValid=function(t){this.$__.validationError&&this.$__.validationError.errors[t]&&(delete this.$__.validationError.errors[t],0===Object.keys(this.$__.validationError.errors).length&&(this.$__.validationError=null))},o.prototype.$isValid=function(t){return!this.$__.validationError||!this.$__.validationError.errors[t]},o.prototype.$__reset=function(){var e=this;return l||(l=t("./types/documentarray")),this.$__.activePaths.map("init","modify",function(t){return e.getValue(t)}).filter(function(t){return t&&t instanceof Array&&t.isMongooseDocumentArray&&t.length}).forEach(function(t){for(var e=t.length;e--;){var r=t[e];r&&r.$__reset()}}),this.$__dirty().forEach(function(t){var e=t.value;e&&e._atomics&&(e._atomics={})}),this.$__.activePaths.clear("modify"),this.$__.activePaths.clear("default"),this.$__.validationError=void 0,this.errors=void 0,e=this,this.schema.requiredPaths().forEach(function(t){e.$__.activePaths.require(t)}),this},o.prototype.$__dirty=function(){var t=this,e=this.$__.activePaths.map("modify",function(e){return{path:e,value:t.getValue(e),schema:t.$__path(e)}});e=e.concat(this.$__.activePaths.map("default",function(e){return"_id"!==e&&t.getValue(e)?{path:e,value:t.getValue(e),schema:t.$__path(e)}:void 0})),e.sort(function(t,e){return t.path<e.path?-1:t.path>e.path?1:0});var r,n,i=[];return e.forEach(function(t,e){t&&(0!==t.path.indexOf(r)?(r=t.path+".",i.push(t),n=t):n.value&&n.value._atomics&&n.value.hasAtomics()&&(n.value._atomics={},n.value._atomics.$set=n.value))}),n=r=null,i},o.prototype.$__setSchema=function(t){a(t.tree,this,void 0,t.options),this.schema=t},o.prototype.$__getArrayPathsToValidate=function(){return l||(l=t("./types/documentarray")),this.$__.activePaths.map("init","modify",function(t){return this.getValue(t)}.bind(this)).filter(function(t){return t&&t instanceof Array&&t.isMongooseDocumentArray&&t.length}).reduce(function(t,e){return t.concat(e)},[]).filter(function(t){return t})},o.prototype.$__getAllSubdocs=function(){function e(t,r){var n=this[r];return n instanceof d&&t.push(n),n&&n.$isSingleNested&&t.push(n),n&&n.isMongooseDocumentArray?n.forEach(function(r){r&&r._doc&&(r instanceof d&&t.push(r),t=Object.keys(r._doc).reduce(e.bind(r._doc),t))}):n instanceof o&&n.$__isNested&&(n=n.toObject(),n&&(t=Object.keys(n).reduce(e.bind(n),t))),t}l||(l=t("./types/documentarray")),d=d||t("./types/embedded");var r=Object.keys(this._doc).reduce(e.bind(this),[]);return r},o.prototype.$__registerHooksFromSchema=function(){d=d||t("./types/embedded");var e=x.get(),r=this,n=r.schema&&r.schema.callQueue;if(!n.length)return r;var i=n.reduce(function(t,e){if("pre"!==e[0]&&"post"!==e[0]&&"on"!==e[0])return r[e[0]].apply(r,e[1]),t;var n=[].slice.call(e[1]),i="on"===e[0]?"post":n[0];return i in t||(t[i]={post:[],pre:[]}),"post"===e[0]?t[i].post.push(n):"on"===e[0]?t[i].push(n):t[i].pre.push(n),t},{post:[]});return i.post.forEach(function(t){r.on.apply(r,t)}),delete i.post,i.init&&r instanceof d&&(i.init.pre&&i.init.pre.forEach(function(t){r.pre.apply(r,t)}),i.init.post&&i.init.post.forEach(function(t){r.post.apply(r,t)}),delete i.init),Object.keys(i).forEach(function(t){var n="$__original_"+t;r[t]&&(r[n]=r[t],r[t]=function(){var t,i=[].slice.call(arguments),o=i.pop();return new e.ES6(function(e,s){o&&"function"!=typeof o?i.push(o):t=o,i.push(function(n,i){return n?(r.$__handleReject(n),t&&t(n),void s(n)):(t&&t.apply(null,[null].concat(Array.prototype.slice.call(arguments,1))),void e(i))}),r[n].apply(r,i)})},i[t].pre.forEach(function(t){t[0]=n,r.pre.apply(r,t)}),i[t].post.forEach(function(t){t[0]=n,r.post.apply(r,t)}))}),r},o.prototype.$__handleReject=function(t){this.listeners("error").length?this.emit("error",t):this.constructor.listeners&&this.constructor.listeners("error").length?this.constructor.emit("error",t):this.listeners&&this.listeners("error").length&&this.emit("error",t)},o.prototype.$toObject=function(t,e){var r={transform:!0,json:e};if(t&&t.depopulate&&!t._skipDepopulateTopLevel&&this.$__.wasPopulated)return w(this._id,t);t&&t._skipDepopulateTopLevel&&(t._skipDepopulateTopLevel=!1),(!t||"Object"!=b.getFunctionName(t.constructor)||t&&t._useSchemaOptions)&&(e?(t=this.schema.options.toJSON?w(this.schema.options.toJSON):{},t.json=!0,t._useSchemaOptions=!0):(t=this.schema.options.toObject?w(this.schema.options.toObject):{},t.json=!1,t._useSchemaOptions=!0));for(var n in r)void 0===t[n]&&(t[n]=r[n]);"minimize"in t||(t.minimize=this.schema.options.minimize);var i=t.transform,o=w(this._doc,t)||{};(t.virtuals||t.getters&&!1!==t.virtuals)&&h(this,o,"virtuals",t),t.getters&&(h(this,o,"paths",t),t.minimize&&(o=f(o)||{})),t.versionKey===!1&&this.schema.options.versionKey&&delete o[this.schema.options.versionKey];var s=t.transform;if(!0===s||this.schema.options.toObject&&s){var a=t.json?this.schema.options.toJSON:this.schema.options.toObject;a&&(s="function"==typeof t.transform?t.transform:a.transform)}else t.transform=i;if("function"==typeof s){var u=s(this,o,t);"undefined"!=typeof u&&(o=u)}return o},o.prototype.toObject=function(t){return this.$toObject(t)},o.prototype.toJSON=function(t){return this.$toObject(t,!0)},o.prototype.inspect=function(t){var e=t&&"Object"==b.getFunctionName(t.constructor)?t:{};return e.minimize=!1,e.retainKeyOrder=!0,A(this.toObject(e))},o.prototype.toString=o.prototype.inspect,o.prototype.equals=function(t){var e=this.get("_id"),r=t.get?t.get("_id"):t;return e||r?e&&e.equals?e.equals(r):e===r:j(this,t)},o.prototype.populate=function(){if(0===arguments.length)return this;var t,e=this.$__.populate||(this.$__.populate={}),r=b.args(arguments);if("function"==typeof r[r.length-1]&&(t=r.pop()),r.length)for(var n=b.populate.apply(null,r),i=0;i<n.length;++i)e[n[i].path]=n[i];if(t){var o=b.object.vals(e);this.$__.populate=void 0,this.constructor.populate(this,o,t)}return this},o.prototype.execPopulate=function(){var t=x.get(),e=this;return new t.ES6(function(t,r){e.populate(function(n){return n?r(n):void t(e)})})},o.prototype.populated=function(t,e,r){if(null==e){if(!this.$__.populated)return void 0;var n=this.$__.populated[t];return n?n.value:void 0}return!0===e?this.$__.populated?this.$__.populated[t]:void 0:(this.$__.populated||(this.$__.populated={}),this.$__.populated[t]={value:e,options:r},e)},o.prototype.depopulate=function(t){var e=this.populated(t);e&&(delete this.$__.populated[t],this.set(t,e))},o.prototype.$__fullPath=function(t){return t||""},o.ValidationError=O,e.exports=r=o}).call(this,t("FWaASH"),t("buffer").Buffer)},{"./error":12,"./internal":21,"./promise_provider":23,"./schema":24,"./schema/mixed":32,"./schematype":36,"./types/array":38,"./types/documentarray":40,"./types/embedded":41,"./utils":45,FWaASH:55,buffer:49,events:53,"hooks-fixed":76,util:57}],6:[function(t,e,r){"use strict";var n=t("./document.js"),i=t("./browserDocument.js");e.exports=function(){return"undefined"!=typeof window&&"undefined"!=typeof document&&document===window.document?i:n}},{"./browserDocument.js":3,"./document.js":5}],7:[function(t,e,r){e.exports=function(){}},{}],8:[function(t,e,r){var n=t("bson").Binary;e.exports=r=n},{bson:60}],9:[function(t,e,r){r.Binary=t("./binary"),r.ObjectId=t("./objectid"),r.ReadPreference=t("./ReadPreference")},{"./ReadPreference":7,"./binary":8,"./objectid":10}],10:[function(t,e,r){var n=t("bson").ObjectID;e.exports=r=n},{bson:60}],11:[function(t,e,r){(function(r){var n;n=t("undefined"==typeof window?r.MONGOOSE_DRIVER_PATH||"./node-mongodb-native":"./browser"),e.exports=n}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./browser":9}],12:[function(t,e,r){function n(t){Error.call(this),this.stack=(new Error).stack,this.message=t,this.name="MongooseError"}n.prototype=Object.create(Error.prototype),n.prototype.constructor=Error,e.exports=r=n,n.messages=t("./error/messages"),n.Messages=n.messages,n.CastError=t("./error/cast"),n.ValidationError=t("./error/validation"),n.ValidatorError=t("./error/validator"),n.VersionError=t("./error/version"),n.OverwriteModelError=t("./error/overwriteModel"),n.MissingSchemaError=t("./error/missingSchema"),n.DivergentArrayError=t("./error/divergentArray")},{"./error/cast":13,"./error/divergentArray":14,"./error/messages":15,"./error/missingSchema":16,"./error/overwriteModel":17,"./error/validation":18,"./error/validator":19,"./error/version":20}],13:[function(t,e,r){function n(t,e,r,n){i.call(this,"Cast to "+t+' failed for value "'+e+'" at path "'+r+'"'),this.stack=(new Error).stack,this.name="CastError",this.kind=t,this.value=e,this.path=r,this.reason=n}var i=t("../error.js");n.prototype=Object.create(i.prototype),n.prototype.constructor=i,e.exports=n},{"../error.js":12}],14:[function(t,e,r){function n(t){var e="For your own good, using `document.save()` to update an array which was selected using an $elemMatch projection OR populated using skip, limit, query conditions, or exclusion of the _id field when the operation results in a $pop or $set of the entire array is not supported. The following path(s) would have been modified unsafely:\n "+t.join("\n ")+"\nUse Model.update() to update these arrays instead.";i.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,arguments.callee),this.name="DivergentArrayError"}var i=t("../error.js");n.prototype=Object.create(i.prototype),n.prototype.constructor=i,e.exports=n},{"../error.js":12}],15:[function(t,e,r){var n=e.exports=r={};n.general={},n.general.default="Validator failed for path `{PATH}` with value `{VALUE}`",n.general.required="Path `{PATH}` is required.",n.Number={},n.Number.min="Path `{PATH}` ({VALUE}) is less than minimum allowed value ({MIN}).",n.Number.max="Path `{PATH}` ({VALUE}) is more than maximum allowed value ({MAX}).",n.Date={},n.Date.min="Path `{PATH}` ({VALUE}) is before minimum allowed value ({MIN}).",n.Date.max="Path `{PATH}` ({VALUE}) is after maximum allowed value ({MAX}).",n.String={},n.String.enum="`{VALUE}` is not a valid enum value for path `{PATH}`.",n.String.match="Path `{PATH}` is invalid ({VALUE}).",n.String.minlength="Path `{PATH}` (`{VALUE}`) is shorter than the minimum allowed length ({MINLENGTH}).",n.String.maxlength="Path `{PATH}` (`{VALUE}`) is longer than the maximum allowed length ({MAXLENGTH})."},{}],16:[function(t,e,r){function n(t){var e="Schema hasn't been registered for model \""+t+'".\nUse mongoose.model(name, schema)';i.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,arguments.callee),this.name="MissingSchemaError"}var i=t("../error.js");n.prototype=Object.create(i.prototype),n.prototype.constructor=i,e.exports=n},{"../error.js":12}],17:[function(t,e,r){function n(t){i.call(this,"Cannot overwrite `"+t+"` model once compiled."),Error.captureStackTrace&&Error.captureStackTrace(this,arguments.callee),this.name="OverwriteModelError"}var i=t("../error.js");n.prototype=Object.create(i.prototype),n.prototype.constructor=i,e.exports=n},{"../error.js":12}],18:[function(t,e,r){function n(t){t&&"model"===t.constructor.name?i.call(this,t.constructor.modelName+" validation failed"):i.call(this,"Validation failed"),this.stack=(new Error).stack,this.name="ValidationError",this.errors={},t&&(t.errors=this.errors)}var i=t("../error.js");n.prototype=Object.create(i.prototype),n.prototype.constructor=i,n.prototype.toString=function(){var t=this.name+": ",e=[];return Object.keys(this.errors).forEach(function(t){this!=this.errors[t]&&e.push(String(this.errors[t]))},this),t+e.join(", ")},e.exports=r=n},{"../error.js":12}],19:[function(t,e,r){function n(t){var e=t.message;e||(e=o.general.default),this.properties=t;var r=this.formatMessage(e,t);i.call(this,r),this.stack=(new Error).stack,this.name="ValidatorError",this.kind=t.type,this.path=t.path,this.value=t.value}var i=t("../error.js"),o=i.messages;n.prototype=Object.create(i.prototype),n.prototype.constructor=i,n.prototype.formatMessage=function(t,e){for(var r=Object.keys(e),n=0;n<r.length;++n){var i=r[n];"message"!==i&&(t=t.replace("{"+i.toUpperCase()+"}",e[i]))}return t},n.prototype.toString=function(){return this.message},e.exports=n},{"../error.js":12}],20:[function(t,e,r){function n(){i.call(this,"No matching document found."),Error.captureStackTrace&&Error.captureStackTrace(this,arguments.callee),this.name="VersionError"}var i=t("../error.js");n.prototype=Object.create(i.prototype),n.prototype.constructor=i,e.exports=n},{"../error.js":12}],21:[function(t,e,r){function n(){this.strictMode=void 0,this.selected=void 0,this.shardval=void 0,this.saveError=void 0,this.validationError=void 0,this.adhocPaths=void 0,this.removing=void 0,this.inserting=void 0,this.version=void 0,this.getters={},this._id=void 0,this.populate=void 0,this.populated=void 0,this.wasPopulated=!1,this.scope=void 0,this.activePaths=new o,this.ownerDocument=void 0,this.fullPath=void 0}var i=t("./statemachine"),o=i.ctor("require","modify","init","default","ignore");e.exports=r=n},{"./statemachine":37}],22:[function(t,e,r){function n(t){i.call(this,t)}var i=t("mpromise"),o=t("util");n.ES6=function(t){var e=new n;return t(function(){e.complete.apply(e,arguments)},function(t){e.error(t)}),e},n.prototype=Object.create(i.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),n.SUCCESS="complete",n.FAILURE="err",n.prototype.error=function(t){return t instanceof Error||(t instanceof Object&&(t=o.inspect(t)),t=new Error(t)),this.reject(t)},n.prototype.resolve=function(t){return t?this.error(t):this.fulfill.apply(this,Array.prototype.slice.call(arguments,1))},n.prototype.addBack=n.prototype.onResolve,n.prototype.complete=i.prototype.fulfill,n.prototype.addCallback=n.prototype.onFulfill,n.prototype.addErrback=n.prototype.onReject,e.exports=n},{mpromise:80,util:57}],23:[function(t,e,r){var n=t("./promise"),i={_promise:n};i.get=function(){return i._promise},i.set=function(e){return e===n?i.reset():(i._promise=t("./ES6Promise"),i._promise.use(e),void(t("mquery").Promise=i._promise.ES6))},i.reset=function(){i._promise=n},e.exports=i},{"./ES6Promise":1,"./promise":22,mquery:85}],24:[function(t,e,r){(function(n){function i(t,e){if(!(this instanceof i))return new i(t,e);this.paths={},this.subpaths={},this.virtuals={},this.nested={},this.inherits={},this.callQueue=[],this._indexes=[],this.methods={},this.statics={},this.tree={},this._requiredpaths=void 0,this.discriminatorMapping=void 0,this._indexedpaths=void 0,this.s={hooks:new p,queryHooks:y},this.options=this.defaultOptions(e),t&&this.add(t);var r=t&&t._id&&l.isObject(t._id),n=!this.paths._id&&!this.options.noId&&this.options._id&&!r;if(n){var t={_id:{auto:!0}};t._id[this.options.typeKey]=i.ObjectId,this.add(t)}var s=!this.paths.id&&!this.options.noVirtualId&&this.options.id;s&&this.virtual("id").get(o);for(var a=0;a<this._defaultMiddleware.length;++a){var u=this._defaultMiddleware[a];this[u.kind](u.hook,!!u.isAsync,u.fn)}var c=this.options.timestamps;if(c){var f=c.createdAt||"createdAt",h=c.updatedAt||"updatedAt",d={};d[h]=Date,this.paths[f]||(d[f]=Date),this.add(d),this.pre("save",function(t){var e=new Date;this[f]||(this[f]=n?this._id.getTimestamp():e),this[h]=this.isNew?this[f]:e,t()});var _=function(){var t=new Date,e={$set:{},$setOnInsert:{}};return e.$set[h]=t,e.$setOnInsert[f]=t,e};this.pre("findOneAndUpdate",function(t){this.findOneAndUpdate({},_()),t()}),this.pre("update",function(t){this.update({},_()),t()})}}function o(){return this.$__._id?this.$__._id:this.$__._id=null==this._id?null:String(this._id)}function s(t,e){var r=e.split(/\.(\d+)\.|\.(\d+)$/).filter(Boolean);if(r.length<2)return t.paths[r[0]];
2
- var n=t.path(r[0]),i=!1;if(!n)return n;for(var o,s=r.length-1,a=1;a<r.length;++a){if(i=!1,o=r[a],a===s&&n&&!n.schema&&!/\D/.test(o)){n=n instanceof u.Array?n.caster:void 0;break}if(/\D/.test(o)){if(!n||!n.schema){n=void 0;break}var c=n.schema.pathType(o);i="nested"===c,n=n.schema.path(o)}}return t.subpaths[e]=n,n?"real":i?"nested":"adhocOrUndefined"}function a(t,e){return s(t,e),t.subpaths[e]}var u,c=t("./drivers").ReadPreference,f=t("events").EventEmitter,h=t("./virtualtype"),l=t("./utils"),p=t("kareem"),d=t("async"),_=t("./promise_provider"),y={count:!0,find:!0,findOne:!0,findOneAndUpdate:!0,findOneAndRemove:!0,update:!0};i.prototype=Object.create(f.prototype),i.prototype.constructor=i,Object.defineProperty(i.prototype,"_defaultMiddleware",{configurable:!1,enumerable:!1,writable:!1,value:[{kind:"pre",hook:"save",fn:function(t,e){if(this.ownerDocument)return t();var r,n=e&&"object"==typeof e&&"validateBeforeSave"in e;r=n?!!e.validateBeforeSave:this.schema.options.validateBeforeSave,r?this.$__original_validate?this.$__original_validate({__noPromise:!0},function(e){t(e)}):this.validate({__noPromise:!0},function(e){t(e)}):t()}},{kind:"pre",hook:"save",isAsync:!0,fn:function(t,e){var r=_.get(),n=this.$__getAllSubdocs();return!n.length||this.$__preSavingFromParent?(e(),void t()):void new r.ES6(function(t,e){d.each(n,function(t,e){t.$__preSavingFromParent=!0,t.save(function(t){e(t)})},function(r){for(var i=0;i<n.length;++i)delete n[i].$__preSavingFromParent;return r?void e(r):void t()})}).then(function(){t(),e()},e)}}]}),i.prototype.paths,i.prototype.tree,i.prototype.defaultOptions=function(t){return t&&!1===t.safe&&(t.safe={w:0}),t&&t.safe&&0===t.safe.w&&(t.versionKey=!1),t=l.options({strict:!0,bufferCommands:!0,capped:!1,versionKey:"__v",discriminatorKey:"__t",minimize:!0,autoIndex:null,shardKey:null,read:null,validateBeforeSave:!0,noId:!1,_id:!0,noVirtualId:!1,id:!0,typeKey:"type"},t),t.read&&(t.read=c(t.read)),t},i.prototype.add=function(t,e){e=e||"";for(var r=Object.keys(t),n=0;n<r.length;++n){var i=r[n];if(null==t[i])throw new TypeError("Invalid value for schema path `"+e+i+"`");if(Array.isArray(t[i])&&1===t[i].length&&null==t[i][0])throw new TypeError("Invalid value for schema Array path `"+e+i+"`");!l.isObject(t[i])||t[i].constructor&&"Object"!=l.getFunctionName(t[i].constructor)||t[i][this.options.typeKey]&&("type"!==this.options.typeKey||!t[i].type.type)?this.path(e+i,t[i]):Object.keys(t[i]).length?(this.nested[e+i]=!0,this.add(t[i],e+i+".")):this.path(e+i,t[i])}},i.reserved=Object.create(null);var v=i.reserved;v.emit=v.on=v.once=v.collection=v.db=v.errors=v.init=v.isModified=v.isNew=v.get=v.modelName=v.save=v.schema=v.set=v.toObject=v.validate=v._pres=v._posts=1;var g={};g.increment="`increment` should not be used as a schema path name unless you have disabled versioning.",i.prototype.path=function(t,e){if(void 0==e)return this.paths[t]?this.paths[t]:this.subpaths[t]?this.subpaths[t]:/\.\d+\.?.*$/.test(t)?a(this,t):void 0;if(v[t])throw new Error("`"+t+"` may not be used as a schema pathname");g[t]&&console.log("WARN: "+g[t]);var r=t.split(/\./),n=r.pop(),o=this.tree;return r.forEach(function(e,n){if(o[e]||(o[e]={}),"object"!=typeof o[e]){var i="Cannot set nested path `"+t+"`. Parent path `"+r.slice(0,n).concat([e]).join(".")+"` already set to type "+o[e].name+".";throw new Error(i)}o=o[e]}),o[n]=l.clone(e),this.paths[t]=i.interpretAsType(t,e,this.options),this},i.interpretAsType=function(t,e,r){if(e.constructor){var o=l.getFunctionName(e.constructor);if("Object"!=o){var s=e;e={},e[r.typeKey]=s}}var a=!e[r.typeKey]||"type"===r.typeKey&&e.type.type?{}:e[r.typeKey];if("Object"==l.getFunctionName(a.constructor)||"mixed"==a)return new u.Mixed(t,e);if(Array.isArray(a)||Array==a||"array"==a){var c=Array==a||"array"==a?e.cast:a[0];if(c instanceof i)return new u.DocumentArray(t,c,e);if("string"==typeof c)c=u[c.charAt(0).toUpperCase()+c.substring(1)];else if(c&&(!c[r.typeKey]||"type"===r.typeKey&&c.type.type)&&"Object"==l.getFunctionName(c.constructor)&&Object.keys(c).length){var f={minimize:r.minimize};return new u.DocumentArray(t,new i(c,f),e)}return new u.Array(t,c||u.Mixed,e)}if(a instanceof i)return new u.Embedded(a,t,e);var h;if(h=n.isBuffer(a)?"Buffer":"string"==typeof a?a:a.schemaName||l.getFunctionName(a),h&&(h=h.charAt(0).toUpperCase()+h.substring(1)),void 0==u[h])throw new TypeError("Undefined type `"+h+"` at `"+t+"`\n Did you try nesting Schemas? You can only nest using refs or arrays.");return new u[h](t,e)},i.prototype.eachPath=function(t){for(var e=Object.keys(this.paths),r=e.length,n=0;r>n;++n)t(e[n],this.paths[e[n]]);return this},i.prototype.requiredPaths=function(t){if(this._requiredpaths&&!t)return this._requiredpaths;for(var e=Object.keys(this.paths),r=e.length,n=[];r--;){var i=e[r];this.paths[i].isRequired&&n.push(i)}return this._requiredpaths=n},i.prototype.indexedPaths=function(){return this._indexedpaths?this._indexedpaths:this._indexedpaths=this.indexes()},i.prototype.pathType=function(t){return t in this.paths?"real":t in this.virtuals?"virtual":t in this.nested?"nested":t in this.subpaths?"real":/\.\d+\.|\.\d+$/.test(t)?s(this,t):"adhocOrUndefined"},i.prototype.hasMixedParent=function(t){var e=t.split(/\./g);t="";for(var r=0;r<e.length;++r)if(t=r>0?t+"."+e[r]:e[r],t in this.paths&&this.paths[t]instanceof u.Mixed)return!0;return!1},i.prototype.queue=function(t,e){return this.callQueue.push([t,e]),this},i.prototype.pre=function(){var t=arguments[0];return y[t]?(this.s.hooks.pre.apply(this.s.hooks,arguments),this):this.queue("pre",arguments)},i.prototype.post=function(t,e){return y[t]?(this.s.hooks.post.apply(this.s.hooks,arguments),this):e.length<2?this.queue("on",[arguments[0],function(t){return e.call(t,t)}]):this.queue("post",[arguments[0],function(t){var r=this,n=Array.prototype.slice.call(arguments,1);e.call(this,this,function(e){return t.apply(r,[e].concat(n))})}])},i.prototype.plugin=function(t,e){return t(this,e),this},i.prototype.method=function(t,e){if("string"!=typeof t)for(var r in t)this.methods[r]=t[r];else this.methods[t]=e;return this},i.prototype.static=function(t,e){if("string"!=typeof t)for(var r in t)this.statics[r]=t[r];else this.statics[t]=e;return this},i.prototype.index=function(t,e){return e||(e={}),e.expires&&l.expires(e),this._indexes.push([t,e]),this},i.prototype.set=function(t,e,r){if(1===arguments.length)return this.options[t];switch(t){case"read":this.options[t]=c(e,r);break;case"safe":this.options[t]=!1===e?{w:0}:e;break;default:this.options[t]=e}return this},i.prototype.get=function(t){return this.options[t]};var m="2d 2dsphere hashed text".split(" ");Object.defineProperty(i,"indexTypes",{get:function(){return m},set:function(){throw new Error("Cannot overwrite Schema.indexTypes")}}),i.prototype.indexes=function(){"use strict";function t(t,r){var n,i,o,s,a,u,c=t._indexes,f=c.length,h=0;for(h=0;f>h;++h){for(n=c[h][0],s=Object.keys(n),o=s.length,i={},u=0;o>u;++u)a=s[u],i[r+a]=n[a];e.push([i,c[h][1]])}}var e=[],r={},n=function(o,s){if(!r[s]){r[s]=!0,s=s||"";for(var a,c,f,h,p,d,_,y=Object.keys(o.paths),v=0;v<y.length;++v)a=y[v],c=o.paths[a],c instanceof u.DocumentArray?n(c.schema,a+"."):(f=c._index,!1!==f&&null!=f&&(h={},p=l.isObject(f),d=p?f:{},_="string"==typeof f?f:p?f.type:!1,_&&~i.indexTypes.indexOf(_)?h[s+a]=_:h[s+a]=1,delete d.type,"background"in d||(d.background=!0),e.push([h,d])));s?t(o,s):(o._indexes.forEach(function(t){"background"in t[1]||(t[1].background=!0)}),e=e.concat(o._indexes))}};return n(this),e},i.prototype.virtual=function(t,e){var r=this.virtuals,n=t.split(".");return r[t]=n.reduce(function(r,i,o){return r[i]||(r[i]=o===n.length-1?new h(e,t):{}),r[i]},this.tree)},i.prototype.virtualpath=function(t){return this.virtuals[t]},i.prototype.remove=function(t){"string"==typeof t&&(t=[t]),Array.isArray(t)&&t.forEach(function(t){this.path(t)&&delete this.paths[t]},this)},i.prototype._getSchema=function(t){var e=this,r=e.path(t);return r?r:function t(e,r){for(var n,i,o=e.length+1;o--;)if(i=e.slice(0,o).join("."),n=r.path(i)){if(n.caster){if(n.caster instanceof u.Mixed)return n.caster;if(o!==e.length&&n.schema)return"$"===e[o]?t(e.slice(o+1),n.schema):t(e.slice(o),n.schema)}return n}}(t.split("."),e)},e.exports=r=i,i.Types=u=t("./schema/index"),r.ObjectId=u.ObjectId}).call(this,t("buffer").Buffer)},{"./drivers":11,"./promise_provider":23,"./schema/index":31,"./utils":45,"./virtualtype":46,async:47,buffer:49,events:53,kareem:77}],25:[function(t,e,r){function n(t,e,r){if(e){var n={};"Object"===m.getFunctionName(e.constructor)&&(e.type?(n=m.clone(e),delete n.type,e=e.type):e=v);var i="string"==typeof e?e:m.getFunctionName(e),o=i in d?d[i]:e;this.casterConstructor=o,this.caster=new o(null,n),this.caster instanceof y||(this.caster.path=t)}l.call(this,t,r,"Array");var s,a,u=this;this.defaultValue&&(s=this.defaultValue,a="function"==typeof s),this.default(function(){var t=a?s():s||[];return new _(t,u.path,this)})}function i(t){return d.Number.prototype.cast.call(this,t)}function o(t,e){e||(e=this),t.forEach(function(r,n){Array.isArray(r)?o(r,e):t[n]=i.call(e,r)})}function s(t){return Array.isArray(t)?(o(t,this),t):t&&t.$geometry?a(t,this):n.prototype.castForQuery.call(this,t)}function a(t,e){switch(t.$geometry.type){case"Polygon":case"LineString":case"Point":o(t.$geometry.coordinates,e)}return t.$maxDistance&&(t.$maxDistance=i.call(e,t.$maxDistance)),t}function u(t){var e=this;if(t.$maxDistance&&(t.$maxDistance=i.call(e,t.$maxDistance)),t.$box||t.$polygon){var r=t.$box?"$box":"$polygon";t[r].forEach(function(t){if(!Array.isArray(t)){var e="Invalid $within $box argument. Expected an array, received "+t;throw new TypeError(e)}t.forEach(function(e,r){t[r]=i.call(this,e)})})}else t.$center||t.$centerSphere?(r=t.$center?"$center":"$centerSphere",t[r].forEach(function(e,n){Array.isArray(e)?e.forEach(function(t,r){e[r]=i.call(this,t)}):t[r][n]=i.call(this,e)})):t.$geometry&&a(t,this);return t}function c(t){return Array.isArray(t)||(t=[t]),t=t.map(function(t){if(m.isObject(t)){var e={};return e[this.path]=t,g(this.casterConstructor.schema,e)[this.path]}return t},this),this.castForQuery(t)}function f(t){for(var e,r,n=Object.keys(t),i=n.length,o=0;i>o;++o)e=n[o],r=t[e],0===e.indexOf("$")&&r&&(t[e]=this.castForQuery(e,r));return g(this.casterConstructor.schema,t)}function h(t){var e=t.$geometry;if(e)return a(t,this),t}var l=t("../schematype"),p=l.CastError,d={Boolean:t("./boolean"),Date:t("./date"),Number:t("./number"),String:t("./string"),ObjectId:t("./objectid"),Buffer:t("./buffer")},_=t("../types").Array,y=t("../types").Embedded,v=t("./mixed"),g=t("../cast"),m=t("../utils"),b=m.isMongooseObject;n.schemaName="Array",n.prototype=Object.create(l.prototype),n.prototype.constructor=n,n.prototype.checkRequired=function(t){return!(!t||!t.length)},n.prototype.applyGetters=function(t,e){return this.caster.options&&this.caster.options.ref?t:l.prototype.applyGetters.call(this,t,e)},n.prototype.cast=function(t,e,r){if(Array.isArray(t)){if(!t.length&&e)for(var n=e.schema.indexedPaths(),i=0,o=n.length;o>i;++i){var s=n[i][0][this.path];if("2dsphere"===s||"2d"===s)return}if(t&&t.isMongooseArray||(t=new _(t,this.path,e)),this.caster)try{for(i=0,o=t.length;o>i;i++)t[i]=this.caster.cast(t[i],e,r)}catch(e){throw new p(e.type,t,this.path)}return t}return e&&r&&e.markModified(this.path),this.cast([t],e,r)},n.prototype.castForQuery=function(t,e){var r,n;if(2===arguments.length){if(r=this.$conditionalHandlers[t],!r)throw new Error("Can't use "+t+" with Array.");n=r.call(this,e)}else{n=t;var i=this.casterConstructor.prototype,o=i.castForQuery||i.cast,s=this.caster;Array.isArray(n)?n=n.map(function(t){return m.isObject(t)&&t.$elemMatch?t:(o&&(t=o.call(s,t)),b(t)?t.toObject({virtuals:!1}):t)}):o&&(n=o.call(s,n))}return n&&b(n)?n.toObject({virtuals:!1}):n};var w=n.prototype.$conditionalHandlers={};w.$all=c,w.$options=String,w.$elemMatch=f,w.$geoIntersects=h,w.$or=w.$and=function(t){if(!Array.isArray(t))throw new TypeError("conditional $or/$and require array");for(var e=[],r=0;r<t.length;++r)e.push(g(this.casterConstructor.schema,t[r]));return e},w.$near=w.$nearSphere=s,w.$within=w.$geoWithin=u,w.$size=w.$maxDistance=i,w.$eq=w.$gt=w.$gte=w.$in=w.$lt=w.$lte=w.$ne=w.$nin=w.$regex=n.prototype.castForQuery,e.exports=n},{"../cast":4,"../schematype":36,"../types":42,"../utils":45,"./boolean":26,"./buffer":27,"./date":28,"./mixed":32,"./number":33,"./objectid":34,"./string":35}],26:[function(t,e,r){function n(t,e){o.call(this,t,e,"Boolean")}var i=t("../utils"),o=t("../schematype");n.schemaName="Boolean",n.prototype=Object.create(o.prototype),n.prototype.constructor=n,n.prototype.checkRequired=function(t){return t===!0||t===!1},n.prototype.cast=function(t){return null===t?t:"0"===t?!1:"true"===t?!0:"false"===t?!1:!!t},n.$conditionalHandlers=i.options(o.prototype.$conditionalHandlers,{}),n.prototype.castForQuery=function(t,e){var r;return 2===arguments.length?(r=n.$conditionalHandlers[t],r?r.call(this,e):this.cast(e)):this.cast(t)},e.exports=n},{"../schematype":36,"../utils":45}],27:[function(t,e,r){(function(r){function n(t,e){u.call(this,t,e,"Buffer")}function i(t){return this.castForQuery(t)}var o,s=t("../utils"),a=t("../types").Buffer,u=t("../schematype"),c=a.Binary,f=u.CastError;n.schemaName="Buffer",n.prototype=Object.create(u.prototype),n.prototype.constructor=n,n.prototype.checkRequired=function(t,e){return u._isRef(this,t,e,!0)?null!=t:!(!t||!t.length)},n.prototype.cast=function(e,n,i){var h;if(u._isRef(this,e,n,i)){if(null==e)return e;if(o||(o=t("./../document")),e instanceof o)return e.$__.wasPopulated=!0,e;if(r.isBuffer(e))return e;if(!s.isObject(e))throw new f("buffer",e,this.path);var l=n.$__fullPath(this.path),p=n.ownerDocument?n.ownerDocument():n,d=p.populated(l,!0);return h=new d.options.model(e),h.$__.wasPopulated=!0,h}if(e&&e._id&&(e=e._id),e&&e.isMongooseBuffer)return e;if(r.isBuffer(e))return e&&e.isMongooseBuffer||(e=new a(e,[this.path,n])),e;if(e instanceof c){if(h=new a(e.value(!0),[this.path,n]),"number"!=typeof e.sub_type)throw new f("buffer",e,this.path);return h._subtype=e.sub_type,h}if(null===e)return e;var _=typeof e;if("string"==_||"number"==_||Array.isArray(e))return h=new a(e,[this.path,n]);throw new f("buffer",e,this.path)},n.prototype.$conditionalHandlers=s.options(u.prototype.$conditionalHandlers,{$gt:i,$gte:i,$lt:i,$lte:i}),n.prototype.castForQuery=function(t,e){var r;if(2===arguments.length){if(r=this.$conditionalHandlers[t],!r)throw new Error("Can't use "+t+" with Buffer.");return r.call(this,e)}return e=t,this.cast(e).toObject()},e.exports=n}).call(this,t("buffer").Buffer)},{"../schematype":36,"../types":42,"../utils":45,"./../document":5,buffer:49}],28:[function(t,e,r){function n(t,e){a.call(this,t,e,"Date")}function i(t){return this.cast(t)}var o=t("../error").messages,s=t("../utils"),a=t("../schematype"),u=a.CastError;n.schemaName="Date",n.prototype=Object.create(a.prototype),n.prototype.constructor=n,n.prototype.expires=function(t){return this._index&&"Object"===this._index.constructor.name||(this._index={}),this._index.expires=t,s.expires(this._index),this},n.prototype.checkRequired=function(t){return t instanceof Date},n.prototype.min=function(t,e){if(this.minValidator&&(this.validators=this.validators.filter(function(t){return t.validator!=this.minValidator},this)),t){var r=e||o.Date.min;r=r.replace(/{MIN}/,t===Date.now?"Date.now()":this.cast(t).toString());var n=this;this.validators.push({validator:this.minValidator=function(e){var r=t===Date.now?t():n.cast(t);return null===e||e.valueOf()>=r.valueOf()},message:r,type:"min",min:t})}return this},n.prototype.max=function(t,e){if(this.maxValidator&&(this.validators=this.validators.filter(function(t){return t.validator!=this.maxValidator},this)),t){var r=e||o.Date.max;r=r.replace(/{MAX}/,t===Date.now?"Date.now()":this.cast(t).toString());var n=this;this.validators.push({validator:this.maxValidator=function(e){var r=t===Date.now?t():n.cast(t);return null===e||e.valueOf()<=r.valueOf()},message:r,type:"max",max:t})}return this},n.prototype.cast=function(t){if(null==t||""===t)return null;if(t instanceof Date)return t;var e;if("undefined"!=typeof t&&(t instanceof Number||"number"==typeof t||String(t)==Number(t)?e=new Date(Number(t)):t.toString&&(e=new Date(t.toString())),"Invalid Date"!=e.toString()))return e;throw new u("date",t,this.path)},n.prototype.$conditionalHandlers=s.options(a.prototype.$conditionalHandlers,{$gt:i,$gte:i,$lt:i,$lte:i}),n.prototype.castForQuery=function(t,e){var r;if(2!==arguments.length)return this.cast(t);if(r=this.$conditionalHandlers[t],!r)throw new Error("Can't use "+t+" with Date.");return r.call(this,e)},e.exports=n},{"../error":12,"../schematype":36,"../utils":45}],29:[function(t,e,r){function n(t,e,r){function n(){u.apply(this,arguments)}n.prototype=Object.create(u.prototype),n.prototype.$__setSchema(e),n.schema=e;for(var i in e.methods)n.prototype[i]=e.methods[i];for(i in e.statics)n[i]=e.statics[i];n.options=r,this.schema=e,o.call(this,t,n,r),this.schema=e;var a=this.path,c=this.defaultValue;this.default(function(){var t=c.call(this);return Array.isArray(t)||(t=[t]),new s(t,a,this)})}function i(t,e,r){if(!r||!e)return void 0;for(var n,i,o=t.path+".",s=Object.keys(e),a=s.length,u={};a--;)i=s[a],0===i.indexOf(o)&&(n||(n=!0),u[i.substring(o.length)]=e[i]);return n&&u||void 0}var o=t("./array"),s=t("../types/documentarray"),a=t("../schematype"),u=t("../types/embedded");n.schemaName="DocumentArray",n.prototype=Object.create(o.prototype),n.prototype.constructor=n,n.prototype.doValidate=function(t,e,r){a.prototype.doValidate.call(this,t,function(r){if(r)return e(r);var n,i=t&&t.length;if(!i)return e();for(var o=0,s=i;s>o;++o){var a=t[o];a?a.validate(function(t){t&&(n=t),--i||e(n)}):--i||e(n)}},r)},n.prototype.doValidateSync=function(t,e){var r=a.prototype.doValidateSync.call(this,t,e);if(r)return r;var n=t&&t.length,i=null;if(n){for(var o=0,s=n;s>o&&!i;++o){var u=t[o];if(u){var c=u.validateSync();c&&(i=c)}}return i}},n.prototype.cast=function(t,e,r,n){var o,a,c;if(!Array.isArray(t))return e&&r&&e.markModified(this.path),this.cast([t],e,r,n);if((!t||!t.isMongooseDocumentArray)&&(t=new s(t,this.path,e),n&&n._handlers))for(var f in n._handlers)e.removeListener(f,n._handlers[f]);for(c=t.length;c--;)if(!(t[c]instanceof u)&&t[c])if(r)o||(o=i(this,e.$__.selected,r)),a=new this.casterConstructor(null,t,!0,o,c),t[c]=a.init(t[c]);else{try{a=n.id(t[c]._id)}catch(t){}n&&a?(a.set(t[c]),t[c]=a):(a=new this.casterConstructor(t[c],t,void 0,void 0,c),t[c]=a)}return t},e.exports=n},{"../schematype":36,"../types/documentarray":40,"../types/embedded":41,"./array":25}],30:[function(t,e,r){function n(t,e,r){var n=function(){o.apply(this,arguments)};n.prototype=Object.create(o.prototype),n.prototype.$__setSchema(t),n.schema=t,n.$isSingleNested=!0,n.prototype.$basePath=e,this.caster=n,this.schema=t,this.$isSingleNested=!0,i.call(this,e,r,"Embedded")}var i=t("../schematype"),o=t("../types/subdocument");e.exports=n,n.prototype=Object.create(i.prototype),n.prototype.cast=function(t,e){var r=new this.caster(t);return r.$parent=e,r},n.prototype.castForQuery=function(t,e){var r;if(2===arguments.length){if(r=this.$conditionalHandlers[t],!r)throw new Error("Can't use "+t);return r.call(this,e)}return e=t,new this.caster(e).toObject({virtuals:!1})},n.prototype.doValidate=function(t,e,r){t.validate(e,{__noPromise:!0})},n.prototype.doValidateSync=function(t,e){return t.validateSync()}},{"../schematype":36,"../types/subdocument":44}],31:[function(t,e,r){r.String=t("./string"),r.Number=t("./number"),r.Boolean=t("./boolean"),r.DocumentArray=t("./documentarray"),r.Embedded=t("./embedded"),r.Array=t("./array"),r.Buffer=t("./buffer"),r.Date=t("./date"),r.ObjectId=t("./objectid"),r.Mixed=t("./mixed"),r.Oid=r.ObjectId,r.Object=r.Mixed,r.Bool=r.Boolean},{"./array":25,"./boolean":26,"./buffer":27,"./date":28,"./documentarray":29,"./embedded":30,"./mixed":32,"./number":33,"./objectid":34,"./string":35}],32:[function(t,e,r){function n(t,e){if(e&&e.default){var r=e.default;Array.isArray(r)&&0===r.length?e.default=Array:!e.shared&&o.isObject(r)&&0===Object.keys(r).length&&(e.default=function(){return{}})}i.call(this,t,e,"Mixed")}var i=t("../schematype"),o=t("../utils");n.schemaName="Mixed",n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.checkRequired=function(t){return void 0!==t&&null!==t},n.prototype.cast=function(t){return t},n.prototype.castForQuery=function(t,e){return 2===arguments.length?e:t},e.exports=n},{"../schematype":36,"../utils":45}],33:[function(t,e,r){(function(r){function n(t,e){a.call(this,t,e,"Number")}function i(t){return this.cast(t)}function o(t){var e=this;return Array.isArray(t)?t.map(function(t){return e.cast(t)}):[this.cast(t)]}var s,a=t("../schematype"),u=a.CastError,c=t("../error").messages,f=t("../utils");n.schemaName="Number",n.prototype=Object.create(a.prototype),n.prototype.constructor=n,n.prototype.checkRequired=function(t,e){return a._isRef(this,t,e,!0)?null!=t:"number"==typeof t||t instanceof Number},n.prototype.min=function(t,e){if(this.minValidator&&(this.validators=this.validators.filter(function(t){return t.validator!=this.minValidator},this)),null!=t){var r=e||c.Number.min;r=r.replace(/{MIN}/,t),this.validators.push({validator:this.minValidator=function(e){return null===e||e>=t},message:r,type:"min",min:t})}return this},n.prototype.max=function(t,e){if(this.maxValidator&&(this.validators=this.validators.filter(function(t){return t.validator!=this.maxValidator},this)),null!=t){var r=e||c.Number.max;r=r.replace(/{MAX}/,t),this.validators.push({validator:this.maxValidator=function(e){return null===e||t>=e},message:r,type:"max",max:t})}return this},n.prototype.cast=function(e,n,i){if(a._isRef(this,e,n,i)){if(null==e)return e;if(s||(s=t("./../document")),e instanceof s)return e.$__.wasPopulated=!0,e;if("number"==typeof e)return e;if(r.isBuffer(e)||!f.isObject(e))throw new u("number",e,this.path);var o=n.$__fullPath(this.path),c=n.ownerDocument?n.ownerDocument():n,h=c.populated(o,!0),l=new h.options.model(e);return l.$__.wasPopulated=!0,l}var p=e&&e._id?e._id:e;if(!isNaN(p)){if(null===p)return p;if(""===p)return null;if("string"==typeof p&&(p=Number(p)),p instanceof Number)return p;if("number"==typeof p)return p;if(p.toString&&!Array.isArray(p)&&p.toString()==Number(p))return new Number(p)}throw new u("number",e,this.path)},n.prototype.$conditionalHandlers=f.options(a.prototype.$conditionalHandlers,{$gt:i,$gte:i,$lt:i,$lte:i,$mod:o}),n.prototype.castForQuery=function(t,e){var r;if(2===arguments.length){if(r=this.$conditionalHandlers[t],!r)throw new Error("Can't use "+t+" with Number.");return r.call(this,e)}return e=this.cast(t),null==e?e:e},e.exports=n}).call(this,t("buffer").Buffer)},{"../error":12,"../schematype":36,"../utils":45,"./../document":5,buffer:49}],34:[function(t,e,r){(function(r){function n(t,e){u.call(this,t,e,"ObjectID")}function i(t){return this.cast(t)}function o(){return new f}function s(t){return this.$__._id=null,t}var a,u=t("../schematype"),c=u.CastError,f=t("../types/objectid"),h=t("../utils");n.schemaName="ObjectId",n.prototype=Object.create(u.prototype),n.prototype.constructor=n,n.prototype.auto=function(t){return t&&(this.default(o),this.set(s)),this},n.prototype.checkRequired=function(t,e){return u._isRef(this,t,e,!0)?null!=t:t instanceof f},n.prototype.cast=function(e,n,i){if(u._isRef(this,e,n,i)){if(null==e)return e;if(a||(a=t("./../document")),e instanceof a)return e.$__.wasPopulated=!0,e;if(e instanceof f)return e;if(r.isBuffer(e)||!h.isObject(e))throw new c("ObjectId",e,this.path);var o=n.$__fullPath(this.path),s=n.ownerDocument?n.ownerDocument():n,l=s.populated(o,!0),p=new l.options.model(e);return p.$__.wasPopulated=!0,p}if(null==e)return e;if(e instanceof f)return e;if(e._id){if(e._id instanceof f)return e._id;if(e._id.toString instanceof Function)try{return f.createFromHexString(e._id.toString())}catch(t){}}if(e.toString instanceof Function)try{return f.createFromHexString(e.toString())}catch(t){throw new c("ObjectId",e,this.path)}throw new c("ObjectId",e,this.path)},n.prototype.$conditionalHandlers=h.options(u.prototype.$conditionalHandlers,{$gt:i,$gte:i,$lt:i,$lte:i}),n.prototype.castForQuery=function(t,e){var r;if(2===arguments.length){if(r=this.$conditionalHandlers[t],!r)throw new Error("Can't use "+t+" with ObjectId.");return r.call(this,e)}return this.cast(t)},e.exports=n}).call(this,t("buffer").Buffer)},{"../schematype":36,"../types/objectid":43,"../utils":45,"./../document":5,buffer:49}],35:[function(t,e,r){(function(r){function n(t,e){this.enumValues=[],this.regExp=null,a.call(this,t,e,"String")}function i(t){return this.castForQuery(t)}function o(t){var e=this;return Array.isArray(t)?t.map(function(t){return e.castForQuery(t)}):[this.castForQuery(t)]}var s,a=t("../schematype"),u=a.CastError,c=t("../error").messages,f=t("../utils");n.schemaName="String",n.prototype=Object.create(a.prototype),n.prototype.constructor=n,n.prototype.enum=function(){if(this.enumValidator&&(this.validators=this.validators.filter(function(t){return t.validator!=this.enumValidator},this),this.enumValidator=!1),void 0===arguments[0]||!1===arguments[0])return this;var t,e;f.isObject(arguments[0])?(t=arguments[0].values,e=arguments[0].message):(t=arguments,e=c.String.enum);for(var r=0;r<t.length;r++)void 0!==t[r]&&this.enumValues.push(this.cast(t[r]));var n=this.enumValues;return this.enumValidator=function(t){return void 0===t||~n.indexOf(t)},this.validators.push({validator:this.enumValidator,message:e,type:"enum",enumValues:n}),this},n.prototype.lowercase=function(){return this.set(function(t,e){return"string"!=typeof t&&(t=e.cast(t)),t?t.toLowerCase():t})},n.prototype.uppercase=function(){return this.set(function(t,e){return"string"!=typeof t&&(t=e.cast(t)),t?t.toUpperCase():t})},n.prototype.trim=function(){return this.set(function(t,e){return"string"!=typeof t&&(t=e.cast(t)),t?t.trim():t})},n.prototype.minlength=function(t,e){if(this.minlengthValidator&&(this.validators=this.validators.filter(function(t){return t.validator!=this.minlengthValidator},this)),null!=t){var r=e||c.String.minlength;r=r.replace(/{MINLENGTH}/,t),this.validators.push({validator:this.minlengthValidator=function(e){return null===e||e.length>=t},message:r,type:"minlength",minlength:t})}return this},n.prototype.maxlength=function(t,e){if(this.maxlengthValidator&&(this.validators=this.validators.filter(function(t){return t.validator!=this.maxlengthValidator},this)),null!=t){var r=e||c.String.maxlength;r=r.replace(/{MAXLENGTH}/,t),this.validators.push({validator:this.maxlengthValidator=function(e){return null===e||e.length<=t},message:r,type:"maxlength",maxlength:t})}return this},n.prototype.match=function(t,e){var r=e||c.String.match,n=function(e){if(!t)return!1;var r=null!=e&&""!==e?t.test(e):!0;return r};return this.validators.push({validator:n,message:r,type:"regexp",regexp:t}),this},n.prototype.checkRequired=function(t,e){return a._isRef(this,t,e,!0)?null!=t:(t instanceof String||"string"==typeof t)&&t.length},n.prototype.cast=function(e,n,i){if(a._isRef(this,e,n,i)){if(null==e)return e;if(s||(s=t("./../document")),e instanceof s)return e.$__.wasPopulated=!0,e;if("string"==typeof e)return e;if(r.isBuffer(e)||!f.isObject(e))throw new u("string",e,this.path);var o=n.$__fullPath(this.path),c=n.ownerDocument?n.ownerDocument():n,h=c.populated(o,!0),l=new h.options.model(e);return l.$__.wasPopulated=!0,l}if(null==e)return e;if("undefined"!=typeof e){if(e._id&&"string"==typeof e._id)return e._id;if(e.toString&&e.toString!==Object.prototype.toString)return e.toString()}throw new u("string",e,this.path)},n.prototype.$conditionalHandlers=f.options(a.prototype.$conditionalHandlers,{$all:o,$gt:i,$gte:i,$lt:i,$lte:i,$options:i,$regex:i}),n.prototype.castForQuery=function(t,e){var r;if(2===arguments.length){if(r=this.$conditionalHandlers[t],!r)throw new Error("Can't use "+t+" with String.");return r.call(this,e)}return e=t,e instanceof RegExp?e:this.cast(e)},e.exports=n}).call(this,t("buffer").Buffer)},{"../error":12,"../schematype":36,"../utils":45,"./../document":5,buffer:49}],36:[function(t,e,r){(function(n){function i(t,e,r){this.path=t,this.instance=r,this.validators=[],this.setters=[],this.getters=[],this.options=e,this._index=null,this.selected;for(var n in e)if(this[n]&&"function"==typeof this[n]){if("index"==n&&this._index)continue;var i=Array.isArray(e[n])?e[n]:[e[n]];this[n].apply(this,i)}}function o(t){return this.castForQuery(t)}function s(t){var e=this;return Array.isArray(t)?t.map(function(t){return e.castForQuery(t)}):[this.castForQuery(t)]}var a=t("./utils"),u=t("./error"),c=u.messages,f=u.CastError,h=u.ValidatorError;i.prototype.default=function(t){return 1===arguments.length?(this.defaultValue="function"==typeof t?t:this.cast(t),this):(arguments.length>1&&(this.defaultValue=a.args(arguments)),this.defaultValue)},i.prototype.index=function(t){return this._index=t,a.expires(this._index),this},i.prototype.unique=function(t){return null==this._index||"boolean"==typeof this._index?this._index={}:"string"==typeof this._index&&(this._index={type:this._index}),this._index.unique=t,this},i.prototype.text=function(t){return null==this._index||"boolean"==typeof this._index?this._index={}:"string"==typeof this._index&&(this._index={type:this._index}),this._index.text=t,this},i.prototype.sparse=function(t){return null==this._index||"boolean"==typeof this._index?this._index={}:"string"==typeof this._index&&(this._index={type:this._index}),this._index.sparse=t,this},i.prototype.set=function(t){if("function"!=typeof t)throw new TypeError("A setter must be a function.");return this.setters.push(t),this},i.prototype.get=function(t){if("function"!=typeof t)throw new TypeError("A getter must be a function.");return this.getters.push(t),this},i.prototype.validate=function(t,e,r){if("function"==typeof t||t&&"RegExp"===a.getFunctionName(t.constructor)){var n;return e instanceof Object&&!r?(n=a.clone(e),n.message||(n.message=n.msg),n.validator=t,n.type=n.type||"user defined"):(e||(e=c.general.default),r||(r="user defined"),n={message:e,type:r,validator:t}),this.validators.push(n),this}var i,o,s;for(i=0,o=arguments.length;o>i;i++){if(s=arguments[i],!s||"Object"!==a.getFunctionName(s.constructor)){var u="Invalid validator. Received ("+typeof s+") "+s+". See http://mongoosejs.com/docs/api.html#schematype_SchemaType-validate";throw new Error(u)}this.validate(s.validator,s)}return this},i.prototype.required=function(t,e){if(!1===t)return this.validators=this.validators.filter(function(t){return t.validator!=this.requiredValidator},this),this.isRequired=!1,this;var r=this;this.isRequired=!0,this.requiredValidator=function(e){return"isSelected"in this&&!this.isSelected(r.path)&&!this.isModified(r.path)?!0:"function"==typeof t&&!t.apply(this)||r.checkRequired(e,this)},"string"==typeof t&&(e=t,t=void 0);var n=e||c.general.required;return this.validators.unshift({validator:this.requiredValidator,message:n,type:"required"}),this},i.prototype.getDefault=function(t,e){var r="function"==typeof this.defaultValue?this.defaultValue.call(t):this.defaultValue;return null!==r&&void 0!==r?this.cast(r,t,e):r},i.prototype.applySetters=function(t,e,r,n){for(var i=t,o=this.setters,s=o.length,a=this.caster;s--;)i=o[s].call(e,i,this);if(Array.isArray(i)&&a&&a.setters){for(var u=[],c=0;c<i.length;c++)u.push(a.applySetters(i[c],e,r,n));i=u}return null===i||void 0===i?i:i=this.cast(i,e,r,n)},i.prototype.applyGetters=function(t,e){var r=t,n=this.getters,i=n.length;if(!i)return r;for(;i--;)r=n[i].call(e,r,this);return r},i.prototype.select=function(t){return this.selected=!!t,this},i.prototype.doValidate=function(t,e,r){var n=!1,i=this.path,o=this.validators.length;if(!o)return e(null);var s=function(t,r){n||(void 0===t||t?--o||e(null):(n=new h(r),e(n)))},u=this;this.validators.forEach(function(e){if(!n){var o=e.validator,c=a.clone(e);if(c.path=i,c.value=t,o instanceof RegExp)s(o.test(t),c);else if("function"==typeof o){
3
- if(void 0===t&&!u.isRequired)return void s(!0,c);2===o.length?o.call(r,t,function(t){s(t,c)}):s(o.call(r,t),c)}}})},i.prototype.doValidateSync=function(t,e){var r=null,n=this.path,i=this.validators.length;if(!i)return null;var o=function(t,e){r||void 0===t||t||(r=new h(e))},s=this;return void 0!==t||s.isRequired?(this.validators.forEach(function(i){if(!r){var s=i.validator,u=a.clone(i);u.path=n,u.value=t,s instanceof RegExp?o(s.test(t),u):"function"==typeof s&&2!==s.length&&o(s.call(e,t),u)}}),r):null},i._isRef=function(t,e,r,i){var o=i&&t.options&&t.options.ref;if(!o&&r&&r.$__fullPath){var s=r.$__fullPath(t.path),u=r.ownerDocument?r.ownerDocument():r;o=u.populated(s)}if(o){if(null==e)return!0;if(!n.isBuffer(e)&&"Binary"!=e._bsontype&&a.isObject(e))return!0}return!1},i.prototype.$conditionalHandlers={$all:s,$eq:o,$in:s,$ne:o,$nin:s},i.prototype.castForQuery=function(t,e){var r;if(2===arguments.length){if(r=this.$conditionalHandlers[t],!r)throw new Error("Can't use "+t);return r.call(this,e)}return e=t,this.cast(e)},e.exports=r=i,r.CastError=f,r.ValidatorError=h}).call(this,t("buffer").Buffer)},{"./error":12,"./utils":45,buffer:49}],37:[function(t,e,r){var n=t("./utils"),i=e.exports=r=function(){};i.ctor=function(){var t=n.args(arguments),e=function(){i.apply(this,arguments),this.paths={},this.states={},this.stateNames=t;for(var e,r=t.length;r--;)e=t[r],this.states[e]={}};return e.prototype=new i,t.forEach(function(t){e.prototype[t]=function(e){this._changeState(e,t)}}),e},i.prototype._changeState=function(t,e){var r=this.states[this.paths[t]];r&&delete r[t],this.paths[t]=e,this.states[e][t]=!0},i.prototype.clear=function(t){for(var e,r=Object.keys(this.states[t]),n=r.length;n--;)e=r[n],delete this.states[t][e],delete this.paths[e]},i.prototype.some=function(){var t=this,e=arguments.length?arguments:this.stateNames;return Array.prototype.some.call(e,function(e){return Object.keys(t.states[e]).length})},i.prototype._iter=function(t){return function(){var e=arguments.length,r=n.args(arguments,0,e-1),i=arguments[e-1];r.length||(r=this.stateNames);var o=this,s=r.reduce(function(t,e){return t.concat(Object.keys(o.states[e]))},[]);return s[t](function(t,e,r){return i(t,e,r)})}},i.prototype.forEach=function(){return this.forEach=this._iter("forEach"),this.forEach.apply(this,arguments)},i.prototype.map=function(){return this.map=this._iter("map"),this.map.apply(this,arguments)}},{"./utils":45}],38:[function(t,e,r){(function(n){function i(t,e,r){var n=[].concat(t);return u.decorate(n,i.mixin),n.isMongooseArray=!0,n._atomics={},n.validators=[],n._path=e,r&&r instanceof s&&(n._parent=r,n._schema=r.schema.path(e)),n}var o=t("./embedded"),s=t("../document"),a=t("./objectid"),u=t("../utils"),c=u.isMongooseObject;i.mixin={_atomics:void 0,_parent:void 0,_cast:function(t){var e,r=this._owner,i=!1;if(this._parent&&(r||(r=this._owner=this._parent.ownerDocument?this._parent.ownerDocument():this._parent),i=r.populated(this._path,!0)),i&&null!=t){e=i.options.model,(n.isBuffer(t)||t instanceof a||!u.isObject(t))&&(t={_id:t});var o=t.schema&&t.schema.discriminatorMapping&&void 0!==t.schema.discriminatorMapping.key;return o||(t=new e(t)),this._schema.caster.cast(t,this._parent,!0)}return this._schema.caster.cast(t,this._parent,!1)},_markModified:function(t,e){var r,n=this._parent;return n&&(r=this._path,arguments.length&&(r=null!=e?r+"."+this.indexOf(t)+"."+e:r+"."+t),n.markModified(r)),this},_registerAtomic:function(t,e){if("$set"==t)return this._atomics={$set:e},this;var r=this._atomics;if("$pop"==t&&!("$pop"in r)){var n=this;this._parent.once("save",function(){n._popped=n._shifted=null})}if(this._atomics.$set||Object.keys(r).length&&!(t in r))return this._atomics={$set:this},this;var i;if("$pullAll"===t||"$pushAll"===t||"$addToSet"===t)r[t]||(r[t]=[]),r[t]=r[t].concat(e);else if("$pullDocs"===t){var s=r.$pull||(r.$pull={});e[0]instanceof o?(i=s.$or||(s.$or=[]),Array.prototype.push.apply(i,e.map(function(t){return t.toObject({virtuals:!1})}))):(i=s._id||(s._id={$in:[]}),i.$in=i.$in.concat(e))}else r[t]=e;return this},$__getAtomics:function(){var t=[],e=Object.keys(this._atomics),r=e.length;if(0===r)return t[0]=["$set",this.toObject({depopulate:1,transform:!1})],t;for(;r--;){var n=e[r],i=this._atomics[n];c(i)?i=i.toObject({depopulate:1,transform:!1}):Array.isArray(i)?i=this.toObject.call(i,{depopulate:1,transform:!1}):i.valueOf&&(i=i.valueOf()),"$addToSet"==n&&(i={$each:i}),t.push([n,i])}return t},hasAtomics:function(){return this._atomics&&"Object"===this._atomics.constructor.name?Object.keys(this._atomics).length:0},_mapCast:function(t,e){return this._cast(t,this.length+e)},push:function(){var t=[].map.call(arguments,this._mapCast,this);t=this._schema.applySetters(t,this._parent);var e=[].push.apply(this,t);return this._registerAtomic("$pushAll",t),this._markModified(),e},nonAtomicPush:function(){var t=[].map.call(arguments,this._mapCast,this),e=[].push.apply(this,t);return this._registerAtomic("$set",this),this._markModified(),e},$pop:function(){return this._registerAtomic("$pop",1),this._markModified(),this._popped?void 0:(this._popped=!0,[].pop.call(this))},pop:function(){var t=[].pop.call(this);return this._registerAtomic("$set",this),this._markModified(),t},$shift:function(){return this._registerAtomic("$pop",-1),this._markModified(),this._shifted?void 0:(this._shifted=!0,[].shift.call(this))},shift:function(){var t=[].shift.call(this);return this._registerAtomic("$set",this),this._markModified(),t},pull:function(){for(var t,e=[].map.call(arguments,this._cast,this),r=this._parent.get(this._path),n=r.length;n--;)t=r[n],t instanceof o?e.some(function(e){return e.equals(t)})&&[].splice.call(r,n,1):~r.indexOf.call(e,t)&&[].splice.call(r,n,1);return e[0]instanceof o?this._registerAtomic("$pullDocs",e.map(function(t){return t._id||t})):this._registerAtomic("$pullAll",e),this._markModified(),this},splice:function(){var t,e,r;if(arguments.length){for(e=[],r=0;r<arguments.length;++r)e[r]=2>r?arguments[r]:this._cast(arguments[r],arguments[0]+(r-2));t=[].splice.apply(this,e),this._registerAtomic("$set",this),this._markModified()}return t},unshift:function(){var t=[].map.call(arguments,this._cast,this);return t=this._schema.applySetters(t,this._parent),[].unshift.apply(this,t),this._registerAtomic("$set",this),this._markModified(),this.length},sort:function(){var t=[].sort.apply(this,arguments);return this._registerAtomic("$set",this),this._markModified(),t},addToSet:function(){var t=[].map.call(arguments,this._mapCast,this);t=this._schema.applySetters(t,this._parent);var e=[],r=t[0]instanceof o?"doc":t[0]instanceof Date?"date":"";return t.forEach(function(t){var n;switch(r){case"doc":n=this.some(function(e){return e.equals(t)});break;case"date":var i=+t;n=this.some(function(t){return+t===i});break;default:n=~this.indexOf(t)}n||([].push.call(this,t),this._registerAtomic("$addToSet",t),this._markModified(),[].push.call(e,t))},this),e},set:function(t,e){var r=this._cast(e,t);return r=this._schema.caster instanceof o?r:this._schema.caster.applySetters(e,this._parent),this[t]=r,this._markModified(t),this},toObject:function(t){return t&&t.depopulate?this.map(function(e){return e instanceof s?e.toObject(t):e}):this.slice()},inspect:function(){return JSON.stringify(this)},indexOf:function(t){t instanceof a&&(t=t.toString());for(var e=0,r=this.length;r>e;++e)if(t==this[e])return e;return-1}},i.mixin.remove=i.mixin.pull,e.exports=r=i}).call(this,t("buffer").Buffer)},{"../document":5,"../utils":45,"./embedded":41,"./objectid":43,buffer:49}],39:[function(t,e,r){(function(r){function n(t,e,i){var s,a=arguments.length;s=0===a||null===arguments[0]||void 0===arguments[0]?0:t;var u,c,f;Array.isArray(e)?(c=e[0],f=e[1]):u=e;var h=new r(s,u,i);return o.decorate(h,n.mixin),h.isMongooseBuffer=!0,Object.defineProperties(h,{validators:{value:[]},_path:{value:c},_parent:{value:f}}),f&&"string"==typeof c&&Object.defineProperty(h,"_schema",{value:f.schema.path(c)}),h._subtype=0,h}var i=t("../drivers").Binary,o=t("../utils");n.mixin={_parent:void 0,_subtype:void 0,_markModified:function(){var t=this._parent;return t&&t.markModified(this._path),this},write:function(){var t=r.prototype.write.apply(this,arguments);return t>0&&this._markModified(),t},copy:function(t){var e=r.prototype.copy.apply(this,arguments);return t&&t.isMongooseBuffer&&t._markModified(),e}},"writeUInt8 writeUInt16 writeUInt32 writeInt8 writeInt16 writeInt32 writeFloat writeDouble fill utf8Write binaryWrite asciiWrite set writeUInt16LE writeUInt16BE writeUInt32LE writeUInt32BE writeInt16LE writeInt16BE writeInt32LE writeInt32BE writeFloatLE writeFloatBE writeDoubleLE writeDoubleBE".split(" ").forEach(function(t){r.prototype[t]&&(n.mixin[t]=new Function("var ret = Buffer.prototype."+t+".apply(this, arguments);this._markModified();return ret;"))}),n.mixin.toObject=function(t){var e="number"==typeof t?t:this._subtype||0;return new i(this,e)},n.mixin.equals=function(t){if(!r.isBuffer(t))return!1;if(this.length!==t.length)return!1;for(var e=0;e<this.length;++e)if(this[e]!==t[e])return!1;return!0},n.mixin.subtype=function(t){if("number"!=typeof t)throw new TypeError("Invalid subtype. Expected a number");this._subtype!=t&&this._markModified(),this._subtype=t},n.Binary=i,e.exports=n}).call(this,t("buffer").Buffer)},{"../drivers":11,"../utils":45,buffer:49}],40:[function(t,e,r){(function(r){function n(t,e,r){var i=[].concat(t);return a.decorate(i,n.mixin),i.isMongooseArray=!0,i.isMongooseDocumentArray=!0,i._atomics={},i.validators=[],i._path=e,r&&r instanceof c&&(i._parent=r,i._schema=r.schema.path(e),i._handlers={isNew:i.notify("isNew"),save:i.notify("save")},r.on("save",i._handlers.save),r.on("isNew",i._handlers.isNew)),i}var i=t("./array"),o=t("./objectid"),s=t("../schema/objectid"),a=t("../utils"),u=t("util"),c=t("../document");n.mixin=Object.create(i.mixin),n.mixin._cast=function(t,e){return t instanceof this._schema.casterConstructor?(t.__parent&&t.__parentArray||(t.__parent=this._parent,t.__parentArray=this),t.__index=e,t):((r.isBuffer(t)||t instanceof o||!a.isObject(t))&&(t={_id:t}),new this._schema.casterConstructor(t,this,void 0,void 0,e))},n.mixin.id=function(t){var e,r,n;try{var i=s.prototype.cast.call({},t);i&&(e=String(i))}catch(t){e=null}for(var u=0,f=this.length;f>u;u++)if(n=this[u].get("_id"),null!==n&&"undefined"!=typeof n)if(n instanceof c){if(r||(r=String(t)),r==n._id)return this[u]}else if(n instanceof o){if(e==n)return this[u]}else if(a.deepEqual(t,n))return this[u];return null},n.mixin.toObject=function(t){return this.map(function(e){return e&&e.toObject(t)||null})},n.mixin.inspect=function(){return"["+Array.prototype.map.call(this,function(t){return t?t.inspect?t.inspect():u.inspect(t):"null"}).join("\n")+"]"},n.mixin.create=function(t){return new this._schema.casterConstructor(t)},n.mixin.notify=function(t){var e=this;return function(r){for(var n=e.length;n--;)if(e[n]){switch(t){case"save":r=e[n]}e[n].emit(t,r)}}},e.exports=n}).call(this,t("buffer").Buffer)},{"../document":5,"../schema/objectid":34,"../utils":45,"./array":38,"./objectid":43,buffer:49,util:57}],41:[function(t,e,r){function n(t,e,r,n,i){e?(this.__parentArray=e,this.__parent=e._parent):(this.__parentArray=void 0,this.__parent=void 0),this.__index=i,o.call(this,t,n,r);var s=this;this.on("isNew",function(t){s.isNew=t})}function i(t){function e(){r.removeListener("save",e),r.removeListener("remove",e),t.emit("remove",t),r=t=e=null}var r=t.ownerDocument();r.on("save",e),r.on("remove",e)}var o=t("../document_provider")(),s=t("util").inspect,a=t("../promise_provider");n.prototype=Object.create(o.prototype),n.prototype.constructor=n,n.prototype.markModified=function(t){this.__parentArray&&(this.$__.activePaths.modify(t),this.isNew?this.__parentArray._markModified():this.__parentArray._markModified(this,t))},n.prototype.save=function(t){var e=a.get();return new e.ES6(function(e){t&&t(),e()})},n.prototype.remove=function(t){if(!this.__parentArray)return this;var e;if(!this.willRemove){if(e=this._doc._id,!e)throw new Error("For your own good, Mongoose does not know how to remove an EmbeddedDocument that has no _id");this.__parentArray.pull({_id:e}),this.willRemove=!0,i(this)}return t&&t(null),this},n.prototype.update=function(){throw new Error("The #update method is not available on EmbeddedDocuments")},n.prototype.inspect=function(){return s(this.toObject())},n.prototype.invalidate=function(t,e,r,n){if(!this.__parent){var i="Unable to invalidate a subdocument that has not been added to an array.";throw new Error(i)}var o=this.__index;if("undefined"!=typeof o){var s=this.__parentArray._path,a=[s,o,t].join(".");this.__parent.invalidate(a,e,r)}return n&&(this.$__.validationError=this.ownerDocument().$__.validationError),!0},n.prototype.$markValid=function(t){if(this.__parent){var e=this.__index;if("undefined"!=typeof e){var r=this.__parentArray._path,n=[r,e,t].join(".");this.__parent.$markValid(n)}}},n.prototype.$isValid=function(t){var e=this.__index;return"undefined"!=typeof e?!this.__parent.$__.validationError||!this.__parent.$__.validationError.errors[t]:!0},n.prototype.ownerDocument=function(){if(this.$__.ownerDocument)return this.$__.ownerDocument;var t=this.__parent;if(!t)return this;for(;t.__parent;)t=t.__parent;return this.$__.ownerDocument=t},n.prototype.$__fullPath=function(t){if(!this.$__.fullPath){var e=this;if(!e.__parent)return t;for(var r=[];e.__parent;)r.unshift(e.__parentArray._path),e=e.__parent;this.$__.fullPath=r.join("."),this.$__.ownerDocument||(this.$__.ownerDocument=e)}return t?this.$__.fullPath+"."+t:this.$__.fullPath},n.prototype.parent=function(){return this.__parent},n.prototype.parentArray=function(){return this.__parentArray},e.exports=n},{"../document_provider":6,"../promise_provider":23,util:57}],42:[function(t,e,r){r.Array=t("./array"),r.Buffer=t("./buffer"),r.Document=r.Embedded=t("./embedded"),r.DocumentArray=t("./documentarray"),r.ObjectId=t("./objectid"),r.Subdocument=t("./subdocument")},{"./array":38,"./buffer":39,"./documentarray":40,"./embedded":41,"./objectid":43,"./subdocument":44}],43:[function(t,e,r){var n=t("../drivers").ObjectId;e.exports=n},{"../drivers":11}],44:[function(t,e,r){function n(){i.apply(this,arguments),this.$isSingleNested=!0}var i=t("../document"),o=t("../promise_provider");e.exports=n,n.prototype=Object.create(i.prototype),n.prototype.save=function(t){var e=o.get();return new e.ES6(function(e){t&&t(),e()})},n.prototype.$isValid=function(t){return this.$parent?this.$parent.$isValid([this.$basePath,t].join(".")):void 0},n.prototype.markModified=function(t){this.$parent&&this.$parent.markModified([this.$basePath,t].join("."))},n.prototype.$markValid=function(t){this.$parent&&this.$parent.$markValid([this.$basePath,t].join("."))},n.prototype.invalidate=function(t,e,r){this.$parent&&this.$parent.invalidate([this.$basePath,t].join("."),e,r)}},{"../document":5,"../promise_provider":23}],45:[function(t,e,r){(function(e,n){function i(t){var e;return!~v.indexOf(t.toLowerCase())&&(e=y.filter(function(e){return t.match(e[0])}),e[0])?t.replace(e[0][0],e[0][1]):t}function o(t,e){var r,n,i,o,s,a=e&&e.retainKeyOrder,u=e&&e.minimize,c={};if(a)for(o in t)i=g(t[o],e),u&&"undefined"==typeof i||(r||(r=!0),c[o]=i);else for(n=Object.keys(t),s=n.length;s--;)o=n[s],i=g(t[o],e),u&&"undefined"==typeof i||(r||(r=!0),c[o]=i);return u?r&&c:c}function s(t,e){for(var r=[],n=0,i=t.length;i>n;n++)r.push(g(t[n],e));return r}function a(t,e,r,n,i,o){this.path=t,this.match=r,this.select=e,this.options=n,this.model=i,"object"==typeof o&&(this.populate=o),this._docs={}}var u,c,f,h=t("./types/objectid"),l=t("regexp-clone"),p=t("sliced"),d=t("mpath"),_=t("ms");r.toCollectionName=function(t,e){return e=e||{},"system.profile"===t?t:"system.indexes"===t?t:e.pluralization===!1?t:i(t.toLowerCase())},r.pluralization=[[/(m)an$/gi,"$1en"],[/(pe)rson$/gi,"$1ople"],[/(child)$/gi,"$1ren"],[/^(ox)$/gi,"$1en"],[/(ax|test)is$/gi,"$1es"],[/(octop|vir)us$/gi,"$1i"],[/(alias|status)$/gi,"$1es"],[/(bu)s$/gi,"$1ses"],[/(buffal|tomat|potat)o$/gi,"$1oes"],[/([ti])um$/gi,"$1a"],[/sis$/gi,"ses"],[/(?:([^f])fe|([lr])f)$/gi,"$1$2ves"],[/(hive)$/gi,"$1s"],[/([^aeiouy]|qu)y$/gi,"$1ies"],[/(x|ch|ss|sh)$/gi,"$1es"],[/(matr|vert|ind)ix|ex$/gi,"$1ices"],[/([m|l])ouse$/gi,"$1ice"],[/(kn|w|l)ife$/gi,"$1ives"],[/(quiz)$/gi,"$1zes"],[/s$/gi,"s"],[/([^a-z])$/,"$1"],[/$/gi,"s"]];var y=r.pluralization;r.uncountables=["advice","energy","excretion","digestion","cooperation","health","justice","labour","machinery","equipment","information","pollution","sewage","paper","money","species","series","rain","rice","fish","sheep","moose","deer","news","expertise","status","media"];var v=r.uncountables;r.deepEqual=function t(e,i){if(e===i)return!0;if(e instanceof Date&&i instanceof Date)return e.getTime()===i.getTime();if(e instanceof h&&i instanceof h)return e.toString()===i.toString();if(e instanceof RegExp&&i instanceof RegExp)return e.source==i.source&&e.ignoreCase==i.ignoreCase&&e.multiline==i.multiline&&e.global==i.global;if("object"!=typeof e&&"object"!=typeof i)return e==i;if(null===e||null===i||void 0===e||void 0===i)return!1;if(e.prototype!==i.prototype)return!1;if(e instanceof Number&&i instanceof Number)return e.valueOf()===i.valueOf();if(n.isBuffer(e))return r.buffer.areEqual(e,i);b(e)&&(e=e.toObject()),b(i)&&(i=i.toObject());try{var o,s,a=Object.keys(e),u=Object.keys(i)}catch(t){return!1}if(a.length!=u.length)return!1;for(a.sort(),u.sort(),s=a.length-1;s>=0;s--)if(a[s]!=u[s])return!1;for(s=a.length-1;s>=0;s--)if(o=a[s],!t(e[o],i[o]))return!1;return!0},r.clone=function(t,e){if(void 0===t||null===t)return t;if(Array.isArray(t))return s(t,e);if(b(t))return e&&e.json&&"function"==typeof t.toJSON?t.toJSON(e):t.toObject(e);if(t.constructor)switch(r.getFunctionName(t.constructor)){case"Object":return o(t,e);case"Date":return new t.constructor(+t);case"RegExp":return l(t)}return t instanceof h?new h(t.id):!t.constructor&&r.isObject(t)?o(t,e):t.valueOf?t.valueOf():void 0};var g=r.clone;r.options=function(t,e){var r,n=Object.keys(t),i=n.length;for(e=e||{};i--;)r=n[i],r in e||(e[r]=t[r]);return e},r.random=function(){return Math.random().toString().substr(3)},r.merge=function t(e,n){for(var i,o=Object.keys(n),s=o.length;s--;)i=o[s],"undefined"==typeof e[i]?e[i]=n[i]:r.isObject(n[i])&&t(e[i],n[i])};var m=Object.prototype.toString;r.toObject=function t(e){var n;if(r.isNullOrUndefined(e))return e;if(e instanceof f)return e.toObject();if(Array.isArray(e)){n=[];for(var i=0,o=e.length;o>i;++i)n.push(t(e[i]));return n}if(e.constructor&&"Object"===r.getFunctionName(e.constructor)||!e.constructor&&r.isObject(e)){n={};for(var s in e)n[s]=t(e[s]);return n}return e},r.isObject=function(t){return"[object Object]"==m.call(t)},r.args=p,r.tick=function(t){return"function"==typeof t?function(){try{t.apply(this,arguments)}catch(t){e.nextTick(function(){throw t})}}:void 0},r.isMongooseObject=function(e){return f||(f=t("./document")),c||(c=t("./types").Array),u||(u=t("./types").Buffer),e instanceof f||e&&e.isMongooseArray||e&&e.isMongooseBuffer};var b=r.isMongooseObject;r.expires=function(t){if(t&&"Object"==t.constructor.name&&"expires"in t){var e;e="string"!=typeof t.expires?t.expires:Math.round(_(t.expires)/1e3),t.expireAfterSeconds=e,delete t.expires}},a.prototype.constructor=Object,r.PopulateOptions=a,r.populate=function(t,e,n,i,o,s){if(1===arguments.length){if(t instanceof a)return[t];if(Array.isArray(t))return t.map(function(t){return r.populate(t)[0]});r.isObject(t)&&(i=t.match,o=t.options,e=t.select,n=t.model,s=t.populate,t=t.path)}else"string"!=typeof n&&"function"!=typeof n&&(o=i,i=n,n=void 0);if("string"!=typeof t)throw new TypeError("utils.populate: invalid path. Expected string. Got typeof `"+typeof t+"`");"object"==typeof s&&(s=r.populate(s));for(var u=[],c=t.split(" "),f=0;f<c.length;++f)u.push(new a(c[f],e,i,o,n,s));return u},r.getValue=function(t,e,r){return d.get(t,e,"_doc",r)},r.setValue=function(t,e,r,n){d.set(t,e,r,"_doc",n)},r.object={},r.object.vals=function(t){for(var e=Object.keys(t),r=e.length,n=[];r--;)n.push(t[e[r]]);return n},r.object.shallowCopy=r.options;var w=Object.prototype.hasOwnProperty;r.object.hasOwnProperty=function(t,e){return w.call(t,e)},r.isNullOrUndefined=function(t){return null==t},r.array={},r.array.flatten=function t(e,r,n){return n||(n=[]),e.forEach(function(e){Array.isArray(e)?t(e,r,n):(!r||r(e))&&n.push(e)}),n},r.array.unique=function(t){for(var e={},r={},n=[],i=t.length,o=0;i>o;++o)if("number"==typeof t[o]||"string"==typeof t[o]){if(e[t[o]])continue;n.push(t[o]),e[t[o]]=!0}else if(t[o]instanceof h){if(r[t[o].toString()])continue;n.push(t[o]),r[t[o].toString()]=!0}else n.push(t[o]);return n},r.buffer={},r.buffer.areEqual=function(t,e){if(!n.isBuffer(t))return!1;if(!n.isBuffer(e))return!1;if(t.length!==e.length)return!1;for(var r=0,i=t.length;i>r;++r)if(t[r]!==e[r])return!1;return!0},r.getFunctionName=function(t){return t.name?t.name:(t.toString().trim().match(/^function\s*([^\s(]+)/)||[])[1]},r.decorate=function(t,e){for(var r in e)t[r]=e[r]},r.mergeClone=function(t,e){for(var n,i=Object.keys(e),o=i.length;o--;)n=i[o],"undefined"==typeof t[n]?t[n]=r.clone(e[n],{retainKeyOrder:1}):r.isObject(e[n])?r.mergeClone(t[n],e[n]):t[n]=r.clone(e[n],{retainKeyOrder:1})},r.each=function(t,e){for(var r=0;r<t.length;++r)e(t[r])}}).call(this,t("FWaASH"),t("buffer").Buffer)},{"./document":5,"./types":42,"./types/objectid":43,FWaASH:55,buffer:49,mpath:78,ms:92,"regexp-clone":93,sliced:94}],46:[function(t,e,r){function n(t,e){this.path=e,this.getters=[],this.setters=[],this.options=t||{}}n.prototype.get=function(t){return this.getters.push(t),this},n.prototype.set=function(t){return this.setters.push(t),this},n.prototype.applyGetters=function(t,e){for(var r=t,n=this.getters.length-1;n>=0;n--)r=this.getters[n].call(e,r,this);return r},n.prototype.applySetters=function(t,e){for(var r=t,n=this.setters.length-1;n>=0;n--)r=this.setters[n].call(e,r,this);return r},e.exports=n},{}],47:[function(t,e,r){(function(t){!function(){function r(t){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,t.apply(n,arguments)}}var n,i,o={};n=this,null!=n&&(i=n.async),o.noConflict=function(){return n.async=i,o};var s=Object.prototype.toString,a=Array.isArray||function(t){return"[object Array]"===s.call(t)},u=function(t,e){if(t.forEach)return t.forEach(e);for(var r=0;r<t.length;r+=1)e(t[r],r,t)},c=function(t,e){if(t.map)return t.map(e);var r=[];return u(t,function(t,n,i){r.push(e(t,n,i))}),r},f=function(t,e,r){return t.reduce?t.reduce(e,r):(u(t,function(t,n,i){r=e(r,t,n,i)}),r)},h=function(t){if(Object.keys)return Object.keys(t);var e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(r);return e};"undefined"!=typeof t&&t.nextTick?(o.nextTick=t.nextTick,"undefined"!=typeof setImmediate?o.setImmediate=function(t){setImmediate(t)}:o.setImmediate=o.nextTick):"function"==typeof setImmediate?(o.nextTick=function(t){setImmediate(t)},o.setImmediate=o.nextTick):(o.nextTick=function(t){setTimeout(t,0)},o.setImmediate=o.nextTick),o.each=function(t,e,n){function i(e){e?(n(e),n=function(){}):(o+=1,o>=t.length&&n())}if(n=n||function(){},!t.length)return n();var o=0;u(t,function(t){e(t,r(i))})},o.forEach=o.each,o.eachSeries=function(t,e,r){if(r=r||function(){},!t.length)return r();var n=0,i=function(){e(t[n],function(e){e?(r(e),r=function(){}):(n+=1,n>=t.length?r():i())})};i()},o.forEachSeries=o.eachSeries,o.eachLimit=function(t,e,r,n){var i=l(e);i.apply(null,[t,r,n])},o.forEachLimit=o.eachLimit;var l=function(t){return function(e,r,n){if(n=n||function(){},!e.length||0>=t)return n();var i=0,o=0,s=0;!function a(){if(i>=e.length)return n();for(;t>s&&o<e.length;)o+=1,s+=1,r(e[o-1],function(t){t?(n(t),n=function(){}):(i+=1,s-=1,i>=e.length?n():a())})}()}},p=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.each].concat(e))}},d=function(t,e){return function(){var r=Array.prototype.slice.call(arguments);return e.apply(null,[l(t)].concat(r))}},_=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.eachSeries].concat(e))}},y=function(t,e,r,n){if(e=c(e,function(t,e){return{index:e,value:t}}),n){var i=[];t(e,function(t,e){r(t.value,function(r,n){i[t.index]=n,e(r)})},function(t){n(t,i)})}else t(e,function(t,e){r(t.value,function(t){e(t)})})};o.map=p(y),o.mapSeries=_(y),o.mapLimit=function(t,e,r,n){return v(e)(t,r,n)};var v=function(t){return d(t,y)};o.reduce=function(t,e,r,n){o.eachSeries(t,function(t,n){r(e,t,function(t,r){e=r,n(t)})},function(t){n(t,e)})},o.inject=o.reduce,o.foldl=o.reduce,o.reduceRight=function(t,e,r,n){var i=c(t,function(t){return t}).reverse();o.reduce(i,e,r,n)},o.foldr=o.reduceRight;var g=function(t,e,r,n){var i=[];e=c(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){r(t.value,function(r){r&&i.push(t),e()})},function(t){n(c(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.filter=p(g),o.filterSeries=_(g),o.select=o.filter,o.selectSeries=o.filterSeries;var m=function(t,e,r,n){var i=[];e=c(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){r(t.value,function(r){r||i.push(t),e()})},function(t){n(c(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.reject=p(m),o.rejectSeries=_(m);var b=function(t,e,r,n){t(e,function(t,e){r(t,function(r){r?(n(t),n=function(){}):e()})},function(t){n()})};o.detect=p(b),o.detectSeries=_(b),o.some=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t&&(r(!0),r=function(){}),n()})},function(t){r(!1)})},o.any=o.some,o.every=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t||(r(!1),r=function(){}),n()})},function(t){r(!0)})},o.all=o.every,o.sortBy=function(t,e,r){o.map(t,function(t,r){e(t,function(e,n){e?r(e):r(null,{value:t,criteria:n})})},function(t,e){if(t)return r(t);var n=function(t,e){var r=t.criteria,n=e.criteria;return n>r?-1:r>n?1:0};r(null,c(e.sort(n),function(t){return t.value}))})},o.auto=function(t,e){e=e||function(){};var r=h(t),n=r.length;if(!n)return e();var i={},s=[],c=function(t){s.unshift(t)},l=function(t){for(var e=0;e<s.length;e+=1)if(s[e]===t)return void s.splice(e,1)},p=function(){n--,u(s.slice(0),function(t){t()})};c(function(){if(!n){var t=e;e=function(){},t(null,i)}}),u(r,function(r){var n=a(t[r])?t[r]:[t[r]],s=function(t){var n=Array.prototype.slice.call(arguments,1);if(n.length<=1&&(n=n[0]),t){var s={};u(h(i),function(t){s[t]=i[t]}),s[r]=n,e(t,s),e=function(){}}else i[r]=n,o.setImmediate(p)},d=n.slice(0,Math.abs(n.length-1))||[],_=function(){return f(d,function(t,e){return t&&i.hasOwnProperty(e)},!0)&&!i.hasOwnProperty(r)};if(_())n[n.length-1](s,i);else{var y=function(){_()&&(l(y),n[n.length-1](s,i))};c(y)}})},o.retry=function(t,e,r){var n=5,i=[];"function"==typeof t&&(r=e,e=t,t=n),t=parseInt(t,10)||n;var s=function(n,s){for(var a=function(t,e){return function(r){t(function(t,n){r(!t||e,{err:t,result:n})},s)}};t;)i.push(a(e,!(t-=1)));o.series(i,function(t,e){e=e[e.length-1],(n||r)(e.err,e.result)})};return r?s():s},o.waterfall=function(t,e){if(e=e||function(){},!a(t)){var r=new Error("First argument to waterfall must be an array of functions");return e(r)}if(!t.length)return e();var n=function(t){return function(r){if(r)e.apply(null,arguments),e=function(){};else{var i=Array.prototype.slice.call(arguments,1),s=t.next();s?i.push(n(s)):i.push(e),o.setImmediate(function(){t.apply(null,i)})}}};n(o.iterator(t))()};var w=function(t,e,r){if(r=r||function(){},a(e))t.map(e,function(t,e){t&&t(function(t){var r=Array.prototype.slice.call(arguments,1);r.length<=1&&(r=r[0]),e.call(null,t,r)})},r);else{var n={};t.each(h(e),function(t,r){e[t](function(e){var i=Array.prototype.slice.call(arguments,1);i.length<=1&&(i=i[0]),n[t]=i,r(e)})},function(t){r(t,n)})}};o.parallel=function(t,e){w({map:o.map,each:o.each},t,e)},o.parallelLimit=function(t,e,r){w({map:v(e),each:l(e)},t,r)},o.series=function(t,e){if(e=e||function(){},a(t))o.mapSeries(t,function(t,e){t&&t(function(t){var r=Array.prototype.slice.call(arguments,1);r.length<=1&&(r=r[0]),e.call(null,t,r)})},e);else{var r={};o.eachSeries(h(t),function(e,n){t[e](function(t){var i=Array.prototype.slice.call(arguments,1);i.length<=1&&(i=i[0]),r[e]=i,n(t)})},function(t){e(t,r)})}},o.iterator=function(t){var e=function(r){var n=function(){return t.length&&t[r].apply(null,arguments),n.next()};return n.next=function(){return r<t.length-1?e(r+1):null},n};return e(0)},o.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 E=function(t,e,r,n){var i=[];t(e,function(t,e){r(t,function(t,r){i=i.concat(r||[]),e(t)})},function(t){n(t,i)})};o.concat=p(E),o.concatSeries=_(E),o.whilst=function(t,e,r){t()?e(function(n){return n?r(n):void o.whilst(t,e,r)}):r()},o.doWhilst=function(t,e,r){t(function(n){if(n)return r(n);var i=Array.prototype.slice.call(arguments,1);e.apply(null,i)?o.doWhilst(t,e,r):r()})},o.until=function(t,e,r){t()?r():e(function(n){return n?r(n):void o.until(t,e,r)})},o.doUntil=function(t,e,r){t(function(n){if(n)return r(n);var i=Array.prototype.slice.call(arguments,1);e.apply(null,i)?r():o.doUntil(t,e,r)})},o.queue=function(t,e){function n(t,e,r,n){return t.started||(t.started=!0),a(e)||(e=[e]),0==e.length?o.setImmediate(function(){t.drain&&t.drain()}):void u(e,function(e){var i={data:e,callback:"function"==typeof n?n:null};r?t.tasks.unshift(i):t.tasks.push(i),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),o.setImmediate(t.process)})}void 0===e&&(e=1);var i=0,s={tasks:[],concurrency:e,saturated:null,empty:null,drain:null,started:!1,paused:!1,push:function(t,e){n(s,t,!1,e)},kill:function(){s.drain=null,s.tasks=[]},unshift:function(t,e){n(s,t,!0,e)},process:function(){if(!s.paused&&i<s.concurrency&&s.tasks.length){var e=s.tasks.shift();s.empty&&0===s.tasks.length&&s.empty(),i+=1;var n=function(){i-=1,e.callback&&e.callback.apply(e,arguments),s.drain&&s.tasks.length+i===0&&s.drain(),s.process()},o=r(n);t(e.data,o)}},length:function(){return s.tasks.length},running:function(){return i},idle:function(){return s.tasks.length+i===0},pause:function(){s.paused!==!0&&(s.paused=!0,s.process())},resume:function(){s.paused!==!1&&(s.paused=!1,s.process())}};return s},o.priorityQueue=function(t,e){function r(t,e){return t.priority-e.priority}function n(t,e,r){for(var n=-1,i=t.length-1;i>n;){var o=n+(i-n+1>>>1);r(e,t[o])>=0?n=o:i=o-1}return n}function i(t,e,i,s){return t.started||(t.started=!0),a(e)||(e=[e]),0==e.length?o.setImmediate(function(){t.drain&&t.drain()}):void u(e,function(e){var a={data:e,priority:i,callback:"function"==typeof s?s:null};t.tasks.splice(n(t.tasks,a,r)+1,0,a),t.saturated&&t.tasks.length===t.concurrency&&t.saturated(),o.setImmediate(t.process)})}var s=o.queue(t,e);return s.push=function(t,e,r){i(s,t,e,r)},delete s.unshift,s},o.cargo=function(t,e){var r=!1,n=[],i={tasks:n,payload:e,saturated:null,empty:null,drain:null,drained:!0,push:function(t,r){a(t)||(t=[t]),u(t,function(t){n.push({data:t,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===e&&i.saturated()}),o.setImmediate(i.process)},process:function o(){if(!r){if(0===n.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var s="number"==typeof e?n.splice(0,e):n.splice(0,n.length),a=c(s,function(t){return t.data});i.empty&&i.empty(),r=!0,t(a,function(){r=!1;var t=arguments;u(s,function(e){e.callback&&e.callback.apply(null,t)}),o()})}},length:function(){return n.length},running:function(){return r}};return i};var A=function(t){return function(e){var r=Array.prototype.slice.call(arguments,1);e.apply(null,r.concat([function(e){var r=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(e?console.error&&console.error(e):console[t]&&u(r,function(e){console[t](e)}))}]))}};o.log=A("log"),o.dir=A("dir"),o.memoize=function(t,e){var r={},n={};e=e||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),s=i.pop(),a=e.apply(null,i);
4
- a in r?o.nextTick(function(){s.apply(null,r[a])}):a in n?n[a].push(s):(n[a]=[s],t.apply(null,i.concat([function(){r[a]=arguments;var t=n[a];delete n[a];for(var e=0,i=t.length;i>e;e++)t[e].apply(null,arguments)}])))};return i.memo=r,i.unmemoized=t,i},o.unmemoize=function(t){return function(){return(t.unmemoized||t).apply(null,arguments)}},o.times=function(t,e,r){for(var n=[],i=0;t>i;i++)n.push(i);return o.map(n,e,r)},o.timesSeries=function(t,e,r){for(var n=[],i=0;t>i;i++)n.push(i);return o.mapSeries(n,e,r)},o.seq=function(){var t=arguments;return function(){var e=this,r=Array.prototype.slice.call(arguments),n=r.pop();o.reduce(t,r,function(t,r,n){r.apply(e,t.concat([function(){var t=arguments[0],e=Array.prototype.slice.call(arguments,1);n(t,e)}]))},function(t,r){n.apply(e,[t].concat(r))})}},o.compose=function(){return o.seq.apply(null,Array.prototype.reverse.call(arguments))};var O=function(t,e){var r=function(){var r=this,n=Array.prototype.slice.call(arguments),i=n.pop();return t(e,function(t,e){t.apply(r,n.concat([e]))},i)};if(arguments.length>2){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r};o.applyEach=p(O),o.applyEachSeries=_(O),o.forever=function(t,e){function r(n){if(n){if(e)return e(n);throw n}t(r)}r()},"undefined"!=typeof e&&e.exports?e.exports=o:"undefined"!=typeof define&&define.amd?define([],function(){return o}):n.async=o}()}).call(this,t("FWaASH"))},{FWaASH:55}],48:[function(t,e,r){function n(t,e){return p.isUndefined(e)?""+e:!p.isNumber(e)||!isNaN(e)&&isFinite(e)?p.isFunction(e)||p.isRegExp(e)?e.toString():e:e.toString()}function i(t,e){return p.isString(t)?t.length<e?t:t.slice(0,e):t}function o(t){return i(JSON.stringify(t.actual,n),128)+" "+t.operator+" "+i(JSON.stringify(t.expected,n),128)}function s(t,e,r,n,i){throw new y.AssertionError({message:r,actual:t,expected:e,operator:n,stackStartFunction:i})}function a(t,e){t||s(t,!0,e,"==",y.ok)}function u(t,e){if(t===e)return!0;if(p.isBuffer(t)&&p.isBuffer(e)){if(t.length!=e.length)return!1;for(var r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}return p.isDate(t)&&p.isDate(e)?t.getTime()===e.getTime():p.isRegExp(t)&&p.isRegExp(e)?t.source===e.source&&t.global===e.global&&t.multiline===e.multiline&&t.lastIndex===e.lastIndex&&t.ignoreCase===e.ignoreCase:p.isObject(t)||p.isObject(e)?f(t,e):t==e}function c(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function f(t,e){if(p.isNullOrUndefined(t)||p.isNullOrUndefined(e))return!1;if(t.prototype!==e.prototype)return!1;if(c(t))return c(e)?(t=d.call(t),e=d.call(e),u(t,e)):!1;try{var r,n,i=v(t),o=v(e)}catch(t){return!1}if(i.length!=o.length)return!1;for(i.sort(),o.sort(),n=i.length-1;n>=0;n--)if(i[n]!=o[n])return!1;for(n=i.length-1;n>=0;n--)if(r=i[n],!u(t[r],e[r]))return!1;return!0}function h(t,e){return t&&e?"[object RegExp]"==Object.prototype.toString.call(e)?e.test(t):t instanceof e?!0:e.call({},t)===!0?!0:!1:!1}function l(t,e,r,n){var i;p.isString(r)&&(n=r,r=null);try{e()}catch(t){i=t}if(n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&s(i,r,"Missing expected exception"+n),!t&&h(i,r)&&s(i,r,"Got unwanted exception"+n),t&&i&&r&&!h(i,r)||!t&&i)throw i}var p=t("util/"),d=Array.prototype.slice,_=Object.prototype.hasOwnProperty,y=e.exports=a;y.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=o(this),this.generatedMessage=!0);var e=t.stackStartFunction||s;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var n=r.stack,i=e.name,a=n.indexOf("\n"+i);if(a>=0){var u=n.indexOf("\n",a+1);n=n.substring(u+1)}this.stack=n}}},p.inherits(y.AssertionError,Error),y.fail=s,y.ok=a,y.equal=function(t,e,r){t!=e&&s(t,e,r,"==",y.equal)},y.notEqual=function(t,e,r){t==e&&s(t,e,r,"!=",y.notEqual)},y.deepEqual=function(t,e,r){u(t,e)||s(t,e,r,"deepEqual",y.deepEqual)},y.notDeepEqual=function(t,e,r){u(t,e)&&s(t,e,r,"notDeepEqual",y.notDeepEqual)},y.strictEqual=function(t,e,r){t!==e&&s(t,e,r,"===",y.strictEqual)},y.notStrictEqual=function(t,e,r){t===e&&s(t,e,r,"!==",y.notStrictEqual)},y.throws=function(t,e,r){l.apply(this,[!0].concat(d.call(arguments)))},y.doesNotThrow=function(t,e){l.apply(this,[!1].concat(d.call(arguments)))},y.ifError=function(t){if(t)throw t};var v=Object.keys||function(t){var e=[];for(var r in t)_.call(t,r)&&e.push(r);return e}},{"util/":57}],49:[function(t,e,r){function n(t,e,r){if(!(this instanceof n))return new n(t,e,r);var i,o=typeof t;if("number"===o)i=t>0?t>>>0:0;else if("string"===o)"base64"===e&&(t=A(t)),i=n.byteLength(t,e);else{if("object"!==o||null===t)throw new TypeError("must start with number, buffer, array or string");"Buffer"===t.type&&R(t.data)&&(t=t.data),i=+t.length>0?Math.floor(+t.length):0}if(this.length>P)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+P.toString(16)+" bytes");var s;n.TYPED_ARRAY_SUPPORT?s=n._augment(new Uint8Array(i)):(s=this,s.length=i,s._isBuffer=!0);var a;if(n.TYPED_ARRAY_SUPPORT&&"number"==typeof t.byteLength)s._set(t);else if(S(t))if(n.isBuffer(t))for(a=0;i>a;a++)s[a]=t.readUInt8(a);else for(a=0;i>a;a++)s[a]=(t[a]%256+256)%256;else if("string"===o)s.write(t,0,e);else if("number"===o&&!n.TYPED_ARRAY_SUPPORT&&!r)for(a=0;i>a;a++)s[a]=0;return s}function i(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=e.length;if(o%2!==0)throw new Error("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;n>s;s++){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");t[r+s]=a}return s}function o(t,e,r,n){var i=k(N(e),t,r,n);return i}function s(t,e,r,n){var i=k(x(e),t,r,n);return i}function a(t,e,r,n){return s(t,e,r,n)}function u(t,e,r,n){var i=k(T(e),t,r,n);return i}function c(t,e,r,n){var i=k(B(e),t,r,n,2);return i}function f(t,e,r){return 0===e&&r===t.length?I.fromByteArray(t):I.fromByteArray(t.slice(e,r))}function h(t,e,r){var n="",i="";r=Math.min(t.length,r);for(var o=e;r>o;o++)t[o]<=127?(n+=$(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return n+$(i)}function l(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function p(t,e,r){return l(t,e,r)}function d(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",o=e;r>o;o++)i+=j(t[o]);return i}function _(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function y(t,e,r){if(t%1!==0||0>t)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function v(t,e,r,i,o,s){if(!n.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(e>o||s>e)throw new TypeError("value is out of bounds");if(r+i>t.length)throw new TypeError("index out of range")}function g(t,e,r,n){0>e&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);o>i;i++)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function m(t,e,r,n){0>e&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);o>i;i++)t[r+i]=e>>>8*(n?i:3-i)&255}function b(t,e,r,n,i,o){if(e>i||o>e)throw new TypeError("value is out of bounds");if(r+n>t.length)throw new TypeError("index out of range")}function w(t,e,r,n,i){return i||b(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),D.write(t,e,r,n,23,4),r+4}function E(t,e,r,n,i){return i||b(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),D.write(t,e,r,n,52,8),r+8}function A(t){for(t=O(t).replace(C,"");t.length%4!==0;)t+="=";return t}function O(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function S(t){return R(t)||n.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function j(t){return 16>t?"0"+t.toString(16):t.toString(16)}function N(t){for(var e=[],r=0;r<t.length;r++){var n=t.charCodeAt(r);if(127>=n)e.push(n);else{var i=r;n>=55296&&57343>=n&&r++;for(var o=encodeURIComponent(t.slice(i,r+1)).substr(1).split("%"),s=0;s<o.length;s++)e.push(parseInt(o[s],16))}}return e}function x(t){for(var e=[],r=0;r<t.length;r++)e.push(255&t.charCodeAt(r));return e}function B(t){for(var e,r,n,i=[],o=0;o<t.length;o++)e=t.charCodeAt(o),r=e>>8,n=e%256,i.push(n),i.push(r);return i}function T(t){return I.toByteArray(t)}function k(t,e,r,n,i){i&&(n-=n%i);for(var o=0;n>o&&!(o+r>=e.length||o>=t.length);o++)e[o+r]=t[o];return o}function $(t){try{return decodeURIComponent(t)}catch(t){return String.fromCharCode(65533)}}var I=t("base64-js"),D=t("ieee754"),R=t("is-array");r.Buffer=n,r.SlowBuffer=n,r.INSPECT_MAX_BYTES=50,n.poolSize=8192;var P=1073741823;n.TYPED_ARRAY_SUPPORT=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(t){return!1}}(),n.isBuffer=function(t){return!(null==t||!t._isBuffer)},n.compare=function(t,e){if(!n.isBuffer(t)||!n.isBuffer(e))throw new TypeError("Arguments must be Buffers");for(var r=t.length,i=e.length,o=0,s=Math.min(r,i);s>o&&t[o]===e[o];o++);return o!==s&&(r=t[o],i=e[o]),i>r?-1:r>i?1:0},n.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},n.concat=function(t,e){if(!R(t))throw new TypeError("Usage: Buffer.concat(list[, length])");if(0===t.length)return new n(0);if(1===t.length)return t[0];var r;if(void 0===e)for(e=0,r=0;r<t.length;r++)e+=t[r].length;var i=new n(e),o=0;for(r=0;r<t.length;r++){var s=t[r];s.copy(i,o),o+=s.length}return i},n.byteLength=function(t,e){var r;switch(t+="",e||"utf8"){case"ascii":case"binary":case"raw":r=t.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=2*t.length;break;case"hex":r=t.length>>>1;break;case"utf8":case"utf-8":r=N(t).length;break;case"base64":r=T(t).length;break;default:r=t.length}return r},n.prototype.length=void 0,n.prototype.parent=void 0,n.prototype.toString=function(t,e,r){var n=!1;if(e>>>=0,r=void 0===r||r===1/0?this.length:r>>>0,t||(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return d(this,e,r);case"utf8":case"utf-8":return h(this,e,r);case"ascii":return l(this,e,r);case"binary":return p(this,e,r);case"base64":return f(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}},n.prototype.equals=function(t){if(!n.isBuffer(t))throw new TypeError("Argument must be a Buffer");return 0===n.compare(this,t)},n.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),"<Buffer "+t+">"},n.prototype.compare=function(t){if(!n.isBuffer(t))throw new TypeError("Argument must be a Buffer");return n.compare(this,t)},n.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},n.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},n.prototype.write=function(t,e,r,n){if(isFinite(e))isFinite(r)||(n=r,r=void 0);else{var f=n;n=e,e=r,r=f}e=Number(e)||0;var h=this.length-e;r?(r=Number(r),r>h&&(r=h)):r=h,n=String(n||"utf8").toLowerCase();var l;switch(n){case"hex":l=i(this,t,e,r);break;case"utf8":case"utf-8":l=o(this,t,e,r);break;case"ascii":l=s(this,t,e,r);break;case"binary":l=a(this,t,e,r);break;case"base64":l=u(this,t,e,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":l=c(this,t,e,r);break;default:throw new TypeError("Unknown encoding: "+n)}return l},n.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},n.prototype.slice=function(t,e){var r=this.length;if(t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t),n.TYPED_ARRAY_SUPPORT)return n._augment(this.subarray(t,e));for(var i=e-t,o=new n(i,void 0,!0),s=0;i>s;s++)o[s]=this[s+t];return o},n.prototype.readUInt8=function(t,e){return e||y(t,1,this.length),this[t]},n.prototype.readUInt16LE=function(t,e){return e||y(t,2,this.length),this[t]|this[t+1]<<8},n.prototype.readUInt16BE=function(t,e){return e||y(t,2,this.length),this[t]<<8|this[t+1]},n.prototype.readUInt32LE=function(t,e){return e||y(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},n.prototype.readUInt32BE=function(t,e){return e||y(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},n.prototype.readInt8=function(t,e){return e||y(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},n.prototype.readInt16LE=function(t,e){e||y(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt16BE=function(t,e){e||y(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt32LE=function(t,e){return e||y(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},n.prototype.readInt32BE=function(t,e){return e||y(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},n.prototype.readFloatLE=function(t,e){return e||y(t,4,this.length),D.read(this,t,!0,23,4)},n.prototype.readFloatBE=function(t,e){return e||y(t,4,this.length),D.read(this,t,!1,23,4)},n.prototype.readDoubleLE=function(t,e){return e||y(t,8,this.length),D.read(this,t,!0,52,8)},n.prototype.readDoubleBE=function(t,e){return e||y(t,8,this.length),D.read(this,t,!1,52,8)},n.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,1,255,0),n.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t,e+1},n.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8):g(this,t,e,!0),e+2},n.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t):g(this,t,e,!1),e+2},n.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t):m(this,t,e,!0),e+4},n.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t):m(this,t,e,!1),e+4},n.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,1,127,-128),n.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=t,e+1},n.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8):g(this,t,e,!0),e+2},n.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t):g(this,t,e,!1),e+2},n.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,4,2147483647,-2147483648),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):m(this,t,e,!0),e+4},n.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||v(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t):m(this,t,e,!1),e+4},n.prototype.writeFloatLE=function(t,e,r){return w(this,t,e,!0,r)},n.prototype.writeFloatBE=function(t,e,r){return w(this,t,e,!1,r)},n.prototype.writeDoubleLE=function(t,e,r){return E(this,t,e,!0,r)},n.prototype.writeDoubleBE=function(t,e,r){return E(this,t,e,!1,r)},n.prototype.copy=function(t,e,r,i){var o=this;if(r||(r=0),i||0===i||(i=this.length),e||(e=0),i!==r&&0!==t.length&&0!==o.length){if(r>i)throw new TypeError("sourceEnd < sourceStart");if(0>e||e>=t.length)throw new TypeError("targetStart out of bounds");if(0>r||r>=o.length)throw new TypeError("sourceStart out of bounds");if(0>i||i>o.length)throw new TypeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);var s=i-r;if(1e3>s||!n.TYPED_ARRAY_SUPPORT)for(var a=0;s>a;a++)t[a+e]=this[a+r];else t._set(this.subarray(r,r+s),e)}},n.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),e>r)throw new TypeError("end < start");if(r!==e&&0!==this.length){if(0>e||e>=this.length)throw new TypeError("start out of bounds");if(0>r||r>this.length)throw new TypeError("end out of bounds");var n;if("number"==typeof t)for(n=e;r>n;n++)this[n]=t;else{var i=N(t.toString()),o=i.length;for(n=e;r>n;n++)this[n]=i[n%o]}return this}},n.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(n.TYPED_ARRAY_SUPPORT)return new n(this).buffer;for(var t=new Uint8Array(this.length),e=0,r=t.length;r>e;e+=1)t[e]=this[e];return t.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var M=n.prototype;n._augment=function(t){return t.constructor=n,t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=M.get,t.set=M.set,t.write=M.write,t.toString=M.toString,t.toLocaleString=M.toString,t.toJSON=M.toJSON,t.equals=M.equals,t.compare=M.compare,t.copy=M.copy,t.slice=M.slice,t.readUInt8=M.readUInt8,t.readUInt16LE=M.readUInt16LE,t.readUInt16BE=M.readUInt16BE,t.readUInt32LE=M.readUInt32LE,t.readUInt32BE=M.readUInt32BE,t.readInt8=M.readInt8,t.readInt16LE=M.readInt16LE,t.readInt16BE=M.readInt16BE,t.readInt32LE=M.readInt32LE,t.readInt32BE=M.readInt32BE,t.readFloatLE=M.readFloatLE,t.readFloatBE=M.readFloatBE,t.readDoubleLE=M.readDoubleLE,t.readDoubleBE=M.readDoubleBE,t.writeUInt8=M.writeUInt8,t.writeUInt16LE=M.writeUInt16LE,t.writeUInt16BE=M.writeUInt16BE,t.writeUInt32LE=M.writeUInt32LE,t.writeUInt32BE=M.writeUInt32BE,t.writeInt8=M.writeInt8,t.writeInt16LE=M.writeInt16LE,t.writeInt16BE=M.writeInt16BE,t.writeInt32LE=M.writeInt32LE,t.writeInt32BE=M.writeInt32BE,t.writeFloatLE=M.writeFloatLE,t.writeFloatBE=M.writeFloatBE,t.writeDoubleLE=M.writeDoubleLE,t.writeDoubleBE=M.writeDoubleBE,t.fill=M.fill,t.inspect=M.inspect,t.toArrayBuffer=M.toArrayBuffer,t};var C=/[^+\/0-9A-z]/g},{"base64-js":50,ieee754:51,"is-array":52}],50:[function(t,e,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===s?62:e===a?63:u>e?-1:u+10>e?e-u+26+26:f+26>e?e-f:c+26>e?e-c+26:void 0}function r(t){function r(t){c[h++]=t}var n,i,s,a,u,c;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=t.length;u="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,c=new o(3*t.length/4-u),s=u>0?t.length-4:t.length;var h=0;for(n=0,i=0;s>n;n+=4,i+=3)a=e(t.charAt(n))<<18|e(t.charAt(n+1))<<12|e(t.charAt(n+2))<<6|e(t.charAt(n+3)),r((16711680&a)>>16),r((65280&a)>>8),r(255&a);return 2===u?(a=e(t.charAt(n))<<2|e(t.charAt(n+1))>>4,r(255&a)):1===u&&(a=e(t.charAt(n))<<10|e(t.charAt(n+1))<<4|e(t.charAt(n+2))>>2,r(a>>8&255),r(255&a)),c}function i(t){function e(t){return n.charAt(t)}function r(t){return e(t>>18&63)+e(t>>12&63)+e(t>>6&63)+e(63&t)}var i,o,s,a=t.length%3,u="";for(i=0,s=t.length-a;s>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],u+=r(o);switch(a){case 1:o=t[t.length-1],u+=e(o>>2),u+=e(o<<4&63),u+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],u+=e(o>>10),u+=e(o>>4&63),u+=e(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),c="a".charCodeAt(0),f="A".charCodeAt(0);t.toByteArray=r,t.fromByteArray=i}("undefined"==typeof r?this.base64js={}:r)},{}],51:[function(t,e,r){r.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,f=-7,h=r?i-1:0,l=r?-1:1,p=t[e+h];for(h+=l,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+t[e+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:(p?-1:1)*(1/0);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<<c)-1,h=f>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,_=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+h>=1?l/u:l*Math.pow(2,1-h),e*u>=2&&(s++,u/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;t[r+p]=255&s,p+=d,s/=256,c-=8);t[r+p-d]|=128*_}},{}],52:[function(t,e,r){var n=Array.isArray,i=Object.prototype.toString;e.exports=n||function(t){return!!t&&"[object Array]"==i.call(t)}},{}],53:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function o(t){return"number"==typeof t}function s(t){return"object"==typeof t&&null!==t}function a(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if(!o(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,o,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||s(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],a(r))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(n=arguments.length,o=new Array(n-1),u=1;n>u;u++)o[u-1]=arguments[u];r.apply(this,o)}else if(s(r)){for(n=arguments.length,o=new Array(n-1),u=1;n>u;u++)o[u-1]=arguments[u];for(c=r.slice(),n=c.length,u=0;n>u;u++)c[u].apply(this,o)}return!0},n.prototype.addListener=function(t,e){var r;if(!i(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,i(e.listener)?e.listener:e),this._events[t]?s(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,s(this._events[t])&&!this._events[t].warned){var r;r=a(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(t,r),this},n.prototype.removeListener=function(t,e){var r,n,o,a;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],o=r.length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(s(r)){for(a=o;a-->0;)if(r[a]===e||r[a].listener&&r[a].listener===e){n=a;break}if(0>n)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.listenerCount=function(t,e){var r;return r=t._events&&t._events[e]?i(t._events[e])?1:t._events[e].length:0}},{}],54:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],55:[function(t,e,r){function n(){}var i=e.exports={};i.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 r=[];return window.addEventListener("message",function(t){var e=t.source;if((e===window||null===e)&&"process-tick"===t.data&&(t.stopPropagation(),r.length>0)){var n=r.shift();n()}},!0),function(t){r.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),i.title="browser",i.browser=!0,i.env={},i.argv=[],i.on=n,i.addListener=n,i.once=n,i.off=n,i.removeListener=n,i.removeAllListeners=n,i.emit=n,i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")}},{}],56:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],57:[function(t,e,r){(function(e,n){function i(t,e){var n={seen:[],stylize:s};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),_(e)?n.showHidden=e:e&&r._extend(n,e),w(n.showHidden)&&(n.showHidden=!1),w(n.depth)&&(n.depth=2),w(n.colors)&&(n.colors=!1),w(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=o),u(n,t,n.depth)}function o(t,e){var r=i.styles[e];return r?"["+i.colors[r][0]+"m"+t+"["+i.colors[r][1]+"m":t}function s(t,e){return t}function a(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}function u(t,e,n){if(t.customInspect&&e&&j(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return m(i)||(i=u(t,i,n)),i}var o=c(t,e);if(o)return o;var s=Object.keys(e),_=a(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),S(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(e);if(0===s.length){if(j(e)){var y=e.name?": "+e.name:"";return t.stylize("[Function"+y+"]","special")}if(E(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(O(e))return t.stylize(Date.prototype.toString.call(e),"date");if(S(e))return f(e)}var v="",g=!1,b=["{","}"];if(d(e)&&(g=!0,b=["[","]"]),j(e)){var w=e.name?": "+e.name:"";v=" [Function"+w+"]"}if(E(e)&&(v=" "+RegExp.prototype.toString.call(e)),O(e)&&(v=" "+Date.prototype.toUTCString.call(e)),S(e)&&(v=" "+f(e)),0===s.length&&(!g||0==e.length))return b[0]+v+b[1];if(0>n)return E(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special");t.seen.push(e);var A;return A=g?h(t,e,n,_,s):s.map(function(r){return l(t,e,n,_,r,g)}),t.seen.pop(),p(A,v,b)}function c(t,e){if(w(e))return t.stylize("undefined","undefined");if(m(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return g(e)?t.stylize(""+e,"number"):_(e)?t.stylize(""+e,"boolean"):y(e)?t.stylize("null","null"):void 0}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,e,r,n,i){for(var o=[],s=0,a=e.length;a>s;++s)k(e,String(s))?o.push(l(t,e,r,n,String(s),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(l(t,e,r,n,i,!0))}),o}function l(t,e,r,n,i,o){var s,a,c;if(c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]},c.get?a=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(a=t.stylize("[Setter]","special")),k(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(c.value)<0?(a=y(r)?u(t,c.value,null):u(t,c.value,r-1),a.indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n"))):a=t.stylize("[Circular]","special")),w(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function p(t,e,r){var n=0,i=t.reduce(function(t,e){return n++,e.indexOf("\n")>=0&&n++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}function d(t){return Array.isArray(t)}function _(t){return"boolean"==typeof t}function y(t){return null===t}function v(t){return null==t}function g(t){return"number"==typeof t}function m(t){return"string"==typeof t}function b(t){return"symbol"==typeof t}function w(t){return void 0===t}function E(t){return A(t)&&"[object RegExp]"===x(t)}function A(t){return"object"==typeof t&&null!==t}function O(t){return A(t)&&"[object Date]"===x(t)}function S(t){return A(t)&&("[object Error]"===x(t)||t instanceof Error)}function j(t){return"function"==typeof t}function N(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function x(t){return Object.prototype.toString.call(t)}function B(t){return 10>t?"0"+t.toString(10):t.toString(10)}function T(){var t=new Date,e=[B(t.getHours()),B(t.getMinutes()),B(t.getSeconds())].join(":");return[t.getDate(),R[t.getMonth()],e].join(" ")}function k(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var $=/%[sdj%]/g;r.format=function(t){if(!m(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(i(arguments[r]));return e.join(" ")}for(var r=1,n=arguments,o=n.length,s=String(t).replace($,function(t){if("%%"===t)return"%";if(r>=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),a=n[r];o>r;a=n[++r])s+=y(a)||!A(a)?" "+a:" "+i(a);return s},r.deprecate=function(t,i){function o(){if(!s){if(e.throwDeprecation)throw new Error(i);e.traceDeprecation?console.trace(i):console.error(i),s=!0}return t.apply(this,arguments)}if(w(n.process))return function(){return r.deprecate(t,i).apply(this,arguments)};if(e.noDeprecation===!0)return t;var s=!1;return o};var I,D={};r.debuglog=function(t){if(w(I)&&(I=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!D[t])if(new RegExp("\\b"+t+"\\b","i").test(I)){var n=e.pid;D[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else D[t]=function(){};return D[t]},r.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=_,r.isNull=y,r.isNullOrUndefined=v,r.isNumber=g,r.isString=m,r.isSymbol=b,r.isUndefined=w,r.isRegExp=E,r.isObject=A,r.isDate=O,r.isError=S,r.isFunction=j,r.isPrimitive=N,r.isBuffer=t("./support/isBuffer");var R=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];r.log=function(){console.log("%s - %s",T(),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!A(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this,t("FWaASH"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":56,FWaASH:55,inherits:54}],58:[function(t,e,r){function n(t,e){if(!(this instanceof n))return new n(t,e);if(this._bsontype="Binary",t instanceof Number?(this.sub_type=t,this.position=0):(this.sub_type=null==e?o:e,this.position=0),null==t||t instanceof Number)"undefined"!=typeof i?this.buffer=new i(n.BUFFER_SIZE):"undefined"!=typeof Uint8Array?this.buffer=new Uint8Array(new ArrayBuffer(n.BUFFER_SIZE)):this.buffer=new Array(n.BUFFER_SIZE),
5
- this.position=0;else{if("string"==typeof t)if("undefined"!=typeof i)this.buffer=new i(t);else{if("undefined"==typeof Uint8Array&&"[object Array]"!=Object.prototype.toString.call(t))throw new Error("only String, Buffer, Uint8Array or Array accepted");this.buffer=s(t)}else this.buffer=t;this.position=t.length}}if("undefined"==typeof window)var i=t("buffer").Buffer;n.prototype.put=function(t){if(null!=t.length&&"number"!=typeof t&&1!=t.length)throw new Error("only accepts single character String, Uint8Array or Array");if("number"!=typeof t&&0>t||t>255)throw new Error("only accepts number in a valid unsigned byte range 0-255");var e=null;if(e="string"==typeof t?t.charCodeAt(0):null!=t.length?t[0]:t,this.buffer.length>this.position)this.buffer[this.position++]=e;else if("undefined"!=typeof i&&i.isBuffer(this.buffer)){var r=new i(n.BUFFER_SIZE+this.buffer.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r,this.buffer[this.position++]=e}else{var r=null;r="[object Uint8Array]"==Object.prototype.toString.call(this.buffer)?new Uint8Array(new ArrayBuffer(n.BUFFER_SIZE+this.buffer.length)):new Array(n.BUFFER_SIZE+this.buffer.length);for(var o=0;o<this.buffer.length;o++)r[o]=this.buffer[o];this.buffer=r,this.buffer[this.position++]=e}},n.prototype.write=function(t,e){if(e="number"==typeof e?e:this.position,this.buffer.length<e+t.length){var r=null;if("undefined"!=typeof i&&i.isBuffer(this.buffer))r=new i(this.buffer.length+t.length),this.buffer.copy(r,0,0,this.buffer.length);else if("[object Uint8Array]"==Object.prototype.toString.call(this.buffer)){r=new Uint8Array(new ArrayBuffer(this.buffer.length+t.length));for(var n=0;n<this.position;n++)r[n]=this.buffer[n]}this.buffer=r}if("undefined"!=typeof i&&i.isBuffer(t)&&i.isBuffer(this.buffer))t.copy(this.buffer,e,0,t.length),this.position=e+t.length>this.position?e+t.length:this.position;else if("undefined"!=typeof i&&"string"==typeof t&&i.isBuffer(this.buffer))this.buffer.write(t,e,"binary"),this.position=e+t.length>this.position?e+t.length:this.position;else if("[object Uint8Array]"==Object.prototype.toString.call(t)||"[object Array]"==Object.prototype.toString.call(t)&&"string"!=typeof t){for(var n=0;n<t.length;n++)this.buffer[e++]=t[n];this.position=e>this.position?e:this.position}else if("string"==typeof t){for(var n=0;n<t.length;n++)this.buffer[e++]=t.charCodeAt(n);this.position=e>this.position?e:this.position}},n.prototype.read=function(t,e){if(e=e&&e>0?e:this.position,this.buffer.slice)return this.buffer.slice(t,t+e);for(var r="undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(e)):new Array(e),n=0;e>n;n++)r[n]=this.buffer[t++];return r},n.prototype.value=function(t){if(t=null==t?!1:t,t&&"undefined"!=typeof i&&i.isBuffer(this.buffer)&&this.buffer.length==this.position)return this.buffer;if("undefined"!=typeof i&&i.isBuffer(this.buffer))return t?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position);if(t){if(null!=this.buffer.slice)return this.buffer.slice(0,this.position);for(var e="[object Uint8Array]"==Object.prototype.toString.call(this.buffer)?new Uint8Array(new ArrayBuffer(this.position)):new Array(this.position),r=0;r<this.position;r++)e[r]=this.buffer[r];return e}return a(this.buffer,0,this.position)},n.prototype.length=function(){return this.position},n.prototype.toJSON=function(){return null!=this.buffer?this.buffer.toString("base64"):""},n.prototype.toString=function(t){return null!=this.buffer?this.buffer.slice(0,this.position).toString(t):""};var o=0,s=function(t){for(var e="undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(t.length)):new Array(t.length),r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e},a=function(t,e,r){for(var n="",i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n};n.BUFFER_SIZE=256,n.SUBTYPE_DEFAULT=0,n.SUBTYPE_FUNCTION=1,n.SUBTYPE_BYTE_ARRAY=2,n.SUBTYPE_UUID_OLD=3,n.SUBTYPE_UUID=4,n.SUBTYPE_MD5=5,n.SUBTYPE_USER_DEFINED=128,e.exports=n,e.exports.Binary=n},{buffer:49}],59:[function(t,e,n){(function(e){function i(t,e){return this instanceof i?(this.bigEndian=t,void(this.allowExceptions=e)):new i(t,e)}function o(t,e){this.bigEndian=t||0,this.buffer=[],this.setBuffer(e)}for(var s=String.fromCharCode,a=[],u=0;64>u;u++)a[u]=Math.pow(2,u);i.warn=function(t){if(this.allowExceptions)throw new Error(t);return 1},i.decodeFloat=function(t,e,r){var n=new this.Buffer(this.bigEndian,t);n.checkBuffer(e+r+1);var i=a[r-1]-1,o=n.readBits(e+r,1),s=n.readBits(e,r),u=0,c=2,f=n.buffer.length+(-e>>3)-1;do for(var h=n.buffer[++f],l=e%8||8,p=1<<l;p>>=1;h&p&&(u+=1/c),c*=2);while(e-=l);return s==(i<<1)+1?u?NaN:o?-(1/0):+(1/0):(1+-2*o)*(s||u?s?Math.pow(2,s-i)*(1+u):Math.pow(2,-i+1)*u:0)},i.decodeInt=function(t,e,r,n){var i=new this.Buffer(this.bigEndian||n,t),o=i.readBits(0,e),s=a[e];return r&&o>=s/2?o-s:o},i.encodeFloat=function(t,e,n){var i,o,s,u,c,f=a[n-1]-1,h=-f+1,l=f,p=h-e,d=parseFloat(t),_=isNaN(d)||d==-(1/0)||d==+(1/0)?d:0,y=0,v=2*f+1+e+3,g=new Array(v),m=(d=0!==_?0:d)<0,b=Math.floor(d=Math.abs(d)),w=d-b;for(u=v;u;g[--u]=0);for(u=f+2;b&&u;g[--u]=b%2,b=Math.floor(b/2));for(u=f+1;w>0&&u;(g[++u]=((w*=2)>=1)-0)&&--w);for(u=-1;++u<v&&!g[u];);if(g[(i=e-1+(u=(y=f+1-u)>=h&&l>=y?u+1:f+1-(y=h-1)))+1]){if(!(o=g[i]))for(c=i+2;!o&&v>c;o=g[c++]);for(c=i+1;o&&--c>=0;(g[c]=!g[c]-0)&&(o=0));}for(u=0>u-2?-1:u-3;++u<v&&!g[u];);for((y=f+1-u)>=h&&l>=y?++u:h>y&&(y!=f+1-v&&p>y&&this.warn("encodeFloat::float underflow"),u=f+1-(y=h-1)),(b||0!==_)&&(this.warn(b?"encodeFloat::float overflow":"encodeFloat::"+_),y=l+1,u=f+2,_==-(1/0)?m=1:isNaN(_)&&(g[u]=1)),d=Math.abs(y+f),c=n+1,s="";--c;s=d%2+s,d=d>>=1);for(d=0,c=0,u=(s=(m?"1":"0")+s+g.slice(u,u+e).join("")).length,r=[];u;c=(c+1)%8)d+=(1<<c)*s.charAt(--u),7==c&&(r[r.length]=String.fromCharCode(d),d=0);return r[r.length]=d?String.fromCharCode(d):"",(this.bigEndian?r.reverse():r).join("")},i.encodeInt=function(t,e,r,n){var i=a[e];(t>=i||-(i/2)>t)&&(this.warn("encodeInt::overflow"),t=0),0>t&&(t+=i);for(var o=[];t;o[o.length]=String.fromCharCode(t%256),t=Math.floor(t/256));for(e=-(-e>>3)-o.length;e--;o[o.length]="\x00");return(this.bigEndian||n?o.reverse():o).join("")},i.toSmall=function(t){return this.decodeInt(t,8,!0)},i.fromSmall=function(t){return this.encodeInt(t,8,!0)},i.toByte=function(t){return this.decodeInt(t,8,!1)},i.fromByte=function(t){return this.encodeInt(t,8,!1)},i.toShort=function(t){return this.decodeInt(t,16,!0)},i.fromShort=function(t){return this.encodeInt(t,16,!0)},i.toWord=function(t){return this.decodeInt(t,16,!1)},i.fromWord=function(t){return this.encodeInt(t,16,!1)},i.toInt=function(t){return this.decodeInt(t,32,!0)},i.fromInt=function(t){return this.encodeInt(t,32,!0)},i.toLong=function(t){return this.decodeInt(t,64,!0)},i.fromLong=function(t){return this.encodeInt(t,64,!0)},i.toDWord=function(t){return this.decodeInt(t,32,!1)},i.fromDWord=function(t){return this.encodeInt(t,32,!1)},i.toQWord=function(t){return this.decodeInt(t,64,!0)},i.fromQWord=function(t){return this.encodeInt(t,64,!0)},i.toFloat=function(t){return this.decodeFloat(t,23,8)},i.fromFloat=function(t){return this.encodeFloat(t,23,8)},i.toDouble=function(t){return this.decodeFloat(t,52,11)},i.fromDouble=function(t){return this.encodeFloat(t,52,11)},i.encode_int32=function(t,e){var r,n,i,o,a;return a=0>t?t+4294967296:t,r=Math.floor(a/16777215),a&=16777215,n=Math.floor(a/65535),a&=65535,i=Math.floor(a/255),a&=255,o=Math.floor(a),e?[s(r),s(n),s(i),s(o)]:s(r)+s(n)+s(i)+s(o)},i.encode_int64=function(t){var e,r,n,i,o,a,u,c,f;return f=0>t?t+0x10000000000000000:t,e=Math.floor(f/72057594037927940),f&=72057594037927940,r=Math.floor(f/0xffffffffffff),f&=0xffffffffffff,n=Math.floor(f/0xffffffffff),f&=0xffffffffff,i=Math.floor(f/4294967295),f&=4294967295,o=Math.floor(f/16777215),f&=16777215,a=Math.floor(f/65535),f&=65535,u=Math.floor(f/255),f&=255,c=Math.floor(f),s(e)+s(r)+s(n)+s(i)+s(o)+s(a)+s(u)+s(c)},i.decode_utf8=function(t){for(var e,r=t.length,n="",i=0,o=0,s=0;r>i;)o=t.charCodeAt(i),128>o?(n+=String.fromCharCode(o),i++):o>191&&224>o?(s=t.charCodeAt(i+1),n+=String.fromCharCode((31&o)<<6|63&s),i+=2):(s=t.charCodeAt(i+1),e=t.charCodeAt(i+2),n+=String.fromCharCode((15&o)<<12|(63&s)<<6|63&e),i+=3);return n},i.encode_cstring=function(t){return unescape(encodeURIComponent(t))+i.fromByte(0)},i.encode_utf8=function(t){for(var e,r="",n=0,i=t.length;i>n;n++)e=t.charCodeAt(n),128>e?r+=String.fromCharCode(e):e>127&&2048>e?(r+=String.fromCharCode(e>>6|192),r+=String.fromCharCode(63&e|128)):(r+=String.fromCharCode(e>>12|224),r+=String.fromCharCode(e>>6&63|128),r+=String.fromCharCode(63&e|128));return r},i.hprint=function(t){for(var r,n=0,i=t.length;i>n;n++)t.charCodeAt(n)<32?(r=t.charCodeAt(n)<=15?"0"+t.charCodeAt(n).toString(16):t.charCodeAt(n).toString(16),e.stdout.write(r+" ")):(r=t.charCodeAt(n)<=15?"0"+t.charCodeAt(n).toString(16):t.charCodeAt(n).toString(16),e.stdout.write(r+" "));e.stdout.write("\n\n")},i.ilprint=function(e){for(var r,n=0,i=e.length;i>n;n++)e.charCodeAt(n)<32?(r=e.charCodeAt(n)<=15?"0"+e.charCodeAt(n).toString(10):e.charCodeAt(n).toString(10),t("util").debug(r+" : ")):(r=e.charCodeAt(n)<=15?"0"+e.charCodeAt(n).toString(10):e.charCodeAt(n).toString(10),t("util").debug(r+" : "+e.charAt(n)))},i.hlprint=function(e){for(var r,n=0,i=e.length;i>n;n++)e.charCodeAt(n)<32?(r=e.charCodeAt(n)<=15?"0"+e.charCodeAt(n).toString(16):e.charCodeAt(n).toString(16),t("util").debug(r+" : ")):(r=e.charCodeAt(n)<=15?"0"+e.charCodeAt(n).toString(16):e.charCodeAt(n).toString(16),t("util").debug(r+" : "+e.charAt(n)))},o.prototype.setBuffer=function(t){var e,r,n;if(t){for(r=e=t.length,n=this.buffer=new Array(e);r;n[e-r]=t.charCodeAt(--r));this.bigEndian&&n.reverse()}},o.prototype.hasNeededBits=function(t){return this.buffer.length>=-(-t>>3)},o.prototype.checkBuffer=function(t){if(!this.hasNeededBits(t))throw new Error("checkBuffer::missing bytes")},o.prototype.readBits=function(t,e){function r(t,e){for(;e--;t=1073741824==(1073741824&(t%=2147483648))?2*t:2*(t-1073741824)+2147483647+1);return t}if(0>t||0>=e)return 0;this.checkBuffer(t+e);for(var n,i=t%8,o=this.buffer.length-(t>>3)-1,s=this.buffer.length+(-(t+e)>>3),a=o-s,u=(this.buffer[o]>>i&(1<<(a?8-i:e))-1)+(a&&(n=(t+e)%8)?(this.buffer[s++]&(1<<n)-1)<<(a--<<3)-i:0);a;u+=r(this.buffer[s++],(a--<<3)-i));return u},i.Buffer=o,n.BinaryParser=i}).call(this,t("FWaASH"))},{FWaASH:55,util:57}],60:[function(t,e,r){(function(r){var n=(t("./float_parser").writeIEEE754,t("./float_parser").readIEEE754,t("./map")),i=t("./long").Long,o=t("./double").Double,s=t("./timestamp").Timestamp,a=t("./objectid").ObjectID,u=t("./regexp").BSONRegExp,c=t("./symbol").Symbol,f=t("./code").Code,h=t("./min_key").MinKey,l=t("./max_key").MaxKey,p=t("./db_ref").DBRef,d=t("./binary").Binary,_=t("./parser/deserializer"),y=t("./parser/serializer"),v=t("./parser/calculate_size"),g=17825792,m=new r(g),b=function(){};b.prototype.serialize=function(t,e,n,i,o,s){var a=y(m,t,e,o||0,0,i,s),u=new r(a);return m.copy(u,0,0,u.length),u},b.prototype.serializeWithBufferAndIndex=function(t,e,r,n,i,o){var s=y(m,t,e,n||0,0,i,o);return m.copy(r,n,0,s),n+s-1},b.prototype.deserialize=function(t,e){return _(t,e)},b.prototype.calculateObjectSize=function(t,e,r){return v(t,e,r)},b.prototype.deserializeStream=function(t,e,r,n,i,o){o=null!=o?o:{};for(var s=e,a=0;r>a;a++){var u=t[s]|t[s+1]<<8|t[s+2]<<16|t[s+3]<<24;o.index=s,n[i+a]=this.deserialize(t,o),s+=u}return s},b.BSON_INT32_MAX=2147483647,b.BSON_INT32_MIN=-2147483648,b.BSON_INT64_MAX=Math.pow(2,63)-1,b.BSON_INT64_MIN=-Math.pow(2,63),b.JS_INT_MAX=9007199254740992,b.JS_INT_MIN=-9007199254740992;i.fromNumber(9007199254740992),i.fromNumber(-9007199254740992);b.BSON_DATA_NUMBER=1,b.BSON_DATA_STRING=2,b.BSON_DATA_OBJECT=3,b.BSON_DATA_ARRAY=4,b.BSON_DATA_BINARY=5,b.BSON_DATA_OID=7,b.BSON_DATA_BOOLEAN=8,b.BSON_DATA_DATE=9,b.BSON_DATA_NULL=10,b.BSON_DATA_REGEXP=11,b.BSON_DATA_CODE=13,b.BSON_DATA_SYMBOL=14,b.BSON_DATA_CODE_W_SCOPE=15,b.BSON_DATA_INT=16,b.BSON_DATA_TIMESTAMP=17,b.BSON_DATA_LONG=18,b.BSON_DATA_MIN_KEY=255,b.BSON_DATA_MAX_KEY=127,b.BSON_BINARY_SUBTYPE_DEFAULT=0,b.BSON_BINARY_SUBTYPE_FUNCTION=1,b.BSON_BINARY_SUBTYPE_BYTE_ARRAY=2,b.BSON_BINARY_SUBTYPE_UUID=3,b.BSON_BINARY_SUBTYPE_MD5=4,b.BSON_BINARY_SUBTYPE_USER_DEFINED=128,e.exports=b,e.exports.Code=f,e.exports.Map=n,e.exports.Symbol=c,e.exports.BSON=b,e.exports.DBRef=p,e.exports.Binary=d,e.exports.ObjectID=a,e.exports.Long=i,e.exports.Timestamp=s,e.exports.Double=o,e.exports.MinKey=h,e.exports.MaxKey=l,e.exports.BSONRegExp=u}).call(this,t("buffer").Buffer)},{"./binary":58,"./code":61,"./db_ref":62,"./double":63,"./float_parser":64,"./long":65,"./map":66,"./max_key":67,"./min_key":68,"./objectid":69,"./parser/calculate_size":70,"./parser/deserializer":71,"./parser/serializer":72,"./regexp":73,"./symbol":74,"./timestamp":75,buffer:49}],61:[function(t,e,r){var n=function t(e,r){return this instanceof t?(this._bsontype="Code",this.code=e,void(this.scope=null==r?{}:r)):new t(e,r)};n.prototype.toJSON=function(){return{scope:this.scope,code:this.code}},e.exports=n,e.exports.Code=n},{}],62:[function(t,e,r){function n(t,e,r){return this instanceof n?(this._bsontype="DBRef",this.namespace=t,this.oid=e,void(this.db=r)):new n(t,e,r)}n.prototype.toJSON=function(){return{$ref:this.namespace,$id:this.oid,$db:null==this.db?"":this.db}},e.exports=n,e.exports.DBRef=n},{}],63:[function(t,e,r){function n(t){return this instanceof n?(this._bsontype="Double",void(this.value=t)):new n(t)}n.prototype.valueOf=function(){return this.value},n.prototype.toJSON=function(){return this.value},e.exports=n,e.exports.Double=n},{}],64:[function(t,e,r){var n=function(t,e,r,n,i){var o,s,a="big"===r,u=8*i-n-1,c=(1<<u)-1,f=c>>1,h=-7,l=a?0:i-1,p=a?1:-1,d=t[e+l];for(l+=p,o=d&(1<<-h)-1,d>>=-h,h+=u;h>0;o=256*o+t[e+l],l+=p,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+t[e+l],l+=p,h-=8);if(0===o)o=1-f;else{if(o===c)return s?NaN:(d?-1:1)*(1/0);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)},i=function(t,e,r,n,i,o){var s,a,u,c="big"===n,f=8*o-i-1,h=(1<<f)-1,l=h>>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=c?o-1:0,_=c?-1:1,y=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+l>=1?p/u:p*Math.pow(2,1-l),e*u>=2&&(s++,u/=2),s+l>=h?(a=0,s=h):s+l>=1?(a=(e*u-1)*Math.pow(2,i),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=_,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;t[r+d]=255&s,d+=_,s/=256,f-=8);t[r+d-_]|=128*y};r.readIEEE754=n,r.writeIEEE754=i},{}],65:[function(t,e,r){function n(t,e){return this instanceof n?(this._bsontype="Long",this.low_=0|t,void(this.high_=0|e)):new n(t,e)}n.prototype.toInt=function(){return this.low_},n.prototype.toNumber=function(){return this.high_*n.TWO_PWR_32_DBL_+this.getLowBitsUnsigned()},n.prototype.toJSON=function(){return this.toString()},n.prototype.toString=function(t){var e=t||10;if(2>e||e>36)throw Error("radix out of range: "+e);if(this.isZero())return"0";if(this.isNegative()){if(this.equals(n.MIN_VALUE)){var r=n.fromNumber(e),i=this.div(r),o=i.multiply(r).subtract(this);return i.toString(e)+o.toInt().toString(e)}return"-"+this.negate().toString(e)}for(var s=n.fromNumber(Math.pow(e,6)),o=this,a="";;){var u=o.div(s),c=o.subtract(u.multiply(s)).toInt(),f=c.toString(e);if(o=u,o.isZero())return f+a;for(;f.length<6;)f="0"+f;a=""+f+a}},n.prototype.getHighBits=function(){return this.high_},n.prototype.getLowBits=function(){return this.low_},n.prototype.getLowBitsUnsigned=function(){return this.low_>=0?this.low_:n.TWO_PWR_32_DBL_+this.low_},n.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(n.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var t=0!=this.high_?this.high_:this.low_,e=31;e>0&&0==(t&1<<e);e--);return 0!=this.high_?e+33:e+1},n.prototype.isZero=function(){return 0==this.high_&&0==this.low_},n.prototype.isNegative=function(){return this.high_<0},n.prototype.isOdd=function(){return 1==(1&this.low_)},n.prototype.equals=function(t){return this.high_==t.high_&&this.low_==t.low_},n.prototype.notEquals=function(t){return this.high_!=t.high_||this.low_!=t.low_},n.prototype.lessThan=function(t){return this.compare(t)<0},n.prototype.lessThanOrEqual=function(t){return this.compare(t)<=0},n.prototype.greaterThan=function(t){return this.compare(t)>0},n.prototype.greaterThanOrEqual=function(t){return this.compare(t)>=0},n.prototype.compare=function(t){if(this.equals(t))return 0;var e=this.isNegative(),r=t.isNegative();return e&&!r?-1:!e&&r?1:this.subtract(t).isNegative()?-1:1},n.prototype.negate=function(){return this.equals(n.MIN_VALUE)?n.MIN_VALUE:this.not().add(n.ONE)},n.prototype.add=function(t){var e=this.high_>>>16,r=65535&this.high_,i=this.low_>>>16,o=65535&this.low_,s=t.high_>>>16,a=65535&t.high_,u=t.low_>>>16,c=65535&t.low_,f=0,h=0,l=0,p=0;return p+=o+c,l+=p>>>16,p&=65535,l+=i+u,h+=l>>>16,l&=65535,h+=r+a,f+=h>>>16,h&=65535,f+=e+s,f&=65535,n.fromBits(l<<16|p,f<<16|h)},n.prototype.subtract=function(t){return this.add(t.negate())},n.prototype.multiply=function(t){if(this.isZero())return n.ZERO;if(t.isZero())return n.ZERO;if(this.equals(n.MIN_VALUE))return t.isOdd()?n.MIN_VALUE:n.ZERO;if(t.equals(n.MIN_VALUE))return this.isOdd()?n.MIN_VALUE:n.ZERO;if(this.isNegative())return t.isNegative()?this.negate().multiply(t.negate()):this.negate().multiply(t).negate();if(t.isNegative())return this.multiply(t.negate()).negate();if(this.lessThan(n.TWO_PWR_24_)&&t.lessThan(n.TWO_PWR_24_))return n.fromNumber(this.toNumber()*t.toNumber());var e=this.high_>>>16,r=65535&this.high_,i=this.low_>>>16,o=65535&this.low_,s=t.high_>>>16,a=65535&t.high_,u=t.low_>>>16,c=65535&t.low_,f=0,h=0,l=0,p=0;return p+=o*c,l+=p>>>16,p&=65535,l+=i*c,h+=l>>>16,l&=65535,l+=o*u,h+=l>>>16,l&=65535,h+=r*c,f+=h>>>16,h&=65535,h+=i*u,f+=h>>>16,h&=65535,h+=o*a,f+=h>>>16,h&=65535,f+=e*c+r*u+i*a+o*s,f&=65535,n.fromBits(l<<16|p,f<<16|h)},n.prototype.div=function(t){if(t.isZero())throw Error("division by zero");if(this.isZero())return n.ZERO;if(this.equals(n.MIN_VALUE)){if(t.equals(n.ONE)||t.equals(n.NEG_ONE))return n.MIN_VALUE;if(t.equals(n.MIN_VALUE))return n.ONE;var e=this.shiftRight(1),r=e.div(t).shiftLeft(1);if(r.equals(n.ZERO))return t.isNegative()?n.ONE:n.NEG_ONE;var i=this.subtract(t.multiply(r)),o=r.add(i.div(t));return o}if(t.equals(n.MIN_VALUE))return n.ZERO;if(this.isNegative())return t.isNegative()?this.negate().div(t.negate()):this.negate().div(t).negate();if(t.isNegative())return this.div(t.negate()).negate();for(var s=n.ZERO,i=this;i.greaterThanOrEqual(t);){for(var r=Math.max(1,Math.floor(i.toNumber()/t.toNumber())),a=Math.ceil(Math.log(r)/Math.LN2),u=48>=a?1:Math.pow(2,a-48),c=n.fromNumber(r),f=c.multiply(t);f.isNegative()||f.greaterThan(i);)r-=u,c=n.fromNumber(r),f=c.multiply(t);c.isZero()&&(c=n.ONE),s=s.add(c),i=i.subtract(f)}return s},n.prototype.modulo=function(t){return this.subtract(this.div(t).multiply(t))},n.prototype.not=function(){return n.fromBits(~this.low_,~this.high_)},n.prototype.and=function(t){return n.fromBits(this.low_&t.low_,this.high_&t.high_)},n.prototype.or=function(t){return n.fromBits(this.low_|t.low_,this.high_|t.high_)},n.prototype.xor=function(t){return n.fromBits(this.low_^t.low_,this.high_^t.high_)},n.prototype.shiftLeft=function(t){if(t&=63,0==t)return this;var e=this.low_;if(32>t){var r=this.high_;return n.fromBits(e<<t,r<<t|e>>>32-t)}return n.fromBits(0,e<<t-32)},n.prototype.shiftRight=function(t){if(t&=63,0==t)return this;var e=this.high_;if(32>t){var r=this.low_;return n.fromBits(r>>>t|e<<32-t,e>>t)}return n.fromBits(e>>t-32,e>=0?0:-1)},n.prototype.shiftRightUnsigned=function(t){if(t&=63,0==t)return this;var e=this.high_;if(32>t){var r=this.low_;return n.fromBits(r>>>t|e<<32-t,e>>>t)}return 32==t?n.fromBits(e,0):n.fromBits(e>>>t-32,0)},n.fromInt=function(t){if(t>=-128&&128>t){var e=n.INT_CACHE_[t];if(e)return e}var r=new n(0|t,0>t?-1:0);return t>=-128&&128>t&&(n.INT_CACHE_[t]=r),r},n.fromNumber=function(t){return isNaN(t)||!isFinite(t)?n.ZERO:t<=-n.TWO_PWR_63_DBL_?n.MIN_VALUE:t+1>=n.TWO_PWR_63_DBL_?n.MAX_VALUE:0>t?n.fromNumber(-t).negate():new n(t%n.TWO_PWR_32_DBL_|0,t/n.TWO_PWR_32_DBL_|0)},n.fromBits=function(t,e){return new n(t,e)},n.fromString=function(t,e){if(0==t.length)throw Error("number format error: empty string");var r=e||10;if(2>r||r>36)throw Error("radix out of range: "+r);if("-"==t.charAt(0))return n.fromString(t.substring(1),r).negate();if(t.indexOf("-")>=0)throw Error('number format error: interior "-" character: '+t);for(var i=n.fromNumber(Math.pow(r,8)),o=n.ZERO,s=0;s<t.length;s+=8){var a=Math.min(8,t.length-s),u=parseInt(t.substring(s,s+a),r);if(8>a){var c=n.fromNumber(Math.pow(r,a));o=o.multiply(c).add(n.fromNumber(u))}else o=o.multiply(i),o=o.add(n.fromNumber(u))}return o},n.INT_CACHE_={},n.TWO_PWR_16_DBL_=65536,n.TWO_PWR_24_DBL_=1<<24,n.TWO_PWR_32_DBL_=n.TWO_PWR_16_DBL_*n.TWO_PWR_16_DBL_,n.TWO_PWR_31_DBL_=n.TWO_PWR_32_DBL_/2,n.TWO_PWR_48_DBL_=n.TWO_PWR_32_DBL_*n.TWO_PWR_16_DBL_,n.TWO_PWR_64_DBL_=n.TWO_PWR_32_DBL_*n.TWO_PWR_32_DBL_,n.TWO_PWR_63_DBL_=n.TWO_PWR_64_DBL_/2,n.ZERO=n.fromInt(0),n.ONE=n.fromInt(1),n.NEG_ONE=n.fromInt(-1),n.MAX_VALUE=n.fromBits(-1,2147483647),n.MIN_VALUE=n.fromBits(0,-2147483648),n.TWO_PWR_24_=n.fromInt(1<<24),e.exports=n,e.exports.Long=n},{}],66:[function(t,e,r){(function(t){"use strict";if("undefined"!=typeof t.Map)e.exports=t.Map,e.exports.Map=t.Map;else{var r=function(t){this._keys=[],this._values={};for(var e=0;e<t.length;e++)if(null!=t[e]){var r=t[e],n=r[0],i=r[1];this._keys.push(n),this._values[n]={v:i,i:this._keys.length-1}}};r.prototype.clear=function(){this._keys=[],this._values={}},r.prototype.delete=function(t){var e=this._values[t];return null==e?!1:(delete this._values[t],this._keys.splice(e.i,1),!0)},r.prototype.entries=function(){var t=this,e=0;return{next:function(){var r=t._keys[e++];return{value:void 0!==r?[r,t._values[r].v]:void 0,done:void 0!==r?!1:!0}}}},r.prototype.forEach=function(t,e){e=e||this;for(var r=0;r<this._keys.length;r++){var n=this._keys[r];t.call(e,this._values[n].v,n,e)}},r.prototype.get=function(t){return this._values[t]?this._values[t].v:void 0},r.prototype.has=function(t){return null!=this._values[t]},r.prototype.keys=function(t){var e=this,r=0;return{next:function(){var t=e._keys[r++];return{value:void 0!==t?t:void 0,done:void 0!==t?!1:!0}}}},r.prototype.set=function(t,e){return this._values[t]?(this._values[t].v=e,this):(this._keys.push(t),this._values[t]={v:e,i:this._keys.length-1},this)},r.prototype.values=function(t,e){var r=this,n=0;return{next:function(){var t=r._keys[n++];return{value:void 0!==t?r._values[t].v:void 0,done:void 0!==t?!1:!0}}}},Object.defineProperty(r.prototype,"size",{enumerable:!0,get:function(){return this._keys.length}}),e.exports=r,e.exports.Map=r}}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],67:[function(t,e,r){function n(){return this instanceof n?void(this._bsontype="MaxKey"):new n}e.exports=n,e.exports.MaxKey=n},{}],68:[function(t,e,r){function n(){return this instanceof n?void(this._bsontype="MinKey"):new n}e.exports=n,e.exports.MinKey=n},{}],69:[function(t,e,r){(function(r){for(var n=t("./binary_parser").BinaryParser,i=parseInt(16777215*Math.random(),10),o=new RegExp("^[0-9a-fA-F]{24}$"),s=function t(e){if(!(this instanceof t))return new t(e);if(e instanceof t)return e;this._bsontype="ObjectID";var r=t.isValid(e);if(!r&&null!=e)throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return r&&"string"==typeof e&&24==e.length?t.createFromHexString(e):(null==e||"number"==typeof e?this.id=this.generate(e):null!=e&&12===e.length&&(this.id=e),void(t.cacheHexString&&(this.__id=this.toHexString())))},a=[],u=0;256>u;u++)a[u]=(15>=u?"0":"")+u.toString(16);s.prototype.toHexString=function(){if(s.cacheHexString&&this.__id)return this.__id;for(var t="",e=0;e<this.id.length;e++)t+=a[this.id.charCodeAt(e)];return s.cacheHexString&&(this.__id=t),t},s.prototype.get_inc=function(){return s.index=(s.index+1)%16777215},s.prototype.getInc=function(){return this.get_inc()},s.prototype.generate=function(t){"number"!=typeof t&&(t=parseInt(Date.now()/1e3,10));var e=n.encodeInt(t,32,!0,!0),o=n.encodeInt(i,24,!1),s=n.fromShort("undefined"==typeof r?Math.floor(1e5*Math.random()):r.pid%65535),a=n.encodeInt(this.get_inc(),24,!1,!0);return e+o+s+a},s.prototype.toString=function(){return this.toHexString()},s.prototype.inspect=s.prototype.toString,s.prototype.toJSON=function(){return this.toHexString()},s.prototype.equals=function(t){var e;if(null!=t&&(t instanceof s||t.toHexString))e=t.id;else{if("string"!=typeof t||!s.isValid(t))return!1;e=s.createFromHexString(t).id}return this.id===e},s.prototype.getTimestamp=function(){var t=new Date;return t.setTime(1e3*Math.floor(n.decodeInt(this.id.substring(0,4),32,!0,!0))),t},s.index=parseInt(16777215*Math.random(),10),s.createPk=function(){return new s},s.createFromTime=function(t){var e=n.encodeInt(t,32,!0,!0)+n.encodeInt(0,64,!0,!0);return new s(e)},s.createFromHexString=function(t){if("undefined"==typeof t||null!=t&&24!=t.length)throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");var e=t.length;if(e>24)throw new Error("Id cannot be longer than 12 bytes");for(var r,i,o="",a=0;e>a;a+=2)r=t.substr(a,2),i=parseInt(r,16),o+=n.fromByte(i);return new s(o,t)},s.isValid=function(t){return null==t?!1:"number"==typeof t?!0:"string"==typeof t?12==t.length||24==t.length&&o.test(t):!1},Object.defineProperty(s.prototype,"generationTime",{enumerable:!0,get:function(){return Math.floor(n.decodeInt(this.id.substring(0,4),32,!0,!0))},set:function(t){var t=n.encodeInt(t,32,!0,!0);this.id=t+this.id.substr(4),this.toHexString()}}),e.exports=s,e.exports.ObjectID=s,e.exports.ObjectId=s}).call(this,t("FWaASH"))},{"./binary_parser":59,FWaASH:55}],70:[function(t,e,r){(function(r){"use strict";function n(t,e,n,g,m){switch(e&&e.toBSON&&(e=e.toBSON()),typeof e){case"string":return 1+r.byteLength(t,"utf8")+1+4+r.byteLength(e,"utf8")+1;case"number":return Math.floor(e)===e&&e>=v.JS_INT_MIN&&e<=v.JS_INT_MAX&&e>=v.BSON_INT32_MIN&&e<=v.BSON_INT32_MAX?(null!=t?r.byteLength(t,"utf8")+1:0)+5:(null!=t?r.byteLength(t,"utf8")+1:0)+9;case"undefined":return g||!m?(null!=t?r.byteLength(t,"utf8")+1:0)+1:0;case"boolean":return(null!=t?r.byteLength(t,"utf8")+1:0)+2;case"object":if(null==e||e instanceof h||e instanceof l||"MinKey"==e._bsontype||"MaxKey"==e._bsontype)return(null!=t?r.byteLength(t,"utf8")+1:0)+1;if(e instanceof a||"ObjectID"==e._bsontype)return(null!=t?r.byteLength(t,"utf8")+1:0)+13;if(e instanceof Date||_(e))return(null!=t?r.byteLength(t,"utf8")+1:0)+9;if("undefined"!=typeof r&&r.isBuffer(e))return(null!=t?r.byteLength(t,"utf8")+1:0)+6+e.length;if(e instanceof i||e instanceof o||e instanceof s||"Long"==e._bsontype||"Double"==e._bsontype||"Timestamp"==e._bsontype)return(null!=t?r.byteLength(t,"utf8")+1:0)+9;if(e instanceof f||"Code"==e._bsontype)return null!=e.scope&&Object.keys(e.scope).length>0?(null!=t?r.byteLength(t,"utf8")+1:0)+1+4+4+r.byteLength(e.code.toString(),"utf8")+1+y(e.scope,n,m):(null!=t?r.byteLength(t,"utf8")+1:0)+1+4+r.byteLength(e.code.toString(),"utf8")+1;if(e instanceof d||"Binary"==e._bsontype)return e.sub_type==d.SUBTYPE_BYTE_ARRAY?(null!=t?r.byteLength(t,"utf8")+1:0)+(e.position+1+4+1+4):(null!=t?r.byteLength(t,"utf8")+1:0)+(e.position+1+4+1);if(e instanceof u||"Symbol"==e._bsontype)return(null!=t?r.byteLength(t,"utf8")+1:0)+r.byteLength(e.value,"utf8")+4+1+1;if(e instanceof p||"DBRef"==e._bsontype){var b={$ref:e.namespace,$id:e.oid};return null!=e.db&&(b.$db=e.db),(null!=t?r.byteLength(t,"utf8")+1:0)+1+y(b,n,m)}return e instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(e)?(null!=t?r.byteLength(t,"utf8")+1:0)+1+r.byteLength(e.source,"utf8")+1+(e.global?1:0)+(e.ignoreCase?1:0)+(e.multiline?1:0)+1:e instanceof c||"BSONRegExp"==e._bsontype?(null!=t?r.byteLength(t,"utf8")+1:0)+1+r.byteLength(e.pattern,"utf8")+1+r.byteLength(e.options,"utf8")+1:(null!=t?r.byteLength(t,"utf8")+1:0)+y(e,n,m)+1;case"function":if(e instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(e)||"[object RegExp]"==String.call(e))return(null!=t?r.byteLength(t,"utf8")+1:0)+1+r.byteLength(e.source,"utf8")+1+(e.global?1:0)+(e.ignoreCase?1:0)+(e.multiline?1:0)+1;if(n&&null!=e.scope&&Object.keys(e.scope).length>0)return(null!=t?r.byteLength(t,"utf8")+1:0)+1+4+4+r.byteLength(e.toString(),"utf8")+1+y(e.scope,n,m);if(n)return(null!=t?r.byteLength(t,"utf8")+1:0)+1+4+r.byteLength(e.toString(),"utf8")+1}return 0}var i=(t("../float_parser").writeIEEE754,t("../float_parser").readIEEE754,t("../long").Long),o=t("../double").Double,s=t("../timestamp").Timestamp,a=t("../objectid").ObjectID,u=t("../symbol").Symbol,c=t("../regexp").BSONRegExp,f=t("../code").Code,h=t("../min_key").MinKey,l=t("../max_key").MaxKey,p=t("../db_ref").DBRef,d=t("../binary").Binary,_=function(t){return"object"==typeof t&&"[object Date]"===Object.prototype.toString.call(t)},y=function(t,e,r){var i=5;if(Array.isArray(t))for(var o=0;o<t.length;o++)i+=n(o.toString(),t[o],e,!0,r);else{t.toBSON&&(t=t.toBSON());for(var s in t)i+=n(s,t[s],e,!1,r)}return i},v={};v.functionCache={};v.BSON_DATA_NUMBER=1,v.BSON_DATA_STRING=2,v.BSON_DATA_OBJECT=3,v.BSON_DATA_ARRAY=4,v.BSON_DATA_BINARY=5,v.BSON_DATA_OID=7,v.BSON_DATA_BOOLEAN=8,v.BSON_DATA_DATE=9,v.BSON_DATA_NULL=10,v.BSON_DATA_REGEXP=11,v.BSON_DATA_CODE=13,v.BSON_DATA_SYMBOL=14,v.BSON_DATA_CODE_W_SCOPE=15,v.BSON_DATA_INT=16,v.BSON_DATA_TIMESTAMP=17,v.BSON_DATA_LONG=18,v.BSON_DATA_MIN_KEY=255,v.BSON_DATA_MAX_KEY=127,v.BSON_BINARY_SUBTYPE_DEFAULT=0,v.BSON_BINARY_SUBTYPE_FUNCTION=1,v.BSON_BINARY_SUBTYPE_BYTE_ARRAY=2,v.BSON_BINARY_SUBTYPE_UUID=3,v.BSON_BINARY_SUBTYPE_MD5=4,v.BSON_BINARY_SUBTYPE_USER_DEFINED=128,v.BSON_INT32_MAX=2147483647,v.BSON_INT32_MIN=-2147483648,v.BSON_INT64_MAX=Math.pow(2,63)-1,v.BSON_INT64_MIN=-Math.pow(2,63),v.JS_INT_MAX=9007199254740992,v.JS_INT_MIN=-9007199254740992;i.fromNumber(9007199254740992),i.fromNumber(-9007199254740992);e.exports=y}).call(this,t("buffer").Buffer)},{"../binary":58,"../code":61,"../db_ref":62,"../double":63,"../float_parser":64,"../long":65,"../max_key":67,"../min_key":68,"../objectid":69,"../regexp":73,"../symbol":74,"../timestamp":75,buffer:49}],71:[function(require,module,exports){"use strict";var writeIEEE754=require("../float_parser").writeIEEE754,readIEEE754=require("../float_parser").readIEEE754,f=require("util").format,Long=require("../long").Long,Double=require("../double").Double,Timestamp=require("../timestamp").Timestamp,ObjectID=require("../objectid").ObjectID,Symbol=require("../symbol").Symbol,Code=require("../code").Code,MinKey=require("../min_key").MinKey,MaxKey=require("../max_key").MaxKey,DBRef=require("../db_ref").DBRef,BSONRegExp=require("../regexp").BSONRegExp,Binary=require("../binary").Binary,deserialize=function(t,e,r){var n=0,i=t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24;if(5>i||t.length<i)throw new Error("corrupt bson message");if(0!=t[i-1])throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return deserializeObject(t,e,r)},readCStyleStringSpecial=function(t,e){for(var r=e;0!==t[r]&&r<t.length;)r++;if(r>=t.length)throw new Error("Bad BSON Document: illegal CString");var n=t.toString("utf8",e,r);return e=r+1,{s:n,i:e}},deserializeObject=function(t,e,r){e=null==e?{}:e;var n=null==e.evalFunctions?!1:e.evalFunctions,i=null==e.cacheFunctions?!1:e.cacheFunctions,o=null==e.cacheFunctionsCrc32?!1:e.cacheFunctionsCrc32,s=null==e.promoteLongs?!0:e.promoteLongs,a=null==e.fieldsAsRaw?{}:e.fieldsAsRaw,u="boolean"==typeof e.bsonRegExp?e.bsonRegExp:!1,c=null==e.promoteBuffers?!1:e.promoteBuffers;if(t.length<5)throw new Error("corrupt bson message < 5 bytes long");var f="number"==typeof e.index?e.index:0,h=t[f++]|t[f++]<<8|t[f++]<<16|t[f++]<<24;if(5>h||h>t.length)throw new Error("corrupt bson message");for(var l=r?[]:{};;){var p=t[f++];if(0==p)break;var d=readCStyleStringSpecial(t,f),_=d.s;if(f=d.i,
6
- p==BSON.BSON_DATA_OID){var y=t.toString("binary",f,f+12);l[_]=new ObjectID(y),f+=12}else if(p==BSON.BSON_DATA_STRING){var v=t[f++]|t[f++]<<8|t[f++]<<16|t[f++]<<24;if(0>=v||v>t.length-f||0!=t[f+v-1])throw new Error("bad string length in bson");l[_]=t.toString("utf8",f,f+v-1),f+=v}else if(p==BSON.BSON_DATA_INT)l[_]=t[f++]|t[f++]<<8|t[f++]<<16|t[f++]<<24;else if(p==BSON.BSON_DATA_NUMBER)l[_]=readIEEE754(t,f,"little",52,8),f+=8;else if(p==BSON.BSON_DATA_DATE){var g=t[f++]|t[f++]<<8|t[f++]<<16|t[f++]<<24,m=t[f++]|t[f++]<<8|t[f++]<<16|t[f++]<<24;l[_]=new Date(new Long(g,m).toNumber())}else if(p==BSON.BSON_DATA_BOOLEAN)l[_]=1==t[f++];else if(p==BSON.BSON_DATA_UNDEFINED||p==BSON.BSON_DATA_NULL)l[_]=null;else if(p==BSON.BSON_DATA_BINARY){var b=t[f++]|t[f++]<<8|t[f++]<<16|t[f++]<<24,w=t[f++];if(null!=t.slice)w==Binary.SUBTYPE_BYTE_ARRAY&&(b=t[f++]|t[f++]<<8|t[f++]<<16|t[f++]<<24),c?l[_]=t.slice(f,f+b):l[_]=new Binary(t.slice(f,f+b),w);else{var E="undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(b)):new Array(b);w==Binary.SUBTYPE_BYTE_ARRAY&&(b=t[f++]|t[f++]<<8|t[f++]<<16|t[f++]<<24);for(var A=0;b>A;A++)E[A]=t[f+A];c?l[_]=E:l[_]=new Binary(E,w)}f+=b}else if(p==BSON.BSON_DATA_ARRAY){e.index=f;var O=t[f]|t[f+1]<<8|t[f+2]<<16|t[f+3]<<24,S=e;if(a[_]){S={};for(var j in e)S[j]=e[j];S.raw=!0}l[_]=deserializeObject(t,S,!0),f+=O}else if(p==BSON.BSON_DATA_OBJECT){e.index=f;var O=t[f]|t[f+1]<<8|t[f+2]<<16|t[f+3]<<24;if(0>=O||O>t.length-f)throw new Error("bad embedded document length in bson");e.raw?l[_]=t.slice(f,f+O):l[_]=deserializeObject(t,e,!1),f+=O}else if(p==BSON.BSON_DATA_REGEXP&&0==u){var d=readCStyleStringSpecial(t,f),N=d.s;f=d.i;var d=readCStyleStringSpecial(t,f),x=d.s;f=d.i;for(var B=new Array(x.length),A=0;A<x.length;A++)switch(x[A]){case"m":B[A]="m";break;case"s":B[A]="g";break;case"i":B[A]="i"}l[_]=new RegExp(N,B.join(""))}else if(p==BSON.BSON_DATA_REGEXP&&1==u){var d=readCStyleStringSpecial(t,f),N=d.s;f=d.i;var d=readCStyleStringSpecial(t,f),x=d.s;f=d.i,l[_]=new BSONRegExp(N,x)}else if(p==BSON.BSON_DATA_LONG){var g=t[f++]|t[f++]<<8|t[f++]<<16|t[f++]<<24,m=t[f++]|t[f++]<<8|t[f++]<<16|t[f++]<<24,T=new Long(g,m);s?l[_]=T.lessThanOrEqual(JS_INT_MAX_LONG)&&T.greaterThanOrEqual(JS_INT_MIN_LONG)?T.toNumber():T:l[_]=T}else if(p==BSON.BSON_DATA_SYMBOL){var v=t[f++]|t[f++]<<8|t[f++]<<16|t[f++]<<24;if(0>=v||v>t.length-f||0!=t[f+v-1])throw new Error("bad string length in bson");l[_]=new Symbol(t.toString("utf8",f,f+v-1)),f+=v}else if(p==BSON.BSON_DATA_TIMESTAMP){var g=t[f++]|t[f++]<<8|t[f++]<<16|t[f++]<<24,m=t[f++]|t[f++]<<8|t[f++]<<16|t[f++]<<24;l[_]=new Timestamp(g,m)}else if(p==BSON.BSON_DATA_MIN_KEY)l[_]=new MinKey;else if(p==BSON.BSON_DATA_MAX_KEY)l[_]=new MaxKey;else if(p==BSON.BSON_DATA_CODE){var v=t[f++]|t[f++]<<8|t[f++]<<16|t[f++]<<24;if(0>=v||v>t.length-f||0!=t[f+v-1])throw new Error("bad string length in bson");var k=t.toString("utf8",f,f+v-1);if(n){if(i){var $=o?crc32(k):k;l[_]=isolateEvalWithHash(functionCache,$,k,l)}else l[_]=isolateEval(k)}else l[_]=new Code(k,{});f+=v}else if(p==BSON.BSON_DATA_CODE_W_SCOPE){var v=(t[f++]|t[f++]<<8|t[f++]<<16|t[f++]<<24,t[f++]|t[f++]<<8|t[f++]<<16|t[f++]<<24);if(0>=v||v>t.length-f||0!=t[f+v-1])throw new Error("bad string length in bson");var k=t.toString("utf8",f,f+v-1);f+=v,e.index=f;var O=t[f]|t[f+1]<<8|t[f+2]<<16|t[f+3]<<24,I=deserializeObject(t,e,!1);if(f+=O,n){if(i){var $=o?crc32(k):k;l[_]=isolateEvalWithHash(functionCache,$,k,l)}else l[_]=isolateEval(k);l[_].scope=I}else l[_]=new Code(k,I)}}return null!=l.$id&&(l=new DBRef(l.$ref,l.$id,l.$db)),l},isolateEvalWithHash=function(functionCache,hash,functionString,object){var value=null;return null==functionCache[hash]&&(eval("value = "+functionString),functionCache[hash]=value),functionCache[hash].bind(object)},isolateEval=function(functionString){var value=null;return eval("value = "+functionString),value},BSON={},functionCache=BSON.functionCache={};BSON.BSON_DATA_NUMBER=1,BSON.BSON_DATA_STRING=2,BSON.BSON_DATA_OBJECT=3,BSON.BSON_DATA_ARRAY=4,BSON.BSON_DATA_BINARY=5,BSON.BSON_DATA_OID=7,BSON.BSON_DATA_BOOLEAN=8,BSON.BSON_DATA_DATE=9,BSON.BSON_DATA_NULL=10,BSON.BSON_DATA_REGEXP=11,BSON.BSON_DATA_CODE=13,BSON.BSON_DATA_SYMBOL=14,BSON.BSON_DATA_CODE_W_SCOPE=15,BSON.BSON_DATA_INT=16,BSON.BSON_DATA_TIMESTAMP=17,BSON.BSON_DATA_LONG=18,BSON.BSON_DATA_MIN_KEY=255,BSON.BSON_DATA_MAX_KEY=127,BSON.BSON_BINARY_SUBTYPE_DEFAULT=0,BSON.BSON_BINARY_SUBTYPE_FUNCTION=1,BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY=2,BSON.BSON_BINARY_SUBTYPE_UUID=3,BSON.BSON_BINARY_SUBTYPE_MD5=4,BSON.BSON_BINARY_SUBTYPE_USER_DEFINED=128,BSON.BSON_INT32_MAX=2147483647,BSON.BSON_INT32_MIN=-2147483648,BSON.BSON_INT64_MAX=Math.pow(2,63)-1,BSON.BSON_INT64_MIN=-Math.pow(2,63),BSON.JS_INT_MAX=9007199254740992,BSON.JS_INT_MIN=-9007199254740992;var JS_INT_MAX_LONG=Long.fromNumber(9007199254740992),JS_INT_MIN_LONG=Long.fromNumber(-9007199254740992);module.exports=deserialize},{"../binary":58,"../code":61,"../db_ref":62,"../double":63,"../float_parser":64,"../long":65,"../max_key":67,"../min_key":68,"../objectid":69,"../regexp":73,"../symbol":74,"../timestamp":75,util:57}],72:[function(t,e,r){(function(r){"use strict";var n=t("../float_parser").writeIEEE754,i=(t("../float_parser").readIEEE754,t("../long").Long),o=t("../map"),s=(t("../double").Double,t("../timestamp").Timestamp,t("../objectid").ObjectID,t("../symbol").Symbol,t("../code").Code,t("../regexp").BSONRegExp,t("../min_key").MinKey),a=(t("../max_key").MaxKey,t("../db_ref").DBRef,t("../binary").Binary),u=/\x00/,c=function(t){return"object"==typeof t&&"[object Date]"===Object.prototype.toString.call(t)},f=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},h=function(t,e,r,n){t[n++]=T.BSON_DATA_STRING;var i=t.write(e,n,"utf8");n=n+i+1,t[n-1]=0;var o=t.write(r,n+4,"utf8");return t[n+3]=o+1>>24&255,t[n+2]=o+1>>16&255,t[n+1]=o+1>>8&255,t[n]=o+1&255,n=n+4+o,t[n++]=0,n},l=function(t,e,r,o){if(Math.floor(r)===r&&r>=T.JS_INT_MIN&&r<=T.JS_INT_MAX)if(r>=T.BSON_INT32_MIN&&r<=T.BSON_INT32_MAX){t[o++]=T.BSON_DATA_INT;var s=t.write(e,o,"utf8");o+=s,t[o++]=0,t[o++]=255&r,t[o++]=r>>8&255,t[o++]=r>>16&255,t[o++]=r>>24&255}else if(r>=T.JS_INT_MIN&&r<=T.JS_INT_MAX){t[o++]=T.BSON_DATA_NUMBER;var s=t.write(e,o,"utf8");o+=s,t[o++]=0,n(t,r,o,"little",52,8),o+=8}else{t[o++]=T.BSON_DATA_LONG;var s=t.write(e,o,"utf8");o+=s,t[o++]=0;var a=i.fromNumber(r),u=a.getLowBits(),c=a.getHighBits();t[o++]=255&u,t[o++]=u>>8&255,t[o++]=u>>16&255,t[o++]=u>>24&255,t[o++]=255&c,t[o++]=c>>8&255,t[o++]=c>>16&255,t[o++]=c>>24&255}else{t[o++]=T.BSON_DATA_NUMBER;var s=t.write(e,o,"utf8");o+=s,t[o++]=0,n(t,r,o,"little",52,8),o+=8}return o},p=function(t,e,r,n){t[n++]=T.BSON_DATA_NULL;var i=t.write(e,n,"utf8");return n+=i,t[n++]=0,n},d=function(t,e,r,n){t[n++]=T.BSON_DATA_BOOLEAN;var i=t.write(e,n,"utf8");return n+=i,t[n++]=0,t[n++]=r?1:0,n},_=function(t,e,r,n){t[n++]=T.BSON_DATA_DATE;var o=t.write(e,n,"utf8");n+=o,t[n++]=0;var s=i.fromNumber(r.getTime()),a=s.getLowBits(),u=s.getHighBits();return t[n++]=255&a,t[n++]=a>>8&255,t[n++]=a>>16&255,t[n++]=a>>24&255,t[n++]=255&u,t[n++]=u>>8&255,t[n++]=u>>16&255,t[n++]=u>>24&255,n},y=function(t,e,r,n){t[n++]=T.BSON_DATA_REGEXP;var i=t.write(e,n,"utf8");if(n+=i,t[n++]=0,r.source&&null!=r.source.match(u))throw Error("value "+r.source+" must not contain null bytes");return n+=t.write(r.source,n,"utf8"),t[n++]=0,r.global&&(t[n++]=115),r.ignoreCase&&(t[n++]=105),r.multiline&&(t[n++]=109),t[n++]=0,n},v=function(t,e,r,n){t[n++]=T.BSON_DATA_REGEXP;var i=t.write(e,n,"utf8");return n+=i,t[n++]=0,n+=t.write(r.pattern,n,"utf8"),t[n++]=0,n+=t.write(r.options,n,"utf8"),t[n++]=0,n},g=function(t,e,r,n){null===r?t[n++]=T.BSON_DATA_NULL:r instanceof s?t[n++]=T.BSON_DATA_MIN_KEY:t[n++]=T.BSON_DATA_MAX_KEY;var i=t.write(e,n,"utf8");return n+=i,t[n++]=0,n},m=function(t,e,r,n){t[n++]=T.BSON_DATA_OID;var i=t.write(e,n,"utf8");return n+=i,t[n++]=0,t.write(r.id,n,"binary"),n+12},b=function(t,e,r,n){t[n++]=T.BSON_DATA_BINARY;var i=t.write(e,n,"utf8");n+=i,t[n++]=0;var o=r.length;return t[n++]=255&o,t[n++]=o>>8&255,t[n++]=o>>16&255,t[n++]=o>>24&255,t[n++]=T.BSON_BINARY_SUBTYPE_DEFAULT,r.copy(t,n,0,o),n+=o},w=function(t,e,r,n,i,o,s,a){t[n++]=Array.isArray(r)?T.BSON_DATA_ARRAY:T.BSON_DATA_OBJECT;var u=t.write(e,n,"utf8");n+=u,t[n++]=0;var c=B(t,r,i,n,o+1,s,a);return c},E=function(t,e,r,n){t[n++]=r instanceof i?T.BSON_DATA_LONG:T.BSON_DATA_TIMESTAMP;var o=t.write(e,n,"utf8");n+=o,t[n++]=0;var s=r.getLowBits(),a=r.getHighBits();return t[n++]=255&s,t[n++]=s>>8&255,t[n++]=s>>16&255,t[n++]=s>>24&255,t[n++]=255&a,t[n++]=a>>8&255,t[n++]=a>>16&255,t[n++]=a>>24&255,n},A=function(t,e,r,i){t[i++]=T.BSON_DATA_NUMBER;var o=t.write(e,i,"utf8");return i+=o,t[i++]=0,n(t,r,i,"little",52,8),i+=8},O=function(t,e,r,n,i,o){t[n++]=T.BSON_DATA_CODE;var s=t.write(e,n,"utf8");n+=s,t[n++]=0;var a=r.toString(),u=t.write(a,n+4,"utf8")+1;return t[n]=255&u,t[n+1]=u>>8&255,t[n+2]=u>>16&255,t[n+3]=u>>24&255,n=n+4+u-1,t[n++]=0,n},S=function(t,e,r,n,i,o,s,a){if(null!=r.scope&&Object.keys(r.scope).length>0){t[n++]=T.BSON_DATA_CODE_W_SCOPE;var u=t.write(e,n,"utf8");n+=u,t[n++]=0;var c=n,f="string"==typeof r.code?r.code:r.code.toString();n+=4;var h=t.write(f,n+4,"utf8")+1;t[n]=255&h,t[n+1]=h>>8&255,t[n+2]=h>>16&255,t[n+3]=h>>24&255,t[n+4+h-1]=0,n=n+h+4;var l=B(t,r.scope,i,n,o+1,s,a);n=l-1;var p=l-c;t[c++]=255&p,t[c++]=p>>8&255,t[c++]=p>>16&255,t[c++]=p>>24&255,t[n++]=0}else{t[n++]=T.BSON_DATA_CODE;var u=t.write(e,n,"utf8");n+=u,t[n++]=0;var f=r.code.toString(),d=t.write(f,n+4,"utf8")+1;t[n]=255&d,t[n+1]=d>>8&255,t[n+2]=d>>16&255,t[n+3]=d>>24&255,n=n+4+d-1,t[n++]=0}return n},j=function(t,e,r,n){t[n++]=T.BSON_DATA_BINARY;var i=t.write(e,n,"utf8");n+=i,t[n++]=0;var o=r.value(!0),s=r.position;return t[n++]=255&s,t[n++]=s>>8&255,t[n++]=s>>16&255,t[n++]=s>>24&255,t[n++]=r.sub_type,r.sub_type==a.SUBTYPE_BYTE_ARRAY&&(t[n++]=255&s,t[n++]=s>>8&255,t[n++]=s>>16&255,t[n++]=s>>24&255),o.copy(t,n,0,r.position),n+=r.position},N=function(t,e,r,n){t[n++]=T.BSON_DATA_SYMBOL;var i=t.write(e,n,"utf8");n+=i,t[n++]=0;var o=t.write(r.value,n+4,"utf8")+1;return t[n]=255&o,t[n+1]=o>>8&255,t[n+2]=o>>16&255,t[n+3]=o>>24&255,n=n+4+o-1,t[n++]=0,n},x=function(t,e,r,n,i,o){t[n++]=T.BSON_DATA_OBJECT;var s=t.write(e,n,"utf8");n+=s,t[n++]=0;var a,u=n;a=null!=r.db?B(t,{$ref:r.namespace,$id:r.oid,$db:r.db},!1,n,i+1,o):B(t,{$ref:r.namespace,$id:r.oid},!1,n,i+1,o);var c=a-u;return t[u++]=255&c,t[u++]=c>>8&255,t[u++]=c>>16&255,t[u++]=c>>24&255,a},B=function(t,e,n,i,s,a,B){i=i||0;var T=i+4;if(Array.isArray(e))for(var k=0;k<e.length;k++){var $=""+k,I=e[k];if(I&&I.toBSON){if("function"!=typeof I.toBSON)throw new Error("toBSON is not a function");I=I.toBSON()}var D=typeof I;"string"==D?T=h(t,$,I,T):"number"==D?T=l(t,$,I,T):"boolean"==D?T=d(t,$,I,T):I instanceof Date||c(I)?T=_(t,$,I,T):"undefined"==D||null==I?T=p(t,$,I,T):"ObjectID"==I._bsontype?T=m(t,$,I,T):r.isBuffer(I)?T=b(t,$,I,T):I instanceof RegExp||f(I)?T=y(t,$,I,T):"object"==D&&null==I._bsontype?T=w(t,$,I,T,n,s,a,B):"Long"==I._bsontype||"Timestamp"==I._bsontype?T=E(t,$,I,T):"Double"==I._bsontype?T=A(t,$,I,T):"function"==typeof I&&a?T=O(t,$,I,T,n,s,a):"Code"==I._bsontype?T=S(t,$,I,T,n,s,a,B):"Binary"==I._bsontype?T=j(t,$,I,T):"Symbol"==I._bsontype?T=N(t,$,I,T):"DBRef"==I._bsontype?T=x(t,$,I,T,s,a):"BSONRegExp"==I._bsontype?T=v(t,$,I,T):("MinKey"==I._bsontype||"MaxKey"==I._bsontype)&&(T=g(t,$,I,T))}else if(e instanceof o)for(var R=e.entries(),P=!1;!P;){var M=R.next();if(P=M.done,!P){var $=M.value[0],I=M.value[1],D=typeof I;if("$db"!=$&&"$ref"!=$&&"$id"!=$){if(null!=$.match(u))throw Error("key "+$+" must not contain null bytes");if(n){if("$"==$[0])throw Error("key "+$+" must not start with '$'");if(~$.indexOf("."))throw Error("key "+$+" must not contain '.'")}}"string"==D?T=h(t,$,I,T):"number"==D?T=l(t,$,I,T):"boolean"==D?T=d(t,$,I,T):I instanceof Date||c(I)?T=_(t,$,I,T):void 0===I&&1==B||(null===I||void 0===I?T=p(t,$,I,T):"ObjectID"==I._bsontype?T=m(t,$,I,T):r.isBuffer(I)?T=b(t,$,I,T):I instanceof RegExp||f(I)?T=y(t,$,I,T):"object"==D&&null==I._bsontype?T=w(t,$,I,T,n,s,a,B):"Long"==I._bsontype||"Timestamp"==I._bsontype?T=E(t,$,I,T):"Double"==I._bsontype?T=A(t,$,I,T):"Code"==I._bsontype?T=S(t,$,I,T,n,s,a,B):"function"==typeof I&&a?T=O(t,$,I,T,n,s,a):"Binary"==I._bsontype?T=j(t,$,I,T):"Symbol"==I._bsontype?T=N(t,$,I,T):"DBRef"==I._bsontype?T=x(t,$,I,T,s,a):"BSONRegExp"==I._bsontype?T=v(t,$,I,T):("MinKey"==I._bsontype||"MaxKey"==I._bsontype)&&(T=g(t,$,I,T)))}}else{if(e.toBSON){if("function"!=typeof e.toBSON)throw new Error("toBSON is not a function");if(e=e.toBSON(),null!=e&&"object"!=typeof e)throw new Error("toBSON function did not return an object")}for(var $ in e){var I=e[$];if(I&&I.toBSON){if("function"!=typeof I.toBSON)throw new Error("toBSON is not a function");I=I.toBSON()}var D=typeof I;if("$db"!=$&&"$ref"!=$&&"$id"!=$){if(null!=$.match(u))throw Error("key "+$+" must not contain null bytes");if(n){if("$"==$[0])throw Error("key "+$+" must not start with '$'");if(~$.indexOf("."))throw Error("key "+$+" must not contain '.'")}}"string"==D?T=h(t,$,I,T):"number"==D?T=l(t,$,I,T):"boolean"==D?T=d(t,$,I,T):I instanceof Date||c(I)?T=_(t,$,I,T):void 0===I&&1==B||(null===I||void 0===I?T=p(t,$,I,T):"ObjectID"==I._bsontype?T=m(t,$,I,T):r.isBuffer(I)?T=b(t,$,I,T):I instanceof RegExp||f(I)?T=y(t,$,I,T):"object"==D&&null==I._bsontype?T=w(t,$,I,T,n,s,a,B):"Long"==I._bsontype||"Timestamp"==I._bsontype?T=E(t,$,I,T):"Double"==I._bsontype?T=A(t,$,I,T):"Code"==I._bsontype?T=S(t,$,I,T,n,s,a,B):"function"==typeof I&&a?T=O(t,$,I,T,n,s,a):"Binary"==I._bsontype?T=j(t,$,I,T):"Symbol"==I._bsontype?T=N(t,$,I,T):"DBRef"==I._bsontype?T=x(t,$,I,T,s,a):"BSONRegExp"==I._bsontype?T=v(t,$,I,T):("MinKey"==I._bsontype||"MaxKey"==I._bsontype)&&(T=g(t,$,I,T)))}}t[T++]=0;var C=T-i;return t[i++]=255&C,t[i++]=C>>8&255,t[i++]=C>>16&255,t[i++]=C>>24&255,T},T={};T.functionCache={};T.BSON_DATA_NUMBER=1,T.BSON_DATA_STRING=2,T.BSON_DATA_OBJECT=3,T.BSON_DATA_ARRAY=4,T.BSON_DATA_BINARY=5,T.BSON_DATA_OID=7,T.BSON_DATA_BOOLEAN=8,T.BSON_DATA_DATE=9,T.BSON_DATA_NULL=10,T.BSON_DATA_REGEXP=11,T.BSON_DATA_CODE=13,T.BSON_DATA_SYMBOL=14,T.BSON_DATA_CODE_W_SCOPE=15,T.BSON_DATA_INT=16,T.BSON_DATA_TIMESTAMP=17,T.BSON_DATA_LONG=18,T.BSON_DATA_MIN_KEY=255,T.BSON_DATA_MAX_KEY=127,T.BSON_BINARY_SUBTYPE_DEFAULT=0,T.BSON_BINARY_SUBTYPE_FUNCTION=1,T.BSON_BINARY_SUBTYPE_BYTE_ARRAY=2,T.BSON_BINARY_SUBTYPE_UUID=3,T.BSON_BINARY_SUBTYPE_MD5=4,T.BSON_BINARY_SUBTYPE_USER_DEFINED=128,T.BSON_INT32_MAX=2147483647,T.BSON_INT32_MIN=-2147483648,T.BSON_INT64_MAX=Math.pow(2,63)-1,T.BSON_INT64_MIN=-Math.pow(2,63),T.JS_INT_MAX=9007199254740992,T.JS_INT_MIN=-9007199254740992;i.fromNumber(9007199254740992),i.fromNumber(-9007199254740992);e.exports=B}).call(this,t("buffer").Buffer)},{"../binary":58,"../code":61,"../db_ref":62,"../double":63,"../float_parser":64,"../long":65,"../map":66,"../max_key":67,"../min_key":68,"../objectid":69,"../regexp":73,"../symbol":74,"../timestamp":75,buffer:49}],73:[function(t,e,r){function n(t,e){if(!(this instanceof n))return new n;this._bsontype="BSONRegExp",this.pattern=t,this.options=e;for(var r=0;r<e.length;r++)if("i"!=this.options[r]&&"m"!=this.options[r]&&"x"!=this.options[r]&&"l"!=this.options[r]&&"s"!=this.options[r]&&"u"!=this.options[r])throw new Error("the regular expression options ["+this.options[r]+"] is not supported")}e.exports=n,e.exports.BSONRegExp=n},{}],74:[function(t,e,r){function n(t){return this instanceof n?(this._bsontype="Symbol",void(this.value=t)):new n(t)}n.prototype.valueOf=function(){return this.value},n.prototype.toString=function(){return this.value},n.prototype.inspect=function(){return this.value},n.prototype.toJSON=function(){return this.value},e.exports=n,e.exports.Symbol=n},{}],75:[function(t,e,r){function n(t,e){return this instanceof n?(this._bsontype="Timestamp",this.low_=0|t,void(this.high_=0|e)):new n(t,e)}n.prototype.toInt=function(){return this.low_},n.prototype.toNumber=function(){return this.high_*n.TWO_PWR_32_DBL_+this.getLowBitsUnsigned()},n.prototype.toJSON=function(){return this.toString()},n.prototype.toString=function(t){var e=t||10;if(2>e||e>36)throw Error("radix out of range: "+e);if(this.isZero())return"0";if(this.isNegative()){if(this.equals(n.MIN_VALUE)){var r=n.fromNumber(e),i=this.div(r),o=i.multiply(r).subtract(this);return i.toString(e)+o.toInt().toString(e)}return"-"+this.negate().toString(e)}for(var s=n.fromNumber(Math.pow(e,6)),o=this,a="";;){var u=o.div(s),c=o.subtract(u.multiply(s)).toInt(),f=c.toString(e);if(o=u,o.isZero())return f+a;for(;f.length<6;)f="0"+f;a=""+f+a}},n.prototype.getHighBits=function(){return this.high_},n.prototype.getLowBits=function(){return this.low_},n.prototype.getLowBitsUnsigned=function(){return this.low_>=0?this.low_:n.TWO_PWR_32_DBL_+this.low_},n.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(n.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var t=0!=this.high_?this.high_:this.low_,e=31;e>0&&0==(t&1<<e);e--);return 0!=this.high_?e+33:e+1},n.prototype.isZero=function(){return 0==this.high_&&0==this.low_},n.prototype.isNegative=function(){return this.high_<0},n.prototype.isOdd=function(){return 1==(1&this.low_)},n.prototype.equals=function(t){return this.high_==t.high_&&this.low_==t.low_},n.prototype.notEquals=function(t){return this.high_!=t.high_||this.low_!=t.low_},n.prototype.lessThan=function(t){return this.compare(t)<0},n.prototype.lessThanOrEqual=function(t){return this.compare(t)<=0},n.prototype.greaterThan=function(t){return this.compare(t)>0},n.prototype.greaterThanOrEqual=function(t){return this.compare(t)>=0},n.prototype.compare=function(t){if(this.equals(t))return 0;var e=this.isNegative(),r=t.isNegative();return e&&!r?-1:!e&&r?1:this.subtract(t).isNegative()?-1:1},n.prototype.negate=function(){return this.equals(n.MIN_VALUE)?n.MIN_VALUE:this.not().add(n.ONE)},n.prototype.add=function(t){var e=this.high_>>>16,r=65535&this.high_,i=this.low_>>>16,o=65535&this.low_,s=t.high_>>>16,a=65535&t.high_,u=t.low_>>>16,c=65535&t.low_,f=0,h=0,l=0,p=0;return p+=o+c,l+=p>>>16,p&=65535,l+=i+u,h+=l>>>16,l&=65535,h+=r+a,f+=h>>>16,h&=65535,f+=e+s,f&=65535,n.fromBits(l<<16|p,f<<16|h)},n.prototype.subtract=function(t){return this.add(t.negate())},n.prototype.multiply=function(t){if(this.isZero())return n.ZERO;if(t.isZero())return n.ZERO;if(this.equals(n.MIN_VALUE))return t.isOdd()?n.MIN_VALUE:n.ZERO;if(t.equals(n.MIN_VALUE))return this.isOdd()?n.MIN_VALUE:n.ZERO;if(this.isNegative())return t.isNegative()?this.negate().multiply(t.negate()):this.negate().multiply(t).negate();if(t.isNegative())return this.multiply(t.negate()).negate();if(this.lessThan(n.TWO_PWR_24_)&&t.lessThan(n.TWO_PWR_24_))return n.fromNumber(this.toNumber()*t.toNumber());var e=this.high_>>>16,r=65535&this.high_,i=this.low_>>>16,o=65535&this.low_,s=t.high_>>>16,a=65535&t.high_,u=t.low_>>>16,c=65535&t.low_,f=0,h=0,l=0,p=0;return p+=o*c,l+=p>>>16,p&=65535,l+=i*c,h+=l>>>16,l&=65535,l+=o*u,h+=l>>>16,l&=65535,h+=r*c,f+=h>>>16,h&=65535,h+=i*u,f+=h>>>16,h&=65535,h+=o*a,f+=h>>>16,h&=65535,f+=e*c+r*u+i*a+o*s,f&=65535,n.fromBits(l<<16|p,f<<16|h)},n.prototype.div=function(t){if(t.isZero())throw Error("division by zero");if(this.isZero())return n.ZERO;if(this.equals(n.MIN_VALUE)){if(t.equals(n.ONE)||t.equals(n.NEG_ONE))return n.MIN_VALUE;if(t.equals(n.MIN_VALUE))return n.ONE;var e=this.shiftRight(1),r=e.div(t).shiftLeft(1);if(r.equals(n.ZERO))return t.isNegative()?n.ONE:n.NEG_ONE;var i=this.subtract(t.multiply(r)),o=r.add(i.div(t));return o}if(t.equals(n.MIN_VALUE))return n.ZERO;if(this.isNegative())return t.isNegative()?this.negate().div(t.negate()):this.negate().div(t).negate();if(t.isNegative())return this.div(t.negate()).negate();for(var s=n.ZERO,i=this;i.greaterThanOrEqual(t);){for(var r=Math.max(1,Math.floor(i.toNumber()/t.toNumber())),a=Math.ceil(Math.log(r)/Math.LN2),u=48>=a?1:Math.pow(2,a-48),c=n.fromNumber(r),f=c.multiply(t);f.isNegative()||f.greaterThan(i);)r-=u,c=n.fromNumber(r),f=c.multiply(t);c.isZero()&&(c=n.ONE),s=s.add(c),i=i.subtract(f)}return s},n.prototype.modulo=function(t){return this.subtract(this.div(t).multiply(t))},n.prototype.not=function(){return n.fromBits(~this.low_,~this.high_)},n.prototype.and=function(t){return n.fromBits(this.low_&t.low_,this.high_&t.high_)},n.prototype.or=function(t){return n.fromBits(this.low_|t.low_,this.high_|t.high_)},n.prototype.xor=function(t){return n.fromBits(this.low_^t.low_,this.high_^t.high_)},n.prototype.shiftLeft=function(t){if(t&=63,0==t)return this;var e=this.low_;if(32>t){var r=this.high_;return n.fromBits(e<<t,r<<t|e>>>32-t)}return n.fromBits(0,e<<t-32)},n.prototype.shiftRight=function(t){if(t&=63,0==t)return this;var e=this.high_;if(32>t){var r=this.low_;return n.fromBits(r>>>t|e<<32-t,e>>t)}return n.fromBits(e>>t-32,e>=0?0:-1)},n.prototype.shiftRightUnsigned=function(t){if(t&=63,0==t)return this;var e=this.high_;if(32>t){var r=this.low_;return n.fromBits(r>>>t|e<<32-t,e>>>t)}return 32==t?n.fromBits(e,0):n.fromBits(e>>>t-32,0)},n.fromInt=function(t){if(t>=-128&&128>t){var e=n.INT_CACHE_[t];if(e)return e}var r=new n(0|t,0>t?-1:0);return t>=-128&&128>t&&(n.INT_CACHE_[t]=r),r},n.fromNumber=function(t){return isNaN(t)||!isFinite(t)?n.ZERO:t<=-n.TWO_PWR_63_DBL_?n.MIN_VALUE:t+1>=n.TWO_PWR_63_DBL_?n.MAX_VALUE:0>t?n.fromNumber(-t).negate():new n(t%n.TWO_PWR_32_DBL_|0,t/n.TWO_PWR_32_DBL_|0)},n.fromBits=function(t,e){return new n(t,e)},n.fromString=function(t,e){if(0==t.length)throw Error("number format error: empty string");var r=e||10;if(2>r||r>36)throw Error("radix out of range: "+r);if("-"==t.charAt(0))return n.fromString(t.substring(1),r).negate();if(t.indexOf("-")>=0)throw Error('number format error: interior "-" character: '+t);for(var i=n.fromNumber(Math.pow(r,8)),o=n.ZERO,s=0;s<t.length;s+=8){var a=Math.min(8,t.length-s),u=parseInt(t.substring(s,s+a),r);if(8>a){var c=n.fromNumber(Math.pow(r,a));o=o.multiply(c).add(n.fromNumber(u))}else o=o.multiply(i),o=o.add(n.fromNumber(u))}return o},n.INT_CACHE_={},n.TWO_PWR_16_DBL_=65536,n.TWO_PWR_24_DBL_=1<<24,n.TWO_PWR_32_DBL_=n.TWO_PWR_16_DBL_*n.TWO_PWR_16_DBL_,n.TWO_PWR_31_DBL_=n.TWO_PWR_32_DBL_/2,n.TWO_PWR_48_DBL_=n.TWO_PWR_32_DBL_*n.TWO_PWR_16_DBL_,n.TWO_PWR_64_DBL_=n.TWO_PWR_32_DBL_*n.TWO_PWR_32_DBL_,n.TWO_PWR_63_DBL_=n.TWO_PWR_64_DBL_/2,n.ZERO=n.fromInt(0),n.ONE=n.fromInt(1),n.NEG_ONE=n.fromInt(-1),n.MAX_VALUE=n.fromBits(-1,2147483647),n.MIN_VALUE=n.fromBits(0,-2147483648),n.TWO_PWR_24_=n.fromInt(1<<24),e.exports=n,e.exports.Timestamp=n},{}],76:[function(t,e,r){function n(t,e){return function r(){if(!r.hookCalled){r.hookCalled=!0;var n=t.apply(e,arguments);n&&n.then&&n.then(function(){},function(){})}}}e.exports={hook:function(t,e,r){if(1!==arguments.length||"object"!=typeof t){var i=this.prototype||this,o=i._pres=i._pres||{},s=i._posts=i._posts||{};return o[t]=o[t]||[],s[t]=s[t]||[],i[t]=function(){var o,s=this,a=arguments[arguments.length-1],u=this._pres[t],c=this._posts[t],f=u.length,h=-1,l=i[t].numAsyncPres,p=function(t){return t?d(t):void(--l||y.apply(s,o))},d=function(t){if("function"==typeof a)return a(t);if(r)return r.call(s,t);throw t},_=function(){if(arguments[0]instanceof Error)return d(arguments[0]);var t,e,r=Array.prototype.slice.call(arguments);if(!r.length||null==arguments[0]&&"function"==typeof a||(o=r),++h<f){if(t=u[h],t.isAsync&&t.length<2)throw new Error("Your pre must have next and done arguments -- e.g., function (next, done, ...)");if(t.length<1)throw new Error("Your pre must have a next argument -- e.g., function (next, ...)");return e=(t.isAsync?[n(_),n(p)]:[n(_)]).concat(o),t.apply(s,e)}return l?void 0:y.apply(s,o)},y=function(){var t,r,i,u,l=Array.prototype.slice.call(arguments);return h===f?(u=function(){if(arguments[0]instanceof Error)return d(arguments[0]);var t,e,f=Array.prototype.slice.call(arguments,1);if(f.length&&(o=f),++i<r){if(t=c[i],t.length<1)throw new Error("Your post must have a next argument -- e.g., function (next, ...)");return e=[n(u)].concat(o),t.apply(s,e)}return"function"==typeof a?a.apply(s,arguments):void 0},"function"==typeof a&&(l[l.length-1]=n(u)),r=c.length,i=-1,t=e.apply(s,l),r&&"function"!=typeof a?u():t):void 0};return _.apply(this,arguments)},i[t].numAsyncPres=0,this}for(var a in t)this.hook(a,t[a])},pre:function(t,e,r,n){"boolean"!=typeof arguments[1]&&(n=r,r=e,e=!1);var i=this.prototype||this,o=i._pres=i._pres||{};return this._lazySetupHooks(i,t,n),(r.isAsync=e)&&i[t].numAsyncPres++,(o[t]=o[t]||[]).push(r),this},post:function(t,e,r){2===arguments.length&&(r=e,e=!1);var n=this.prototype||this,i=n._posts=n._posts||{};return this._lazySetupHooks(n,t),(i[t]=i[t]||[]).push(r),this},removePre:function(t,e){var r=this.prototype||this,n=r._pres||r._pres||{};return n[t]?(1===arguments.length?n[t].length=0:n[t]=n[t].filter(function(t){return t!==e}),this):this},removePost:function(t,e){var r=this.prototype||this,n=r._posts||r._posts||{};return n[t]?(1===arguments.length?n[t].length=0:n[t]=n[t].filter(function(t){return t!==e}),this):this},_lazySetupHooks:function(t,e,r){"undefined"==typeof t[e].numAsyncPres&&this.hook(e,t[e],r)}}},{}],77:[function(t,e,r){(function(t){"use strict";function r(){this._pres={},this._posts={}}r.prototype.execPre=function(e,r,n){var i=this._pres[e]||[],o=i.length,s=i.numAsync||0,a=0,u=s,c=!1;if(!o)return t.nextTick(function(){n(null)});var f=function(){if(!(a>=o)){var e=i[a];if(e.isAsync)e.fn.call(r,function(t){if(t){if(c)return;return c=!0,n(t)}++a,f.apply(r,arguments)},function(t){if(t){if(c)return;return c=!0,n(t)}return 0===--s?n(null):void 0});else if(e.fn.length>0){var h=[function(t){if(t){if(c)return;return c=!0,n(t)}return++a>=o?u>0?void 0:n(null):void f.apply(r,arguments)}];if(arguments.length>=2)for(var l=1;l<arguments.length;++l)h.push(arguments[l]);e.fn.apply(r,h)}else{if(e.fn.call(r),++a>=o)return u>0?void 0:t.nextTick(function(){n(null)});f()}}};f()},r.prototype.execPost=function(e,r,n,i){var o=this._posts[e]||[],s=o.length,a=0;if(!s)return t.nextTick(function(){i.apply(null,[null].concat(n))});var u=function(){var t=o[a];if(t.length>n.length)t.apply(r,n.concat(function(t){return t?i(t):++a>=s?i.apply(null,[null].concat(n)):void u()}));else{if(t.apply(r,n),++a>=s)return i.apply(null,[null].concat(n));u()}};u()},r.prototype.wrap=function(t,e,r,n,i){var o=n.length>0?n[n.length-1]:null,s=this;this.execPre(t,r,function(a){if(a){if("function"==typeof o)return o(a)}else{var u="function"==typeof o?n.length-1:n.length;e.apply(r,n.slice(0,u).concat(function(){if(arguments[0])return"function"==typeof o?o(arguments[0]):void 0;i&&"function"==typeof o&&o.apply(r,arguments);var e=Array.prototype.slice.call(arguments,1);s.execPost(t,r,e,function(){return arguments[0]?"function"==typeof o?o(arguments[0]):void 0:"function"!=typeof o||i?void 0:o.apply(r,arguments)})}))}})},r.prototype.createWrapper=function(t,e,r){var n=this;return function(){var i=Array.prototype.slice.call(arguments);n.wrap(t,e,r,i)}},r.prototype.pre=function(t,e,r,n){"boolean"!=typeof arguments[1]&&(n=r,r=e,e=!1),this._pres[t]=this._pres[t]||[];var i=this._pres[t];return e&&(i.numAsync=i.numAsync||0,++i.numAsync),i.push({fn:r,isAsync:e}),this},r.prototype.post=function(t,e){return(this._posts[t]=this._posts[t]||[]).push(e),this},r.prototype.clone=function(){var t=new r;for(var e in this._pres)t._pres[e]=this._pres[e].slice();for(var e in this._posts)t._posts[e]=this._posts[e].slice();return t},e.exports=r}).call(this,t("FWaASH"))},{FWaASH:55}],78:[function(t,e,r){e.exports=r=t("./lib")},{"./lib":79}],79:[function(t,e,r){function n(t){return t}r.get=function(t,e,i,o){"function"==typeof i&&(o=i,i=void 0),o||(o=n);var s="string"==typeof t?t.split("."):t;if(!Array.isArray(s))throw new TypeError("Invalid `path`. Must be either string or array");for(var a,u=e,c=0;c<s.length;++c){if(a=s[c],Array.isArray(u)&&!/^\d+$/.test(a)){var f=s.slice(c);return u.map(function(t){return t?r.get(f,t,i,o):o(void 0)})}if(u=i&&u[i]?u[i][a]:u[a],!u)return o(u)}return o(u)},r.set=function(t,e,i,o,s,a){"function"==typeof o&&(s=o,o=void 0),s||(s=n);var u="string"==typeof t?t.split("."):t;if(!Array.isArray(u))throw new TypeError("Invalid `path`. Must be either string or array");if(null!=i){for(var c,f=a||/\$/.test(t),h=i,l=0,p=u.length-1;p>l;++l)if(c=u[l],"$"!=c){if(Array.isArray(h)&&!/^\d+$/.test(c)){var d=u.slice(l);if(!f&&Array.isArray(e))for(var _=0;_<h.length&&_<e.length;++_)r.set(d,e[_],h[_],o,s,f);else for(var _=0;_<h.length;++_)r.set(d,e,h[_],o,s,f);return}if(h=o&&h[o]?h[o][c]:h[c],!h)return}else if(l==p-1)break;if(c=u[p],o&&h[o]&&(h=h[o]),Array.isArray(h)&&!/^\d+$/.test(c))if(!f&&Array.isArray(e))for(var y,_=0;_<h.length&&_<e.length;++_)y=h[_],y&&(y[o]&&(y=y[o]),y[c]=s(e[_]));else for(var _=0;_<h.length;++_)y=h[_],y&&(y[o]&&(y=y[o]),y[c]=s(e));else h[c]=s(e)}}},{}],80:[function(t,e,r){(function(r){"use strict";function n(t,e,r){return Array.prototype.slice.call(t,e,r)}function i(t,e){var r=n(e);return r.unshift(t),r}function o(t){this.emitter=new u,this.emitted={},this.ended=!1,"function"==typeof t&&this.onResolve(t)}function s(t,e){function n(){var n=t.emitter.domain;n&&n!==r.domain&&n.enter();try{var o=e.apply(void 0,i.args)}catch(e){return void t.reject(e)}a(t,o)}function i(){i.args=arguments,r.nextTick(n)}return i}function a(t,e){function r(){f++||a.apply(void 0,i(t,arguments))}function o(e){f++||t.reject(e)}if(t===e)return void t.reject(new TypeError("promise and x are the same"));var s=n(arguments,1),u=typeof e;if("undefined"==u||null==e||"object"!=u&&"function"!=u)return void t.fulfill.apply(t,s);try{var c=e.then}catch(e){return void t.reject(e)}if("function"!=typeof c)return void t.fulfill.apply(t,s);var f=0;try{var h=c.call(e,r,o);return h}catch(e){if(f++)return;t.reject(e)}}var u=(t("util"),t("events").EventEmitter);e.exports=o,o.SUCCESS="fulfill",o.FAILURE="reject",o.prototype.on=function(t,e){return this.emitted[t]?e.apply(void 0,this.emitted[t]):this.emitter.on(t,e),this},o.prototype.safeEmit=function(t){if(t==o.SUCCESS||t==o.FAILURE){if(this.emitted[o.SUCCESS]||this.emitted[o.FAILURE])return this;this.emitted[t]=n(arguments,1)}return this.emitter.emit.apply(this.emitter,arguments),this},o.prototype.fulfill=function(){return this.safeEmit.apply(this,i(o.SUCCESS,arguments))},o.prototype.reject=function(t){if(this.ended&&!this.hasRejectListeners())throw t;return this.safeEmit(o.FAILURE,t)},o.prototype.resolve=function(t,e){return t?this.reject(t):this.fulfill(e)},o.prototype.onFulfill=function(t){if(!t)return this;if("function"!=typeof t)throw new TypeError("fn should be a function");return this.on(o.SUCCESS,t)},o.prototype.hasRejectListeners=function(){return this.emitter.listeners(o.FAILURE).length>0},o.prototype.onReject=function(t){if(!t)return this;if("function"!=typeof t)throw new TypeError("fn should be a function");return this.on(o.FAILURE,t)},o.prototype.onResolve=function(t){if(this.end(),!t)return this;if("function"!=typeof t)throw new TypeError("fn should be a function");return this.on(o.FAILURE,function(e){t.call(this,e)}),this.on(o.SUCCESS,function(){t.apply(this,i(null,arguments))}),this},o.prototype.then=function(t,e){var r=new o;return"function"==typeof t?this.onFulfill(s(r,t)):this.onFulfill(r.fulfill.bind(r)),"function"==typeof e?this.onReject(s(r,e)):this.onReject(r.reject.bind(r)),r},o.prototype.end=function(t){return this.onReject(t),this.ended=!0,this},o.trace=function(t,e){t.then(function(){console.log("%s fulfill %j",e,n(arguments))},function(){console.log("%s reject %j",e,n(arguments))})},o.prototype.chain=function(t){var e=this;return e.onFulfill(t.fulfill.bind(t)),e.onReject(t.reject.bind(t)),t},o.prototype.all=function(t){var e=new o;return this.then(t).then(function(t){var r,n=0,i=[];return t.length||e.resolve(),t.forEach(function(t,o){r||(n++,t.then(function(t){r||(i[o]=t,--n,0==n&&e.fulfill(i))},function(t){r||(r=t,e.reject(t))}))}),e},e.reject.bind(e)),e},o.hook=function(t){var e=new o,r=new o,n=function(){return--i,0==i&&r.fulfill(),r},i=1,s=e;return t.forEach(function(t){s=s.then(function(){var e=new o;return i++,t(e.resolve.bind(e),n),
7
- e})}),s=s.then(n),e.resolve(),s},o.fulfilled=function(){var t=new o;return t.fulfill.apply(t,arguments),t},o.rejected=function(t){return(new o).reject(t)},o.deferred=function(){var t=new o;return{promise:t,reject:t.reject.bind(t),resolve:t.fulfill.bind(t),callback:t.resolve.bind(t)}}}).call(this,t("FWaASH"))},{FWaASH:55,events:53,util:57}],81:[function(t,e,r){"use strict";function n(){}function i(t){return function(){throw new Error("collection."+t+" not implemented")}}for(var o=["find","findOne","update","remove","count","distinct","findAndModify","aggregate","findStream"],s=0,a=o.length;a>s;++s){var u=o[s];n.prototype[u]=i(u)}e.exports=r=n,n.methods=o},{}],82:[function(t,e,r){"use strict";var n=t("../env");if("unknown"==n.type)throw new Error("Unknown environment");e.exports=t(n.isNode?"./node":n.isMongo?"./collection":"./collection")},{"../env":84,"./collection":81,"./node":83}],83:[function(t,e,r){"use strict";function n(t){this.collection=t,this.collectionName=t.collectionName}var i=t("./collection"),o=t("../utils");o.inherits(n,i),n.prototype.find=function(t,e,r){this.collection.find(t,e,function(t,e){return t?r(t):void e.toArray(r)})},n.prototype.findOne=function(t,e,r){this.collection.findOne(t,e,r)},n.prototype.count=function(t,e,r){this.collection.count(t,e,r)},n.prototype.distinct=function(t,e,r,n){this.collection.distinct(t,e,r,n)},n.prototype.update=function(t,e,r,n){this.collection.update(t,e,r,n)},n.prototype.remove=function(t,e,r){this.collection.remove(t,e,r)},n.prototype.findAndModify=function(t,e,r,n){var i=Array.isArray(r.sort)?r.sort:[];this.collection.findAndModify(t,i,e,r,n)},n.prototype.findStream=function(t,e,r){return this.collection.find(t,e).stream(r)},e.exports=r=n},{"../utils":87,"./collection":81}],84:[function(t,e,r){(function(t,n,i){"use strict";r.isNode="undefined"!=typeof t&&"object"==typeof e&&"object"==typeof n&&"function"==typeof i&&t.argv,r.isMongo=!r.isNode&&"function"==typeof printjson&&"function"==typeof ObjectId&&"function"==typeof rs&&"function"==typeof sh,r.isBrowser=!r.isNode&&!r.isMongo&&"undefined"!=typeof window,r.type=r.isNode?"node":r.isMongo?"mongo":r.isBrowser?"browser":"unknown"}).call(this,t("FWaASH"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{FWaASH:55,buffer:49}],85:[function(t,e,r){"use strict";function n(t,e){if(!(this instanceof n))return new n(t,e);var r=this.constructor.prototype;this.op=r.op||void 0,this.options={},this.setOptions(r.options),this._conditions=r._conditions?u.clone(r._conditions):{},this._fields=r._fields?u.clone(r._fields):void 0,this._update=r._update?u.clone(r._update):void 0,this._path=r._path||void 0,this._distinct=r._distinct||void 0,this._collection=r._collection||void 0,this._traceFunction=r._traceFunction||void 0,e&&this.setOptions(e),t&&(t.find&&t.remove&&t.update?this.collection(t):this.find(t))}function i(t,e,r){if(r&&r.$meta){var n=t.sort||(t.sort={});return void(n[e]={$meta:r.$meta})}var i=String(r||1).toLowerCase();if(!/^(?:ascending|asc|descending|desc|1|-1)$/.test(i))throw u.isArray(r)&&(r="["+r+"]"),new TypeError("Invalid sort value: {"+e+": "+r+" }");var n=t.sort||(t.sort={}),o=r.toString().replace("asc","1").replace("ascending","1").replace("desc","-1").replace("descending","-1");n[e]=parseInt(o,10)}var o=t("sliced"),s=t("assert"),a=t("util"),u=t("./utils"),c=t("debug")("mquery"),f="$geoWithin";Object.defineProperty(n,"use$geoWithin",{get:function(){return"$geoWithin"==f},set:function(t){f=!0===t?"$geoWithin":"$within"}}),n.prototype.toConstructor=function(){function t(e,r){return this instanceof t?void n.call(this,e,r):new t(e,r)}u.inherits(t,n);var e=t.prototype;return e.options={},e.setOptions(this.options),e.op=this.op,e._conditions=u.clone(this._conditions),e._fields=u.clone(this._fields),e._update=u.clone(this._update),e._path=this._path,e._distinct=this._distinct,e._collection=this._collection,e._traceFunction=this._traceFunction,t},n.prototype.setOptions=function(t){if(!t||!u.isObject(t))return this;for(var e,r=u.keys(t),n=0;n<r.length;++n)if(e=r[n],"function"==typeof this[e]){var i=u.isArray(t[e])?t[e]:[t[e]];this[e].apply(this,i)}else this.options[e]=t[e];return this},n.prototype.collection=function(t){return this._collection=new n.Collection(t),this},n.prototype.$where=function(t){return this._conditions.$where=t,this},n.prototype.where=function(){if(!arguments.length)return this;this.op||(this.op="find");var t=typeof arguments[0];if("string"==t)return this._path=arguments[0],2===arguments.length&&(this._conditions[this._path]=arguments[1]),this;if("object"==t&&!Array.isArray(arguments[0]))return this.merge(arguments[0]);throw new TypeError("path must be a string or object")},n.prototype.equals=function(t){this._ensurePath("equals");var e=this._path;return this._conditions[e]=t,this},n.prototype.or=function t(e){var t=this._conditions.$or||(this._conditions.$or=[]);return u.isArray(e)||(e=[e]),t.push.apply(t,e),this},n.prototype.nor=function t(e){var t=this._conditions.$nor||(this._conditions.$nor=[]);return u.isArray(e)||(e=[e]),t.push.apply(t,e),this},n.prototype.and=function t(e){var t=this._conditions.$and||(this._conditions.$and=[]);return Array.isArray(e)||(e=[e]),t.push.apply(t,e),this},"gt gte lt lte ne in nin all regex size maxDistance".split(" ").forEach(function(t){n.prototype[t]=function(){var e,r;1===arguments.length?(this._ensurePath(t),r=arguments[0],e=this._path):(r=arguments[1],e=arguments[0]);var n=this._conditions[e]||(this._conditions[e]={});return n["$"+t]=r,this}}),n.prototype.mod=function(){var t,e;1===arguments.length?(this._ensurePath("mod"),t=arguments[0],e=this._path):2!==arguments.length||u.isArray(arguments[1])?3===arguments.length?(t=o(arguments,1),e=arguments[0]):(t=arguments[1],e=arguments[0]):(this._ensurePath("mod"),t=o(arguments),e=this._path);var r=this._conditions[e]||(this._conditions[e]={});return r.$mod=t,this},n.prototype.exists=function(){var t,e;0===arguments.length?(this._ensurePath("exists"),t=this._path,e=!0):1===arguments.length?"boolean"==typeof arguments[0]?(this._ensurePath("exists"),t=this._path,e=arguments[0]):(t=arguments[0],e=!0):2===arguments.length&&(t=arguments[0],e=arguments[1]);var r=this._conditions[t]||(this._conditions[t]={});return r.$exists=e,this},n.prototype.elemMatch=function(){if(null==arguments[0])throw new TypeError("Invalid argument");var t,e,r;if("function"==typeof arguments[0])this._ensurePath("elemMatch"),e=this._path,t=arguments[0];else if(u.isObject(arguments[0]))this._ensurePath("elemMatch"),e=this._path,r=arguments[0];else if("function"==typeof arguments[1])e=arguments[0],t=arguments[1];else{if(!arguments[1]||!u.isObject(arguments[1]))throw new TypeError("Invalid argument");e=arguments[0],r=arguments[1]}t&&(r=new n,t(r),r=r._conditions);var i=this._conditions[e]||(this._conditions[e]={});return i.$elemMatch=r,this},n.prototype.within=function(){if(this._ensurePath("within"),this._geoComparison=f,0===arguments.length)return this;if(2===arguments.length)return this.box.apply(this,arguments);if(2<arguments.length)return this.polygon.apply(this,arguments);var t=arguments[0];if(!t)throw new TypeError("Invalid argument");if(t.center)return this.circle(t);if(t.box)return this.box.apply(this,t.box);if(t.polygon)return this.polygon.apply(this,t.polygon);if(t.type&&t.coordinates)return this.geometry(t);throw new TypeError("Invalid argument")},n.prototype.box=function(){var t,e;if(3===arguments.length)t=arguments[0],e=[arguments[1],arguments[2]];else{if(2!==arguments.length)throw new TypeError("Invalid argument");this._ensurePath("box"),t=this._path,e=[arguments[0],arguments[1]]}var r=this._conditions[t]||(this._conditions[t]={});return r[this._geoComparison||f]={$box:e},this},n.prototype.polygon=function(){var t,e;"string"==typeof arguments[0]?(e=arguments[0],t=o(arguments,1)):(this._ensurePath("polygon"),e=this._path,t=o(arguments));var r=this._conditions[e]||(this._conditions[e]={});return r[this._geoComparison||f]={$polygon:t},this},n.prototype.circle=function(){var t,e;if(1===arguments.length)this._ensurePath("circle"),t=this._path,e=arguments[0];else{if(2!==arguments.length)throw new TypeError("Invalid argument");t=arguments[0],e=arguments[1]}if(!("radius"in e&&e.center))throw new Error("center and radius are required");var r=this._conditions[t]||(this._conditions[t]={}),n=e.spherical?"$centerSphere":"$center",i=this._geoComparison||f;return r[i]={},r[i][n]=[e.center,e.radius],"unique"in e&&(r[i].$uniqueDocs=!!e.unique),this},n.prototype.near=function(){var t,e;if(this._geoComparison="$near",0===arguments.length)return this;if(1===arguments.length)this._ensurePath("near"),t=this._path,e=arguments[0];else{if(2!==arguments.length)throw new TypeError("Invalid argument");t=arguments[0],e=arguments[1]}if(!e.center)throw new Error("center is required");var r=this._conditions[t]||(this._conditions[t]={}),n=e.spherical?"$nearSphere":"$near";if(Array.isArray(e.center)){r[n]=e.center;var i="maxDistance"in e?e.maxDistance:null;null!=i&&(r.$maxDistance=i)}else{if("Point"!=e.center.type||!Array.isArray(e.center.coordinates))throw new Error(a.format("Invalid GeoJSON specified for %s",n));r[n]={$geometry:e.center},"maxDistance"in e&&(r[n].$maxDistance=e.maxDistance)}return this},n.prototype.intersects=function(){if(this._ensurePath("intersects"),this._geoComparison="$geoIntersects",0===arguments.length)return this;var t=arguments[0];if(null!=t&&t.type&&t.coordinates)return this.geometry(t);throw new TypeError("Invalid argument")},n.prototype.geometry=function(){if("$within"!=this._geoComparison&&"$geoWithin"!=this._geoComparison&&"$near"!=this._geoComparison&&"$geoIntersects"!=this._geoComparison)throw new Error("geometry() must come after `within()`, `intersects()`, or `near()");var t,e;if(1!==arguments.length)throw new TypeError("Invalid argument");if(this._ensurePath("geometry"),e=this._path,t=arguments[0],!t.type||!Array.isArray(t.coordinates))throw new TypeError("Invalid argument");var r=this._conditions[e]||(this._conditions[e]={});return r[this._geoComparison]={$geometry:t},this},n.prototype.select=function(){var t=arguments[0];if(!t)return this;if(1!==arguments.length)throw new Error("Invalid select: select only takes 1 argument");this._validate("select");var e=this._fields||(this._fields={}),r=typeof t;if("string"==r||"object"==r&&"number"==typeof t.length&&!Array.isArray(t)){"string"==r&&(t=t.split(/\s+/));for(var n=0,i=t.length;i>n;++n){var o=t[n];if(o){var s="-"==o[0]?0:1;0===s&&(o=o.substring(1)),e[o]=s}}return this}if(u.isObject(t)&&!Array.isArray(t)){for(var a=u.keys(t),n=0;n<a.length;++n)e[a[n]]=t[a[n]];return this}throw new TypeError("Invalid select() argument. Must be string or object.")},n.prototype.slice=function(){if(0===arguments.length)return this;this._validate("slice");var t,e;if(1===arguments.length){var r=arguments[0];if("object"==typeof r&&!Array.isArray(r)){for(var n=Object.keys(r),i=n.length,s=0;i>s;++s)this.slice(n[s],r[n[s]]);return this}this._ensurePath("slice"),t=this._path,e=arguments[0]}else 2===arguments.length?"number"==typeof arguments[0]?(this._ensurePath("slice"),t=this._path,e=o(arguments)):(t=arguments[0],e=arguments[1]):3===arguments.length&&(t=arguments[0],e=o(arguments,1));var a=this._fields||(this._fields={});return a[t]={$slice:e},this},n.prototype.sort=function(t){if(!t)return this;this._validate("sort");var e=typeof t;if(1===arguments.length&&"string"==e){t=t.split(/\s+/);for(var r=0,n=t.length;n>r;++r){var o=t[r];if(o){var s="-"==o[0]?-1:1;-1===s&&(o=o.substring(1)),i(this.options,o,s)}}return this}if(u.isObject(t)){for(var a=u.keys(t),r=0;r<a.length;++r){var o=a[r];i(this.options,o,t[o])}return this}throw new TypeError("Invalid sort() argument. Must be a string or object.")},["limit","skip","maxScan","batchSize","comment"].forEach(function(t){n.prototype[t]=function(e){return this._validate(t),this.options[t]=e,this}}),n.prototype.maxTime=function(t){return this._validate("maxTime"),this.options.maxTimeMS=t,this},n.prototype.snapshot=function(){return this._validate("snapshot"),this.options.snapshot=arguments.length?!!arguments[0]:!0,this},n.prototype.hint=function(){if(0===arguments.length)return this;this._validate("hint");var t=arguments[0];if(u.isObject(t)){var e=this.options.hint||(this.options.hint={});for(var r in t)e[r]=t[r];return this}throw new TypeError("Invalid hint. "+t)},n.prototype.slaveOk=function(t){return this.options.slaveOk=arguments.length?!!t:!0,this},n.prototype.read=function(t){return arguments.length>1&&!n.prototype.read.deprecationWarningIssued&&(console.error("Deprecation warning: 'tags' argument is not supported anymore in Query.read() method. Please use mongodb.ReadPreference object instead."),n.prototype.read.deprecationWarningIssued=!0),this.options.readPreference=u.readPref(t),this},n.prototype.tailable=function(){return this._validate("tailable"),this.options.tailable=arguments.length?!!arguments[0]:!0,this},n.prototype.merge=function(t){if(!t)return this;if(!n.canMerge(t))throw new TypeError("Invalid argument. Expected instanceof mquery or plain object");return t instanceof n?(t._conditions&&u.merge(this._conditions,t._conditions),t._fields&&(this._fields||(this._fields={}),u.merge(this._fields,t._fields)),t.options&&(this.options||(this.options={}),u.merge(this.options,t.options)),t._update&&(this._update||(this._update={}),u.mergeClone(this._update,t._update)),t._distinct&&(this._distinct=t._distinct),this):(u.merge(this._conditions,t),this)},n.prototype.find=function(t,e){if(this.op="find","function"==typeof t?(e=t,t=void 0):n.canMerge(t)&&this.merge(t),!e)return this;var r=this._conditions,i=this._optionsForExec();return i.fields=this._fieldsForExec(),c("find",this._collection.collectionName,r,i),e=this._wrapCallback("find",e,{conditions:r,options:i}),this._collection.find(r,i,u.tick(e)),this},n.prototype.findOne=function(t,e){if(this.op="findOne","function"==typeof t?(e=t,t=void 0):n.canMerge(t)&&this.merge(t),!e)return this;var r=this._conditions,i=this._optionsForExec();return i.fields=this._fieldsForExec(),c("findOne",this._collection.collectionName,r,i),e=this._wrapCallback("findOne",e,{conditions:r,options:i}),this._collection.findOne(r,i,u.tick(e)),this},n.prototype.count=function(t,e){if(this.op="count",this._validate(),"function"==typeof t?(e=t,t=void 0):n.canMerge(t)&&this.merge(t),!e)return this;var r=this._conditions,i=this._optionsForExec();return c("count",this._collection.collectionName,r,i),e=this._wrapCallback("count",e,{conditions:r,options:i}),this._collection.count(r,i,u.tick(e)),this},n.prototype.distinct=function(t,e,r){if(this.op="distinct",this._validate(),!r){switch(typeof e){case"function":r=e,"string"==typeof t&&(e=t,t=void 0);break;case"undefined":case"string":break;default:throw new TypeError("Invalid `field` argument. Must be string or function")}switch(typeof t){case"function":r=t,t=e=void 0;break;case"string":e=t,t=void 0}}if("string"==typeof e&&(this._distinct=e),n.canMerge(t)&&this.merge(t),!r)return this;if(!this._distinct)throw new Error("No value for `distinct` has been declared");var i=this._conditions,o=this._optionsForExec();return c("distinct",this._collection.collectionName,i,o),r=this._wrapCallback("distinct",r,{conditions:i,options:o}),this._collection.distinct(this._distinct,i,o,u.tick(r)),this},n.prototype.update=function(t,e,r,i){this.op="update";var o;switch(arguments.length){case 3:"function"==typeof r&&(i=r,r=void 0);break;case 2:"function"==typeof e&&(i=e,e=t,t=void 0);break;case 1:switch(typeof t){case"function":i=t,t=r=e=void 0;break;case"boolean":o=t,t=void 0;break;default:e=t,t=r=void 0}}if(n.canMerge(t)&&this.merge(t),e&&this._mergeUpdate(e),u.isObject(r)&&this.setOptions(r),!o&&!i)return this;if(!this._update||!this.options.overwrite&&0===u.keys(this._update).length)return i&&u.soon(i.bind(null,null,0)),this;r=this._optionsForExec(),i||(r.safe=!1);var t=this._conditions;return e=this._updateForExec(),c("update",this._collection.collectionName,t,e,r),i=this._wrapCallback("update",i,{conditions:t,doc:e,options:r}),this._collection.update(t,e,r,u.tick(i)),this},n.prototype.remove=function(t,e){this.op="remove";var r;if("function"==typeof t?(e=t,t=void 0):n.canMerge(t)?this.merge(t):!0===t&&(r=t,t=void 0),!r&&!e)return this;var i=this._optionsForExec();e||(i.safe=!1);var o=this._conditions;return c("remove",this._collection.collectionName,o,i),e=this._wrapCallback("remove",e,{conditions:o,options:i}),this._collection.remove(o,i,u.tick(e)),this},n.prototype.findOneAndUpdate=function(t,e,r,i){switch(this.op="findOneAndUpdate",this._validate(),arguments.length){case 3:"function"==typeof r&&(i=r,r={});break;case 2:"function"==typeof e&&(i=e,e=t,t=void 0),r=void 0;break;case 1:"function"==typeof t?(i=t,t=r=e=void 0):(e=t,t=r=void 0)}return n.canMerge(t)&&this.merge(t),e&&this._mergeUpdate(e),r&&this.setOptions(r),i?this._findAndModify("update",i):this},n.prototype.findOneAndRemove=function(t,e,r){return this.op="findOneAndRemove",this._validate(),"function"==typeof e?(r=e,e=void 0):"function"==typeof t&&(r=t,t=void 0),n.canMerge(t)&&this.merge(t),e&&this.setOptions(e),r?this._findAndModify("remove",r):this},n.prototype._findAndModify=function(t,e){s.equal("function",typeof e);var r,n,i=this._optionsForExec();if("remove"==t)i.remove=!0;else if("new"in i||(i.new=!0),"upsert"in i||(i.upsert=!1),n=this._updateForExec(),!n){if(!i.upsert)return this.findOne(e);n={$set:{}}}var r=this._fieldsForExec();r&&(i.fields=r);var o=this._conditions;return c("findAndModify",this._collection.collectionName,o,n,i),e=this._wrapCallback("findAndModify",e,{conditions:o,doc:n,options:i}),this._collection.findAndModify(o,n,i,u.tick(e)),this},n.prototype._wrapCallback=function(t,e,r){var i=this._traceFunction||n.traceFunction;if(i){r.collectionName=this._collection.collectionName;var o=i&&i.call(null,t,r,this),s=(new Date).getTime();return function(t,r){if(o){var n=(new Date).getTime()-s;o.call(null,t,r,n)}e&&e.apply(null,arguments)}}return e},n.prototype.setTraceFunction=function(t){return this._traceFunction=t,this},n.prototype.exec=function(t,e){switch(typeof t){case"function":e=t,t=null;break;case"string":this.op=t}s.ok(this.op,"Missing query type: (find, update, etc)"),("update"==this.op||"remove"==this.op)&&(e||(e=!0)),this[this.op](e)},n.prototype.thunk=function(){var t=this;return function(e){t.exec(e)}},n.prototype.then=function(t,e){var r=this,i=new n.Promise(function(t,e){r.exec(function(n,i){n?e(n):t(i),r=t=e=null})});return i.then(t,e)},n.prototype.stream=function(t){if("find"!=this.op)throw new Error("stream() is only available for find");var e=this._conditions,r=this._optionsForExec();return r.fields=this._fieldsForExec(),c("stream",this._collection.collectionName,e,r,t),this._collection.findStream(e,r,t)},n.prototype.selected=function(){return!!(this._fields&&Object.keys(this._fields).length>0)},n.prototype.selectedInclusively=function(){if(!this._fields)return!1;var t=Object.keys(this._fields);if(0===t.length)return!1;for(var e=0;e<t.length;++e){var r=t[e];if(0===this._fields[r])return!1;if(this._fields[r]&&"object"==typeof this._fields[r]&&this._fields[r].$meta)return!1}return!0},n.prototype.selectedExclusively=function(){if(!this._fields)return!1;var t=Object.keys(this._fields);if(0===t.length)return!1;for(var e=0;e<t.length;++e){var r=t[e];if(0===this._fields[r])return!0}return!1},n.prototype._mergeUpdate=function(t){this._update||(this._update={}),t instanceof n?t._update&&u.mergeClone(this._update,t._update):u.mergeClone(this._update,t)},n.prototype._optionsForExec=function(){var t=u.clone(this.options,{retainKeyOrder:!0});return t},n.prototype._fieldsForExec=function(){return u.clone(this._fields,{retainKeyOrder:!0})},n.prototype._updateForExec=function(){for(var t=u.clone(this._update,{retainKeyOrder:!0}),e=u.keys(t),r=e.length,n={};r--;){var i=e[r];this.options.overwrite?n[i]=t[i]:"$"!==i[0]?(n.$set||(t.$set?n.$set=t.$set:n.$set={}),n.$set[i]=t[i],e.splice(r,1),~e.indexOf("$set")||e.push("$set")):"$set"===i?n.$set||(n[i]=t[i]):n[i]=t[i]}return n},n.prototype._ensurePath=function(t){if(!this._path){var e=t+"() must be used after where() when called with these arguments";throw new Error(e)}},n.permissions=t("./permissions"),n._isPermitted=function(t,e){var r=n.permissions[e];return r?!0!==r[t]:!0},n.prototype._validate=function(t){var e,r;if(void 0===t){if(r=n.permissions[this.op],"function"!=typeof r)return!0;e=r(this)}else n._isPermitted(t,this.op)||(e=t);if(e)throw new Error(e+" cannot be used with "+this.op)},n.canMerge=function(t){return t instanceof n||u.isObject(t)},n.setGlobalTraceFunction=function(t){n.traceFunction=t},n.utils=u,n.env=t("./env"),n.Collection=t("./collection"),n.BaseCollection=t("./collection/collection"),n.Promise=t("bluebird"),e.exports=r=n},{"./collection":82,"./collection/collection":81,"./env":84,"./permissions":86,"./utils":87,assert:48,bluebird:88,debug:89,sliced:94,util:57}],86:[function(t,e,r){"use strict";var n=r;n.distinct=function(t){if(t._fields&&Object.keys(t._fields).length>0)return"field selection and slice";var e,r=Object.keys(n.distinct);return r.every(function(r){return t.options[r]?(e=r,!1):!0}),e},n.distinct.select=n.distinct.slice=n.distinct.sort=n.distinct.limit=n.distinct.skip=n.distinct.batchSize=n.distinct.comment=n.distinct.maxScan=n.distinct.snapshot=n.distinct.hint=n.distinct.tailable=!0,n.findOneAndUpdate=n.findOneAndRemove=function(t){var e,r=Object.keys(n.findOneAndUpdate);return r.every(function(r){return t.options[r]?(e=r,!1):!0}),e},n.findOneAndUpdate.limit=n.findOneAndUpdate.skip=n.findOneAndUpdate.batchSize=n.findOneAndUpdate.maxScan=n.findOneAndUpdate.snapshot=n.findOneAndUpdate.hint=n.findOneAndUpdate.tailable=n.findOneAndUpdate.comment=!0,n.count=function(t){if(t._fields&&Object.keys(t._fields).length>0)return"field selection and slice";var e,r=Object.keys(n.count);return r.every(function(r){return t.options[r]?(e=r,!1):!0}),e},n.count.select=n.count.slice=n.count.sort=n.count.batchSize=n.count.comment=n.count.maxScan=n.count.snapshot=n.count.tailable=!0},{}],87:[function(t,e,r){(function(e,n){"use strict";function i(t){function e(){}if(arguments.length>1)throw new Error("Adding properties is not supported");return e.prototype=t,new e}var o=t("regexp-clone"),s=r.clone=function t(e,n){if(void 0===e||null===e)return e;if(Array.isArray(e))return r.cloneArray(e,n);if(e.constructor){if(/ObjectI[dD]$/.test(e.constructor.name))return"function"==typeof e.clone?e.clone():new e.constructor(e.id);if("ReadPreference"===e._type&&e.isValid&&e.toObject)return"function"==typeof e.clone?e.clone():new e.constructor(e.mode,t(e.tags,n));if("Binary"==e._bsontype&&e.buffer&&e.value)return"function"==typeof e.clone?e.clone():new e.constructor(e.value(!0),e.sub_type);if("Date"===e.constructor.name||"Function"===e.constructor.name)return new e.constructor(+e);if("RegExp"===e.constructor.name)return o(e);if("Buffer"===e.constructor.name)return r.cloneBuffer(e)}return u(e)?r.cloneObject(e,n):e.valueOf?e.valueOf():void 0};r.cloneObject=function(t,e){var r,n,i,o,a,u=e&&e.retainKeyOrder,c=e&&e.minimize,f={};if(u)for(o in t)i=s(t[o],e),c&&"undefined"==typeof i||(r||(r=!0),f[o]=i);else for(n=Object.keys(t),a=n.length;a--;)o=n[a],i=s(t[o],e),c&&"undefined"==typeof i||(r||(r=!0),f[o]=i);return c?r&&f:f},r.cloneArray=function(t,e){for(var r=[],n=0,i=t.length;i>n;n++)r.push(s(t[n],e));return r},r.tick=function(t){return"function"==typeof t?function(){var e=arguments;c(function(){t.apply(this,e)})}:void 0},r.merge=function t(e,n){for(var i,o=Object.keys(n),s=o.length;s--;)i=o[s],"undefined"==typeof e[i]?e[i]=n[i]:r.isObject(n[i])?t(e[i],n[i]):e[i]=n[i]},r.mergeClone=function t(e,n){for(var i,o=Object.keys(n),a=o.length;a--;)i=o[a],"undefined"==typeof e[i]?e[i]=s(n[i],{retainKeyOrder:1}):r.isObject(n[i])?t(e[i],n[i]):e[i]=s(n[i],{retainKeyOrder:1})};r.readPref=function(t){switch(t){case"p":t="primary";break;case"pp":t="primaryPreferred";break;case"s":t="secondary";break;case"sp":t="secondaryPreferred";break;case"n":t="nearest"}return t};var a=Object.prototype.toString,u=(r.toString=function(t){return a.call(t)},r.isObject=function(t){return"[object Object]"==r.toString(t)});r.isArray=function(t){return Array.isArray(t)||"object"==typeof t&&"[object Array]"==r.toString(t)};r.keys=Object.keys||function(t){var e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(r);return e},r.create="function"==typeof Object.create?Object.create:i,r.inherits=function(t,e){t.prototype=r.create(e.prototype),t.prototype.constructor=t};var c=r.soon="function"==typeof setImmediate?setImmediate:e.nextTick;r.cloneBuffer=function(t){var e=new n(t.length);return t.copy(e,0,0,t.length),e}}).call(this,t("FWaASH"),t("buffer").Buffer)},{FWaASH:55,buffer:49,"regexp-clone":93}],88:[function(t,e,r){(function(t,n){!function(t){if("object"==typeof r&&"undefined"!=typeof e)e.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i;"undefined"!=typeof window?i=window:"undefined"!=typeof n?i=n:"undefined"!=typeof self&&(i=self),i.Promise=t()}}(function(){var e,r,i;return function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u="function"==typeof _dereq_&&_dereq_;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=r[s]={exports:{}};e[s][0].call(f.exports,function(t){var r=e[s][1][t];return i(r?r:t)},f,f.exports,t,e,r,n)}return r[s].exports}for(var o="function"==typeof _dereq_&&_dereq_,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(t,e,r){"use strict";e.exports=function(t){function e(t){var e=new r(t),n=e.promise();return e.setHowMany(1),e.setUnwrap(),e.init(),n}var r=t._SomePromiseArray;t.any=function(t){return e(t)},t.prototype.any=function(){return e(this)}}},{}],2:[function(t,e,r){"use strict";function n(){this._isTickUsed=!1,this._lateQueue=new c(16),this._normalQueue=new c(16),this._trampolineEnabled=!0;var t=this;this.drainQueues=function(){t._drainQueues()},this._schedule=u.isStatic?u(this.drainQueues):u}function i(t,e,r){var n=this._getDomain();void 0!==n&&(t=n.bind(t)),this._lateQueue.push(t,e,r),this._queueTick()}function o(t,e,r){var n=this._getDomain();void 0!==n&&(t=n.bind(t)),this._normalQueue.push(t,e,r),this._queueTick()}function s(t){var e=this._getDomain();if(void 0!==e){var r=e.bind(t._settlePromises);this._normalQueue.push(r,t,void 0)}else this._normalQueue._pushOne(t);this._queueTick()}var a;try{throw new Error}catch(t){a=t}var u=t("./schedule.js"),c=t("./queue.js"),f=t("./util.js");n.prototype.disableTrampolineIfNecessary=function(){f.hasDevTools&&(this._trampolineEnabled=!1)},n.prototype.enableTrampoline=function(){this._trampolineEnabled||(this._trampolineEnabled=!0,this._schedule=function(t){setTimeout(t,0)})},n.prototype.haveItemsQueued=function(){return this._normalQueue.length()>0},n.prototype.throwLater=function(t,e){1===arguments.length&&(e=t,t=function(){throw e});var r=this._getDomain();if(void 0!==r&&(t=r.bind(t)),"undefined"!=typeof setTimeout)setTimeout(function(){t(e)},0);else try{this._schedule(function(){t(e)})}catch(t){throw new Error("No async scheduler available\n\n See http://goo.gl/m3OTXk\n")}},n.prototype._getDomain=function(){};f.hasDevTools?(n.prototype.invokeLater=function(t,e,r){this._trampolineEnabled?i.call(this,t,e,r):setTimeout(function(){t.call(e,r)},100)},n.prototype.invoke=function(t,e,r){this._trampolineEnabled?o.call(this,t,e,r):setTimeout(function(){t.call(e,r)},0)},n.prototype.settlePromises=function(t){this._trampolineEnabled?s.call(this,t):setTimeout(function(){t._settlePromises()},0)}):(n.prototype.invokeLater=i,n.prototype.invoke=o,n.prototype.settlePromises=s),n.prototype.invokeFirst=function(t,e,r){var n=this._getDomain();void 0!==n&&(t=n.bind(t)),this._normalQueue.unshift(t,e,r),this._queueTick()},n.prototype._drainQueue=function(t){for(;t.length()>0;){var e=t.shift();if("function"==typeof e){var r=t.shift(),n=t.shift();e.call(r,n)}else e._settlePromises()}},n.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._drainQueue(this._lateQueue)},n.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},n.prototype._reset=function(){this._isTickUsed=!1},e.exports=new n,e.exports.firstLineError=a},{"./queue.js":28,"./schedule.js":31,"./util.js":38,events:39}],3:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n=function(t,e){this._reject(e)},i=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(n,n,null,this,t)},o=function(t,e){this._setBoundTo(t),this._isPending()&&this._resolveCallback(e.target)},s=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(n){var a=r(n),u=new t(e);u._propagateFrom(this,1);var c=this._target();if(a instanceof t){var f={promiseRejectionQueued:!1,promise:u,target:c,bindingPromise:a};c._then(e,i,u._progress,u,f),a._then(o,s,u._progress,u,f)}else u._setBoundTo(n),u._resolveCallback(c);return u},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=131072|this._bitField,this._boundTo=t):this._bitField=-131073&this._bitField},t.prototype._isBound=function(){return 131072===(131072&this._bitField)},t.bind=function(n,i){var o=r(n),s=new t(e);return o instanceof t?o._then(function(t){s._setBoundTo(t),s._resolveCallback(i)},s._reject,s._progress,s,null):(s._setBoundTo(n),s._resolveCallback(i)),s}}},{}],4:[function(t,e,r){"use strict";function n(){try{Promise===o&&(Promise=i)}catch(t){}return o}var i;"undefined"!=typeof Promise&&(i=Promise);var o=t("./promise.js")();o.noConflict=n,e.exports=o},{"./promise.js":23}],5:[function(t,e,r){"use strict";var n=Object.create;if(n){var i=n(null),o=n(null);i[" size"]=o[" size"]=0}e.exports=function(e){function r(t,r){var n;if(null!=t&&(n=t[r]),"function"!=typeof n){var i="Object "+a.classString(t)+" has no method '"+a.toString(r)+"'";throw new e.TypeError(i)}return n}function n(t){var e=this.pop(),n=r(t,e);return n.apply(t,this)}function i(t){return t[this]}function o(t){var e=+this;return 0>e&&(e=Math.max(0,e+t.length)),t[e]}var s,a=t("./util.js"),u=a.canEvaluate;a.isIdentifier;e.prototype.call=function(t){for(var e=arguments.length,r=new Array(e-1),i=1;e>i;++i)r[i-1]=arguments[i];return r.push(t),this._then(n,void 0,void 0,r,void 0)},e.prototype.get=function(t){var e,r="number"==typeof t;if(r)e=o;else if(u){var n=s(t);e=null!==n?n:i}else e=i;return this._then(e,void 0,void 0,t,void 0)}}},{"./util.js":38}],6:[function(t,e,r){"use strict";e.exports=function(e){var r=t("./errors.js"),n=t("./async.js"),i=r.CancellationError;e.prototype._cancel=function(t){if(!this.isCancellable())return this;for(var e,r=this;void 0!==(e=r._cancellationParent)&&e.isCancellable();)r=e;this._unsetCancellable(),r._target()._rejectCallback(t,!1,!0)},e.prototype.cancel=function(t){return this.isCancellable()?(void 0===t&&(t=new i),n.invokeLater(this._cancel,this,t),this):this},e.prototype.cancellable=function(){return this._cancellable()?this:(n.enableTrampoline(),this._setCancellable(),this._cancellationParent=void 0,this)},e.prototype.uncancellable=function(){var t=this.then();return t._unsetCancellable(),t},e.prototype.fork=function(t,e,r){var n=this._then(t,e,r,void 0,void 0);return n._setCancellable(),n._cancellationParent=void 0,n}}},{"./async.js":2,"./errors.js":13}],7:[function(e,r,n){"use strict";r.exports=function(){function r(t){this._parent=t;var e=this._length=1+(void 0===t?0:t._length);w(this,r),e>32&&this.uncycle()}function n(t,e){for(var r=0;r<e.length-1;++r)e[r].push("From previous event:"),e[r]=e[r].join("\n");return r<e.length&&(e[r]=e[r].join("\n")),t+"\n"+e.join("\n")}function i(t){for(var e=0;e<t.length;++e)(0===t[e].length||e+1<t.length&&t[e][0]===t[e+1][0])&&(t.splice(e,1),e--)}function o(t){for(var e=t[0],r=1;r<t.length;++r){for(var n=t[r],i=e.length-1,o=e[i],s=-1,a=n.length-1;a>=0;--a)if(n[a]===o){s=a;break}for(var a=s;a>=0;--a){var u=n[a];if(e[i]!==u)break;e.pop(),i--}e=n}}function s(t){
8
- for(var e=[],r=0;r<t.length;++r){var n=t[r],i=_.test(n)||" (No stack trace)"===n,o=i&&g(n);i&&!o&&(v&&" "!==n.charAt(0)&&(n=" "+n),e.push(n))}return e}function a(t){for(var e=t.stack.replace(/\s+$/g,"").split("\n"),r=0;r<e.length;++r){var n=e[r];if(" (No stack trace)"===n||_.test(n))break}return r>0&&(e=e.slice(r)),e}function u(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t.toString();var r=/\[object [a-zA-Z0-9$_]+\]/;if(r.test(e))try{var n=JSON.stringify(t);e=n}catch(t){}0===e.length&&(e="(empty array)")}return"(<"+c(e)+">, no stack trace)"}function c(t){var e=41;return t.length<e?t:t.substr(0,e-3)+"..."}function f(t){var e=t.match(m);return e?{fileName:e[1],line:parseInt(e[2],10)}:void 0}var h,l=e("./async.js"),p=e("./util.js"),d=/[\\\/]bluebird[\\\/]js[\\\/](main|debug|zalgo|instrumented)/,_=null,y=null,v=!1;p.inherits(r,Error),r.prototype.uncycle=function(){var t=this._length;if(!(2>t)){for(var e=[],r={},n=0,i=this;void 0!==i;++n)e.push(i),i=i._parent;t=this._length=n;for(var n=t-1;n>=0;--n){var o=e[n].stack;void 0===r[o]&&(r[o]=n)}for(var n=0;t>n;++n){var s=e[n].stack,a=r[s];if(void 0!==a&&a!==n){a>0&&(e[a-1]._parent=void 0,e[a-1]._length=1),e[n]._parent=void 0,e[n]._length=1;var u=n>0?e[n-1]:this;t-1>a?(u._parent=e[a+1],u._parent.uncycle(),u._length=u._parent._length+1):(u._parent=void 0,u._length=1);for(var c=u._length+1,f=n-2;f>=0;--f)e[f]._length=c,c++;return}}}},r.prototype.parent=function(){return this._parent},r.prototype.hasParent=function(){return void 0!==this._parent},r.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var e=r.parseStackAndMessage(t),a=e.message,u=[e.stack],c=this;void 0!==c;)u.push(s(c.stack.split("\n"))),c=c._parent;o(u),i(u),p.notEnumerableProp(t,"stack",n(a,u)),p.notEnumerableProp(t,"__stackCleaned__",!0)}},r.parseStackAndMessage=function(t){var e=t.stack,r=t.toString();return e="string"==typeof e&&e.length>0?a(t):[" (No stack trace)"],{message:r,stack:s(e)}},r.formatAndLogError=function(t,e){if("undefined"!=typeof console){var r;if("object"==typeof t||"function"==typeof t){var n=t.stack;r=e+y(n,t)}else r=e+String(t);"function"==typeof h?h(r):("function"==typeof console.log||"object"==typeof console.log)&&console.log(r)}},r.unhandledRejection=function(t){r.formatAndLogError(t,"^--- With additional stack trace: ")},r.isSupported=function(){return"function"==typeof w},r.fireRejectionEvent=function(t,e,n,i){var o=!1;try{"function"==typeof e&&(o=!0,"rejectionHandled"===t?e(i):e(n,i))}catch(t){l.throwLater(t)}var s=!1;try{s=E(t,n,i)}catch(t){s=!0,l.throwLater(t)}var a=!1;if(b)try{a=b(t.toLowerCase(),{reason:n,promise:i})}catch(t){a=!0,l.throwLater(t)}s||o||a||"unhandledRejection"!==t||r.formatAndLogError(n,"Unhandled rejection ")};var g=function(){return!1},m=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;r.setBounds=function(t,e){if(r.isSupported()){for(var n,i,o=t.stack.split("\n"),s=e.stack.split("\n"),a=-1,u=-1,c=0;c<o.length;++c){var h=f(o[c]);if(h){n=h.fileName,a=h.line;break}}for(var c=0;c<s.length;++c){var h=f(s[c]);if(h){i=h.fileName,u=h.line;break}}0>a||0>u||!n||!i||n!==i||a>=u||(g=function(t){if(d.test(t))return!0;var e=f(t);return e&&e.fileName===n&&a<=e.line&&e.line<=u?!0:!1})}};var b,w=function(){var t=/^\s*at\s*/,e=function(t,e){return"string"==typeof t?t:void 0!==e.name&&void 0!==e.message?e.toString():u(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit=Error.stackTraceLimit+6,_=t,y=e;var r=Error.captureStackTrace;return g=function(t){return d.test(t)},function(t,e){Error.stackTraceLimit=Error.stackTraceLimit+6,r(t,e),Error.stackTraceLimit=Error.stackTraceLimit-6}}var n=new Error;if("string"==typeof n.stack&&n.stack.split("\n")[0].indexOf("stackDetection@")>=0)return _=/@/,y=e,v=!0,function(t){t.stack=(new Error).stack};var i;try{throw new Error}catch(t){i="stack"in t}return"stack"in n||!i?(y=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?u(e):e.toString()},null):(_=t,y=e,function(t){Error.stackTraceLimit=Error.stackTraceLimit+6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit=Error.stackTraceLimit-6})}([]),E=function(){if(p.isNode)return function(e,r,n){return"rejectionHandled"===e?t.emit(e,n):t.emit(e,r,n)};var e=!1,r=!0;try{var n=new self.CustomEvent("test");e=n instanceof CustomEvent}catch(t){}if(!e)try{var i=document.createEvent("CustomEvent");i.initCustomEvent("testingtheevent",!1,!0,{}),self.dispatchEvent(i)}catch(t){r=!1}r&&(b=function(t,r){var n;return e?n=new self.CustomEvent(t,{detail:r,bubbles:!1,cancelable:!0}):self.dispatchEvent&&(n=document.createEvent("CustomEvent"),n.initCustomEvent(t,!1,!0,r)),n?!self.dispatchEvent(n):!1});var o={};return o.unhandledRejection="onunhandledRejection".toLowerCase(),o.rejectionHandled="onrejectionHandled".toLowerCase(),function(t,e,r){var n=o[t],i=self[n];return i?("rejectionHandled"===t?i.call(self,r):i.call(self,e,r),!0):!1}}();return"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(h=function(t){console.warn(t)},p.isNode&&t.stderr.isTTY?h=function(e){t.stderr.write(""+e+"\n")}:p.isNode||"string"!=typeof(new Error).stack||(h=function(t){console.warn("%c"+t,"color: red")})),r}},{"./async.js":2,"./util.js":38}],8:[function(t,e,r){"use strict";e.exports=function(e){function r(t,e,r){this._instances=t,this._callback=e,this._promise=r}function n(t,e){var r={},n=s(t).call(r,e);if(n===a)return n;var i=u(r);return i.length?(a.e=new c("Catch filter must inherit from Error or be a simple predicate function\n\n See http://goo.gl/o84o68\n"),a):n}var i=t("./util.js"),o=t("./errors.js"),s=i.tryCatch,a=i.errorObj,u=t("./es5.js").keys,c=o.TypeError;return r.prototype.doFilter=function(t){for(var r=this._callback,i=this._promise,o=i._boundTo,u=0,c=this._instances.length;c>u;++u){var f=this._instances[u],h=f===Error||null!=f&&f.prototype instanceof Error;if(h&&t instanceof f){var l=s(r).call(o,t);return l===a?(e.e=l.e,e):l}if("function"==typeof f&&!h){var p=n(f,t);if(p===a){t=a.e;break}if(p){var l=s(r).call(o,t);return l===a?(e.e=l.e,e):l}}}return e.e=t,e},r}},{"./errors.js":13,"./es5.js":14,"./util.js":38}],9:[function(t,e,r){"use strict";e.exports=function(t,e,r){function n(){this._trace=new e(o())}function i(){return r()?new n:void 0}function o(){var t=s.length-1;return t>=0?s[t]:void 0}var s=[];return n.prototype._pushContext=function(){r()&&void 0!==this._trace&&s.push(this._trace)},n.prototype._popContext=function(){r()&&void 0!==this._trace&&s.pop()},t.prototype._peekContext=o,t.prototype._pushContext=n.prototype._pushContext,t.prototype._popContext=n.prototype._popContext,i}},{}],10:[function(e,r,n){"use strict";r.exports=function(r,n){var i,o,s=e("./async.js"),a=e("./errors.js").Warning,u=e("./util.js"),c=u.canAttachTrace,f=u.isNode&&(!!t.env.BLUEBIRD_DEBUG||"development"===t.env.NODE_ENV);return f&&s.disableTrampolineIfNecessary(),r.prototype._ensurePossibleRejectionHandled=function(){this._setRejectionIsUnhandled(),s.invokeLater(this._notifyUnhandledRejection,this,void 0)},r.prototype._notifyUnhandledRejectionIsHandled=function(){n.fireRejectionEvent("rejectionHandled",i,void 0,this)},r.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._getCarriedStackTrace()||this._settledValue;this._setUnhandledRejectionIsNotified(),n.fireRejectionEvent("unhandledRejection",o,t,this)}},r.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=524288|this._bitField},r.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-524289&this._bitField},r.prototype._isUnhandledRejectionNotified=function(){return(524288&this._bitField)>0},r.prototype._setRejectionIsUnhandled=function(){this._bitField=2097152|this._bitField},r.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-2097153&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},r.prototype._isRejectionUnhandled=function(){return(2097152&this._bitField)>0},r.prototype._setCarriedStackTrace=function(t){this._bitField=1048576|this._bitField,this._fulfillmentHandler0=t},r.prototype._isCarryingStackTrace=function(){return(1048576&this._bitField)>0},r.prototype._getCarriedStackTrace=function(){return this._isCarryingStackTrace()?this._fulfillmentHandler0:void 0},r.prototype._captureStackTrace=function(){return f&&(this._trace=new n(this._peekContext())),this},r.prototype._attachExtraTrace=function(t,e){if(f&&c(t)){var r=this._trace;if(void 0!==r&&e&&(r=r._parent),void 0!==r)r.attachExtraTrace(t);else if(!t.__stackCleaned__){var i=n.parseStackAndMessage(t);u.notEnumerableProp(t,"stack",i.message+"\n"+i.stack.join("\n")),u.notEnumerableProp(t,"__stackCleaned__",!0)}}},r.prototype._warn=function(t){var e=new a(t),r=this._peekContext();if(r)r.attachExtraTrace(e);else{var i=n.parseStackAndMessage(e);e.stack=i.message+"\n"+i.stack.join("\n")}n.formatAndLogError(e,"")},r.onPossiblyUnhandledRejection=function(t){o="function"==typeof t?t:void 0},r.onUnhandledRejectionHandled=function(t){i="function"==typeof t?t:void 0},r.longStackTraces=function(){if(s.haveItemsQueued()&&f===!1)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/DT1qyG\n");f=n.isSupported(),f&&s.disableTrampolineIfNecessary()},r.hasLongStackTraces=function(){return f&&n.isSupported()},n.isSupported()||(r.longStackTraces=function(){},f=!1),function(){return f}}},{"./async.js":2,"./errors.js":13,"./util.js":38}],11:[function(t,e,r){"use strict";var n=t("./util.js"),i=n.isPrimitive,o=n.wrapsPrimitiveReceiver;e.exports=function(t){var e=function(){return this},r=function(){throw this},n=function(){},s=function(){throw void 0},a=function(t,e){return 1===e?function(){throw t}:2===e?function(){return t}:void 0};t.prototype.return=t.prototype.thenReturn=function(t){return void 0===t?this.then(n):o&&i(t)?this._then(a(t,2),void 0,void 0,void 0,void 0):this._then(e,void 0,void 0,t,void 0)},t.prototype.throw=t.prototype.thenThrow=function(t){return void 0===t?this.then(s):o&&i(t)?this._then(a(t,1),void 0,void 0,void 0,void 0):this._then(r,void 0,void 0,t,void 0)}}},{"./util.js":38}],12:[function(t,e,r){"use strict";e.exports=function(t,e){var r=t.reduce;t.prototype.each=function(t){return r(this,t,null,e)},t.each=function(t,n){return r(t,n,null,e)}}},{}],13:[function(t,e,r){"use strict";function n(t,e){function r(n){return this instanceof r?(h(this,"message","string"==typeof n?n:e),h(this,"name",t),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new r(n)}return f(r,Error),r}function i(t){return this instanceof i?(h(this,"name","OperationalError"),h(this,"message",t),this.cause=t,this.isOperational=!0,void(t instanceof Error?(h(this,"message",t.message),h(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new i(t)}var o,s,a=t("./es5.js"),u=a.freeze,c=t("./util.js"),f=c.inherits,h=c.notEnumerableProp,l=n("Warning","warning"),p=n("CancellationError","cancellation error"),d=n("TimeoutError","timeout error"),_=n("AggregateError","aggregate error");try{o=TypeError,s=RangeError}catch(t){o=n("TypeError","type error"),s=n("RangeError","range error")}for(var y="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),v=0;v<y.length;++v)"function"==typeof Array.prototype[y[v]]&&(_.prototype[y[v]]=Array.prototype[y[v]]);a.defineProperty(_.prototype,"length",{value:0,configurable:!1,writable:!0,enumerable:!0}),_.prototype.isOperational=!0;var g=0;_.prototype.toString=function(){var t=Array(4*g+1).join(" "),e="\n"+t+"AggregateError of:\n";g++,t=Array(4*g+1).join(" ");for(var r=0;r<this.length;++r){for(var n=this[r]===this?"[Circular AggregateError]":this[r]+"",i=n.split("\n"),o=0;o<i.length;++o)i[o]=t+i[o];n=i.join("\n"),e+=n+"\n"}return g--,e},f(i,Error);var m=Error.__BluebirdErrorTypes__;m||(m=u({CancellationError:p,TimeoutError:d,OperationalError:i,RejectionError:i,AggregateError:_}),h(Error,"__BluebirdErrorTypes__",m)),e.exports={Error:Error,TypeError:o,RangeError:s,CancellationError:m.CancellationError,OperationalError:m.OperationalError,TimeoutError:m.TimeoutError,AggregateError:m.AggregateError,Warning:l}},{"./es5.js":14,"./util.js":38}],14:[function(t,e,r){var n=function(){"use strict";return void 0===this}();if(n)e.exports={freeze:Object.freeze,defineProperty:Object.defineProperty,getDescriptor:Object.getOwnPropertyDescriptor,keys:Object.keys,names:Object.getOwnPropertyNames,getPrototypeOf:Object.getPrototypeOf,isArray:Array.isArray,isES5:n,propertyIsWritable:function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return!(r&&!r.writable&&!r.set)}};else{var i={}.hasOwnProperty,o={}.toString,s={}.constructor.prototype,a=function(t){var e=[];for(var r in t)i.call(t,r)&&e.push(r);return e},u=function(t,e){return{value:t[e]}},c=function(t,e,r){return t[e]=r.value,t},f=function(t){return t},h=function(t){try{return Object(t).constructor.prototype}catch(t){return s}},l=function(t){try{return"[object Array]"===o.call(t)}catch(t){return!1}};e.exports={isArray:l,keys:a,names:a,defineProperty:c,getDescriptor:u,freeze:f,getPrototypeOf:h,isES5:n,propertyIsWritable:function(){return!0}}}},{}],15:[function(t,e,r){"use strict";e.exports=function(t,e){var r=t.map;t.prototype.filter=function(t,n){return r(this,t,n,e)},t.filter=function(t,n,i){return r(t,n,i,e)}}},{}],16:[function(t,e,r){"use strict";e.exports=function(e,r,n){function i(){return this}function o(){throw this}function s(t){return function(){return t}}function a(t){return function(){throw t}}function u(t,e,r){var n;return n=l&&p(e)?r?s(e):a(e):r?i:o,t._then(n,d,void 0,e,void 0)}function c(t){var i=this.promise,o=this.handler,s=i._isBound()?o.call(i._boundTo):o();if(void 0!==s){var a=n(s,i);if(a instanceof e)return a=a._target(),u(a,t,i.isFulfilled())}return i.isRejected()?(r.e=t,r):t}function f(t){var r=this.promise,i=this.handler,o=r._isBound()?i.call(r._boundTo,t):i(t);if(void 0!==o){var s=n(o,r);if(s instanceof e)return s=s._target(),u(s,t,!0)}return t}var h=t("./util.js"),l=h.wrapsPrimitiveReceiver,p=h.isPrimitive,d=h.thrower;e.prototype._passThroughHandler=function(t,e){if("function"!=typeof t)return this.then();var r={promise:this,handler:t};return this._then(e?c:f,e?c:void 0,void 0,r,void 0)},e.prototype.lastly=e.prototype.finally=function(t){return this._passThroughHandler(t,!0)},e.prototype.tap=function(t){return this._passThroughHandler(t,!1)}}},{"./util.js":38}],17:[function(t,e,r){"use strict";e.exports=function(e,r,n,i){function o(t,r,n){for(var o=0;o<r.length;++o){n._pushContext();var s=h(r[o])(t);if(n._popContext(),s===f){n._pushContext();var a=e.reject(f.e);return n._popContext(),a}var u=i(s,n);if(u instanceof e)return u}return null}function s(t,r,i,o){var s=this._promise=new e(n);s._captureStackTrace(),this._stack=o,this._generatorFunction=t,this._receiver=r,this._generator=void 0,this._yieldHandlers="function"==typeof i?[i].concat(l):l}var a=t("./errors.js"),u=a.TypeError,c=t("./util.js"),f=c.errorObj,h=c.tryCatch,l=[];s.prototype.promise=function(){return this._promise},s.prototype._run=function(){this._generator=this._generatorFunction.call(this._receiver),this._receiver=this._generatorFunction=void 0,this._next(void 0)},s.prototype._continue=function(t){if(t===f)return this._promise._rejectCallback(t.e,!1,!0);var r=t.value;if(t.done===!0)this._promise._resolveCallback(r);else{var n=i(r,this._promise);if(!(n instanceof e)&&(n=o(n,this._yieldHandlers,this._promise),null===n))return void this._throw(new u("A value %s was yielded that could not be treated as a promise\n\n See http://goo.gl/4Y4pDk\n\n".replace("%s",r)+"From coroutine:\n"+this._stack.split("\n").slice(1,-7).join("\n")));n._then(this._next,this._throw,void 0,this,null)}},s.prototype._throw=function(t){this._promise._attachExtraTrace(t),this._promise._pushContext();var e=h(this._generator.throw).call(this._generator,t);this._promise._popContext(),this._continue(e)},s.prototype._next=function(t){this._promise._pushContext();var e=h(this._generator.next).call(this._generator,t);this._promise._popContext(),this._continue(e)},e.coroutine=function(t,e){if("function"!=typeof t)throw new u("generatorFunction must be a function\n\n See http://goo.gl/6Vqhm0\n");var r=Object(e).yieldHandler,n=s,i=(new Error).stack;return function(){var e=t.apply(this,arguments),o=new n(void 0,void 0,r,i);return o._generator=e,o._next(void 0),o.promise()}},e.coroutine.addYieldHandler=function(t){if("function"!=typeof t)throw new u("fn must be a function\n\n See http://goo.gl/916lJJ\n");l.push(t)},e.spawn=function(t){if("function"!=typeof t)return r("generatorFunction must be a function\n\n See http://goo.gl/6Vqhm0\n");var n=new s(t,this),i=n.promise();return n._run(e.spawn),i}}},{"./errors.js":13,"./util.js":38}],18:[function(t,e,r){"use strict";e.exports=function(e,r,n,i){var o=t("./util.js");o.canEvaluate,o.tryCatch,o.errorObj;e.join=function(){var t,e=arguments.length-1;if(e>0&&"function"==typeof arguments[e]){t=arguments[e];var n}for(var i=arguments.length,o=new Array(i),s=0;i>s;++s)o[s]=arguments[s];t&&o.pop();var n=new r(o).promise();return void 0!==t?n.spread(t):n}}},{"./util.js":38}],19:[function(t,e,r){"use strict";e.exports=function(e,r,n,i,o){function s(t,e,r,n){this.constructor$(t),this._promise._captureStackTrace(),this._callback=e,this._preservedValues=n===o?new Array(this.length()):null,this._limit=r,this._inFlight=0,this._queue=r>=1?[]:d,c.invoke(a,this,void 0)}function a(){this._init$(void 0,-2)}function u(t,e,r,n){var i="object"==typeof r&&null!==r?r.concurrency:0;return i="number"==typeof i&&isFinite(i)&&i>=1?i:0,new s(t,e,i,n)}var c=t("./async.js"),f=t("./util.js"),h=f.tryCatch,l=f.errorObj,p={},d=[];f.inherits(s,r),s.prototype._init=function(){},s.prototype._promiseFulfilled=function(t,r){var n=this._values,o=this.length(),s=this._preservedValues,a=this._limit;if(n[r]===p){if(n[r]=t,a>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return}else{if(a>=1&&this._inFlight>=a)return n[r]=t,void this._queue.push(r);null!==s&&(s[r]=t);var u=this._callback,c=this._promise._boundTo;this._promise._pushContext();var f=h(u).call(c,t,r,o);if(this._promise._popContext(),f===l)return this._reject(f.e);var d=i(f,this._promise);if(d instanceof e){if(d=d._target(),d._isPending())return a>=1&&this._inFlight++,n[r]=p,d._proxyPromiseArray(this,r);if(!d._isFulfilled())return this._reject(d._reason());f=d._value()}n[r]=f}var _=++this._totalResolved;_>=o&&(null!==s?this._filter(n,s):this._resolve(n))},s.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,r=this._values;t.length>0&&this._inFlight<e;){if(this._isResolved())return;var n=t.pop();this._promiseFulfilled(r[n],n)}},s.prototype._filter=function(t,e){for(var r=e.length,n=new Array(r),i=0,o=0;r>o;++o)t[o]&&(n[i++]=e[o]);n.length=i,this._resolve(n)},s.prototype.preservedValues=function(){return this._preservedValues},e.prototype.map=function(t,e){return"function"!=typeof t?n("fn must be a function\n\n See http://goo.gl/916lJJ\n"):u(this,t,e,null).promise()},e.map=function(t,e,r,i){return"function"!=typeof e?n("fn must be a function\n\n See http://goo.gl/916lJJ\n"):u(t,e,r,i).promise()}}},{"./async.js":2,"./util.js":38}],20:[function(t,e,r){"use strict";e.exports=function(e,r,n,i){var o=t("./util.js"),s=o.tryCatch;e.method=function(t){if("function"!=typeof t)throw new e.TypeError("fn must be a function\n\n See http://goo.gl/916lJJ\n");return function(){var n=new e(r);n._captureStackTrace(),n._pushContext();var i=s(t).apply(this,arguments);return n._popContext(),n._resolveFromSyncValue(i),n}},e.attempt=e.try=function(t,n,a){if("function"!=typeof t)return i("fn must be a function\n\n See http://goo.gl/916lJJ\n");var u=new e(r);u._captureStackTrace(),u._pushContext();var c=o.isArray(n)?s(t).apply(a,n):s(t).call(a,n);return u._popContext(),u._resolveFromSyncValue(c),u},e.prototype._resolveFromSyncValue=function(t){t===o.errorObj?this._rejectCallback(t.e,!1,!0):this._resolveCallback(t,!0)}}},{"./util.js":38}],21:[function(t,e,r){"use strict";e.exports=function(e){function r(t,e){var r=this;if(!o.isArray(t))return n.call(r,t,e);var i=a(e).apply(r._boundTo,[null].concat(t));i===u&&s.throwLater(i.e)}function n(t,e){var r=this,n=r._boundTo,i=void 0===t?a(e).call(n,null):a(e).call(n,null,t);i===u&&s.throwLater(i.e)}function i(t,e){var r=this;if(!t){var n=r._target(),i=n._getCarriedStackTrace();i.cause=t,t=i}var o=a(e).call(r._boundTo,t);o===u&&s.throwLater(o.e)}var o=t("./util.js"),s=t("./async.js"),a=o.tryCatch,u=o.errorObj;e.prototype.asCallback=e.prototype.nodeify=function(t,e){if("function"==typeof t){var o=n;void 0!==e&&Object(e).spread&&(o=r),this._then(o,i,void 0,this,t)}return this}}},{"./async.js":2,"./util.js":38}],22:[function(t,e,r){"use strict";e.exports=function(e,r){var n=t("./util.js"),i=t("./async.js"),o=n.tryCatch,s=n.errorObj;e.prototype.progressed=function(t){return this._then(void 0,void 0,t,void 0,void 0)},e.prototype._progress=function(t){this._isFollowingOrFulfilledOrRejected()||this._target()._progressUnchecked(t)},e.prototype._progressHandlerAt=function(t){return 0===t?this._progressHandler0:this[(t<<2)+t-5+2]},e.prototype._doProgressWith=function(t){var r=t.value,i=t.handler,a=t.promise,u=t.receiver,c=o(i).call(u,r);if(c===s){if(null!=c.e&&"StopProgressPropagation"!==c.e.name){var f=n.canAttachTrace(c.e)?c.e:new Error(n.toString(c.e));a._attachExtraTrace(f),a._progress(c.e)}}else c instanceof e?c._then(a._progress,null,null,a,void 0):a._progress(c)},e.prototype._progressUnchecked=function(t){for(var n=this._length(),o=this._progress,s=0;n>s;s++){var a=this._progressHandlerAt(s),u=this._promiseAt(s);if(u instanceof e)"function"==typeof a?i.invoke(this._doProgressWith,this,{handler:a,promise:u,receiver:this._receiverAt(s),value:t}):i.invoke(o,u,t);else{var c=this._receiverAt(s);"function"==typeof a?a.call(c,t,u):c instanceof r&&!c._isResolved()&&c._promiseProgressed(t,u)}}}}},{"./async.js":2,"./util.js":38}],23:[function(t,e,r){"use strict";e.exports=function(){function e(t){if("function"!=typeof t)throw new c("the promise constructor requires a resolver function\n\n See http://goo.gl/EC22Yn\n");if(this.constructor!==e)throw new c("the promise constructor cannot be invoked directly\n\n See http://goo.gl/KsIlge\n");this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._progressHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,this._settledValue=void 0,t!==f&&this._resolveFromResolver(t)}function r(t){var r=new e(f);r._fulfillmentHandler0=t,r._rejectionHandler0=t,r._progressHandler0=t,r._promise0=t,r._receiver0=t,r._settledValue=t}var n=function(){return new c("circular promise resolution chain\n\n See http://goo.gl/LhFpo0\n")},i=function(){return new e.PromiseInspection(this._target())},o=function(t){return e.reject(new c(t))},s=t("./util.js"),a=t("./async.js"),u=t("./errors.js"),c=e.TypeError=u.TypeError;e.RangeError=u.RangeError,e.CancellationError=u.CancellationError,e.TimeoutError=u.TimeoutError,e.OperationalError=u.OperationalError,e.RejectionError=u.OperationalError,e.AggregateError=u.AggregateError;var f=function(){},h={},l={e:null},p=t("./thenables.js")(e,f),d=t("./promise_array.js")(e,f,p,o),_=t("./captured_trace.js")(),y=t("./debuggability.js")(e,_),v=t("./context.js")(e,_,y),g=t("./catch_filter.js")(l),m=t("./promise_resolver.js"),b=m._nodebackForPromise,w=s.errorObj,E=s.tryCatch;return e.prototype.toString=function(){return"[object Promise]"},e.prototype.caught=e.prototype.catch=function(t){var r=arguments.length;if(r>1){var n,i=new Array(r-1),o=0;for(n=0;r-1>n;++n){var s=arguments[n];if("function"!=typeof s)return e.reject(new c("Catch filter must inherit from Error or be a simple predicate function\n\n See http://goo.gl/o84o68\n"));i[o++]=s}i.length=o,t=arguments[n];var a=new g(i,t,this);return this._then(void 0,a.doFilter,void 0,a,void 0)}return this._then(void 0,t,void 0,void 0,void 0)},e.prototype.reflect=function(){return this._then(i,i,void 0,this,void 0)},e.prototype.then=function(t,e,r){if(y()&&arguments.length>0&&"function"!=typeof t&&"function"!=typeof e){var n=".then() only accepts functions but was passed: "+s.classString(t);arguments.length>1&&(n+=", "+s.classString(e)),this._warn(n)}return this._then(t,e,r,void 0,void 0)},e.prototype.done=function(t,e,r){var n=this._then(t,e,r,void 0,void 0);n._setIsFinal()},e.prototype.spread=function(t,e){return this.all()._then(t,e,void 0,h,void 0)},e.prototype.isCancellable=function(){return!this.isResolved()&&this._cancellable()},e.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},e.prototype.all=function(){return new d(this).promise()},e.prototype.error=function(t){return this.caught(s.originatesFromRejection,t)},e.is=function(t){return t instanceof e},e.fromNode=function(t){var r=new e(f),n=E(t)(b(r));return n===w&&r._rejectCallback(n.e,!0,!0),r},e.all=function(t){return new d(t).promise()},e.defer=e.pending=function(){var t=new e(f);return new m(t)},e.cast=function(t){var r=p(t);if(!(r instanceof e)){var n=r;r=new e(f),r._fulfillUnchecked(n)}return r},e.resolve=e.fulfilled=e.cast,e.reject=e.rejected=function(t){var r=new e(f);return r._captureStackTrace(),r._rejectCallback(t,!0),r},e.setScheduler=function(t){if("function"!=typeof t)throw new c("fn must be a function\n\n See http://goo.gl/916lJJ\n");var e=a._schedule;return a._schedule=t,e},e.prototype._then=function(t,r,n,i,o){var s=void 0!==o,u=s?o:new e(f);s||(u._propagateFrom(this,5),u._captureStackTrace());var c=this._target();c!==this&&(void 0===i&&(i=this._boundTo),s||u._setIsMigrated());var h=c._addCallbacks(t,r,n,u,i);return c._isResolved()&&!c._isSettlePromisesQueued()&&a.invoke(c._settlePromiseAtPostResolution,c,h),u},e.prototype._settlePromiseAtPostResolution=function(t){this._isRejectionUnhandled()&&this._unsetRejectionIsUnhandled(),this._settlePromiseAt(t)},e.prototype._length=function(){return 131071&this._bitField},e.prototype._isFollowingOrFulfilledOrRejected=function(){return(939524096&this._bitField)>0},e.prototype._isFollowing=function(){return 536870912===(536870912&this._bitField)},e.prototype._setLength=function(t){this._bitField=-131072&this._bitField|131071&t},e.prototype._setFulfilled=function(){this._bitField=268435456|this._bitField},e.prototype._setRejected=function(){this._bitField=134217728|this._bitField},e.prototype._setFollowing=function(){this._bitField=536870912|this._bitField},e.prototype._setIsFinal=function(){this._bitField=33554432|this._bitField},e.prototype._isFinal=function(){return(33554432&this._bitField)>0},e.prototype._cancellable=function(){return(67108864&this._bitField)>0},e.prototype._setCancellable=function(){this._bitField=67108864|this._bitField},e.prototype._unsetCancellable=function(){this._bitField=-67108865&this._bitField},e.prototype._setIsMigrated=function(){this._bitField=4194304|this._bitField},e.prototype._unsetIsMigrated=function(){this._bitField=-4194305&this._bitField},e.prototype._isMigrated=function(){return(4194304&this._bitField)>0},e.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[5*t-5+4];return void 0===e&&this._isBound()?this._boundTo:e},e.prototype._promiseAt=function(t){return 0===t?this._promise0:this[5*t-5+3]},e.prototype._fulfillmentHandlerAt=function(t){return 0===t?this._fulfillmentHandler0:this[5*t-5+0]},e.prototype._rejectionHandlerAt=function(t){return 0===t?this._rejectionHandler0:this[5*t-5+1]},e.prototype._migrateCallbacks=function(t,r){var n=t._fulfillmentHandlerAt(r),i=t._rejectionHandlerAt(r),o=t._progressHandlerAt(r),s=t._promiseAt(r),a=t._receiverAt(r);s instanceof e&&s._setIsMigrated(),this._addCallbacks(n,i,o,s,a)},e.prototype._addCallbacks=function(t,e,r,n,i){var o=this._length();if(o>=131066&&(o=0,this._setLength(0)),0===o)this._promise0=n,void 0!==i&&(this._receiver0=i),"function"!=typeof t||this._isCarryingStackTrace()||(this._fulfillmentHandler0=t),"function"==typeof e&&(this._rejectionHandler0=e),"function"==typeof r&&(this._progressHandler0=r);else{var s=5*o-5;this[s+3]=n,this[s+4]=i,"function"==typeof t&&(this[s+0]=t),"function"==typeof e&&(this[s+1]=e),"function"==typeof r&&(this[s+2]=r)}return this._setLength(o+1),o},e.prototype._setProxyHandlers=function(t,e){var r=this._length();if(r>=131066&&(r=0,this._setLength(0)),0===r)this._promise0=e,this._receiver0=t;else{var n=5*r-5;this[n+3]=e,this[n+4]=t}this._setLength(r+1)},e.prototype._proxyPromiseArray=function(t,e){this._setProxyHandlers(t,e)},e.prototype._resolveCallback=function(t,r){if(!this._isFollowingOrFulfilledOrRejected()){if(t===this)return this._rejectCallback(n(),!1,!0);var i=p(t,this);if(!(i instanceof e))return this._fulfill(t);var o=1|(r?4:0);this._propagateFrom(i,o);var s=i._target();if(s._isPending()){for(var a=this._length(),u=0;a>u;++u)s._migrateCallbacks(this,u);this._setFollowing(),this._setLength(0),this._setFollowee(s)}else s._isFulfilled()?this._fulfillUnchecked(s._value()):this._rejectUnchecked(s._reason(),s._getCarriedStackTrace())}},e.prototype._rejectCallback=function(t,e,r){r||s.markAsOriginatingFromRejection(t);var n=s.ensureErrorObject(t),i=n===t;this._attachExtraTrace(n,e?i:!1),this._reject(t,i?void 0:n)},e.prototype._resolveFromResolver=function(t){var e=this;this._captureStackTrace(),this._pushContext();var r=!0,n=E(t)(function(t){null!==e&&(e._resolveCallback(t),e=null)},function(t){null!==e&&(e._rejectCallback(t,r),e=null)});r=!1,this._popContext(),void 0!==n&&n===w&&null!==e&&(e._rejectCallback(n.e,!0,!0),e=null)},e.prototype._settlePromiseFromHandler=function(t,e,r,i){if(!i._isRejected()){i._pushContext();var o;if(o=e!==h||this._isRejected()?E(t).call(e,r):E(t).apply(this._boundTo,r),i._popContext(),o===w||o===i||o===l){var s=o===i?n():o.e;i._rejectCallback(s,!1,!0)}else i._resolveCallback(o)}},e.prototype._target=function(){for(var t=this;t._isFollowing();)t=t._followee();return t},e.prototype._followee=function(){return this._rejectionHandler0},e.prototype._setFollowee=function(t){this._rejectionHandler0=t},e.prototype._cleanValues=function(){this._cancellable()&&(this._cancellationParent=void 0)},e.prototype._propagateFrom=function(t,e){(1&e)>0&&t._cancellable()&&(this._setCancellable(),this._cancellationParent=t),(4&e)>0&&t._isBound()&&this._setBoundTo(t._boundTo)},e.prototype._fulfill=function(t){this._isFollowingOrFulfilledOrRejected()||this._fulfillUnchecked(t)},e.prototype._reject=function(t,e){this._isFollowingOrFulfilledOrRejected()||this._rejectUnchecked(t,e)},e.prototype._settlePromiseAt=function(t){var r=this._promiseAt(t),n=r instanceof e;if(n&&r._isMigrated())return r._unsetIsMigrated(),a.invoke(this._settlePromiseAt,this,t);var i=this._isFulfilled()?this._fulfillmentHandlerAt(t):this._rejectionHandlerAt(t),o=this._isCarryingStackTrace()?this._getCarriedStackTrace():void 0,s=this._settledValue,u=this._receiverAt(t);this._clearCallbackDataAtIndex(t),"function"==typeof i?n?this._settlePromiseFromHandler(i,u,s,r):i.call(u,s,r):u instanceof d?u._isResolved()||(this._isFulfilled()?u._promiseFulfilled(s,r):u._promiseRejected(s,r)):n&&(this._isFulfilled()?r._fulfill(s):r._reject(s,o)),t>=4&&4===(31&t)&&a.invokeLater(this._setLength,this,0)},e.prototype._clearCallbackDataAtIndex=function(t){if(0===t)this._isCarryingStackTrace()||(this._fulfillmentHandler0=void 0),this._rejectionHandler0=this._progressHandler0=this._receiver0=this._promise0=void 0;else{var e=5*t-5;this[e+3]=this[e+4]=this[e+0]=this[e+1]=this[e+2]=void 0}},e.prototype._isSettlePromisesQueued=function(){return-1073741824===(-1073741824&this._bitField);
9
- },e.prototype._setSettlePromisesQueued=function(){this._bitField=-1073741824|this._bitField},e.prototype._unsetSettlePromisesQueued=function(){this._bitField=1073741823&this._bitField},e.prototype._queueSettlePromises=function(){a.settlePromises(this),this._setSettlePromisesQueued()},e.prototype._fulfillUnchecked=function(t){if(t===this){var e=n();return this._attachExtraTrace(e),this._rejectUnchecked(e,void 0)}this._setFulfilled(),this._settledValue=t,this._cleanValues(),this._length()>0&&this._queueSettlePromises()},e.prototype._rejectUncheckedCheckError=function(t){var e=s.ensureErrorObject(t);this._rejectUnchecked(t,e===t?void 0:e)},e.prototype._rejectUnchecked=function(t,e){if(t===this){var r=n();return this._attachExtraTrace(r),this._rejectUnchecked(r)}return this._setRejected(),this._settledValue=t,this._cleanValues(),this._isFinal()?void a.throwLater(function(t){throw"stack"in t&&a.invokeFirst(_.unhandledRejection,void 0,t),t},void 0===e?t:e):(void 0!==e&&e!==t&&this._setCarriedStackTrace(e),void(this._length()>0?this._queueSettlePromises():this._ensurePossibleRejectionHandled()))},e.prototype._settlePromises=function(){this._unsetSettlePromisesQueued();for(var t=this._length(),e=0;t>e;e++)this._settlePromiseAt(e)},e._makeSelfResolutionError=n,t("./progress.js")(e,d),t("./method.js")(e,f,p,o),t("./bind.js")(e,f,p),t("./finally.js")(e,l,p),t("./direct_resolve.js")(e),t("./synchronous_inspection.js")(e),t("./join.js")(e,d,p,f),e.Promise=e,t("./map.js")(e,d,o,p,f),t("./cancel.js")(e),t("./using.js")(e,o,p,v),t("./generators.js")(e,o,f,p),t("./nodeify.js")(e),t("./call_get.js")(e),t("./props.js")(e,d,p,o),t("./race.js")(e,f,p,o),t("./reduce.js")(e,d,o,p,f),t("./settle.js")(e,d),t("./some.js")(e,d,o),t("./promisify.js")(e,f),t("./any.js")(e),t("./each.js")(e,f),t("./timers.js")(e,f),t("./filter.js")(e,f),s.toFastProperties(e),s.toFastProperties(e.prototype),r({a:1}),r({b:2}),r({c:3}),r(1),r(function(){}),r(void 0),r(!1),r(new e(f)),_.setBounds(a.firstLineError,s.lastLineError),e}},{"./any.js":1,"./async.js":2,"./bind.js":3,"./call_get.js":5,"./cancel.js":6,"./captured_trace.js":7,"./catch_filter.js":8,"./context.js":9,"./debuggability.js":10,"./direct_resolve.js":11,"./each.js":12,"./errors.js":13,"./filter.js":15,"./finally.js":16,"./generators.js":17,"./join.js":18,"./map.js":19,"./method.js":20,"./nodeify.js":21,"./progress.js":22,"./promise_array.js":24,"./promise_resolver.js":25,"./promisify.js":26,"./props.js":27,"./race.js":29,"./reduce.js":30,"./settle.js":32,"./some.js":33,"./synchronous_inspection.js":34,"./thenables.js":35,"./timers.js":36,"./using.js":37,"./util.js":38}],24:[function(t,e,r){"use strict";e.exports=function(e,r,n,i){function o(t){switch(t){case-2:return[];case-3:return{}}}function s(t){var n,i=this._promise=new e(r);t instanceof e&&(n=t,i._propagateFrom(n,5)),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var a=t("./util.js"),u=a.isArray;return s.prototype.length=function(){return this._length},s.prototype.promise=function(){return this._promise},s.prototype._init=function t(r,s){var a=n(this._values,this._promise);if(a instanceof e){if(a=a._target(),this._values=a,!a._isFulfilled())return a._isPending()?void a._then(t,this._reject,void 0,this,s):void this._reject(a._reason());if(a=a._value(),!u(a)){var c=new e.TypeError("expecting an array, a promise or a thenable\n\n See http://goo.gl/s8MMhc\n");return void this.__hardReject__(c)}}else if(!u(a))return void this._promise._reject(i("expecting an array, a promise or a thenable\n\n See http://goo.gl/s8MMhc\n")._reason());if(0===a.length)return void(-5===s?this._resolveEmptyArray():this._resolve(o(s)));var f=this.getActualLength(a.length);this._length=f,this._values=this.shouldCopyValues()?new Array(f):this._values;for(var h=this._promise,l=0;f>l;++l){var p=this._isResolved(),d=n(a[l],h);d instanceof e?(d=d._target(),p?d._unsetRejectionIsUnhandled():d._isPending()?d._proxyPromiseArray(this,l):d._isFulfilled()?this._promiseFulfilled(d._value(),l):this._promiseRejected(d._reason(),l)):p||this._promiseFulfilled(d,l)}},s.prototype._isResolved=function(){return null===this._values},s.prototype._resolve=function(t){this._values=null,this._promise._fulfill(t)},s.prototype.__hardReject__=s.prototype._reject=function(t){this._values=null,this._promise._rejectCallback(t,!1,!0)},s.prototype._promiseProgressed=function(t,e){this._promise._progress({index:e,value:t})},s.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var r=++this._totalResolved;r>=this._length&&this._resolve(this._values)},s.prototype._promiseRejected=function(t,e){this._totalResolved++,this._reject(t)},s.prototype.shouldCopyValues=function(){return!0},s.prototype.getActualLength=function(t){return t},s}},{"./util.js":38}],25:[function(t,e,r){"use strict";function n(t){return t instanceof Error&&p.getPrototypeOf(t)===Error.prototype}function i(t){var e;if(n(t)){e=new h(t),e.name=t.name,e.message=t.message,e.stack=t.stack;for(var r=p.keys(t),i=0;i<r.length;++i){var o=r[i];d.test(o)||(e[o]=t[o])}return e}return a.markAsOriginatingFromRejection(t),t}function o(t){return function(e,r){if(null!==t){if(e){var n=i(u(e));t._attachExtraTrace(n),t._reject(n)}else if(arguments.length>2){for(var o=arguments.length,s=new Array(o-1),a=1;o>a;++a)s[a-1]=arguments[a];t._fulfill(s)}else t._fulfill(r);t=null}}}var s,a=t("./util.js"),u=a.maybeWrapAsError,c=t("./errors.js"),f=c.TimeoutError,h=c.OperationalError,l=a.haveGetters,p=t("./es5.js"),d=/^(?:name|message|stack|cause)$/;if(s=l?function(t){this.promise=t}:function(t){this.promise=t,this.asCallback=o(t),this.callback=this.asCallback},l){var _={get:function(){return o(this.promise)}};p.defineProperty(s.prototype,"asCallback",_),p.defineProperty(s.prototype,"callback",_)}s._nodebackForPromise=o,s.prototype.toString=function(){return"[object PromiseResolver]"},s.prototype.resolve=s.prototype.fulfill=function(t){if(!(this instanceof s))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._resolveCallback(t)},s.prototype.reject=function(t){if(!(this instanceof s))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._rejectCallback(t)},s.prototype.progress=function(t){if(!(this instanceof s))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._progress(t)},s.prototype.cancel=function(t){this.promise.cancel(t)},s.prototype.timeout=function(){this.reject(new f("timeout"))},s.prototype.isResolved=function(){return this.promise.isResolved()},s.prototype.toJSON=function(){return this.promise.toJSON()},e.exports=s},{"./errors.js":13,"./es5.js":14,"./util.js":38}],26:[function(t,e,r){"use strict";e.exports=function(e,r){function n(t){return!w.test(t)}function i(t){try{return t.__isPromisified__===!0}catch(t){return!1}}function o(t,e,r){var n=p.getDataPropertyOrDefault(t,e+r,b);return n?i(n):!1}function s(t,e,r){for(var n=0;n<t.length;n+=2){var i=t[n];if(r.test(i))for(var o=i.replace(r,""),s=0;s<t.length;s+=2)if(t[s]===o)throw new g("Cannot promisify an API that has normal methods with '%s'-suffix\n\n See http://goo.gl/iWrZbw\n".replace("%s",e))}}function a(t,e,r,n){for(var a=p.inheritedDataKeys(t),u=[],c=0;c<a.length;++c){var f=a[c],h=t[f],l=n===E?!0:E(f,h,t);"function"!=typeof h||i(h)||o(t,f,e)||!n(f,h,t,l)||u.push(f,h)}return s(u,e,r),u}function u(t,n,i,o){function s(){var i=n;n===l&&(i=this);var o=new e(r);o._captureStackTrace();var s="string"==typeof u&&this!==a?this[u]:t,c=d(o);try{s.apply(i,_(arguments,c))}catch(t){o._rejectCallback(y(t),!0,!0)}return o}var a=function(){return this}(),u=t;return"string"==typeof u&&(t=o),s.__isPromisified__=!0,s}function c(t,e,r,n){for(var i=new RegExp(A(e)+"$"),o=a(t,e,i,r),s=0,u=o.length;u>s;s+=2){var c=o[s],f=o[s+1],h=c+e;t[h]=n===O?O(c,l,c,f,e):n(f,function(){return O(c,l,c,f,e)})}return p.toFastProperties(t),t}function f(t,e){return O(t,e,void 0,t)}var h,l={},p=t("./util.js"),d=t("./promise_resolver.js")._nodebackForPromise,_=p.withAppended,y=p.maybeWrapAsError,v=p.canEvaluate,g=t("./errors").TypeError,m="Async",b={__isPromisified__:!0},w=/^(?:length|name|arguments|caller|callee|prototype|__isPromisified__)$/,E=function(t,e){return p.isIdentifier(t)&&"_"!==t.charAt(0)&&!p.isClass(e)},A=function(t){return t.replace(/([$])/,"\\$")},O=v?h:u;e.promisify=function(t,e){if("function"!=typeof t)throw new g("fn must be a function\n\n See http://goo.gl/916lJJ\n");if(i(t))return t;var r=f(t,arguments.length<2?l:e);return p.copyDescriptors(t,r,n),r},e.promisifyAll=function(t,e){if("function"!=typeof t&&"object"!=typeof t)throw new g("the target of promisifyAll must be an object or a function\n\n See http://goo.gl/9ITlV0\n");e=Object(e);var r=e.suffix;"string"!=typeof r&&(r=m);var n=e.filter;"function"!=typeof n&&(n=E);var i=e.promisifier;if("function"!=typeof i&&(i=O),!p.isIdentifier(r))throw new RangeError("suffix must be a valid identifier\n\n See http://goo.gl/8FZo5V\n");for(var o=p.inheritedDataKeys(t),s=0;s<o.length;++s){var a=t[o[s]];"constructor"!==o[s]&&p.isClass(a)&&(c(a.prototype,r,n,i),c(a,r,n,i))}return c(t,r,n,i)}}},{"./errors":13,"./promise_resolver.js":25,"./util.js":38}],27:[function(t,e,r){"use strict";e.exports=function(e,r,n,i){function o(t){for(var e=c.keys(t),r=e.length,n=new Array(2*r),i=0;r>i;++i){var o=e[i];n[i]=t[o],n[i+r]=o}this.constructor$(n)}function s(t){var r,s=n(t);return u(s)?(r=s instanceof e?s._then(e.props,void 0,void 0,void 0,void 0):new o(s).promise(),s instanceof e&&r._propagateFrom(s,4),r):i("cannot await properties of a non-object\n\n See http://goo.gl/OsFKC8\n")}var a=t("./util.js"),u=a.isObject,c=t("./es5.js");a.inherits(o,r),o.prototype._init=function(){this._init$(void 0,-3)},o.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var r=++this._totalResolved;if(r>=this._length){for(var n={},i=this.length(),o=0,s=this.length();s>o;++o)n[this._values[o+i]]=this._values[o];this._resolve(n)}},o.prototype._promiseProgressed=function(t,e){this._promise._progress({key:this._values[e+this.length()],value:t})},o.prototype.shouldCopyValues=function(){return!1},o.prototype.getActualLength=function(t){return t>>1},e.prototype.props=function(){return s(this)},e.props=function(t){return s(t)}}},{"./es5.js":14,"./util.js":38}],28:[function(t,e,r){"use strict";function n(t,e,r,n,i){for(var o=0;i>o;++o)r[o+n]=t[o+e],t[o+e]=void 0}function i(t){this._capacity=t,this._length=0,this._front=0}i.prototype._willBeOverCapacity=function(t){return this._capacity<t},i.prototype._pushOne=function(t){var e=this.length();this._checkCapacity(e+1);var r=this._front+e&this._capacity-1;this[r]=t,this._length=e+1},i.prototype._unshiftOne=function(t){var e=this._capacity;this._checkCapacity(this.length()+1);var r=this._front,n=(r-1&e-1^e)-e;this[n]=t,this._front=n,this._length=this.length()+1},i.prototype.unshift=function(t,e,r){this._unshiftOne(r),this._unshiftOne(e),this._unshiftOne(t)},i.prototype.push=function(t,e,r){var n=this.length()+3;if(this._willBeOverCapacity(n))return this._pushOne(t),this._pushOne(e),void this._pushOne(r);var i=this._front+n-3;this._checkCapacity(n);var o=this._capacity-1;this[i+0&o]=t,this[i+1&o]=e,this[i+2&o]=r,this._length=n},i.prototype.shift=function(){var t=this._front,e=this[t];return this[t]=void 0,this._front=t+1&this._capacity-1,this._length--,e},i.prototype.length=function(){return this._length},i.prototype._checkCapacity=function(t){this._capacity<t&&this._resizeTo(this._capacity<<1)},i.prototype._resizeTo=function(t){var e=this._capacity;this._capacity=t;var r=this._front,i=this._length,o=r+i&e-1;n(this,0,this,e,o)},e.exports=i},{}],29:[function(t,e,r){"use strict";e.exports=function(e,r,n,i){function o(t,o){var u=n(t);if(u instanceof e)return a(u);if(!s(t))return i("expecting an array, a promise or a thenable\n\n See http://goo.gl/s8MMhc\n");var c=new e(r);void 0!==o&&c._propagateFrom(o,5);for(var f=c._fulfill,h=c._reject,l=0,p=t.length;p>l;++l){var d=t[l];(void 0!==d||l in t)&&e.cast(d)._then(f,h,void 0,c,null)}return c}var s=t("./util.js").isArray,a=function(t){return t.then(function(e){return o(e,t)})};e.race=function(t){return o(t,void 0)},e.prototype.race=function(){return o(this,void 0)}}},{"./util.js":38}],30:[function(t,e,r){"use strict";e.exports=function(e,r,n,i,o){function s(t,r,n,s){this.constructor$(t),this._promise._captureStackTrace(),this._preservedValues=s===o?[]:null,this._zerothIsAccum=void 0===n,this._gotAccum=!1,this._reducingIndex=this._zerothIsAccum?1:0,this._valuesPhase=void 0;var u=i(n,this._promise),f=!1,h=u instanceof e;h&&(u=u._target(),u._isPending()?u._proxyPromiseArray(this,-1):u._isFulfilled()?(n=u._value(),this._gotAccum=!0):(this._reject(u._reason()),f=!0)),h||this._zerothIsAccum||(this._gotAccum=!0),this._callback=r,this._accum=n,f||c.invoke(a,this,void 0)}function a(){this._init$(void 0,-5)}function u(t,e,r,i){if("function"!=typeof e)return n("fn must be a function\n\n See http://goo.gl/916lJJ\n");var o=new s(t,e,r,i);return o.promise()}var c=t("./async.js"),f=t("./util.js"),h=f.tryCatch,l=f.errorObj;f.inherits(s,r),s.prototype._init=function(){},s.prototype._resolveEmptyArray=function(){(this._gotAccum||this._zerothIsAccum)&&this._resolve(null!==this._preservedValues?[]:this._accum)},s.prototype._promiseFulfilled=function(t,r){var n=this._values;n[r]=t;var o,s=this.length(),a=this._preservedValues,u=null!==a,c=this._gotAccum,f=this._valuesPhase;if(!f)for(f=this._valuesPhase=new Array(s),o=0;s>o;++o)f[o]=0;if(o=f[r],0===r&&this._zerothIsAccum?(this._accum=t,this._gotAccum=c=!0,f[r]=0===o?1:2):-1===r?(this._accum=t,this._gotAccum=c=!0):0===o?f[r]=1:(f[r]=2,this._accum=t),c){for(var p,d=this._callback,_=this._promise._boundTo,y=this._reducingIndex;s>y;++y)if(o=f[y],2!==o){if(1!==o)return;if(t=n[y],this._promise._pushContext(),u?(a.push(t),p=h(d).call(_,t,y,s)):p=h(d).call(_,this._accum,t,y,s),this._promise._popContext(),p===l)return this._reject(p.e);var v=i(p,this._promise);if(v instanceof e){if(v=v._target(),v._isPending())return f[y]=4,v._proxyPromiseArray(this,y);if(!v._isFulfilled())return this._reject(v._reason());p=v._value()}this._reducingIndex=y+1,this._accum=p}else this._reducingIndex=y+1;this._resolve(u?a:this._accum)}},e.prototype.reduce=function(t,e){return u(this,t,e,null)},e.reduce=function(t,e,r,n){return u(t,e,r,n)}}},{"./async.js":2,"./util.js":38}],31:[function(e,r,i){"use strict";var o,s=function(){throw new Error("No async scheduler available\n\n See http://goo.gl/m3OTXk\n")};if(e("./util.js").isNode){var a=t.versions.node.split(".").map(Number);o=0===a[0]&&a[1]>10||a[0]>0?function(t){n.setImmediate(t)}:t.nextTick,o||(o="undefined"!=typeof setImmediate?setImmediate:"undefined"!=typeof setTimeout?setTimeout:s)}else"undefined"!=typeof MutationObserver?(o=function(t){var e=document.createElement("div"),r=new MutationObserver(t);return r.observe(e,{attributes:!0}),function(){e.classList.toggle("foo")}},o.isStatic=!0):o="undefined"!=typeof setImmediate?function(t){setImmediate(t)}:"undefined"!=typeof setTimeout?function(t){setTimeout(t,0)}:s;r.exports=o},{"./util.js":38}],32:[function(t,e,r){"use strict";e.exports=function(e,r){function n(t){this.constructor$(t)}var i=e.PromiseInspection,o=t("./util.js");o.inherits(n,r),n.prototype._promiseResolved=function(t,e){this._values[t]=e;var r=++this._totalResolved;r>=this._length&&this._resolve(this._values)},n.prototype._promiseFulfilled=function(t,e){var r=new i;r._bitField=268435456,r._settledValue=t,this._promiseResolved(e,r)},n.prototype._promiseRejected=function(t,e){var r=new i;r._bitField=134217728,r._settledValue=t,this._promiseResolved(e,r)},e.settle=function(t){return new n(t).promise()},e.prototype.settle=function(){return new n(this).promise()}}},{"./util.js":38}],33:[function(t,e,r){"use strict";e.exports=function(e,r,n){function i(t){this.constructor$(t),this._howMany=0,this._unwrap=!1,this._initialized=!1}function o(t,e){if((0|e)!==e||0>e)return n("expecting a positive integer\n\n See http://goo.gl/1wAmHx\n");var r=new i(t),o=r.promise();return r.setHowMany(e),r.init(),o}var s=t("./util.js"),a=t("./errors.js").RangeError,u=t("./errors.js").AggregateError,c=s.isArray;s.inherits(i,r),i.prototype._init=function(){if(this._initialized){if(0===this._howMany)return void this._resolve([]);this._init$(void 0,-5);var t=c(this._values);!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}},i.prototype.init=function(){this._initialized=!0,this._init()},i.prototype.setUnwrap=function(){this._unwrap=!0},i.prototype.howMany=function(){return this._howMany},i.prototype.setHowMany=function(t){this._howMany=t},i.prototype._promiseFulfilled=function(t){this._addFulfilled(t),this._fulfilled()===this.howMany()&&(this._values.length=this.howMany(),1===this.howMany()&&this._unwrap?this._resolve(this._values[0]):this._resolve(this._values))},i.prototype._promiseRejected=function(t){if(this._addRejected(t),this.howMany()>this._canPossiblyFulfill()){for(var e=new u,r=this.length();r<this._values.length;++r)e.push(this._values[r]);this._reject(e)}},i.prototype._fulfilled=function(){return this._totalResolved},i.prototype._rejected=function(){return this._values.length-this.length()},i.prototype._addRejected=function(t){this._values.push(t)},i.prototype._addFulfilled=function(t){this._values[this._totalResolved++]=t},i.prototype._canPossiblyFulfill=function(){return this.length()-this._rejected()},i.prototype._getRangeError=function(t){var e="Input array must contain at least "+this._howMany+" items but contains only "+t+" items";return new a(e)},i.prototype._resolveEmptyArray=function(){this._reject(this._getRangeError(0))},e.some=function(t,e){return o(t,e)},e.prototype.some=function(t){return o(this,t)},e._SomePromiseArray=i}},{"./errors.js":13,"./util.js":38}],34:[function(t,e,r){"use strict";e.exports=function(t){function e(t){void 0!==t?(t=t._target(),this._bitField=t._bitField,this._settledValue=t._settledValue):(this._bitField=0,this._settledValue=void 0)}e.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/hc1DLj\n");return this._settledValue},e.prototype.error=e.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/hPuiwB\n");return this._settledValue},e.prototype.isFulfilled=t.prototype._isFulfilled=function(){return(268435456&this._bitField)>0},e.prototype.isRejected=t.prototype._isRejected=function(){return(134217728&this._bitField)>0},e.prototype.isPending=t.prototype._isPending=function(){return 0===(402653184&this._bitField)},e.prototype.isResolved=t.prototype._isResolved=function(){return(402653184&this._bitField)>0},t.prototype.isPending=function(){return this._target()._isPending()},t.prototype.isRejected=function(){return this._target()._isRejected()},t.prototype.isFulfilled=function(){return this._target()._isFulfilled()},t.prototype.isResolved=function(){return this._target()._isResolved()},t.prototype._value=function(){return this._settledValue},t.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue},t.prototype.value=function(){var t=this._target();if(!t.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/hc1DLj\n");return t._settledValue},t.prototype.reason=function(){var t=this._target();if(!t.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/hPuiwB\n");return t._unsetRejectionIsUnhandled(),t._settledValue},t.PromiseInspection=e}},{}],35:[function(t,e,r){"use strict";e.exports=function(e,r){function n(t,n){if(c(t)){if(t instanceof e)return t;if(o(t)){var f=new e(r);return t._then(f._fulfillUnchecked,f._rejectUncheckedCheckError,f._progressUnchecked,f,null),f}var h=a.tryCatch(i)(t);if(h===u){n&&n._pushContext();var f=e.reject(h.e);return n&&n._popContext(),f}if("function"==typeof h)return s(t,h,n)}return t}function i(t){return t.then}function o(t){return f.call(t,"_promise0")}function s(t,n,i){function o(r){f&&(t===r?f._rejectCallback(e._makeSelfResolutionError(),!1,!0):f._resolveCallback(r),f=null)}function s(t){f&&(f._rejectCallback(t,l,!0),f=null)}function c(t){f&&"function"==typeof f._progress&&f._progress(t)}var f=new e(r),h=f;i&&i._pushContext(),f._captureStackTrace(),i&&i._popContext();var l=!0,p=a.tryCatch(n).call(t,o,s,c);return l=!1,f&&p===u&&(f._rejectCallback(p.e,!0,!0),f=null),h}var a=t("./util.js"),u=a.errorObj,c=a.isObject,f={}.hasOwnProperty;return n}},{"./util.js":38}],36:[function(t,e,r){"use strict";e.exports=function(e,r){function n(t){var e=this;return e instanceof Number&&(e=+e),clearTimeout(e),t}function i(t){var e=this;throw e instanceof Number&&(e=+e),clearTimeout(e),t}var o=t("./util.js"),s=e.TimeoutError,a=function(t,e){if(t.isPending()){"string"!=typeof e&&(e="operation timed out");var r=new s(e);o.markAsOriginatingFromRejection(r),t._attachExtraTrace(r),t._cancel(r)}},u=function(t){return c(+this).thenReturn(t)},c=e.delay=function(t,n){if(void 0===n){n=t,t=void 0;var i=new e(r);return setTimeout(function(){i._fulfill()},n),i}return n=+n,e.resolve(t)._then(u,null,null,n,void 0)};e.prototype.delay=function(t){return c(this,t)},e.prototype.timeout=function(t,e){t=+t;var r=this.then().cancellable();r._cancellationParent=this;var o=setTimeout(function(){a(r,e)},t);return r._then(n,i,void 0,o,void 0)}}},{"./util.js":38}],37:[function(t,e,r){"use strict";e.exports=function(e,r,n,i){function o(t){for(var r=t.length,n=0;r>n;++n){var i=t[n];if(i.isRejected())return e.reject(i.error());t[n]=i._settledValue}return t}function s(t){setTimeout(function(){throw t},0)}function a(t){var e=n(t);return e!==t&&"function"==typeof t._isDisposable&&"function"==typeof t._getDisposer&&t._isDisposable()&&e._setDisposable(t._getDisposer()),e}function u(t,r){function i(){if(o>=u)return c.resolve();var f=a(t[o++]);if(f instanceof e&&f._isDisposable()){try{f=n(f._getDisposer().tryDispose(r),t.promise)}catch(t){return s(t)}if(f instanceof e)return f._then(i,s,null,null,null)}i()}var o=0,u=t.length,c=e.defer();return i(),c.promise}function c(t){var e=new y;return e._settledValue=t,e._bitField=268435456,u(this,e).thenReturn(t)}function f(t){var e=new y;return e._settledValue=t,e._bitField=134217728,u(this,e).thenThrow(t)}function h(t,e,r){this._data=t,this._promise=e,this._context=r}function l(t,e,r){this.constructor$(t,e,r)}function p(t){return h.isDisposer(t)?(this.resources[this.index]._setDisposable(t),t.promise()):t}var d=t("./errors.js").TypeError,_=t("./util.js").inherits,y=e.PromiseInspection;h.prototype.data=function(){return this._data},h.prototype.promise=function(){return this._promise},h.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():null},h.prototype.tryDispose=function(t){var e=this.resource(),r=this._context;void 0!==r&&r._pushContext();var n=null!==e?this.doDispose(e,t):null;return void 0!==r&&r._popContext(),this._promise._unsetDisposable(),this._data=null,n},h.isDisposer=function(t){return null!=t&&"function"==typeof t.resource&&"function"==typeof t.tryDispose},_(l,h),l.prototype.doDispose=function(t,e){var r=this.data();return r.call(t,t,e)},e.using=function(){var t=arguments.length;if(2>t)return r("you must pass at least 2 arguments to Promise.using");var i=arguments[t-1];if("function"!=typeof i)return r("fn must be a function\n\n See http://goo.gl/916lJJ\n");t--;for(var s=new Array(t),a=0;t>a;++a){var u=arguments[a];if(h.isDisposer(u)){var l=u;u=u.promise(),u._setDisposable(l)}else{var d=n(u);d instanceof e&&(u=d._then(p,null,null,{resources:s,index:a},void 0))}s[a]=u}var _=e.settle(s).then(o).then(function(t){_._pushContext();var e;try{e=i.apply(void 0,t)}finally{_._popContext()}return e})._then(c,f,void 0,s,void 0);return s.promise=_,_},e.prototype._setDisposable=function(t){this._bitField=262144|this._bitField,this._disposer=t},e.prototype._isDisposable=function(){return(262144&this._bitField)>0},e.prototype._getDisposer=function(){return this._disposer},e.prototype._unsetDisposable=function(){this._bitField=-262145&this._bitField,this._disposer=void 0},e.prototype.disposer=function(t){if("function"==typeof t)return new l(t,this,i());throw new d}}},{"./errors.js":13,"./util.js":38}],38:[function(e,r,n){"use strict";function i(){try{return N.apply(this,arguments)}catch(t){return j.e=t,j}}function o(t){return N=t,i}function s(t){return null==t||t===!0||t===!1||"string"==typeof t||"number"==typeof t}function a(t){return!s(t)}function u(t){return s(t)?new Error(v(t)):t}function c(t,e){var r,n=t.length,i=new Array(n+1);for(r=0;n>r;++r)i[r]=t[r];return i[r]=e,i}function f(t,e,r){if(!A.isES5)return{}.hasOwnProperty.call(t,e)?t[e]:void 0;var n=Object.getOwnPropertyDescriptor(t,e);return null!=n?null==n.get&&null==n.set?n.value:r:void 0}function h(t,e,r){if(s(t))return t;var n={value:r,configurable:!0,enumerable:!1,writable:!0};return A.defineProperty(t,e,n),t}function l(t){throw t}function p(t){try{if("function"==typeof t){var e=A.names(t.prototype);return A.isES5?e.length>1:e.length>0&&!(1===e.length&&"constructor"===e[0])}return!1}catch(t){return!1}}function d(t){function e(){}e.prototype=t;for(var r=8;r--;)new e;return t}function _(t){return k.test(t)}function y(t,e,r){for(var n=new Array(t),i=0;t>i;++i)n[i]=e+i+r;return n}function v(t){try{return t+""}catch(t){return"[no string representation]"}}function g(t){try{h(t,"isOperational",!0)}catch(t){}}function m(t){return null==t?!1:t instanceof Error.__BluebirdErrorTypes__.OperationalError||t.isOperational===!0}function b(t){return t instanceof Error&&A.propertyIsWritable(t,"stack")}function w(t){return{}.toString.call(t)}function E(t,e,r){for(var n=A.names(t),i=0;i<n.length;++i){var o=n[i];r(o)&&A.defineProperty(e,o,A.getDescriptor(t,o))}}var A=e("./es5.js"),O="undefined"==typeof navigator,S=function(){try{var t={};return A.defineProperty(t,"f",{get:function(){return 3}}),3===t.f}catch(t){return!1}}(),j={e:{}},N,x=function(t,e){function r(){this.constructor=t,this.constructor$=e;for(var r in e.prototype)n.call(e.prototype,r)&&"$"!==r.charAt(r.length-1)&&(this[r+"$"]=e.prototype[r])}var n={}.hasOwnProperty;return r.prototype=e.prototype,t.prototype=new r,t.prototype},B=function(){return"string"!==this}.call("string"),T=function(){if(A.isES5){var t=Object.prototype,e=Object.getOwnPropertyNames;return function(r){for(var n=[],i=Object.create(null);null!=r&&r!==t;){var o;try{o=e(r)}catch(t){return n}for(var s=0;s<o.length;++s){var a=o[s];if(!i[a]){i[a]=!0;var u=Object.getOwnPropertyDescriptor(r,a);null!=u&&null==u.get&&null==u.set&&n.push(a)}}r=A.getPrototypeOf(r)}return n}}return function(t){var e=[];for(var r in t)e.push(r);return e}}(),k=/^[a-z$_][a-z$_0-9]*$/i,$=function(){return"stack"in new Error?function(t){return b(t)?t:new Error(v(t))}:function(t){if(b(t))return t;try{throw new Error(v(t))}catch(t){return t}}}(),I={isClass:p,isIdentifier:_,inheritedDataKeys:T,getDataPropertyOrDefault:f,thrower:l,isArray:A.isArray,haveGetters:S,notEnumerableProp:h,isPrimitive:s,isObject:a,canEvaluate:O,errorObj:j,tryCatch:o,inherits:x,withAppended:c,maybeWrapAsError:u,wrapsPrimitiveReceiver:B,toFastProperties:d,filledRange:y,toString:v,canAttachTrace:b,ensureErrorObject:$,originatesFromRejection:m,markAsOriginatingFromRejection:g,classString:w,copyDescriptors:E,hasDevTools:"undefined"!=typeof chrome&&chrome&&"function"==typeof chrome.loadTimes,isNode:"undefined"!=typeof t&&"[object process]"===w(t).toLowerCase()};try{throw new Error}catch(t){I.lastLineError=t}r.exports=I},{"./es5.js":14}],39:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function o(t){return"number"==typeof t}function s(t){return"object"==typeof t&&null!==t}function a(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if(!o(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,o,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||s(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],a(r))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(n=arguments.length,o=new Array(n-1),u=1;n>u;u++)o[u-1]=arguments[u];r.apply(this,o)}else if(s(r)){for(n=arguments.length,o=new Array(n-1),u=1;n>u;u++)o[u-1]=arguments[u];for(c=r.slice(),n=c.length,u=0;n>u;u++)c[u].apply(this,o)}return!0},n.prototype.addListener=function(t,e){var r;if(!i(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,i(e.listener)?e.listener:e),this._events[t]?s(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,s(this._events[t])&&!this._events[t].warned){var r;r=a(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(t,r),this},n.prototype.removeListener=function(t,e){var r,n,o,a;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],o=r.length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(s(r)){for(a=o;a-->0;)if(r[a]===e||r[a].listener&&r[a].listener===e){n=a;break}if(0>n)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.listenerCount=function(t,e){var r;return r=t._events&&t._events[e]?i(t._events[e])?1:t._events[e].length:0}},{}]},{},[4])(4)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise)}).call(this,t("FWaASH"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{FWaASH:55}],89:[function(t,e,r){function n(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31;
10
- }function i(){var t=arguments,e=this.useColors;if(t[0]=(e?"%c":"")+this.namespace+(e?" %c":" ")+t[0]+(e?"%c ":" ")+"+"+r.humanize(this.diff),!e)return t;var n="color: "+this.color;t=[t[0],n,"color: inherit"].concat(Array.prototype.slice.call(t,1));var i=0,o=0;return t[0].replace(/%[a-z%]/g,function(t){"%%"!==t&&(i++,"%c"===t&&(o=i))}),t.splice(o,0,n),t}function o(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(t){try{null==t?r.storage.removeItem("debug"):r.storage.debug=t}catch(t){}}function a(){var t;try{t=r.storage.debug}catch(t){}return t}function u(){try{return window.localStorage}catch(t){}}r=e.exports=t("./debug"),r.log=o,r.formatArgs=i,r.save=s,r.load=a,r.useColors=n,r.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:u(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(t){return JSON.stringify(t)},r.enable(a())},{"./debug":90}],90:[function(t,e,r){function n(){return r.colors[f++%r.colors.length]}function i(t){function e(){}function i(){var t=i,e=+new Date,o=e-(c||e);t.diff=o,t.prev=c,t.curr=e,c=e,null==t.useColors&&(t.useColors=r.useColors()),null==t.color&&t.useColors&&(t.color=n());var s=Array.prototype.slice.call(arguments);s[0]=r.coerce(s[0]),"string"!=typeof s[0]&&(s=["%o"].concat(s));var a=0;s[0]=s[0].replace(/%([a-z%])/g,function(e,n){if("%%"===e)return e;a++;var i=r.formatters[n];if("function"==typeof i){var o=s[a];e=i.call(t,o),s.splice(a,1),a--}return e}),"function"==typeof r.formatArgs&&(s=r.formatArgs.apply(t,s));var u=i.log||r.log||console.log.bind(console);u.apply(t,s)}e.enabled=!1,i.enabled=!0;var o=r.enabled(t)?i:e;return o.namespace=t,o}function o(t){r.save(t);for(var e=(t||"").split(/[\s,]+/),n=e.length,i=0;n>i;i++)e[i]&&(t=e[i].replace(/\*/g,".*?"),"-"===t[0]?r.skips.push(new RegExp("^"+t.substr(1)+"$")):r.names.push(new RegExp("^"+t+"$")))}function s(){r.enable("")}function a(t){var e,n;for(e=0,n=r.skips.length;n>e;e++)if(r.skips[e].test(t))return!1;for(e=0,n=r.names.length;n>e;e++)if(r.names[e].test(t))return!0;return!1}function u(t){return t instanceof Error?t.stack||t.message:t}r=e.exports=i,r.coerce=u,r.disable=s,r.enable=o,r.enabled=a,r.humanize=t("ms"),r.names=[],r.skips=[],r.formatters={};var c,f=0},{ms:91}],91:[function(t,e,r){function n(t){if(t=""+t,!(t.length>1e4)){var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*h;case"days":case"day":case"d":return r*f;case"hours":case"hour":case"hrs":case"hr":case"h":return r*c;case"minutes":case"minute":case"mins":case"min":case"m":return r*u;case"seconds":case"second":case"secs":case"sec":case"s":return r*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}}}function i(t){return t>=f?Math.round(t/f)+"d":t>=c?Math.round(t/c)+"h":t>=u?Math.round(t/u)+"m":t>=a?Math.round(t/a)+"s":t+"ms"}function o(t){return s(t,f,"day")||s(t,c,"hour")||s(t,u,"minute")||s(t,a,"second")||t+" ms"}function s(t,e,r){return e>t?void 0:1.5*e>t?Math.floor(t/e)+" "+r:Math.ceil(t/e)+" "+r+"s"}var a=1e3,u=60*a,c=60*u,f=24*c,h=365.25*f;e.exports=function(t,e){return e=e||{},"string"==typeof t?n(t):e.long?o(t):i(t)}},{}],92:[function(t,e,r){!function(t){function r(t){return t==Number(t)?Number(t):(n.exec(t.toLowerCase()),RegExp.$1*i[RegExp.$2])}var n=/(\d*.?\d+)([mshd]+)/,i={};i.ms=1,i.s=1e3,i.m=60*i.s,i.h=60*i.m,i.d=24*i.h,t.top?t.ms=r:e.exports=r}(this)},{}],93:[function(t,e,r){function n(t){return"object"==typeof t&&"[object RegExp]"==i.call(t)}var i=Object.prototype.toString;e.exports=r=function(t){if(!n(t))throw new TypeError("Not a RegExp");var e=[];return t.global&&e.push("g"),t.multiline&&e.push("m"),t.ignoreCase&&e.push("i"),new RegExp(t.source,e.join(""))}},{}],94:[function(t,e,r){e.exports=r=t("./lib/sliced")},{"./lib/sliced":95}],95:[function(t,e,r){e.exports=function(t,e,r){var n=[],i=t.length;if(0===i)return n;var o=0>e?Math.max(0,e+i):e||0;for(void 0!==r&&(i=0>r?r+i:r);i-->o;)n[i-o]=t[i];return n}},{}]},{},[2]);
1
+ !function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var c=r[s]={exports:{}};e[s][0].call(c.exports,function(t){var r=e[s][1][t];return i(r?r:t)},c,c.exports,t,e,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(t,e,r){function n(){throw new Error("Can't use ES6 promise with mpromise style constructor")}n.use=function(t){n.ES6=t},e.exports=n},{}],2:[function(t,e,r){(function(n){r.Error=t("./error"),r.Schema=t("./schema"),r.Types=t("./types"),r.VirtualType=t("./virtualtype"),r.SchemaType=t("./schematype.js"),r.utils=t("./utils.js"),r.Document=t("./document_provider.js")(),"undefined"!=typeof window&&(window.mongoose=e.exports,window.Buffer=n)}).call(this,t("buffer").Buffer)},{"./document_provider.js":6,"./error":12,"./schema":26,"./schematype.js":39,"./types":45,"./utils.js":48,"./virtualtype":49,buffer:71}],3:[function(t,e,r){function n(t,e,r,i,f){if(!(this instanceof n))return new n(t,e,r,i,f);if(c.isObject(e)&&!e.instanceOfSchema&&(e=new a(e)),e=this.schema||e,!this.schema&&e.options._id&&(t=t||{},void 0===t._id&&(t._id=new u)),!e)throw new s.MissingSchemaError;this.$__setSchema(e),this.$__=new l,this.$__.emitter=new o,this.isNew=!0,this.errors=void 0,"boolean"==typeof r?(this.$__.strictMode=r,r=void 0):(this.$__.strictMode=this.schema.options&&this.schema.options.strict,this.$__.selected=r);for(var h=this.schema.requiredPaths(),p=0;p<h.length;++p)this.$__.activePaths.require(h[p]);this.$__.emitter.setMaxListeners(0),this._doc=this.$__buildDoc(t,r,i),!f&&t&&this.init(t),this.$__registerHooksFromSchema();for(var d in e.methods)this[d]=e.methods[d];for(var _ in e.statics)this[_]=e.statics[_]}var i=t("./document"),o=t("events").EventEmitter,s=t("./error"),a=t("./schema"),u=t("./types/objectid"),c=t("./utils"),f=s.ValidationError,l=t("./internal");n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.ValidationError=f,e.exports=r=n},{"./document":5,"./error":12,"./internal":23,"./schema":26,"./types/objectid":46,"./utils":48,events:74}],4:[function(t,e,r){function n(t,e){if(Array.isArray(t))t.forEach(function(r,o){return Array.isArray(r)||i.isObject(r)?n(r,e):void(t[o]=e.castForQuery(r))});else for(var r=Object.keys(t),o=r.length;o--;){var s=r[o],a=t[s];Array.isArray(a)||i.isObject(a)?(n(a,e),t[s]=a):t[s]=e.castForQuery(a)}}var i=t("./utils"),o=t("./schema/index");e.exports=function t(e,r){for(var s,a,u,c,f,l,h=Object.keys(r),p=h.length;p--;)if(c=h[p],l=r[c],"$or"===c||"$nor"===c||"$and"===c)for(var d=l.length;d--;)l[d]=t(e,l[d]);else{if("$where"===c){if(f=typeof l,"string"!==f&&"function"!==f)throw new Error("Must have a string or function for $where");"function"===f&&(r[c]=l.toString());continue}if("$elemMatch"===c)l=t(e,l);else{if(!e)continue;if(a=e.path(c)){if(null===l||void 0===l){r[c]=null;continue}if("Object"===l.constructor.name)if(s=Object.keys(l).some(function(t){return"$"===t.charAt(0)&&"$id"!==t&&"$ref"!==t})){var _,y=Object.keys(l);for(d=y.length;d--;)if(_=y[d],u=l[_],"$exists"!==_){if("$type"!==_)"$not"===_?t(e,u):l[_]=a.castForQuery(_,u);else if("number"!=typeof u)throw new Error("$type parameter must be Number")}else if("boolean"!=typeof u)throw new Error("$exists parameter must be Boolean")}else r[c]=a.castForQuery(l);else r[c]=a.castForQuery(l)}else{for(var g,v,m,b=c.split("."),w=b.length;w--&&(g=b.slice(0,w).join("."),!(a=e.path(g))););if(a){a.caster&&a.caster.schema?(m={},v=b.slice(w).join("."),m[v]=l,r[c]=t(a.caster.schema,m)[v]):r[c]=l;continue}if(i.isObject(l)){var E=l.$near?"$near":l.$nearSphere?"$nearSphere":l.$within?"$within":l.$geoIntersects?"$geoIntersects":"";if(!E)continue;var O=new o.Number("__QueryCasting__"),A=l[E];if(l.$maxDistance&&(l.$maxDistance=O.castForQuery(l.$maxDistance)),"$within"===E){var S=A.$center||A.$centerSphere||A.$box||A.$polygon;if(!S)throw new Error("Bad $within paramater: "+JSON.stringify(l));A=S}else"$near"===E&&"string"==typeof A.type&&Array.isArray(A.coordinates)?A=A.coordinates:("$near"===E||"$nearSphere"===E||"$geoIntersects"===E)&&A.$geometry&&"string"==typeof A.$geometry.type&&Array.isArray(A.$geometry.coordinates)&&(A=A.$geometry.coordinates);n(A,O)}}}}return r}},{"./schema/index":33,"./utils":48}],5:[function(t,e,r){(function(n,i){function o(t,e,r){this.$__=new N,this.$__.emitter=new _,this.isNew=!0,this.errors=void 0;var n=this.schema;"boolean"==typeof e?(this.$__.strictMode=e,e=void 0):(this.$__.strictMode=n.options&&n.options.strict,this.$__.selected=e);for(var i=n.requiredPaths(!0),s=0;s<i.length;++s)this.$__.activePaths.require(i[s]);if(this.$__.emitter.setMaxListeners(0),this._doc=this.$__buildDoc(t,e,r),t&&(t instanceof o&&(this.isNew=t.isNew),this.set(t,void 0,!0)),!n.options.strict&&t){var a=this,u=Object.keys(this._doc);u.forEach(function(t){t in n.tree||c(t,null,a)})}this.$__registerHooksFromSchema()}function s(t,e,r,n){n=n||"";for(var i,o,a,u=Object.keys(e),c=u.length;c--;)if(a=u[c],o=n+a,i=t.schema.path(o),i||!E.isObject(e[a])||e[a].constructor&&"Object"!==E.getFunctionName(e[a].constructor)){if(null===e[a])r[a]=null;else if(void 0!==e[a])if(i)try{r[a]=i.cast(e[a],t,!0)}catch(e){t.invalidate(e.path,new w({path:e.path,message:e.message,type:"cast",value:e.value}))}else r[a]=e[a];t.isModified(o)||t.$__.activePaths.init(o)}else r[a]||(r[a]={}),s(t,e[a],r[a],o+".")}function a(t,e,r,n){for(var i,o,s=Object.keys(t),a=s.length;a--;)o=s[a],i=t[o],c(o,"Object"===E.getFunctionName(i.constructor)&&Object.keys(i).length&&(!i[n.typeKey]||"type"===n.typeKey&&i.type.type)?i:null,e,r,s,n)}function u(t){var e={};return Object.getOwnPropertyNames(t).forEach(function(r){e[r]=Object.getOwnPropertyDescriptor(t,r),e[r].enumerable=!0}),e}function c(t,e,r,n,i,s){var c=(n?n+".":"")+t;n=n||"",e?Object.defineProperty(r,t,{enumerable:!0,configurable:!0,get:function(){var t=this;if(this.$__.getters||(this.$__.getters={}),!this.$__.getters[c]){var r=Object.create(Object.getPrototypeOf(this),u(this));n||(r.$__.scope=this);for(var o=0,f=i.length;f>o;++o)Object.defineProperty(r,i[o],{enumerable:!1,writable:!0,configurable:!0,value:void 0});Object.defineProperty(r,"toObject",{enumerable:!0,configurable:!0,writable:!1,value:function(){return t.get(c)}}),Object.defineProperty(r,"toJSON",{enumerable:!0,configurable:!0,writable:!1,value:function(){return t.get(c)}}),Object.defineProperty(r,"$__isNested",{enumerable:!0,configurable:!0,writable:!1,value:!0}),a(e,r,c,s),this.$__.getters[c]=r}return this.$__.getters[c]},set:function(t){return t instanceof o&&(t=t.toObject()),(this.$__.scope||this).set(c,t)}}):Object.defineProperty(r,t,{enumerable:!0,configurable:!0,get:function(){return this.get.call(this.$__.scope||this,c)},set:function(t){return this.set.call(this.$__.scope||this,c,t)}})}function f(t){for(var e,r,n,i=Object.keys(t),o=i.length;o--;)r=i[o],n=t[r],E.isObject(n)&&(t[r]=f(n)),void 0!==t[r]?e=!0:delete t[r];return e?t:void 0}function l(t,e,r,n){for(var i,o=t.schema,s=Object.keys(o[r]),a=s.length;a--;){i=s[a];for(var u,c=i.split("."),f=c.length,l=f-1,h=e,p=0;f>p;++p)u=c[p],p===l?h[u]=O(t.get(i),n):h=h[u]||(h[u]={})}return e}var h,p,d,_=t("events").EventEmitter,y=t("./error"),g=t("./schema/mixed"),v=t("./schema"),m=t("./error/objectExpected"),b=t("./error/strict"),w=t("./schematype").ValidatorError,E=t("./utils"),O=E.clone,A=E.isMongooseObject,S=t("util").inspect,j=y.ValidationError,N=t("./internal"),x=E.deepEqual,B=t("hooks-fixed"),T=t("./promise_provider");E.each(["on","once","emit","listeners","removeListener","setMaxListeners","removeAllListeners","addListener"],function(t){o.prototype[t]=function(){return this.$__.emitter[t].apply(this.$__.emitter,arguments)}}),o.prototype.constructor=o,o.prototype.schema,o.prototype.isNew,o.prototype.id,o.prototype.errors,o.prototype.$__buildDoc=function(t,e,r){var n,i,o={},s=null,a=this;if(e&&"Object"===E.getFunctionName(e.constructor))if(n=Object.keys(e),i=n.length,1===i&&"_id"===n[0])s=!!e[n[i]];else for(;i--;)if("_id"!==n[i]&&(!e[n[i]]||"object"!=typeof e[n[i]])){s=!e[n[i]];break}for(var u=Object.keys(this.schema.paths),c=u.length,f=0;c>f;++f){var l=u[f];if("_id"===l){if(r)continue;if(t&&"_id"in t)continue}for(var h=this.schema.paths[l],p=l.split("."),d=p.length,_=d-1,y="",g=o,v=0,m=!1;d>v;++v){var b,w=p[v];if(y+=w,s===!0){if(y in e)break}else e&&y in e&&(m=!0);if(v===_)if(e&&null!==s)if(s===!0){if(l in e)continue;b=h.getDefault(a,!0),"undefined"!=typeof b&&(g[w]=b,a.$__.activePaths.default(l))}else m&&(b=h.getDefault(a,!0),"undefined"!=typeof b&&(g[w]=b,a.$__.activePaths.default(l)));else b=h.getDefault(a,!0),"undefined"!=typeof b&&(g[w]=b,a.$__.activePaths.default(l));else g=g[w]||(g[w]={}),y+="."}}return o},o.prototype.init=function(t,e,r){if("function"==typeof e&&(r=e,e=null),this.isNew=!1,null!==t._id&&void 0!==t._id&&e&&e.populated&&e.populated.length)for(var n=String(t._id),i=0;i<e.populated.length;++i){var o=e.populated[i];this.populated(o.path,o._docs[n],o)}return s(this,t,this._doc),this.$__storeShard(),this.emit("init",this),r&&r(null),this},o.prototype.$__storeShard=function(){var t=this.schema.options.shardKey||this.schema.options.shardkey;if(t&&"Object"===E.getFunctionName(t.constructor))for(var e,r=this.$__.shardval={},n=Object.keys(t),i=n.length,o=0;i>o;++o)e=this.getValue(n[o]),A(e)?r[n[o]]=e.toObject({depopulate:!0}):null===e||void 0===e||!e.valueOf||e.constructor&&"Date"===E.getFunctionName(e.constructor)?r[n[o]]=e:r[n[o]]=e.valueOf()};for(var k in B)"pre"===k||"post"===k?o.prototype["$"+k]=o["$"+k]=B[k]:o.prototype[k]=o[k]=B[k];o.prototype.update=function(){var t=E.args(arguments);return t.unshift({_id:this._id}),this.constructor.update.apply(this.constructor,t)},o.prototype.set=function(t,e,r,n){r&&"Object"===E.getFunctionName(r.constructor)&&(n=r,r=void 0);var i,s=n&&n.merge,a=r&&r!==!0,u=r===!0,c=n&&"strict"in n?n.strict:this.$__.strictMode;if(a&&(i=this.$__.adhocPaths||(this.$__.adhocPaths={}),i[t]=v.interpretAsType(t,r,this.schema.options)),"string"!=typeof t){if(null!==t&&void 0!==t){var f=e?e+".":"";t instanceof o&&(t=t.$__isNested?t.toObject():t._doc);for(var l,h,p=Object.keys(t),d=p.length;d--;){h=p[d];var _=f+h;if(l=this.schema.pathType(_),null===t[h]||void 0===t[h]||!E.isObject(t[h])||t[h].constructor&&"Object"!==E.getFunctionName(t[h].constructor)||"virtual"===l||"real"===l||this.$__path(_)instanceof g||this.schema.paths[_]&&this.schema.paths[_].options&&this.schema.paths[_].options.ref)if(c){if(u&&void 0===t[h]&&void 0!==this.get(h))continue;if("real"===l||"virtual"===l)this.schema.paths[_]&&this.schema.paths[_].$isSingleNested&&t[h]instanceof o&&(t[h]=t[h].toObject({virtuals:!1})),this.set(f+h,t[h],u);else if("nested"===l&&t[h]instanceof o)this.set(f+h,t[h].toObject({virtuals:!1}),u);else if("throw"===c)throw"nested"===l?new m(h,t[h]):new b(h)}else void 0!==t[h]&&this.set(f+h,t[h],u);else this.set(t[h],f+h,u)}return this}var w=t;t=e,e=w}var O=this.schema.pathType(t);if("nested"===O&&e)return!E.isObject(e)||e.constructor&&"Object"!==E.getFunctionName(e.constructor)?(this.invalidate(t,new y.CastError("Object",e,t)),this):(s||this.setValue(t,null),this.set(e,t,u),this);var A,S=t.split(".");if("adhocOrUndefined"===O&&c){var j;for(d=0;d<S.length;++d){var N=S.slice(0,d+1).join(".");if(A=this.schema.path(N),A instanceof g){j=!0;break}}if(!j){if("throw"===c)throw new b(t);return this}}else{if("virtual"===O)return A=this.schema.virtualpath(t),A.applySetters(e,this),this;A=this.$__path(t)}var x;if(S.length<=1)x=t;else{for(d=0;d<S.length;++d)if(N=S.slice(0,d+1).join("."),this.isDirectModified(N)||null===this.get(N)){x=N;break}x||(x=t)}var B=u?void 0:this.getValue(t);if(!A)return this.$__set(x,t,u,S,A,e,B),this;var T=!0;try{var k=!1;A.options&&A.options.ref&&e instanceof o&&A.options.ref===e.constructor.modelName&&(this.ownerDocument?this.ownerDocument().populated(this.$__fullPath(t),e._id,{model:e.constructor}):this.populated(t,e._id,{model:e.constructor}),k=!0);var $;A.options&&Array.isArray(A.options.type)&&A.options.type.length&&A.options.type[0].ref&&Array.isArray(e)&&e.length>0&&e[0]instanceof o&&e[0].constructor.modelName&&A.options.type[0].ref===e[0].constructor.modelName&&(this.ownerDocument?($={model:e[0].constructor},this.ownerDocument().populated(this.$__fullPath(t),e.map(function(t){return t._id}),$)):($={model:e[0].constructor},this.populated(t,e.map(function(t){return t._id}),$)),k=!0),e=A.applySetters(e,this,!1,B),!k&&this.$__.populated&&delete this.$__.populated[t],this.$markValid(t)}catch(r){var I;r instanceof y.CastError||(I=r),this.invalidate(t,new y.CastError(A.instance,e,t,I)),T=!1}return T&&this.$__set(x,t,u,S,A,e,B),this},o.prototype.$__shouldModify=function(t,e,r,n,i,s,a){return this.isNew?!0:void 0!==s||this.isSelected(e)?void 0===s&&e in this.$__.activePaths.states.default?!1:this.populated(e)&&s instanceof o&&x(s._id,a)?!1:x(s,a||this.get(e))?!r&&null!==s&&void 0!==s&&e in this.$__.activePaths.states.default&&x(s,i.getDefault(this,r))?!0:!1:!0:!0},o.prototype.$__set=function(e,r,n,i,o,s,a){d=d||t("./types/embedded");var u=this.$__shouldModify(e,r,n,i,o,s,a),c=this;u&&(this.markModified(e,s),p||(p=t("./types/array")),s&&s.isMongooseArray&&(s._registerAtomic("$set",s),this.$__.activePaths.forEach(function(t){0===t.indexOf(r+".")&&c.$__.activePaths.ignore(t)})));for(var f=this._doc,l=0,h=i.length;h>l;l++){var _=l+1,y=_===h;y?f[i[l]]=s:f=f[i[l]]&&"Object"===E.getFunctionName(f[i[l]].constructor)?f[i[l]]:f[i[l]]&&f[i[l]]instanceof d?f[i[l]]:f[i[l]]&&f[i[l]].$isSingleNested?f[i[l]]:f[i[l]]&&Array.isArray(f[i[l]])?f[i[l]]:f[i[l]]={}}},o.prototype.getValue=function(t){return E.getValue(t,this._doc)},o.prototype.setValue=function(t,e){return E.setValue(t,e,this._doc),this},o.prototype.get=function(t,e){var r;e&&(r=v.interpretAsType(t,e,this.schema.options));for(var n=this.$__path(t)||this.schema.virtualpath(t),i=t.split("."),o=this._doc,s=0,a=i.length;a>s;s++)o=null===o||void 0===o?void 0:o[i[s]];return r&&(o=r.cast(o)),n&&!this.populated(t)&&(o=n.applyGetters(o,this)),o},o.prototype.$__path=function(t){var e=this.$__.adhocPaths,r=e&&e[t];return r?r:this.schema.path(t)},o.prototype.markModified=function(t){this.$__.activePaths.modify(t)},o.prototype.modifiedPaths=function(){var t=Object.keys(this.$__.activePaths.states.modify);return t.reduce(function(t,e){var r=e.split(".");return t.concat(r.reduce(function(t,e,n){return t.concat(r.slice(0,n).concat(e).join("."))},[]))},[])},o.prototype.isModified=function(t){return t?!!~this.modifiedPaths().indexOf(t):this.$__.activePaths.some("modify")},o.prototype.$isDefault=function(t){return t in this.$__.activePaths.states.default},o.prototype.isDirectModified=function(t){return t in this.$__.activePaths.states.modify},o.prototype.isInit=function(t){return t in this.$__.activePaths.states.init},o.prototype.isSelected=function(t){if(this.$__.selected){if("_id"===t)return 0!==this.$__.selected._id;var e,r=Object.keys(this.$__.selected),n=r.length,i=!1;if(1===n&&"_id"===r[0])return 0===this.$__.selected._id;for(;n--;)if(e=r[n],"_id"!==e){i=!!this.$__.selected[e];break}if(t in this.$__.selected)return i;n=r.length;for(var o=t+".";n--;)if(e=r[n],"_id"!==e){if(0===e.indexOf(o))return i;if(0===o.indexOf(e+"."))return i}return!i}return!0},o.prototype.validate=function(t,e){var r=this,n=T.get();return"function"==typeof t&&(e=t,t=null),t&&t.__noPromise?void this.$__validate(e):new n.ES6(function(t,n){r.$__validate(function(r){return e&&e(r),r?void n(r):void t()})})},o.prototype.$__validate=function(t){var e=this,r=function(){var t=e.$__.validationError;if(e.$__.validationError=void 0,e.emit("validate",e),t){for(var r in t.errors)!e.__parent&&t.errors[r]instanceof y.CastError&&e.invalidate(r,t.errors[r]);return t}},o=Object.keys(this.$__.activePaths.states.require).filter(function(t){return e.isSelected(t)||e.isModified(t)?!0:!1});o=o.concat(Object.keys(this.$__.activePaths.states.init)),o=o.concat(Object.keys(this.$__.activePaths.states.modify)),o=o.concat(Object.keys(this.$__.activePaths.states.default)),0===o.length&&n.nextTick(function(){var e=r();return e?void t(e):void t()});for(var s={},a=0,u=0;u<o.length;++u){var c=o[u],f=e.getValue(c);if(f&&f.isMongooseArray&&!i.isBuffer(f)&&!f.isMongooseDocumentArray)for(var l=f.length,h=0;l>h;++h)o.push(c+"."+h)}var p=function(){var e=r();return e?void t(e):void t()},d=function(t){s[t]||(s[t]=!0,a++,n.nextTick(function(){var r=e.schema.path(t);if(!r)return--a||p();if(!e.$isValid(t))return void(--a||p());var n=e.getValue(t);r.doValidate(n,function(r){r&&e.invalidate(t,r,void 0,!0),--a||p()},e)}))};o.forEach(d)},o.prototype.validateSync=function(t){var e=this;"string"==typeof t&&(t=t.split(" "));var r=Object.keys(this.$__.activePaths.states.require).filter(function(t){return e.isSelected(t)||e.isModified(t)?!0:!1});if(r=r.concat(Object.keys(this.$__.activePaths.states.init)),r=r.concat(Object.keys(this.$__.activePaths.states.modify)),r=r.concat(Object.keys(this.$__.activePaths.states.default)),t&&t.length){for(var n=[],i=0;i<r.length;++i)-1!==t.indexOf(r[i])&&n.push(r[i]);r=n}var o={};r.forEach(function(t){if(!o[t]){o[t]=!0;var r=e.schema.path(t);if(r&&e.$isValid(t)){var n=e.getValue(t),i=r.doValidateSync(n,e);i&&e.invalidate(t,i,void 0,!0)}}});var s=e.$__.validationError;if(e.$__.validationError=void 0,e.emit("validate",e),s)for(var a in s.errors)s.errors[a]instanceof y.CastError&&e.invalidate(a,s.errors[a]);return s},o.prototype.invalidate=function(t,e,r,n){return this.$__.validationError||(this.$__.validationError=new j(this)),this.$__.validationError.errors[t]?void 0:(e&&"string"!=typeof e||(e=new w({path:t,message:e,type:n||"user defined",value:r})),this.$__.validationError===e?this.$__.validationError:(this.$__.validationError.errors[t]=e,this.$__.validationError))},o.prototype.$markValid=function(t){this.$__.validationError&&this.$__.validationError.errors[t]&&(delete this.$__.validationError.errors[t],0===Object.keys(this.$__.validationError.errors).length&&(this.$__.validationError=null))},o.prototype.$isValid=function(t){return!this.$__.validationError||!this.$__.validationError.errors[t]},o.prototype.$__reset=function(){var e=this;return h||(h=t("./types/documentarray")),this.$__.activePaths.map("init","modify",function(t){return e.getValue(t)}).filter(function(t){return t&&t instanceof Array&&t.isMongooseDocumentArray&&t.length}).forEach(function(t){for(var e=t.length;e--;){var r=t[e];r&&r.$__reset()}}),this.$__dirty().forEach(function(t){var e=t.value;e&&e._atomics&&(e._atomics={})}),this.$__.activePaths.clear("modify"),this.$__.activePaths.clear("default"),this.$__.validationError=void 0,this.errors=void 0,e=this,this.schema.requiredPaths().forEach(function(t){e.$__.activePaths.require(t)}),this},o.prototype.$__dirty=function(){var t=this,e=this.$__.activePaths.map("modify",function(e){return{path:e,value:t.getValue(e),schema:t.$__path(e)}});e=e.concat(this.$__.activePaths.map("default",function(e){return"_id"!==e&&t.getValue(e)?{path:e,value:t.getValue(e),schema:t.$__path(e)}:void 0})),e.sort(function(t,e){return t.path<e.path?-1:t.path>e.path?1:0});var r,n,i=[];return e.forEach(function(t){t&&(0!==t.path.indexOf(r)?(r=t.path+".",i.push(t),n=t):n.value&&n.value._atomics&&n.value.hasAtomics()&&(n.value._atomics={},n.value._atomics.$set=n.value))}),n=r=null,i},o.prototype.$__setSchema=function(t){a(t.tree,this,void 0,t.options),this.schema=t},o.prototype.$__getArrayPathsToValidate=function(){return h||(h=t("./types/documentarray")),this.$__.activePaths.map("init","modify",function(t){return this.getValue(t)}.bind(this)).filter(function(t){return t&&t instanceof Array&&t.isMongooseDocumentArray&&t.length}).reduce(function(t,e){return t.concat(e)},[]).filter(function(t){return t})},o.prototype.$__getAllSubdocs=function(){function e(t,r){var n=this[r];return n instanceof d&&t.push(n),n&&n.$isSingleNested&&(t=Object.keys(n._doc).reduce(e.bind(n._doc),t),t.push(n)),n&&n.isMongooseDocumentArray?n.forEach(function(r){r&&r._doc&&(r instanceof d&&t.push(r),t=Object.keys(r._doc).reduce(e.bind(r._doc),t))}):n instanceof o&&n.$__isNested&&(n=n.toObject(),n&&(t=Object.keys(n).reduce(e.bind(n),t))),t}h||(h=t("./types/documentarray")),d=d||t("./types/embedded");var r=Object.keys(this._doc).reduce(e.bind(this),[]);return r},o.prototype.$__registerHooksFromSchema=function(){d=d||t("./types/embedded");var e=T.get(),r=this,n=r.schema&&r.schema.callQueue;if(!n.length)return r;var i=n.reduce(function(t,e){if("pre"!==e[0]&&"post"!==e[0]&&"on"!==e[0])return r[e[0]].apply(r,e[1]),t;var n=[].slice.call(e[1]),i="on"===e[0]?"post":n[0];return i in t||(t[i]={post:[],pre:[]}),"post"===e[0]?t[i].post.push(n):"on"===e[0]?t[i].push(n):t[i].pre.push(n),t},{post:[]});return i.post.forEach(function(t){r.on.apply(r,t)}),delete i.post,i.init&&r instanceof d?(i.init.pre&&i.init.pre.forEach(function(t){r.$pre.apply(r,t)}),i.init.post&&i.init.post.forEach(function(t){r.$post.apply(r,t)}),delete i.init):i.set&&(i.set.pre&&i.set.pre.forEach(function(t){r.$pre.apply(r,t)}),i.set.post&&i.set.post.forEach(function(t){r.$post.apply(r,t)}),delete i.set),Object.keys(i).forEach(function(t){var n="$__original_"+t;r[t]&&(r[n]=r[t],r[t]=function(){var t,i=[].slice.call(arguments),o=i.pop();return new e.ES6(function(e,s){o&&"function"!=typeof o?i.push(o):t=o,i.push(function(n,i){return n?(r.$__handleReject(n),t&&t(n),void s(n)):(t&&t.apply(null,[null].concat(Array.prototype.slice.call(arguments,1))),void e(i))}),r[n].apply(r,i)})},i[t].pre.forEach(function(t){t[0]=n,r.$pre.apply(r,t)}),i[t].post.forEach(function(t){t[0]=n,r.$post.apply(r,t)}))}),r},o.prototype.$__handleReject=function(t){this.listeners("error").length?this.emit("error",t):this.constructor.listeners&&this.constructor.listeners("error").length?this.constructor.emit("error",t):this.listeners&&this.listeners("error").length&&this.emit("error",t)},o.prototype.$toObject=function(t,e){var r={transform:!0,json:e};if(t&&t.depopulate&&!t._skipDepopulateTopLevel&&this.$__.wasPopulated)return O(this._id,t);t&&t._skipDepopulateTopLevel&&(t._skipDepopulateTopLevel=!1),(!t||"Object"!==E.getFunctionName(t.constructor)||t&&t._useSchemaOptions)&&(e?(t=this.schema.options.toJSON?O(this.schema.options.toJSON):{},t.json=!0,t._useSchemaOptions=!0):(t=this.schema.options.toObject?O(this.schema.options.toObject):{},t.json=!1,t._useSchemaOptions=!0));for(var n in r)void 0===t[n]&&(t[n]=r[n]);"minimize"in t||(t.minimize=this.schema.options.minimize);var i=t.transform,o=O(this._doc,t)||{};t.getters&&(l(this,o,"paths",t),t.minimize&&(o=f(o)||{})),(t.virtuals||t.getters&&t.virtuals!==!1)&&l(this,o,"virtuals",t),t.versionKey===!1&&this.schema.options.versionKey&&delete o[this.schema.options.versionKey];var s=t.transform;if(s===!0||this.schema.options.toObject&&s){var a=t.json?this.schema.options.toJSON:this.schema.options.toObject;a&&(s="function"==typeof t.transform?t.transform:a.transform)}else t.transform=i;if("function"==typeof s){var u=s(this,o,t);"undefined"!=typeof u&&(o=u)}return o},o.prototype.toObject=function(t){return this.$toObject(t)},o.prototype.toJSON=function(t){return this.$toObject(t,!0)},o.prototype.inspect=function(t){var e,r=t&&"Object"===E.getFunctionName(t.constructor);return e=r?t:this.schema.options.toObject?O(this.schema.options.toObject):{},e.minimize=!1,e.retainKeyOrder=!0,this.toObject(e)},o.prototype.toString=function(){return S(this.inspect())},o.prototype.equals=function(t){var e=this.get("_id"),r=t.get?t.get("_id"):t;return e||r?e&&e.equals?e.equals(r):e===r:x(this,t)},o.prototype.populate=function(){if(0===arguments.length)return this;var t,e=this.$__.populate||(this.$__.populate={}),r=E.args(arguments);if("function"==typeof r[r.length-1]&&(t=r.pop()),r.length)for(var n=E.populate.apply(null,r),i=0;i<n.length;++i)e[n[i].path]=n[i];if(t){var o=E.object.vals(e);this.$__.populate=void 0,o.__noPromise=!0,this.constructor.populate(this,o,t)}return this},o.prototype.execPopulate=function(){var t=T.get(),e=this;return new t.ES6(function(t,r){e.populate(function(e,n){e?r(e):t(n)})})},o.prototype.populated=function(t,e,r){if(null!==e&&void 0!==e){if(e===!0){if(!this.$__.populated)return;return this.$__.populated[t]}return this.$__.populated||(this.$__.populated={}),this.$__.populated[t]={value:e,options:r},e}if(this.$__.populated){var n=this.$__.populated[t];return n?n.value:void 0}},o.prototype.depopulate=function(t){var e=this.populated(t);e&&(delete this.$__.populated[t],this.set(t,e))},o.prototype.$__fullPath=function(t){return t||""},o.ValidationError=j,e.exports=r=o}).call(this,t("g5I+bs"),t("buffer").Buffer)},{"./error":12,"./error/objectExpected":17,"./error/strict":19,"./internal":23,"./promise_provider":25,"./schema":26,"./schema/mixed":34,"./schematype":39,"./types/array":41,"./types/documentarray":43,"./types/embedded":44,"./utils":48,buffer:71,events:74,"g5I+bs":94,"hooks-fixed":75,util:98}],6:[function(t,e,r){"use strict";var n=t("./document.js"),i=t("./browserDocument.js");e.exports=function(){return"undefined"!=typeof window&&"undefined"!=typeof document&&document===window.document?i:n}},{"./browserDocument.js":3,"./document.js":5}],7:[function(t,e,r){e.exports=function(){}},{}],8:[function(t,e,r){var n=t("bson").Binary;e.exports=r=n},{bson:55}],9:[function(t,e,r){r.Binary=t("./binary"),r.ObjectId=t("./objectid"),r.ReadPreference=t("./ReadPreference")},{"./ReadPreference":7,"./binary":8,"./objectid":10}],10:[function(t,e,r){var n=t("bson").ObjectID;e.exports=r=n},{bson:55}],11:[function(t,e,r){(function(r){var n;n=t("undefined"==typeof window?r.MONGOOSE_DRIVER_PATH||"./node-mongodb-native":"./browser"),e.exports=n}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./browser":9}],12:[function(t,e,r){function n(t){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this):this.stack=(new Error).stack,this.message=t,this.name="MongooseError"}n.prototype=Object.create(Error.prototype),n.prototype.constructor=Error,e.exports=r=n,n.messages=t("./error/messages"),n.Messages=n.messages,n.CastError=t("./error/cast"),n.ValidationError=t("./error/validation"),n.ValidatorError=t("./error/validator"),n.VersionError=t("./error/version"),n.OverwriteModelError=t("./error/overwriteModel"),n.MissingSchemaError=t("./error/missingSchema"),n.DivergentArrayError=t("./error/divergentArray")},{"./error/cast":13,"./error/divergentArray":14,"./error/messages":15,"./error/missingSchema":16,"./error/overwriteModel":18,"./error/validation":20,"./error/validator":21,"./error/version":22}],13:[function(t,e,r){function n(t,e,r,n){i.call(this,"Cast to "+t+' failed for value "'+e+'" at path "'+r+'"'),Error.captureStackTrace?Error.captureStackTrace(this):this.stack=(new Error).stack,this.name="CastError",this.kind=t,this.value=e,this.path=r,this.reason=n}var i=t("../error.js");n.prototype=Object.create(i.prototype),n.prototype.constructor=i,e.exports=n},{"../error.js":12}],14:[function(t,e,r){function n(t){var e="For your own good, using `document.save()` to update an array which was selected using an $elemMatch projection OR populated using skip, limit, query conditions, or exclusion of the _id field when the operation results in a $pop or $set of the entire array is not supported. The following path(s) would have been modified unsafely:\n "+t.join("\n ")+"\nUse Model.update() to update these arrays instead.";i.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,arguments.callee),this.name="DivergentArrayError"}var i=t("../error.js");n.prototype=Object.create(i.prototype),n.prototype.constructor=i,e.exports=n},{"../error.js":12}],15:[function(t,e,r){var n=e.exports=r={};n.general={},n.general.default="Validator failed for path `{PATH}` with value `{VALUE}`",n.general.required="Path `{PATH}` is required.",n.Number={},n.Number.min="Path `{PATH}` ({VALUE}) is less than minimum allowed value ({MIN}).",n.Number.max="Path `{PATH}` ({VALUE}) is more than maximum allowed value ({MAX}).",n.Date={},n.Date.min="Path `{PATH}` ({VALUE}) is before minimum allowed value ({MIN}).",n.Date.max="Path `{PATH}` ({VALUE}) is after maximum allowed value ({MAX}).",n.String={},n.String.enum="`{VALUE}` is not a valid enum value for path `{PATH}`.",n.String.match="Path `{PATH}` is invalid ({VALUE}).",n.String.minlength="Path `{PATH}` (`{VALUE}`) is shorter than the minimum allowed length ({MINLENGTH}).",n.String.maxlength="Path `{PATH}` (`{VALUE}`) is longer than the maximum allowed length ({MAXLENGTH})."},{}],16:[function(t,e,r){function n(t){var e="Schema hasn't been registered for model \""+t+'".\nUse mongoose.model(name, schema)';i.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,arguments.callee),this.name="MissingSchemaError"}var i=t("../error.js");n.prototype=Object.create(i.prototype),n.prototype.constructor=i,e.exports=n},{"../error.js":12}],17:[function(t,e,r){function n(t,e){i.call(this,"Tried to set nested object field `"+t+"` to primitive value `"+e+"` and strict mode is set to throw."),Error.captureStackTrace?Error.captureStackTrace(this):this.stack=(new Error).stack,this.name="ObjectExpectedError",this.path=t}var i=t("../error.js");n.prototype=Object.create(i.prototype),n.prototype.constructor=i,e.exports=n},{"../error.js":12}],18:[function(t,e,r){function n(t){i.call(this,"Cannot overwrite `"+t+"` model once compiled."),Error.captureStackTrace&&Error.captureStackTrace(this,arguments.callee),this.name="OverwriteModelError"}var i=t("../error.js");n.prototype=Object.create(i.prototype),n.prototype.constructor=i,e.exports=n},{"../error.js":12}],19:[function(t,e,r){function n(t){i.call(this,"Field `"+t+"` is not in schema and strict mode is set to throw."),Error.captureStackTrace?Error.captureStackTrace(this):this.stack=(new Error).stack,this.name="StrictModeError",this.path=t}var i=t("../error.js");n.prototype=Object.create(i.prototype),n.prototype.constructor=i,e.exports=n},{"../error.js":12}],20:[function(t,e,r){function n(t){t&&"model"===t.constructor.name?i.call(this,t.constructor.modelName+" validation failed"):i.call(this,"Validation failed"),Error.captureStackTrace?Error.captureStackTrace(this):this.stack=(new Error).stack,this.name="ValidationError",this.errors={},t&&(t.errors=this.errors)}var i=t("../error.js");n.prototype=Object.create(i.prototype),n.prototype.constructor=i,n.prototype.toString=function(){var t=this.name+": ",e=[];return Object.keys(this.errors).forEach(function(t){this!==this.errors[t]&&e.push(String(this.errors[t]))},this),t+e.join(", ")},e.exports=r=n},{"../error.js":12}],21:[function(t,e,r){function n(t){var e=t.message;e||(e=o.general.default);var r=this.formatMessage(e,t);i.call(this,r),Error.captureStackTrace?Error.captureStackTrace(this):this.stack=(new Error).stack,this.properties=t,this.name="ValidatorError",this.kind=t.type,this.path=t.path,this.value=t.value}var i=t("../error.js"),o=i.messages;n.prototype=Object.create(i.prototype),n.prototype.constructor=i,Object.defineProperty(n.prototype,"properties",{enumerable:!1,writable:!0,value:null}),n.prototype.formatMessage=function(t,e){for(var r=Object.keys(e),n=0;n<r.length;++n){var i=r[n];"message"!==i&&(t=t.replace("{"+i.toUpperCase()+"}",e[i]))}return t},n.prototype.toString=function(){return this.message},e.exports=n},{"../error.js":12}],22:[function(t,e,r){function n(){i.call(this,"No matching document found."),Error.captureStackTrace&&Error.captureStackTrace(this,arguments.callee),this.name="VersionError"}var i=t("../error.js");n.prototype=Object.create(i.prototype),n.prototype.constructor=i,e.exports=n},{"../error.js":12}],23:[function(t,e,r){function n(){this.strictMode=void 0,this.selected=void 0,this.shardval=void 0,this.saveError=void 0,this.validationError=void 0,this.adhocPaths=void 0,this.removing=void 0,this.inserting=void 0,this.version=void 0,this.getters={},this._id=void 0,this.populate=void 0,this.populated=void 0,this.wasPopulated=!1,this.scope=void 0,this.activePaths=new o,this.ownerDocument=void 0,
2
+ this.fullPath=void 0}var i=t("./statemachine"),o=i.ctor("require","modify","init","default","ignore");e.exports=r=n},{"./statemachine":40}],24:[function(t,e,r){function n(t){i.call(this,t)}var i=t("mpromise"),o=t("util");n.ES6=function(t){var e=new n;return t(function(){e.complete.apply(e,arguments)},function(t){e.error(t)}),e},n.prototype=Object.create(i.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),n.SUCCESS="complete",n.FAILURE="err",n.prototype.error=function(t){return t instanceof Error||(t instanceof Object&&(t=o.inspect(t)),t=new Error(t)),this.reject(t)},n.prototype.resolve=function(t){return t?this.error(t):this.fulfill.apply(this,Array.prototype.slice.call(arguments,1))},n.prototype.addBack=n.prototype.onResolve,n.prototype.complete=i.prototype.fulfill,n.prototype.addCallback=n.prototype.onFulfill,n.prototype.addErrback=n.prototype.onReject,e.exports=n},{mpromise:82,util:98}],25:[function(t,e,r){var n=t("./promise"),i={_promise:n};i.get=function(){return i._promise},i.set=function(e){return e===n?i.reset():(i._promise=t("./ES6Promise"),i._promise.use(e),void(t("mquery").Promise=i._promise.ES6))},i.reset=function(){i._promise=n},e.exports=i},{"./ES6Promise":1,"./promise":24,mquery:87}],26:[function(t,e,r){(function(n){function i(t,e){if(!(this instanceof i))return new i(t,e);this.paths={},this.subpaths={},this.virtuals={},this.singleNestedPaths={},this.nested={},this.inherits={},this.callQueue=[],this._indexes=[],this.methods={},this.statics={},this.tree={},this._requiredpaths=void 0,this.discriminatorMapping=void 0,this._indexedpaths=void 0,this.s={hooks:new p,queryHooks:_},this.options=this.defaultOptions(e),t&&this.add(t);var r=t&&t._id&&h.isObject(t._id),n=!this.paths._id&&!this.options.noId&&this.options._id&&!r;n&&(t={_id:{auto:!0}},t._id[this.options.typeKey]=i.ObjectId,this.add(t));var s=!this.paths.id&&!this.options.noVirtualId&&this.options.id;s&&this.virtual("id").get(o);for(var a=0;a<this._defaultMiddleware.length;++a){var u=this._defaultMiddleware[a];this[u.kind](u.hook,!!u.isAsync,u.fn)}this.options.timestamps&&this.setupTimestamp(this.options.timestamps)}function o(){return this.$__._id?this.$__._id:(this.$__._id=null==this._id?null:String(this._id),this.$__._id)}function s(t,e){var r=e.split(/\.(\d+)\.|\.(\d+)$/).filter(Boolean);if(r.length<2)return t.paths[r[0]];var n=t.path(r[0]),i=!1;if(!n)return n;for(var o,s=r.length-1,a=1;a<r.length;++a){if(i=!1,o=r[a],a===s&&n&&!n.schema&&!/\D/.test(o)){n=n instanceof u.Array?n.caster:void 0;break}if(/\D/.test(o)){if(!n||!n.schema){n=void 0;break}var c=n.schema.pathType(o);i="nested"===c,n=n.schema.path(o)}}return t.subpaths[e]=n,n?"real":i?"nested":"adhocOrUndefined"}function a(t,e){return s(t,e),t.subpaths[e]}var u,c=t("./drivers").ReadPreference,f=t("events").EventEmitter,l=t("./virtualtype"),h=t("./utils"),p=t("kareem"),d=t("async"),_={count:!0,find:!0,findOne:!0,findOneAndUpdate:!0,findOneAndRemove:!0,update:!0};i.prototype=Object.create(f.prototype),i.prototype.constructor=i,i.prototype.instanceOfSchema=!0,Object.defineProperty(i.prototype,"_defaultMiddleware",{configurable:!1,enumerable:!1,writable:!1,value:[{kind:"pre",hook:"save",fn:function(t,e){if(this.ownerDocument)return t();var r,n=e&&"object"==typeof e&&"validateBeforeSave"in e;r=n?!!e.validateBeforeSave:this.schema.options.validateBeforeSave,r?this.$__original_validate?this.$__original_validate({__noPromise:!0},function(e){t(e)}):this.validate({__noPromise:!0},function(e){t(e)}):t()}},{kind:"pre",hook:"save",isAsync:!0,fn:function(t,e){var r=this.$__getAllSubdocs();return!r.length||this.$__preSavingFromParent?(e(),void t()):void d.each(r,function(t,e){t.$__preSavingFromParent=!0,t.save(function(t){e(t)})},function(n){for(var i=0;i<r.length;++i)delete r[i].$__preSavingFromParent;return n?void e(n):(t(),void e())})}}]}),i.prototype.paths,i.prototype.tree,i.prototype.defaultOptions=function(t){return t&&t.safe===!1&&(t.safe={w:0}),t&&t.safe&&0===t.safe.w&&(t.versionKey=!1),t=h.options({strict:!0,bufferCommands:!0,capped:!1,versionKey:"__v",discriminatorKey:"__t",minimize:!0,autoIndex:null,shardKey:null,read:null,validateBeforeSave:!0,noId:!1,_id:!0,noVirtualId:!1,id:!0,typeKey:"type"},t),t.read&&(t.read=c(t.read)),t},i.prototype.add=function(t,e){e=e||"";for(var r=Object.keys(t),n=0;n<r.length;++n){var i=r[n];if(null==t[i])throw new TypeError("Invalid value for schema path `"+e+i+"`");if(Array.isArray(t[i])&&1===t[i].length&&null==t[i][0])throw new TypeError("Invalid value for schema Array path `"+e+i+"`");!h.isObject(t[i])||t[i].constructor&&"Object"!==h.getFunctionName(t[i].constructor)||t[i][this.options.typeKey]&&("type"!==this.options.typeKey||!t[i].type.type)?this.path(e+i,t[i]):Object.keys(t[i]).length?(this.nested[e+i]=!0,this.add(t[i],e+i+".")):this.path(e+i,t[i])}},i.reserved=Object.create(null);var y=i.reserved;y.emit=y.on=y.once=y.listeners=y.removeListener=y.collection=y.db=y.errors=y.init=y.isModified=y.isNew=y.get=y.modelName=y.save=y.schema=y.set=y.toObject=y.validate=y._pres=y._posts=1;var g={};g.increment="`increment` should not be used as a schema path name unless you have disabled versioning.",i.prototype.path=function(t,e){if(void 0===e)return this.paths[t]?this.paths[t]:this.subpaths[t]?this.subpaths[t]:this.singleNestedPaths[t]?this.singleNestedPaths[t]:/\.\d+\.?.*$/.test(t)?a(this,t):void 0;if(y[t])throw new Error("`"+t+"` may not be used as a schema pathname");g[t]&&console.log("WARN: "+g[t]);var r=t.split(/\./),n=r.pop(),o=this.tree;if(r.forEach(function(e,n){if(o[e]||(o[e]={}),"object"!=typeof o[e]){var i="Cannot set nested path `"+t+"`. Parent path `"+r.slice(0,n).concat([e]).join(".")+"` already set to type "+o[e].name+".";throw new Error(i)}o=o[e]}),o[n]=h.clone(e),this.paths[t]=i.interpretAsType(t,e,this.options),this.paths[t].$isSingleNested){for(var s in this.paths[t].schema.paths)this.singleNestedPaths[t+"."+s]=this.paths[t].schema.paths[s];for(s in this.paths[t].schema.singleNestedPaths)this.singleNestedPaths[t+"."+s]=this.paths[t].schema.singleNestedPaths[s]}return this},i.interpretAsType=function(t,e,r){if(e.constructor){var o=h.getFunctionName(e.constructor);if("Object"!==o){var s=e;e={},e[r.typeKey]=s}}var a=!e[r.typeKey]||"type"===r.typeKey&&e.type.type?{}:e[r.typeKey];if("Object"===h.getFunctionName(a.constructor)||"mixed"===a)return new u.Mixed(t,e);if(Array.isArray(a)||Array===a||"array"===a){var c=Array===a||"array"===a?e.cast:a[0];if(c&&c.instanceOfSchema)return new u.DocumentArray(t,c,e);if("string"==typeof c)c=u[c.charAt(0).toUpperCase()+c.substring(1)];else if(c&&(!c[r.typeKey]||"type"===r.typeKey&&c.type.type)&&"Object"===h.getFunctionName(c.constructor)&&Object.keys(c).length){var f={minimize:r.minimize};r.typeKey&&(f.typeKey=r.typeKey);var l=new i(c,f);return new u.DocumentArray(t,l,e)}return new u.Array(t,c||u.Mixed,e)}if(a&&a.instanceOfSchema)return new u.Embedded(a,t,e);var p;if(p=n.isBuffer(a)?"Buffer":"string"==typeof a?a:a.schemaName||h.getFunctionName(a),p&&(p=p.charAt(0).toUpperCase()+p.substring(1)),void 0==u[p])throw new TypeError("Undefined type `"+p+"` at `"+t+"`\n Did you try nesting Schemas? You can only nest using refs or arrays.");return new u[p](t,e)},i.prototype.eachPath=function(t){for(var e=Object.keys(this.paths),r=e.length,n=0;r>n;++n)t(e[n],this.paths[e[n]]);return this},i.prototype.requiredPaths=function(t){if(this._requiredpaths&&!t)return this._requiredpaths;for(var e=Object.keys(this.paths),r=e.length,n=[];r--;){var i=e[r];this.paths[i].isRequired&&n.push(i)}return this._requiredpaths=n,this._requiredpaths},i.prototype.indexedPaths=function(){return this._indexedpaths?this._indexedpaths:(this._indexedpaths=this.indexes(),this._indexedpaths)},i.prototype.pathType=function(t){return t in this.paths?"real":t in this.virtuals?"virtual":t in this.nested?"nested":t in this.subpaths?"real":t in this.singleNestedPaths?"real":/\.\d+\.|\.\d+$/.test(t)?s(this,t):"adhocOrUndefined"},i.prototype.hasMixedParent=function(t){var e=t.split(/\./g);t="";for(var r=0;r<e.length;++r)if(t=r>0?t+"."+e[r]:e[r],t in this.paths&&this.paths[t]instanceof u.Mixed)return!0;return!1},i.prototype.setupTimestamp=function(t){if(t){var e=t.createdAt||"createdAt",r=t.updatedAt||"updatedAt",n={};n[r]=Date,this.paths[e]||(n[e]=Date),this.add(n),this.pre("save",function(t){var n=new Date,i=this._id&&this._id.auto;this[e]||(this[e]=i?this._id.getTimestamp():n),(this.isNew||this.isModified())&&(this[r]=this.isNew?this[e]:n),t()});var i=function(){var t=new Date,n={$set:{},$setOnInsert:{}};return n.$set[r]=t,n.$setOnInsert[e]=t,n};this.pre("findOneAndUpdate",function(t){this.findOneAndUpdate({},i()),t()}),this.pre("update",function(t){this.update({},i()),t()})}},i.prototype.queue=function(t,e){return this.callQueue.push([t,e]),this},i.prototype.pre=function(){var t=arguments[0];return _[t]?(this.s.hooks.pre.apply(this.s.hooks,arguments),this):this.queue("pre",arguments)},i.prototype.post=function(t,e){return _[t]?(this.s.hooks.post.apply(this.s.hooks,arguments),this):e.length<2?this.queue("on",[arguments[0],function(t){return e.call(t,t)}]):this.queue("post",[arguments[0],function(t){var r=this,n=Array.prototype.slice.call(arguments,1);e.call(this,this,function(e){return t.apply(r,[e].concat(n))})}])},i.prototype.plugin=function(t,e){return t(this,e),this},i.prototype.method=function(t,e){if("string"!=typeof t)for(var r in t)this.methods[r]=t[r];else this.methods[t]=e;return this},i.prototype.static=function(t,e){if("string"!=typeof t)for(var r in t)this.statics[r]=t[r];else this.statics[t]=e;return this},i.prototype.index=function(t,e){return e||(e={}),e.expires&&h.expires(e),this._indexes.push([t,e]),this},i.prototype.set=function(t,e,r){if(1===arguments.length)return this.options[t];switch(t){case"read":this.options[t]=c(e,r);break;case"safe":this.options[t]=e===!1?{w:0}:e;break;case"timestamps":this.setupTimestamp(e),this.options[t]=e;break;default:this.options[t]=e}return this},i.prototype.get=function(t){return this.options[t]};var v="2d 2dsphere hashed text".split(" ");Object.defineProperty(i,"indexTypes",{get:function(){return v},set:function(){throw new Error("Cannot overwrite Schema.indexTypes")}}),i.prototype.indexes=function(){"use strict";function t(t,r){var n,i,o,s,a,u,c=t._indexes,f=c.length,l=0;for(l=0;f>l;++l){for(n=c[l][0],s=Object.keys(n),o=s.length,i={},u=0;o>u;++u)a=s[u],i[r+a]=n[a];e.push([i,c[l][1]])}}var e=[],r={},n=function(o,s){if(!r[s]){r[s]=!0,s=s||"";for(var a,c,f,l,p,d,_,y=Object.keys(o.paths),g=0;g<y.length;++g)a=y[g],c=o.paths[a],c instanceof u.DocumentArray||c.$isSingleNested?n(c.schema,a+"."):(f=c._index,f!==!1&&null!==f&&void 0!==f&&(l={},p=h.isObject(f),d=p?f:{},_="string"==typeof f?f:p?f.type:!1,_&&~i.indexTypes.indexOf(_)?l[s+a]=_:d.text?(l[s+a]="text",delete d.text):l[s+a]=1,delete d.type,"background"in d||(d.background=!0),e.push([l,d])));s?t(o,s):(o._indexes.forEach(function(t){"background"in t[1]||(t[1].background=!0)}),e=e.concat(o._indexes))}};return n(this),e},i.prototype.virtual=function(t,e){var r=this.virtuals,n=t.split(".");return r[t]=n.reduce(function(r,i,o){return r[i]||(r[i]=o===n.length-1?new l(e,t):{}),r[i]},this.tree),r[t]},i.prototype.virtualpath=function(t){return this.virtuals[t]},i.prototype.remove=function(t){"string"==typeof t&&(t=[t]),Array.isArray(t)&&t.forEach(function(t){if(this.path(t)){delete this.paths[t];for(var e=t.split("."),r=e.pop(),n=this.tree,i=0;i<e.length;++i)n=n[e[i]];delete n[r]}},this)},i.prototype._getSchema=function(t){function e(t,r){for(var n,i,o=t.length+1;o--;)if(i=t.slice(0,o).join("."),n=r.path(i)){if(n.caster){if(n.caster instanceof u.Mixed)return n.caster;if(o!==t.length&&n.schema)return"$"===t[o]?e(t.slice(o+1),n.schema):e(t.slice(o),n.schema)}return n}}var r=this,n=r.path(t);return n?n:e(t.split("."),r)},i.prototype._getPathType=function(t){function e(t,r){for(var n,i,o=t.length+1;o--;){if(i=t.slice(0,o).join("."),n=r.path(i))return n.caster?n.caster instanceof u.Mixed?{schema:n,pathType:"mixed"}:o!==t.length&&n.schema?"$"===t[o]?o===t.length-1?{schema:n,pathType:"nested"}:e(t.slice(o+1),n.schema):e(t.slice(o),n.schema):{schema:n,pathType:n.$isSingleNested?"nested":"array"}:{schema:n,pathType:"real"};if(o===t.length&&r.nested[i])return{schema:r,pathType:"nested"}}return{schema:n||r,pathType:"undefined"}}var r=this,n=r.path(t);return n?"real":e(t.split("."),r)},e.exports=r=i,i.Types=u=t("./schema/index"),r.ObjectId=u.ObjectId}).call(this,t("buffer").Buffer)},{"./drivers":11,"./schema/index":33,"./utils":48,"./virtualtype":49,async:51,buffer:71,events:74,kareem:79}],27:[function(t,e,r){function n(t,e,r){if(e){var n={};"Object"===m.getFunctionName(e.constructor)&&(e.type?(n=m.clone(e),delete n.type,e=e.type):e=g);var i="string"==typeof e?e:m.getFunctionName(e),o=i in d?d[i]:e;this.casterConstructor=o,this.caster=new o(null,n),this.caster instanceof y||(this.caster.path=t)}h.call(this,t,r,"Array");var s,a,u=this;this.defaultValue&&(s=this.defaultValue,a="function"==typeof s),this.default(function(){var t=a?s():s||[];return new _(t,u.path,this)})}function i(t){return d.Number.prototype.cast.call(this,t)}function o(t,e){t.forEach(function(r,n){Array.isArray(r)?o(r,e):t[n]=i.call(e,r)})}function s(t){return Array.isArray(t)?(o(t,this),t):t&&t.$geometry?a(t,this):n.prototype.castForQuery.call(this,t)}function a(t,e){switch(t.$geometry.type){case"Polygon":case"LineString":case"Point":o(t.$geometry.coordinates,e)}return t.$maxDistance&&(t.$maxDistance=i.call(e,t.$maxDistance)),t}function u(t){var e=this;if(t.$maxDistance&&(t.$maxDistance=i.call(e,t.$maxDistance)),t.$box||t.$polygon){var r=t.$box?"$box":"$polygon";t[r].forEach(function(t){if(!Array.isArray(t)){var e="Invalid $within $box argument. Expected an array, received "+t;throw new TypeError(e)}t.forEach(function(e,r){t[r]=i.call(this,e)})})}else t.$center||t.$centerSphere?(r=t.$center?"$center":"$centerSphere",t[r].forEach(function(e,n){Array.isArray(e)?e.forEach(function(t,r){e[r]=i.call(this,t)}):t[r][n]=i.call(this,e)})):t.$geometry&&a(t,this);return t}function c(t){return Array.isArray(t)||(t=[t]),t=t.map(function(t){if(m.isObject(t)){var e={};return e[this.path]=t,v(this.casterConstructor.schema,e)[this.path]}return t},this),this.castForQuery(t)}function f(t){for(var e,r,n=Object.keys(t),i=n.length,o=0;i>o;++o)e=n[o],r=t[e],0===e.indexOf("$")&&r&&(t[e]=this.castForQuery(e,r));return v(this.casterConstructor.schema,t)}function l(t){var e=t.$geometry;if(e)return a(t,this),t}var h=t("../schematype"),p=h.CastError,d={Boolean:t("./boolean"),Date:t("./date"),Number:t("./number"),String:t("./string"),ObjectId:t("./objectid"),Buffer:t("./buffer")},_=t("../types").Array,y=t("../types").Embedded,g=t("./mixed"),v=t("../cast"),m=t("../utils"),b=m.isMongooseObject;n.schemaName="Array",n.prototype=Object.create(h.prototype),n.prototype.constructor=n,n.prototype.checkRequired=function(t){return!(!t||!t.length)},n.prototype.applyGetters=function(t,e){return this.caster.options&&this.caster.options.ref?t:h.prototype.applyGetters.call(this,t,e)},n.prototype.cast=function(t,e,r){if(Array.isArray(t)){if(!t.length&&e)for(var n=e.schema.indexedPaths(),i=0,o=n.length;o>i;++i){var s=n[i][0][this.path];if("2dsphere"===s||"2d"===s)return}if(t&&t.isMongooseArray||(t=new _(t,this.path,e)),this.caster)try{for(i=0,o=t.length;o>i;i++)t[i]=this.caster.cast(t[i],e,r)}catch(e){throw new p(e.type,t,this.path,e)}return t}return e&&r&&e.markModified(this.path),this.cast([t],e,r)},n.prototype.castForQuery=function(t,e){var r,n;if(2===arguments.length){if(r=this.$conditionalHandlers[t],!r)throw new Error("Can't use "+t+" with Array.");n=r.call(this,e)}else{n=t;var i=this.casterConstructor.prototype,o=i.castForQuery||i.cast,s=this.caster;Array.isArray(n)?n=n.map(function(t){return m.isObject(t)&&t.$elemMatch?t:(o&&(t=o.call(s,t)),b(t)?t.toObject({virtuals:!1}):t)}):o&&(n=o.call(s,n))}return n&&b(n)?n.toObject({virtuals:!1}):n};var w=n.prototype.$conditionalHandlers={};w.$all=c,w.$options=String,w.$elemMatch=f,w.$geoIntersects=l,w.$or=w.$and=function(t){if(!Array.isArray(t))throw new TypeError("conditional $or/$and require array");for(var e=[],r=0;r<t.length;++r)e.push(v(this.casterConstructor.schema,t[r]));return e},w.$near=w.$nearSphere=s,w.$within=w.$geoWithin=u,w.$size=w.$maxDistance=i,w.$eq=w.$gt=w.$gte=w.$in=w.$lt=w.$lte=w.$ne=w.$nin=w.$regex=n.prototype.castForQuery,e.exports=n},{"../cast":4,"../schematype":39,"../types":45,"../utils":48,"./boolean":28,"./buffer":29,"./date":30,"./mixed":34,"./number":35,"./objectid":36,"./string":38}],28:[function(t,e,r){function n(t,e){o.call(this,t,e,"Boolean")}var i=t("../utils"),o=t("../schematype");n.schemaName="Boolean",n.prototype=Object.create(o.prototype),n.prototype.constructor=n,n.prototype.checkRequired=function(t){return t===!0||t===!1},n.prototype.cast=function(t){return null===t?t:"0"===t?!1:"true"===t?!0:"false"===t?!1:!!t},n.$conditionalHandlers=i.options(o.prototype.$conditionalHandlers,{}),n.prototype.castForQuery=function(t,e){var r;return 2===arguments.length?(r=n.$conditionalHandlers[t],r?r.call(this,e):this.cast(e)):this.cast(t)},e.exports=n},{"../schematype":39,"../utils":48}],29:[function(t,e,r){(function(r){function n(t,e){c.call(this,t,e,"Buffer")}function i(t){return this.castForQuery(t)}var o,s=t("./operators/bitwise"),a=t("../utils"),u=t("../types").Buffer,c=t("../schematype"),f=u.Binary,l=c.CastError;n.schemaName="Buffer",n.prototype=Object.create(c.prototype),n.prototype.constructor=n,n.prototype.checkRequired=function(t,e){return c._isRef(this,t,e,!0)?!!t:!(!t||!t.length)},n.prototype.cast=function(e,n,i){var s;if(c._isRef(this,e,n,i)){if(null===e||void 0===e)return e;if(o||(o=t("./../document")),e instanceof o)return e.$__.wasPopulated=!0,e;if(r.isBuffer(e))return e;if(!a.isObject(e))throw new l("buffer",e,this.path);var h=n.$__fullPath(this.path),p=n.ownerDocument?n.ownerDocument():n,d=p.populated(h,!0);return s=new d.options.model(e),s.$__.wasPopulated=!0,s}if(e&&e._id&&(e=e._id),e&&e.isMongooseBuffer)return e;if(r.isBuffer(e))return e&&e.isMongooseBuffer||(e=new u(e,[this.path,n])),e;if(e instanceof f){if(s=new u(e.value(!0),[this.path,n]),"number"!=typeof e.sub_type)throw new l("buffer",e,this.path);return s._subtype=e.sub_type,s}if(null===e)return e;var _=typeof e;if("string"===_||"number"===_||Array.isArray(e))return"number"===_&&(e=[e]),s=new u(e,[this.path,n]);throw new l("buffer",e,this.path)},n.prototype.$conditionalHandlers=a.options(c.prototype.$conditionalHandlers,{$bitsAllClear:s,$bitsAnyClear:s,$bitsAllSet:s,$bitsAnySet:s,$gt:i,$gte:i,$lt:i,$lte:i}),n.prototype.castForQuery=function(t,e){var r;if(2===arguments.length){if(r=this.$conditionalHandlers[t],!r)throw new Error("Can't use "+t+" with Buffer.");return r.call(this,e)}return e=t,this.cast(e).toObject()},e.exports=n}).call(this,t("buffer").Buffer)},{"../schematype":39,"../types":45,"../utils":48,"./../document":5,"./operators/bitwise":37,buffer:71}],30:[function(t,e,r){function n(t,e){a.call(this,t,e,"Date")}function i(t){return this.cast(t)}var o=t("../error").messages,s=t("../utils"),a=t("../schematype"),u=a.CastError;n.schemaName="Date",n.prototype=Object.create(a.prototype),n.prototype.constructor=n,n.prototype.expires=function(t){return this._index&&"Object"===this._index.constructor.name||(this._index={}),this._index.expires=t,s.expires(this._index),this},n.prototype.checkRequired=function(t){return t instanceof Date},n.prototype.min=function(t,e){if(this.minValidator&&(this.validators=this.validators.filter(function(t){return t.validator!==this.minValidator},this)),t){var r=e||o.Date.min;r=r.replace(/{MIN}/,t===Date.now?"Date.now()":this.cast(t).toString());var n=this;this.validators.push({validator:this.minValidator=function(e){var r=t===Date.now?t():n.cast(t);return null===e||e.valueOf()>=r.valueOf()},message:r,type:"min",min:t})}return this},n.prototype.max=function(t,e){if(this.maxValidator&&(this.validators=this.validators.filter(function(t){return t.validator!==this.maxValidator},this)),t){var r=e||o.Date.max;r=r.replace(/{MAX}/,t===Date.now?"Date.now()":this.cast(t).toString());var n=this;this.validators.push({validator:this.maxValidator=function(e){var r=t===Date.now?t():n.cast(t);return null===e||e.valueOf()<=r.valueOf()},message:r,type:"max",max:t})}return this},n.prototype.cast=function(t){if(null===t||void 0===t||""===t)return null;if(t instanceof Date)return t;var e;if("boolean"==typeof t)throw new u("date",t,this.path);if(t instanceof Number||"number"==typeof t||String(t)==Number(t)?e=new Date(Number(t)):t.valueOf&&(e=new Date(t.valueOf())),!isNaN(e.valueOf()))return e;throw new u("date",t,this.path)},n.prototype.$conditionalHandlers=s.options(a.prototype.$conditionalHandlers,{$gt:i,$gte:i,$lt:i,$lte:i}),n.prototype.castForQuery=function(t,e){var r;if(2!==arguments.length)return this.cast(t);if(r=this.$conditionalHandlers[t],!r)throw new Error("Can't use "+t+" with Date.");return r.call(this,e)},e.exports=n},{"../error":12,"../schematype":39,"../utils":48}],31:[function(t,e,r){function n(t,e,r){function n(){c.apply(this,arguments)}n.prototype=Object.create(c.prototype),n.prototype.$__setSchema(e),n.schema=e;for(var i in e.methods)n.prototype[i]=e.methods[i];for(i in e.statics)n[i]=e.statics[i];n.options=r,o.call(this,t,n,r),this.schema=e;var s=this.path,u=this.defaultValue;this.default(function(){var t=u.call(this);return Array.isArray(t)||(t=[t]),new a(t,s,this)})}function i(t,e,r){if(r&&e){for(var n,i,o=t.path+".",s=Object.keys(e),a=s.length,u={};a--;)i=s[a],0===i.indexOf(o)&&(n||(n=!0),u[i.substring(o.length)]=e[i]);return n&&u||void 0}}var o=t("./array"),s=t("../error/cast"),a=t("../types/documentarray"),u=t("../schematype"),c=t("../types/embedded");n.schemaName="DocumentArray",n.prototype=Object.create(o.prototype),n.prototype.constructor=n,n.prototype.doValidate=function(t,e,r,n){u.prototype.doValidate.call(this,t,function(r){function i(t){t&&(o=t),--s||e(o)}if(r)return e(r);var o,s=t&&t.length;if(!s)return e();if(n&&n.updateValidator)return e();for(var a=0,u=s;u>a;++a){var c=t[a];c?c.$__original_validate?c.$__original_validate({__noPromise:!0},i):c.validate({__noPromise:!0},i):--s||e(o)}},r)},n.prototype.doValidateSync=function(t,e){var r=u.prototype.doValidateSync.call(this,t,e);if(r)return r;var n=t&&t.length,i=null;if(n){for(var o=0,s=n;s>o&&!i;++o){var a=t[o];if(a){var c=a.validateSync();c&&(i=c)}}return i}},n.prototype.cast=function(t,e,r,n,o){var u,f,l;if(!Array.isArray(t))return e&&r&&e.markModified(this.path),this.cast([t],e,r,n);if(!(t&&t.isMongooseDocumentArray||o&&o.skipDocumentArrayCast)&&(t=new a(t,this.path,e),n&&n._handlers))for(var h in n._handlers)e.removeListener(h,n._handlers[h]);for(l=t.length;l--;)if(t[l]&&(t[l]instanceof c&&t[l].schema!==this.casterConstructor.schema&&(t[l]=t[l].toObject({virtuals:!1})),!(t[l]instanceof c)&&t[l]))if(r)u||(u=i(this,e.$__.selected,r)),f=new this.casterConstructor(null,t,!0,u,l),t[l]=f.init(t[l]);else{try{f=n.id(t[l]._id)}catch(t){}if(n&&f)f.set(t[l]),t[l]=f;else try{f=new this.casterConstructor(t[l],t,void 0,void 0,l),t[l]=f}catch(e){throw new s("embedded",t[l],t._path,e)}}return t},e.exports=n},{"../error/cast":13,"../schematype":39,"../types/documentarray":43,"../types/embedded":44,"./array":27}],32:[function(t,e,r){function n(t,e,r){var n=function(t,e,r){var n=this;o.apply(this,arguments),this.$parent=r,r&&r.on("save",function(){n.emit("save",n)})};n.prototype=Object.create(o.prototype),n.prototype.$__setSchema(t),n.schema=t,n.$isSingleNested=!0,n.prototype.$basePath=e;for(var s in t.methods)n.prototype[s]=t.methods[s];for(s in t.statics)n[s]=t.statics[s];this.caster=n,this.schema=t,this.$isSingleNested=!0,i.call(this,e,r,"Embedded")}var i=t("../schematype"),o=t("../types/subdocument");e.exports=n,n.prototype=Object.create(i.prototype),n.prototype.$conditionalHandlers.$geoWithin=function(t){return{$geometry:this.castForQuery(t.$geometry)}},n.prototype.cast=function(t,e,r){if(t&&t.$isSingleNested)return t;var n=new this.caster(void 0,e?e.$__.selected:void 0,e);return r?n.init(t):n.set(t,void 0,!0),n},n.prototype.castForQuery=function(t,e){var r;if(2===arguments.length){if(r=this.$conditionalHandlers[t],!r)throw new Error("Can't use "+t);return r.call(this,e)}return e=t,new this.caster(e).toObject({virtuals:!1})},n.prototype.doValidate=function(t,e){i.prototype.doValidate.call(this,t,function(r){return r?e(r):t?void t.validate(e,{__noPromise:!0}):e(null)})},n.prototype.doValidateSync=function(t){var e=i.prototype.doValidateSync.call(this,t);if(e)return e;if(t)return t.validateSync()}},{"../schematype":39,"../types/subdocument":47}],33:[function(t,e,r){r.String=t("./string"),r.Number=t("./number"),r.Boolean=t("./boolean"),r.DocumentArray=t("./documentarray"),r.Embedded=t("./embedded"),r.Array=t("./array"),r.Buffer=t("./buffer"),r.Date=t("./date"),r.ObjectId=t("./objectid"),r.Mixed=t("./mixed"),r.Oid=r.ObjectId,r.Object=r.Mixed,r.Bool=r.Boolean},{"./array":27,"./boolean":28,"./buffer":29,"./date":30,"./documentarray":31,"./embedded":32,"./mixed":34,"./number":35,"./objectid":36,"./string":38}],34:[function(t,e,r){function n(t,e){if(e&&e.default){var r=e.default;Array.isArray(r)&&0===r.length?e.default=Array:!e.shared&&o.isObject(r)&&0===Object.keys(r).length&&(e.default=function(){return{}})}i.call(this,t,e,"Mixed")}var i=t("../schematype"),o=t("../utils");n.schemaName="Mixed",n.prototype=Object.create(i.prototype),n.prototype.constructor=n,n.prototype.cast=function(t){return t},n.prototype.castForQuery=function(t,e){return 2===arguments.length?e:t},e.exports=n},{"../schematype":39,"../utils":48}],35:[function(t,e,r){(function(r){function n(t,e){a.call(this,t,e,"Number")}function i(t){return this.cast(t)}function o(t){var e=this;return Array.isArray(t)?t.map(function(t){return e.cast(t)}):[this.cast(t)]}var s,a=t("../schematype"),u=a.CastError,c=t("./operators/bitwise"),f=t("../error").messages,l=t("../utils");n.schemaName="Number",n.prototype=Object.create(a.prototype),n.prototype.constructor=n,n.prototype.checkRequired=function(t,e){return a._isRef(this,t,e,!0)?!!t:"number"==typeof t||t instanceof Number},n.prototype.min=function(t,e){if(this.minValidator&&(this.validators=this.validators.filter(function(t){return t.validator!==this.minValidator},this)),null!==t&&void 0!==t){var r=e||f.Number.min;r=r.replace(/{MIN}/,t),this.validators.push({validator:this.minValidator=function(e){return null==e||e>=t},message:r,type:"min",min:t})}return this},n.prototype.max=function(t,e){if(this.maxValidator&&(this.validators=this.validators.filter(function(t){return t.validator!==this.maxValidator},this)),null!==t&&void 0!==t){var r=e||f.Number.max;r=r.replace(/{MAX}/,t),this.validators.push({validator:this.maxValidator=function(e){return null==e||t>=e},message:r,type:"max",max:t})}return this},n.prototype.cast=function(e,n,i){if(a._isRef(this,e,n,i)){if(null===e||void 0===e)return e;if(s||(s=t("./../document")),e instanceof s)return e.$__.wasPopulated=!0,e;if("number"==typeof e)return e;if(r.isBuffer(e)||!l.isObject(e))throw new u("number",e,this.path);var o=n.$__fullPath(this.path),c=n.ownerDocument?n.ownerDocument():n,f=c.populated(o,!0),h=new f.options.model(e);return h.$__.wasPopulated=!0,h}var p=e&&e._id?e._id:e;if(!isNaN(p)){if(null===p)return p;if(""===p)return null;if(("string"==typeof p||"boolean"==typeof p)&&(p=Number(p)),p instanceof Number)return p;if("number"==typeof p)return p;if(p.toString&&!Array.isArray(p)&&p.toString()==Number(p))return new Number(p)}throw new u("number",e,this.path)},n.prototype.$conditionalHandlers=l.options(a.prototype.$conditionalHandlers,{$bitsAllClear:c,$bitsAnyClear:c,$bitsAllSet:c,$bitsAnySet:c,$gt:i,$gte:i,$lt:i,$lte:i,$mod:o}),n.prototype.castForQuery=function(t,e){var r;if(2===arguments.length){if(r=this.$conditionalHandlers[t],!r)throw new Error("Can't use "+t+" with Number.");return r.call(this,e)}return e=this.cast(t)},e.exports=n}).call(this,t("buffer").Buffer)},{"../error":12,"../schematype":39,"../utils":48,"./../document":5,"./operators/bitwise":37,buffer:71}],36:[function(t,e,r){(function(r){function n(t,e){u.call(this,t,e,"ObjectID")}function i(t){return this.cast(t)}function o(){return new f}function s(t){return this.$__._id=null,t}var a,u=t("../schematype"),c=u.CastError,f=t("../types/objectid"),l=t("../utils");n.schemaName="ObjectId",n.prototype=Object.create(u.prototype),n.prototype.constructor=n,n.prototype.auto=function(t){return t&&(this.default(o),this.set(s)),this},n.prototype.checkRequired=function(t,e){return u._isRef(this,t,e,!0)?!!t:t instanceof f},n.prototype.cast=function(e,n,i){if(u._isRef(this,e,n,i)){if(null===e||void 0===e)return e;if(a||(a=t("./../document")),e instanceof a)return e.$__.wasPopulated=!0,e;if(e instanceof f)return e;if(r.isBuffer(e)||!l.isObject(e))throw new c("ObjectId",e,this.path);var o=n.$__fullPath(this.path),s=n.ownerDocument?n.ownerDocument():n,h=s.populated(o,!0),p=e;return n.$__.populated&&n.$__.populated[o]&&n.$__.populated[o].options&&n.$__.populated[o].options.options&&n.$__.populated[o].options.options.lean||(p=new h.options.model(e),p.$__.wasPopulated=!0),p}if(null===e||void 0===e)return e;if(e instanceof f)return e;if(e._id){if(e._id instanceof f)return e._id;if(e._id.toString instanceof Function)try{return f.createFromHexString(e._id.toString())}catch(t){}}if(e.toString instanceof Function)try{return f.createFromHexString(e.toString())}catch(t){throw new c("ObjectId",e,this.path)}throw new c("ObjectId",e,this.path)},n.prototype.$conditionalHandlers=l.options(u.prototype.$conditionalHandlers,{$gt:i,$gte:i,$lt:i,$lte:i}),n.prototype.castForQuery=function(t,e){var r;if(2===arguments.length){if(r=this.$conditionalHandlers[t],!r)throw new Error("Can't use "+t+" with ObjectId.");return r.call(this,e)}return this.cast(t)},e.exports=n}).call(this,t("buffer").Buffer)},{"../schematype":39,"../types/objectid":46,"../utils":48,"./../document":5,buffer:71}],37:[function(t,e,r){(function(r){function n(t){var e=this;return Array.isArray(t)?t.map(function(t){return i(e.path,t)}):r.isBuffer(t)?t:i(e.path,t)}function i(t,e){var r=Number(e);if(isNaN(r))throw new o("number",e,t);return r}var o=t("../../error/cast");e.exports=n}).call(this,t("buffer").Buffer)},{"../../error/cast":13,buffer:71}],38:[function(t,e,r){(function(r){function n(t,e){this.enumValues=[],this.regExp=null,a.call(this,t,e,"String")}function i(t){return this.castForQuery(t)}function o(t){var e=this;return Array.isArray(t)?t.map(function(t){return e.castForQuery(t)}):[this.castForQuery(t)]}var s,a=t("../schematype"),u=a.CastError,c=t("../error").messages,f=t("../utils");n.schemaName="String",n.prototype=Object.create(a.prototype),n.prototype.constructor=n,n.prototype.enum=function(){if(this.enumValidator&&(this.validators=this.validators.filter(function(t){return t.validator!==this.enumValidator},this),this.enumValidator=!1),void 0===arguments[0]||arguments[0]===!1)return this;var t,e;f.isObject(arguments[0])?(t=arguments[0].values,e=arguments[0].message):(t=arguments,e=c.String.enum);for(var r=0;r<t.length;r++)void 0!==t[r]&&this.enumValues.push(this.cast(t[r]));var n=this.enumValues;return this.enumValidator=function(t){return void 0===t||~n.indexOf(t)},this.validators.push({validator:this.enumValidator,message:e,type:"enum",enumValues:n}),this},n.prototype.lowercase=function(){return this.set(function(t,e){return"string"!=typeof t&&(t=e.cast(t)),t?t.toLowerCase():t})},n.prototype.uppercase=function(){return this.set(function(t,e){return"string"!=typeof t&&(t=e.cast(t)),t?t.toUpperCase():t})},n.prototype.trim=function(){return this.set(function(t,e){return"string"!=typeof t&&(t=e.cast(t)),t&&e.options.trim?t.trim():t})},n.prototype.minlength=function(t,e){if(this.minlengthValidator&&(this.validators=this.validators.filter(function(t){return t.validator!==this.minlengthValidator},this)),null!==t&&void 0!==t){var r=e||c.String.minlength;r=r.replace(/{MINLENGTH}/,t),this.validators.push({validator:this.minlengthValidator=function(e){
3
+ return null===e||e.length>=t},message:r,type:"minlength",minlength:t})}return this},n.prototype.maxlength=function(t,e){if(this.maxlengthValidator&&(this.validators=this.validators.filter(function(t){return t.validator!==this.maxlengthValidator},this)),null!==t&&void 0!==t){var r=e||c.String.maxlength;r=r.replace(/{MAXLENGTH}/,t),this.validators.push({validator:this.maxlengthValidator=function(e){return null===e||e.length<=t},message:r,type:"maxlength",maxlength:t})}return this},n.prototype.match=function(t,e){var r=e||c.String.match,n=function(e){if(!t)return!1;var r=null!=e&&""!==e?t.test(e):!0;return r};return this.validators.push({validator:n,message:r,type:"regexp",regexp:t}),this},n.prototype.checkRequired=function(t,e){return a._isRef(this,t,e,!0)?!!t:(t instanceof String||"string"==typeof t)&&t.length},n.prototype.cast=function(e,n,i){if(a._isRef(this,e,n,i)){if(null===e||void 0===e)return e;if(s||(s=t("./../document")),e instanceof s)return e.$__.wasPopulated=!0,e;if("string"==typeof e)return e;if(r.isBuffer(e)||!f.isObject(e))throw new u("string",e,this.path);var o=n.$__fullPath(this.path),c=n.ownerDocument?n.ownerDocument():n,l=c.populated(o,!0),h=new l.options.model(e);return h.$__.wasPopulated=!0,h}if(null===e||void 0===e)return e;if("undefined"!=typeof e){if(e._id&&"string"==typeof e._id)return e._id;if(e.toString&&e.toString!==Object.prototype.toString)return e.toString()}throw new u("string",e,this.path)},n.prototype.$conditionalHandlers=f.options(a.prototype.$conditionalHandlers,{$all:o,$gt:i,$gte:i,$lt:i,$lte:i,$options:i,$regex:i}),n.prototype.castForQuery=function(t,e){var r;if(2===arguments.length){if(r=this.$conditionalHandlers[t],!r)throw new Error("Can't use "+t+" with String.");return r.call(this,e)}return e=t,"[object RegExp]"===Object.prototype.toString.call(e)?e:this.cast(e)},e.exports=n}).call(this,t("buffer").Buffer)},{"../error":12,"../schematype":39,"../utils":48,"./../document":5,buffer:71}],39:[function(t,e,r){(function(n){function i(t,e,r){this.path=t,this.instance=r,this.validators=[],this.setters=[],this.getters=[],this.options=e,this._index=null,this.selected;for(var n in e)if(this[n]&&"function"==typeof this[n]){if("index"===n&&this._index)continue;var i=Array.isArray(e[n])?e[n]:[e[n]];this[n].apply(this,i)}}function o(t){return this.castForQuery(t)}function s(t){var e=this;return Array.isArray(t)?t.map(function(t){return e.castForQuery(t)}):[this.castForQuery(t)]}var a=t("./utils"),u=t("./error"),c=u.messages,f=u.CastError,l=u.ValidatorError;i.prototype.default=function(t){return 1===arguments.length?(this.defaultValue="function"==typeof t?t:this.cast(t),this):(arguments.length>1&&(this.defaultValue=a.args(arguments)),this.defaultValue)},i.prototype.index=function(t){return this._index=t,a.expires(this._index),this},i.prototype.unique=function(t){return null===this._index||void 0===this._index||"boolean"==typeof this._index?this._index={}:"string"==typeof this._index&&(this._index={type:this._index}),this._index.unique=t,this},i.prototype.text=function(t){return null===this._index||void 0===this._index||"boolean"==typeof this._index?this._index={}:"string"==typeof this._index&&(this._index={type:this._index}),this._index.text=t,this},i.prototype.sparse=function(t){return null===this._index||void 0===this._index||"boolean"==typeof this._index?this._index={}:"string"==typeof this._index&&(this._index={type:this._index}),this._index.sparse=t,this},i.prototype.set=function(t){if("function"!=typeof t)throw new TypeError("A setter must be a function.");return this.setters.push(t),this},i.prototype.get=function(t){if("function"!=typeof t)throw new TypeError("A getter must be a function.");return this.getters.push(t),this},i.prototype.validate=function(t,e,r){if("function"==typeof t||t&&"RegExp"===a.getFunctionName(t.constructor)){var n;return e instanceof Object&&!r?(n=a.clone(e),n.message||(n.message=n.msg),n.validator=t,n.type=n.type||"user defined"):(e||(e=c.general.default),r||(r="user defined"),n={message:e,type:r,validator:t}),this.validators.push(n),this}var i,o,s;for(i=0,o=arguments.length;o>i;i++){if(s=arguments[i],!s||"Object"!==a.getFunctionName(s.constructor)){var u="Invalid validator. Received ("+typeof s+") "+s+". See http://mongoosejs.com/docs/api.html#schematype_SchemaType-validate";throw new Error(u)}this.validate(s.validator,s)}return this},i.prototype.required=function(t,e){if(t===!1)return this.validators=this.validators.filter(function(t){return t.validator!==this.requiredValidator},this),this.isRequired=!1,this;var r=this;this.isRequired=!0,this.requiredValidator=function(e){return"isSelected"in this&&!this.isSelected(r.path)&&!this.isModified(r.path)?!0:"function"==typeof t&&!t.apply(this)||r.checkRequired(e,this)},"string"==typeof t&&(e=t,t=void 0);var n=e||c.general.required;return this.validators.unshift({validator:this.requiredValidator,message:n,type:"required"}),this},i.prototype.getDefault=function(t,e){var r="function"==typeof this.defaultValue?this.defaultValue.call(t):this.defaultValue;return null!==r&&void 0!==r?this.cast(r,t,e):r},i.prototype.applySetters=function(t,e,r,n,i){for(var o=t,s=this.setters,a=s.length,u=this.caster;a--;)o=s[a].call(e,o,this);if(Array.isArray(o)&&u&&u.setters){for(var c=[],f=0;f<o.length;f++)c.push(u.applySetters(o[f],e,r,n));o=c}return null===o||void 0===o?o:o=this.cast(o,e,r,n,i)},i.prototype.applyGetters=function(t,e){var r=t,n=this.getters,i=n.length;if(!i)return r;for(;i--;)r=n[i].call(e,r,this);return r},i.prototype.select=function(t){return this.selected=!!t,this},i.prototype.doValidate=function(t,e,r){var n=!1,i=this.path,o=this.validators.length;if(!o)return e(null);var s=function(t,r){n||(void 0===t||t?--o||e(null):(n=new l(r),e(n)))},u=this;this.validators.forEach(function(e){if(!n){var o=e.validator,c=a.clone(e);if(c.path=i,c.value=t,o instanceof RegExp)s(o.test(t),c);else if("function"==typeof o){if(void 0===t&&!u.isRequired)return void s(!0,c);2===o.length?o.call(r,t,function(t,e){e&&(c.message=e),s(t,c)}):s(o.call(r,t),c)}}})},i.prototype.doValidateSync=function(t,e){var r=null,n=this.path,i=this.validators.length;if(!i)return null;var o=function(t,e){r||void 0===t||t||(r=new l(e))},s=this;return void 0!==t||s.isRequired?(this.validators.forEach(function(i){if(!r){var s=i.validator,u=a.clone(i);u.path=n,u.value=t,s instanceof RegExp?o(s.test(t),u):"function"==typeof s&&2!==s.length&&o(s.call(e,t),u)}}),r):null},i._isRef=function(t,e,r,i){var o=i&&t.options&&t.options.ref;if(!o&&r&&r.$__fullPath){var s=r.$__fullPath(t.path),u=r.ownerDocument?r.ownerDocument():r;o=u.populated(s)}if(o){if(null==e)return!0;if(!n.isBuffer(e)&&"Binary"!==e._bsontype&&a.isObject(e))return!0}return!1},i.prototype.$conditionalHandlers={$all:s,$eq:o,$in:s,$ne:o,$nin:s},i.prototype.castForQuery=function(t,e){var r;if(2===arguments.length){if(r=this.$conditionalHandlers[t],!r)throw new Error("Can't use "+t);return r.call(this,e)}return e=t,this.cast(e)},i.prototype.checkRequired=function(t){return null!=t},e.exports=r=i,r.CastError=f,r.ValidatorError=l}).call(this,t("buffer").Buffer)},{"./error":12,"./utils":48,buffer:71}],40:[function(t,e,r){var n=t("./utils"),i=e.exports=r=function(){};i.ctor=function(){var t=n.args(arguments),e=function(){i.apply(this,arguments),this.paths={},this.states={},this.stateNames=t;for(var e,r=t.length;r--;)e=t[r],this.states[e]={}};return e.prototype=new i,t.forEach(function(t){e.prototype[t]=function(e){this._changeState(e,t)}}),e},i.prototype._changeState=function(t,e){var r=this.states[this.paths[t]];r&&delete r[t],this.paths[t]=e,this.states[e][t]=!0},i.prototype.clear=function(t){for(var e,r=Object.keys(this.states[t]),n=r.length;n--;)e=r[n],delete this.states[t][e],delete this.paths[e]},i.prototype.some=function(){var t=this,e=arguments.length?arguments:this.stateNames;return Array.prototype.some.call(e,function(e){return Object.keys(t.states[e]).length})},i.prototype._iter=function(t){return function(){var e=arguments.length,r=n.args(arguments,0,e-1),i=arguments[e-1];r.length||(r=this.stateNames);var o=this,s=r.reduce(function(t,e){return t.concat(Object.keys(o.states[e]))},[]);return s[t](function(t,e,r){return i(t,e,r)})}},i.prototype.forEach=function(){return this.forEach=this._iter("forEach"),this.forEach.apply(this,arguments)},i.prototype.map=function(){return this.map=this._iter("map"),this.map.apply(this,arguments)}},{"./utils":48}],41:[function(t,e,r){(function(n){function i(t,e,r){for(var n=[].concat(t),o={isMongooseArray:!0,validators:[],_path:e,_atomics:{},_schema:void 0},a={},u=Object.keys(i.mixin),c=0;c<u.length;++c)a[u[c]]={enumerable:!1,configurable:!0,writable:!0,value:i.mixin[u[c]]};for(var f=Object.keys(o),l=0;l<f.length;++l)a[f[l]]={enumerable:!1,configurable:!0,writable:!0,value:o[f[l]]};return Object.defineProperties(n,a),r&&r instanceof s&&(n._parent=r,n._schema=r.schema.path(e)),n}var o=t("./embedded"),s=t("../document"),a=t("./objectid"),u=t("../utils"),c=u.isMongooseObject;i.mixin={_atomics:void 0,_parent:void 0,_cast:function(t){var e,r=this._owner,i=!1;if(this._parent&&(r||(r=this._owner=this._parent.ownerDocument?this._parent.ownerDocument():this._parent),i=r.populated(this._path,!0)),i&&null!==t&&void 0!==t){e=i.options.model,(n.isBuffer(t)||t instanceof a||!u.isObject(t))&&(t={_id:t});var o=t.schema&&t.schema.discriminatorMapping&&void 0!==t.schema.discriminatorMapping.key;return o||(t=new e(t)),this._schema.caster.cast(t,this._parent,!0)}return this._schema.caster.cast(t,this._parent,!1)},_markModified:function(t,e){var r,n=this._parent;return n&&(r=this._path,arguments.length&&(r=null!=e?r+"."+this.indexOf(t)+"."+e:r+"."+t),n.markModified(r)),this},_registerAtomic:function(t,e){if("$set"===t)return this._atomics={$set:e},this;var r=this._atomics;if("$pop"===t&&!("$pop"in r)){var n=this;this._parent.once("save",function(){n._popped=n._shifted=null})}if(this._atomics.$set||Object.keys(r).length&&!(t in r))return this._atomics={$set:this},this;var i;if("$pullAll"===t||"$pushAll"===t||"$addToSet"===t)r[t]||(r[t]=[]),r[t]=r[t].concat(e);else if("$pullDocs"===t){var s=r.$pull||(r.$pull={});e[0]instanceof o?(i=s.$or||(s.$or=[]),Array.prototype.push.apply(i,e.map(function(t){return t.toObject({virtuals:!1})}))):(i=s._id||(s._id={$in:[]}),i.$in=i.$in.concat(e))}else r[t]=e;return this},$__getAtomics:function(){var t=[],e=Object.keys(this._atomics),r=e.length;if(0===r)return t[0]=["$set",this.toObject({depopulate:1,transform:!1})],t;for(;r--;){var n=e[r],i=this._atomics[n];c(i)?i=i.toObject({depopulate:1,transform:!1}):Array.isArray(i)?i=this.toObject.call(i,{depopulate:1,transform:!1}):i.valueOf&&(i=i.valueOf()),"$addToSet"===n&&(i={$each:i}),t.push([n,i])}return t},hasAtomics:function(){return this._atomics&&"Object"===this._atomics.constructor.name?Object.keys(this._atomics).length:0},_mapCast:function(t,e){return this._cast(t,this.length+e)},push:function(){var t=[].map.call(arguments,this._mapCast,this);t=this._schema.applySetters(t,this._parent,void 0,void 0,{skipDocumentArrayCast:!0});var e=[].push.apply(this,t);return this._registerAtomic("$pushAll",t),this._markModified(),e},nonAtomicPush:function(){var t=[].map.call(arguments,this._mapCast,this),e=[].push.apply(this,t);return this._registerAtomic("$set",this),this._markModified(),e},$pop:function(){return this._registerAtomic("$pop",1),this._markModified(),this._popped?void 0:(this._popped=!0,[].pop.call(this))},pop:function(){var t=[].pop.call(this);return this._registerAtomic("$set",this),this._markModified(),t},$shift:function(){return this._registerAtomic("$pop",-1),this._markModified(),this._shifted?void 0:(this._shifted=!0,[].shift.call(this))},shift:function(){var t=[].shift.call(this);return this._registerAtomic("$set",this),this._markModified(),t},pull:function(){for(var t,e=[].map.call(arguments,this._cast,this),r=this._parent.get(this._path),n=r.length;n--;)if(t=r[n],t instanceof s){var i=e.some(function(e){return e.equals(t)});i&&[].splice.call(r,n,1)}else~r.indexOf.call(e,t)&&[].splice.call(r,n,1);return e[0]instanceof o?this._registerAtomic("$pullDocs",e.map(function(t){return t._id||t})):this._registerAtomic("$pullAll",e),this._markModified(),this},splice:function(){var t,e,r;if(arguments.length){for(e=[],r=0;r<arguments.length;++r)e[r]=2>r?arguments[r]:this._cast(arguments[r],arguments[0]+(r-2));t=[].splice.apply(this,e),this._registerAtomic("$set",this),this._markModified()}return t},unshift:function(){var t=[].map.call(arguments,this._cast,this);return t=this._schema.applySetters(t,this._parent),[].unshift.apply(this,t),this._registerAtomic("$set",this),this._markModified(),this.length},sort:function(){var t=[].sort.apply(this,arguments);return this._registerAtomic("$set",this),this._markModified(),t},addToSet:function(){var t=[].map.call(arguments,this._mapCast,this);t=this._schema.applySetters(t,this._parent);var e=[],r="";return t[0]instanceof o?r="doc":t[0]instanceof Date&&(r="date"),t.forEach(function(t){var n;switch(r){case"doc":n=this.some(function(e){return e.equals(t)});break;case"date":var i=+t;n=this.some(function(t){return+t===i});break;default:n=~this.indexOf(t)}n||([].push.call(this,t),this._registerAtomic("$addToSet",t),this._markModified(),[].push.call(e,t))},this),e},set:function(t,e){var r=this._cast(e,t);return r=this._schema.caster instanceof o?r:this._schema.caster.applySetters(e,this._parent),this[t]=r,this._markModified(t),this},toObject:function(t){return t&&t.depopulate?this.map(function(e){return e instanceof s?e.toObject(t):e}):this.slice()},inspect:function(){return JSON.stringify(this)},indexOf:function(t){t instanceof a&&(t=t.toString());for(var e=0,r=this.length;r>e;++e)if(t==this[e])return e;return-1}},i.mixin.remove=i.mixin.pull,e.exports=r=i}).call(this,t("buffer").Buffer)},{"../document":5,"../utils":48,"./embedded":44,"./objectid":46,buffer:71}],42:[function(t,e,r){(function(r){function n(t,e,i){var s,a=arguments.length;s=0===a||null===arguments[0]||void 0===arguments[0]?0:t;var u,c,f;Array.isArray(e)?(c=e[0],f=e[1]):u=e;var l=new r(s,u,i);return o.decorate(l,n.mixin),l.isMongooseBuffer=!0,Object.defineProperties(l,{validators:{value:[]},_path:{value:c},_parent:{value:f}}),f&&"string"==typeof c&&Object.defineProperty(l,"_schema",{value:f.schema.path(c)}),l._subtype=0,l}var i=t("../drivers").Binary,o=t("../utils");n.mixin={_parent:void 0,_subtype:void 0,_markModified:function(){var t=this._parent;return t&&t.markModified(this._path),this},write:function(){var t=r.prototype.write.apply(this,arguments);return t>0&&this._markModified(),t},copy:function(t){var e=r.prototype.copy.apply(this,arguments);return t&&t.isMongooseBuffer&&t._markModified(),e}},"writeUInt8 writeUInt16 writeUInt32 writeInt8 writeInt16 writeInt32 writeFloat writeDouble fill utf8Write binaryWrite asciiWrite set writeUInt16LE writeUInt16BE writeUInt32LE writeUInt32BE writeInt16LE writeInt16BE writeInt32LE writeInt32BE writeFloatLE writeFloatBE writeDoubleLE writeDoubleBE".split(" ").forEach(function(t){r.prototype[t]&&(n.mixin[t]=function(){var e=r.prototype[t].apply(this,arguments);return this._markModified(),e})}),n.mixin.toObject=function(t){var e="number"==typeof t?t:this._subtype||0;return new i(this,e)},n.mixin.equals=function(t){if(!r.isBuffer(t))return!1;if(this.length!==t.length)return!1;for(var e=0;e<this.length;++e)if(this[e]!==t[e])return!1;return!0},n.mixin.subtype=function(t){if("number"!=typeof t)throw new TypeError("Invalid subtype. Expected a number");this._subtype!==t&&this._markModified(),this._subtype=t},n.Binary=i,e.exports=n}).call(this,t("buffer").Buffer)},{"../drivers":11,"../utils":48,buffer:71}],43:[function(t,e,r){(function(r){function n(t,e,r){for(var o=[].concat(t),s={isMongooseArray:!0,isMongooseDocumentArray:!0,validators:[],_path:e,_atomics:{},_schema:void 0,_handlers:void 0},a={},c=Object.keys(i.mixin),f=0;f<c.length;++f)a[c[f]]={enumerable:!1,configurable:!0,writable:!0,value:i.mixin[c[f]]};for(var l=Object.keys(n.mixin),h=0;h<l.length;++h)a[l[h]]={enumerable:!1,configurable:!0,writable:!0,value:n.mixin[l[h]]};for(var p=Object.keys(s),d=0;d<p.length;++d)a[p[d]]={enumerable:!1,configurable:!0,writable:!0,value:s[p[d]]};return Object.defineProperties(o,a),r&&r instanceof u&&(o._parent=r,o._schema=r.schema.path(e),o._handlers={isNew:o.notify("isNew"),save:o.notify("save")},r.on("save",o._handlers.save),r.on("isNew",o._handlers.isNew)),o}var i=t("./array"),o=t("./objectid"),s=t("../schema/objectid"),a=t("../utils"),u=t("../document");n.mixin={_cast:function(t,e){return t instanceof this._schema.casterConstructor?(t.__parent&&t.__parentArray||(t.__parent=this._parent,t.__parentArray=this),t.__index=e,t):((r.isBuffer(t)||t instanceof o||!a.isObject(t))&&(t={_id:t}),new this._schema.casterConstructor(t,this,void 0,void 0,e))},id:function(t){var e,r,n;try{var i=s.prototype.cast.call({},t);i&&(e=String(i))}catch(t){e=null}for(var c=0,f=this.length;f>c;c++)if(n=this[c].get("_id"),null!==n&&"undefined"!=typeof n)if(n instanceof u){if(r||(r=String(t)),r==n._id)return this[c]}else if(t instanceof o||n instanceof o){if(e==n)return this[c]}else if(a.deepEqual(t,n))return this[c];return null},toObject:function(t){return this.map(function(e){return e&&e.toObject(t)||null})},inspect:function(){return Array.prototype.slice.call(this)},create:function(t){return new this._schema.casterConstructor(t)},notify:function(t){var e=this;return function(r){for(var n=e.length;n--;)if(e[n]){switch(t){case"save":r=e[n]}e[n].emit(t,r)}}}},e.exports=n}).call(this,t("buffer").Buffer)},{"../document":5,"../schema/objectid":36,"../utils":48,"./array":41,"./objectid":46,buffer:71}],44:[function(t,e,r){function n(t,e,r,n,i){e?(this.__parentArray=e,this.__parent=e._parent):(this.__parentArray=void 0,this.__parent=void 0),this.__index=i,o.call(this,t,n,r);var s=this;this.on("isNew",function(t){s.isNew=t})}function i(t){function e(){r.removeListener("save",e),r.removeListener("remove",e),t.emit("remove",t),r=t=null}var r=t.ownerDocument();r.on("save",e),r.on("remove",e)}var o=t("../document_provider")(),s=t("../promise_provider");n.prototype=Object.create(o.prototype),n.prototype.constructor=n,n.prototype.markModified=function(t){this.$__.activePaths.modify(t),this.__parentArray&&(this.isNew?this.__parentArray._markModified():this.__parentArray._markModified(this,t))},n.prototype.save=function(t){var e=s.get();return new e.ES6(function(e){t&&t(),e()})},n.prototype.remove=function(t){if(!this.__parentArray)return this;var e;if(!this.willRemove){if(e=this._doc._id,!e)throw new Error("For your own good, Mongoose does not know how to remove an EmbeddedDocument that has no _id");this.__parentArray.pull({_id:e}),this.willRemove=!0,i(this)}return t&&t(null),this},n.prototype.update=function(){throw new Error("The #update method is not available on EmbeddedDocuments")},n.prototype.inspect=function(){return this.toObject()},n.prototype.invalidate=function(t,e,r,n){if(!this.__parent){var i="Unable to invalidate a subdocument that has not been added to an array.";throw new Error(i)}var o=this.__index;if("undefined"!=typeof o){var s=this.__parentArray._path,a=[s,o,t].join(".");this.__parent.invalidate(a,e,r)}return n&&(this.$__.validationError=this.ownerDocument().$__.validationError),!0},n.prototype.$markValid=function(t){if(this.__parent){var e=this.__index;if("undefined"!=typeof e){var r=this.__parentArray._path,n=[r,e,t].join(".");this.__parent.$markValid(n)}}},n.prototype.$isValid=function(t){var e=this.__index;return"undefined"!=typeof e?!this.__parent.$__.validationError||!this.__parent.$__.validationError.errors[this.$__fullPath(t)]:!0},n.prototype.ownerDocument=function(){if(this.$__.ownerDocument)return this.$__.ownerDocument;var t=this.__parent;if(!t)return this;for(;t.__parent;)t=t.__parent;return this.$__.ownerDocument=t,this.$__.ownerDocument},n.prototype.$__fullPath=function(t){if(!this.$__.fullPath){var e=this;if(!e.__parent)return t;for(var r=[];e.__parent;)r.unshift(e.__parentArray._path),e=e.__parent;this.$__.fullPath=r.join("."),this.$__.ownerDocument||(this.$__.ownerDocument=e)}return t?this.$__.fullPath+"."+t:this.$__.fullPath},n.prototype.parent=function(){return this.__parent},n.prototype.parentArray=function(){return this.__parentArray},e.exports=n},{"../document_provider":6,"../promise_provider":25}],45:[function(t,e,r){r.Array=t("./array"),r.Buffer=t("./buffer"),r.Document=r.Embedded=t("./embedded"),r.DocumentArray=t("./documentarray"),r.ObjectId=t("./objectid"),r.Subdocument=t("./subdocument")},{"./array":41,"./buffer":42,"./documentarray":43,"./embedded":44,"./objectid":46,"./subdocument":47}],46:[function(t,e,r){var n=t("../drivers").ObjectId;e.exports=n},{"../drivers":11}],47:[function(t,e,r){function n(t,e){this.$isSingleNested=!0,o.call(this,t,e)}function i(t){function e(){r.removeListener("save",e),r.removeListener("remove",e),t.emit("remove",t),r=t=null}var r=t.ownerDocument();r.on("save",e),r.on("remove",e)}var o=t("../document"),s=t("../promise_provider");e.exports=n,n.prototype=Object.create(o.prototype),n.prototype.save=function(t){var e=s.get();return new e.ES6(function(e){t&&t(),e()})},n.prototype.$isValid=function(t){return this.$parent?this.$parent.$isValid([this.$basePath,t].join(".")):void 0},n.prototype.markModified=function(t){o.prototype.markModified.call(this,t),this.$parent&&this.$parent.markModified([this.$basePath,t].join("."))},n.prototype.$markValid=function(t){this.$parent&&this.$parent.$markValid([this.$basePath,t].join("."))},n.prototype.invalidate=function(t,e,r){if(this.$parent)this.$parent.invalidate([this.$basePath,t].join("."),e,r);else if("cast"===e.kind||"CastError"===e.name)throw e},n.prototype.ownerDocument=function(){if(this.$__.ownerDocument)return this.$__.ownerDocument;var t=this.$parent;if(!t)return this;for(;t.$parent;)t=t.$parent;return this.$__.ownerDocument=t,this.$__.ownerDocument},n.prototype.remove=function(t){this.$parent.set(this.$basePath,null),i(this),t&&t(null)}},{"../document":5,"../promise_provider":25}],48:[function(t,e,r){(function(e,n){function i(t){var e;return!~g.indexOf(t.toLowerCase())&&(e=y.filter(function(e){return t.match(e[0])}),e[0])?t.replace(e[0][0],e[0][1]):t}function o(t,e){var r,n,i,o,s,a=e&&e.retainKeyOrder,u=e&&e.minimize,c={};if(a)for(o in t)i=v(t[o],e),u&&"undefined"==typeof i||(r||(r=!0),c[o]=i);else for(n=Object.keys(t),s=n.length;s--;)o=n[s],i=v(t[o],e),u&&"undefined"==typeof i||(r||(r=!0),c[o]=i);return u?r&&c:c}function s(t,e){for(var r=[],n=0,i=t.length;i>n;n++)r.push(v(t[n],e));return r}function a(t,e,r,n,i,o){this.path=t,this.match=r,this.select=e,this.options=n,this.model=i,"object"==typeof o&&(this.populate=o),this._docs={}}var u,c,f,l=t("./types/objectid"),h=t("regexp-clone"),p=t("sliced"),d=t("mpath"),_=t("ms");r.toCollectionName=function(t,e){return e=e||{},"system.profile"===t?t:"system.indexes"===t?t:e.pluralization===!1?t:i(t.toLowerCase())},r.pluralization=[[/(m)an$/gi,"$1en"],[/(pe)rson$/gi,"$1ople"],[/(child)$/gi,"$1ren"],[/^(ox)$/gi,"$1en"],[/(ax|test)is$/gi,"$1es"],[/(octop|vir)us$/gi,"$1i"],[/(alias|status)$/gi,"$1es"],[/(bu)s$/gi,"$1ses"],[/(buffal|tomat|potat)o$/gi,"$1oes"],[/([ti])um$/gi,"$1a"],[/sis$/gi,"ses"],[/(?:([^f])fe|([lr])f)$/gi,"$1$2ves"],[/(hive)$/gi,"$1s"],[/([^aeiouy]|qu)y$/gi,"$1ies"],[/(x|ch|ss|sh)$/gi,"$1es"],[/(matr|vert|ind)ix|ex$/gi,"$1ices"],[/([m|l])ouse$/gi,"$1ice"],[/(kn|w|l)ife$/gi,"$1ives"],[/(quiz)$/gi,"$1zes"],[/s$/gi,"s"],[/([^a-z])$/,"$1"],[/$/gi,"s"]];var y=r.pluralization;r.uncountables=["advice","energy","excretion","digestion","cooperation","health","justice","labour","machinery","equipment","information","pollution","sewage","paper","money","species","series","rain","rice","fish","sheep","moose","deer","news","expertise","status","media"];var g=r.uncountables;r.deepEqual=function t(e,i){if(e===i)return!0;if(e instanceof Date&&i instanceof Date)return e.getTime()===i.getTime();if(e instanceof l&&i instanceof l)return e.toString()===i.toString();if(e instanceof RegExp&&i instanceof RegExp)return e.source===i.source&&e.ignoreCase===i.ignoreCase&&e.multiline===i.multiline&&e.global===i.global;if("object"!=typeof e&&"object"!=typeof i)return e==i;if(null===e||null===i||void 0===e||void 0===i)return!1;if(e.prototype!==i.prototype)return!1;if(e instanceof Number&&i instanceof Number)return e.valueOf()===i.valueOf();if(n.isBuffer(e))return r.buffer.areEqual(e,i);b(e)&&(e=e.toObject()),b(i)&&(i=i.toObject());try{var o,s,a=Object.keys(e),u=Object.keys(i)}catch(t){return!1}if(a.length!==u.length)return!1;for(a.sort(),u.sort(),s=a.length-1;s>=0;s--)if(a[s]!==u[s])return!1;for(s=a.length-1;s>=0;s--)if(o=a[s],!t(e[o],i[o]))return!1;return!0},r.clone=function(t,e){if(void 0===t||null===t)return t;if(Array.isArray(t))return s(t,e);if(b(t))return e&&e.json&&"function"==typeof t.toJSON?t.toJSON(e):t.toObject(e);if(t.constructor)switch(r.getFunctionName(t.constructor)){case"Object":return o(t,e);case"Date":return new t.constructor(+t);case"RegExp":return h(t)}return t instanceof l?new l(t.id):!t.constructor&&r.isObject(t)?o(t,e):t.valueOf?t.valueOf():void 0};var v=r.clone;r.options=function(t,e){var r,n=Object.keys(t),i=n.length;for(e=e||{};i--;)r=n[i],r in e||(e[r]=t[r]);return e},r.random=function(){return Math.random().toString().substr(3)},r.merge=function t(e,n){for(var i,o=Object.keys(n),s=o.length;s--;)i=o[s],"undefined"==typeof e[i]?e[i]=n[i]:r.isObject(n[i])&&t(e[i],n[i])};var m=Object.prototype.toString;r.toObject=function t(e){var n;if(r.isNullOrUndefined(e))return e;if(e instanceof f)return e.toObject();if(Array.isArray(e)){n=[];for(var i=0,o=e.length;o>i;++i)n.push(t(e[i]));return n}if(e.constructor&&"Object"===r.getFunctionName(e.constructor)||!e.constructor&&r.isObject(e)){n={};for(var s in e)n[s]=t(e[s]);return n}return e},r.isObject=function(t){return n.isBuffer(t)?!0:"[object Object]"===m.call(t)},r.args=p,r.tick=function(t){return"function"==typeof t?function(){try{t.apply(this,arguments)}catch(t){e.nextTick(function(){throw t})}}:void 0},r.isMongooseObject=function(e){return f||(f=t("./document")),c||(c=t("./types").Array),u||(u=t("./types").Buffer),e instanceof f||e&&e.isMongooseArray||e&&e.isMongooseBuffer};var b=r.isMongooseObject;r.expires=function(t){if(t&&"Object"===t.constructor.name&&"expires"in t){var e;e="string"!=typeof t.expires?t.expires:Math.round(_(t.expires)/1e3),t.expireAfterSeconds=e,delete t.expires}},a.prototype.constructor=Object,r.PopulateOptions=a,r.populate=function(t,e,n,i,o,s){if(1===arguments.length){if(t instanceof a)return[t];if(Array.isArray(t))return t.map(function(t){return r.populate(t)[0]});r.isObject(t)&&(i=t.match,o=t.options,e=t.select,n=t.model,s=t.populate,t=t.path)}else"string"!=typeof n&&"function"!=typeof n&&(o=i,i=n,n=void 0);if("string"!=typeof t)throw new TypeError("utils.populate: invalid path. Expected string. Got typeof `"+typeof t+"`");"object"==typeof s&&(s=r.populate(s));var u=[],c=t.split(" ");o=r.clone(o,{retainKeyOrder:!0});for(var f=0;f<c.length;++f)u.push(new a(c[f],e,i,o,n,s));return u},r.getValue=function(t,e,r){return d.get(t,e,"_doc",r)},r.setValue=function(t,e,r,n){d.set(t,e,r,"_doc",n)},r.object={},r.object.vals=function(t){for(var e=Object.keys(t),r=e.length,n=[];r--;)n.push(t[e[r]]);return n},r.object.shallowCopy=r.options;var w=Object.prototype.hasOwnProperty;r.object.hasOwnProperty=function(t,e){return w.call(t,e)},r.isNullOrUndefined=function(t){return null===t||void 0===t},r.array={},r.array.flatten=function t(e,r,n){return n||(n=[]),e.forEach(function(e){Array.isArray(e)?t(e,r,n):(!r||r(e))&&n.push(e)}),n},r.array.unique=function(t){for(var e={},r={},n=[],i=t.length,o=0;i>o;++o)if("number"==typeof t[o]||"string"==typeof t[o]){if(e[t[o]])continue;n.push(t[o]),e[t[o]]=!0}else if(t[o]instanceof l){if(r[t[o].toString()])continue;n.push(t[o]),r[t[o].toString()]=!0}else n.push(t[o]);return n},r.buffer={},r.buffer.areEqual=function(t,e){if(!n.isBuffer(t))return!1;if(!n.isBuffer(e))return!1;if(t.length!==e.length)return!1;for(var r=0,i=t.length;i>r;++r)if(t[r]!==e[r])return!1;return!0},r.getFunctionName=function(t){return t.name?t.name:(t.toString().trim().match(/^function\s*([^\s(]+)/)||[])[1]},r.decorate=function(t,e){for(var r in e)t[r]=e[r]},r.mergeClone=function(t,e){for(var n,i=Object.keys(e),o=i.length;o--;)if(n=i[o],"undefined"==typeof t[n])t[n]=r.clone(e[n],{retainKeyOrder:1});else if(r.isObject(e[n])){var s=e[n];b(e[n])&&!e[n].isMongooseBuffer&&(s=s.toObject({virtuals:!1})),r.mergeClone(t[n],s)}else t[n]=r.clone(e[n],{retainKeyOrder:1})},r.each=function(t,e){for(var r=0;r<t.length;++r)e(t[r])}}).call(this,t("g5I+bs"),t("buffer").Buffer)},{"./document":5,"./types":45,"./types/objectid":46,buffer:71,"g5I+bs":94,mpath:80,ms:93,"regexp-clone":95,sliced:96}],49:[function(t,e,r){function n(t,e){this.path=e,this.getters=[],this.setters=[],this.options=t||{}}n.prototype.get=function(t){return this.getters.push(t),this},n.prototype.set=function(t){return this.setters.push(t),this},n.prototype.applyGetters=function(t,e){for(var r=t,n=this.getters.length-1;n>=0;n--)r=this.getters[n].call(e,r,this);return r},n.prototype.applySetters=function(t,e){for(var r=t,n=this.setters.length-1;n>=0;n--)r=this.setters[n].call(e,r,this);return r},e.exports=n},{}],50:[function(t,e,r){function n(t,e){return p.isUndefined(e)?""+e:!p.isNumber(e)||!isNaN(e)&&isFinite(e)?p.isFunction(e)||p.isRegExp(e)?e.toString():e:e.toString()}function i(t,e){return p.isString(t)?t.length<e?t:t.slice(0,e):t}function o(t){return i(JSON.stringify(t.actual,n),128)+" "+t.operator+" "+i(JSON.stringify(t.expected,n),128)}function s(t,e,r,n,i){throw new y.AssertionError({message:r,actual:t,expected:e,operator:n,stackStartFunction:i})}function a(t,e){t||s(t,!0,e,"==",y.ok)}function u(t,e){if(t===e)return!0;if(p.isBuffer(t)&&p.isBuffer(e)){if(t.length!=e.length)return!1;for(var r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}return p.isDate(t)&&p.isDate(e)?t.getTime()===e.getTime():p.isRegExp(t)&&p.isRegExp(e)?t.source===e.source&&t.global===e.global&&t.multiline===e.multiline&&t.lastIndex===e.lastIndex&&t.ignoreCase===e.ignoreCase:p.isObject(t)||p.isObject(e)?f(t,e):t==e}function c(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function f(t,e){if(p.isNullOrUndefined(t)||p.isNullOrUndefined(e))return!1;if(t.prototype!==e.prototype)return!1;if(c(t))return c(e)?(t=d.call(t),e=d.call(e),u(t,e)):!1;try{var r,n,i=g(t),o=g(e)}catch(t){return!1}if(i.length!=o.length)return!1;for(i.sort(),o.sort(),n=i.length-1;n>=0;n--)if(i[n]!=o[n])return!1;for(n=i.length-1;n>=0;n--)if(r=i[n],!u(t[r],e[r]))return!1;return!0}function l(t,e){return t&&e?"[object RegExp]"==Object.prototype.toString.call(e)?e.test(t):t instanceof e?!0:e.call({},t)===!0?!0:!1:!1}function h(t,e,r,n){var i;p.isString(r)&&(n=r,r=null);try{e()}catch(t){i=t}if(n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&s(i,r,"Missing expected exception"+n),!t&&l(i,r)&&s(i,r,"Got unwanted exception"+n),t&&i&&r&&!l(i,r)||!t&&i)throw i}var p=t("util/"),d=Array.prototype.slice,_=Object.prototype.hasOwnProperty,y=e.exports=a;y.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=o(this),this.generatedMessage=!0);var e=t.stackStartFunction||s;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var n=r.stack,i=e.name,a=n.indexOf("\n"+i);if(a>=0){var u=n.indexOf("\n",a+1);n=n.substring(u+1)}this.stack=n}}},p.inherits(y.AssertionError,Error),y.fail=s,y.ok=a,y.equal=function(t,e,r){t!=e&&s(t,e,r,"==",y.equal)},y.notEqual=function(t,e,r){t==e&&s(t,e,r,"!=",y.notEqual)},y.deepEqual=function(t,e,r){u(t,e)||s(t,e,r,"deepEqual",y.deepEqual)},y.notDeepEqual=function(t,e,r){u(t,e)&&s(t,e,r,"notDeepEqual",y.notDeepEqual)},y.strictEqual=function(t,e,r){t!==e&&s(t,e,r,"===",y.strictEqual)},y.notStrictEqual=function(t,e,r){t===e&&s(t,e,r,"!==",y.notStrictEqual)},y.throws=function(t,e,r){
4
+ h.apply(this,[!0].concat(d.call(arguments)))},y.doesNotThrow=function(t,e){h.apply(this,[!1].concat(d.call(arguments)))},y.ifError=function(t){if(t)throw t};var g=Object.keys||function(t){var e=[];for(var r in t)_.call(t,r)&&e.push(r);return e}},{"util/":98}],51:[function(t,e,r){(function(t,r){!function(){function n(){}function i(t){return t}function o(t){return!!t}function s(t){return!t}function a(t){return function(){if(null===t)throw new Error("Callback was already called.");t.apply(this,arguments),t=null}}function u(t){return function(){null!==t&&(t.apply(this,arguments),t=null)}}function c(t){return L(t)||"number"==typeof t.length&&t.length>=0&&t.length%1===0}function f(t,e){for(var r=-1,n=t.length;++r<n;)e(t[r],r,t)}function l(t,e){for(var r=-1,n=t.length,i=Array(n);++r<n;)i[r]=e(t[r],r,t);return i}function h(t){return l(Array(t),function(t,e){return e})}function p(t,e,r){return f(t,function(t,n,i){r=e(r,t,n,i)}),r}function d(t,e){f(U(t),function(r){e(t[r],r)})}function _(t,e){for(var r=0;r<t.length;r++)if(t[r]===e)return r;return-1}function y(t){var e,r,n=-1;return c(t)?(e=t.length,function(){return n++,e>n?n:null}):(r=U(t),e=r.length,function(){return n++,e>n?r[n]:null})}function g(t,e){return e=null==e?t.length-1:+e,function(){for(var r=Math.max(arguments.length-e,0),n=Array(r),i=0;r>i;i++)n[i]=arguments[i+e];switch(e){case 0:return t.call(this,n);case 1:return t.call(this,arguments[0],n)}}}function v(t){return function(e,r,n){return t(e,n)}}function m(t){return function(e,r,i){i=u(i||n),e=e||[];var o=y(e);if(0>=t)return i(null);var s=!1,c=0,f=!1;!function n(){if(s&&0>=c)return i(null);for(;t>c&&!f;){var u=o();if(null===u)return s=!0,void(0>=c&&i(null));c+=1,r(e[u],u,a(function(t){c-=1,t?(i(t),f=!0):n()}))}}()}}function b(t){return function(e,r,n){return t(R.eachOf,e,r,n)}}function w(t){return function(e,r,n,i){return t(m(r),e,n,i)}}function E(t){return function(e,r,n){return t(R.eachOfSeries,e,r,n)}}function O(t,e,r,i){i=u(i||n),e=e||[];var o=c(e)?[]:{};t(e,function(t,e,n){r(t,function(t,r){o[e]=r,n(t)})},function(t){i(t,o)})}function A(t,e,r,n){var i=[];t(e,function(t,e,n){r(t,function(r){r&&i.push({index:e,value:t}),n()})},function(){n(l(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})}function S(t,e,r,n){A(t,e,function(t,e){r(t,function(t){e(!t)})},n)}function j(t,e,r){return function(n,i,o,s){function a(){s&&s(r(!1,void 0))}function u(t,n,i){return s?void o(t,function(n){s&&e(n)&&(s(r(!0,t)),s=o=!1),i()}):i()}arguments.length>3?t(n,i,u,a):(s=o,o=i,t(n,u,a))}}function N(t,e){return e}function x(t,e,r){r=r||n;var i=c(e)?[]:{};t(e,function(t,e,r){t(g(function(t,n){n.length<=1&&(n=n[0]),i[e]=n,r(t)}))},function(t){r(t,i)})}function B(t,e,r,n){var i=[];t(e,function(t,e,n){r(t,function(t,e){i=i.concat(e||[]),n(t)})},function(t){n(t,i)})}function T(t,e,r){function i(t,e,r,i){if(null!=i&&"function"!=typeof i)throw new Error("task callback must be a function");return t.started=!0,L(e)||(e=[e]),0===e.length&&t.idle()?R.setImmediate(function(){t.drain()}):(f(e,function(e){var o={data:e,callback:i||n};r?t.tasks.unshift(o):t.tasks.push(o),t.tasks.length===t.concurrency&&t.saturated()}),void R.setImmediate(t.process))}function o(t,e){return function(){s-=1;var r=!1,n=arguments;f(e,function(t){f(u,function(e,n){e!==t||r||(u.splice(n,1),r=!0)}),t.callback.apply(t,n)}),t.tasks.length+s===0&&t.drain(),t.process()}}if(null==e)e=1;else if(0===e)throw new Error("Concurrency must not be zero");var s=0,u=[],c={tasks:[],concurrency:e,payload:r,saturated:n,empty:n,drain:n,started:!1,paused:!1,push:function(t,e){i(c,t,!1,e)},kill:function(){c.drain=n,c.tasks=[]},unshift:function(t,e){i(c,t,!0,e)},process:function(){for(;!c.paused&&s<c.concurrency&&c.tasks.length;){var e=c.payload?c.tasks.splice(0,c.payload):c.tasks.splice(0,c.tasks.length),r=l(e,function(t){return t.data});0===c.tasks.length&&c.empty(),s+=1,u.push(e[0]);var n=a(o(c,e));t(r,n)}},length:function(){return c.tasks.length},running:function(){return s},workersList:function(){return u},idle:function(){return c.tasks.length+s===0},pause:function(){c.paused=!0},resume:function(){if(c.paused!==!1){c.paused=!1;for(var t=Math.min(c.concurrency,c.tasks.length),e=1;t>=e;e++)R.setImmediate(c.process)}}};return c}function k(t){return g(function(e,r){e.apply(null,r.concat([g(function(e,r){"object"==typeof console&&(e?console.error&&console.error(e):console[t]&&f(r,function(e){console[t](e)}))})]))})}function $(t){return function(e,r,n){t(h(e),r,n)}}function I(t){return g(function(e,r){var n=g(function(r){var n=this,i=r.pop();return t(e,function(t,e,i){t.apply(n,r.concat([i]))},i)});return r.length?n.apply(this,r):n})}function D(t){return g(function(e){var r=e.pop();e.push(function(){var t=arguments;n?R.setImmediate(function(){r.apply(null,t)}):r.apply(null,t)});var n=!0;t.apply(this,e),n=!1})}var P,R={},C="object"==typeof self&&self.self===self&&self||"object"==typeof r&&r.global===r&&r||this;null!=C&&(P=C.async),R.noConflict=function(){return C.async=P,R};var M=Object.prototype.toString,L=Array.isArray||function(t){return"[object Array]"===M.call(t)},F=function(t){var e=typeof t;return"function"===e||"object"===e&&!!t},U=Object.keys||function(t){var e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(r);return e},V="function"==typeof setImmediate&&setImmediate,q=V?function(t){V(t)}:function(t){setTimeout(t,0)};"object"==typeof t&&"function"==typeof t.nextTick?R.nextTick=t.nextTick:R.nextTick=q,R.setImmediate=V?q:R.nextTick,R.forEach=R.each=function(t,e,r){return R.eachOf(t,v(e),r)},R.forEachSeries=R.eachSeries=function(t,e,r){return R.eachOfSeries(t,v(e),r)},R.forEachLimit=R.eachLimit=function(t,e,r,n){return m(e)(t,v(r),n)},R.forEachOf=R.eachOf=function(t,e,r){function i(t){c--,t?r(t):null===o&&0>=c&&r(null)}r=u(r||n),t=t||[];for(var o,s=y(t),c=0;null!=(o=s());)c+=1,e(t[o],o,a(i));0===c&&r(null)},R.forEachOfSeries=R.eachOfSeries=function(t,e,r){function i(){var n=!0;return null===s?r(null):(e(t[s],s,a(function(t){if(t)r(t);else{if(s=o(),null===s)return r(null);n?R.setImmediate(i):i()}})),void(n=!1))}r=u(r||n),t=t||[];var o=y(t),s=o();i()},R.forEachOfLimit=R.eachOfLimit=function(t,e,r,n){m(e)(t,r,n)},R.map=b(O),R.mapSeries=E(O),R.mapLimit=w(O),R.inject=R.foldl=R.reduce=function(t,e,r,n){R.eachOfSeries(t,function(t,n,i){r(e,t,function(t,r){e=r,i(t)})},function(t){n(t,e)})},R.foldr=R.reduceRight=function(t,e,r,n){var o=l(t,i).reverse();R.reduce(o,e,r,n)},R.transform=function(t,e,r,n){3===arguments.length&&(n=r,r=e,e=L(t)?[]:{}),R.eachOf(t,function(t,n,i){r(e,t,n,i)},function(t){n(t,e)})},R.select=R.filter=b(A),R.selectLimit=R.filterLimit=w(A),R.selectSeries=R.filterSeries=E(A),R.reject=b(S),R.rejectLimit=w(S),R.rejectSeries=E(S),R.any=R.some=j(R.eachOf,o,i),R.someLimit=j(R.eachOfLimit,o,i),R.all=R.every=j(R.eachOf,s,s),R.everyLimit=j(R.eachOfLimit,s,s),R.detect=j(R.eachOf,i,N),R.detectSeries=j(R.eachOfSeries,i,N),R.detectLimit=j(R.eachOfLimit,i,N),R.sortBy=function(t,e,r){function n(t,e){var r=t.criteria,n=e.criteria;return n>r?-1:r>n?1:0}R.map(t,function(t,r){e(t,function(e,n){e?r(e):r(null,{value:t,criteria:n})})},function(t,e){return t?r(t):void r(null,l(e.sort(n),function(t){return t.value}))})},R.auto=function(t,e,r){function i(t){v.unshift(t)}function o(t){var e=_(v,t);e>=0&&v.splice(e,1)}function s(){c--,f(v.slice(0),function(t){t()})}"function"==typeof arguments[1]&&(r=e,e=null),r=u(r||n);var a=U(t),c=a.length;if(!c)return r(null);e||(e=c);var l={},h=0,y=!1,v=[];i(function(){c||r(null,l)}),f(a,function(n){function a(){return e>h&&p(m,function(t,e){return t&&l.hasOwnProperty(e)},!0)&&!l.hasOwnProperty(n)}function u(){a()&&(h++,o(u),f[f.length-1](v,l))}if(!y){for(var c,f=L(t[n])?t[n]:[t[n]],v=g(function(t,e){if(h--,e.length<=1&&(e=e[0]),t){var i={};d(l,function(t,e){i[e]=t}),i[n]=e,y=!0,r(t,i)}else l[n]=e,R.setImmediate(s)}),m=f.slice(0,f.length-1),b=m.length;b--;){if(!(c=t[m[b]]))throw new Error("Has nonexistent dependency in "+m.join(", "));if(L(c)&&_(c,n)>=0)throw new Error("Has cyclic dependencies")}a()?(h++,f[f.length-1](v,l)):i(u)}})},R.retry=function(t,e,r){function n(t,e){if("number"==typeof e)t.times=parseInt(e,10)||o;else{if("object"!=typeof e)throw new Error("Unsupported argument type for 'times': "+typeof e);t.times=parseInt(e.times,10)||o,t.interval=parseInt(e.interval,10)||s}}function i(t,e){function r(t,r){return function(n){t(function(t,e){n(!t||r,{err:t,result:e})},e)}}function n(t){return function(e){setTimeout(function(){e(null)},t)}}for(;u.times;){var i=!(u.times-=1);a.push(r(u.task,i)),!i&&u.interval>0&&a.push(n(u.interval))}R.series(a,function(e,r){r=r[r.length-1],(t||u.callback)(r.err,r.result)})}var o=5,s=0,a=[],u={times:o,interval:s},c=arguments.length;if(1>c||c>3)throw new Error("Invalid arguments - must be either (task), (task, callback), (times, task) or (times, task, callback)");return 2>=c&&"function"==typeof t&&(r=e,e=t),"function"!=typeof t&&n(u,t),u.callback=r,u.task=e,u.callback?i():i},R.waterfall=function(t,e){function r(t){return g(function(n,i){if(n)e.apply(null,[n].concat(i));else{var o=t.next();o?i.push(r(o)):i.push(e),D(t).apply(null,i)}})}if(e=u(e||n),!L(t)){var i=new Error("First argument to waterfall must be an array of functions");return e(i)}return t.length?void r(R.iterator(t))():e()},R.parallel=function(t,e){x(R.eachOf,t,e)},R.parallelLimit=function(t,e,r){x(m(e),t,r)},R.series=function(t,e){x(R.eachOfSeries,t,e)},R.iterator=function(t){function e(r){function n(){return t.length&&t[r].apply(null,arguments),n.next()}return n.next=function(){return r<t.length-1?e(r+1):null},n}return e(0)},R.apply=g(function(t,e){return g(function(r){return t.apply(null,e.concat(r))})}),R.concat=b(B),R.concatSeries=E(B),R.whilst=function(t,e,r){if(r=r||n,t()){var i=g(function(n,o){n?r(n):t.apply(this,o)?e(i):r.apply(null,[null].concat(o))});e(i)}else r(null)},R.doWhilst=function(t,e,r){var n=0;return R.whilst(function(){return++n<=1||e.apply(this,arguments)},t,r)},R.until=function(t,e,r){return R.whilst(function(){return!t.apply(this,arguments)},e,r)},R.doUntil=function(t,e,r){return R.doWhilst(t,function(){return!e.apply(this,arguments)},r)},R.during=function(t,e,r){r=r||n;var i=g(function(e,n){e?r(e):(n.push(o),t.apply(this,n))}),o=function(t,n){t?r(t):n?e(i):r(null)};t(o)},R.doDuring=function(t,e,r){var n=0;R.during(function(t){n++<1?t(null,!0):e.apply(this,arguments)},t,r)},R.queue=function(t,e){var r=T(function(e,r){t(e[0],r)},e,1);return r},R.priorityQueue=function(t,e){function r(t,e){return t.priority-e.priority}function i(t,e,r){for(var n=-1,i=t.length-1;i>n;){var o=n+(i-n+1>>>1);r(e,t[o])>=0?n=o:i=o-1}return n}function o(t,e,o,s){if(null!=s&&"function"!=typeof s)throw new Error("task callback must be a function");return t.started=!0,L(e)||(e=[e]),0===e.length?R.setImmediate(function(){t.drain()}):void f(e,function(e){var a={data:e,priority:o,callback:"function"==typeof s?s:n};t.tasks.splice(i(t.tasks,a,r)+1,0,a),t.tasks.length===t.concurrency&&t.saturated(),R.setImmediate(t.process)})}var s=R.queue(t,e);return s.push=function(t,e,r){o(s,t,e,r)},delete s.unshift,s},R.cargo=function(t,e){return T(t,1,e)},R.log=k("log"),R.dir=k("dir"),R.memoize=function(t,e){var r={},n={},o=Object.prototype.hasOwnProperty;e=e||i;var s=g(function(i){var s=i.pop(),a=e.apply(null,i);o.call(r,a)?R.setImmediate(function(){s.apply(null,r[a])}):o.call(n,a)?n[a].push(s):(n[a]=[s],t.apply(null,i.concat([g(function(t){r[a]=t;var e=n[a];delete n[a];for(var i=0,o=e.length;o>i;i++)e[i].apply(null,t)})])))});return s.memo=r,s.unmemoized=t,s},R.unmemoize=function(t){return function(){return(t.unmemoized||t).apply(null,arguments)}},R.times=$(R.map),R.timesSeries=$(R.mapSeries),R.timesLimit=function(t,e,r,n){return R.mapLimit(h(t),e,r,n)},R.seq=function(){var t=arguments;return g(function(e){var r=this,i=e[e.length-1];"function"==typeof i?e.pop():i=n,R.reduce(t,e,function(t,e,n){e.apply(r,t.concat([g(function(t,e){n(t,e)})]))},function(t,e){i.apply(r,[t].concat(e))})})},R.compose=function(){return R.seq.apply(null,Array.prototype.reverse.call(arguments))},R.applyEach=I(R.eachOf),R.applyEachSeries=I(R.eachOfSeries),R.forever=function(t,e){function r(t){return t?i(t):void o(r)}var i=a(e||n),o=D(t);r()},R.ensureAsync=D,R.constant=g(function(t){var e=[null].concat(t);return function(t){return t.apply(this,e)}}),R.wrapSync=R.asyncify=function(t){return g(function(e){var r,n=e.pop();try{r=t.apply(this,e)}catch(t){return n(t)}F(r)&&"function"==typeof r.then?r.then(function(t){n(null,t)}).catch(function(t){n(t.message?t:new Error(t))}):n(null,r)})},"object"==typeof e&&e.exports?e.exports=R:"function"==typeof define&&define.amd?define([],function(){return R}):C.async=R}()}).call(this,t("g5I+bs"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"g5I+bs":94}],52:[function(t,e,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===s?62:e===a?63:u>e?-1:u+10>e?e-u+26+26:f+26>e?e-f:c+26>e?e-c+26:void 0}function r(t){function r(t){c[l++]=t}var n,i,s,a,u,c;if(t.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=t.length;u="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,c=new o(3*t.length/4-u),s=u>0?t.length-4:t.length;var l=0;for(n=0,i=0;s>n;n+=4,i+=3)a=e(t.charAt(n))<<18|e(t.charAt(n+1))<<12|e(t.charAt(n+2))<<6|e(t.charAt(n+3)),r((16711680&a)>>16),r((65280&a)>>8),r(255&a);return 2===u?(a=e(t.charAt(n))<<2|e(t.charAt(n+1))>>4,r(255&a)):1===u&&(a=e(t.charAt(n))<<10|e(t.charAt(n+1))<<4|e(t.charAt(n+2))>>2,r(a>>8&255),r(255&a)),c}function i(t){function e(t){return n.charAt(t)}function r(t){return e(t>>18&63)+e(t>>12&63)+e(t>>6&63)+e(63&t)}var i,o,s,a=t.length%3,u="";for(i=0,s=t.length-a;s>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],u+=r(o);switch(a){case 1:o=t[t.length-1],u+=e(o>>2),u+=e(o<<4&63),u+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],u+=e(o>>10),u+=e(o>>4&63),u+=e(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),c="a".charCodeAt(0),f="A".charCodeAt(0);t.toByteArray=r,t.fromByteArray=i}("undefined"==typeof r?this.base64js={}:r)},{}],53:[function(t,e,r){(function(r){function n(t,e){if(!(this instanceof n))return new n(t,e);if(this._bsontype="Binary",t instanceof Number?(this.sub_type=t,this.position=0):(this.sub_type=null==e?o:e,this.position=0),null==t||t instanceof Number)"undefined"!=typeof i?this.buffer=new i(n.BUFFER_SIZE):"undefined"!=typeof Uint8Array?this.buffer=new Uint8Array(new ArrayBuffer(n.BUFFER_SIZE)):this.buffer=new Array(n.BUFFER_SIZE),this.position=0;else{if("string"==typeof t)if("undefined"!=typeof i)this.buffer=new i(t);else{if("undefined"==typeof Uint8Array&&"[object Array]"!=Object.prototype.toString.call(t))throw new Error("only String, Buffer, Uint8Array or Array accepted");this.buffer=s(t)}else this.buffer=t;this.position=t.length}}if("undefined"!=typeof r)var i=t("buffer").Buffer;n.prototype.put=function(t){if(null!=t.length&&"number"!=typeof t&&1!=t.length)throw new Error("only accepts single character String, Uint8Array or Array");if("number"!=typeof t&&0>t||t>255)throw new Error("only accepts number in a valid unsigned byte range 0-255");var e=null;if(e="string"==typeof t?t.charCodeAt(0):null!=t.length?t[0]:t,this.buffer.length>this.position)this.buffer[this.position++]=e;else if("undefined"!=typeof i&&i.isBuffer(this.buffer)){var r=new i(n.BUFFER_SIZE+this.buffer.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r,this.buffer[this.position++]=e}else{var r=null;r="[object Uint8Array]"==Object.prototype.toString.call(this.buffer)?new Uint8Array(new ArrayBuffer(n.BUFFER_SIZE+this.buffer.length)):new Array(n.BUFFER_SIZE+this.buffer.length);for(var o=0;o<this.buffer.length;o++)r[o]=this.buffer[o];this.buffer=r,this.buffer[this.position++]=e}},n.prototype.write=function(t,e){if(e="number"==typeof e?e:this.position,this.buffer.length<e+t.length){var r=null;if("undefined"!=typeof i&&i.isBuffer(this.buffer))r=new i(this.buffer.length+t.length),this.buffer.copy(r,0,0,this.buffer.length);else if("[object Uint8Array]"==Object.prototype.toString.call(this.buffer)){r=new Uint8Array(new ArrayBuffer(this.buffer.length+t.length));for(var n=0;n<this.position;n++)r[n]=this.buffer[n]}this.buffer=r}if("undefined"!=typeof i&&i.isBuffer(t)&&i.isBuffer(this.buffer))t.copy(this.buffer,e,0,t.length),this.position=e+t.length>this.position?e+t.length:this.position;else if("undefined"!=typeof i&&"string"==typeof t&&i.isBuffer(this.buffer))this.buffer.write(t,e,"binary"),this.position=e+t.length>this.position?e+t.length:this.position;else if("[object Uint8Array]"==Object.prototype.toString.call(t)||"[object Array]"==Object.prototype.toString.call(t)&&"string"!=typeof t){for(var n=0;n<t.length;n++)this.buffer[e++]=t[n];this.position=e>this.position?e:this.position}else if("string"==typeof t){for(var n=0;n<t.length;n++)this.buffer[e++]=t.charCodeAt(n);this.position=e>this.position?e:this.position}},n.prototype.read=function(t,e){if(e=e&&e>0?e:this.position,this.buffer.slice)return this.buffer.slice(t,t+e);for(var r="undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(e)):new Array(e),n=0;e>n;n++)r[n]=this.buffer[t++];return r},n.prototype.value=function(t){if(t=null==t?!1:t,t&&"undefined"!=typeof i&&i.isBuffer(this.buffer)&&this.buffer.length==this.position)return this.buffer;if("undefined"!=typeof i&&i.isBuffer(this.buffer))return t?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position);if(t){if(null!=this.buffer.slice)return this.buffer.slice(0,this.position);for(var e="[object Uint8Array]"==Object.prototype.toString.call(this.buffer)?new Uint8Array(new ArrayBuffer(this.position)):new Array(this.position),r=0;r<this.position;r++)e[r]=this.buffer[r];return e}return a(this.buffer,0,this.position)},n.prototype.length=function(){return this.position},n.prototype.toJSON=function(){return null!=this.buffer?this.buffer.toString("base64"):""},n.prototype.toString=function(t){return null!=this.buffer?this.buffer.slice(0,this.position).toString(t):""};var o=0,s=function(t){for(var e="undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(t.length)):new Array(t.length),r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e},a=function(t,e,r){for(var n="",i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n};n.BUFFER_SIZE=256,n.SUBTYPE_DEFAULT=0,n.SUBTYPE_FUNCTION=1,n.SUBTYPE_BYTE_ARRAY=2,n.SUBTYPE_UUID_OLD=3,n.SUBTYPE_UUID=4,n.SUBTYPE_MD5=5,n.SUBTYPE_USER_DEFINED=128,e.exports=n,e.exports.Binary=n}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{buffer:71}],54:[function(t,e,n){(function(e){function i(t,e){return this instanceof i?(this.bigEndian=t,void(this.allowExceptions=e)):new i(t,e)}function o(t,e){this.bigEndian=t||0,this.buffer=[],this.setBuffer(e)}for(var s=String.fromCharCode,a=[],u=0;64>u;u++)a[u]=Math.pow(2,u);i.warn=function(t){if(this.allowExceptions)throw new Error(t);return 1},i.decodeFloat=function(t,e,r){var n=new this.Buffer(this.bigEndian,t);n.checkBuffer(e+r+1);var i=a[r-1]-1,o=n.readBits(e+r,1),s=n.readBits(e,r),u=0,c=2,f=n.buffer.length+(-e>>3)-1;do for(var l=n.buffer[++f],h=e%8||8,p=1<<h;p>>=1;l&p&&(u+=1/c),c*=2);while(e-=h);return s==(i<<1)+1?u?NaN:o?-(1/0):+(1/0):(1+-2*o)*(s||u?s?Math.pow(2,s-i)*(1+u):Math.pow(2,-i+1)*u:0)},i.decodeInt=function(t,e,r,n){var i=new this.Buffer(this.bigEndian||n,t),o=i.readBits(0,e),s=a[e];return r&&o>=s/2?o-s:o},i.encodeFloat=function(t,e,n){var i,o,s,u,c,f=a[n-1]-1,l=-f+1,h=f,p=l-e,d=parseFloat(t),_=isNaN(d)||d==-(1/0)||d==+(1/0)?d:0,y=0,g=2*f+1+e+3,v=new Array(g),m=(d=0!==_?0:d)<0,b=Math.floor(d=Math.abs(d)),w=d-b;for(u=g;u;v[--u]=0);for(u=f+2;b&&u;v[--u]=b%2,b=Math.floor(b/2));for(u=f+1;w>0&&u;(v[++u]=((w*=2)>=1)-0)&&--w);for(u=-1;++u<g&&!v[u];);if(v[(i=e-1+(u=(y=f+1-u)>=l&&h>=y?u+1:f+1-(y=l-1)))+1]){if(!(o=v[i]))for(c=i+2;!o&&g>c;o=v[c++]);for(c=i+1;o&&--c>=0;(v[c]=!v[c]-0)&&(o=0));}for(u=0>u-2?-1:u-3;++u<g&&!v[u];);for((y=f+1-u)>=l&&h>=y?++u:l>y&&(y!=f+1-g&&p>y&&this.warn("encodeFloat::float underflow"),u=f+1-(y=l-1)),(b||0!==_)&&(this.warn(b?"encodeFloat::float overflow":"encodeFloat::"+_),y=h+1,u=f+2,_==-(1/0)?m=1:isNaN(_)&&(v[u]=1)),d=Math.abs(y+f),c=n+1,s="";--c;s=d%2+s,d=d>>=1);for(d=0,c=0,u=(s=(m?"1":"0")+s+v.slice(u,u+e).join("")).length,r=[];u;c=(c+1)%8)d+=(1<<c)*s.charAt(--u),7==c&&(r[r.length]=String.fromCharCode(d),d=0);return r[r.length]=d?String.fromCharCode(d):"",(this.bigEndian?r.reverse():r).join("")},i.encodeInt=function(t,e,r,n){var i=a[e];(t>=i||-(i/2)>t)&&(this.warn("encodeInt::overflow"),t=0),0>t&&(t+=i);for(var o=[];t;o[o.length]=String.fromCharCode(t%256),t=Math.floor(t/256));for(e=-(-e>>3)-o.length;e--;o[o.length]="\x00");return(this.bigEndian||n?o.reverse():o).join("")},i.toSmall=function(t){return this.decodeInt(t,8,!0)},i.fromSmall=function(t){return this.encodeInt(t,8,!0)},i.toByte=function(t){return this.decodeInt(t,8,!1)},i.fromByte=function(t){return this.encodeInt(t,8,!1)},i.toShort=function(t){return this.decodeInt(t,16,!0)},i.fromShort=function(t){return this.encodeInt(t,16,!0)},i.toWord=function(t){return this.decodeInt(t,16,!1)},i.fromWord=function(t){return this.encodeInt(t,16,!1)},i.toInt=function(t){return this.decodeInt(t,32,!0)},i.fromInt=function(t){return this.encodeInt(t,32,!0)},i.toLong=function(t){return this.decodeInt(t,64,!0)},i.fromLong=function(t){return this.encodeInt(t,64,!0)},i.toDWord=function(t){return this.decodeInt(t,32,!1)},i.fromDWord=function(t){return this.encodeInt(t,32,!1)},i.toQWord=function(t){return this.decodeInt(t,64,!0)},i.fromQWord=function(t){return this.encodeInt(t,64,!0)},i.toFloat=function(t){return this.decodeFloat(t,23,8)},i.fromFloat=function(t){return this.encodeFloat(t,23,8)},i.toDouble=function(t){return this.decodeFloat(t,52,11)},i.fromDouble=function(t){return this.encodeFloat(t,52,11)},i.encode_int32=function(t,e){var r,n,i,o,a;return a=0>t?t+4294967296:t,r=Math.floor(a/16777215),a&=16777215,n=Math.floor(a/65535),a&=65535,i=Math.floor(a/255),a&=255,o=Math.floor(a),e?[s(r),s(n),s(i),s(o)]:s(r)+s(n)+s(i)+s(o)},i.encode_int64=function(t){var e,r,n,i,o,a,u,c,f;return f=0>t?t+0x10000000000000000:t,e=Math.floor(f/72057594037927940),f&=72057594037927940,r=Math.floor(f/0xffffffffffff),f&=0xffffffffffff,n=Math.floor(f/0xffffffffff),f&=0xffffffffff,i=Math.floor(f/4294967295),f&=4294967295,o=Math.floor(f/16777215),f&=16777215,a=Math.floor(f/65535),f&=65535,u=Math.floor(f/255),f&=255,c=Math.floor(f),s(e)+s(r)+s(n)+s(i)+s(o)+s(a)+s(u)+s(c)},i.decode_utf8=function(t){for(var e,r=t.length,n="",i=0,o=0,s=0;r>i;)o=t.charCodeAt(i),128>o?(n+=String.fromCharCode(o),i++):o>191&&224>o?(s=t.charCodeAt(i+1),n+=String.fromCharCode((31&o)<<6|63&s),i+=2):(s=t.charCodeAt(i+1),e=t.charCodeAt(i+2),n+=String.fromCharCode((15&o)<<12|(63&s)<<6|63&e),i+=3);return n},i.encode_cstring=function(t){return unescape(encodeURIComponent(t))+i.fromByte(0)},i.encode_utf8=function(t){for(var e,r="",n=0,i=t.length;i>n;n++)e=t.charCodeAt(n),128>e?r+=String.fromCharCode(e):e>127&&2048>e?(r+=String.fromCharCode(e>>6|192),r+=String.fromCharCode(63&e|128)):(r+=String.fromCharCode(e>>12|224),r+=String.fromCharCode(e>>6&63|128),r+=String.fromCharCode(63&e|128));return r},i.hprint=function(t){for(var r,n=0,i=t.length;i>n;n++)t.charCodeAt(n)<32?(r=t.charCodeAt(n)<=15?"0"+t.charCodeAt(n).toString(16):t.charCodeAt(n).toString(16),e.stdout.write(r+" ")):(r=t.charCodeAt(n)<=15?"0"+t.charCodeAt(n).toString(16):t.charCodeAt(n).toString(16),e.stdout.write(r+" "));e.stdout.write("\n\n")},i.ilprint=function(e){for(var r,n=0,i=e.length;i>n;n++)e.charCodeAt(n)<32?(r=e.charCodeAt(n)<=15?"0"+e.charCodeAt(n).toString(10):e.charCodeAt(n).toString(10),t("util").debug(r+" : ")):(r=e.charCodeAt(n)<=15?"0"+e.charCodeAt(n).toString(10):e.charCodeAt(n).toString(10),t("util").debug(r+" : "+e.charAt(n)))},i.hlprint=function(e){for(var r,n=0,i=e.length;i>n;n++)e.charCodeAt(n)<32?(r=e.charCodeAt(n)<=15?"0"+e.charCodeAt(n).toString(16):e.charCodeAt(n).toString(16),t("util").debug(r+" : ")):(r=e.charCodeAt(n)<=15?"0"+e.charCodeAt(n).toString(16):e.charCodeAt(n).toString(16),t("util").debug(r+" : "+e.charAt(n)))},o.prototype.setBuffer=function(t){var e,r,n;if(t){for(r=e=t.length,n=this.buffer=new Array(e);r;n[e-r]=t.charCodeAt(--r));this.bigEndian&&n.reverse()}},o.prototype.hasNeededBits=function(t){return this.buffer.length>=-(-t>>3)},o.prototype.checkBuffer=function(t){if(!this.hasNeededBits(t))throw new Error("checkBuffer::missing bytes")},o.prototype.readBits=function(t,e){function r(t,e){for(;e--;t=1073741824==(1073741824&(t%=2147483648))?2*t:2*(t-1073741824)+2147483647+1);return t}if(0>t||0>=e)return 0;this.checkBuffer(t+e);for(var n,i=t%8,o=this.buffer.length-(t>>3)-1,s=this.buffer.length+(-(t+e)>>3),a=o-s,u=(this.buffer[o]>>i&(1<<(a?8-i:e))-1)+(a&&(n=(t+e)%8)?(this.buffer[s++]&(1<<n)-1)<<(a--<<3)-i:0);a;u+=r(this.buffer[s++],(a--<<3)-i));return u},i.Buffer=o,n.BinaryParser=i}).call(this,t("g5I+bs"))},{"g5I+bs":94,util:98}],55:[function(t,e,r){(function(r){var n=(t("./float_parser").writeIEEE754,t("./float_parser").readIEEE754,t("./map")),i=t("./long").Long,o=t("./double").Double,s=t("./timestamp").Timestamp,a=t("./objectid").ObjectID,u=t("./regexp").BSONRegExp,c=t("./symbol").Symbol,f=t("./code").Code,l=t("./min_key").MinKey,h=t("./max_key").MaxKey,p=t("./db_ref").DBRef,d=t("./binary").Binary,_=t("./parser/deserializer"),y=t("./parser/serializer"),g=t("./parser/calculate_size"),v=17825792,m=new r(v),b=function(){};b.prototype.serialize=function(t,e,n,i,o,s){var a=y(m,t,e,o||0,0,i,s),u=new r(a);return m.copy(u,0,0,u.length),u},b.prototype.serializeWithBufferAndIndex=function(t,e,r,n,i,o){var s=y(m,t,e,n||0,0,i,o);return m.copy(r,n,0,s),n+s-1},b.prototype.deserialize=function(t,e){return _(t,e)},b.prototype.calculateObjectSize=function(t,e,r){return g(t,e,r)},b.prototype.deserializeStream=function(t,e,r,n,i,o){o=null!=o?o:{};for(var s=e,a=0;r>a;a++){var u=t[s]|t[s+1]<<8|t[s+2]<<16|t[s+3]<<24;o.index=s,n[i+a]=this.deserialize(t,o),s+=u}return s},b.BSON_INT32_MAX=2147483647,b.BSON_INT32_MIN=-2147483648,b.BSON_INT64_MAX=Math.pow(2,63)-1,b.BSON_INT64_MIN=-Math.pow(2,63),b.JS_INT_MAX=9007199254740992,b.JS_INT_MIN=-9007199254740992;i.fromNumber(9007199254740992),i.fromNumber(-9007199254740992);b.BSON_DATA_NUMBER=1,b.BSON_DATA_STRING=2,b.BSON_DATA_OBJECT=3,b.BSON_DATA_ARRAY=4,b.BSON_DATA_BINARY=5,b.BSON_DATA_OID=7,b.BSON_DATA_BOOLEAN=8,b.BSON_DATA_DATE=9,b.BSON_DATA_NULL=10,b.BSON_DATA_REGEXP=11,b.BSON_DATA_CODE=13,b.BSON_DATA_SYMBOL=14,b.BSON_DATA_CODE_W_SCOPE=15,b.BSON_DATA_INT=16,b.BSON_DATA_TIMESTAMP=17,b.BSON_DATA_LONG=18,b.BSON_DATA_MIN_KEY=255,b.BSON_DATA_MAX_KEY=127,b.BSON_BINARY_SUBTYPE_DEFAULT=0,b.BSON_BINARY_SUBTYPE_FUNCTION=1,b.BSON_BINARY_SUBTYPE_BYTE_ARRAY=2,b.BSON_BINARY_SUBTYPE_UUID=3,b.BSON_BINARY_SUBTYPE_MD5=4,b.BSON_BINARY_SUBTYPE_USER_DEFINED=128,e.exports=b,e.exports.Code=f,e.exports.Map=n,e.exports.Symbol=c,e.exports.BSON=b,e.exports.DBRef=p,e.exports.Binary=d,e.exports.ObjectID=a,e.exports.Long=i,e.exports.Timestamp=s,e.exports.Double=o,e.exports.MinKey=l,e.exports.MaxKey=h,e.exports.BSONRegExp=u}).call(this,t("buffer").Buffer)},{"./binary":53,"./code":56,"./db_ref":57,"./double":58,"./float_parser":59,"./long":60,"./map":61,"./max_key":62,"./min_key":63,"./objectid":64,"./parser/calculate_size":65,"./parser/deserializer":66,"./parser/serializer":67,"./regexp":68,"./symbol":69,"./timestamp":70,buffer:71}],56:[function(t,e,r){var n=function t(e,r){return this instanceof t?(this._bsontype="Code",this.code=e,void(this.scope=null==r?{}:r)):new t(e,r)};n.prototype.toJSON=function(){return{scope:this.scope,code:this.code}},e.exports=n,e.exports.Code=n},{}],57:[function(t,e,r){function n(t,e,r){return this instanceof n?(this._bsontype="DBRef",this.namespace=t,this.oid=e,void(this.db=r)):new n(t,e,r)}n.prototype.toJSON=function(){return{$ref:this.namespace,$id:this.oid,$db:null==this.db?"":this.db}},e.exports=n,e.exports.DBRef=n},{}],58:[function(t,e,r){function n(t){return this instanceof n?(this._bsontype="Double",void(this.value=t)):new n(t)}n.prototype.valueOf=function(){return this.value},n.prototype.toJSON=function(){return this.value},e.exports=n,e.exports.Double=n},{}],59:[function(t,e,r){var n=function(t,e,r,n,i){var o,s,a="big"===r,u=8*i-n-1,c=(1<<u)-1,f=c>>1,l=-7,h=a?0:i-1,p=a?1:-1,d=t[e+h];for(h+=p,o=d&(1<<-l)-1,d>>=-l,l+=u;l>0;o=256*o+t[e+h],h+=p,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+t[e+h],h+=p,l-=8);if(0===o)o=1-f;else{if(o===c)return s?NaN:(d?-1:1)*(1/0);s+=Math.pow(2,n),o-=f}return(d?-1:1)*s*Math.pow(2,o-n)},i=function(t,e,r,n,i,o){var s,a,u,c="big"===n,f=8*o-i-1,l=(1<<f)-1,h=l>>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=c?o-1:0,_=c?-1:1,y=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+h>=1?p/u:p*Math.pow(2,1-h),e*u>=2&&(s++,u/=2),s+h>=l?(a=0,s=l):s+h>=1?(a=(e*u-1)*Math.pow(2,i),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=_,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;t[r+d]=255&s,d+=_,s/=256,f-=8);t[r+d-_]|=128*y};r.readIEEE754=n,r.writeIEEE754=i},{}],60:[function(t,e,r){function n(t,e){return this instanceof n?(this._bsontype="Long",this.low_=0|t,void(this.high_=0|e)):new n(t,e)}n.prototype.toInt=function(){return this.low_},n.prototype.toNumber=function(){return this.high_*n.TWO_PWR_32_DBL_+this.getLowBitsUnsigned()},n.prototype.toJSON=function(){return this.toString()},n.prototype.toString=function(t){var e=t||10;if(2>e||e>36)throw Error("radix out of range: "+e);if(this.isZero())return"0";if(this.isNegative()){if(this.equals(n.MIN_VALUE)){var r=n.fromNumber(e),i=this.div(r),o=i.multiply(r).subtract(this);return i.toString(e)+o.toInt().toString(e)}return"-"+this.negate().toString(e)}for(var s=n.fromNumber(Math.pow(e,6)),o=this,a="";;){var u=o.div(s),c=o.subtract(u.multiply(s)).toInt(),f=c.toString(e);if(o=u,o.isZero())return f+a;for(;f.length<6;)f="0"+f;a=""+f+a}},n.prototype.getHighBits=function(){return this.high_},n.prototype.getLowBits=function(){return this.low_},n.prototype.getLowBitsUnsigned=function(){return this.low_>=0?this.low_:n.TWO_PWR_32_DBL_+this.low_},n.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(n.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var t=0!=this.high_?this.high_:this.low_,e=31;e>0&&0==(t&1<<e);e--);return 0!=this.high_?e+33:e+1},n.prototype.isZero=function(){return 0==this.high_&&0==this.low_},n.prototype.isNegative=function(){return this.high_<0},n.prototype.isOdd=function(){return 1==(1&this.low_)},n.prototype.equals=function(t){return this.high_==t.high_&&this.low_==t.low_},n.prototype.notEquals=function(t){return this.high_!=t.high_||this.low_!=t.low_},n.prototype.lessThan=function(t){return this.compare(t)<0},n.prototype.lessThanOrEqual=function(t){return this.compare(t)<=0},n.prototype.greaterThan=function(t){return this.compare(t)>0},n.prototype.greaterThanOrEqual=function(t){return this.compare(t)>=0},n.prototype.compare=function(t){if(this.equals(t))return 0;var e=this.isNegative(),r=t.isNegative();return e&&!r?-1:!e&&r?1:this.subtract(t).isNegative()?-1:1},n.prototype.negate=function(){return this.equals(n.MIN_VALUE)?n.MIN_VALUE:this.not().add(n.ONE)},n.prototype.add=function(t){var e=this.high_>>>16,r=65535&this.high_,i=this.low_>>>16,o=65535&this.low_,s=t.high_>>>16,a=65535&t.high_,u=t.low_>>>16,c=65535&t.low_,f=0,l=0,h=0,p=0;return p+=o+c,h+=p>>>16,p&=65535,h+=i+u,l+=h>>>16,h&=65535,l+=r+a,f+=l>>>16,l&=65535,f+=e+s,f&=65535,n.fromBits(h<<16|p,f<<16|l)},n.prototype.subtract=function(t){return this.add(t.negate())},n.prototype.multiply=function(t){if(this.isZero())return n.ZERO;if(t.isZero())return n.ZERO;if(this.equals(n.MIN_VALUE))return t.isOdd()?n.MIN_VALUE:n.ZERO;if(t.equals(n.MIN_VALUE))return this.isOdd()?n.MIN_VALUE:n.ZERO;if(this.isNegative())return t.isNegative()?this.negate().multiply(t.negate()):this.negate().multiply(t).negate();
5
+ if(t.isNegative())return this.multiply(t.negate()).negate();if(this.lessThan(n.TWO_PWR_24_)&&t.lessThan(n.TWO_PWR_24_))return n.fromNumber(this.toNumber()*t.toNumber());var e=this.high_>>>16,r=65535&this.high_,i=this.low_>>>16,o=65535&this.low_,s=t.high_>>>16,a=65535&t.high_,u=t.low_>>>16,c=65535&t.low_,f=0,l=0,h=0,p=0;return p+=o*c,h+=p>>>16,p&=65535,h+=i*c,l+=h>>>16,h&=65535,h+=o*u,l+=h>>>16,h&=65535,l+=r*c,f+=l>>>16,l&=65535,l+=i*u,f+=l>>>16,l&=65535,l+=o*a,f+=l>>>16,l&=65535,f+=e*c+r*u+i*a+o*s,f&=65535,n.fromBits(h<<16|p,f<<16|l)},n.prototype.div=function(t){if(t.isZero())throw Error("division by zero");if(this.isZero())return n.ZERO;if(this.equals(n.MIN_VALUE)){if(t.equals(n.ONE)||t.equals(n.NEG_ONE))return n.MIN_VALUE;if(t.equals(n.MIN_VALUE))return n.ONE;var e=this.shiftRight(1),r=e.div(t).shiftLeft(1);if(r.equals(n.ZERO))return t.isNegative()?n.ONE:n.NEG_ONE;var i=this.subtract(t.multiply(r)),o=r.add(i.div(t));return o}if(t.equals(n.MIN_VALUE))return n.ZERO;if(this.isNegative())return t.isNegative()?this.negate().div(t.negate()):this.negate().div(t).negate();if(t.isNegative())return this.div(t.negate()).negate();for(var s=n.ZERO,i=this;i.greaterThanOrEqual(t);){for(var r=Math.max(1,Math.floor(i.toNumber()/t.toNumber())),a=Math.ceil(Math.log(r)/Math.LN2),u=48>=a?1:Math.pow(2,a-48),c=n.fromNumber(r),f=c.multiply(t);f.isNegative()||f.greaterThan(i);)r-=u,c=n.fromNumber(r),f=c.multiply(t);c.isZero()&&(c=n.ONE),s=s.add(c),i=i.subtract(f)}return s},n.prototype.modulo=function(t){return this.subtract(this.div(t).multiply(t))},n.prototype.not=function(){return n.fromBits(~this.low_,~this.high_)},n.prototype.and=function(t){return n.fromBits(this.low_&t.low_,this.high_&t.high_)},n.prototype.or=function(t){return n.fromBits(this.low_|t.low_,this.high_|t.high_)},n.prototype.xor=function(t){return n.fromBits(this.low_^t.low_,this.high_^t.high_)},n.prototype.shiftLeft=function(t){if(t&=63,0==t)return this;var e=this.low_;if(32>t){var r=this.high_;return n.fromBits(e<<t,r<<t|e>>>32-t)}return n.fromBits(0,e<<t-32)},n.prototype.shiftRight=function(t){if(t&=63,0==t)return this;var e=this.high_;if(32>t){var r=this.low_;return n.fromBits(r>>>t|e<<32-t,e>>t)}return n.fromBits(e>>t-32,e>=0?0:-1)},n.prototype.shiftRightUnsigned=function(t){if(t&=63,0==t)return this;var e=this.high_;if(32>t){var r=this.low_;return n.fromBits(r>>>t|e<<32-t,e>>>t)}return 32==t?n.fromBits(e,0):n.fromBits(e>>>t-32,0)},n.fromInt=function(t){if(t>=-128&&128>t){var e=n.INT_CACHE_[t];if(e)return e}var r=new n(0|t,0>t?-1:0);return t>=-128&&128>t&&(n.INT_CACHE_[t]=r),r},n.fromNumber=function(t){return isNaN(t)||!isFinite(t)?n.ZERO:t<=-n.TWO_PWR_63_DBL_?n.MIN_VALUE:t+1>=n.TWO_PWR_63_DBL_?n.MAX_VALUE:0>t?n.fromNumber(-t).negate():new n(t%n.TWO_PWR_32_DBL_|0,t/n.TWO_PWR_32_DBL_|0)},n.fromBits=function(t,e){return new n(t,e)},n.fromString=function(t,e){if(0==t.length)throw Error("number format error: empty string");var r=e||10;if(2>r||r>36)throw Error("radix out of range: "+r);if("-"==t.charAt(0))return n.fromString(t.substring(1),r).negate();if(t.indexOf("-")>=0)throw Error('number format error: interior "-" character: '+t);for(var i=n.fromNumber(Math.pow(r,8)),o=n.ZERO,s=0;s<t.length;s+=8){var a=Math.min(8,t.length-s),u=parseInt(t.substring(s,s+a),r);if(8>a){var c=n.fromNumber(Math.pow(r,a));o=o.multiply(c).add(n.fromNumber(u))}else o=o.multiply(i),o=o.add(n.fromNumber(u))}return o},n.INT_CACHE_={},n.TWO_PWR_16_DBL_=65536,n.TWO_PWR_24_DBL_=1<<24,n.TWO_PWR_32_DBL_=n.TWO_PWR_16_DBL_*n.TWO_PWR_16_DBL_,n.TWO_PWR_31_DBL_=n.TWO_PWR_32_DBL_/2,n.TWO_PWR_48_DBL_=n.TWO_PWR_32_DBL_*n.TWO_PWR_16_DBL_,n.TWO_PWR_64_DBL_=n.TWO_PWR_32_DBL_*n.TWO_PWR_32_DBL_,n.TWO_PWR_63_DBL_=n.TWO_PWR_64_DBL_/2,n.ZERO=n.fromInt(0),n.ONE=n.fromInt(1),n.NEG_ONE=n.fromInt(-1),n.MAX_VALUE=n.fromBits(-1,2147483647),n.MIN_VALUE=n.fromBits(0,-2147483648),n.TWO_PWR_24_=n.fromInt(1<<24),e.exports=n,e.exports.Long=n},{}],61:[function(t,e,r){(function(t){"use strict";if("undefined"!=typeof t.Map)e.exports=t.Map,e.exports.Map=t.Map;else{var r=function(t){this._keys=[],this._values={};for(var e=0;e<t.length;e++)if(null!=t[e]){var r=t[e],n=r[0],i=r[1];this._keys.push(n),this._values[n]={v:i,i:this._keys.length-1}}};r.prototype.clear=function(){this._keys=[],this._values={}},r.prototype.delete=function(t){var e=this._values[t];return null==e?!1:(delete this._values[t],this._keys.splice(e.i,1),!0)},r.prototype.entries=function(){var t=this,e=0;return{next:function(){var r=t._keys[e++];return{value:void 0!==r?[r,t._values[r].v]:void 0,done:void 0!==r?!1:!0}}}},r.prototype.forEach=function(t,e){e=e||this;for(var r=0;r<this._keys.length;r++){var n=this._keys[r];t.call(e,this._values[n].v,n,e)}},r.prototype.get=function(t){return this._values[t]?this._values[t].v:void 0},r.prototype.has=function(t){return null!=this._values[t]},r.prototype.keys=function(t){var e=this,r=0;return{next:function(){var t=e._keys[r++];return{value:void 0!==t?t:void 0,done:void 0!==t?!1:!0}}}},r.prototype.set=function(t,e){return this._values[t]?(this._values[t].v=e,this):(this._keys.push(t),this._values[t]={v:e,i:this._keys.length-1},this)},r.prototype.values=function(t,e){var r=this,n=0;return{next:function(){var t=r._keys[n++];return{value:void 0!==t?r._values[t].v:void 0,done:void 0!==t?!1:!0}}}},Object.defineProperty(r.prototype,"size",{enumerable:!0,get:function(){return this._keys.length}}),e.exports=r,e.exports.Map=r}}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],62:[function(t,e,r){function n(){return this instanceof n?void(this._bsontype="MaxKey"):new n}e.exports=n,e.exports.MaxKey=n},{}],63:[function(t,e,r){function n(){return this instanceof n?void(this._bsontype="MinKey"):new n}e.exports=n,e.exports.MinKey=n},{}],64:[function(t,e,r){(function(r){for(var n=t("./binary_parser").BinaryParser,i=parseInt(16777215*Math.random(),10),o=new RegExp("^[0-9a-fA-F]{24}$"),s=function t(e){if(!(this instanceof t))return new t(e);if(e instanceof t||e&&e.toHexString)return e;this._bsontype="ObjectID";var r=t.isValid(e);if(!r&&null!=e)throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return r&&"string"==typeof e&&24==e.length?t.createFromHexString(e):(null==e||"number"==typeof e?this.id=this.generate(e):null!=e&&12===e.length&&(this.id=e),void(t.cacheHexString&&(this.__id=this.toHexString())))},a=[],u=0;256>u;u++)a[u]=(15>=u?"0":"")+u.toString(16);s.prototype.toHexString=function(){if(s.cacheHexString&&this.__id)return this.__id;for(var t="",e=0;e<this.id.length;e++)t+=a[this.id.charCodeAt(e)];return s.cacheHexString&&(this.__id=t),t},s.prototype.get_inc=function(){return s.index=(s.index+1)%16777215},s.prototype.getInc=function(){return this.get_inc()},s.prototype.generate=function(t){"number"!=typeof t&&(t=parseInt(Date.now()/1e3,10));var e=n.encodeInt(t,32,!0,!0),o=n.encodeInt(i,24,!1),s=n.fromShort(("undefined"==typeof r?Math.floor(1e5*Math.random()):r.pid)%65535),a=n.encodeInt(this.get_inc(),24,!1,!0);return e+o+s+a},s.prototype.toString=function(){return this.toHexString()},s.prototype.inspect=s.prototype.toString,s.prototype.toJSON=function(){return this.toHexString()},s.prototype.equals=function(t){var e;if(null!=t&&(t instanceof s||t.toHexString))e=t.id;else{if("string"!=typeof t||!s.isValid(t))return!1;e=s.createFromHexString(t).id}return this.id===e},s.prototype.getTimestamp=function(){var t=new Date;return t.setTime(1e3*Math.floor(n.decodeInt(this.id.substring(0,4),32,!0,!0))),t},s.index=parseInt(16777215*Math.random(),10),s.createPk=function(){return new s},s.createFromTime=function(t){var e=n.encodeInt(t,32,!0,!0)+n.encodeInt(0,64,!0,!0);return new s(e)},s.createFromHexString=function(t){if("undefined"==typeof t||null!=t&&24!=t.length)throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");var e=t.length;if(e>24)throw new Error("Id cannot be longer than 12 bytes");for(var r,i,o="",a=0;e>a;a+=2)r=t.substr(a,2),i=parseInt(r,16),o+=n.fromByte(i);return new s(o,t)},s.isValid=function(t){return null==t?!1:"number"==typeof t?!0:"string"==typeof t?12==t.length||24==t.length&&o.test(t):t instanceof s?!0:t.toHexString?12==t.id.length||24==t.id.length&&o.test(t.id):!1},Object.defineProperty(s.prototype,"generationTime",{enumerable:!0,get:function(){return Math.floor(n.decodeInt(this.id.substring(0,4),32,!0,!0))},set:function(t){var t=n.encodeInt(t,32,!0,!0);this.id=t+this.id.substr(4),this.toHexString()}}),e.exports=s,e.exports.ObjectID=s,e.exports.ObjectId=s}).call(this,t("g5I+bs"))},{"./binary_parser":54,"g5I+bs":94}],65:[function(t,e,r){(function(r){"use strict";function n(t,e,n,v,m){switch(e&&e.toBSON&&(e=e.toBSON()),typeof e){case"string":return 1+r.byteLength(t,"utf8")+1+4+r.byteLength(e,"utf8")+1;case"number":return Math.floor(e)===e&&e>=g.JS_INT_MIN&&e<=g.JS_INT_MAX&&e>=g.BSON_INT32_MIN&&e<=g.BSON_INT32_MAX?(null!=t?r.byteLength(t,"utf8")+1:0)+5:(null!=t?r.byteLength(t,"utf8")+1:0)+9;case"undefined":return v||!m?(null!=t?r.byteLength(t,"utf8")+1:0)+1:0;case"boolean":return(null!=t?r.byteLength(t,"utf8")+1:0)+2;case"object":if(null==e||e instanceof l||e instanceof h||"MinKey"==e._bsontype||"MaxKey"==e._bsontype)return(null!=t?r.byteLength(t,"utf8")+1:0)+1;if(e instanceof a||"ObjectID"==e._bsontype)return(null!=t?r.byteLength(t,"utf8")+1:0)+13;if(e instanceof Date||_(e))return(null!=t?r.byteLength(t,"utf8")+1:0)+9;if("undefined"!=typeof r&&r.isBuffer(e))return(null!=t?r.byteLength(t,"utf8")+1:0)+6+e.length;if(e instanceof i||e instanceof o||e instanceof s||"Long"==e._bsontype||"Double"==e._bsontype||"Timestamp"==e._bsontype)return(null!=t?r.byteLength(t,"utf8")+1:0)+9;if(e instanceof f||"Code"==e._bsontype)return null!=e.scope&&Object.keys(e.scope).length>0?(null!=t?r.byteLength(t,"utf8")+1:0)+1+4+4+r.byteLength(e.code.toString(),"utf8")+1+y(e.scope,n,m):(null!=t?r.byteLength(t,"utf8")+1:0)+1+4+r.byteLength(e.code.toString(),"utf8")+1;if(e instanceof d||"Binary"==e._bsontype)return e.sub_type==d.SUBTYPE_BYTE_ARRAY?(null!=t?r.byteLength(t,"utf8")+1:0)+(e.position+1+4+1+4):(null!=t?r.byteLength(t,"utf8")+1:0)+(e.position+1+4+1);if(e instanceof u||"Symbol"==e._bsontype)return(null!=t?r.byteLength(t,"utf8")+1:0)+r.byteLength(e.value,"utf8")+4+1+1;if(e instanceof p||"DBRef"==e._bsontype){var b={$ref:e.namespace,$id:e.oid};return null!=e.db&&(b.$db=e.db),(null!=t?r.byteLength(t,"utf8")+1:0)+1+y(b,n,m)}return e instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(e)?(null!=t?r.byteLength(t,"utf8")+1:0)+1+r.byteLength(e.source,"utf8")+1+(e.global?1:0)+(e.ignoreCase?1:0)+(e.multiline?1:0)+1:e instanceof c||"BSONRegExp"==e._bsontype?(null!=t?r.byteLength(t,"utf8")+1:0)+1+r.byteLength(e.pattern,"utf8")+1+r.byteLength(e.options,"utf8")+1:(null!=t?r.byteLength(t,"utf8")+1:0)+y(e,n,m)+1;case"function":if(e instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(e)||"[object RegExp]"==String.call(e))return(null!=t?r.byteLength(t,"utf8")+1:0)+1+r.byteLength(e.source,"utf8")+1+(e.global?1:0)+(e.ignoreCase?1:0)+(e.multiline?1:0)+1;if(n&&null!=e.scope&&Object.keys(e.scope).length>0)return(null!=t?r.byteLength(t,"utf8")+1:0)+1+4+4+r.byteLength(e.toString(),"utf8")+1+y(e.scope,n,m);if(n)return(null!=t?r.byteLength(t,"utf8")+1:0)+1+4+r.byteLength(e.toString(),"utf8")+1}return 0}var i=(t("../float_parser").writeIEEE754,t("../float_parser").readIEEE754,t("../long").Long),o=t("../double").Double,s=t("../timestamp").Timestamp,a=t("../objectid").ObjectID,u=t("../symbol").Symbol,c=t("../regexp").BSONRegExp,f=t("../code").Code,l=t("../min_key").MinKey,h=t("../max_key").MaxKey,p=t("../db_ref").DBRef,d=t("../binary").Binary,_=function(t){return"object"==typeof t&&"[object Date]"===Object.prototype.toString.call(t)},y=function(t,e,r){var i=5;if(Array.isArray(t))for(var o=0;o<t.length;o++)i+=n(o.toString(),t[o],e,!0,r);else{t.toBSON&&(t=t.toBSON());for(var s in t)i+=n(s,t[s],e,!1,r)}return i},g={};g.functionCache={};g.BSON_DATA_NUMBER=1,g.BSON_DATA_STRING=2,g.BSON_DATA_OBJECT=3,g.BSON_DATA_ARRAY=4,g.BSON_DATA_BINARY=5,g.BSON_DATA_OID=7,g.BSON_DATA_BOOLEAN=8,g.BSON_DATA_DATE=9,g.BSON_DATA_NULL=10,g.BSON_DATA_REGEXP=11,g.BSON_DATA_CODE=13,g.BSON_DATA_SYMBOL=14,g.BSON_DATA_CODE_W_SCOPE=15,g.BSON_DATA_INT=16,g.BSON_DATA_TIMESTAMP=17,g.BSON_DATA_LONG=18,g.BSON_DATA_MIN_KEY=255,g.BSON_DATA_MAX_KEY=127,g.BSON_BINARY_SUBTYPE_DEFAULT=0,g.BSON_BINARY_SUBTYPE_FUNCTION=1,g.BSON_BINARY_SUBTYPE_BYTE_ARRAY=2,g.BSON_BINARY_SUBTYPE_UUID=3,g.BSON_BINARY_SUBTYPE_MD5=4,g.BSON_BINARY_SUBTYPE_USER_DEFINED=128,g.BSON_INT32_MAX=2147483647,g.BSON_INT32_MIN=-2147483648,g.BSON_INT64_MAX=Math.pow(2,63)-1,g.BSON_INT64_MIN=-Math.pow(2,63),g.JS_INT_MAX=9007199254740992,g.JS_INT_MIN=-9007199254740992;i.fromNumber(9007199254740992),i.fromNumber(-9007199254740992);e.exports=y}).call(this,t("buffer").Buffer)},{"../binary":53,"../code":56,"../db_ref":57,"../double":58,"../float_parser":59,"../long":60,"../max_key":62,"../min_key":63,"../objectid":64,"../regexp":68,"../symbol":69,"../timestamp":70,buffer:71}],66:[function(require,module,exports){"use strict";var readIEEE754=require("../float_parser").readIEEE754,f=require("util").format,Long=require("../long").Long,Double=require("../double").Double,Timestamp=require("../timestamp").Timestamp,ObjectID=require("../objectid").ObjectID,Symbol=require("../symbol").Symbol,Code=require("../code").Code,MinKey=require("../min_key").MinKey,MaxKey=require("../max_key").MaxKey,DBRef=require("../db_ref").DBRef,BSONRegExp=require("../regexp").BSONRegExp,Binary=require("../binary").Binary,deserialize=function(t,e,r){e=null==e?{}:e;var n=e&&e.index?e.index:0,i=t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24;if(5>i||t.length<i)throw new Error("corrupt bson message");if(0!=t[n+i-1])throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return deserializeObject(t,n,e,r)},deserializeObject=function(t,e,r,n){var i=null==r.evalFunctions?!1:r.evalFunctions,o=null==r.cacheFunctions?!1:r.cacheFunctions,s=null==r.cacheFunctionsCrc32?!1:r.cacheFunctionsCrc32,a=null==r.promoteLongs?!0:r.promoteLongs,u=null==r.fieldsAsRaw?null:r.fieldsAsRaw,c=null==r.raw?!1:r.raw,f="boolean"==typeof r.bsonRegExp?r.bsonRegExp:!1,l=null==r.promoteBuffers?!1:r.promoteBuffers;if(t.length<5)throw new Error("corrupt bson message < 5 bytes long");var h=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;if(5>h||h>t.length)throw new Error("corrupt bson message");for(var p=n?[]:{};;){var d=t[e++];if(0==d)break;for(var _=e;0!==t[_]&&_<t.length;)_++;if(_>=t.length)throw new Error("Bad BSON Document: illegal CString");var y=t.toString("utf8",e,_);if(e=_+1,d==BSON.BSON_DATA_STRING){var g=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;if(0>=g||g>t.length-e||0!=t[e+g-1])throw new Error("bad string length in bson");p[y]=t.toString("utf8",e,e+g-1),e+=g}else if(d==BSON.BSON_DATA_OID){var v=t.toString("binary",e,e+12);p[y]=new ObjectID(v),e+=12}else if(d==BSON.BSON_DATA_INT)p[y]=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;else if(d==BSON.BSON_DATA_NUMBER)p[y]=t.readDoubleLE(e),e+=8;else if(d==BSON.BSON_DATA_DATE){var m=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,b=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;p[y]=new Date(new Long(m,b).toNumber())}else if(d==BSON.BSON_DATA_BOOLEAN)p[y]=1==t[e++];else if(d==BSON.BSON_DATA_OBJECT){var w=e,E=t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24;if(0>=E||E>t.length-e)throw new Error("bad embedded document length in bson");c?p[y]=t.slice(e,e+E):p[y]=deserializeObject(t,w,r,!1),e+=E}else if(d==BSON.BSON_DATA_ARRAY){var w=e,E=t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24,O=r;if(u&&u[y]){O={};for(var A in r)O[A]=r[A];O.raw=!0}p[y]=deserializeObject(t,w,O,!0),e+=E}else if(d==BSON.BSON_DATA_UNDEFINED||d==BSON.BSON_DATA_NULL)p[y]=null;else if(d==BSON.BSON_DATA_LONG){var m=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,b=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,S=new Long(m,b);a?p[y]=S.lessThanOrEqual(JS_INT_MAX_LONG)&&S.greaterThanOrEqual(JS_INT_MIN_LONG)?S.toNumber():S:p[y]=S}else if(d==BSON.BSON_DATA_BINARY){var j=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,N=t[e++];if(null!=t.slice)N==Binary.SUBTYPE_BYTE_ARRAY&&(j=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24),l?p[y]=t.slice(e,e+j):p[y]=new Binary(t.slice(e,e+j),N);else{var x="undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(j)):new Array(j);N==Binary.SUBTYPE_BYTE_ARRAY&&(j=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24);for(var _=0;j>_;_++)x[_]=t[e+_];l?p[y]=x:p[y]=new Binary(x,N)}e+=j}else if(d==BSON.BSON_DATA_REGEXP&&0==f){for(var _=e;0!==t[_]&&_<t.length;)_++;if(_>=t.length)throw new Error("Bad BSON Document: illegal CString");var B=t.toString("utf8",e,_);e=_+1;for(var _=e;0!==t[_]&&_<t.length;)_++;if(_>=t.length)throw new Error("Bad BSON Document: illegal CString");var T=t.toString("utf8",e,_);e=_+1;for(var k=new Array(T.length),_=0;_<T.length;_++)switch(T[_]){case"m":k[_]="m";break;case"s":k[_]="g";break;case"i":k[_]="i"}p[y]=new RegExp(B,k.join(""))}else if(d==BSON.BSON_DATA_REGEXP&&1==f){for(var _=e;0!==t[_]&&_<t.length;)_++;if(_>=t.length)throw new Error("Bad BSON Document: illegal CString");var B=t.toString("utf8",e,_);e=_+1;for(var _=e;0!==t[_]&&_<t.length;)_++;if(_>=t.length)throw new Error("Bad BSON Document: illegal CString");var T=t.toString("utf8",e,_);e=_+1,p[y]=new BSONRegExp(B,T)}else if(d==BSON.BSON_DATA_SYMBOL){var g=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;if(0>=g||g>t.length-e||0!=t[e+g-1])throw new Error("bad string length in bson");p[y]=new Symbol(t.toString("utf8",e,e+g-1)),e+=g}else if(d==BSON.BSON_DATA_TIMESTAMP){var m=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,b=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;p[y]=new Timestamp(m,b)}else if(d==BSON.BSON_DATA_MIN_KEY)p[y]=new MinKey;else if(d==BSON.BSON_DATA_MAX_KEY)p[y]=new MaxKey;else if(d==BSON.BSON_DATA_CODE){var g=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;if(0>=g||g>t.length-e||0!=t[e+g-1])throw new Error("bad string length in bson");var $=t.toString("utf8",e,e+g-1);if(i){if(o){var I=s?crc32($):$;p[y]=isolateEvalWithHash(functionCache,I,$,p)}else p[y]=isolateEval($)}else p[y]=new Code($,{});e+=g}else if(d==BSON.BSON_DATA_CODE_W_SCOPE){var g=(t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24);if(0>=g||g>t.length-e||0!=t[e+g-1])throw new Error("bad string length in bson");var $=t.toString("utf8",e,e+g-1);e+=g;var w=e,E=t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24,D=deserializeObject(t,w,r,!1);if(e+=E,i){if(o){var I=s?crc32($):$;p[y]=isolateEvalWithHash(functionCache,I,$,p)}else p[y]=isolateEval($);p[y].scope=D}else p[y]=new Code($,D)}}return null!=p.$id&&(p=new DBRef(p.$ref,p.$id,p.$db)),p},isolateEvalWithHash=function(functionCache,hash,functionString,object){var value=null;return null==functionCache[hash]&&(eval("value = "+functionString),functionCache[hash]=value),functionCache[hash].bind(object)},isolateEval=function(functionString){var value=null;return eval("value = "+functionString),value},BSON={},functionCache=BSON.functionCache={};BSON.BSON_DATA_NUMBER=1,BSON.BSON_DATA_STRING=2,BSON.BSON_DATA_OBJECT=3,BSON.BSON_DATA_ARRAY=4,BSON.BSON_DATA_BINARY=5,BSON.BSON_DATA_UNDEFINED=7,BSON.BSON_DATA_OID=7,BSON.BSON_DATA_BOOLEAN=8,BSON.BSON_DATA_DATE=9,BSON.BSON_DATA_NULL=10,BSON.BSON_DATA_REGEXP=11,BSON.BSON_DATA_CODE=13,BSON.BSON_DATA_SYMBOL=14,BSON.BSON_DATA_CODE_W_SCOPE=15,BSON.BSON_DATA_INT=16,BSON.BSON_DATA_TIMESTAMP=17,BSON.BSON_DATA_LONG=18,BSON.BSON_DATA_MIN_KEY=255,BSON.BSON_DATA_MAX_KEY=127,BSON.BSON_BINARY_SUBTYPE_DEFAULT=0,BSON.BSON_BINARY_SUBTYPE_FUNCTION=1,BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY=2,BSON.BSON_BINARY_SUBTYPE_UUID=3,BSON.BSON_BINARY_SUBTYPE_MD5=4,BSON.BSON_BINARY_SUBTYPE_USER_DEFINED=128,BSON.BSON_INT32_MAX=2147483647,BSON.BSON_INT32_MIN=-2147483648,BSON.BSON_INT64_MAX=Math.pow(2,63)-1,BSON.BSON_INT64_MIN=-Math.pow(2,63),BSON.JS_INT_MAX=9007199254740992,BSON.JS_INT_MIN=-9007199254740992;var JS_INT_MAX_LONG=Long.fromNumber(9007199254740992),JS_INT_MIN_LONG=Long.fromNumber(-9007199254740992);module.exports=deserialize},{"../binary":53,"../code":56,"../db_ref":57,"../double":58,"../float_parser":59,"../long":60,"../max_key":62,"../min_key":63,"../objectid":64,"../regexp":68,"../symbol":69,"../timestamp":70,util:98}],67:[function(t,e,r){(function(r){"use strict";var n=t("../float_parser").writeIEEE754,i=(t("../float_parser").readIEEE754,t("../long").Long),o=t("../map"),s=(t("../double").Double,t("../timestamp").Timestamp,t("../objectid").ObjectID,t("../symbol").Symbol,t("../code").Code,t("../regexp").BSONRegExp,t("../min_key").MinKey),a=(t("../max_key").MaxKey,t("../db_ref").DBRef,t("../binary").Binary),u=/\x00/,c=function(t){return"object"==typeof t&&"[object Date]"===Object.prototype.toString.call(t)},f=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},l=function(t,e,r,n){t[n++]=T.BSON_DATA_STRING;var i=t.write(e,n,"utf8");n=n+i+1,t[n-1]=0;var o=t.write(r,n+4,"utf8");return t[n+3]=o+1>>24&255,t[n+2]=o+1>>16&255,t[n+1]=o+1>>8&255,t[n]=o+1&255,n=n+4+o,t[n++]=0,n},h=function(t,e,r,o){if(Math.floor(r)===r&&r>=T.JS_INT_MIN&&r<=T.JS_INT_MAX)if(r>=T.BSON_INT32_MIN&&r<=T.BSON_INT32_MAX){t[o++]=T.BSON_DATA_INT;var s=t.write(e,o,"utf8");o+=s,t[o++]=0,t[o++]=255&r,t[o++]=r>>8&255,t[o++]=r>>16&255,t[o++]=r>>24&255}else if(r>=T.JS_INT_MIN&&r<=T.JS_INT_MAX){t[o++]=T.BSON_DATA_NUMBER;var s=t.write(e,o,"utf8");o+=s,t[o++]=0,n(t,r,o,"little",52,8),o+=8}else{t[o++]=T.BSON_DATA_LONG;var s=t.write(e,o,"utf8");o+=s,t[o++]=0;var a=i.fromNumber(r),u=a.getLowBits(),c=a.getHighBits();t[o++]=255&u,t[o++]=u>>8&255,t[o++]=u>>16&255,t[o++]=u>>24&255,t[o++]=255&c,t[o++]=c>>8&255,t[o++]=c>>16&255,t[o++]=c>>24&255}else{t[o++]=T.BSON_DATA_NUMBER;var s=t.write(e,o,"utf8");o+=s,t[o++]=0,n(t,r,o,"little",52,8),o+=8}return o},p=function(t,e,r,n){t[n++]=T.BSON_DATA_NULL;var i=t.write(e,n,"utf8");return n+=i,t[n++]=0,n},d=function(t,e,r,n){t[n++]=T.BSON_DATA_BOOLEAN;var i=t.write(e,n,"utf8");return n+=i,t[n++]=0,t[n++]=r?1:0,n},_=function(t,e,r,n){t[n++]=T.BSON_DATA_DATE;var o=t.write(e,n,"utf8");n+=o,t[n++]=0;var s=i.fromNumber(r.getTime()),a=s.getLowBits(),u=s.getHighBits();return t[n++]=255&a,t[n++]=a>>8&255,t[n++]=a>>16&255,t[n++]=a>>24&255,t[n++]=255&u,t[n++]=u>>8&255,t[n++]=u>>16&255,t[n++]=u>>24&255,n},y=function(t,e,r,n){t[n++]=T.BSON_DATA_REGEXP;var i=t.write(e,n,"utf8");if(n+=i,t[n++]=0,r.source&&null!=r.source.match(u))throw Error("value "+r.source+" must not contain null bytes");return n+=t.write(r.source,n,"utf8"),t[n++]=0,r.global&&(t[n++]=115),r.ignoreCase&&(t[n++]=105),r.multiline&&(t[n++]=109),t[n++]=0,n},g=function(t,e,r,n){t[n++]=T.BSON_DATA_REGEXP;var i=t.write(e,n,"utf8");return n+=i,t[n++]=0,n+=t.write(r.pattern,n,"utf8"),t[n++]=0,n+=t.write(r.options,n,"utf8"),t[n++]=0,n},v=function(t,e,r,n){null===r?t[n++]=T.BSON_DATA_NULL:r instanceof s?t[n++]=T.BSON_DATA_MIN_KEY:t[n++]=T.BSON_DATA_MAX_KEY;var i=t.write(e,n,"utf8");return n+=i,t[n++]=0,n},m=function(t,e,r,n){t[n++]=T.BSON_DATA_OID;var i=t.write(e,n,"utf8");return n+=i,t[n++]=0,t.write(r.id,n,"binary"),n+12},b=function(t,e,r,n){t[n++]=T.BSON_DATA_BINARY;var i=t.write(e,n,"utf8");n+=i,t[n++]=0;var o=r.length;return t[n++]=255&o,t[n++]=o>>8&255,t[n++]=o>>16&255,t[n++]=o>>24&255,t[n++]=T.BSON_BINARY_SUBTYPE_DEFAULT,r.copy(t,n,0,o),n+=o},w=function(t,e,r,n,i,o,s,a){t[n++]=Array.isArray(r)?T.BSON_DATA_ARRAY:T.BSON_DATA_OBJECT;var u=t.write(e,n,"utf8");n+=u,t[n++]=0;var c=B(t,r,i,n,o+1,s,a);return c},E=function(t,e,r,n){t[n++]="Long"==r._bsontype?T.BSON_DATA_LONG:T.BSON_DATA_TIMESTAMP;var i=t.write(e,n,"utf8");n+=i,t[n++]=0;var o=r.getLowBits(),s=r.getHighBits();return t[n++]=255&o,t[n++]=o>>8&255,t[n++]=o>>16&255,t[n++]=o>>24&255,t[n++]=255&s,t[n++]=s>>8&255,t[n++]=s>>16&255,t[n++]=s>>24&255,n},O=function(t,e,r,i){t[i++]=T.BSON_DATA_NUMBER;var o=t.write(e,i,"utf8");return i+=o,t[i++]=0,n(t,r,i,"little",52,8),i+=8},A=function(t,e,r,n,i,o){t[n++]=T.BSON_DATA_CODE;var s=t.write(e,n,"utf8");n+=s,t[n++]=0;var a=r.toString(),u=t.write(a,n+4,"utf8")+1;return t[n]=255&u,t[n+1]=u>>8&255,t[n+2]=u>>16&255,t[n+3]=u>>24&255,n=n+4+u-1,t[n++]=0,n},S=function(t,e,r,n,i,o,s,a){if(null!=r.scope&&Object.keys(r.scope).length>0){t[n++]=T.BSON_DATA_CODE_W_SCOPE;var u=t.write(e,n,"utf8");n+=u,t[n++]=0;var c=n,f="string"==typeof r.code?r.code:r.code.toString();n+=4;var l=t.write(f,n+4,"utf8")+1;t[n]=255&l,t[n+1]=l>>8&255,t[n+2]=l>>16&255,t[n+3]=l>>24&255,t[n+4+l-1]=0,n=n+l+4;var h=B(t,r.scope,i,n,o+1,s,a);n=h-1;var p=h-c;t[c++]=255&p,t[c++]=p>>8&255,t[c++]=p>>16&255,t[c++]=p>>24&255,t[n++]=0}else{t[n++]=T.BSON_DATA_CODE;var u=t.write(e,n,"utf8");n+=u,t[n++]=0;var f=r.code.toString(),d=t.write(f,n+4,"utf8")+1;t[n]=255&d,t[n+1]=d>>8&255,t[n+2]=d>>16&255,t[n+3]=d>>24&255,n=n+4+d-1,t[n++]=0}return n},j=function(t,e,r,n){t[n++]=T.BSON_DATA_BINARY;var i=t.write(e,n,"utf8");n+=i,t[n++]=0;var o=r.value(!0),s=r.position;return t[n++]=255&s,t[n++]=s>>8&255,t[n++]=s>>16&255,t[n++]=s>>24&255,t[n++]=r.sub_type,r.sub_type==a.SUBTYPE_BYTE_ARRAY&&(t[n++]=255&s,t[n++]=s>>8&255,t[n++]=s>>16&255,t[n++]=s>>24&255),o.copy(t,n,0,r.position),n+=r.position},N=function(t,e,r,n){t[n++]=T.BSON_DATA_SYMBOL;var i=t.write(e,n,"utf8");n+=i,t[n++]=0;var o=t.write(r.value,n+4,"utf8")+1;return t[n]=255&o,t[n+1]=o>>8&255,t[n+2]=o>>16&255,t[n+3]=o>>24&255,n=n+4+o-1,t[n++]=0,n},x=function(t,e,r,n,i,o){t[n++]=T.BSON_DATA_OBJECT;var s=t.write(e,n,"utf8");n+=s,t[n++]=0;var a,u=n;a=null!=r.db?B(t,{$ref:r.namespace,$id:r.oid,$db:r.db},!1,n,i+1,o):B(t,{$ref:r.namespace,$id:r.oid},!1,n,i+1,o);var c=a-u;return t[u++]=255&c,t[u++]=c>>8&255,t[u++]=c>>16&255,t[u++]=c>>24&255,a},B=function(t,e,n,i,s,a,B){i=i||0;var T=i+4;if(Array.isArray(e))for(var k=0;k<e.length;k++){var $=""+k,I=e[k];if(I&&I.toBSON){if("function"!=typeof I.toBSON)throw new Error("toBSON is not a function");I=I.toBSON()}var D=typeof I;"string"==D?T=l(t,$,I,T):"number"==D?T=h(t,$,I,T):"boolean"==D?T=d(t,$,I,T):I instanceof Date||c(I)?T=_(t,$,I,T):"undefined"==D||null==I?T=p(t,$,I,T):"ObjectID"==I._bsontype?T=m(t,$,I,T):r.isBuffer(I)?T=b(t,$,I,T):I instanceof RegExp||f(I)?T=y(t,$,I,T):"object"==D&&null==I._bsontype?T=w(t,$,I,T,n,s,a,B):"Long"==I._bsontype||"Timestamp"==I._bsontype?T=E(t,$,I,T):"Double"==I._bsontype?T=O(t,$,I,T):"function"==typeof I&&a?T=A(t,$,I,T,n,s,a):"Code"==I._bsontype?T=S(t,$,I,T,n,s,a,B):"Binary"==I._bsontype?T=j(t,$,I,T):"Symbol"==I._bsontype?T=N(t,$,I,T):"DBRef"==I._bsontype?T=x(t,$,I,T,s,a):"BSONRegExp"==I._bsontype?T=g(t,$,I,T):("MinKey"==I._bsontype||"MaxKey"==I._bsontype)&&(T=v(t,$,I,T))}else if(e instanceof o)for(var P=e.entries(),R=!1;!R;){var C=P.next();if(R=C.done,!R){var $=C.value[0],I=C.value[1],D=typeof I;if("$db"!=$&&"$ref"!=$&&"$id"!=$){if(null!=$.match(u))throw Error("key "+$+" must not contain null bytes");if(n){if("$"==$[0])throw Error("key "+$+" must not start with '$'");if(~$.indexOf("."))throw Error("key "+$+" must not contain '.'")}}"string"==D?T=l(t,$,I,T):"number"==D?T=h(t,$,I,T):"boolean"==D?T=d(t,$,I,T):I instanceof Date||c(I)?T=_(t,$,I,T):void 0===I&&1==B||(null===I||void 0===I?T=p(t,$,I,T):"ObjectID"==I._bsontype?T=m(t,$,I,T):r.isBuffer(I)?T=b(t,$,I,T):I instanceof RegExp||f(I)?T=y(t,$,I,T):"object"==D&&null==I._bsontype?T=w(t,$,I,T,n,s,a,B):"Long"==I._bsontype||"Timestamp"==I._bsontype?T=E(t,$,I,T):"Double"==I._bsontype?T=O(t,$,I,T):"Code"==I._bsontype?T=S(t,$,I,T,n,s,a,B):"function"==typeof I&&a?T=A(t,$,I,T,n,s,a):"Binary"==I._bsontype?T=j(t,$,I,T):"Symbol"==I._bsontype?T=N(t,$,I,T):"DBRef"==I._bsontype?T=x(t,$,I,T,s,a):"BSONRegExp"==I._bsontype?T=g(t,$,I,T):("MinKey"==I._bsontype||"MaxKey"==I._bsontype)&&(T=v(t,$,I,T)))}}else{if(e.toBSON){if("function"!=typeof e.toBSON)throw new Error("toBSON is not a function");if(e=e.toBSON(),null!=e&&"object"!=typeof e)throw new Error("toBSON function did not return an object")}for(var $ in e){var I=e[$];if(I&&I.toBSON){if("function"!=typeof I.toBSON)throw new Error("toBSON is not a function");I=I.toBSON()}var D=typeof I;if("$db"!=$&&"$ref"!=$&&"$id"!=$){if(null!=$.match(u))throw Error("key "+$+" must not contain null bytes");if(n){if("$"==$[0])throw Error("key "+$+" must not start with '$'");if(~$.indexOf("."))throw Error("key "+$+" must not contain '.'")}}"string"==D?T=l(t,$,I,T):"number"==D?T=h(t,$,I,T):"boolean"==D?T=d(t,$,I,T):I instanceof Date||c(I)?T=_(t,$,I,T):void 0===I&&1==B||(null===I||void 0===I?T=p(t,$,I,T):"ObjectID"==I._bsontype?T=m(t,$,I,T):r.isBuffer(I)?T=b(t,$,I,T):I instanceof RegExp||f(I)?T=y(t,$,I,T):"object"==D&&null==I._bsontype?T=w(t,$,I,T,n,s,a,B):"Long"==I._bsontype||"Timestamp"==I._bsontype?T=E(t,$,I,T):"Double"==I._bsontype?T=O(t,$,I,T):"Code"==I._bsontype?T=S(t,$,I,T,n,s,a,B):"function"==typeof I&&a?T=A(t,$,I,T,n,s,a):"Binary"==I._bsontype?T=j(t,$,I,T):"Symbol"==I._bsontype?T=N(t,$,I,T):"DBRef"==I._bsontype?T=x(t,$,I,T,s,a):"BSONRegExp"==I._bsontype?T=g(t,$,I,T):("MinKey"==I._bsontype||"MaxKey"==I._bsontype)&&(T=v(t,$,I,T)))}}t[T++]=0;var M=T-i;return t[i++]=255&M,t[i++]=M>>8&255,t[i++]=M>>16&255,t[i++]=M>>24&255,T},T={};T.functionCache={};T.BSON_DATA_NUMBER=1,T.BSON_DATA_STRING=2,T.BSON_DATA_OBJECT=3,T.BSON_DATA_ARRAY=4,T.BSON_DATA_BINARY=5,T.BSON_DATA_OID=7,T.BSON_DATA_BOOLEAN=8,T.BSON_DATA_DATE=9,T.BSON_DATA_NULL=10,T.BSON_DATA_REGEXP=11,T.BSON_DATA_CODE=13,T.BSON_DATA_SYMBOL=14,T.BSON_DATA_CODE_W_SCOPE=15,T.BSON_DATA_INT=16,T.BSON_DATA_TIMESTAMP=17,T.BSON_DATA_LONG=18,T.BSON_DATA_MIN_KEY=255,T.BSON_DATA_MAX_KEY=127,T.BSON_BINARY_SUBTYPE_DEFAULT=0,T.BSON_BINARY_SUBTYPE_FUNCTION=1,T.BSON_BINARY_SUBTYPE_BYTE_ARRAY=2,T.BSON_BINARY_SUBTYPE_UUID=3,T.BSON_BINARY_SUBTYPE_MD5=4,T.BSON_BINARY_SUBTYPE_USER_DEFINED=128,T.BSON_INT32_MAX=2147483647,T.BSON_INT32_MIN=-2147483648,T.BSON_INT64_MAX=Math.pow(2,63)-1,T.BSON_INT64_MIN=-Math.pow(2,63),T.JS_INT_MAX=9007199254740992,T.JS_INT_MIN=-9007199254740992;i.fromNumber(9007199254740992),i.fromNumber(-9007199254740992);e.exports=B}).call(this,t("buffer").Buffer)},{"../binary":53,"../code":56,"../db_ref":57,"../double":58,"../float_parser":59,"../long":60,"../map":61,"../max_key":62,"../min_key":63,"../objectid":64,"../regexp":68,"../symbol":69,"../timestamp":70,buffer:71}],68:[function(t,e,r){function n(t,e){if(!(this instanceof n))return new n;this._bsontype="BSONRegExp",this.pattern=t,this.options=e;for(var r=0;r<e.length;r++)if("i"!=this.options[r]&&"m"!=this.options[r]&&"x"!=this.options[r]&&"l"!=this.options[r]&&"s"!=this.options[r]&&"u"!=this.options[r])throw new Error("the regular expression options ["+this.options[r]+"] is not supported")}e.exports=n,e.exports.BSONRegExp=n},{}],69:[function(t,e,r){function n(t){return this instanceof n?(this._bsontype="Symbol",void(this.value=t)):new n(t)}n.prototype.valueOf=function(){return this.value},n.prototype.toString=function(){return this.value},n.prototype.inspect=function(){return this.value},n.prototype.toJSON=function(){return this.value},e.exports=n,e.exports.Symbol=n},{}],70:[function(t,e,r){function n(t,e){return this instanceof n?(this._bsontype="Timestamp",this.low_=0|t,void(this.high_=0|e)):new n(t,e)}n.prototype.toInt=function(){return this.low_},n.prototype.toNumber=function(){return this.high_*n.TWO_PWR_32_DBL_+this.getLowBitsUnsigned()},n.prototype.toJSON=function(){return this.toString()},n.prototype.toString=function(t){var e=t||10;if(2>e||e>36)throw Error("radix out of range: "+e);if(this.isZero())return"0";if(this.isNegative()){if(this.equals(n.MIN_VALUE)){var r=n.fromNumber(e),i=this.div(r),o=i.multiply(r).subtract(this);return i.toString(e)+o.toInt().toString(e)}return"-"+this.negate().toString(e)}for(var s=n.fromNumber(Math.pow(e,6)),o=this,a="";;){var u=o.div(s),c=o.subtract(u.multiply(s)).toInt(),f=c.toString(e);if(o=u,o.isZero())return f+a;for(;f.length<6;)f="0"+f;a=""+f+a}},n.prototype.getHighBits=function(){return this.high_},n.prototype.getLowBits=function(){return this.low_},n.prototype.getLowBitsUnsigned=function(){return this.low_>=0?this.low_:n.TWO_PWR_32_DBL_+this.low_},n.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(n.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var t=0!=this.high_?this.high_:this.low_,e=31;e>0&&0==(t&1<<e);e--);return 0!=this.high_?e+33:e+1;
6
+ },n.prototype.isZero=function(){return 0==this.high_&&0==this.low_},n.prototype.isNegative=function(){return this.high_<0},n.prototype.isOdd=function(){return 1==(1&this.low_)},n.prototype.equals=function(t){return this.high_==t.high_&&this.low_==t.low_},n.prototype.notEquals=function(t){return this.high_!=t.high_||this.low_!=t.low_},n.prototype.lessThan=function(t){return this.compare(t)<0},n.prototype.lessThanOrEqual=function(t){return this.compare(t)<=0},n.prototype.greaterThan=function(t){return this.compare(t)>0},n.prototype.greaterThanOrEqual=function(t){return this.compare(t)>=0},n.prototype.compare=function(t){if(this.equals(t))return 0;var e=this.isNegative(),r=t.isNegative();return e&&!r?-1:!e&&r?1:this.subtract(t).isNegative()?-1:1},n.prototype.negate=function(){return this.equals(n.MIN_VALUE)?n.MIN_VALUE:this.not().add(n.ONE)},n.prototype.add=function(t){var e=this.high_>>>16,r=65535&this.high_,i=this.low_>>>16,o=65535&this.low_,s=t.high_>>>16,a=65535&t.high_,u=t.low_>>>16,c=65535&t.low_,f=0,l=0,h=0,p=0;return p+=o+c,h+=p>>>16,p&=65535,h+=i+u,l+=h>>>16,h&=65535,l+=r+a,f+=l>>>16,l&=65535,f+=e+s,f&=65535,n.fromBits(h<<16|p,f<<16|l)},n.prototype.subtract=function(t){return this.add(t.negate())},n.prototype.multiply=function(t){if(this.isZero())return n.ZERO;if(t.isZero())return n.ZERO;if(this.equals(n.MIN_VALUE))return t.isOdd()?n.MIN_VALUE:n.ZERO;if(t.equals(n.MIN_VALUE))return this.isOdd()?n.MIN_VALUE:n.ZERO;if(this.isNegative())return t.isNegative()?this.negate().multiply(t.negate()):this.negate().multiply(t).negate();if(t.isNegative())return this.multiply(t.negate()).negate();if(this.lessThan(n.TWO_PWR_24_)&&t.lessThan(n.TWO_PWR_24_))return n.fromNumber(this.toNumber()*t.toNumber());var e=this.high_>>>16,r=65535&this.high_,i=this.low_>>>16,o=65535&this.low_,s=t.high_>>>16,a=65535&t.high_,u=t.low_>>>16,c=65535&t.low_,f=0,l=0,h=0,p=0;return p+=o*c,h+=p>>>16,p&=65535,h+=i*c,l+=h>>>16,h&=65535,h+=o*u,l+=h>>>16,h&=65535,l+=r*c,f+=l>>>16,l&=65535,l+=i*u,f+=l>>>16,l&=65535,l+=o*a,f+=l>>>16,l&=65535,f+=e*c+r*u+i*a+o*s,f&=65535,n.fromBits(h<<16|p,f<<16|l)},n.prototype.div=function(t){if(t.isZero())throw Error("division by zero");if(this.isZero())return n.ZERO;if(this.equals(n.MIN_VALUE)){if(t.equals(n.ONE)||t.equals(n.NEG_ONE))return n.MIN_VALUE;if(t.equals(n.MIN_VALUE))return n.ONE;var e=this.shiftRight(1),r=e.div(t).shiftLeft(1);if(r.equals(n.ZERO))return t.isNegative()?n.ONE:n.NEG_ONE;var i=this.subtract(t.multiply(r)),o=r.add(i.div(t));return o}if(t.equals(n.MIN_VALUE))return n.ZERO;if(this.isNegative())return t.isNegative()?this.negate().div(t.negate()):this.negate().div(t).negate();if(t.isNegative())return this.div(t.negate()).negate();for(var s=n.ZERO,i=this;i.greaterThanOrEqual(t);){for(var r=Math.max(1,Math.floor(i.toNumber()/t.toNumber())),a=Math.ceil(Math.log(r)/Math.LN2),u=48>=a?1:Math.pow(2,a-48),c=n.fromNumber(r),f=c.multiply(t);f.isNegative()||f.greaterThan(i);)r-=u,c=n.fromNumber(r),f=c.multiply(t);c.isZero()&&(c=n.ONE),s=s.add(c),i=i.subtract(f)}return s},n.prototype.modulo=function(t){return this.subtract(this.div(t).multiply(t))},n.prototype.not=function(){return n.fromBits(~this.low_,~this.high_)},n.prototype.and=function(t){return n.fromBits(this.low_&t.low_,this.high_&t.high_)},n.prototype.or=function(t){return n.fromBits(this.low_|t.low_,this.high_|t.high_)},n.prototype.xor=function(t){return n.fromBits(this.low_^t.low_,this.high_^t.high_)},n.prototype.shiftLeft=function(t){if(t&=63,0==t)return this;var e=this.low_;if(32>t){var r=this.high_;return n.fromBits(e<<t,r<<t|e>>>32-t)}return n.fromBits(0,e<<t-32)},n.prototype.shiftRight=function(t){if(t&=63,0==t)return this;var e=this.high_;if(32>t){var r=this.low_;return n.fromBits(r>>>t|e<<32-t,e>>t)}return n.fromBits(e>>t-32,e>=0?0:-1)},n.prototype.shiftRightUnsigned=function(t){if(t&=63,0==t)return this;var e=this.high_;if(32>t){var r=this.low_;return n.fromBits(r>>>t|e<<32-t,e>>>t)}return 32==t?n.fromBits(e,0):n.fromBits(e>>>t-32,0)},n.fromInt=function(t){if(t>=-128&&128>t){var e=n.INT_CACHE_[t];if(e)return e}var r=new n(0|t,0>t?-1:0);return t>=-128&&128>t&&(n.INT_CACHE_[t]=r),r},n.fromNumber=function(t){return isNaN(t)||!isFinite(t)?n.ZERO:t<=-n.TWO_PWR_63_DBL_?n.MIN_VALUE:t+1>=n.TWO_PWR_63_DBL_?n.MAX_VALUE:0>t?n.fromNumber(-t).negate():new n(t%n.TWO_PWR_32_DBL_|0,t/n.TWO_PWR_32_DBL_|0)},n.fromBits=function(t,e){return new n(t,e)},n.fromString=function(t,e){if(0==t.length)throw Error("number format error: empty string");var r=e||10;if(2>r||r>36)throw Error("radix out of range: "+r);if("-"==t.charAt(0))return n.fromString(t.substring(1),r).negate();if(t.indexOf("-")>=0)throw Error('number format error: interior "-" character: '+t);for(var i=n.fromNumber(Math.pow(r,8)),o=n.ZERO,s=0;s<t.length;s+=8){var a=Math.min(8,t.length-s),u=parseInt(t.substring(s,s+a),r);if(8>a){var c=n.fromNumber(Math.pow(r,a));o=o.multiply(c).add(n.fromNumber(u))}else o=o.multiply(i),o=o.add(n.fromNumber(u))}return o},n.INT_CACHE_={},n.TWO_PWR_16_DBL_=65536,n.TWO_PWR_24_DBL_=1<<24,n.TWO_PWR_32_DBL_=n.TWO_PWR_16_DBL_*n.TWO_PWR_16_DBL_,n.TWO_PWR_31_DBL_=n.TWO_PWR_32_DBL_/2,n.TWO_PWR_48_DBL_=n.TWO_PWR_32_DBL_*n.TWO_PWR_16_DBL_,n.TWO_PWR_64_DBL_=n.TWO_PWR_32_DBL_*n.TWO_PWR_32_DBL_,n.TWO_PWR_63_DBL_=n.TWO_PWR_64_DBL_/2,n.ZERO=n.fromInt(0),n.ONE=n.fromInt(1),n.NEG_ONE=n.fromInt(-1),n.MAX_VALUE=n.fromBits(-1,2147483647),n.MIN_VALUE=n.fromBits(0,-2147483648),n.TWO_PWR_24_=n.fromInt(1<<24),e.exports=n,e.exports.Timestamp=n},{}],71:[function(t,e,r){function n(t,e,r){if(!(this instanceof n))return new n(t,e,r);var i,o=typeof t;if("number"===o)i=t>0?t>>>0:0;else if("string"===o)"base64"===e&&(t=O(t)),i=n.byteLength(t,e);else{if("object"!==o||null===t)throw new TypeError("must start with number, buffer, array or string");"Buffer"===t.type&&P(t.data)&&(t=t.data),i=+t.length>0?Math.floor(+t.length):0}if(this.length>R)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+R.toString(16)+" bytes");var s;n.TYPED_ARRAY_SUPPORT?s=n._augment(new Uint8Array(i)):(s=this,s.length=i,s._isBuffer=!0);var a;if(n.TYPED_ARRAY_SUPPORT&&"number"==typeof t.byteLength)s._set(t);else if(S(t))if(n.isBuffer(t))for(a=0;i>a;a++)s[a]=t.readUInt8(a);else for(a=0;i>a;a++)s[a]=(t[a]%256+256)%256;else if("string"===o)s.write(t,0,e);else if("number"===o&&!n.TYPED_ARRAY_SUPPORT&&!r)for(a=0;i>a;a++)s[a]=0;return s}function i(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=e.length;if(o%2!==0)throw new Error("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;n>s;s++){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");t[r+s]=a}return s}function o(t,e,r,n){var i=k(N(e),t,r,n);return i}function s(t,e,r,n){var i=k(x(e),t,r,n);return i}function a(t,e,r,n){return s(t,e,r,n)}function u(t,e,r,n){var i=k(T(e),t,r,n);return i}function c(t,e,r,n){var i=k(B(e),t,r,n,2);return i}function f(t,e,r){return 0===e&&r===t.length?I.fromByteArray(t):I.fromByteArray(t.slice(e,r))}function l(t,e,r){var n="",i="";r=Math.min(t.length,r);for(var o=e;r>o;o++)t[o]<=127?(n+=$(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return n+$(i)}function h(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n}function p(t,e,r){return h(t,e,r)}function d(t,e,r){var n=t.length;(!e||0>e)&&(e=0),(!r||0>r||r>n)&&(r=n);for(var i="",o=e;r>o;o++)i+=j(t[o]);return i}function _(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function y(t,e,r){if(t%1!==0||0>t)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function g(t,e,r,i,o,s){if(!n.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");if(e>o||s>e)throw new TypeError("value is out of bounds");if(r+i>t.length)throw new TypeError("index out of range")}function v(t,e,r,n){0>e&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);o>i;i++)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function m(t,e,r,n){0>e&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);o>i;i++)t[r+i]=e>>>8*(n?i:3-i)&255}function b(t,e,r,n,i,o){if(e>i||o>e)throw new TypeError("value is out of bounds");if(r+n>t.length)throw new TypeError("index out of range")}function w(t,e,r,n,i){return i||b(t,e,r,4,3.4028234663852886e38,-3.4028234663852886e38),D.write(t,e,r,n,23,4),r+4}function E(t,e,r,n,i){return i||b(t,e,r,8,1.7976931348623157e308,-1.7976931348623157e308),D.write(t,e,r,n,52,8),r+8}function O(t){for(t=A(t).replace(M,"");t.length%4!==0;)t+="=";return t}function A(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function S(t){return P(t)||n.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function j(t){return 16>t?"0"+t.toString(16):t.toString(16)}function N(t){for(var e=[],r=0;r<t.length;r++){var n=t.charCodeAt(r);if(127>=n)e.push(n);else{var i=r;n>=55296&&57343>=n&&r++;for(var o=encodeURIComponent(t.slice(i,r+1)).substr(1).split("%"),s=0;s<o.length;s++)e.push(parseInt(o[s],16))}}return e}function x(t){for(var e=[],r=0;r<t.length;r++)e.push(255&t.charCodeAt(r));return e}function B(t){for(var e,r,n,i=[],o=0;o<t.length;o++)e=t.charCodeAt(o),r=e>>8,n=e%256,i.push(n),i.push(r);return i}function T(t){return I.toByteArray(t)}function k(t,e,r,n,i){i&&(n-=n%i);for(var o=0;n>o&&!(o+r>=e.length||o>=t.length);o++)e[o+r]=t[o];return o}function $(t){try{return decodeURIComponent(t)}catch(t){return String.fromCharCode(65533)}}var I=t("base64-js"),D=t("ieee754"),P=t("is-array");r.Buffer=n,r.SlowBuffer=n,r.INSPECT_MAX_BYTES=50,n.poolSize=8192;var R=1073741823;n.TYPED_ARRAY_SUPPORT=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(t){return!1}}(),n.isBuffer=function(t){return!(null==t||!t._isBuffer)},n.compare=function(t,e){if(!n.isBuffer(t)||!n.isBuffer(e))throw new TypeError("Arguments must be Buffers");for(var r=t.length,i=e.length,o=0,s=Math.min(r,i);s>o&&t[o]===e[o];o++);return o!==s&&(r=t[o],i=e[o]),i>r?-1:r>i?1:0},n.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},n.concat=function(t,e){if(!P(t))throw new TypeError("Usage: Buffer.concat(list[, length])");if(0===t.length)return new n(0);if(1===t.length)return t[0];var r;if(void 0===e)for(e=0,r=0;r<t.length;r++)e+=t[r].length;var i=new n(e),o=0;for(r=0;r<t.length;r++){var s=t[r];s.copy(i,o),o+=s.length}return i},n.byteLength=function(t,e){var r;switch(t+="",e||"utf8"){case"ascii":case"binary":case"raw":r=t.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=2*t.length;break;case"hex":r=t.length>>>1;break;case"utf8":case"utf-8":r=N(t).length;break;case"base64":r=T(t).length;break;default:r=t.length}return r},n.prototype.length=void 0,n.prototype.parent=void 0,n.prototype.toString=function(t,e,r){var n=!1;if(e>>>=0,r=void 0===r||r===1/0?this.length:r>>>0,t||(t="utf8"),0>e&&(e=0),r>this.length&&(r=this.length),e>=r)return"";for(;;)switch(t){case"hex":return d(this,e,r);case"utf8":case"utf-8":return l(this,e,r);case"ascii":return h(this,e,r);case"binary":return p(this,e,r);case"base64":return f(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}},n.prototype.equals=function(t){if(!n.isBuffer(t))throw new TypeError("Argument must be a Buffer");return 0===n.compare(this,t)},n.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,e).match(/.{2}/g).join(" "),this.length>e&&(t+=" ... ")),"<Buffer "+t+">"},n.prototype.compare=function(t){if(!n.isBuffer(t))throw new TypeError("Argument must be a Buffer");return n.compare(this,t)},n.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},n.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},n.prototype.write=function(t,e,r,n){if(isFinite(e))isFinite(r)||(n=r,r=void 0);else{var f=n;n=e,e=r,r=f}e=Number(e)||0;var l=this.length-e;r?(r=Number(r),r>l&&(r=l)):r=l,n=String(n||"utf8").toLowerCase();var h;switch(n){case"hex":h=i(this,t,e,r);break;case"utf8":case"utf-8":h=o(this,t,e,r);break;case"ascii":h=s(this,t,e,r);break;case"binary":h=a(this,t,e,r);break;case"base64":h=u(this,t,e,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":h=c(this,t,e,r);break;default:throw new TypeError("Unknown encoding: "+n)}return h},n.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},n.prototype.slice=function(t,e){var r=this.length;if(t=~~t,e=void 0===e?r:~~e,0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),t>e&&(e=t),n.TYPED_ARRAY_SUPPORT)return n._augment(this.subarray(t,e));for(var i=e-t,o=new n(i,void 0,!0),s=0;i>s;s++)o[s]=this[s+t];return o},n.prototype.readUInt8=function(t,e){return e||y(t,1,this.length),this[t]},n.prototype.readUInt16LE=function(t,e){return e||y(t,2,this.length),this[t]|this[t+1]<<8},n.prototype.readUInt16BE=function(t,e){return e||y(t,2,this.length),this[t]<<8|this[t+1]},n.prototype.readUInt32LE=function(t,e){return e||y(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},n.prototype.readUInt32BE=function(t,e){return e||y(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},n.prototype.readInt8=function(t,e){return e||y(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},n.prototype.readInt16LE=function(t,e){e||y(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt16BE=function(t,e){e||y(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt32LE=function(t,e){return e||y(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},n.prototype.readInt32BE=function(t,e){return e||y(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},n.prototype.readFloatLE=function(t,e){return e||y(t,4,this.length),D.read(this,t,!0,23,4)},n.prototype.readFloatBE=function(t,e){return e||y(t,4,this.length),D.read(this,t,!1,23,4)},n.prototype.readDoubleLE=function(t,e){return e||y(t,8,this.length),D.read(this,t,!0,52,8)},n.prototype.readDoubleBE=function(t,e){return e||y(t,8,this.length),D.read(this,t,!1,52,8)},n.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||g(this,t,e,1,255,0),n.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t,e+1},n.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||g(this,t,e,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8):v(this,t,e,!0),e+2},n.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||g(this,t,e,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t):v(this,t,e,!1),e+2},n.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||g(this,t,e,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t):m(this,t,e,!0),e+4},n.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||g(this,t,e,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t):m(this,t,e,!1),e+4},n.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||g(this,t,e,1,127,-128),n.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),0>t&&(t=255+t+1),this[e]=t,e+1},n.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||g(this,t,e,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8):v(this,t,e,!0),e+2},n.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||g(this,t,e,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t):v(this,t,e,!1),e+2},n.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||g(this,t,e,4,2147483647,-2147483648),n.TYPED_ARRAY_SUPPORT?(this[e]=t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):m(this,t,e,!0),e+4},n.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||g(this,t,e,4,2147483647,-2147483648),0>t&&(t=4294967295+t+1),n.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t):m(this,t,e,!1),e+4},n.prototype.writeFloatLE=function(t,e,r){return w(this,t,e,!0,r)},n.prototype.writeFloatBE=function(t,e,r){return w(this,t,e,!1,r)},n.prototype.writeDoubleLE=function(t,e,r){return E(this,t,e,!0,r)},n.prototype.writeDoubleBE=function(t,e,r){return E(this,t,e,!1,r)},n.prototype.copy=function(t,e,r,i){var o=this;if(r||(r=0),i||0===i||(i=this.length),e||(e=0),i!==r&&0!==t.length&&0!==o.length){if(r>i)throw new TypeError("sourceEnd < sourceStart");if(0>e||e>=t.length)throw new TypeError("targetStart out of bounds");if(0>r||r>=o.length)throw new TypeError("sourceStart out of bounds");if(0>i||i>o.length)throw new TypeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);var s=i-r;if(1e3>s||!n.TYPED_ARRAY_SUPPORT)for(var a=0;s>a;a++)t[a+e]=this[a+r];else t._set(this.subarray(r,r+s),e)}},n.prototype.fill=function(t,e,r){if(t||(t=0),e||(e=0),r||(r=this.length),e>r)throw new TypeError("end < start");if(r!==e&&0!==this.length){if(0>e||e>=this.length)throw new TypeError("start out of bounds");if(0>r||r>this.length)throw new TypeError("end out of bounds");var n;if("number"==typeof t)for(n=e;r>n;n++)this[n]=t;else{var i=N(t.toString()),o=i.length;for(n=e;r>n;n++)this[n]=i[n%o]}return this}},n.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(n.TYPED_ARRAY_SUPPORT)return new n(this).buffer;for(var t=new Uint8Array(this.length),e=0,r=t.length;r>e;e+=1)t[e]=this[e];return t.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var C=n.prototype;n._augment=function(t){return t.constructor=n,t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=C.get,t.set=C.set,t.write=C.write,t.toString=C.toString,t.toLocaleString=C.toString,t.toJSON=C.toJSON,t.equals=C.equals,t.compare=C.compare,t.copy=C.copy,t.slice=C.slice,t.readUInt8=C.readUInt8,t.readUInt16LE=C.readUInt16LE,t.readUInt16BE=C.readUInt16BE,t.readUInt32LE=C.readUInt32LE,t.readUInt32BE=C.readUInt32BE,t.readInt8=C.readInt8,t.readInt16LE=C.readInt16LE,t.readInt16BE=C.readInt16BE,t.readInt32LE=C.readInt32LE,t.readInt32BE=C.readInt32BE,t.readFloatLE=C.readFloatLE,t.readFloatBE=C.readFloatBE,t.readDoubleLE=C.readDoubleLE,t.readDoubleBE=C.readDoubleBE,t.writeUInt8=C.writeUInt8,t.writeUInt16LE=C.writeUInt16LE,t.writeUInt16BE=C.writeUInt16BE,t.writeUInt32LE=C.writeUInt32LE,t.writeUInt32BE=C.writeUInt32BE,t.writeInt8=C.writeInt8,t.writeInt16LE=C.writeInt16LE,t.writeInt16BE=C.writeInt16BE,t.writeInt32LE=C.writeInt32LE,t.writeInt32BE=C.writeInt32BE,t.writeFloatLE=C.writeFloatLE,t.writeFloatBE=C.writeFloatBE,t.writeDoubleLE=C.writeDoubleLE,t.writeDoubleBE=C.writeDoubleBE,t.fill=C.fill,t.inspect=C.inspect,t.toArrayBuffer=C.toArrayBuffer,t};var M=/[^+\/0-9A-z]/g},{"base64-js":52,ieee754:76,"is-array":78}],72:[function(t,e,r){function n(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function i(){var t=arguments,e=this.useColors;if(t[0]=(e?"%c":"")+this.namespace+(e?" %c":" ")+t[0]+(e?"%c ":" ")+"+"+r.humanize(this.diff),!e)return t;var n="color: "+this.color;t=[t[0],n,"color: inherit"].concat(Array.prototype.slice.call(t,1));var i=0,o=0;return t[0].replace(/%[a-z%]/g,function(t){"%%"!==t&&(i++,"%c"===t&&(o=i))}),t.splice(o,0,n),t}function o(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(t){try{null==t?r.storage.removeItem("debug"):r.storage.debug=t}catch(t){}}function a(){var t;try{t=r.storage.debug}catch(t){}return t}function u(){try{return window.localStorage}catch(t){}}r=e.exports=t("./debug"),r.log=o,r.formatArgs=i,r.save=s,r.load=a,r.useColors=n,r.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:u(),r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],r.formatters.j=function(t){return JSON.stringify(t)},r.enable(a())},{"./debug":73}],73:[function(t,e,r){function n(){return r.colors[f++%r.colors.length]}function i(t){function e(){}function i(){var t=i,e=+new Date,o=e-(c||e);t.diff=o,t.prev=c,t.curr=e,c=e,null==t.useColors&&(t.useColors=r.useColors()),null==t.color&&t.useColors&&(t.color=n());var s=Array.prototype.slice.call(arguments);s[0]=r.coerce(s[0]),"string"!=typeof s[0]&&(s=["%o"].concat(s));var a=0;s[0]=s[0].replace(/%([a-z%])/g,function(e,n){if("%%"===e)return e;a++;var i=r.formatters[n];if("function"==typeof i){var o=s[a];e=i.call(t,o),s.splice(a,1),a--}return e}),"function"==typeof r.formatArgs&&(s=r.formatArgs.apply(t,s));var u=i.log||r.log||console.log.bind(console);u.apply(t,s)}e.enabled=!1,i.enabled=!0;var o=r.enabled(t)?i:e;return o.namespace=t,o}function o(t){r.save(t);for(var e=(t||"").split(/[\s,]+/),n=e.length,i=0;n>i;i++)e[i]&&(t=e[i].replace(/\*/g,".*?"),"-"===t[0]?r.skips.push(new RegExp("^"+t.substr(1)+"$")):r.names.push(new RegExp("^"+t+"$")))}function s(){r.enable("")}function a(t){var e,n;for(e=0,n=r.skips.length;n>e;e++)if(r.skips[e].test(t))return!1;for(e=0,n=r.names.length;n>e;e++)if(r.names[e].test(t))return!0;return!1}function u(t){return t instanceof Error?t.stack||t.message:t}r=e.exports=i,r.coerce=u,r.disable=s,r.enable=o,r.enabled=a,r.humanize=t("ms"),r.names=[],r.skips=[],r.formatters={};var c,f=0},{ms:93}],74:[function(t,e,r){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(t){return"function"==typeof t}function o(t){return"number"==typeof t}function s(t){return"object"==typeof t&&null!==t}function a(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if(!o(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,r,n,o,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||s(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(r=this._events[t],a(r))return!1;if(i(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:for(n=arguments.length,o=new Array(n-1),u=1;n>u;u++)o[u-1]=arguments[u];r.apply(this,o)}else if(s(r)){for(n=arguments.length,o=new Array(n-1),u=1;n>u;u++)o[u-1]=arguments[u];for(c=r.slice(),n=c.length,u=0;n>u;u++)c[u].apply(this,o)}return!0},n.prototype.addListener=function(t,e){var r;if(!i(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,i(e.listener)?e.listener:e),this._events[t]?s(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,s(this._events[t])&&!this._events[t].warned){var r;r=a(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function r(){this.removeListener(t,r),n||(n=!0,e.apply(this,arguments))}if(!i(e))throw TypeError("listener must be a function");var n=!1;return r.listener=e,this.on(t,r),this},n.prototype.removeListener=function(t,e){var r,n,o,a;if(!i(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],o=r.length,n=-1,r===e||i(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(s(r)){for(a=o;a-- >0;)if(r[a]===e||r[a].listener&&r[a].listener===e){n=a;break}if(0>n)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],i(r))this.removeListener(t,r);else for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?i(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.listenerCount=function(t,e){var r;return r=t._events&&t._events[e]?i(t._events[e])?1:t._events[e].length:0}},{}],75:[function(t,e,r){function n(t,e){return function r(){if(!r.hookCalled){r.hookCalled=!0;var n=t.apply(e,arguments);n&&n.then&&n.then(function(){},function(){})}}}e.exports={hook:function(t,e,r){if(1!==arguments.length||"object"!=typeof t){var i=this.prototype||this,o=i._pres=i._pres||{},s=i._posts=i._posts||{};return o[t]=o[t]||[],s[t]=s[t]||[],i[t]=function(){var o,s=this,a=arguments[arguments.length-1],u=this._pres[t],c=this._posts[t],f=u.length,l=-1,h=i[t].numAsyncPres,p=function(t){return t?d(t):void(--h||y.apply(s,o))},d=function(t){if("function"==typeof a)return a(t);if(r)return r.call(s,t);throw t},_=function(){if(arguments[0]instanceof Error)return d(arguments[0]);var t,e,r=Array.prototype.slice.call(arguments);if(!r.length||null==arguments[0]&&"function"==typeof a||(o=r),++l<f){if(t=u[l],t.isAsync&&t.length<2)throw new Error("Your pre must have next and done arguments -- e.g., function (next, done, ...)");if(t.length<1)throw new Error("Your pre must have a next argument -- e.g., function (next, ...)");return e=(t.isAsync?[n(_),n(p)]:[n(_)]).concat(o),t.apply(s,e)}return h?void 0:y.apply(s,o)},y=function(){var t,r,i,u,h=Array.prototype.slice.call(arguments);return l===f?(u=function(){if(arguments[0]instanceof Error)return d(arguments[0]);var t,e,f=Array.prototype.slice.call(arguments,1);if(f.length&&(o=f),++i<r){if(t=c[i],t.length<1)throw new Error("Your post must have a next argument -- e.g., function (next, ...)");return e=[n(u)].concat(o),t.apply(s,e)}return"function"==typeof a?a.apply(s,arguments):void 0},"function"==typeof a&&(h[h.length-1]=n(u)),r=c.length,i=-1,t=e.apply(s,h),r&&"function"!=typeof a?u():t):void 0};return _.apply(this,arguments)},i[t].numAsyncPres=0,this}for(var a in t)this.hook(a,t[a])},pre:function(t,e,r,n){"boolean"!=typeof arguments[1]&&(n=r,r=e,e=!1);var i=this.prototype||this,o=i._pres=i._pres||{};return this._lazySetupHooks(i,t,n),(r.isAsync=e)&&i[t].numAsyncPres++,(o[t]=o[t]||[]).push(r),this},post:function(t,e,r){2===arguments.length&&(r=e,e=!1);var n=this.prototype||this,i=n._posts=n._posts||{};return this._lazySetupHooks(n,t),(i[t]=i[t]||[]).push(r),this},removePre:function(t,e){var r=this.prototype||this,n=r._pres||r._pres||{};return n[t]?(1===arguments.length?n[t].length=0:n[t]=n[t].filter(function(t){return t!==e}),this):this},removePost:function(t,e){var r=this.prototype||this,n=r._posts||r._posts||{};return n[t]?(1===arguments.length?n[t].length=0:n[t]=n[t].filter(function(t){return t!==e}),this):this},_lazySetupHooks:function(t,e,r){"undefined"==typeof t[e].numAsyncPres&&this.hook(e,t[e],r)}}},{}],76:[function(t,e,r){r.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,f=-7,l=r?i-1:0,h=r?-1:1,p=t[e+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+t[e+l],l+=h,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=n;f>0;s=256*s+t[e+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:(p?-1:1)*(1/0);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},r.write=function(t,e,r,n,i,o){var s,a,u,c=8*o-i-1,f=(1<<c)-1,l=f>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,_=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),e+=s+l>=1?h/u:h*Math.pow(2,1-l),e*u>=2&&(s++,u/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(e*u-1)*Math.pow(2,i),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;t[r+p]=255&s,p+=d,s/=256,c-=8);t[r+p-d]|=128*_}},{}],77:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],78:[function(t,e,r){var n=Array.isArray,i=Object.prototype.toString;e.exports=n||function(t){return!!t&&"[object Array]"==i.call(t)}},{}],79:[function(t,e,r){(function(t){"use strict";function r(){this._pres={},this._posts={}}r.prototype.execPre=function(e,r,n){var i=this._pres[e]||[],o=i.length,s=i.numAsync||0,a=0,u=s,c=!1;if(!o)return t.nextTick(function(){n(null)});var f=function(){if(!(a>=o)){var e=i[a];if(e.isAsync)e.fn.call(r,function(t){if(t){if(c)return;return c=!0,n(t)}++a,f.apply(r,arguments)},function(t){if(t){if(c)return;return c=!0,n(t)}return 0===--s?n(null):void 0});else if(e.fn.length>0){var l=[function(t){if(t){if(c)return;return c=!0,n(t)}return++a>=o?u>0?void 0:n(null):void f.apply(r,arguments)}];if(arguments.length>=2)for(var h=1;h<arguments.length;++h)l.push(arguments[h]);e.fn.apply(r,l)}else{if(e.fn.call(r),++a>=o)return u>0?void 0:t.nextTick(function(){n(null)});f()}}};f()},r.prototype.execPost=function(e,r,n,i){var o=this._posts[e]||[],s=o.length,a=0;if(!s)return t.nextTick(function(){i.apply(null,[null].concat(n))});var u=function(){var t=o[a];if(t.length>n.length)t.apply(r,n.concat(function(t){return t?i(t):++a>=s?i.apply(null,[null].concat(n)):void u()}));else{if(t.apply(r,n),++a>=s)return i.apply(null,[null].concat(n));u()}};u()},r.prototype.wrap=function(t,e,r,n,i){var o=n.length>0?n[n.length-1]:null,s=this;this.execPre(t,r,function(a){if(a){if("function"==typeof o)return o(a)}else{var u="function"==typeof o?n.length-1:n.length;e.apply(r,n.slice(0,u).concat(function(){if(arguments[0])return"function"==typeof o?o(arguments[0]):void 0;i&&"function"==typeof o&&o.apply(r,arguments);var e=Array.prototype.slice.call(arguments,1);s.execPost(t,r,e,function(){return arguments[0]?"function"==typeof o?o(arguments[0]):void 0:"function"!=typeof o||i?void 0:o.apply(r,arguments)})}))}})},r.prototype.createWrapper=function(t,e,r){var n=this;return function(){var i=Array.prototype.slice.call(arguments);n.wrap(t,e,r,i)}},r.prototype.pre=function(t,e,r,n){"boolean"!=typeof arguments[1]&&(n=r,r=e,e=!1),this._pres[t]=this._pres[t]||[];var i=this._pres[t];return e&&(i.numAsync=i.numAsync||0,++i.numAsync),i.push({fn:r,isAsync:e}),this},r.prototype.post=function(t,e){return(this._posts[t]=this._posts[t]||[]).push(e),this},r.prototype.clone=function(){var t=new r;for(var e in this._pres)t._pres[e]=this._pres[e].slice();for(var e in this._posts)t._posts[e]=this._posts[e].slice();return t},e.exports=r}).call(this,t("g5I+bs"))},{"g5I+bs":94}],80:[function(t,e,r){e.exports=r=t("./lib")},{"./lib":81}],81:[function(t,e,r){function n(t){return t}r.get=function(t,e,i,o){var s;"function"==typeof i&&(i.length<2?(o=i,i=void 0):(s=i,i=void 0)),o||(o=n);var a="string"==typeof t?t.split("."):t;if(!Array.isArray(a))throw new TypeError("Invalid `path`. Must be either string or array");for(var u,c=e,f=0;f<a.length;++f){if(u=a[f],Array.isArray(c)&&!/^\d+$/.test(u)){var l=a.slice(f);return c.map(function(t){return t?r.get(l,t,i||s,o):o(void 0);
7
+ })}if(c=s?s(c,u):i&&c[i]?c[i][u]:c[u],!c)return o(c)}return o(c)},r.set=function(t,e,i,o,s,a){var u;"function"==typeof o&&(o.length<2?(s=o,o=void 0):(u=o,o=void 0)),s||(s=n);var c="string"==typeof t?t.split("."):t;if(!Array.isArray(c))throw new TypeError("Invalid `path`. Must be either string or array");if(null!=i){for(var f,l=a||/\$/.test(t),h=i,p=0,d=c.length-1;d>p;++p)if(f=c[p],"$"!=f){if(Array.isArray(h)&&!/^\d+$/.test(f)){var _=c.slice(p);if(!l&&Array.isArray(e))for(var y=0;y<h.length&&y<e.length;++y)r.set(_,e[y],h[y],o||u,s,l);else for(var y=0;y<h.length;++y)r.set(_,e,h[y],o||u,s,l);return}if(h=u?u(h,f):o&&h[o]?h[o][f]:h[f],!h)return}else if(p==d-1)break;if(f=c[d],o&&h[o]&&(h=h[o]),Array.isArray(h)&&!/^\d+$/.test(f))if(!l&&Array.isArray(e))for(var g,y=0;y<h.length&&y<e.length;++y)g=h[y],g&&(u?u(g,f,s(e[y])):(g[o]&&(g=g[o]),g[f]=s(e[y])));else for(var y=0;y<h.length;++y)g=h[y],g&&(u?u(g,f,s(e)):(g[o]&&(g=g[o]),g[f]=s(e)));else u?u(h,f,s(e)):h[f]=s(e)}}},{}],82:[function(t,e,r){(function(r){"use strict";function n(t,e,r){return Array.prototype.slice.call(t,e,r)}function i(t,e){var r=n(e);return r.unshift(t),r}function o(t){this.emitter=new u,this.emitted={},this.ended=!1,"function"==typeof t&&(this.ended=!0,this.onResolve(t))}function s(t,e){function n(){var n=t.emitter.domain;n&&n!==r.domain&&n.enter();try{var o=e.apply(void 0,i.args)}catch(e){return void t.reject(e)}a(t,o)}function i(){i.args=arguments,r.nextTick(n)}return i}function a(t,e){function r(){f++||a.apply(void 0,i(t,arguments))}function o(e){f++||t.reject(e)}if(t===e)return void t.reject(new TypeError("promise and x are the same"));var s=n(arguments,1),u=typeof e;if("undefined"==u||null==e||"object"!=u&&"function"!=u)return void t.fulfill.apply(t,s);try{var c=e.then}catch(e){return void t.reject(e)}if("function"!=typeof c)return void t.fulfill.apply(t,s);var f=0;try{var l=c.call(e,r,o);return l}catch(e){if(f++)return;t.reject(e)}}var u=(t("util"),t("events").EventEmitter);e.exports=o,o.SUCCESS="fulfill",o.FAILURE="reject",o.prototype.on=function(t,e){return this.emitted[t]?e.apply(void 0,this.emitted[t]):this.emitter.on(t,e),this},o.prototype.safeEmit=function(t){if(t==o.SUCCESS||t==o.FAILURE){if(this.emitted[o.SUCCESS]||this.emitted[o.FAILURE])return this;this.emitted[t]=n(arguments,1)}return this.emitter.emit.apply(this.emitter,arguments),this},o.prototype.hasRejectListeners=function(){return u.listenerCount(this.emitter,o.FAILURE)>0},o.prototype.fulfill=function(){return this.safeEmit.apply(this,i(o.SUCCESS,arguments))},o.prototype.reject=function(t){if(this.ended&&!this.hasRejectListeners())throw t;return this.safeEmit(o.FAILURE,t)},o.prototype.resolve=function(t,e){return t?this.reject(t):this.fulfill(e)},o.prototype.onFulfill=function(t){if(!t)return this;if("function"!=typeof t)throw new TypeError("fn should be a function");return this.on(o.SUCCESS,t)},o.prototype.onReject=function(t){if(!t)return this;if("function"!=typeof t)throw new TypeError("fn should be a function");return this.on(o.FAILURE,t)},o.prototype.onResolve=function(t){if(!t)return this;if("function"!=typeof t)throw new TypeError("fn should be a function");return this.on(o.FAILURE,function(e){t.call(this,e)}),this.on(o.SUCCESS,function(){t.apply(this,i(null,arguments))}),this},o.prototype.then=function(t,e){var r=new o;return"function"==typeof t?this.onFulfill(s(r,t)):this.onFulfill(r.fulfill.bind(r)),"function"==typeof e?this.onReject(s(r,e)):this.onReject(r.reject.bind(r)),r},o.prototype.end=o.prototype.catch=function(t){return t||this.hasRejectListeners()||(t=function(t){throw t}),this.onReject(t),this.ended=!0,this},o.trace=function(t,e){t.then(function(){console.log("%s fulfill %j",e,n(arguments))},function(){console.log("%s reject %j",e,n(arguments))})},o.prototype.chain=function(t){var e=this;return e.onFulfill(t.fulfill.bind(t)),e.onReject(t.reject.bind(t)),t},o.prototype.all=function(t){var e=new o;return this.then(t).then(function(t){var r,n=0,i=[];return t.length||e.resolve(),t.forEach(function(t,o){r||(n++,t.then(function(t){r||(i[o]=t,--n,0==n&&e.fulfill(i))},function(t){r||(r=t,e.reject(t))}))}),e},e.reject.bind(e)),e},o.hook=function(t){var e=new o,r=new o,n=function(){return--i,0==i&&r.fulfill(),r},i=1,s=e;return t.forEach(function(t){s=s.then(function(){var e=new o;return i++,t(e.resolve.bind(e),n),e})}),s=s.then(n),e.resolve(),s},o.fulfilled=function(){var t=new o;return t.fulfill.apply(t,arguments),t},o.rejected=function(t){return(new o).reject(t)},o.deferred=function(){var t=new o;return{promise:t,reject:t.reject.bind(t),resolve:t.fulfill.bind(t),callback:t.resolve.bind(t)}}}).call(this,t("g5I+bs"))},{events:74,"g5I+bs":94,util:98}],83:[function(t,e,r){"use strict";function n(){}function i(t){return function(){throw new Error("collection."+t+" not implemented")}}for(var o=["find","findOne","update","remove","count","distinct","findAndModify","aggregate","findStream"],s=0,a=o.length;a>s;++s){var u=o[s];n.prototype[u]=i(u)}e.exports=r=n,n.methods=o},{}],84:[function(t,e,r){"use strict";var n=t("../env");if("unknown"==n.type)throw new Error("Unknown environment");e.exports=t(n.isNode?"./node":n.isMongo?"./collection":"./collection")},{"../env":86,"./collection":83,"./node":85}],85:[function(t,e,r){"use strict";function n(t){this.collection=t,this.collectionName=t.collectionName}var i=t("./collection"),o=t("../utils");o.inherits(n,i),n.prototype.find=function(t,e,r){this.collection.find(t,e,function(t,e){return t?r(t):void e.toArray(r)})},n.prototype.findOne=function(t,e,r){this.collection.findOne(t,e,r)},n.prototype.count=function(t,e,r){this.collection.count(t,e,r)},n.prototype.distinct=function(t,e,r,n){this.collection.distinct(t,e,r,n)},n.prototype.update=function(t,e,r,n){this.collection.update(t,e,r,n)},n.prototype.remove=function(t,e,r){this.collection.remove(t,e,r)},n.prototype.findAndModify=function(t,e,r,n){var i=Array.isArray(r.sort)?r.sort:[];this.collection.findAndModify(t,i,e,r,n)},n.prototype.findStream=function(t,e,r){return this.collection.find(t,e).stream(r)},n.prototype.findCursor=function(t,e){return this.collection.find(t,e)},e.exports=r=n},{"../utils":89,"./collection":83}],86:[function(t,e,r){(function(t,n,i){"use strict";r.isNode="undefined"!=typeof t&&"object"==typeof e&&"object"==typeof n&&"function"==typeof i&&t.argv,r.isMongo=!r.isNode&&"function"==typeof printjson&&"function"==typeof ObjectId&&"function"==typeof rs&&"function"==typeof sh,r.isBrowser=!r.isNode&&!r.isMongo&&"undefined"!=typeof window,r.type=r.isNode?"node":r.isMongo?"mongo":r.isBrowser?"browser":"unknown"}).call(this,t("g5I+bs"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("buffer").Buffer)},{buffer:71,"g5I+bs":94}],87:[function(t,e,r){"use strict";function n(t,e){if(!(this instanceof n))return new n(t,e);var r=this.constructor.prototype;this.op=r.op||void 0,this.options={},this.setOptions(r.options),this._conditions=r._conditions?c.clone(r._conditions):{},this._fields=r._fields?c.clone(r._fields):void 0,this._update=r._update?c.clone(r._update):void 0,this._path=r._path||void 0,this._distinct=r._distinct||void 0,this._collection=r._collection||void 0,this._traceFunction=r._traceFunction||void 0,e&&this.setOptions(e),t&&(t.find&&t.remove&&t.update?this.collection(t):this.find(t))}function i(t,e,r){if(Array.isArray(t.sort))throw new TypeError("Can't mix sort syntaxes. Use either array or object:\n- `.sort([['field', 1], ['test', -1]])`\n- `.sort({ field: 1, test: -1 })`");if(r&&r.$meta){var n=t.sort||(t.sort={});return void(n[e]={$meta:r.$meta})}var i=String(r||1).toLowerCase();if(!/^(?:ascending|asc|descending|desc|1|-1)$/.test(i))throw c.isArray(r)&&(r="["+r+"]"),new TypeError("Invalid sort value: {"+e+": "+r+" }");var n=t.sort||(t.sort={}),o=r.toString().replace("asc","1").replace("ascending","1").replace("desc","-1").replace("descending","-1");n[e]=parseInt(o,10)}function o(t,e,r){if(t.sort=t.sort||[],!Array.isArray(t.sort))throw new TypeError("Can't mix sort syntaxes. Use either array or object:\n- `.sort([['field', 1], ['test', -1]])`\n- `.sort({ field: 1, test: -1 })`");r.toString().replace("asc","1").replace("ascending","1").replace("desc","-1").replace("descending","-1");t.sort.push([e,r])}var s=t("sliced"),a=t("assert"),u=t("util"),c=t("./utils"),f=t("debug")("mquery"),l="$geoWithin";Object.defineProperty(n,"use$geoWithin",{get:function(){return"$geoWithin"==l},set:function(t){l=!0===t?"$geoWithin":"$within"}}),n.prototype.toConstructor=function(){function t(e,r){return this instanceof t?void n.call(this,e,r):new t(e,r)}c.inherits(t,n);var e=t.prototype;return e.options={},e.setOptions(this.options),e.op=this.op,e._conditions=c.clone(this._conditions),e._fields=c.clone(this._fields),e._update=c.clone(this._update),e._path=this._path,e._distinct=this._distinct,e._collection=this._collection,e._traceFunction=this._traceFunction,t},n.prototype.setOptions=function(t){if(!t||!c.isObject(t))return this;for(var e,r=c.keys(t),n=0;n<r.length;++n)if(e=r[n],"function"==typeof this[e]){var i=c.isArray(t[e])?t[e]:[t[e]];this[e].apply(this,i)}else this.options[e]=t[e];return this},n.prototype.collection=function(t){return this._collection=new n.Collection(t),this},n.prototype.$where=function(t){return this._conditions.$where=t,this},n.prototype.where=function(){if(!arguments.length)return this;this.op||(this.op="find");var t=typeof arguments[0];if("string"==t)return this._path=arguments[0],2===arguments.length&&(this._conditions[this._path]=arguments[1]),this;if("object"==t&&!Array.isArray(arguments[0]))return this.merge(arguments[0]);throw new TypeError("path must be a string or object")},n.prototype.equals=function(t){this._ensurePath("equals");var e=this._path;return this._conditions[e]=t,this},n.prototype.eq=function(t){this._ensurePath("eq");var e=this._path;return this._conditions[e]=t,this},n.prototype.or=function t(e){var t=this._conditions.$or||(this._conditions.$or=[]);return c.isArray(e)||(e=[e]),t.push.apply(t,e),this},n.prototype.nor=function t(e){var t=this._conditions.$nor||(this._conditions.$nor=[]);return c.isArray(e)||(e=[e]),t.push.apply(t,e),this},n.prototype.and=function t(e){var t=this._conditions.$and||(this._conditions.$and=[]);return Array.isArray(e)||(e=[e]),t.push.apply(t,e),this},"gt gte lt lte ne in nin all regex size maxDistance".split(" ").forEach(function(t){n.prototype[t]=function(){var e,r;1===arguments.length?(this._ensurePath(t),r=arguments[0],e=this._path):(r=arguments[1],e=arguments[0]);var n=this._conditions[e]||(this._conditions[e]={});return n["$"+t]=r,this}}),n.prototype.mod=function(){var t,e;1===arguments.length?(this._ensurePath("mod"),t=arguments[0],e=this._path):2!==arguments.length||c.isArray(arguments[1])?3===arguments.length?(t=s(arguments,1),e=arguments[0]):(t=arguments[1],e=arguments[0]):(this._ensurePath("mod"),t=s(arguments),e=this._path);var r=this._conditions[e]||(this._conditions[e]={});return r.$mod=t,this},n.prototype.exists=function(){var t,e;0===arguments.length?(this._ensurePath("exists"),t=this._path,e=!0):1===arguments.length?"boolean"==typeof arguments[0]?(this._ensurePath("exists"),t=this._path,e=arguments[0]):(t=arguments[0],e=!0):2===arguments.length&&(t=arguments[0],e=arguments[1]);var r=this._conditions[t]||(this._conditions[t]={});return r.$exists=e,this},n.prototype.elemMatch=function(){if(null==arguments[0])throw new TypeError("Invalid argument");var t,e,r;if("function"==typeof arguments[0])this._ensurePath("elemMatch"),e=this._path,t=arguments[0];else if(c.isObject(arguments[0]))this._ensurePath("elemMatch"),e=this._path,r=arguments[0];else if("function"==typeof arguments[1])e=arguments[0],t=arguments[1];else{if(!arguments[1]||!c.isObject(arguments[1]))throw new TypeError("Invalid argument");e=arguments[0],r=arguments[1]}t&&(r=new n,t(r),r=r._conditions);var i=this._conditions[e]||(this._conditions[e]={});return i.$elemMatch=r,this},n.prototype.within=function(){if(this._ensurePath("within"),this._geoComparison=l,0===arguments.length)return this;if(2===arguments.length)return this.box.apply(this,arguments);if(2<arguments.length)return this.polygon.apply(this,arguments);var t=arguments[0];if(!t)throw new TypeError("Invalid argument");if(t.center)return this.circle(t);if(t.box)return this.box.apply(this,t.box);if(t.polygon)return this.polygon.apply(this,t.polygon);if(t.type&&t.coordinates)return this.geometry(t);throw new TypeError("Invalid argument")},n.prototype.box=function(){var t,e;if(3===arguments.length)t=arguments[0],e=[arguments[1],arguments[2]];else{if(2!==arguments.length)throw new TypeError("Invalid argument");this._ensurePath("box"),t=this._path,e=[arguments[0],arguments[1]]}var r=this._conditions[t]||(this._conditions[t]={});return r[this._geoComparison||l]={$box:e},this},n.prototype.polygon=function(){var t,e;"string"==typeof arguments[0]?(e=arguments[0],t=s(arguments,1)):(this._ensurePath("polygon"),e=this._path,t=s(arguments));var r=this._conditions[e]||(this._conditions[e]={});return r[this._geoComparison||l]={$polygon:t},this},n.prototype.circle=function(){var t,e;if(1===arguments.length)this._ensurePath("circle"),t=this._path,e=arguments[0];else{if(2!==arguments.length)throw new TypeError("Invalid argument");t=arguments[0],e=arguments[1]}if(!("radius"in e&&e.center))throw new Error("center and radius are required");var r=this._conditions[t]||(this._conditions[t]={}),n=e.spherical?"$centerSphere":"$center",i=this._geoComparison||l;return r[i]={},r[i][n]=[e.center,e.radius],"unique"in e&&(r[i].$uniqueDocs=!!e.unique),this},n.prototype.near=function(){var t,e;if(this._geoComparison="$near",0===arguments.length)return this;if(1===arguments.length)this._ensurePath("near"),t=this._path,e=arguments[0];else{if(2!==arguments.length)throw new TypeError("Invalid argument");t=arguments[0],e=arguments[1]}if(!e.center)throw new Error("center is required");var r=this._conditions[t]||(this._conditions[t]={}),n=e.spherical?"$nearSphere":"$near";if(Array.isArray(e.center)){r[n]=e.center;var i="maxDistance"in e?e.maxDistance:null;null!=i&&(r.$maxDistance=i)}else{if("Point"!=e.center.type||!Array.isArray(e.center.coordinates))throw new Error(u.format("Invalid GeoJSON specified for %s",n));r[n]={$geometry:e.center},"maxDistance"in e&&(r[n].$maxDistance=e.maxDistance)}return this},n.prototype.intersects=function(){if(this._ensurePath("intersects"),this._geoComparison="$geoIntersects",0===arguments.length)return this;var t=arguments[0];if(null!=t&&t.type&&t.coordinates)return this.geometry(t);throw new TypeError("Invalid argument")},n.prototype.geometry=function(){if("$within"!=this._geoComparison&&"$geoWithin"!=this._geoComparison&&"$near"!=this._geoComparison&&"$geoIntersects"!=this._geoComparison)throw new Error("geometry() must come after `within()`, `intersects()`, or `near()");var t,e;if(1!==arguments.length)throw new TypeError("Invalid argument");if(this._ensurePath("geometry"),e=this._path,t=arguments[0],!t.type||!Array.isArray(t.coordinates))throw new TypeError("Invalid argument");var r=this._conditions[e]||(this._conditions[e]={});return r[this._geoComparison]={$geometry:t},this},n.prototype.select=function(){var t=arguments[0];if(!t)return this;if(1!==arguments.length)throw new Error("Invalid select: select only takes 1 argument");this._validate("select");var e=this._fields||(this._fields={}),r=typeof t;if(("string"==r||c.isArgumentsObject(t))&&"number"==typeof t.length){"string"==r&&(t=t.split(/\s+/));for(var n=0,i=t.length;i>n;++n){var o=t[n];if(o){var s="-"==o[0]?0:1;0===s&&(o=o.substring(1)),e[o]=s}}return this}if(c.isObject(t)&&!Array.isArray(t)){for(var a=c.keys(t),n=0;n<a.length;++n)e[a[n]]=t[a[n]];return this}throw new TypeError("Invalid select() argument. Must be string or object.")},n.prototype.slice=function(){if(0===arguments.length)return this;this._validate("slice");var t,e;if(1===arguments.length){var r=arguments[0];if("object"==typeof r&&!Array.isArray(r)){for(var n=Object.keys(r),i=n.length,o=0;i>o;++o)this.slice(n[o],r[n[o]]);return this}this._ensurePath("slice"),t=this._path,e=arguments[0]}else 2===arguments.length?"number"==typeof arguments[0]?(this._ensurePath("slice"),t=this._path,e=s(arguments)):(t=arguments[0],e=arguments[1]):3===arguments.length&&(t=arguments[0],e=s(arguments,1));var a=this._fields||(this._fields={});return a[t]={$slice:e},this},n.prototype.sort=function(t){if(!t)return this;var e;this._validate("sort");var r=typeof t;if(Array.isArray(t)){e=t.length;for(var n=0;n<t.length;++n)o(this.options,t[n][0],t[n][1]);return this}if(1===arguments.length&&"string"==r){t=t.split(/\s+/),e=t.length;for(var n=0;e>n;++n){var s=t[n];if(s){var a="-"==s[0]?-1:1;-1===a&&(s=s.substring(1)),i(this.options,s,a)}}return this}if(c.isObject(t)){for(var u=c.keys(t),n=0;n<u.length;++n){var s=u[n];i(this.options,s,t[s])}return this}throw new TypeError("Invalid sort() argument. Must be a string, object, or array.")},["limit","skip","maxScan","batchSize","comment"].forEach(function(t){n.prototype[t]=function(e){return this._validate(t),this.options[t]=e,this}}),n.prototype.maxTime=function(t){return this._validate("maxTime"),this.options.maxTimeMS=t,this},n.prototype.snapshot=function(){return this._validate("snapshot"),this.options.snapshot=arguments.length?!!arguments[0]:!0,this},n.prototype.hint=function(){if(0===arguments.length)return this;this._validate("hint");var t=arguments[0];if(c.isObject(t)){var e=this.options.hint||(this.options.hint={});for(var r in t)e[r]=t[r];return this}throw new TypeError("Invalid hint. "+t)},n.prototype.slaveOk=function(t){return this.options.slaveOk=arguments.length?!!t:!0,this},n.prototype.read=function(t){return arguments.length>1&&!n.prototype.read.deprecationWarningIssued&&(console.error("Deprecation warning: 'tags' argument is not supported anymore in Query.read() method. Please use mongodb.ReadPreference object instead."),n.prototype.read.deprecationWarningIssued=!0),this.options.readPreference=c.readPref(t),this},n.prototype.tailable=function(){return this._validate("tailable"),this.options.tailable=arguments.length?!!arguments[0]:!0,this},n.prototype.merge=function(t){if(!t)return this;if(!n.canMerge(t))throw new TypeError("Invalid argument. Expected instanceof mquery or plain object");return t instanceof n?(t._conditions&&c.merge(this._conditions,t._conditions),t._fields&&(this._fields||(this._fields={}),c.merge(this._fields,t._fields)),t.options&&(this.options||(this.options={}),c.merge(this.options,t.options)),t._update&&(this._update||(this._update={}),c.mergeClone(this._update,t._update)),t._distinct&&(this._distinct=t._distinct),this):(c.merge(this._conditions,t),this)},n.prototype.find=function(t,e){if(this.op="find","function"==typeof t?(e=t,t=void 0):n.canMerge(t)&&this.merge(t),!e)return this;var r=this._conditions,i=this._optionsForExec();return i.fields=this._fieldsForExec(),f("find",this._collection.collectionName,r,i),e=this._wrapCallback("find",e,{conditions:r,options:i}),this._collection.find(r,i,c.tick(e)),this},n.prototype.cursor=function(t){if(this.op){if("find"!==this.op)throw new TypeError(".cursor only support .find method")}else this.find(t);var e=this._conditions,r=this._optionsForExec();return r.fields=this._fieldsForExec(),f("findCursor",this._collection.collectionName,e,r),this._collection.findCursor(e,r)},n.prototype.findOne=function(t,e){if(this.op="findOne","function"==typeof t?(e=t,t=void 0):n.canMerge(t)&&this.merge(t),!e)return this;var r=this._conditions,i=this._optionsForExec();return i.fields=this._fieldsForExec(),f("findOne",this._collection.collectionName,r,i),e=this._wrapCallback("findOne",e,{conditions:r,options:i}),this._collection.findOne(r,i,c.tick(e)),this},n.prototype.count=function(t,e){if(this.op="count",this._validate(),"function"==typeof t?(e=t,t=void 0):n.canMerge(t)&&this.merge(t),!e)return this;var r=this._conditions,i=this._optionsForExec();return f("count",this._collection.collectionName,r,i),e=this._wrapCallback("count",e,{conditions:r,options:i}),this._collection.count(r,i,c.tick(e)),this},n.prototype.distinct=function(t,e,r){if(this.op="distinct",this._validate(),!r){switch(typeof e){case"function":r=e,"string"==typeof t&&(e=t,t=void 0);break;case"undefined":case"string":break;default:throw new TypeError("Invalid `field` argument. Must be string or function")}switch(typeof t){case"function":r=t,t=e=void 0;break;case"string":e=t,t=void 0}}if("string"==typeof e&&(this._distinct=e),n.canMerge(t)&&this.merge(t),!r)return this;if(!this._distinct)throw new Error("No value for `distinct` has been declared");var i=this._conditions,o=this._optionsForExec();return f("distinct",this._collection.collectionName,i,o),r=this._wrapCallback("distinct",r,{conditions:i,options:o}),this._collection.distinct(this._distinct,i,o,c.tick(r)),this},n.prototype.update=function(t,e,r,i){this.op="update";var o;switch(arguments.length){case 3:"function"==typeof r&&(i=r,r=void 0);break;case 2:"function"==typeof e&&(i=e,e=t,t=void 0);break;case 1:switch(typeof t){case"function":i=t,t=r=e=void 0;break;case"boolean":o=t,t=void 0;break;default:e=t,t=r=void 0}}if(n.canMerge(t)&&this.merge(t),e&&this._mergeUpdate(e),c.isObject(r)&&this.setOptions(r),!o&&!i)return this;if(!this._update||!this.options.overwrite&&0===c.keys(this._update).length)return i&&c.soon(i.bind(null,null,0)),this;r=this._optionsForExec(),i||(r.safe=!1);var t=this._conditions;return e=this._updateForExec(),f("update",this._collection.collectionName,t,e,r),i=this._wrapCallback("update",i,{conditions:t,doc:e,options:r}),this._collection.update(t,e,r,c.tick(i)),this},n.prototype.remove=function(t,e){this.op="remove";var r;if("function"==typeof t?(e=t,t=void 0):n.canMerge(t)?this.merge(t):!0===t&&(r=t,t=void 0),!r&&!e)return this;var i=this._optionsForExec();e||(i.safe=!1);var o=this._conditions;return f("remove",this._collection.collectionName,o,i),e=this._wrapCallback("remove",e,{conditions:o,options:i}),this._collection.remove(o,i,c.tick(e)),this},n.prototype.findOneAndUpdate=function(t,e,r,i){switch(this.op="findOneAndUpdate",this._validate(),arguments.length){case 3:"function"==typeof r&&(i=r,r={});break;case 2:"function"==typeof e&&(i=e,e=t,t=void 0),r=void 0;break;case 1:"function"==typeof t?(i=t,t=r=e=void 0):(e=t,t=r=void 0)}return n.canMerge(t)&&this.merge(t),e&&this._mergeUpdate(e),r&&this.setOptions(r),i?this._findAndModify("update",i):this},n.prototype.findOneAndRemove=function(t,e,r){return this.op="findOneAndRemove",this._validate(),"function"==typeof e?(r=e,e=void 0):"function"==typeof t&&(r=t,t=void 0),n.canMerge(t)&&this.merge(t),e&&this.setOptions(e),r?this._findAndModify("remove",r):this},n.prototype._findAndModify=function(t,e){a.equal("function",typeof e);var r,n,i=this._optionsForExec();if("remove"==t)i.remove=!0;else if("new"in i||(i.new=!0),"upsert"in i||(i.upsert=!1),n=this._updateForExec(),!n){if(!i.upsert)return this.findOne(e);n={$set:{}}}var r=this._fieldsForExec();r&&(i.fields=r);var o=this._conditions;return f("findAndModify",this._collection.collectionName,o,n,i),e=this._wrapCallback("findAndModify",e,{conditions:o,doc:n,options:i}),this._collection.findAndModify(o,n,i,c.tick(e)),this},n.prototype._wrapCallback=function(t,e,r){var i=this._traceFunction||n.traceFunction;if(i){r.collectionName=this._collection.collectionName;var o=i&&i.call(null,t,r,this),s=(new Date).getTime();return function(t,r){if(o){var n=(new Date).getTime()-s;o.call(null,t,r,n)}e&&e.apply(null,arguments)}}return e},n.prototype.setTraceFunction=function(t){return this._traceFunction=t,this},n.prototype.exec=function(t,e){switch(typeof t){case"function":e=t,t=null;break;case"string":this.op=t}a.ok(this.op,"Missing query type: (find, update, etc)"),("update"==this.op||"remove"==this.op)&&(e||(e=!0));var r=this;return"function"!=typeof e?new n.Promise(function(t,e){r[r.op](function(n,i){n?e(n):t(i),r=t=e=null})}):void this[this.op](e)},n.prototype.thunk=function(){var t=this;return function(e){t.exec(e)}},n.prototype.then=function(t,e){var r=this,i=new n.Promise(function(t,e){r.exec(function(n,i){n?e(n):t(i),r=t=e=null})});return i.then(t,e)},n.prototype.stream=function(t){if("find"!=this.op)throw new Error("stream() is only available for find");var e=this._conditions,r=this._optionsForExec();return r.fields=this._fieldsForExec(),f("stream",this._collection.collectionName,e,r,t),this._collection.findStream(e,r,t)},n.prototype.selected=function(){return!!(this._fields&&Object.keys(this._fields).length>0)},n.prototype.selectedInclusively=function(){if(!this._fields)return!1;var t=Object.keys(this._fields);if(0===t.length)return!1;for(var e=0;e<t.length;++e){var r=t[e];if(0===this._fields[r])return!1;if(this._fields[r]&&"object"==typeof this._fields[r]&&this._fields[r].$meta)return!1}return!0},n.prototype.selectedExclusively=function(){if(!this._fields)return!1;var t=Object.keys(this._fields);if(0===t.length)return!1;for(var e=0;e<t.length;++e){var r=t[e];if(0===this._fields[r])return!0}return!1},n.prototype._mergeUpdate=function(t){this._update||(this._update={}),t instanceof n?t._update&&c.mergeClone(this._update,t._update):c.mergeClone(this._update,t)},n.prototype._optionsForExec=function(){var t=c.clone(this.options,{retainKeyOrder:!0});return t},n.prototype._fieldsForExec=function(){return c.clone(this._fields,{retainKeyOrder:!0})},n.prototype._updateForExec=function(){for(var t=c.clone(this._update,{retainKeyOrder:!0}),e=c.keys(t),r=e.length,n={};r--;){var i=e[r];this.options.overwrite?n[i]=t[i]:"$"!==i[0]?(n.$set||(t.$set?n.$set=t.$set:n.$set={}),n.$set[i]=t[i],e.splice(r,1),~e.indexOf("$set")||e.push("$set")):"$set"===i?n.$set||(n[i]=t[i]):n[i]=t[i]}return this._compiledUpdate=n,n},n.prototype._ensurePath=function(t){if(!this._path){var e=t+"() must be used after where() when called with these arguments";throw new Error(e)}},n.permissions=t("./permissions"),n._isPermitted=function(t,e){var r=n.permissions[e];return r?!0!==r[t]:!0},n.prototype._validate=function(t){var e,r;if(void 0===t){if(r=n.permissions[this.op],"function"!=typeof r)return!0;e=r(this)}else n._isPermitted(t,this.op)||(e=t);if(e)throw new Error(e+" cannot be used with "+this.op)},n.canMerge=function(t){return t instanceof n||c.isObject(t)},n.setGlobalTraceFunction=function(t){n.traceFunction=t},n.utils=c,n.env=t("./env"),n.Collection=t("./collection"),n.BaseCollection=t("./collection/collection"),n.Promise=t("bluebird"),e.exports=r=n},{"./collection":84,"./collection/collection":83,"./env":86,"./permissions":88,"./utils":89,assert:50,bluebird:90,debug:72,sliced:91,util:98}],88:[function(t,e,r){"use strict";var n=r;n.distinct=function(t){if(t._fields&&Object.keys(t._fields).length>0)return"field selection and slice";var e,r=Object.keys(n.distinct);return r.every(function(r){return t.options[r]?(e=r,!1):!0}),e},n.distinct.select=n.distinct.slice=n.distinct.sort=n.distinct.limit=n.distinct.skip=n.distinct.batchSize=n.distinct.comment=n.distinct.maxScan=n.distinct.snapshot=n.distinct.hint=n.distinct.tailable=!0,n.findOneAndUpdate=n.findOneAndRemove=function(t){var e,r=Object.keys(n.findOneAndUpdate);return r.every(function(r){return t.options[r]?(e=r,!1):!0}),e},n.findOneAndUpdate.limit=n.findOneAndUpdate.skip=n.findOneAndUpdate.batchSize=n.findOneAndUpdate.maxScan=n.findOneAndUpdate.snapshot=n.findOneAndUpdate.hint=n.findOneAndUpdate.tailable=n.findOneAndUpdate.comment=!0,n.count=function(t){if(t._fields&&Object.keys(t._fields).length>0)return"field selection and slice";var e,r=Object.keys(n.count);return r.every(function(r){return t.options[r]?(e=r,!1):!0}),e},n.count.slice=n.count.batchSize=n.count.comment=n.count.maxScan=n.count.snapshot=n.count.tailable=!0},{}],89:[function(t,e,r){(function(e,n){"use strict";function i(t){function e(){}if(arguments.length>1)throw new Error("Adding properties is not supported");return e.prototype=t,new e}var o=t("regexp-clone"),s=r.clone=function t(e,n){if(void 0===e||null===e)return e;if(Array.isArray(e))return r.cloneArray(e,n);if(e.constructor){if(/ObjectI[dD]$/.test(e.constructor.name))return"function"==typeof e.clone?e.clone():new e.constructor(e.id);if("ReadPreference"===e._type&&e.isValid&&e.toObject)return"function"==typeof e.clone?e.clone():new e.constructor(e.mode,t(e.tags,n));if("Binary"==e._bsontype&&e.buffer&&e.value)return"function"==typeof e.clone?e.clone():new e.constructor(e.value(!0),e.sub_type);if("Date"===e.constructor.name||"Function"===e.constructor.name)return new e.constructor(+e);if("RegExp"===e.constructor.name)return o(e);if("Buffer"===e.constructor.name)return r.cloneBuffer(e)}return u(e)?r.cloneObject(e,n):e.valueOf?e.valueOf():void 0};r.cloneObject=function(t,e){var r,n,i,o,a,u=e&&e.retainKeyOrder,c=e&&e.minimize,f={};if(u)for(o in t)i=s(t[o],e),c&&"undefined"==typeof i||(r||(r=!0),f[o]=i);else for(n=Object.keys(t),a=n.length;a--;)o=n[a],i=s(t[o],e),c&&"undefined"==typeof i||(r||(r=!0),f[o]=i);return c?r&&f:f},r.cloneArray=function(t,e){for(var r=[],n=0,i=t.length;i>n;n++)r.push(s(t[n],e));return r},r.tick=function(t){return"function"==typeof t?function(){var e=arguments;c(function(){t.apply(this,e)})}:void 0},r.merge=function t(e,n){for(var i,o=Object.keys(n),s=o.length;s--;)i=o[s],"undefined"==typeof e[i]?e[i]=n[i]:r.isObject(n[i])?t(e[i],n[i]):e[i]=n[i]},r.mergeClone=function t(e,n){for(var i,o=Object.keys(n),a=o.length;a--;)i=o[a],"undefined"==typeof e[i]?e[i]=s(n[i],{retainKeyOrder:1}):r.isObject(n[i])?t(e[i],n[i]):e[i]=s(n[i],{retainKeyOrder:1})};r.readPref=function(t){switch(t){case"p":t="primary";break;case"pp":t="primaryPreferred";break;case"s":t="secondary";break;case"sp":t="secondaryPreferred";break;case"n":t="nearest"}return t};var a=Object.prototype.toString,u=(r.toString=function(t){return a.call(t)},r.isObject=function(t){return"[object Object]"==r.toString(t)});r.isArray=function(t){return Array.isArray(t)||"object"==typeof t&&"[object Array]"==r.toString(t)};r.keys=Object.keys||function(t){var e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(r);return e},r.create="function"==typeof Object.create?Object.create:i,r.inherits=function(t,e){t.prototype=r.create(e.prototype),t.prototype.constructor=t};var c=r.soon="function"==typeof setImmediate?setImmediate:e.nextTick;r.cloneBuffer=function(t){var e=new n(t.length);return t.copy(e,0,0,t.length),e},r.isArgumentsObject=function(t){return"[object Arguments]"===Object.prototype.toString.call(t)}}).call(this,t("g5I+bs"),t("buffer").Buffer)},{buffer:71,"g5I+bs":94,"regexp-clone":95}],90:[function(t,e,r){(function(t,n){!function(t){if("object"==typeof r&&"undefined"!=typeof e)e.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i;"undefined"!=typeof window?i=window:"undefined"!=typeof n?i=n:"undefined"!=typeof self&&(i=self),i.Promise=t()}}(function(){var e,r,i;return function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u="function"==typeof _dereq_&&_dereq_;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=r[s]={exports:{}};e[s][0].call(f.exports,function(t){var r=e[s][1][t];return i(r?r:t)},f,f.exports,t,e,r,n)}return r[s].exports}for(var o="function"==typeof _dereq_&&_dereq_,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(t,e,r){"use strict";e.exports=function(t){function e(t){var e=new r(t),n=e.promise();return e.setHowMany(1),e.setUnwrap(),e.init(),n}var r=t._SomePromiseArray;t.any=function(t){return e(t)},t.prototype.any=function(){return e(this)}}},{}],2:[function(t,e,r){"use strict";function n(){this._isTickUsed=!1,this._lateQueue=new c(16),this._normalQueue=new c(16),this._trampolineEnabled=!0;var t=this;this.drainQueues=function(){t._drainQueues()},this._schedule=u.isStatic?u(this.drainQueues):u}function i(t,e,r){this._lateQueue.push(t,e,r),this._queueTick()}function o(t,e,r){this._normalQueue.push(t,e,r),this._queueTick()}function s(t){this._normalQueue._pushOne(t),this._queueTick()}var a;try{throw new Error}catch(t){a=t}var u=t("./schedule.js"),c=t("./queue.js"),f=t("./util.js");n.prototype.disableTrampolineIfNecessary=function(){
8
+ f.hasDevTools&&(this._trampolineEnabled=!1)},n.prototype.enableTrampoline=function(){this._trampolineEnabled||(this._trampolineEnabled=!0,this._schedule=function(t){setTimeout(t,0)})},n.prototype.haveItemsQueued=function(){return this._normalQueue.length()>0},n.prototype.throwLater=function(t,e){if(1===arguments.length&&(e=t,t=function(){throw e}),"undefined"!=typeof setTimeout)setTimeout(function(){t(e)},0);else try{this._schedule(function(){t(e)})}catch(t){throw new Error("No async scheduler available\n\n See http://goo.gl/m3OTXk\n")}},f.hasDevTools?(u.isStatic&&(u=function(t){setTimeout(t,0)}),n.prototype.invokeLater=function(t,e,r){this._trampolineEnabled?i.call(this,t,e,r):this._schedule(function(){setTimeout(function(){t.call(e,r)},100)})},n.prototype.invoke=function(t,e,r){this._trampolineEnabled?o.call(this,t,e,r):this._schedule(function(){t.call(e,r)})},n.prototype.settlePromises=function(t){this._trampolineEnabled?s.call(this,t):this._schedule(function(){t._settlePromises()})}):(n.prototype.invokeLater=i,n.prototype.invoke=o,n.prototype.settlePromises=s),n.prototype.invokeFirst=function(t,e,r){this._normalQueue.unshift(t,e,r),this._queueTick()},n.prototype._drainQueue=function(t){for(;t.length()>0;){var e=t.shift();if("function"==typeof e){var r=t.shift(),n=t.shift();e.call(r,n)}else e._settlePromises()}},n.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._drainQueue(this._lateQueue)},n.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},n.prototype._reset=function(){this._isTickUsed=!1},e.exports=new n,e.exports.firstLineError=a},{"./queue.js":28,"./schedule.js":31,"./util.js":38}],3:[function(t,e,r){"use strict";e.exports=function(t,e,r){var n=function(t,e){this._reject(e)},i=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(n,n,null,this,t)},o=function(t,e){this._isPending()&&this._resolveCallback(e.target)},s=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(n){var a=r(n),u=new t(e);u._propagateFrom(this,1);var c=this._target();if(u._setBoundTo(a),a instanceof t){var f={promiseRejectionQueued:!1,promise:u,target:c,bindingPromise:a};c._then(e,i,u._progress,u,f),a._then(o,s,u._progress,u,f)}else u._resolveCallback(c);return u},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=131072|this._bitField,this._boundTo=t):this._bitField=-131073&this._bitField},t.prototype._isBound=function(){return 131072===(131072&this._bitField)},t.bind=function(n,i){var o=r(n),s=new t(e);return s._setBoundTo(o),o instanceof t?o._then(function(){s._resolveCallback(i)},s._reject,s._progress,s,null):s._resolveCallback(i),s}}},{}],4:[function(t,e,r){"use strict";function n(){try{Promise===o&&(Promise=i)}catch(t){}return o}var i;"undefined"!=typeof Promise&&(i=Promise);var o=t("./promise.js")();o.noConflict=n,e.exports=o},{"./promise.js":23}],5:[function(t,e,r){"use strict";var n=Object.create;if(n){var i=n(null),o=n(null);i[" size"]=o[" size"]=0}e.exports=function(e){function r(t,r){var n;if(null!=t&&(n=t[r]),"function"!=typeof n){var i="Object "+a.classString(t)+" has no method '"+a.toString(r)+"'";throw new e.TypeError(i)}return n}function n(t){var e=this.pop(),n=r(t,e);return n.apply(t,this)}function i(t){return t[this]}function o(t){var e=+this;return 0>e&&(e=Math.max(0,e+t.length)),t[e]}var s,a=t("./util.js"),u=a.canEvaluate;a.isIdentifier;e.prototype.call=function(t){for(var e=arguments.length,r=new Array(e-1),i=1;e>i;++i)r[i-1]=arguments[i];return r.push(t),this._then(n,void 0,void 0,r,void 0)},e.prototype.get=function(t){var e,r="number"==typeof t;if(r)e=o;else if(u){var n=s(t);e=null!==n?n:i}else e=i;return this._then(e,void 0,void 0,t,void 0)}}},{"./util.js":38}],6:[function(t,e,r){"use strict";e.exports=function(e){var r=t("./errors.js"),n=t("./async.js"),i=r.CancellationError;e.prototype._cancel=function(t){if(!this.isCancellable())return this;for(var e,r=this;void 0!==(e=r._cancellationParent)&&e.isCancellable();)r=e;this._unsetCancellable(),r._target()._rejectCallback(t,!1,!0)},e.prototype.cancel=function(t){return this.isCancellable()?(void 0===t&&(t=new i),n.invokeLater(this._cancel,this,t),this):this},e.prototype.cancellable=function(){return this._cancellable()?this:(n.enableTrampoline(),this._setCancellable(),this._cancellationParent=void 0,this)},e.prototype.uncancellable=function(){var t=this.then();return t._unsetCancellable(),t},e.prototype.fork=function(t,e,r){var n=this._then(t,e,r,void 0,void 0);return n._setCancellable(),n._cancellationParent=void 0,n}}},{"./async.js":2,"./errors.js":13}],7:[function(e,r,n){"use strict";r.exports=function(){function r(t){this._parent=t;var e=this._length=1+(void 0===t?0:t._length);w(this,r),e>32&&this.uncycle()}function n(t,e){for(var r=0;r<e.length-1;++r)e[r].push("From previous event:"),e[r]=e[r].join("\n");return r<e.length&&(e[r]=e[r].join("\n")),t+"\n"+e.join("\n")}function i(t){for(var e=0;e<t.length;++e)(0===t[e].length||e+1<t.length&&t[e][0]===t[e+1][0])&&(t.splice(e,1),e--)}function o(t){for(var e=t[0],r=1;r<t.length;++r){for(var n=t[r],i=e.length-1,o=e[i],s=-1,a=n.length-1;a>=0;--a)if(n[a]===o){s=a;break}for(var a=s;a>=0;--a){var u=n[a];if(e[i]!==u)break;e.pop(),i--}e=n}}function s(t){for(var e=[],r=0;r<t.length;++r){var n=t[r],i=_.test(n)||" (No stack trace)"===n,o=i&&v(n);i&&!o&&(g&&" "!==n.charAt(0)&&(n=" "+n),e.push(n))}return e}function a(t){for(var e=t.stack.replace(/\s+$/g,"").split("\n"),r=0;r<e.length;++r){var n=e[r];if(" (No stack trace)"===n||_.test(n))break}return r>0&&(e=e.slice(r)),e}function u(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t.toString();var r=/\[object [a-zA-Z0-9$_]+\]/;if(r.test(e))try{var n=JSON.stringify(t);e=n}catch(t){}0===e.length&&(e="(empty array)")}return"(<"+c(e)+">, no stack trace)"}function c(t){var e=41;return t.length<e?t:t.substr(0,e-3)+"..."}function f(t){var e=t.match(m);return e?{fileName:e[1],line:parseInt(e[2],10)}:void 0}var l,h=e("./async.js"),p=e("./util.js"),d=/[\\\/]bluebird[\\\/]js[\\\/](main|debug|zalgo|instrumented)/,_=null,y=null,g=!1;p.inherits(r,Error),r.prototype.uncycle=function(){var t=this._length;if(!(2>t)){for(var e=[],r={},n=0,i=this;void 0!==i;++n)e.push(i),i=i._parent;t=this._length=n;for(var n=t-1;n>=0;--n){var o=e[n].stack;void 0===r[o]&&(r[o]=n)}for(var n=0;t>n;++n){var s=e[n].stack,a=r[s];if(void 0!==a&&a!==n){a>0&&(e[a-1]._parent=void 0,e[a-1]._length=1),e[n]._parent=void 0,e[n]._length=1;var u=n>0?e[n-1]:this;t-1>a?(u._parent=e[a+1],u._parent.uncycle(),u._length=u._parent._length+1):(u._parent=void 0,u._length=1);for(var c=u._length+1,f=n-2;f>=0;--f)e[f]._length=c,c++;return}}}},r.prototype.parent=function(){return this._parent},r.prototype.hasParent=function(){return void 0!==this._parent},r.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var e=r.parseStackAndMessage(t),a=e.message,u=[e.stack],c=this;void 0!==c;)u.push(s(c.stack.split("\n"))),c=c._parent;o(u),i(u),p.notEnumerableProp(t,"stack",n(a,u)),p.notEnumerableProp(t,"__stackCleaned__",!0)}},r.parseStackAndMessage=function(t){var e=t.stack,r=t.toString();return e="string"==typeof e&&e.length>0?a(t):[" (No stack trace)"],{message:r,stack:s(e)}},r.formatAndLogError=function(t,e){if("undefined"!=typeof console){var r;if("object"==typeof t||"function"==typeof t){var n=t.stack;r=e+y(n,t)}else r=e+String(t);"function"==typeof l?l(r):("function"==typeof console.log||"object"==typeof console.log)&&console.log(r)}},r.unhandledRejection=function(t){r.formatAndLogError(t,"^--- With additional stack trace: ")},r.isSupported=function(){return"function"==typeof w},r.fireRejectionEvent=function(t,e,n,i){var o=!1;try{"function"==typeof e&&(o=!0,"rejectionHandled"===t?e(i):e(n,i))}catch(t){h.throwLater(t)}var s=!1;try{s=E(t,n,i)}catch(t){s=!0,h.throwLater(t)}var a=!1;if(b)try{a=b(t.toLowerCase(),{reason:n,promise:i})}catch(t){a=!0,h.throwLater(t)}s||o||a||"unhandledRejection"!==t||r.formatAndLogError(n,"Unhandled rejection ")};var v=function(){return!1},m=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;r.setBounds=function(t,e){if(r.isSupported()){for(var n,i,o=t.stack.split("\n"),s=e.stack.split("\n"),a=-1,u=-1,c=0;c<o.length;++c){var l=f(o[c]);if(l){n=l.fileName,a=l.line;break}}for(var c=0;c<s.length;++c){var l=f(s[c]);if(l){i=l.fileName,u=l.line;break}}0>a||0>u||!n||!i||n!==i||a>=u||(v=function(t){if(d.test(t))return!0;var e=f(t);return e&&e.fileName===n&&a<=e.line&&e.line<=u?!0:!1})}};var b,w=function(){var t=/^\s*at\s*/,e=function(t,e){return"string"==typeof t?t:void 0!==e.name&&void 0!==e.message?e.toString():u(e)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit=Error.stackTraceLimit+6,_=t,y=e;var r=Error.captureStackTrace;return v=function(t){return d.test(t)},function(t,e){Error.stackTraceLimit=Error.stackTraceLimit+6,r(t,e),Error.stackTraceLimit=Error.stackTraceLimit-6}}var n=new Error;if("string"==typeof n.stack&&n.stack.split("\n")[0].indexOf("stackDetection@")>=0)return _=/@/,y=e,g=!0,function(t){t.stack=(new Error).stack};var i;try{throw new Error}catch(t){i="stack"in t}return"stack"in n||!i||"number"!=typeof Error.stackTraceLimit?(y=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?u(e):e.toString()},null):(_=t,y=e,function(t){Error.stackTraceLimit=Error.stackTraceLimit+6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit=Error.stackTraceLimit-6})}([]),E=function(){if(p.isNode)return function(e,r,n){return"rejectionHandled"===e?t.emit(e,n):t.emit(e,r,n)};var e=!1,r=!0;try{var n=new self.CustomEvent("test");e=n instanceof CustomEvent}catch(t){}if(!e)try{var i=document.createEvent("CustomEvent");i.initCustomEvent("testingtheevent",!1,!0,{}),self.dispatchEvent(i)}catch(t){r=!1}r&&(b=function(t,r){var n;return e?n=new self.CustomEvent(t,{detail:r,bubbles:!1,cancelable:!0}):self.dispatchEvent&&(n=document.createEvent("CustomEvent"),n.initCustomEvent(t,!1,!0,r)),n?!self.dispatchEvent(n):!1});var o={};return o.unhandledRejection="onunhandledRejection".toLowerCase(),o.rejectionHandled="onrejectionHandled".toLowerCase(),function(t,e,r){var n=o[t],i=self[n];return i?("rejectionHandled"===t?i.call(self,r):i.call(self,e,r),!0):!1}}();return"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(l=function(t){console.warn(t)},p.isNode&&t.stderr.isTTY?l=function(e){t.stderr.write(""+e+"\n")}:p.isNode||"string"!=typeof(new Error).stack||(l=function(t){console.warn("%c"+t,"color: red")})),r}},{"./async.js":2,"./util.js":38}],8:[function(t,e,r){"use strict";e.exports=function(e){function r(t,e,r){this._instances=t,this._callback=e,this._promise=r}function n(t,e){var r={},n=s(t).call(r,e);if(n===a)return n;var i=u(r);return i.length?(a.e=new c("Catch filter must inherit from Error or be a simple predicate function\n\n See http://goo.gl/o84o68\n"),a):n}var i=t("./util.js"),o=t("./errors.js"),s=i.tryCatch,a=i.errorObj,u=t("./es5.js").keys,c=o.TypeError;return r.prototype.doFilter=function(t){for(var r=this._callback,i=this._promise,o=i._boundValue(),u=0,c=this._instances.length;c>u;++u){var f=this._instances[u],l=f===Error||null!=f&&f.prototype instanceof Error;if(l&&t instanceof f){var h=s(r).call(o,t);return h===a?(e.e=h.e,e):h}if("function"==typeof f&&!l){var p=n(f,t);if(p===a){t=a.e;break}if(p){var h=s(r).call(o,t);return h===a?(e.e=h.e,e):h}}}return e.e=t,e},r}},{"./errors.js":13,"./es5.js":14,"./util.js":38}],9:[function(t,e,r){"use strict";e.exports=function(t,e,r){function n(){this._trace=new e(o())}function i(){return r()?new n:void 0}function o(){var t=s.length-1;return t>=0?s[t]:void 0}var s=[];return n.prototype._pushContext=function(){r()&&void 0!==this._trace&&s.push(this._trace)},n.prototype._popContext=function(){r()&&void 0!==this._trace&&s.pop()},t.prototype._peekContext=o,t.prototype._pushContext=n.prototype._pushContext,t.prototype._popContext=n.prototype._popContext,i}},{}],10:[function(e,r,n){"use strict";r.exports=function(r,n){var i,o,s=r._getDomain,a=e("./async.js"),u=e("./errors.js").Warning,c=e("./util.js"),f=c.canAttachTrace,l=c.isNode&&(!!t.env.BLUEBIRD_DEBUG||"development"===t.env.NODE_ENV);return c.isNode&&0==t.env.BLUEBIRD_DEBUG&&(l=!1),l&&a.disableTrampolineIfNecessary(),r.prototype._ignoreRejections=function(){this._unsetRejectionIsUnhandled(),this._bitField=16777216|this._bitField},r.prototype._ensurePossibleRejectionHandled=function(){0===(16777216&this._bitField)&&(this._setRejectionIsUnhandled(),a.invokeLater(this._notifyUnhandledRejection,this,void 0))},r.prototype._notifyUnhandledRejectionIsHandled=function(){n.fireRejectionEvent("rejectionHandled",i,void 0,this)},r.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._getCarriedStackTrace()||this._settledValue;this._setUnhandledRejectionIsNotified(),n.fireRejectionEvent("unhandledRejection",o,t,this)}},r.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=524288|this._bitField},r.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-524289&this._bitField},r.prototype._isUnhandledRejectionNotified=function(){return(524288&this._bitField)>0},r.prototype._setRejectionIsUnhandled=function(){this._bitField=2097152|this._bitField},r.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-2097153&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},r.prototype._isRejectionUnhandled=function(){return(2097152&this._bitField)>0},r.prototype._setCarriedStackTrace=function(t){this._bitField=1048576|this._bitField,this._fulfillmentHandler0=t},r.prototype._isCarryingStackTrace=function(){return(1048576&this._bitField)>0},r.prototype._getCarriedStackTrace=function(){return this._isCarryingStackTrace()?this._fulfillmentHandler0:void 0},r.prototype._captureStackTrace=function(){return l&&(this._trace=new n(this._peekContext())),this},r.prototype._attachExtraTrace=function(t,e){if(l&&f(t)){var r=this._trace;if(void 0!==r&&e&&(r=r._parent),void 0!==r)r.attachExtraTrace(t);else if(!t.__stackCleaned__){var i=n.parseStackAndMessage(t);c.notEnumerableProp(t,"stack",i.message+"\n"+i.stack.join("\n")),c.notEnumerableProp(t,"__stackCleaned__",!0)}}},r.prototype._warn=function(t){var e=new u(t),r=this._peekContext();if(r)r.attachExtraTrace(e);else{var i=n.parseStackAndMessage(e);e.stack=i.message+"\n"+i.stack.join("\n")}n.formatAndLogError(e,"")},r.onPossiblyUnhandledRejection=function(t){var e=s();o="function"==typeof t?null===e?t:e.bind(t):void 0},r.onUnhandledRejectionHandled=function(t){var e=s();i="function"==typeof t?null===e?t:e.bind(t):void 0},r.longStackTraces=function(){if(a.haveItemsQueued()&&l===!1)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/DT1qyG\n");l=n.isSupported(),l&&a.disableTrampolineIfNecessary()},r.hasLongStackTraces=function(){return l&&n.isSupported()},n.isSupported()||(r.longStackTraces=function(){},l=!1),function(){return l}}},{"./async.js":2,"./errors.js":13,"./util.js":38}],11:[function(t,e,r){"use strict";var n=t("./util.js"),i=n.isPrimitive;e.exports=function(t){var e=function(){return this},r=function(){throw this},n=function(){},o=function(){throw void 0},s=function(t,e){return 1===e?function(){throw t}:2===e?function(){return t}:void 0};t.prototype.return=t.prototype.thenReturn=function(r){return void 0===r?this.then(n):i(r)?this._then(s(r,2),void 0,void 0,void 0,void 0):(r instanceof t&&r._ignoreRejections(),this._then(e,void 0,void 0,r,void 0))},t.prototype.throw=t.prototype.thenThrow=function(t){return void 0===t?this.then(o):i(t)?this._then(s(t,1),void 0,void 0,void 0,void 0):this._then(r,void 0,void 0,t,void 0)}}},{"./util.js":38}],12:[function(t,e,r){"use strict";e.exports=function(t,e){var r=t.reduce;t.prototype.each=function(t){return r(this,t,null,e)},t.each=function(t,n){return r(t,n,null,e)}}},{}],13:[function(t,e,r){"use strict";function n(t,e){function r(n){return this instanceof r?(l(this,"message","string"==typeof n?n:e),l(this,"name",t),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new r(n)}return f(r,Error),r}function i(t){return this instanceof i?(l(this,"name","OperationalError"),l(this,"message",t),this.cause=t,this.isOperational=!0,void(t instanceof Error?(l(this,"message",t.message),l(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new i(t)}var o,s,a=t("./es5.js"),u=a.freeze,c=t("./util.js"),f=c.inherits,l=c.notEnumerableProp,h=n("Warning","warning"),p=n("CancellationError","cancellation error"),d=n("TimeoutError","timeout error"),_=n("AggregateError","aggregate error");try{o=TypeError,s=RangeError}catch(t){o=n("TypeError","type error"),s=n("RangeError","range error")}for(var y="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),g=0;g<y.length;++g)"function"==typeof Array.prototype[y[g]]&&(_.prototype[y[g]]=Array.prototype[y[g]]);a.defineProperty(_.prototype,"length",{value:0,configurable:!1,writable:!0,enumerable:!0}),_.prototype.isOperational=!0;var v=0;_.prototype.toString=function(){var t=Array(4*v+1).join(" "),e="\n"+t+"AggregateError of:\n";v++,t=Array(4*v+1).join(" ");for(var r=0;r<this.length;++r){for(var n=this[r]===this?"[Circular AggregateError]":this[r]+"",i=n.split("\n"),o=0;o<i.length;++o)i[o]=t+i[o];n=i.join("\n"),e+=n+"\n"}return v--,e},f(i,Error);var m=Error.__BluebirdErrorTypes__;m||(m=u({CancellationError:p,TimeoutError:d,OperationalError:i,RejectionError:i,AggregateError:_}),l(Error,"__BluebirdErrorTypes__",m)),e.exports={Error:Error,TypeError:o,RangeError:s,CancellationError:m.CancellationError,OperationalError:m.OperationalError,TimeoutError:m.TimeoutError,AggregateError:m.AggregateError,Warning:h}},{"./es5.js":14,"./util.js":38}],14:[function(t,e,r){var n=function(){"use strict";return void 0===this}();if(n)e.exports={freeze:Object.freeze,defineProperty:Object.defineProperty,getDescriptor:Object.getOwnPropertyDescriptor,keys:Object.keys,names:Object.getOwnPropertyNames,getPrototypeOf:Object.getPrototypeOf,isArray:Array.isArray,isES5:n,propertyIsWritable:function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return!(r&&!r.writable&&!r.set)}};else{var i={}.hasOwnProperty,o={}.toString,s={}.constructor.prototype,a=function(t){var e=[];for(var r in t)i.call(t,r)&&e.push(r);return e},u=function(t,e){return{value:t[e]}},c=function(t,e,r){return t[e]=r.value,t},f=function(t){return t},l=function(t){try{return Object(t).constructor.prototype}catch(t){return s}},h=function(t){try{return"[object Array]"===o.call(t)}catch(t){return!1}};e.exports={isArray:h,keys:a,names:a,defineProperty:c,getDescriptor:u,freeze:f,getPrototypeOf:l,isES5:n,propertyIsWritable:function(){return!0}}}},{}],15:[function(t,e,r){"use strict";e.exports=function(t,e){var r=t.map;t.prototype.filter=function(t,n){return r(this,t,n,e)},t.filter=function(t,n,i){return r(t,n,i,e)}}},{}],16:[function(t,e,r){"use strict";e.exports=function(e,r,n){function i(){return this}function o(){throw this}function s(t){return function(){return t}}function a(t){return function(){throw t}}function u(t,e,r){var n;return n=h(e)?r?s(e):a(e):r?i:o,t._then(n,p,void 0,e,void 0)}function c(t){var i=this.promise,o=this.handler,s=i._isBound()?o.call(i._boundValue()):o();if(void 0!==s){var a=n(s,i);if(a instanceof e)return a=a._target(),u(a,t,i.isFulfilled())}return i.isRejected()?(r.e=t,r):t}function f(t){var r=this.promise,i=this.handler,o=r._isBound()?i.call(r._boundValue(),t):i(t);if(void 0!==o){var s=n(o,r);if(s instanceof e)return s=s._target(),u(s,t,!0)}return t}var l=t("./util.js"),h=l.isPrimitive,p=l.thrower;e.prototype._passThroughHandler=function(t,e){if("function"!=typeof t)return this.then();var r={promise:this,handler:t};return this._then(e?c:f,e?c:void 0,void 0,r,void 0)},e.prototype.lastly=e.prototype.finally=function(t){return this._passThroughHandler(t,!0)},e.prototype.tap=function(t){return this._passThroughHandler(t,!1)}}},{"./util.js":38}],17:[function(t,e,r){"use strict";e.exports=function(e,r,n,i){function o(t,r,n){for(var o=0;o<r.length;++o){n._pushContext();var s=l(r[o])(t);if(n._popContext(),s===f){n._pushContext();var a=e.reject(f.e);return n._popContext(),a}var u=i(s,n);if(u instanceof e)return u}return null}function s(t,r,i,o){var s=this._promise=new e(n);s._captureStackTrace(),this._stack=o,this._generatorFunction=t,this._receiver=r,this._generator=void 0,this._yieldHandlers="function"==typeof i?[i].concat(h):h}var a=t("./errors.js"),u=a.TypeError,c=t("./util.js"),f=c.errorObj,l=c.tryCatch,h=[];s.prototype.promise=function(){return this._promise},s.prototype._run=function(){this._generator=this._generatorFunction.call(this._receiver),this._receiver=this._generatorFunction=void 0,this._next(void 0)},s.prototype._continue=function(t){if(t===f)return this._promise._rejectCallback(t.e,!1,!0);var r=t.value;if(t.done===!0)this._promise._resolveCallback(r);else{var n=i(r,this._promise);if(!(n instanceof e)&&(n=o(n,this._yieldHandlers,this._promise),null===n))return void this._throw(new u("A value %s was yielded that could not be treated as a promise\n\n See http://goo.gl/4Y4pDk\n\n".replace("%s",r)+"From coroutine:\n"+this._stack.split("\n").slice(1,-7).join("\n")));n._then(this._next,this._throw,void 0,this,null)}},s.prototype._throw=function(t){this._promise._attachExtraTrace(t),this._promise._pushContext();var e=l(this._generator.throw).call(this._generator,t);this._promise._popContext(),this._continue(e)},s.prototype._next=function(t){this._promise._pushContext();var e=l(this._generator.next).call(this._generator,t);this._promise._popContext(),this._continue(e)},e.coroutine=function(t,e){if("function"!=typeof t)throw new u("generatorFunction must be a function\n\n See http://goo.gl/6Vqhm0\n");var r=Object(e).yieldHandler,n=s,i=(new Error).stack;return function(){var e=t.apply(this,arguments),o=new n(void 0,void 0,r,i);return o._generator=e,o._next(void 0),o.promise()}},e.coroutine.addYieldHandler=function(t){if("function"!=typeof t)throw new u("fn must be a function\n\n See http://goo.gl/916lJJ\n");h.push(t)},e.spawn=function(t){if("function"!=typeof t)return r("generatorFunction must be a function\n\n See http://goo.gl/6Vqhm0\n");var n=new s(t,this),i=n.promise();return n._run(e.spawn),i}}},{"./errors.js":13,"./util.js":38}],18:[function(t,e,r){"use strict";e.exports=function(e,r,n,i){var o=t("./util.js");o.canEvaluate,o.tryCatch,o.errorObj;e.join=function(){var t,e=arguments.length-1;if(e>0&&"function"==typeof arguments[e]){t=arguments[e];var n}for(var i=arguments.length,o=new Array(i),s=0;i>s;++s)o[s]=arguments[s];t&&o.pop();var n=new r(o).promise();return void 0!==t?n.spread(t):n}}},{"./util.js":38}],19:[function(t,e,r){"use strict";e.exports=function(e,r,n,i,o){function s(t,e,r,n){this.constructor$(t),this._promise._captureStackTrace();var i=c();this._callback=null===i?e:i.bind(e),this._preservedValues=n===o?new Array(this.length()):null,this._limit=r,this._inFlight=0,this._queue=r>=1?[]:_,f.invoke(a,this,void 0)}function a(){this._init$(void 0,-2)}function u(t,e,r,n){var i="object"==typeof r&&null!==r?r.concurrency:0;return i="number"==typeof i&&isFinite(i)&&i>=1?i:0,new s(t,e,i,n)}var c=e._getDomain,f=t("./async.js"),l=t("./util.js"),h=l.tryCatch,p=l.errorObj,d={},_=[];l.inherits(s,r),s.prototype._init=function(){},s.prototype._promiseFulfilled=function(t,r){var n=this._values,o=this.length(),s=this._preservedValues,a=this._limit;if(n[r]===d){if(n[r]=t,a>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return}else{if(a>=1&&this._inFlight>=a)return n[r]=t,void this._queue.push(r);null!==s&&(s[r]=t);var u=this._callback,c=this._promise._boundValue();this._promise._pushContext();var f=h(u).call(c,t,r,o);if(this._promise._popContext(),f===p)return this._reject(f.e);var l=i(f,this._promise);if(l instanceof e){if(l=l._target(),l._isPending())return a>=1&&this._inFlight++,n[r]=d,l._proxyPromiseArray(this,r);if(!l._isFulfilled())return this._reject(l._reason());f=l._value()}n[r]=f}var _=++this._totalResolved;_>=o&&(null!==s?this._filter(n,s):this._resolve(n))},s.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,r=this._values;t.length>0&&this._inFlight<e;){if(this._isResolved())return;var n=t.pop();this._promiseFulfilled(r[n],n)}},s.prototype._filter=function(t,e){for(var r=e.length,n=new Array(r),i=0,o=0;r>o;++o)t[o]&&(n[i++]=e[o]);n.length=i,this._resolve(n)},s.prototype.preservedValues=function(){return this._preservedValues},e.prototype.map=function(t,e){return"function"!=typeof t?n("fn must be a function\n\n See http://goo.gl/916lJJ\n"):u(this,t,e,null).promise()},e.map=function(t,e,r,i){return"function"!=typeof e?n("fn must be a function\n\n See http://goo.gl/916lJJ\n"):u(t,e,r,i).promise()}}},{"./async.js":2,"./util.js":38}],20:[function(t,e,r){"use strict";e.exports=function(e,r,n,i){var o=t("./util.js"),s=o.tryCatch;e.method=function(t){if("function"!=typeof t)throw new e.TypeError("fn must be a function\n\n See http://goo.gl/916lJJ\n");return function(){var n=new e(r);n._captureStackTrace(),n._pushContext();var i=s(t).apply(this,arguments);return n._popContext(),n._resolveFromSyncValue(i),n}},e.attempt=e.try=function(t,n,a){if("function"!=typeof t)return i("fn must be a function\n\n See http://goo.gl/916lJJ\n");var u=new e(r);u._captureStackTrace(),u._pushContext();var c=o.isArray(n)?s(t).apply(a,n):s(t).call(a,n);return u._popContext(),u._resolveFromSyncValue(c),u},e.prototype._resolveFromSyncValue=function(t){t===o.errorObj?this._rejectCallback(t.e,!1,!0):this._resolveCallback(t,!0)}}},{"./util.js":38}],21:[function(t,e,r){"use strict";e.exports=function(e){function r(t,e){var r=this;if(!o.isArray(t))return n.call(r,t,e);var i=a(e).apply(r._boundValue(),[null].concat(t));i===u&&s.throwLater(i.e)}function n(t,e){var r=this,n=r._boundValue(),i=void 0===t?a(e).call(n,null):a(e).call(n,null,t);i===u&&s.throwLater(i.e)}function i(t,e){var r=this;if(!t){var n=r._target(),i=n._getCarriedStackTrace();i.cause=t,t=i}var o=a(e).call(r._boundValue(),t);o===u&&s.throwLater(o.e)}var o=t("./util.js"),s=t("./async.js"),a=o.tryCatch,u=o.errorObj;e.prototype.asCallback=e.prototype.nodeify=function(t,e){if("function"==typeof t){var o=n;void 0!==e&&Object(e).spread&&(o=r),this._then(o,i,void 0,this,t)}return this}}},{"./async.js":2,"./util.js":38}],22:[function(t,e,r){"use strict";e.exports=function(e,r){var n=t("./util.js"),i=t("./async.js"),o=n.tryCatch,s=n.errorObj;e.prototype.progressed=function(t){return this._then(void 0,void 0,t,void 0,void 0)},e.prototype._progress=function(t){this._isFollowingOrFulfilledOrRejected()||this._target()._progressUnchecked(t)},e.prototype._progressHandlerAt=function(t){return 0===t?this._progressHandler0:this[(t<<2)+t-5+2]},e.prototype._doProgressWith=function(t){var r=t.value,i=t.handler,a=t.promise,u=t.receiver,c=o(i).call(u,r);if(c===s){if(null!=c.e&&"StopProgressPropagation"!==c.e.name){var f=n.canAttachTrace(c.e)?c.e:new Error(n.toString(c.e));a._attachExtraTrace(f),a._progress(c.e)}}else c instanceof e?c._then(a._progress,null,null,a,void 0):a._progress(c)},e.prototype._progressUnchecked=function(t){for(var n=this._length(),o=this._progress,s=0;n>s;s++){var a=this._progressHandlerAt(s),u=this._promiseAt(s);if(u instanceof e)"function"==typeof a?i.invoke(this._doProgressWith,this,{handler:a,promise:u,receiver:this._receiverAt(s),value:t}):i.invoke(o,u,t);else{var c=this._receiverAt(s);"function"==typeof a?a.call(c,t,u):c instanceof r&&!c._isResolved()&&c._promiseProgressed(t,u)}}}}},{"./async.js":2,"./util.js":38}],23:[function(e,r,n){"use strict";r.exports=function(){function r(t){if("function"!=typeof t)throw new h("the promise constructor requires a resolver function\n\n See http://goo.gl/EC22Yn\n");if(this.constructor!==r)throw new h("the promise constructor cannot be invoked directly\n\n See http://goo.gl/KsIlge\n");this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._progressHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,this._settledValue=void 0,t!==p&&this._resolveFromResolver(t)}function n(t){var e=new r(p);e._fulfillmentHandler0=t,e._rejectionHandler0=t,e._progressHandler0=t,e._promise0=t,e._receiver0=t,e._settledValue=t}var i,o=function(){return new h("circular promise resolution chain\n\n See http://goo.gl/LhFpo0\n")},s=function(){return new r.PromiseInspection(this._target())},a=function(t){return r.reject(new h(t))},u=e("./util.js");i=u.isNode?function(){var e=t.domain;return void 0===e&&(e=null),e}:function(){return null},u.notEnumerableProp(r,"_getDomain",i);var c={},f=e("./async.js"),l=e("./errors.js"),h=r.TypeError=l.TypeError;r.RangeError=l.RangeError,r.CancellationError=l.CancellationError,r.TimeoutError=l.TimeoutError,r.OperationalError=l.OperationalError,r.RejectionError=l.OperationalError,r.AggregateError=l.AggregateError;var p=function(){},d={},_={e:null},y=e("./thenables.js")(r,p),g=e("./promise_array.js")(r,p,y,a),v=e("./captured_trace.js")(),m=e("./debuggability.js")(r,v),b=e("./context.js")(r,v,m),w=e("./catch_filter.js")(_),E=e("./promise_resolver.js"),O=E._nodebackForPromise,A=u.errorObj,S=u.tryCatch;return r.prototype.toString=function(){return"[object Promise]"},r.prototype.caught=r.prototype.catch=function(t){var e=arguments.length;if(e>1){var n,i=new Array(e-1),o=0;for(n=0;e-1>n;++n){var s=arguments[n];if("function"!=typeof s)return r.reject(new h("Catch filter must inherit from Error or be a simple predicate function\n\n See http://goo.gl/o84o68\n"));i[o++]=s}i.length=o,t=arguments[n];var a=new w(i,t,this);return this._then(void 0,a.doFilter,void 0,a,void 0)}return this._then(void 0,t,void 0,void 0,void 0)},r.prototype.reflect=function(){return this._then(s,s,void 0,this,void 0)},r.prototype.then=function(t,e,r){if(m()&&arguments.length>0&&"function"!=typeof t&&"function"!=typeof e){var n=".then() only accepts functions but was passed: "+u.classString(t);arguments.length>1&&(n+=", "+u.classString(e)),this._warn(n)}return this._then(t,e,r,void 0,void 0)},r.prototype.done=function(t,e,r){var n=this._then(t,e,r,void 0,void 0);n._setIsFinal()},r.prototype.spread=function(t,e){return this.all()._then(t,e,void 0,d,void 0)},r.prototype.isCancellable=function(){return!this.isResolved()&&this._cancellable()},r.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},r.prototype.all=function(){return new g(this).promise()},r.prototype.error=function(t){return this.caught(u.originatesFromRejection,t)},r.is=function(t){return t instanceof r},r.fromNode=function(t){var e=new r(p),n=S(t)(O(e));return n===A&&e._rejectCallback(n.e,!0,!0),e},r.all=function(t){return new g(t).promise()},r.defer=r.pending=function(){var t=new r(p);return new E(t)},r.cast=function(t){var e=y(t);if(!(e instanceof r)){var n=e;e=new r(p),e._fulfillUnchecked(n)}return e},r.resolve=r.fulfilled=r.cast,r.reject=r.rejected=function(t){var e=new r(p);return e._captureStackTrace(),e._rejectCallback(t,!0),e},r.setScheduler=function(t){if("function"!=typeof t)throw new h("fn must be a function\n\n See http://goo.gl/916lJJ\n");var e=f._schedule;return f._schedule=t,e},r.prototype._then=function(t,e,n,o,s){var a=void 0!==s,u=a?s:new r(p);a||(u._propagateFrom(this,5),u._captureStackTrace());var c=this._target();c!==this&&(void 0===o&&(o=this._boundTo),a||u._setIsMigrated());var l=c._addCallbacks(t,e,n,u,o,i());return c._isResolved()&&!c._isSettlePromisesQueued()&&f.invoke(c._settlePromiseAtPostResolution,c,l),
9
+ u},r.prototype._settlePromiseAtPostResolution=function(t){this._isRejectionUnhandled()&&this._unsetRejectionIsUnhandled(),this._settlePromiseAt(t)},r.prototype._length=function(){return 131071&this._bitField},r.prototype._isFollowingOrFulfilledOrRejected=function(){return(939524096&this._bitField)>0},r.prototype._isFollowing=function(){return 536870912===(536870912&this._bitField)},r.prototype._setLength=function(t){this._bitField=-131072&this._bitField|131071&t},r.prototype._setFulfilled=function(){this._bitField=268435456|this._bitField},r.prototype._setRejected=function(){this._bitField=134217728|this._bitField},r.prototype._setFollowing=function(){this._bitField=536870912|this._bitField},r.prototype._setIsFinal=function(){this._bitField=33554432|this._bitField},r.prototype._isFinal=function(){return(33554432&this._bitField)>0},r.prototype._cancellable=function(){return(67108864&this._bitField)>0},r.prototype._setCancellable=function(){this._bitField=67108864|this._bitField},r.prototype._unsetCancellable=function(){this._bitField=-67108865&this._bitField},r.prototype._setIsMigrated=function(){this._bitField=4194304|this._bitField},r.prototype._unsetIsMigrated=function(){this._bitField=-4194305&this._bitField},r.prototype._isMigrated=function(){return(4194304&this._bitField)>0},r.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[5*t-5+4];if(e!==c)return void 0===e&&this._isBound()?this._boundValue():e},r.prototype._promiseAt=function(t){return 0===t?this._promise0:this[5*t-5+3]},r.prototype._fulfillmentHandlerAt=function(t){return 0===t?this._fulfillmentHandler0:this[5*t-5+0]},r.prototype._rejectionHandlerAt=function(t){return 0===t?this._rejectionHandler0:this[5*t-5+1]},r.prototype._boundValue=function(){var t=this._boundTo;return void 0!==t&&t instanceof r?t.isFulfilled()?t.value():void 0:t},r.prototype._migrateCallbacks=function(t,e){var n=t._fulfillmentHandlerAt(e),i=t._rejectionHandlerAt(e),o=t._progressHandlerAt(e),s=t._promiseAt(e),a=t._receiverAt(e);s instanceof r&&s._setIsMigrated(),void 0===a&&(a=c),this._addCallbacks(n,i,o,s,a,null)},r.prototype._addCallbacks=function(t,e,r,n,i,o){var s=this._length();if(s>=131066&&(s=0,this._setLength(0)),0===s)this._promise0=n,void 0!==i&&(this._receiver0=i),"function"!=typeof t||this._isCarryingStackTrace()||(this._fulfillmentHandler0=null===o?t:o.bind(t)),"function"==typeof e&&(this._rejectionHandler0=null===o?e:o.bind(e)),"function"==typeof r&&(this._progressHandler0=null===o?r:o.bind(r));else{var a=5*s-5;this[a+3]=n,this[a+4]=i,"function"==typeof t&&(this[a+0]=null===o?t:o.bind(t)),"function"==typeof e&&(this[a+1]=null===o?e:o.bind(e)),"function"==typeof r&&(this[a+2]=null===o?r:o.bind(r))}return this._setLength(s+1),s},r.prototype._setProxyHandlers=function(t,e){var r=this._length();if(r>=131066&&(r=0,this._setLength(0)),0===r)this._promise0=e,this._receiver0=t;else{var n=5*r-5;this[n+3]=e,this[n+4]=t}this._setLength(r+1)},r.prototype._proxyPromiseArray=function(t,e){this._setProxyHandlers(t,e)},r.prototype._resolveCallback=function(t,e){if(!this._isFollowingOrFulfilledOrRejected()){if(t===this)return this._rejectCallback(o(),!1,!0);var n=y(t,this);if(!(n instanceof r))return this._fulfill(t);var i=1|(e?4:0);this._propagateFrom(n,i);var s=n._target();if(s._isPending()){for(var a=this._length(),u=0;a>u;++u)s._migrateCallbacks(this,u);this._setFollowing(),this._setLength(0),this._setFollowee(s)}else s._isFulfilled()?this._fulfillUnchecked(s._value()):this._rejectUnchecked(s._reason(),s._getCarriedStackTrace())}},r.prototype._rejectCallback=function(t,e,r){r||u.markAsOriginatingFromRejection(t);var n=u.ensureErrorObject(t),i=n===t;this._attachExtraTrace(n,e?i:!1),this._reject(t,i?void 0:n)},r.prototype._resolveFromResolver=function(t){var e=this;this._captureStackTrace(),this._pushContext();var r=!0,n=S(t)(function(t){null!==e&&(e._resolveCallback(t),e=null)},function(t){null!==e&&(e._rejectCallback(t,r),e=null)});r=!1,this._popContext(),void 0!==n&&n===A&&null!==e&&(e._rejectCallback(n.e,!0,!0),e=null)},r.prototype._settlePromiseFromHandler=function(t,e,r,n){if(!n._isRejected()){n._pushContext();var i;if(i=e!==d||this._isRejected()?S(t).call(e,r):S(t).apply(this._boundValue(),r),n._popContext(),i===A||i===n||i===_){var s=i===n?o():i.e;n._rejectCallback(s,!1,!0)}else n._resolveCallback(i)}},r.prototype._target=function(){for(var t=this;t._isFollowing();)t=t._followee();return t},r.prototype._followee=function(){return this._rejectionHandler0},r.prototype._setFollowee=function(t){this._rejectionHandler0=t},r.prototype._cleanValues=function(){this._cancellable()&&(this._cancellationParent=void 0)},r.prototype._propagateFrom=function(t,e){(1&e)>0&&t._cancellable()&&(this._setCancellable(),this._cancellationParent=t),(4&e)>0&&t._isBound()&&this._setBoundTo(t._boundTo)},r.prototype._fulfill=function(t){this._isFollowingOrFulfilledOrRejected()||this._fulfillUnchecked(t)},r.prototype._reject=function(t,e){this._isFollowingOrFulfilledOrRejected()||this._rejectUnchecked(t,e)},r.prototype._settlePromiseAt=function(t){var e=this._promiseAt(t),n=e instanceof r;if(n&&e._isMigrated())return e._unsetIsMigrated(),f.invoke(this._settlePromiseAt,this,t);var i=this._isFulfilled()?this._fulfillmentHandlerAt(t):this._rejectionHandlerAt(t),o=this._isCarryingStackTrace()?this._getCarriedStackTrace():void 0,s=this._settledValue,a=this._receiverAt(t);this._clearCallbackDataAtIndex(t),"function"==typeof i?n?this._settlePromiseFromHandler(i,a,s,e):i.call(a,s,e):a instanceof g?a._isResolved()||(this._isFulfilled()?a._promiseFulfilled(s,e):a._promiseRejected(s,e)):n&&(this._isFulfilled()?e._fulfill(s):e._reject(s,o)),t>=4&&4===(31&t)&&f.invokeLater(this._setLength,this,0)},r.prototype._clearCallbackDataAtIndex=function(t){if(0===t)this._isCarryingStackTrace()||(this._fulfillmentHandler0=void 0),this._rejectionHandler0=this._progressHandler0=this._receiver0=this._promise0=void 0;else{var e=5*t-5;this[e+3]=this[e+4]=this[e+0]=this[e+1]=this[e+2]=void 0}},r.prototype._isSettlePromisesQueued=function(){return-1073741824===(-1073741824&this._bitField)},r.prototype._setSettlePromisesQueued=function(){this._bitField=-1073741824|this._bitField},r.prototype._unsetSettlePromisesQueued=function(){this._bitField=1073741823&this._bitField},r.prototype._queueSettlePromises=function(){f.settlePromises(this),this._setSettlePromisesQueued()},r.prototype._fulfillUnchecked=function(t){if(t===this){var e=o();return this._attachExtraTrace(e),this._rejectUnchecked(e,void 0)}this._setFulfilled(),this._settledValue=t,this._cleanValues(),this._length()>0&&this._queueSettlePromises()},r.prototype._rejectUncheckedCheckError=function(t){var e=u.ensureErrorObject(t);this._rejectUnchecked(t,e===t?void 0:e)},r.prototype._rejectUnchecked=function(t,e){if(t===this){var r=o();return this._attachExtraTrace(r),this._rejectUnchecked(r)}return this._setRejected(),this._settledValue=t,this._cleanValues(),this._isFinal()?void f.throwLater(function(t){throw"stack"in t&&f.invokeFirst(v.unhandledRejection,void 0,t),t},void 0===e?t:e):(void 0!==e&&e!==t&&this._setCarriedStackTrace(e),void(this._length()>0?this._queueSettlePromises():this._ensurePossibleRejectionHandled()))},r.prototype._settlePromises=function(){this._unsetSettlePromisesQueued();for(var t=this._length(),e=0;t>e;e++)this._settlePromiseAt(e)},u.notEnumerableProp(r,"_makeSelfResolutionError",o),e("./progress.js")(r,g),e("./method.js")(r,p,y,a),e("./bind.js")(r,p,y),e("./finally.js")(r,_,y),e("./direct_resolve.js")(r),e("./synchronous_inspection.js")(r),e("./join.js")(r,g,y,p),r.Promise=r,e("./map.js")(r,g,a,y,p),e("./cancel.js")(r),e("./using.js")(r,a,y,b),e("./generators.js")(r,a,p,y),e("./nodeify.js")(r),e("./call_get.js")(r),e("./props.js")(r,g,y,a),e("./race.js")(r,p,y,a),e("./reduce.js")(r,g,a,y,p),e("./settle.js")(r,g),e("./some.js")(r,g,a),e("./promisify.js")(r,p),e("./any.js")(r),e("./each.js")(r,p),e("./timers.js")(r,p),e("./filter.js")(r,p),u.toFastProperties(r),u.toFastProperties(r.prototype),n({a:1}),n({b:2}),n({c:3}),n(1),n(function(){}),n(void 0),n(!1),n(new r(p)),v.setBounds(f.firstLineError,u.lastLineError),r}},{"./any.js":1,"./async.js":2,"./bind.js":3,"./call_get.js":5,"./cancel.js":6,"./captured_trace.js":7,"./catch_filter.js":8,"./context.js":9,"./debuggability.js":10,"./direct_resolve.js":11,"./each.js":12,"./errors.js":13,"./filter.js":15,"./finally.js":16,"./generators.js":17,"./join.js":18,"./map.js":19,"./method.js":20,"./nodeify.js":21,"./progress.js":22,"./promise_array.js":24,"./promise_resolver.js":25,"./promisify.js":26,"./props.js":27,"./race.js":29,"./reduce.js":30,"./settle.js":32,"./some.js":33,"./synchronous_inspection.js":34,"./thenables.js":35,"./timers.js":36,"./using.js":37,"./util.js":38}],24:[function(t,e,r){"use strict";e.exports=function(e,r,n,i){function o(t){switch(t){case-2:return[];case-3:return{}}}function s(t){var n,i=this._promise=new e(r);t instanceof e&&(n=t,i._propagateFrom(n,5)),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}var a=t("./util.js"),u=a.isArray;return s.prototype.length=function(){return this._length},s.prototype.promise=function(){return this._promise},s.prototype._init=function t(r,s){var a=n(this._values,this._promise);if(a instanceof e){if(a=a._target(),this._values=a,!a._isFulfilled())return a._isPending()?void a._then(t,this._reject,void 0,this,s):void this._reject(a._reason());if(a=a._value(),!u(a)){var c=new e.TypeError("expecting an array, a promise or a thenable\n\n See http://goo.gl/s8MMhc\n");return void this.__hardReject__(c)}}else if(!u(a))return void this._promise._reject(i("expecting an array, a promise or a thenable\n\n See http://goo.gl/s8MMhc\n")._reason());if(0===a.length)return void(-5===s?this._resolveEmptyArray():this._resolve(o(s)));var f=this.getActualLength(a.length);this._length=f,this._values=this.shouldCopyValues()?new Array(f):this._values;for(var l=this._promise,h=0;f>h;++h){var p=this._isResolved(),d=n(a[h],l);d instanceof e?(d=d._target(),p?d._ignoreRejections():d._isPending()?d._proxyPromiseArray(this,h):d._isFulfilled()?this._promiseFulfilled(d._value(),h):this._promiseRejected(d._reason(),h)):p||this._promiseFulfilled(d,h)}},s.prototype._isResolved=function(){return null===this._values},s.prototype._resolve=function(t){this._values=null,this._promise._fulfill(t)},s.prototype.__hardReject__=s.prototype._reject=function(t){this._values=null,this._promise._rejectCallback(t,!1,!0)},s.prototype._promiseProgressed=function(t,e){this._promise._progress({index:e,value:t})},s.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var r=++this._totalResolved;r>=this._length&&this._resolve(this._values)},s.prototype._promiseRejected=function(t,e){this._totalResolved++,this._reject(t)},s.prototype.shouldCopyValues=function(){return!0},s.prototype.getActualLength=function(t){return t},s}},{"./util.js":38}],25:[function(t,e,r){"use strict";function n(t){return t instanceof Error&&p.getPrototypeOf(t)===Error.prototype}function i(t){var e;if(n(t)){e=new l(t),e.name=t.name,e.message=t.message,e.stack=t.stack;for(var r=p.keys(t),i=0;i<r.length;++i){var o=r[i];d.test(o)||(e[o]=t[o])}return e}return a.markAsOriginatingFromRejection(t),t}function o(t){return function(e,r){if(null!==t){if(e){var n=i(u(e));t._attachExtraTrace(n),t._reject(n)}else if(arguments.length>2){for(var o=arguments.length,s=new Array(o-1),a=1;o>a;++a)s[a-1]=arguments[a];t._fulfill(s)}else t._fulfill(r);t=null}}}var s,a=t("./util.js"),u=a.maybeWrapAsError,c=t("./errors.js"),f=c.TimeoutError,l=c.OperationalError,h=a.haveGetters,p=t("./es5.js"),d=/^(?:name|message|stack|cause)$/;if(s=h?function(t){this.promise=t}:function(t){this.promise=t,this.asCallback=o(t),this.callback=this.asCallback},h){var _={get:function(){return o(this.promise)}};p.defineProperty(s.prototype,"asCallback",_),p.defineProperty(s.prototype,"callback",_)}s._nodebackForPromise=o,s.prototype.toString=function(){return"[object PromiseResolver]"},s.prototype.resolve=s.prototype.fulfill=function(t){if(!(this instanceof s))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._resolveCallback(t)},s.prototype.reject=function(t){if(!(this instanceof s))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._rejectCallback(t)},s.prototype.progress=function(t){if(!(this instanceof s))throw new TypeError("Illegal invocation, resolver resolve/reject must be called within a resolver context. Consider using the promise constructor instead.\n\n See http://goo.gl/sdkXL9\n");this.promise._progress(t)},s.prototype.cancel=function(t){this.promise.cancel(t)},s.prototype.timeout=function(){this.reject(new f("timeout"))},s.prototype.isResolved=function(){return this.promise.isResolved()},s.prototype.toJSON=function(){return this.promise.toJSON()},e.exports=s},{"./errors.js":13,"./es5.js":14,"./util.js":38}],26:[function(t,e,r){"use strict";e.exports=function(e,r){function n(t){return!E.test(t)}function i(t){try{return t.__isPromisified__===!0}catch(t){return!1}}function o(t,e,r){var n=p.getDataPropertyOrDefault(t,e+r,b);return n?i(n):!1}function s(t,e,r){for(var n=0;n<t.length;n+=2){var i=t[n];if(r.test(i))for(var o=i.replace(r,""),s=0;s<t.length;s+=2)if(t[s]===o)throw new v("Cannot promisify an API that has normal methods with '%s'-suffix\n\n See http://goo.gl/iWrZbw\n".replace("%s",e))}}function a(t,e,r,n){for(var a=p.inheritedDataKeys(t),u=[],c=0;c<a.length;++c){var f=a[c],l=t[f],h=n===O?!0:O(f,l,t);"function"!=typeof l||i(l)||o(t,f,e)||!n(f,l,t,h)||u.push(f,l)}return s(u,e,r),u}function u(t,n,i,o){function s(){var i=n;n===h&&(i=this);var o=new e(r);o._captureStackTrace();var s="string"==typeof u&&this!==a?this[u]:t,c=d(o);try{s.apply(i,_(arguments,c))}catch(t){o._rejectCallback(y(t),!0,!0)}return o}var a=function(){return this}(),u=t;return"string"==typeof u&&(t=o),p.notEnumerableProp(s,"__isPromisified__",!0),s}function c(t,e,r,n){for(var i=new RegExp(A(e)+"$"),o=a(t,e,i,r),s=0,u=o.length;u>s;s+=2){var c=o[s],f=o[s+1],l=c+e;if(n===S)t[l]=S(c,h,c,f,e);else{var d=n(f,function(){return S(c,h,c,f,e)});p.notEnumerableProp(d,"__isPromisified__",!0),t[l]=d}}return p.toFastProperties(t),t}function f(t,e){return S(t,e,void 0,t)}var l,h={},p=t("./util.js"),d=t("./promise_resolver.js")._nodebackForPromise,_=p.withAppended,y=p.maybeWrapAsError,g=p.canEvaluate,v=t("./errors").TypeError,m="Async",b={__isPromisified__:!0},w=["arity","length","name","arguments","caller","callee","prototype","__isPromisified__"],E=new RegExp("^(?:"+w.join("|")+")$"),O=function(t){return p.isIdentifier(t)&&"_"!==t.charAt(0)&&"constructor"!==t},A=function(t){return t.replace(/([$])/,"\\$")},S=g?l:u;e.promisify=function(t,e){if("function"!=typeof t)throw new v("fn must be a function\n\n See http://goo.gl/916lJJ\n");if(i(t))return t;var r=f(t,arguments.length<2?h:e);return p.copyDescriptors(t,r,n),r},e.promisifyAll=function(t,e){if("function"!=typeof t&&"object"!=typeof t)throw new v("the target of promisifyAll must be an object or a function\n\n See http://goo.gl/9ITlV0\n");e=Object(e);var r=e.suffix;"string"!=typeof r&&(r=m);var n=e.filter;"function"!=typeof n&&(n=O);var i=e.promisifier;if("function"!=typeof i&&(i=S),!p.isIdentifier(r))throw new RangeError("suffix must be a valid identifier\n\n See http://goo.gl/8FZo5V\n");for(var o=p.inheritedDataKeys(t),s=0;s<o.length;++s){var a=t[o[s]];"constructor"!==o[s]&&p.isClass(a)&&(c(a.prototype,r,n,i),c(a,r,n,i))}return c(t,r,n,i)}}},{"./errors":13,"./promise_resolver.js":25,"./util.js":38}],27:[function(t,e,r){"use strict";e.exports=function(e,r,n,i){function o(t){for(var e=c.keys(t),r=e.length,n=new Array(2*r),i=0;r>i;++i){var o=e[i];n[i]=t[o],n[i+r]=o}this.constructor$(n)}function s(t){var r,s=n(t);return u(s)?(r=s instanceof e?s._then(e.props,void 0,void 0,void 0,void 0):new o(s).promise(),s instanceof e&&r._propagateFrom(s,4),r):i("cannot await properties of a non-object\n\n See http://goo.gl/OsFKC8\n")}var a=t("./util.js"),u=a.isObject,c=t("./es5.js");a.inherits(o,r),o.prototype._init=function(){this._init$(void 0,-3)},o.prototype._promiseFulfilled=function(t,e){this._values[e]=t;var r=++this._totalResolved;if(r>=this._length){for(var n={},i=this.length(),o=0,s=this.length();s>o;++o)n[this._values[o+i]]=this._values[o];this._resolve(n)}},o.prototype._promiseProgressed=function(t,e){this._promise._progress({key:this._values[e+this.length()],value:t})},o.prototype.shouldCopyValues=function(){return!1},o.prototype.getActualLength=function(t){return t>>1},e.prototype.props=function(){return s(this)},e.props=function(t){return s(t)}}},{"./es5.js":14,"./util.js":38}],28:[function(t,e,r){"use strict";function n(t,e,r,n,i){for(var o=0;i>o;++o)r[o+n]=t[o+e],t[o+e]=void 0}function i(t){this._capacity=t,this._length=0,this._front=0}i.prototype._willBeOverCapacity=function(t){return this._capacity<t},i.prototype._pushOne=function(t){var e=this.length();this._checkCapacity(e+1);var r=this._front+e&this._capacity-1;this[r]=t,this._length=e+1},i.prototype._unshiftOne=function(t){var e=this._capacity;this._checkCapacity(this.length()+1);var r=this._front,n=(r-1&e-1^e)-e;this[n]=t,this._front=n,this._length=this.length()+1},i.prototype.unshift=function(t,e,r){this._unshiftOne(r),this._unshiftOne(e),this._unshiftOne(t)},i.prototype.push=function(t,e,r){var n=this.length()+3;if(this._willBeOverCapacity(n))return this._pushOne(t),this._pushOne(e),void this._pushOne(r);var i=this._front+n-3;this._checkCapacity(n);var o=this._capacity-1;this[i+0&o]=t,this[i+1&o]=e,this[i+2&o]=r,this._length=n},i.prototype.shift=function(){var t=this._front,e=this[t];return this[t]=void 0,this._front=t+1&this._capacity-1,this._length--,e},i.prototype.length=function(){return this._length},i.prototype._checkCapacity=function(t){this._capacity<t&&this._resizeTo(this._capacity<<1)},i.prototype._resizeTo=function(t){var e=this._capacity;this._capacity=t;var r=this._front,i=this._length,o=r+i&e-1;n(this,0,this,e,o)},e.exports=i},{}],29:[function(t,e,r){"use strict";e.exports=function(e,r,n,i){function o(t,o){var u=n(t);if(u instanceof e)return a(u);if(!s(t))return i("expecting an array, a promise or a thenable\n\n See http://goo.gl/s8MMhc\n");var c=new e(r);void 0!==o&&c._propagateFrom(o,5);for(var f=c._fulfill,l=c._reject,h=0,p=t.length;p>h;++h){var d=t[h];(void 0!==d||h in t)&&e.cast(d)._then(f,l,void 0,c,null)}return c}var s=t("./util.js").isArray,a=function(t){return t.then(function(e){return o(e,t)})};e.race=function(t){return o(t,void 0)},e.prototype.race=function(){return o(this,void 0)}}},{"./util.js":38}],30:[function(t,e,r){"use strict";e.exports=function(e,r,n,i,o){function s(t,r,n,s){this.constructor$(t),this._promise._captureStackTrace(),this._preservedValues=s===o?[]:null,this._zerothIsAccum=void 0===n,this._gotAccum=!1,this._reducingIndex=this._zerothIsAccum?1:0,this._valuesPhase=void 0;var u=i(n,this._promise),l=!1,h=u instanceof e;h&&(u=u._target(),u._isPending()?u._proxyPromiseArray(this,-1):u._isFulfilled()?(n=u._value(),this._gotAccum=!0):(this._reject(u._reason()),l=!0)),h||this._zerothIsAccum||(this._gotAccum=!0);var p=c();this._callback=null===p?r:p.bind(r),this._accum=n,l||f.invoke(a,this,void 0)}function a(){this._init$(void 0,-5)}function u(t,e,r,i){if("function"!=typeof e)return n("fn must be a function\n\n See http://goo.gl/916lJJ\n");var o=new s(t,e,r,i);return o.promise()}var c=e._getDomain,f=t("./async.js"),l=t("./util.js"),h=l.tryCatch,p=l.errorObj;l.inherits(s,r),s.prototype._init=function(){},s.prototype._resolveEmptyArray=function(){(this._gotAccum||this._zerothIsAccum)&&this._resolve(null!==this._preservedValues?[]:this._accum)},s.prototype._promiseFulfilled=function(t,r){var n=this._values;n[r]=t;var o,s=this.length(),a=this._preservedValues,u=null!==a,c=this._gotAccum,f=this._valuesPhase;if(!f)for(f=this._valuesPhase=new Array(s),o=0;s>o;++o)f[o]=0;if(o=f[r],0===r&&this._zerothIsAccum?(this._accum=t,this._gotAccum=c=!0,f[r]=0===o?1:2):-1===r?(this._accum=t,this._gotAccum=c=!0):0===o?f[r]=1:(f[r]=2,this._accum=t),c){for(var l,d=this._callback,_=this._promise._boundValue(),y=this._reducingIndex;s>y;++y)if(o=f[y],2!==o){if(1!==o)return;if(t=n[y],this._promise._pushContext(),u?(a.push(t),l=h(d).call(_,t,y,s)):l=h(d).call(_,this._accum,t,y,s),this._promise._popContext(),l===p)return this._reject(l.e);var g=i(l,this._promise);if(g instanceof e){if(g=g._target(),g._isPending())return f[y]=4,g._proxyPromiseArray(this,y);if(!g._isFulfilled())return this._reject(g._reason());l=g._value()}this._reducingIndex=y+1,this._accum=l}else this._reducingIndex=y+1;this._resolve(u?a:this._accum)}},e.prototype.reduce=function(t,e){return u(this,t,e,null)},e.reduce=function(t,e,r,n){return u(t,e,r,n)}}},{"./async.js":2,"./util.js":38}],31:[function(e,r,i){"use strict";var o,s=e("./util"),a=function(){throw new Error("No async scheduler available\n\n See http://goo.gl/m3OTXk\n")};if(s.isNode&&"undefined"==typeof MutationObserver){var u=n.setImmediate,c=t.nextTick;o=s.isRecentNode?function(t){u.call(n,t)}:function(e){c.call(t,e)}}else"undefined"==typeof MutationObserver||"undefined"!=typeof window&&window.navigator&&window.navigator.standalone?o="undefined"!=typeof setImmediate?function(t){setImmediate(t)}:"undefined"!=typeof setTimeout?function(t){setTimeout(t,0)}:a:(o=function(t){var e=document.createElement("div"),r=new MutationObserver(t);return r.observe(e,{attributes:!0}),function(){e.classList.toggle("foo")}},o.isStatic=!0);r.exports=o},{"./util":38}],32:[function(t,e,r){"use strict";e.exports=function(e,r){function n(t){this.constructor$(t)}var i=e.PromiseInspection,o=t("./util.js");o.inherits(n,r),n.prototype._promiseResolved=function(t,e){this._values[t]=e;var r=++this._totalResolved;r>=this._length&&this._resolve(this._values)},n.prototype._promiseFulfilled=function(t,e){var r=new i;r._bitField=268435456,r._settledValue=t,this._promiseResolved(e,r)},n.prototype._promiseRejected=function(t,e){var r=new i;r._bitField=134217728,r._settledValue=t,this._promiseResolved(e,r)},e.settle=function(t){return new n(t).promise()},e.prototype.settle=function(){return new n(this).promise()}}},{"./util.js":38}],33:[function(t,e,r){"use strict";e.exports=function(e,r,n){function i(t){this.constructor$(t),this._howMany=0,this._unwrap=!1,this._initialized=!1}function o(t,e){if((0|e)!==e||0>e)return n("expecting a positive integer\n\n See http://goo.gl/1wAmHx\n");var r=new i(t),o=r.promise();return r.setHowMany(e),r.init(),o}var s=t("./util.js"),a=t("./errors.js").RangeError,u=t("./errors.js").AggregateError,c=s.isArray;s.inherits(i,r),i.prototype._init=function(){if(this._initialized){if(0===this._howMany)return void this._resolve([]);this._init$(void 0,-5);var t=c(this._values);!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}},i.prototype.init=function(){this._initialized=!0,this._init()},i.prototype.setUnwrap=function(){this._unwrap=!0},i.prototype.howMany=function(){return this._howMany},i.prototype.setHowMany=function(t){this._howMany=t},i.prototype._promiseFulfilled=function(t){this._addFulfilled(t),this._fulfilled()===this.howMany()&&(this._values.length=this.howMany(),1===this.howMany()&&this._unwrap?this._resolve(this._values[0]):this._resolve(this._values))},i.prototype._promiseRejected=function(t){if(this._addRejected(t),this.howMany()>this._canPossiblyFulfill()){for(var e=new u,r=this.length();r<this._values.length;++r)e.push(this._values[r]);this._reject(e)}},i.prototype._fulfilled=function(){return this._totalResolved},i.prototype._rejected=function(){return this._values.length-this.length()},i.prototype._addRejected=function(t){this._values.push(t)},i.prototype._addFulfilled=function(t){this._values[this._totalResolved++]=t},i.prototype._canPossiblyFulfill=function(){return this.length()-this._rejected()},i.prototype._getRangeError=function(t){var e="Input array must contain at least "+this._howMany+" items but contains only "+t+" items";return new a(e)},i.prototype._resolveEmptyArray=function(){this._reject(this._getRangeError(0))},e.some=function(t,e){return o(t,e)},e.prototype.some=function(t){return o(this,t)},e._SomePromiseArray=i}},{"./errors.js":13,"./util.js":38}],34:[function(t,e,r){"use strict";e.exports=function(t){function e(t){void 0!==t?(t=t._target(),this._bitField=t._bitField,this._settledValue=t._settledValue):(this._bitField=0,this._settledValue=void 0)}e.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/hc1DLj\n");return this._settledValue},e.prototype.error=e.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/hPuiwB\n");return this._settledValue},e.prototype.isFulfilled=t.prototype._isFulfilled=function(){return(268435456&this._bitField)>0},e.prototype.isRejected=t.prototype._isRejected=function(){return(134217728&this._bitField)>0},e.prototype.isPending=t.prototype._isPending=function(){return 0===(402653184&this._bitField)},e.prototype.isResolved=t.prototype._isResolved=function(){return(402653184&this._bitField)>0},t.prototype.isPending=function(){return this._target()._isPending()},t.prototype.isRejected=function(){return this._target()._isRejected()},t.prototype.isFulfilled=function(){return this._target()._isFulfilled()},t.prototype.isResolved=function(){return this._target()._isResolved()},t.prototype._value=function(){return this._settledValue},t.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue},t.prototype.value=function(){var t=this._target();if(!t.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/hc1DLj\n");return t._settledValue},t.prototype.reason=function(){var t=this._target();if(!t.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/hPuiwB\n");return t._unsetRejectionIsUnhandled(),t._settledValue},t.PromiseInspection=e}},{}],35:[function(t,e,r){"use strict";e.exports=function(e,r){function n(t,n){if(c(t)){if(t instanceof e)return t;if(o(t)){var f=new e(r);return t._then(f._fulfillUnchecked,f._rejectUncheckedCheckError,f._progressUnchecked,f,null),f}var l=a.tryCatch(i)(t);if(l===u){n&&n._pushContext();var f=e.reject(l.e);return n&&n._popContext(),f}if("function"==typeof l)return s(t,l,n)}return t}function i(t){return t.then}function o(t){return f.call(t,"_promise0")}function s(t,n,i){function o(t){f&&(f._resolveCallback(t),f=null)}function s(t){f&&(f._rejectCallback(t,h,!0),f=null)}function c(t){f&&"function"==typeof f._progress&&f._progress(t)}var f=new e(r),l=f;i&&i._pushContext(),f._captureStackTrace(),i&&i._popContext();var h=!0,p=a.tryCatch(n).call(t,o,s,c);return h=!1,f&&p===u&&(f._rejectCallback(p.e,!0,!0),f=null),l}var a=t("./util.js"),u=a.errorObj,c=a.isObject,f={}.hasOwnProperty;return n}},{"./util.js":38}],36:[function(t,e,r){"use strict";e.exports=function(e,r){function n(t){var e=this;return e instanceof Number&&(e=+e),clearTimeout(e),t}function i(t){var e=this;throw e instanceof Number&&(e=+e),clearTimeout(e),t}var o=t("./util.js"),s=e.TimeoutError,a=function(t,e){if(t.isPending()){var r;!o.isPrimitive(e)&&e instanceof Error?r=e:("string"!=typeof e&&(e="operation timed out"),r=new s(e)),o.markAsOriginatingFromRejection(r),t._attachExtraTrace(r),t._cancel(r)}},u=function(t){return c(+this).thenReturn(t)},c=e.delay=function(t,n){if(void 0===n){n=t,t=void 0;var i=new e(r);return setTimeout(function(){i._fulfill()},n),i}return n=+n,e.resolve(t)._then(u,null,null,n,void 0)};e.prototype.delay=function(t){return c(this,t)},e.prototype.timeout=function(t,e){t=+t;var r=this.then().cancellable();r._cancellationParent=this;var o=setTimeout(function(){a(r,e)},t);return r._then(n,i,void 0,o,void 0)}}},{"./util.js":38}],37:[function(t,e,r){"use strict";e.exports=function(e,r,n,i){function o(t){for(var r=t.length,n=0;r>n;++n){var i=t[n];if(i.isRejected())return e.reject(i.error());t[n]=i._settledValue}return t}function s(t){setTimeout(function(){throw t},0)}function a(t){var e=n(t);return e!==t&&"function"==typeof t._isDisposable&&"function"==typeof t._getDisposer&&t._isDisposable()&&e._setDisposable(t._getDisposer()),e}function u(t,r){function i(){if(o>=u)return c.resolve();var f=a(t[o++]);if(f instanceof e&&f._isDisposable()){try{f=n(f._getDisposer().tryDispose(r),t.promise)}catch(t){return s(t)}if(f instanceof e)return f._then(i,s,null,null,null)}i()}var o=0,u=t.length,c=e.defer();return i(),c.promise}function c(t){var e=new y;return e._settledValue=t,e._bitField=268435456,u(this,e).thenReturn(t)}function f(t){var e=new y;return e._settledValue=t,e._bitField=134217728,u(this,e).thenThrow(t)}function l(t,e,r){this._data=t,this._promise=e,this._context=r}function h(t,e,r){this.constructor$(t,e,r)}function p(t){return l.isDisposer(t)?(this.resources[this.index]._setDisposable(t),t.promise()):t}var d=t("./errors.js").TypeError,_=t("./util.js").inherits,y=e.PromiseInspection;l.prototype.data=function(){return this._data},l.prototype.promise=function(){return this._promise},l.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():null},l.prototype.tryDispose=function(t){var e=this.resource(),r=this._context;void 0!==r&&r._pushContext();var n=null!==e?this.doDispose(e,t):null;return void 0!==r&&r._popContext(),this._promise._unsetDisposable(),this._data=null,n},l.isDisposer=function(t){return null!=t&&"function"==typeof t.resource&&"function"==typeof t.tryDispose},_(h,l),h.prototype.doDispose=function(t,e){var r=this.data();return r.call(t,t,e)},e.using=function(){var t=arguments.length;if(2>t)return r("you must pass at least 2 arguments to Promise.using");var i=arguments[t-1];if("function"!=typeof i)return r("fn must be a function\n\n See http://goo.gl/916lJJ\n");var s,a=!0;2===t&&Array.isArray(arguments[0])?(s=arguments[0],t=s.length,a=!1):(s=arguments,t--);for(var u=new Array(t),h=0;t>h;++h){var d=s[h];if(l.isDisposer(d)){var _=d;d=d.promise(),d._setDisposable(_)}else{var y=n(d);y instanceof e&&(d=y._then(p,null,null,{resources:u,index:h},void 0))}u[h]=d}var g=e.settle(u).then(o).then(function(t){g._pushContext();var e;try{e=a?i.apply(void 0,t):i.call(void 0,t)}finally{g._popContext()}return e})._then(c,f,void 0,u,void 0);return u.promise=g,g},e.prototype._setDisposable=function(t){this._bitField=262144|this._bitField,this._disposer=t},e.prototype._isDisposable=function(){return(262144&this._bitField)>0},e.prototype._getDisposer=function(){return this._disposer},e.prototype._unsetDisposable=function(){this._bitField=-262145&this._bitField,this._disposer=void 0},e.prototype.disposer=function(t){if("function"==typeof t)return new h(t,this,i());throw new d}}},{"./errors.js":13,"./util.js":38}],38:[function(e,r,n){"use strict";function i(){try{var t=N;return N=null,t.apply(this,arguments)}catch(t){return j.e=t,j}}function o(t){return N=t,i}function s(t){return null==t||t===!0||t===!1||"string"==typeof t||"number"==typeof t}function a(t){return!s(t)}function u(t){return s(t)?new Error(g(t)):t}function c(t,e){var r,n=t.length,i=new Array(n+1);for(r=0;n>r;++r)i[r]=t[r];return i[r]=e,i}function f(t,e,r){if(!O.isES5)return{}.hasOwnProperty.call(t,e)?t[e]:void 0;var n=Object.getOwnPropertyDescriptor(t,e);return null!=n?null==n.get&&null==n.set?n.value:r:void 0}function l(t,e,r){if(s(t))return t;var n={value:r,configurable:!0,enumerable:!1,writable:!0};return O.defineProperty(t,e,n),t}function h(t){throw t}function p(t){try{if("function"==typeof t){var e=O.names(t.prototype),r=O.isES5&&e.length>1,n=e.length>0&&!(1===e.length&&"constructor"===e[0]),i=T.test(t+"")&&O.names(t).length>0;
10
+ if(r||n||i)return!0}return!1}catch(t){return!1}}function d(t){function e(){}e.prototype=t;for(var r=8;r--;)new e;return t}function _(t){return k.test(t)}function y(t,e,r){for(var n=new Array(t),i=0;t>i;++i)n[i]=e+i+r;return n}function g(t){try{return t+""}catch(t){return"[no string representation]"}}function v(t){try{l(t,"isOperational",!0)}catch(t){}}function m(t){return null==t?!1:t instanceof Error.__BluebirdErrorTypes__.OperationalError||t.isOperational===!0}function b(t){return t instanceof Error&&O.propertyIsWritable(t,"stack")}function w(t){return{}.toString.call(t)}function E(t,e,r){for(var n=O.names(t),i=0;i<n.length;++i){var o=n[i];if(r(o))try{O.defineProperty(e,o,O.getDescriptor(t,o))}catch(t){}}}var O=e("./es5.js"),A="undefined"==typeof navigator,S=function(){try{var t={};return O.defineProperty(t,"f",{get:function(){return 3}}),3===t.f}catch(t){return!1}}(),j={e:{}},N,x=function(t,e){function r(){this.constructor=t,this.constructor$=e;for(var r in e.prototype)n.call(e.prototype,r)&&"$"!==r.charAt(r.length-1)&&(this[r+"$"]=e.prototype[r])}var n={}.hasOwnProperty;return r.prototype=e.prototype,t.prototype=new r,t.prototype},B=function(){var t=[Array.prototype,Object.prototype,Function.prototype],e=function(e){for(var r=0;r<t.length;++r)if(t[r]===e)return!0;return!1};if(O.isES5){var r=Object.getOwnPropertyNames;return function(t){for(var n=[],i=Object.create(null);null!=t&&!e(t);){var o;try{o=r(t)}catch(t){return n}for(var s=0;s<o.length;++s){var a=o[s];if(!i[a]){i[a]=!0;var u=Object.getOwnPropertyDescriptor(t,a);null!=u&&null==u.get&&null==u.set&&n.push(a)}}t=O.getPrototypeOf(t)}return n}}var n={}.hasOwnProperty;return function(r){if(e(r))return[];var i=[];t:for(var o in r)if(n.call(r,o))i.push(o);else{for(var s=0;s<t.length;++s)if(n.call(t[s],o))continue t;i.push(o)}return i}}(),T=/this\s*\.\s*\S+\s*=/,k=/^[a-z$_][a-z$_0-9]*$/i,$=function(){return"stack"in new Error?function(t){return b(t)?t:new Error(g(t))}:function(t){if(b(t))return t;try{throw new Error(g(t))}catch(t){return t}}}(),I={isClass:p,isIdentifier:_,inheritedDataKeys:B,getDataPropertyOrDefault:f,thrower:h,isArray:O.isArray,haveGetters:S,notEnumerableProp:l,isPrimitive:s,isObject:a,canEvaluate:A,errorObj:j,tryCatch:o,inherits:x,withAppended:c,maybeWrapAsError:u,toFastProperties:d,filledRange:y,toString:g,canAttachTrace:b,ensureErrorObject:$,originatesFromRejection:m,markAsOriginatingFromRejection:v,classString:w,copyDescriptors:E,hasDevTools:"undefined"!=typeof chrome&&chrome&&"function"==typeof chrome.loadTimes,isNode:"undefined"!=typeof t&&"[object process]"===w(t).toLowerCase()};I.isRecentNode=I.isNode&&function(){var e=t.versions.node.split(".").map(Number);return 0===e[0]&&e[1]>10||e[0]>0}(),I.isNode&&I.toFastProperties(t);try{throw new Error}catch(t){I.lastLineError=t}r.exports=I},{"./es5.js":14}]},{},[4])(4)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise)}).call(this,t("g5I+bs"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"g5I+bs":94}],91:[function(t,e,r){e.exports=r=t("./lib/sliced")},{"./lib/sliced":92}],92:[function(t,e,r){e.exports=function(t,e,r){var n=[],i=t.length;if(0===i)return n;var o=0>e?Math.max(0,e+i):e||0;for(void 0!==r&&(i=0>r?r+i:r);i-- >o;)n[i-o]=t[i];return n}},{}],93:[function(t,e,r){function n(t){if(t=""+t,!(t.length>1e4)){var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*l;case"days":case"day":case"d":return r*f;case"hours":case"hour":case"hrs":case"hr":case"h":return r*c;case"minutes":case"minute":case"mins":case"min":case"m":return r*u;case"seconds":case"second":case"secs":case"sec":case"s":return r*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}}}function i(t){return t>=f?Math.round(t/f)+"d":t>=c?Math.round(t/c)+"h":t>=u?Math.round(t/u)+"m":t>=a?Math.round(t/a)+"s":t+"ms"}function o(t){return s(t,f,"day")||s(t,c,"hour")||s(t,u,"minute")||s(t,a,"second")||t+" ms"}function s(t,e,r){return e>t?void 0:1.5*e>t?Math.floor(t/e)+" "+r:Math.ceil(t/e)+" "+r+"s"}var a=1e3,u=60*a,c=60*u,f=24*c,l=365.25*f;e.exports=function(t,e){return e=e||{},"string"==typeof t?n(t):e.long?o(t):i(t)}},{}],94:[function(t,e,r){function n(){}var i=e.exports={};i.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 r=[];return window.addEventListener("message",function(t){var e=t.source;if((e===window||null===e)&&"process-tick"===t.data&&(t.stopPropagation(),r.length>0)){var n=r.shift();n()}},!0),function(t){r.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),i.title="browser",i.browser=!0,i.env={},i.argv=[],i.on=n,i.addListener=n,i.once=n,i.off=n,i.removeListener=n,i.removeAllListeners=n,i.emit=n,i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")}},{}],95:[function(t,e,r){function n(t){return"object"==typeof t&&"[object RegExp]"==i.call(t)}var i=Object.prototype.toString;e.exports=r=function(t){if(!n(t))throw new TypeError("Not a RegExp");var e=[];return t.global&&e.push("g"),t.multiline&&e.push("m"),t.ignoreCase&&e.push("i"),new RegExp(t.source,e.join(""))}},{}],96:[function(t,e,r){e.exports=t(92)},{}],97:[function(t,e,r){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],98:[function(t,e,r){(function(e,n){function i(t,e){var n={seen:[],stylize:s};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),_(e)?n.showHidden=e:e&&r._extend(n,e),w(n.showHidden)&&(n.showHidden=!1),w(n.depth)&&(n.depth=2),w(n.colors)&&(n.colors=!1),w(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=o),u(n,t,n.depth)}function o(t,e){var r=i.styles[e];return r?"["+i.colors[r][0]+"m"+t+"["+i.colors[r][1]+"m":t}function s(t,e){return t}function a(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}function u(t,e,n){if(t.customInspect&&e&&j(e.inspect)&&e.inspect!==r.inspect&&(!e.constructor||e.constructor.prototype!==e)){var i=e.inspect(n,t);return m(i)||(i=u(t,i,n)),i}var o=c(t,e);if(o)return o;var s=Object.keys(e),_=a(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),S(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(e);if(0===s.length){if(j(e)){var y=e.name?": "+e.name:"";return t.stylize("[Function"+y+"]","special")}if(E(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(A(e))return t.stylize(Date.prototype.toString.call(e),"date");if(S(e))return f(e)}var g="",v=!1,b=["{","}"];if(d(e)&&(v=!0,b=["[","]"]),j(e)){var w=e.name?": "+e.name:"";g=" [Function"+w+"]"}if(E(e)&&(g=" "+RegExp.prototype.toString.call(e)),A(e)&&(g=" "+Date.prototype.toUTCString.call(e)),S(e)&&(g=" "+f(e)),0===s.length&&(!v||0==e.length))return b[0]+g+b[1];if(0>n)return E(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special");t.seen.push(e);var O;return O=v?l(t,e,n,_,s):s.map(function(r){return h(t,e,n,_,r,v)}),t.seen.pop(),p(O,g,b)}function c(t,e){if(w(e))return t.stylize("undefined","undefined");if(m(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return v(e)?t.stylize(""+e,"number"):_(e)?t.stylize(""+e,"boolean"):y(e)?t.stylize("null","null"):void 0}function f(t){return"["+Error.prototype.toString.call(t)+"]"}function l(t,e,r,n,i){for(var o=[],s=0,a=e.length;a>s;++s)k(e,String(s))?o.push(h(t,e,r,n,String(s),!0)):o.push("");return i.forEach(function(i){i.match(/^\d+$/)||o.push(h(t,e,r,n,i,!0))}),o}function h(t,e,r,n,i,o){var s,a,c;if(c=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]},c.get?a=c.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):c.set&&(a=t.stylize("[Setter]","special")),k(n,i)||(s="["+i+"]"),a||(t.seen.indexOf(c.value)<0?(a=y(r)?u(t,c.value,null):u(t,c.value,r-1),a.indexOf("\n")>-1&&(a=o?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n"))):a=t.stylize("[Circular]","special")),w(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=t.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=t.stylize(s,"string"))}return s+": "+a}function p(t,e,r){var n=0,i=t.reduce(function(t,e){return n++,e.indexOf("\n")>=0&&n++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}function d(t){return Array.isArray(t)}function _(t){return"boolean"==typeof t}function y(t){return null===t}function g(t){return null==t}function v(t){return"number"==typeof t}function m(t){return"string"==typeof t}function b(t){return"symbol"==typeof t}function w(t){return void 0===t}function E(t){return O(t)&&"[object RegExp]"===x(t)}function O(t){return"object"==typeof t&&null!==t}function A(t){return O(t)&&"[object Date]"===x(t)}function S(t){return O(t)&&("[object Error]"===x(t)||t instanceof Error)}function j(t){return"function"==typeof t}function N(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function x(t){return Object.prototype.toString.call(t)}function B(t){return 10>t?"0"+t.toString(10):t.toString(10)}function T(){var t=new Date,e=[B(t.getHours()),B(t.getMinutes()),B(t.getSeconds())].join(":");return[t.getDate(),P[t.getMonth()],e].join(" ")}function k(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var $=/%[sdj%]/g;r.format=function(t){if(!m(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(i(arguments[r]));return e.join(" ")}for(var r=1,n=arguments,o=n.length,s=String(t).replace($,function(t){if("%%"===t)return"%";if(r>=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),a=n[r];o>r;a=n[++r])s+=y(a)||!O(a)?" "+a:" "+i(a);return s},r.deprecate=function(t,i){function o(){if(!s){if(e.throwDeprecation)throw new Error(i);e.traceDeprecation?console.trace(i):console.error(i),s=!0}return t.apply(this,arguments)}if(w(n.process))return function(){return r.deprecate(t,i).apply(this,arguments)};if(e.noDeprecation===!0)return t;var s=!1;return o};var I,D={};r.debuglog=function(t){if(w(I)&&(I=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!D[t])if(new RegExp("\\b"+t+"\\b","i").test(I)){var n=e.pid;D[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else D[t]=function(){};return D[t]},r.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},r.isArray=d,r.isBoolean=_,r.isNull=y,r.isNullOrUndefined=g,r.isNumber=v,r.isString=m,r.isSymbol=b,r.isUndefined=w,r.isRegExp=E,r.isObject=O,r.isDate=A,r.isError=S,r.isFunction=j,r.isPrimitive=N,r.isBuffer=t("./support/isBuffer");var P=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];r.log=function(){console.log("%s - %s",T(),r.format.apply(r,arguments))},r.inherits=t("inherits"),r._extend=function(t,e){if(!e||!O(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}}).call(this,t("g5I+bs"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":97,"g5I+bs":94,inherits:77}]},{},[2]);