text: !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){function r(){throw"Can't use ES6 promise with mpromise style constructor"}r.use=function(t){r.ES6=t},e.exports=r},{}],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":35,"./types":41,"./utils.js":43,"./virtualtype":44,buffer:47}],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 y in e.statics)this[y]=e.statics[y]}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":42,"./utils":43,events:51}],4:[function(t,e){var r=t("./utils"),n=t("./schema/index"),i=e.exports=function(t,e){for(var o,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]=i(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(!t)continue;if(s=t.path(u)){if(null===f||void 0===f)continue;if("Object"===f.constructor.name)if(o=Object.keys(f).some(function(t){return"$"===t.charAt(0)&&"$id"!==t&&"$ref"!==t})){var d,y=Object.keys(f);for(p=y.length;p--;)if(d=y[p],a=f[d],"$exists"!==d){if("$type"!==d)"$not"===d?i(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 _,g,v,m=u.split("."),b=m.length;b--&&(_=m.slice(0,b).join("."),!(s=t.path(_))););if(s){s.caster&&s.caster.schema?(v={},g=m.slice(b).join("."),v[g]=f,e[u]=i(s.caster.schema,v)[g]):e[u]=f;continue}if(r.isObject(f)){var w=f.$near?"$near":f.$nearSphere?"$nearSphere":f.$within?"$within":f.$geoIntersects?"$geoIntersects":"";if(!w)continue;var E=new n.Number("__QueryCasting__"),O=f[w];if(f.$maxDistance&&(f.$maxDistance=E.castForQuery(f.$maxDistance)),"$within"==w){var A=O.$center||O.$centerSphere||O.$box||O.$polygon;if(!A)throw new Error("Bad $within paramater: "+JSON.stringify(f));O=A}else"$near"==w&&"string"==typeof O.type&&Array.isArray(O.coordinates)?O=O.coordinates:("$near"==w||"$nearSphere"==w||"$geoIntersects"==w)&&O.$geometry&&"string"==typeof O.$geometry.type&&Array.isArray(O.$geometry.coordinates)&&(O=O.$geometry.coordinates);!function t(e){if(Array.isArray(e))e.forEach(function(n,i){return Array.isArray(n)||r.isObject(n)?t(n):void(e[i]=E.castForQuery(n))});else for(var n=Object.keys(e),i=n.length;i--;){var o=n[i],s=e[o];Array.isArray(s)||r.isObject(s)?(t(s),e[o]=s):e[o]=E.castForQuery(s)}}(O)}}}return e}},{"./schema/index":30,"./utils":43}],5:[function(t,e,r){(function(n,i){function o(t,e,r){this.$__=new j,this.$__.emitter=new y,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(),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){for(var n,i,o=Object.keys(t),s=o.length;s--;)i=o[s],n=t[i],c(i,"Object"!==b.getFunctionName(n.constructor)||!Object.keys(n).length||n.type&&!n.type.type?null:n,e,r,o)}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){var s=(n?n+".":"")+t;n=n||"",e?Object.defineProperty(r,t,{enumerable:!0,configurable:!0,get:function(){if(this.$__.getters||(this.$__.getters={}),!this.$__.getters[s]){var t=Object.create(Object.getPrototypeOf(this),u(this));n||(t.$__.scope=this);for(var r=0,o=i.length;o>r;++r)Object.defineProperty(t,i[r],{enumerable:!1,writable:!0,configurable:!0,value:void 0});t.toObject=function(){return this.get(s)},t.toJSON=t.toObject,t.$__isNested=!0,a(e,t,s),this.$__.getters[s]=t}return this.$__.getters[s]},set:function(t){return t instanceof o&&(t=t.toObject()),(this.$__.scope||this).set(s,t)}}):Object.defineProperty(r,t,{enumerable:!0,configurable:!0,get:function(){return this.get.call(this.$__.scope||this,s)},set:function(t){return this.set.call(this.$__.scope||this,s,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,y=t("events").EventEmitter,_=t("./error"),g=t("./schema/mixed"),v=t("./schema"),m=t("./schematype").ValidatorError,b=t("./utils"),w=b.clone,E=b.isMongooseObject,O=t("util").inspect,A=_.ValidationError,j=t("./internal"),S=b.deepEqual,B=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={},a=this;if(e&&"Object"===b.getFunctionName(e.constructor))for(i=Object.keys(e),o=i.length;o--;)if("_id"!==i[o]){n=0===e[i[o]];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,y=d-1,_="",g=s,v=0,m=!1;d>v;++v){var w,E=p[v];if(_+=E,n){if(_ in e)break}else e&&_ in e&&(m=!0);if(v===y)if(e)if(n){if(h in e)continue;w=l.getDefault(a,!0),"undefined"!=typeof w&&(g[E]=w,a.$__.activePaths.default(h))}else m&&(w=l.getDefault(a,!0),"undefined"!=typeof w&&(g[E]=w,a.$__.activePaths.default(h)));else w=l.getDefault(a,!0),"undefined"!=typeof w&&(g[E]=w,a.$__.activePaths.default(h));else g=g[E]||(g[E]={}),_+="."}}return s},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]),r[n[o]]=E(e)?e.toObject({depopulate:!0}):null==e||!e.valueOf||e.constructor&&"Date"===b.getFunctionName(e.constructor)?e:e.valueOf()};for(var N in B)o.prototype[N]=o[N]=B[N];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]=v.interpretAsType(t,r)),"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 y=f+l;if(h=this.schema.pathType(y),null==t[l]||!b.isObject(t[l])||t[l].constructor&&"Object"!=b.getFunctionName(t[l].constructor)||"virtual"===h||"real"===h||this.$__path(y)instanceof g||this.schema.paths[y]&&this.schema.paths[y].options.ref)if(c){if("real"===h||"virtual"===h)this.set(f+l,t[l],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 _.CastError("Object",e,t)),this):(s||this.setValue(t,null),this.set(e,t,u),this);var E,O=t.split(".");if("adhocOrUndefined"==w&&c){var A;for(d=0;d<O.length;++d){var j=O.slice(0,d+1).join(".");if(E=this.schema.path(j),E instanceof g){A=!0;break}}if(!A){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 S;if(O.length<=1)S=t;else{for(d=0;d<O.length;++d)if(j=O.slice(0,d+1).join("."),this.isDirectModified(j)||null===this.get(j)){S=j;break}S||(S=t)}var B=u?void 0:this.getValue(t);if(!E)return this.$__set(S,t,u,O,E,e,B),this;var x=!0;try{E.options&&E.options.ref&&e instanceof o&&E.options.ref===e.constructor.modelName&&this.populated(t,e._id),e=E.applySetters(e,this,!1,B),this.$markValid(t)}catch(r){this.invalidate(t,new _.CastError(E.instance,e,t)),x=!1}return x&&this.$__set(S,t,u,O,E,e,B),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:S(o,s||this.get(e))?!r&&null!=o&&e in this.$__.activePaths.states.default&&S(o,i.getDefault(this,r))?!0:!1:!0:!0},o.prototype.$__set=function(e,r,n,i,o,s){d=d||t("./types/embedded");var a=this.$__shouldModify.apply(this,arguments),u=this;a&&(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+".")&&u.$__.activePaths.ignore(t)})));for(var c=this._doc,f=0,h=i.length;h>f;f++){var l=f+1,y=l===h;y?c[i[f]]=s:c=c[i[f]]&&"Object"===b.getFunctionName(c[i[f]].constructor)?c[i[f]]:c[i[f]]&&c[i[f]]instanceof d?c[i[f]]:c[i[f]]&&Array.isArray(c[i[f]])?c[i[f]]:c[i[f]]={}}},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=v.interpretAsType(t,e));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&&(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){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 _.CastError&&e.invalidate(r,t.errors[r]);return t}},o=x.get(),s=Object.keys(this.$__.activePaths.states.require).filter(function(t){return e.isSelected(t)||e.isModified(t)?!0:!1});if(s=s.concat(Object.keys(this.$__.activePaths.states.init)),s=s.concat(Object.keys(this.$__.activePaths.states.modify)),s=s.concat(Object.keys(this.$__.activePaths.states.default)),0===s.length)return new o.ES6(function(e,i){n.nextTick(function(){var n=r();return n?(t&&t(n),void i(n)):(t&&t(),void e())})});for(var a={},u=0,c=0;c<s.length;++c){var f=s[c],h=e.getValue(f);if(h instanceof Array&&!i.isBuffer(h)&&!h.isMongooseDocumentArray)for(var l=h.length,p=0;l>p;++p)s.push(f+"."+p)}return new o.ES6(function(i,o){var c=function(){var e=r();return e?(t&&t(e),void o(e)):(t&&t(),void i())},f=function(t){a[t]||(a[t]=!0,u++,n.nextTick(function(){var r=e.schema.path(t);if(!r)return--u||c();if(!e.$isValid(t))return void(--u||c());var n=e.getValue(t);r.doValidate(n,function(r){r&&e.invalidate(t,r,void 0,!0),--u||c()},e)}))};s.forEach(f)})},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 _.CastError&&e.invalidate(a,s.errors[a]);return s},o.prototype.invalidate=function(t,e,r){this.$__.validationError||(this.$__.validationError=new A(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){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),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.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))}),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,O(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:S(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.$__fullPath=function(t){return t||""},o.ValidationError=A,e.exports=r=o}).call(this,t("FWaASH"),t("buffer").Buffer)},{"./error":12,"./internal":21,"./promise_provider":23,"./schema":24,"./schema/mixed":31,"./schematype":35,"./types/array":37,"./types/documentarray":39,"./types/embedded":40,"./utils":43,FWaASH:53,buffer:47,events:51,"hooks-fixed":69,util:55}],6:[function(t,e){"use strict";var r=t("./document.js"),n=t("./browserDocument.js");e.exports=function(){return"undefined"!=typeof window&&"undefined"!=typeof document&&document===window.document?n:r}},{"./browserDocument.js":3,"./document.js":5}],7:[function(t,e){e.exports=function(){}},{}],8:[function(t,e,r){var n=t("bson").Binary;e.exports=r=n},{bson:58}],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:58}],11:[function(t,e){(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){function r(t,e,r){n.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}var n=t("../error.js");r.prototype=Object.create(n.prototype),r.prototype.constructor=n,e.exports=r},{"../error.js":12}],14:[function(t,e){function r(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.";n.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,arguments.callee),this.name="DivergentArrayError"}var n=t("../error.js");r.prototype=Object.create(n.prototype),r.prototype.constructor=n,e.exports=r},{"../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){function r(t){var e="Schema hasn't been registered for model \""+t+'".\nUse mongoose.model(name, schema)';n.call(this,e),Error.captureStackTrace&&Error.captureStackTrace(this,arguments.callee),this.name="MissingSchemaError"}var n=t("../error.js");r.prototype=Object.create(n.prototype),r.prototype.constructor=n,e.exports=r},{"../error.js":12}],17:[function(t,e){function r(t){n.call(this,"Cannot overwrite `"+t+"` model once compiled."),Error.captureStackTrace&&Error.captureStackTrace(this,arguments.callee),this.name="OverwriteModelError"}var n=t("../error.js");r.prototype=Object.create(n.prototype),r.prototype.constructor=n,e.exports=r},{"../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){function r(t){var e=t.message;e||(e=i.general.default),this.properties=t;var r=this.formatMessage(e,t);n.call(this,r),this.stack=(new Error).stack,this.name="ValidatorError",this.kind=t.type,this.path=t.path,this.value=t.value}var n=t("../error.js"),i=n.messages;r.prototype=Object.create(n.prototype),r.prototype.constructor=n,r.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},r.prototype.toString=function(){return this.message},e.exports=r},{"../error.js":12}],20:[function(t,e){function r(){n.call(this,"No matching document found."),Error.captureStackTrace&&Error.captureStackTrace(this,arguments.callee),this.name="VersionError"}var n=t("../error.js");r.prototype=Object.create(n.prototype),r.prototype.constructor=n,e.exports=r},{"../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":36}],22:[function(t,e){function r(t){n.call(this,t)}var n=t("mpromise"),i=t("util");r.ES6=function(t){var e=new r;try{t(function(){e.complete.apply(e,arguments)},function(t){e.error(t)})}catch(t){e.error(t)}return e},r.prototype=Object.create(n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),r.SUCCESS="complete",r.FAILURE="err",r.prototype.error=function(t){return t instanceof Error||(t instanceof Object&&(t=i.inspect(t)),t=new Error(t)),this.reject(t)},r.prototype.resolve=function(t){return t?this.error(t):this.fulfill.apply(this,Array.prototype.slice.call(arguments,1))},r.prototype.addBack=r.prototype.onResolve,r.prototype.complete=n.prototype.fulfill,r.prototype.addCallback=r.prototype.onFulfill,r.prototype.addErrback=r.prototype.onReject,e.exports=r},{mpromise:73,util:55}],23:[function(t,e){var r=t("./promise"),n={_promise:r};n.get=function(){return n._promise},n.set=function(e){return e===r?n.reset():(n._promise=t("./ES6Promise"),n._promise.use(e),void(t("mquery").Promise=n._promise.ES6))},n.reset=function(){n._promise=r},e.exports=n},{"./ES6Promise":1,"./promise":22,mquery:78}],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 l,queryHooks:y},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&&this.add({_id:{type:i.ObjectId,auto:!0}});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",p=c.updatedAt||"updatedAt",d={};d[p]=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[p]=this.isNew?this[f]:e,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]];var n=t.path(r[0]);if(!n)return n;for(var i,o=r.length-1,s=1;s<r.length;++s){if(i=r[s],s===o&&n&&!n.schema&&!/\D/.test(i)){n=n instanceof a.Array?n.caster:void 0;break}if(/\D/.test(i)){if(!n||!n.schema){n=void 0;break}n=n.schema.path(i)}}return t.subpaths[e]=n}var a,u=t("./drivers").ReadPreference,c=t("events").EventEmitter,f=t("./virtualtype"),h=t("./utils"),l=t("kareem"),p=t("async"),d=t("./promise_provider"),y={count:!0,find:!0,findOne:!0,findOneAndUpdate:!0,findOneAndRemove:!0,update:!0};i.prototype=Object.create(c.prototype),i.prototype.constructor=i,Object.defineProperty(i.prototype,"_defaultMiddleware",{configurable:!1,enumerable:!1,writable:!1,value:[{kind:"pre",hook:"save",fn:function(t){return this.ownerDocument?t():void(this.schema.options.validateBeforeSave?this.validate().then(t,t):t())}},{kind:"pre",hook:"save",isAsync:!0,fn:function(t,e){var r=d.get(),n=this.$__getAllSubdocs();return n=n.filter(function(t){return!t.$__preSavingFromParent}),n.length?void new r.ES6(function(t,e){p.each(n,function(t,e){t.$__preSavingFromParent=!0,t.save(function(r){delete t.$__preSavingFromParent,e(r)})},function(r){return r?void e(r):void t()
  })}).then(function(){t(),e()},e):(e(),void t())}}]}),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=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},t),t.read&&(t.read=u(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].type&&!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 _=i.reserved;_.emit=_.on=_.once=_.collection=_.db=_.errors=_.init=_.isModified=_.isNew=_.get=_.modelName=_.save=_.schema=_.set=_.toObject=_.validate=_._pres=_._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)?s(this,t):void 0;if(_[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]=h.clone(e),this.paths[t]=i.interpretAsType(t,e),this},i.interpretAsType=function(t,e){if(e.constructor){var r=h.getFunctionName(e.constructor);"Object"!=r&&(e={type:e})}var o=e.type&&!e.type.type?e.type:{};if("Object"==h.getFunctionName(o.constructor)||"mixed"==o)return new a.Mixed(t,e);if(Array.isArray(o)||Array==o||"array"==o){var s=Array==o||"array"==o?e.cast:o[0];if(s instanceof i)return new a.DocumentArray(t,s,e);if("string"==typeof s)s=a[s.charAt(0).toUpperCase()+s.substring(1)];else if(s&&(!s.type||s.type.type)&&"Object"==h.getFunctionName(s.constructor)&&Object.keys(s).length)return new a.DocumentArray(t,new i(s),e);return new a.Array(t,s||a.Mixed,e)}var u;if(u=n.isBuffer(o)?"Buffer":"string"==typeof o?o:o.schemaName||h.getFunctionName(o),u&&(u=u.charAt(0).toUpperCase()+u.substring(1)),void 0==a[u])throw new TypeError("Undefined type `"+u+"` at `"+t+"`\n  Did you try nesting Schemas? You can only nest using refs or arrays.");return new a[u](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(){if(this._requiredpaths)return this._requiredpaths;for(var t=Object.keys(this.paths),e=t.length,r=[];e--;){var n=t[e];this.paths[n].isRequired&&r.push(n)}return this._requiredpaths=r},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)?"real":"adhocOrUndefined"},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&&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]=u(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 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,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 u,c,f,l,p,d,y,_=Object.keys(o.paths),g=0;g<_.length;++g)u=_[g],c=o.paths[u],c instanceof a.DocumentArray?n(c.schema,u+"."):(f=c._index,!1!==f&&null!=f&&(l={},p=h.isObject(f),d=p?f:{},y="string"==typeof f?f:p?f.type:!1,l[s+u]=y&&~i.indexTypes.indexOf(y)?y: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 f(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)},e.exports=r=i,i.Types=a=t("./schema/index"),r.ObjectId=a.ObjectId}).call(this,t("buffer").Buffer)},{"./drivers":11,"./promise_provider":23,"./schema/index":30,"./utils":43,"./virtualtype":44,async:45,buffer:47,events:51,kareem:70}],25:[function(t,e){function r(t,e,r){if(e){var n={};"Object"===v.getFunctionName(e.constructor)&&(e.type?(n=v.clone(e),delete n.type,e=e.type):e=_);var i="string"==typeof e?e:v.getFunctionName(e),o=i in p?p[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 d(t,u.path,this)})}function n(t){return p.Number.prototype.cast.call(this,t)}function i(t,e){e||(e=this),t.forEach(function(r,o){Array.isArray(r)?i(r,e):t[o]=n.call(e,r)})}function o(t){return Array.isArray(t)?(i(t,this),t):t&&t.$geometry?s(t,this):r.prototype.castForQuery.call(this,t)}function s(t,e){switch(t.$geometry.type){case"Polygon":case"LineString":case"Point":i(t.$geometry.coordinates,e)}return t.$maxDistance&&(t.$maxDistance=n.call(e,t.$maxDistance)),t}function a(t){var e=this;if(t.$maxDistance&&(t.$maxDistance=n.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]=n.call(this,e)})})}else t.$center||t.$centerSphere?(r=t.$center?"$center":"$centerSphere",t[r].forEach(function(e,i){Array.isArray(e)?e.forEach(function(t,r){e[r]=n.call(this,t)}):t[r][i]=n.call(this,e)})):t.$geometry&&s(t,this);return t}function u(t){return Array.isArray(t)||(t=[t]),t=t.map(function(t){if(v.isObject(t)){var e={};return e[this.path]=t,g(this.casterConstructor.schema,e)[this.path]}return t},this)}function c(t){for(var e,r,n=!1,i=Object.keys(t),o=i.length,s=0;o>s;++s)e=i[s],r=t[e],0===e.indexOf("$")&&r&&(t[e]=this.castForQuery(e,r),n=!0);return n?t:g(this.casterConstructor.schema,t)}function f(t){var e=t.$geometry;if(e)return s(t,this),t}var h=t("../schematype"),l=h.CastError,p={Boolean:t("./boolean"),Date:t("./date"),Number:t("./number"),String:t("./string"),ObjectId:t("./objectid"),Buffer:t("./buffer")},d=t("../types").Array,y=t("../types").Embedded,_=t("./mixed"),g=t("../cast"),v=t("../utils"),m=v.isMongooseObject;r.schemaName="Array",r.prototype=Object.create(h.prototype),r.prototype.constructor=r,r.prototype.checkRequired=function(t){return!(!t||!t.length)},r.prototype.applyGetters=function(t,e){return this.caster.options&&this.caster.options.ref?t:h.prototype.applyGetters.call(this,t,e)},r.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 d(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 l(e.type,t,this.path)}return t}return e&&r&&e.markModified(this.path),this.cast([t],e,r)},r.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 o&&(t=o.call(s,t)),m(t)?t.toObject({virtuals:!1}):t}):o&&(n=o.call(s,n))}return n&&m(n)?n.toObject({virtuals:!1}):n};var b=r.prototype.$conditionalHandlers={};b.$all=u,b.$options=String,b.$elemMatch=c,b.$geoIntersects=f,b.$or=b.$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},b.$near=b.$nearSphere=o,b.$within=b.$geoWithin=a,b.$size=b.$maxDistance=n,b.$eq=b.$gt=b.$gte=b.$in=b.$lt=b.$lte=b.$ne=b.$nin=b.$regex=r.prototype.castForQuery,e.exports=r},{"../cast":4,"../schematype":35,"../types":41,"../utils":43,"./boolean":26,"./buffer":27,"./date":28,"./mixed":31,"./number":32,"./objectid":33,"./string":34}],26:[function(t,e){function r(t,e){o.call(this,t,e,"Boolean")}function n(t){var e=this;return t.map(function(t){return e.cast(t)})}var i=t("../utils"),o=t("../schematype");r.schemaName="Boolean",r.prototype=Object.create(o.prototype),r.prototype.constructor=r,r.prototype.checkRequired=function(t){return t===!0||t===!1},r.prototype.cast=function(t){return null===t?t:"0"===t?!1:"true"===t?!0:"false"===t?!1:!!t},r.$conditionalHandlers=i.options(o.prototype.$conditionalHandlers,{$in:n}),r.prototype.castForQuery=function(t,e){var n;return 2===arguments.length?(n=r.$conditionalHandlers[t],n?n.call(this,e):this.cast(e)):this.cast(t)},e.exports=r},{"../schematype":35,"../utils":43}],27:[function(t,e){(function(r){function n(t,e){c.call(this,t,e,"Buffer")}function i(t){return this.castForQuery(t)}function o(t){var e=this;return t.map(function(t){return e.castForQuery(t)})}var s,a=t("../utils"),u=t("../types").Buffer,c=t("../schematype"),f=u.Binary,h=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)?null!=t:!(!t||!t.length)},n.prototype.cast=function(e,n,i){var o;if(c._isRef(this,e,n,i)){if(null==e)return e;if(s||(s=t("./../document")),e instanceof s)return e.$__.wasPopulated=!0,e;if(r.isBuffer(e))return e;if(!a.isObject(e))throw new h("buffer",e,this.path);var l=n.$__fullPath(this.path),p=n.ownerDocument?n.ownerDocument():n,d=p.populated(l,!0);return o=new d.options.model(e),o.$__.wasPopulated=!0,o}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(o=new u(e.value(!0),[this.path,n]),"number"!=typeof e.sub_type)throw new h("buffer",e,this.path);return o._subtype=e.sub_type,o}if(null===e)return e;var y=typeof e;if("string"==y||"number"==y||Array.isArray(e))return o=new u(e,[this.path,n]);throw new h("buffer",e,this.path)},n.prototype.$conditionalHandlers=a.options(c.prototype.$conditionalHandlers,{$gt:i,$gte:i,$in:o,$lt:i,$lte:i,$ne:i,$nin: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 Buffer.");return r.call(this,e)}return e=t,this.cast(e).toObject()},e.exports=n}).call(this,t("buffer").Buffer)},{"../schematype":35,"../types":41,"../utils":43,"./../document":5,buffer:47}],28:[function(t,e){function r(t,e){a.call(this,t,e,"Date")}function n(t){return this.cast(t)}function i(t){var e=this;return t.map(function(t){return e.cast(t)})}var o=t("../error").messages,s=t("../utils"),a=t("../schematype"),u=a.CastError;r.schemaName="Date",r.prototype=Object.create(a.prototype),r.prototype.constructor=r,r.prototype.expires=function(t){return this._index&&"Object"===this._index.constructor.name||(this._index={}),this._index.expires=t,s.expires(this._index),this},r.prototype.checkRequired=function(t){return t instanceof Date},r.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},r.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},r.prototype.cast=function(t){if(null==t||""===t)return t;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)},r.prototype.$conditionalHandlers=s.options(a.prototype.$conditionalHandlers,{$all:i,$gt:n,$gte:n,$in:i,$lt:n,$lte:n,$ne:n,$nin:i}),r.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=r},{"../error":12,"../schematype":35,"../utils":43}],29:[function(t,e){function r(t,e,r){function n(){a.apply(this,arguments)}n.prototype=Object.create(a.prototype),n.prototype.$__setSchema(e),n.schema=e;for(var s in e.methods)n.prototype[s]=e.methods[s];for(s in e.statics)n[s]=e.statics[s];n.options=r,this.schema=e,i.call(this,t,n,r),this.schema=e;var u=this.path,c=this.defaultValue;this.default(function(){var t=c.call(this);return Array.isArray(t)||(t=[t]),new o(t,u,this)})}function n(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 i=t("./array"),o=t("../types/documentarray"),s=t("../schematype"),a=t("../types/embedded");r.schemaName="DocumentArray",r.prototype=Object.create(i.prototype),r.prototype.constructor=r,r.prototype.doValidate=function(t,e,r){s.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)},r.prototype.doValidateSync=function(t,e){var r=s.prototype.doValidateSync.call(this,t,e);if(r)return r;var n=t&&t.length,i=null;if(n){for(var o=0,a=n;a>o&&!i;++o){var u=t[o];if(u){var c=u.validateSync();c&&(i=c)}}return i}},r.prototype.cast=function(t,e,r,i){var s,u,c;if(!Array.isArray(t))return e&&r&&e.markModified(this.path),this.cast([t],e,r,i);if((!t||!t.isMongooseDocumentArray)&&(t=new o(t,this.path,e),i&&i._handlers))for(var f in i._handlers)e.removeListener(f,i._handlers[f]);for(c=t.length;c--;)if(!(t[c]instanceof a)&&t[c])if(r)s||(s=n(this,e.$__.selected,r)),u=new this.casterConstructor(null,t,!0,s,c),t[c]=u.init(t[c]);else{try{u=i.id(t[c]._id)}catch(t){}i&&u?(u.set(t[c]),t[c]=u):(u=new this.casterConstructor(t[c],t,void 0,void 0,c),t[c]=u)}return t},e.exports=r},{"../schematype":35,"../types/documentarray":39,"../types/embedded":40,"./array":25}],30:[function(t,e,r){r.String=t("./string"),r.Number=t("./number"),r.Boolean=t("./boolean"),r.DocumentArray=t("./documentarray"),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,"./mixed":31,"./number":32,"./objectid":33,"./string":34}],31:[function(t,e){function r(t,e){if(e&&e.default){var r=e.default;Array.isArray(r)&&0===r.length?e.default=Array:!e.shared&&i.isObject(r)&&0===Object.keys(r).length&&(e.default=function(){return{}})}n.call(this,t,e,"Mixed")}var n=t("../schematype"),i=t("../utils");r.schemaName="Mixed",r.prototype=Object.create(n.prototype),r.prototype.constructor=r,r.prototype.checkRequired=function(t){return void 0!==t&&null!==t},r.prototype.cast=function(t){return t},r.prototype.castForQuery=function(t,e){return 2===arguments.length?e:t},e.exports=r},{"../schematype":35,"../utils":43}],32:[function(t,e){(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 t.map(function(t){return e.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,{$all:o,$gt:i,$gte:i,$in:o,$lt:i,$lte:i,$ne:i,$mod:o,$nin: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":35,"../utils":43,"./../document":5,buffer:47}],33:[function(t,e){(function(r){function n(t,e){c.call(this,t,e,"ObjectID")}function i(t){return this.cast(t)}function o(t){var e=this;return t.map(function(t){return e.cast(t)})}function s(){return new h}function a(t){return this.$__._id=null,t}var u,c=t("../schematype"),f=c.CastError,h=t("../types/objectid"),l=t("../utils");n.schemaName="ObjectId",n.prototype=Object.create(c.prototype),n.prototype.constructor=n,n.prototype.auto=function(t){return t&&(this.default(s),this.set(a)),this},n.prototype.checkRequired=function(t,e){return c._isRef(this,t,e,!0)?null!=t:t instanceof h},n.prototype.cast=function(e,n,i){if(c._isRef(this,e,n,i)){if(null==e)return e;if(u||(u=t("./../document")),e instanceof u)return e.$__.wasPopulated=!0,e;if(e instanceof h)return e;if(r.isBuffer(e)||!l.isObject(e))throw new f("ObjectId",e,this.path);var o=n.$__fullPath(this.path),s=n.ownerDocument?n.ownerDocument():n,a=s.populated(o,!0),p=new a.options.model(e);return p.$__.wasPopulated=!0,p}if(null==e)return e;if(e instanceof h)return e;if(e._id){if(e._id instanceof h)return e._id;if(e._id.toString instanceof Function)try{return h.createFromHexString(e._id.toString())}catch(t){}}if(e.toString instanceof Function)try{return h.createFromHexString(e.toString())}catch(t){throw new f("ObjectId",e,this.path)}throw new f("ObjectId",e,this.path)},n.prototype.$conditionalHandlers=l.options(c.prototype.$conditionalHandlers,{$all:o,$gt:i,$gte:i,$in:o,$lt:i,$lte:i,$ne:i,$nin: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 ObjectId.");return r.call(this,e)}return this.cast(t)},e.exports=n}).call(this,t("buffer").Buffer)},{"../schematype":35,"../types/objectid":42,"../utils":43,"./../document":5,buffer:47}],34:[function(t,e){(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 t.map(function(t){return e.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,$in:o,$lt:i,$lte:i,$ne:i,$nin:o,$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":35,"../utils":43,"./../document":5,buffer:47}],35:[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.cast(t)}var s=t("./utils"),a=t("./error"),u=a.messages,c=a.CastError,f=a.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=s.args(arguments)),this.defaultValue)},i.prototype.index=function(t){return this._index=t,s.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"===s.getFunctionName(t.constructor)){var n;return e instanceof Object&&!r?(n=s.clone(e),n.message||(n.message=n.msg),n.validator=t,n.type=n.type||"user defined"):(e||(e=u.general.default),r||(r="user defined"),n={message:e,type:r,validator:t}),this.validators.push(n),this}var i,o,a;for(i=0,o=arguments.length;o>i;i++){if(a=arguments[i],!a||"Object"!==s.getFunctionName(a.constructor)){var c="Invalid validator. Received ("+typeof a+") "+a+". See http://mongoosejs.com/docs/api.html#schematype_SchemaType-validate";throw new Error(c)}this.validate(a.validator,a)}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||u.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 a=function(t,r){n||(void 0===t||t?--o||e(null):(n=new f(r),e(n)))},u=this;this.validators.forEach(function(e){if(!n){var o=e.validator,c=s.clone(e);if(c.path=i,c.value=t,o instanceof RegExp)a(o.test(t),c);else if("function"==typeof o){if(void 0===t&&!u.isRequired)return void a(!0,c);2===o.length?o.call(r,t,function(t){a(t,c)}):a(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 f(e))},a=this;return void 0!==t||a.isRequired?(this.validators.forEach(function(i){if(!r){var a=i.validator,u=s.clone(i);u.path=n,u.value=t,a instanceof RegExp?o(a.test(t),u):"function"==typeof a&&2!==a.length&&o(a.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 a=r.$__fullPath(t.path),u=r.ownerDocument?r.ownerDocument():r;o=u.populated(a)}if(o){if(null==e)return!0;if(!n.isBuffer(e)&&"Binary"!=e._bsontype&&s.isObject(e))return!0}return!1},i.prototype.$conditionalHandlers={$eq:o},e.exports=r=i,r.CastError=c,r.ValidatorError=f}).call(this,t("buffer").Buffer)},{"./error":12,"./utils":43,buffer:47}],36:[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":43}],37:[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;if("$pullAll"===t||"$pushAll"===t||"$addToSet"===t)r[t]||(r[t]=[]),r[t]=r[t].concat(e);else if("$pullDocs"===t){var i=r.$pull||(r.$pull={}),o=i._id||(i._id={$in:[]});o.$in=o.$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})):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":43,"./embedded":40,"./objectid":42,buffer:47}],38:[function(t,e){(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":43,buffer:47}],39:[function(t,e){(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":33,"../utils":43,"./array":37,"./objectid":42,buffer:47,util:55}],40:[function(t,e){function r(t,e,r,n,o){e?(this.__parentArray=e,this.__parent=e._parent):(this.__parentArray=void 0,this.__parent=void 0),this.__index=o,i.call(this,t,n,r);var s=this;this.on("isNew",function(t){s.isNew=t})}function n(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 i=t("../document_provider")(),o=t("util").inspect,s=t("../promise");r.prototype=Object.create(i.prototype),r.prototype.constructor=r,r.prototype.markModified=function(t){this.__parentArray&&(this.$__.activePaths.modify(t),this.isNew?this.__parentArray._markModified():this.__parentArray._markModified(this,t))},r.prototype.save=function(t){return new s.ES6(function(e){t&&t(),e()})},r.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,n(this)}return t&&t(null),this},r.prototype.update=function(){throw new Error("The #update method is not available on EmbeddedDocuments")},r.prototype.inspect=function(){return o(this.toObject())},r.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},r.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)}}},r.prototype.$isValid=function(t){var e=this.__index;return"undefined"!=typeof e?!this.__parent.$__.validationError||!this.__parent.$__.validationError.errors[t]:!0},r.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},r.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},r.prototype.parent=function(){return this.__parent},r.prototype.parentArray=function(){return this.__parentArray},e.exports=r},{"../document_provider":6,"../promise":22,util:55}],41:[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")},{"./array":37,"./buffer":38,"./documentarray":39,"./embedded":40,"./objectid":42}],42:[function(t,e){var r=t("../drivers").ObjectId;e.exports=r},{"../drivers":11}],43:[function(t,e,r){(function(e,n){function i(t){var e;return!~g.indexOf(t.toLowerCase())&&(e=_.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,h=t("./types/objectid"),l=t("regexp-clone"),p=t("sliced"),d=t("mpath"),y=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 _=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 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 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"[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(y(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":41,"./types/objectid":42,FWaASH:53,buffer:47,mpath:71,ms:85,"regexp-clone":86,sliced:87}],44:[function(t,e){function r(t,e){this.path=e,this.getters=[],this.setters=[],this.options=t||{}}r.prototype.get=function(t){return this.getters.push(t),this},r.prototype.set=function(t){return this.setters.push(t),this},r.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},r.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=r},{}],45:[function(t,e){(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,o.setImmediate="undefined"!=typeof setImmediate?function(t){setImmediate(t)}: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))}},y=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[o.eachSeries].concat(e))}},_=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(_),o.mapSeries=y(_),o.mapLimit=function(t,e,r,n){return g(e)(t,r,n)};var g=function(t){return d(t,_)};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 v=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(){n(c(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.filter=p(v),o.filterSeries=y(v),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(){n(c(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};o.reject=p(m),o.rejectSeries=y(m);var b=function(t,e,r,n){t(e,function(t,e){r(t,function(r){r?(n(t),n=function(){}):e()})},function(){n()})};o.detect=p(b),o.detectSeries=y(b),o.some=function(t,e,r){o.each(t,function(t,n){e(t,function(t){t&&(r(!0),r=function(){}),n()})},function(){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(){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))||[],y=function(){return f(d,function(t,e){return t&&i.hasOwnProperty(e)},!0)&&!i.hasOwnProperty(r)};if(y())n[n.length-1](s,i);else{var _=function(){y()&&(l(_),n[n.length-1](s,i))};c(_)}})},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();i.push(s?n(s):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:g(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=y(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 O=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=O("log"),o.dir=O("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);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 A=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(A),o.applyEachSeries=y(A),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:53}],46:[function(t,e){function r(t,e){return l.isUndefined(e)?""+e:!l.isNumber(e)||!isNaN(e)&&isFinite(e)?l.isFunction(e)||l.isRegExp(e)?e.toString():e:e.toString()}function n(t,e){return l.isString(t)?t.length<e?t:t.slice(0,e):t}function i(t){return n(JSON.stringify(t.actual,r),128)+" "+t.operator+" "+n(JSON.stringify(t.expected,r),128)}function o(t,e,r,n,i){throw new y.AssertionError({message:r,actual:t,expected:e,operator:n,stackStartFunction:i})}function s(t,e){t||o(t,!0,e,"==",y.ok)}function a(t,e){if(t===e)return!0;if(l.isBuffer(t)&&l.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 l.isDate(t)&&l.isDate(e)?t.getTime()===e.getTime():l.isRegExp(t)&&l.isRegExp(e)?t.source===e.source&&t.global===e.global&&t.multiline===e.multiline&&t.lastIndex===e.lastIndex&&t.ignoreCase===e.ignoreCase:l.isObject(t)||l.isObject(e)?c(t,e):t==e}function u(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function c(t,e){if(l.isNullOrUndefined(t)||l.isNullOrUndefined(e))return!1;if(t.prototype!==e.prototype)return!1;if(u(t))return u(e)?(t=p.call(t),e=p.call(e),a(t,e)):!1;try{var r,n,i=_(t),o=_(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],!a(t[r],e[r]))return!1;return!0}function f(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;l.isString(r)&&(n=r,r=null);try{e()}catch(t){i=t}if(n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&o(i,r,"Missing expected exception"+n),!t&&f(i,r)&&o(i,r,"Got unwanted exception"+n),t&&i&&r&&!f(i,r)||!t&&i)throw i}var l=t("util/"),p=Array.prototype.slice,d=Object.prototype.hasOwnProperty,y=e.exports=s;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=i(this),this.generatedMessage=!0);var e=t.stackStartFunction||o;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var r=new Error;if(r.stack){var n=r.stack,s=e.name,a=n.indexOf("\n"+s);if(a>=0){var u=n.indexOf("\n",a+1);n=n.substring(u+1)}this.stack=n}}},l.inherits(y.AssertionError,Error),y.fail=o,y.ok=s,y.equal=function(t,e,r){t!=e&&o(t,e,r,"==",y.equal)},y.notEqual=function(t,e,r){t==e&&o(t,e,r,"!=",y.notEqual)},y.deepEqual=function(t,e,r){a(t,e)||o(t,e,r,"deepEqual",y.deepEqual)},y.notDeepEqual=function(t,e,r){a(t,e)&&o(t,e,r,"notDeepEqual",y.notDeepEqual)},y.strictEqual=function(t,e,r){t!==e&&o(t,e,r,"===",y.strictEqual)},y.notStrictEqual=function(t,e,r){t===e&&o(t,e,r,"!==",y.notStrictEqual)},y.throws=function(){h.apply(this,[!0].concat(p.call(arguments)))
  },y.doesNotThrow=function(){h.apply(this,[!1].concat(p.call(arguments)))},y.ifError=function(t){if(t)throw t};var _=Object.keys||function(t){var e=[];for(var r in t)d.call(t,r)&&e.push(r);return e}},{"util/":55}],47:[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&&C(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(j(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(B(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(N(e),t,r,n,2);return i}function f(t,e,r){return P.fromByteArray(0===e&&r===t.length?t: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+=S(t[o]);return i}function y(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 _(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),I.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),I.write(t,e,r,n,52,8),r+8}function O(t){for(t=A(t).replace(L,"");t.length%4!==0;)t+="=";return t}function A(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function j(t){return C(t)||n.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function S(t){return 16>t?"0"+t.toString(16):t.toString(16)}function B(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 N(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 P.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 P=t("base64-js"),I=t("ieee754"),C=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(!C(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=B(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||1/0===r?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 y(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||_(t,1,this.length),this[t]},n.prototype.readUInt16LE=function(t,e){return e||_(t,2,this.length),this[t]|this[t+1]<<8},n.prototype.readUInt16BE=function(t,e){return e||_(t,2,this.length),this[t]<<8|this[t+1]},n.prototype.readUInt32LE=function(t,e){return e||_(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||_(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||_(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},n.prototype.readInt16LE=function(t,e){e||_(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||_(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||_(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||_(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||_(t,4,this.length),I.read(this,t,!0,23,4)},n.prototype.readFloatBE=function(t,e){return e||_(t,4,this.length),I.read(this,t,!1,23,4)},n.prototype.readDoubleLE=function(t,e){return e||_(t,8,this.length),I.read(this,t,!0,52,8)},n.prototype.readDoubleBE=function(t,e){return e||_(t,8,this.length),I.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=B(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 D=n.prototype;n._augment=function(t){return t.constructor=n,t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=D.get,t.set=D.set,t.write=D.write,t.toString=D.toString,t.toLocaleString=D.toString,t.toJSON=D.toJSON,t.equals=D.equals,t.compare=D.compare,t.copy=D.copy,t.slice=D.slice,t.readUInt8=D.readUInt8,t.readUInt16LE=D.readUInt16LE,t.readUInt16BE=D.readUInt16BE,t.readUInt32LE=D.readUInt32LE,t.readUInt32BE=D.readUInt32BE,t.readInt8=D.readInt8,t.readInt16LE=D.readInt16LE,t.readInt16BE=D.readInt16BE,t.readInt32LE=D.readInt32LE,t.readInt32BE=D.readInt32BE,t.readFloatLE=D.readFloatLE,t.readFloatBE=D.readFloatBE,t.readDoubleLE=D.readDoubleLE,t.readDoubleBE=D.readDoubleBE,t.writeUInt8=D.writeUInt8,t.writeUInt16LE=D.writeUInt16LE,t.writeUInt16BE=D.writeUInt16BE,t.writeUInt32LE=D.writeUInt32LE,t.writeUInt32BE=D.writeUInt32BE,t.writeInt8=D.writeInt8,t.writeInt16LE=D.writeInt16LE,t.writeInt16BE=D.writeInt16BE,t.writeInt32LE=D.writeInt32LE,t.writeInt32BE=D.writeInt32BE,t.writeFloatLE=D.writeFloatLE,t.writeFloatBE=D.writeFloatBE,t.writeDoubleLE=D.writeDoubleLE,t.writeDoubleBE=D.writeDoubleBE,t.fill=D.fill,t.inspect=D.inspect,t.toArrayBuffer=D.toArrayBuffer,t};var L=/[^+\/0-9A-z]/g},{"base64-js":48,ieee754:49,"is-array":50}],48:[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)},{}],49:[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?0/0:1/0*(p?-1:1);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,y=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(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*y}},{}],50:[function(t,e){var r=Array.isArray,n=Object.prototype.toString;e.exports=r||function(t){return!!t&&"[object Array]"==n.call(t)}},{}],51:[function(t,e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(t){return"function"==typeof t}function i(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!i(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,i,a,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(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],s(r))return!1;if(n(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(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];r.apply(this,a)}else if(o(r)){for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];for(c=r.slice(),i=c.length,u=0;i>u;u++)c[u].apply(this,a)}return!0},r.prototype.addListener=function(t,e){var i;if(!n(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned){var i;i=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[t].length>i&&(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},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),i||(i=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var i=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,i,s,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],s=r.length,i=-1,r===e||n(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-->0;)if(r[a]===e||r[a].listener&&r[a].listener===e){i=a;break}if(0>i)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.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],n(r))this.removeListener(t,r);else for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.listenerCount=function(t,e){var r;return r=t._events&&t._events[e]?n(t._events[e])?1:t._events[e].length:0}},{}],52:[function(t,e){e.exports="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},{}],53:[function(t,e){function r(){}var n=e.exports={};n.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var 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)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.on=r,n.addListener=r,n.once=r,n.off=r,n.removeListener=r,n.removeAllListeners=r,n.emit=r,n.binding=function(){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw new Error("process.chdir is not supported")}},{}],54:[function(t,e){e.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},{}],55:[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]),y(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){return t}function a(t){var e={};return t.forEach(function(t){e[t]=!0}),e}function u(t,e,n){if(t.customInspect&&e&&S(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),y=a(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),j(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(e);if(0===s.length){if(S(e)){var _=e.name?": "+e.name:"";return t.stylize("[Function"+_+"]","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(j(e))return f(e)}var g="",v=!1,b=["{","}"];if(d(e)&&(v=!0,b=["[","]"]),S(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)),j(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?h(t,e,n,y,s):s.map(function(r){return l(t,e,n,y,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"):y(e)?t.stylize(""+e,"boolean"):_(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)o.push(k(e,String(s))?l(t,e,r,n,String(s),!0):"");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=_(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 y(t){return"boolean"==typeof t}function _(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 j(t){return O(t)&&("[object Error]"===x(t)||t instanceof Error)}function S(t){return"function"==typeof t}function B(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 N(t){return 10>t?"0"+t.toString(10):t.toString(10)}function T(){var t=new Date,e=[N(t.getHours()),N(t.getMinutes()),N(t.getSeconds())].join(":");return[t.getDate(),C[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+=_(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 P,I={};r.debuglog=function(t){if(w(P)&&(P=e.env.NODE_DEBUG||""),t=t.toUpperCase(),!I[t])if(new RegExp("\\b"+t+"\\b","i").test(P)){var n=e.pid;I[t]=function(){var e=r.format.apply(r,arguments);console.error("%s %d: %s",t,n,e)}}else I[t]=function(){};return I[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=y,r.isNull=_,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=j,r.isFunction=S,r.isPrimitive=B,r.isBuffer=t("./support/isBuffer");var C=["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("FWaASH"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":54,FWaASH:53,inherits:52}],56:[function(t,e){function r(t,e){if(!(this instanceof r))return new r(t,e);if(this._bsontype="Binary",t instanceof Number?(this.sub_type=t,this.position=0):(this.sub_type=null==e?i:e,this.position=0),null==t||t instanceof Number)this.buffer="undefined"!=typeof n?new n(r.BUFFER_SIZE):"undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(r.BUFFER_SIZE)):new Array(r.BUFFER_SIZE),this.position=0;else{if("string"==typeof t)if("undefined"!=typeof n)this.buffer=new n(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=o(t)}else this.buffer=t;this.position=t.length}}if("undefined"==typeof window)var n=t("buffer").Buffer;r.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 n&&n.isBuffer(this.buffer)){var i=new n(r.BUFFER_SIZE+this.buffer.length);this.buffer.copy(i,0,0,this.buffer.length),this.buffer=i,this.buffer[this.position++]=e}else{var i=null;i="[object Uint8Array]"==Object.prototype.toString.call(this.buffer)?new Uint8Array(new ArrayBuffer(r.BUFFER_SIZE+this.buffer.length)):new Array(r.BUFFER_SIZE+this.buffer.length);for(var o=0;o<this.buffer.length;o++)i[o]=this.buffer[o];this.buffer=i,this.buffer[this.position++]=e}},r.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 n&&n.isBuffer(this.buffer))r=new n(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 i=0;i<this.position;i++)r[i]=this.buffer[i]}this.buffer=r}if("undefined"!=typeof n&&n.isBuffer(t)&&n.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 n&&"string"==typeof t&&n.isBuffer(this.buffer))this.buffer.write(t,"binary",e),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 i=0;i<t.length;i++)this.buffer[e++]=t[i];this.position=e>this.position?e:this.position}else if("string"==typeof t){for(var i=0;i<t.length;i++)this.buffer[e++]=t.charCodeAt(i);this.position=e>this.position?e:this.position}},r.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},r.prototype.value=function(t){if(t=null==t?!1:t,t&&"undefined"!=typeof n&&n.isBuffer(this.buffer)&&this.buffer.length==this.position)return this.buffer;if("undefined"!=typeof n&&n.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 s(this.buffer,0,this.position)},r.prototype.length=function(){return this.position},r.prototype.toJSON=function(){return null!=this.buffer?this.buffer.toString("base64"):""},r.prototype.toString=function(t){return null!=this.buffer?this.buffer.slice(0,this.position).toString(t):""};var i=0,o=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},s=function(t,e,r){for(var n="",i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n};r.BUFFER_SIZE=256,r.SUBTYPE_DEFAULT=0,r.SUBTYPE_FUNCTION=1,r.SUBTYPE_BYTE_ARRAY=2,r.SUBTYPE_UUID_OLD=3,r.SUBTYPE_UUID=4,r.SUBTYPE_MD5=5,r.SUBTYPE_USER_DEFINED=128,e.exports=r,e.exports.Binary=r},{buffer:47}],57:[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?0/0: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),y=isNaN(d)||d==-1/0||d==+1/0?d:0,_=0,g=2*f+1+e+3,v=new Array(g),m=(d=0!==y?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=(_=f+1-u)>=h&&l>=_?u+1:f+1-(_=h-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((_=f+1-u)>=h&&l>=_?++u:h>_&&(_!=f+1-g&&p>_&&this.warn("encodeFloat::float underflow"),u=f+1-(_=h-1)),(b||0!==y)&&(this.warn(b?"encodeFloat::float overflow":"encodeFloat::"+y),_=l+1,u=f+2,y==-1/0?m=1:isNaN(y)&&(v[u]=1)),d=Math.abs(_+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("FWaASH"))},{FWaASH:53,util:55}],58:[function(require,module,exports){(function(Buffer){function BSON(){}function calculateElement(t,e,r){var n="undefined"!=typeof Buffer;switch(e&&e.toBSON&&(e=e.toBSON()),typeof e){case"string":return 1+(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1+4+(n?Buffer.byteLength(e,"utf8"):numberOfBytes(e))+1;case"number":return Math.floor(e)===e&&e>=BSON.JS_INT_MIN&&e<=BSON.JS_INT_MAX&&e>=BSON.BSON_INT32_MIN&&e<=BSON.BSON_INT32_MAX?(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+5:(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+9;case"undefined":return(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+1;case"boolean":return(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+2;case"object":if(null==e||e instanceof MinKey||e instanceof MaxKey||"MinKey"==e._bsontype||"MaxKey"==e._bsontype)return(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+1;if(e instanceof ObjectID||"ObjectID"==e._bsontype)return(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+13;if(e instanceof Date||isDate(e))return(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+9;if("undefined"!=typeof Buffer&&Buffer.isBuffer(e))return(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+6+e.length;if(e instanceof Long||e instanceof Double||e instanceof Timestamp||"Long"==e._bsontype||"Double"==e._bsontype||"Timestamp"==e._bsontype)return(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+9;if(e instanceof Code||"Code"==e._bsontype)return null!=e.scope&&Object.keys(e.scope).length>0?(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+1+4+4+(n?Buffer.byteLength(e.code.toString(),"utf8"):numberOfBytes(e.code.toString()))+1+BSON.calculateObjectSize(e.scope,r):(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+1+4+(n?Buffer.byteLength(e.code.toString(),"utf8"):numberOfBytes(e.code.toString()))+1;if(e instanceof Binary||"Binary"==e._bsontype)return e.sub_type==Binary.SUBTYPE_BYTE_ARRAY?(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+(e.position+1+4+1+4):(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+(e.position+1+4+1);if(e instanceof Symbol||"Symbol"==e._bsontype)return(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+((n?Buffer.byteLength(e.value,"utf8"):numberOfBytes(e.value))+4+1+1);if(e instanceof DBRef||"DBRef"==e._bsontype){var i={$ref:e.namespace,$id:e.oid};return null!=e.db&&(i.$db=e.db),(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+1+BSON.calculateObjectSize(i,r)}return e instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(e)?(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+1+(n?Buffer.byteLength(e.source,"utf8"):numberOfBytes(e.source))+1+(e.global?1:0)+(e.ignoreCase?1:0)+(e.multiline?1:0)+1:(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+BSON.calculateObjectSize(e,r)+1;case"function":if(e instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(e)||"[object RegExp]"==String.call(e))return(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+1+(n?Buffer.byteLength(e.source,"utf8"):numberOfBytes(e.source))+1+(e.global?1:0)+(e.ignoreCase?1:0)+(e.multiline?1:0)+1;if(r&&null!=e.scope&&Object.keys(e.scope).length>0)return(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+1+4+4+(n?Buffer.byteLength(e.toString(),"utf8"):numberOfBytes(e.toString()))+1+BSON.calculateObjectSize(e.scope,r);if(r)return(null!=t?(n?Buffer.byteLength(t,"utf8"):numberOfBytes(t))+1:0)+1+4+(n?Buffer.byteLength(e.toString(),"utf8"):numberOfBytes(e.toString()))+1}return 0}var 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,Binary=require("./binary").Binary,BinaryParser=require("./binary_parser").BinaryParser,writeIEEE754=require("./float_parser").writeIEEE754,readIEEE754=require("./float_parser").readIEEE754,isDate=function(t){return"object"==typeof t&&"[object Date]"===Object.prototype.toString.call(t)};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);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=6,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.calculateObjectSize=function(t,e){var r=5;if(Array.isArray(t))for(var n=0;n<t.length;n++)r+=calculateElement(n.toString(),t[n],e);else{t.toBSON&&(t=t.toBSON());for(var i in t)r+=calculateElement(i,t[i],e)}return r},BSON.serializeWithBufferAndIndex=function(t,e,r,n,i){i=null==i?!1:i;var o=r.length;return r[n++]=255&o,r[n++]=o>>8&255,r[n++]=o>>16&255,r[n++]=o>>24&255,serializeObject(t,e,r,n,i)-1};var serializeObject=function(t,e,r,n,i){if(t.toBSON){if("function"!=typeof t.toBSON)throw new Error("toBSON is not a function");if(t=t.toBSON(),null!=t&&"object"!=typeof t)throw new Error("toBSON function did not return an object")}if(Array.isArray(t))for(var o=0;o<t.length;o++)n=packElement(o.toString(),t[o],e,r,n,i);else{t.toBSON&&(t=t.toBSON());for(var s in t)"$db"!=s&&"$ref"!=s&&"$id"!=s&&BSON.checkKey(s,!e),n=packElement(s,t[s],e,r,n,i)}return r[n++]=0,n},stringToBytes=function(t){for(var e,r,n=[],i=0;i<t.length;i++){e=t.charCodeAt(i),r=[];do r.push(255&e),e>>=8;while(e);n=n.concat(r.reverse())}return n},numberOfBytes=function(t){for(var e,r,n=0,i=0;i<t.length;i++){e=t.charCodeAt(i),r=[];do r.push(255&e),e>>=8;while(e);n+=r.length}return n},writeToTypedArray=function(t,e,r){for(var n=stringToBytes(e),i=0;i<n.length;i++)t[r+i]=n[i];return n.length},supportsBuffer="undefined"!=typeof Buffer,packElement=function(t,e,r,n,i,o){e&&e.toBSON&&(e=e.toBSON());switch(typeof e){case"string":n[i++]=BSON.BSON_DATA_STRING;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);i=i+s+1,n[i-1]=0;var a=supportsBuffer?Buffer.byteLength(e)+1:numberOfBytes(e)+1;return n[i+3]=a>>24&255,n[i+2]=a>>16&255,n[i+1]=a>>8&255,n[i]=255&a,i+=4,supportsBuffer?n.write(e,i,"utf8"):writeToTypedArray(n,e,i),i=i+a-1,n[i++]=0,i;case"number":if(Math.floor(e)===e&&e>=BSON.JS_INT_MIN&&e<=BSON.JS_INT_MAX)if(e>=BSON.BSON_INT32_MIN&&e<=BSON.BSON_INT32_MAX){n[i++]=BSON.BSON_DATA_INT;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);i=i+s+1,n[i-1]=0,n[i++]=255&e,n[i++]=e>>8&255,n[i++]=e>>16&255,n[i++]=e>>24&255}else if(e>=BSON.JS_INT_MIN&&e<=BSON.JS_INT_MAX){n[i++]=BSON.BSON_DATA_NUMBER;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);i=i+s+1,n[i-1]=0,writeIEEE754(n,e,i,"little",52,8),i+=8}else{n[i++]=BSON.BSON_DATA_LONG;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);i=i+s+1,n[i-1]=0;var u=Long.fromNumber(e),c=u.getLowBits(),f=u.getHighBits();n[i++]=255&c,n[i++]=c>>8&255,n[i++]=c>>16&255,n[i++]=c>>24&255,n[i++]=255&f,n[i++]=f>>8&255,n[i++]=f>>16&255,n[i++]=f>>24&255}else{n[i++]=BSON.BSON_DATA_NUMBER;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);i=i+s+1,n[i-1]=0,writeIEEE754(n,e,i,"little",52,8),i+=8}return i;case"undefined":n[i++]=BSON.BSON_DATA_NULL;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);return i=i+s+1,n[i-1]=0,i;case"boolean":n[i++]=BSON.BSON_DATA_BOOLEAN;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);return i=i+s+1,n[i-1]=0,n[i++]=e?1:0,i;case"object":if(null===e||e instanceof MinKey||e instanceof MaxKey||"MinKey"==e._bsontype||"MaxKey"==e._bsontype){n[i++]=null===e?BSON.BSON_DATA_NULL:e instanceof MinKey?BSON.BSON_DATA_MIN_KEY:BSON.BSON_DATA_MAX_KEY;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);return i=i+s+1,n[i-1]=0,i}if(e instanceof ObjectID||"ObjectID"==e._bsontype){n[i++]=BSON.BSON_DATA_OID;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);return i=i+s+1,n[i-1]=0,supportsBuffer?n.write(e.id,i,"binary"):writeToTypedArray(n,e.id,i),i+=12}if(e instanceof Date||isDate(e)){n[i++]=BSON.BSON_DATA_DATE;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);i=i+s+1,n[i-1]=0;var h=Long.fromNumber(e.getTime()),c=h.getLowBits(),f=h.getHighBits();return n[i++]=255&c,n[i++]=c>>8&255,n[i++]=c>>16&255,n[i++]=c>>24&255,n[i++]=255&f,n[i++]=f>>8&255,n[i++]=f>>16&255,n[i++]=f>>24&255,i}if("undefined"!=typeof Buffer&&Buffer.isBuffer(e)){n[i++]=BSON.BSON_DATA_BINARY;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);i=i+s+1,n[i-1]=0;var a=e.length;return n[i++]=255&a,n[i++]=a>>8&255,n[i++]=a>>16&255,n[i++]=a>>24&255,n[i++]=BSON.BSON_BINARY_SUBTYPE_DEFAULT,e.copy(n,i,0,a),i+=a}if(e instanceof Long||e instanceof Timestamp||"Long"==e._bsontype||"Timestamp"==e._bsontype){n[i++]=e instanceof Long||"Long"==e._bsontype?BSON.BSON_DATA_LONG:BSON.BSON_DATA_TIMESTAMP;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);i=i+s+1,n[i-1]=0;var c=e.getLowBits(),f=e.getHighBits();return n[i++]=255&c,n[i++]=c>>8&255,n[i++]=c>>16&255,n[i++]=c>>24&255,n[i++]=255&f,n[i++]=f>>8&255,n[i++]=f>>16&255,n[i++]=f>>24&255,i}if(e instanceof Double||"Double"==e._bsontype){n[i++]=BSON.BSON_DATA_NUMBER;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);return i=i+s+1,n[i-1]=0,writeIEEE754(n,e,i,"little",52,8),i+=8}if(e instanceof Code||"Code"==e._bsontype){if(null!=e.scope&&Object.keys(e.scope).length>0){n[i++]=BSON.BSON_DATA_CODE_W_SCOPE;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);i=i+s+1,n[i-1]=0;var l=BSON.calculateObjectSize(e.scope,o),p=e.code.toString(),d=supportsBuffer?Buffer.byteLength(p)+1:numberOfBytes(p)+1,y=4+d+l+4;n[i++]=255&y,n[i++]=y>>8&255,n[i++]=y>>16&255,n[i++]=y>>24&255,n[i++]=255&d,n[i++]=d>>8&255,n[i++]=d>>16&255,n[i++]=d>>24&255,supportsBuffer?n.write(p,i,"utf8"):writeToTypedArray(n,p,i),i=i+d-1,n[i++]=0;var _=supportsBuffer?new Buffer(l):new Uint8Array(new ArrayBuffer(l));serializeObject(e.scope,r,_,0,o);var g=l;return n[i++]=255&g,n[i++]=g>>8&255,n[i++]=g>>16&255,n[i++]=g>>24&255,supportsBuffer?_.copy(n,i,0,l):n.set(_,i),i=i+g-5,n[i++]=0,i}n[i++]=BSON.BSON_DATA_CODE;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);i=i+s+1,n[i-1]=0;var p=e.code.toString(),a=supportsBuffer?Buffer.byteLength(p)+1:numberOfBytes(p)+1;return n[i++]=255&a,n[i++]=a>>8&255,n[i++]=a>>16&255,n[i++]=a>>24&255,supportsBuffer?n.write(p,i,"utf8"):writeToTypedArray(n,p,i),i=i+a-1,n[i++]=0,i}if(e instanceof Binary||"Binary"==e._bsontype){n[i++]=BSON.BSON_DATA_BINARY;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);i=i+s+1,n[i-1]=0;var v=e.value(!0),a=e.position;return n[i++]=255&a,n[i++]=a>>8&255,n[i++]=a>>16&255,n[i++]=a>>24&255,n[i++]=e.sub_type,e.sub_type==Binary.SUBTYPE_BYTE_ARRAY&&(n[i++]=255&a,n[i++]=a>>8&255,n[i++]=a>>16&255,n[i++]=a>>24&255),supportsBuffer?v.copy(n,i,0,e.position):n.set(v,i),i+=e.position}if(e instanceof Symbol||"Symbol"==e._bsontype){n[i++]=BSON.BSON_DATA_SYMBOL;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);i=i+s+1,n[i-1]=0;var a=supportsBuffer?Buffer.byteLength(e.value)+1:numberOfBytes(e.value)+1;return n[i++]=255&a,n[i++]=a>>8&255,n[i++]=a>>16&255,n[i++]=a>>24&255,n.write(e.value,i,"utf8"),i=i+a-1,n[i++]=0,i}if(e instanceof DBRef||"DBRef"==e._bsontype){n[i++]=BSON.BSON_DATA_OBJECT;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);i=i+s+1,n[i-1]=0;var m={$ref:e.namespace,$id:e.oid};null!=e.db&&(m.$db=e.db);var a=BSON.calculateObjectSize(m,o),b=BSON.serializeWithBufferAndIndex(m,r,n,i,o);return n[i++]=255&a,n[i++]=a>>8&255,n[i++]=a>>16&255,n[i++]=a>>24&255,n[b++]=0,b}if(e instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(e)){n[i++]=BSON.BSON_DATA_REGEXP;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);return i=i+s+1,n[i-1]=0,supportsBuffer?n.write(e.source,i,"utf8"):writeToTypedArray(n,e.source,i),i+=supportsBuffer?Buffer.byteLength(e.source):numberOfBytes(e.source),n[i++]=0,e.global&&(n[i++]=115),e.ignoreCase&&(n[i++]=105),e.multiline&&(n[i++]=109),n[i++]=0,i}n[i++]=Array.isArray(e)?BSON.BSON_DATA_ARRAY:BSON.BSON_DATA_OBJECT;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);i=i+s+1,n[i-1]=0;var b=serializeObject(e,r,n,i+4,o),a=b-i;return n[i++]=255&a,n[i++]=a>>8&255,n[i++]=a>>16&255,n[i++]=a>>24&255,b;case"function":if(e instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(e)||"[object RegExp]"==String.call(e)){n[i++]=BSON.BSON_DATA_REGEXP;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);return i=i+s+1,n[i-1]=0,n.write(e.source,i,"utf8"),i+=supportsBuffer?Buffer.byteLength(e.source):numberOfBytes(e.source),n[i++]=0,e.global&&(n[i++]=115),e.ignoreCase&&(n[i++]=105),e.multiline&&(n[i++]=109),n[i++]=0,i}if(o&&null!=e.scope&&Object.keys(e.scope).length>0){n[i++]=BSON.BSON_DATA_CODE_W_SCOPE;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);i=i+s+1,n[i-1]=0;var l=BSON.calculateObjectSize(e.scope,o),p=e.toString(),d=supportsBuffer?Buffer.byteLength(p)+1:numberOfBytes(p)+1,y=4+d+l;n[i++]=255&y,n[i++]=y>>8&255,n[i++]=y>>16&255,n[i++]=y>>24&255,n[i++]=255&d,n[i++]=d>>8&255,n[i++]=d>>16&255,n[i++]=d>>24&255,supportsBuffer?n.write(p,i,"utf8"):writeToTypedArray(n,p,i),i=i+d-1,n[i++]=0;var _=new Buffer(l);serializeObject(e.scope,r,_,0,o);var g=l-4;return n[i++]=255&g,n[i++]=g>>8&255,n[i++]=g>>16&255,n[i++]=g>>24&255,_.copy(n,i,0,l),i=i+g-5,n[i++]=0,i}if(o){n[i++]=BSON.BSON_DATA_CODE;var s=supportsBuffer?n.write(t,i,"utf8"):writeToTypedArray(n,t,i);i=i+s+1,n[i-1]=0;var p=e.toString(),a=supportsBuffer?Buffer.byteLength(p)+1:numberOfBytes(p)+1;return n[i++]=255&a,n[i++]=a>>8&255,n[i++]=a>>16&255,n[i++]=a>>24&255,supportsBuffer?n.write(p,i,"utf8"):writeToTypedArray(n,p,i),i=i+a-1,n[i++]=0,i}}return i};BSON.serialize=function(t,e,r,n){if(null==t||"object"!=typeof t||Array.isArray(t))throw new Error("Only javascript objects supported");var i=null,o=BSON.calculateObjectSize(t,n);return(i="undefined"!=typeof Buffer)?(i=new Buffer(o),r=!0):i="undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(o)):new Array(o),BSON.serializeWithBufferAndIndex(t,e,i,0,n),i};var functionCache=BSON.functionCache={},table=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],crc32=function(t,e,r){var n=0,i=0,o=0;n=-1^n;for(var s=e,a=r;a>s;s++)o=255&(n^t[s]),i=table[o],n=n>>>8^i;return-1^n};BSON.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]=BSON.deserialize(t,o),s+=u}return s};var 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},convertUint8ArrayToUtf8String=function(t,e,r){return BinaryParser.decode_utf8(convertArraytoUtf8BinaryString(t,e,r))},convertArraytoUtf8BinaryString=function(t,e,r){for(var n="",i=e;r>i;i++)n+=String.fromCharCode(t[i]);return n};BSON.deserialize=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;if(t.length<5)throw new Error("corrupt bson message < 5 bytes long");var a="number"==typeof e.index?e.index:0,u=function(){for(var e=a;0!==t[e]&&e<t.length;)e++;if(e>=t.length)throw new Error("Bad BSON Document: illegal CString");var r=supportsBuffer&&Buffer.isBuffer(t)?t.toString("utf8",a,e):convertUint8ArrayToUtf8String(t,a,e);return a=e+1,r},c=r?[]:{},f=t[a++]|t[a++]<<8|t[a++]<<16|t[a++]<<24;if(5>f||f>t.length)throw new Error("corrupt bson message");for(;;){var h=t[a++];if(0==h)break;var l=u();switch(h){case BSON.BSON_DATA_OID:var p=supportsBuffer&&Buffer.isBuffer(t)?t.toString("binary",a,a+12):convertArraytoUtf8BinaryString(t,a,a+12);c[l]=new ObjectID(p),a+=12;break;case BSON.BSON_DATA_STRING:var d=t[a++]|t[a++]<<8|t[a++]<<16|t[a++]<<24;c[l]=supportsBuffer&&Buffer.isBuffer(t)?t.toString("utf8",a,a+d-1):convertUint8ArrayToUtf8String(t,a,a+d-1),a+=d;break;case BSON.BSON_DATA_INT:c[l]=t[a++]|t[a++]<<8|t[a++]<<16|t[a++]<<24;break;case BSON.BSON_DATA_NUMBER:c[l]=readIEEE754(t,a,"little",52,8),a+=8;break;case BSON.BSON_DATA_DATE:var y=t[a++]|t[a++]<<8|t[a++]<<16|t[a++]<<24,_=t[a++]|t[a++]<<8|t[a++]<<16|t[a++]<<24;c[l]=new Date(new Long(y,_).toNumber());break;case BSON.BSON_DATA_BOOLEAN:c[l]=1==t[a++];break;case BSON.BSON_DATA_UNDEFINED:case BSON.BSON_DATA_NULL:c[l]=null;break;case BSON.BSON_DATA_BINARY:var g=t[a++]|t[a++]<<8|t[a++]<<16|t[a++]<<24,v=t[a++];if(null!=t.slice)v==Binary.SUBTYPE_BYTE_ARRAY&&(g=t[a++]|t[a++]<<8|t[a++]<<16|t[a++]<<24),c[l]=new Binary(t.slice(a,a+g),v);else{var m="undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(g)):new Array(g);v==Binary.SUBTYPE_BYTE_ARRAY&&(g=t[a++]|t[a++]<<8|t[a++]<<16|t[a++]<<24);for(var b=0;g>b;b++)m[b]=t[a+b];c[l]=new Binary(m,v)}a+=g;break;case BSON.BSON_DATA_ARRAY:e.index=a;var w=t[a]|t[a+1]<<8|t[a+2]<<16|t[a+3]<<24;c[l]=BSON.deserialize(t,e,!0),a+=w;break;case BSON.BSON_DATA_OBJECT:e.index=a;var w=t[a]|t[a+1]<<8|t[a+2]<<16|t[a+3]<<24;c[l]=BSON.deserialize(t,e,!1),a+=w;break;case BSON.BSON_DATA_REGEXP:for(var E=u(),O=u(),A=new Array(O.length),b=0;b<O.length;b++)switch(O[b]){case"m":A[b]="m";break;case"s":A[b]="g";break;case"i":A[b]="i"}c[l]=new RegExp(E,A.join(""));break;case BSON.BSON_DATA_LONG:var y=t[a++]|t[a++]<<8|t[a++]<<16|t[a++]<<24,_=t[a++]|t[a++]<<8|t[a++]<<16|t[a++]<<24,j=new Long(y,_);c[l]=s&&j.lessThanOrEqual(JS_INT_MAX_LONG)&&j.greaterThanOrEqual(JS_INT_MIN_LONG)?j.toNumber():j;break;case BSON.BSON_DATA_SYMBOL:var d=t[a++]|t[a++]<<8|t[a++]<<16|t[a++]<<24;c[l]=new Symbol(t.toString("utf8",a,a+d-1)),a+=d;break;case BSON.BSON_DATA_TIMESTAMP:var y=t[a++]|t[a++]<<8|t[a++]<<16|t[a++]<<24,_=t[a++]|t[a++]<<8|t[a++]<<16|t[a++]<<24;c[l]=new Timestamp(y,_);break;case BSON.BSON_DATA_MIN_KEY:c[l]=new MinKey;break;case BSON.BSON_DATA_MAX_KEY:c[l]=new MaxKey;break;case BSON.BSON_DATA_CODE:var d=t[a++]|t[a++]<<8|t[a++]<<16|t[a++]<<24,S=supportsBuffer&&Buffer.isBuffer(t)?t.toString("utf8",a,a+d-1):convertUint8ArrayToUtf8String(t,a,a+d-1);if(n){if(i){var B=o?crc32(S):S;c[l]=isolateEvalWithHash(functionCache,B,S,c)}else c[l]=isolateEval(S)}else c[l]=new Code(S,{});a+=d;break;case BSON.BSON_DATA_CODE_W_SCOPE:var d=(t[a++]|t[a++]<<8|t[a++]<<16|t[a++]<<24,t[a++]|t[a++]<<8|t[a++]<<16|t[a++]<<24),S=supportsBuffer&&Buffer.isBuffer(t)?t.toString("utf8",a,a+d-1):convertUint8ArrayToUtf8String(t,a,a+d-1);a+=d,e.index=a;var w=t[a]|t[a+1]<<8|t[a+2]<<16|t[a+3]<<24,x=BSON.deserialize(t,e,!1);if(a+=w,n){if(i){var B=o?crc32(S):S;c[l]=isolateEvalWithHash(functionCache,B,S,c)}else c[l]=isolateEval(S);c[l].scope=x}else c[l]=new Code(S,x)}}return null!=c.$id&&(c=new DBRef(c.$ref,c.$id,c.$db)),c},BSON.checkKey=function(t,e){if(t.length){if(~t.indexOf("\x00"))throw Error("key "+t+" must not contain null bytes");if(!e){if("$"==t[0])throw Error("key "+t+" must not start with '$'");if(~t.indexOf("."))throw Error("key "+t+" must not contain '.'")}}},BSON.prototype.deserialize=function(t,e){return BSON.deserialize(t,e)},BSON.prototype.deserializeStream=function(t,e,r,n,i,o){return BSON.deserializeStream(t,e,r,n,i,o)},BSON.prototype.serialize=function(t,e,r,n){return BSON.serialize(t,e,r,n)},BSON.prototype.calculateObjectSize=function(t,e){return BSON.calculateObjectSize(t,e)},BSON.prototype.serializeWithBufferAndIndex=function(t,e,r,n,i){return BSON.serializeWithBufferAndIndex(t,e,r,n,i)},exports.Code=Code,exports.Symbol=Symbol,exports.BSON=BSON,exports.DBRef=DBRef,exports.Binary=Binary,exports.ObjectID=ObjectID,exports.Long=Long,exports.Timestamp=Timestamp,exports.Double=Double,exports.MinKey=MinKey,exports.MaxKey=MaxKey}).call(this,require("buffer").Buffer)},{"./binary":56,"./binary_parser":57,"./code":59,"./db_ref":60,"./double":61,"./float_parser":62,"./long":63,"./max_key":64,"./min_key":65,"./objectid":66,"./symbol":67,"./timestamp":68,buffer:47}],59:[function(t,e){var r=function t(e,r){return this instanceof t?(this._bsontype="Code",this.code=e,void(this.scope=null==r?{}:r)):new t(e,r)};r.prototype.toJSON=function(){return{scope:this.scope,code:this.code}},e.exports=r,e.exports.Code=r},{}],60:[function(t,e){function r(t,e,n){return this instanceof r?(this._bsontype="DBRef",this.namespace=t,this.oid=e,void(this.db=n)):new r(t,e,n)}r.prototype.toJSON=function(){return{$ref:this.namespace,$id:this.oid,$db:null==this.db?"":this.db}},e.exports=r,e.exports.DBRef=r},{}],61:[function(t,e){function r(t){return this instanceof r?(this._bsontype="Double",void(this.value=t)):new r(t)}r.prototype.valueOf=function(){return this.value},r.prototype.toJSON=function(){return this.value},e.exports=r,e.exports.Double=r},{}],62:[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?0/0:1/0*(d?-1:1);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,y=c?-1:1,_=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(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+=y,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;t[r+d]=255&s,d+=y,s/=256,f-=8);t[r+d-y]|=128*_};r.readIEEE754=n,r.writeIEEE754=i},{}],63:[function(t,e){function r(t,e){return this instanceof r?(this._bsontype="Long",this.low_=0|t,void(this.high_=0|e)):new r(t,e)}r.prototype.toInt=function(){return this.low_},r.prototype.toNumber=function(){return this.high_*r.TWO_PWR_32_DBL_+this.getLowBitsUnsigned()},r.prototype.toJSON=function(){return this.toString()},r.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(r.MIN_VALUE)){var n=r.fromNumber(e),i=this.div(n),o=i.multiply(n).subtract(this);return i.toString(e)+o.toInt().toString(e)}return"-"+this.negate().toString(e)}for(var s=r.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}},r.prototype.getHighBits=function(){return this.high_},r.prototype.getLowBits=function(){return this.low_},r.prototype.getLowBitsUnsigned=function(){return this.low_>=0?this.low_:r.TWO_PWR_32_DBL_+this.low_},r.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(r.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},r.prototype.isZero=function(){return 0==this.high_&&0==this.low_},r.prototype.isNegative=function(){return this.high_<0},r.prototype.isOdd=function(){return 1==(1&this.low_)},r.prototype.equals=function(t){return this.high_==t.high_&&this.low_==t.low_},r.prototype.notEquals=function(t){return this.high_!=t.high_||this.low_!=t.low_},r.prototype.lessThan=function(t){return this.compare(t)<0},r.prototype.lessThanOrEqual=function(t){return this.compare(t)<=0},r.prototype.greaterThan=function(t){return this.compare(t)>0},r.prototype.greaterThanOrEqual=function(t){return this.compare(t)>=0},r.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},r.prototype.negate=function(){return this.equals(r.MIN_VALUE)?r.MIN_VALUE:this.not().add(r.ONE)},r.prototype.add=function(t){var e=this.high_>>>16,n=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+=n+a,f+=h>>>16,h&=65535,f+=e+s,f&=65535,r.fromBits(l<<16|p,f<<16|h)},r.prototype.subtract=function(t){return this.add(t.negate())},r.prototype.multiply=function(t){if(this.isZero())return r.ZERO;if(t.isZero())return r.ZERO;if(this.equals(r.MIN_VALUE))return t.isOdd()?r.MIN_VALUE:r.ZERO;if(t.equals(r.MIN_VALUE))return this.isOdd()?r.MIN_VALUE:r.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(r.TWO_PWR_24_)&&t.lessThan(r.TWO_PWR_24_))return r.fromNumber(this.toNumber()*t.toNumber());var e=this.high_>>>16,n=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+=n*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+n*u+i*a+o*s,f&=65535,r.fromBits(l<<16|p,f<<16|h)},r.prototype.div=function(t){if(t.isZero())throw Error("division by zero");if(this.isZero())return r.ZERO;if(this.equals(r.MIN_VALUE)){if(t.equals(r.ONE)||t.equals(r.NEG_ONE))return r.MIN_VALUE;if(t.equals(r.MIN_VALUE))return r.ONE;var e=this.shiftRight(1),n=e.div(t).shiftLeft(1);if(n.equals(r.ZERO))return t.isNegative()?r.ONE:r.NEG_ONE;var i=this.subtract(t.multiply(n)),o=n.add(i.div(t));return o}if(t.equals(r.MIN_VALUE))return r.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=r.ZERO,i=this;i.greaterThanOrEqual(t);){for(var n=Math.max(1,Math.floor(i.toNumber()/t.toNumber())),a=Math.ceil(Math.log(n)/Math.LN2),u=48>=a?1:Math.pow(2,a-48),c=r.fromNumber(n),f=c.multiply(t);f.isNegative()||f.greaterThan(i);)n-=u,c=r.fromNumber(n),f=c.multiply(t);c.isZero()&&(c=r.ONE),s=s.add(c),i=i.subtract(f)}return s},r.prototype.modulo=function(t){return this.subtract(this.div(t).multiply(t))},r.prototype.not=function(){return r.fromBits(~this.low_,~this.high_)},r.prototype.and=function(t){return r.fromBits(this.low_&t.low_,this.high_&t.high_)},r.prototype.or=function(t){return r.fromBits(this.low_|t.low_,this.high_|t.high_)},r.prototype.xor=function(t){return r.fromBits(this.low_^t.low_,this.high_^t.high_)},r.prototype.shiftLeft=function(t){if(t&=63,0==t)return this;var e=this.low_;if(32>t){var n=this.high_;return r.fromBits(e<<t,n<<t|e>>>32-t)}return r.fromBits(0,e<<t-32)},r.prototype.shiftRight=function(t){if(t&=63,0==t)return this;var e=this.high_;if(32>t){var n=this.low_;return r.fromBits(n>>>t|e<<32-t,e>>t)}return r.fromBits(e>>t-32,e>=0?0:-1)},r.prototype.shiftRightUnsigned=function(t){if(t&=63,0==t)return this;var e=this.high_;if(32>t){var n=this.low_;return r.fromBits(n>>>t|e<<32-t,e>>>t)}return 32==t?r.fromBits(e,0):r.fromBits(e>>>t-32,0)},r.fromInt=function(t){if(t>=-128&&128>t){var e=r.INT_CACHE_[t];if(e)return e}var n=new r(0|t,0>t?-1:0);return t>=-128&&128>t&&(r.INT_CACHE_[t]=n),n},r.fromNumber=function(t){return isNaN(t)||!isFinite(t)?r.ZERO:t<=-r.TWO_PWR_63_DBL_?r.MIN_VALUE:t+1>=r.TWO_PWR_63_DBL_?r.MAX_VALUE:0>t?r.fromNumber(-t).negate():new r(t%r.TWO_PWR_32_DBL_|0,t/r.TWO_PWR_32_DBL_|0)},r.fromBits=function(t,e){return new r(t,e)},r.fromString=function(t,e){if(0==t.length)throw Error("number format error: empty string");var n=e||10;if(2>n||n>36)throw Error("radix out of range: "+n);if("-"==t.charAt(0))return r.fromString(t.substring(1),n).negate();if(t.indexOf("-")>=0)throw Error('number format error: interior "-" character: '+t);for(var i=r.fromNumber(Math.pow(n,8)),o=r.ZERO,s=0;s<t.length;s+=8){var a=Math.min(8,t.length-s),u=parseInt(t.substring(s,s+a),n);if(8>a){var c=r.fromNumber(Math.pow(n,a));o=o.multiply(c).add(r.fromNumber(u))}else o=o.multiply(i),o=o.add(r.fromNumber(u))}return o},r.INT_CACHE_={},r.TWO_PWR_16_DBL_=65536,r.TWO_PWR_24_DBL_=1<<24,r.TWO_PWR_32_DBL_=r.TWO_PWR_16_DBL_*r.TWO_PWR_16_DBL_,r.TWO_PWR_31_DBL_=r.TWO_PWR_32_DBL_/2,r.TWO_PWR_48_DBL_=r.TWO_PWR_32_DBL_*r.TWO_PWR_16_DBL_,r.TWO_PWR_64_DBL_=r.TWO_PWR_32_DBL_*r.TWO_PWR_32_DBL_,r.TWO_PWR_63_DBL_=r.TWO_PWR_64_DBL_/2,r.ZERO=r.fromInt(0),r.ONE=r.fromInt(1),r.NEG_ONE=r.fromInt(-1),r.MAX_VALUE=r.fromBits(-1,2147483647),r.MIN_VALUE=r.fromBits(0,-2147483648),r.TWO_PWR_24_=r.fromInt(1<<24),e.exports=r,e.exports.Long=r},{}],64:[function(t,e){function r(){return this instanceof r?void(this._bsontype="MaxKey"):new r}e.exports=r,e.exports.MaxKey=r},{}],65:[function(t,e){function r(){return this instanceof r?void(this._bsontype="MinKey"):new r}e.exports=r,e.exports.MinKey=r},{}],66:[function(t,e){(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){if(null==t)return!1;var e=t instanceof s||t.toHexString?t.id: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:null!=t&&"number"!=typeof t&&12!=t.length&&24!=t.length?!1:"string"==typeof t&&24==t.length?o.test(t):!0},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":57,FWaASH:53}],67:[function(t,e){function r(t){return this instanceof r?(this._bsontype="Symbol",void(this.value=t)):new r(t)}r.prototype.valueOf=function(){return this.value},r.prototype.toString=function(){return this.value},r.prototype.inspect=function(){return this.value},r.prototype.toJSON=function(){return this.value},e.exports=r,e.exports.Symbol=r},{}],68:[function(t,e){function r(t,e){return this instanceof r?(this._bsontype="Timestamp",this.low_=0|t,void(this.high_=0|e)):new r(t,e)}r.prototype.toInt=function(){return this.low_},r.prototype.toNumber=function(){return this.high_*r.TWO_PWR_32_DBL_+this.getLowBitsUnsigned()},r.prototype.toJSON=function(){return this.toString()},r.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(r.MIN_VALUE)){var n=r.fromNumber(e),i=this.div(n),o=i.multiply(n).subtract(this);return i.toString(e)+o.toInt().toString(e)}return"-"+this.negate().toString(e)}for(var s=r.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}},r.prototype.getHighBits=function(){return this.high_},r.prototype.getLowBits=function(){return this.low_},r.prototype.getLowBitsUnsigned=function(){return this.low_>=0?this.low_:r.TWO_PWR_32_DBL_+this.low_},r.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(r.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},r.prototype.isZero=function(){return 0==this.high_&&0==this.low_},r.prototype.isNegative=function(){return this.high_<0},r.prototype.isOdd=function(){return 1==(1&this.low_)},r.prototype.equals=function(t){return this.high_==t.high_&&this.low_==t.low_},r.prototype.notEquals=function(t){return this.high_!=t.high_||this.low_!=t.low_},r.prototype.lessThan=function(t){return this.compare(t)<0},r.prototype.lessThanOrEqual=function(t){return this.compare(t)<=0},r.prototype.greaterThan=function(t){return this.compare(t)>0},r.prototype.greaterThanOrEqual=function(t){return this.compare(t)>=0},r.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},r.prototype.negate=function(){return this.equals(r.MIN_VALUE)?r.MIN_VALUE:this.not().add(r.ONE)},r.prototype.add=function(t){var e=this.high_>>>16,n=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+=n+a,f+=h>>>16,h&=65535,f+=e+s,f&=65535,r.fromBits(l<<16|p,f<<16|h)},r.prototype.subtract=function(t){return this.add(t.negate())},r.prototype.multiply=function(t){if(this.isZero())return r.ZERO;if(t.isZero())return r.ZERO;if(this.equals(r.MIN_VALUE))return t.isOdd()?r.MIN_VALUE:r.ZERO;if(t.equals(r.MIN_VALUE))return this.isOdd()?r.MIN_VALUE:r.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(r.TWO_PWR_24_)&&t.lessThan(r.TWO_PWR_24_))return r.fromNumber(this.toNumber()*t.toNumber());var e=this.high_>>>16,n=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+=n*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+n*u+i*a+o*s,f&=65535,r.fromBits(l<<16|p,f<<16|h)},r.prototype.div=function(t){if(t.isZero())throw Error("division by zero");if(this.isZero())return r.ZERO;if(this.equals(r.MIN_VALUE)){if(t.equals(r.ONE)||t.equals(r.NEG_ONE))return r.MIN_VALUE;if(t.equals(r.MIN_VALUE))return r.ONE;var e=this.shiftRight(1),n=e.div(t).shiftLeft(1);if(n.equals(r.ZERO))return t.isNegative()?r.ONE:r.NEG_ONE;var i=this.subtract(t.multiply(n)),o=n.add(i.div(t));return o}if(t.equals(r.MIN_VALUE))return r.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=r.ZERO,i=this;i.greaterThanOrEqual(t);){for(var n=Math.max(1,Math.floor(i.toNumber()/t.toNumber())),a=Math.ceil(Math.log(n)/Math.LN2),u=48>=a?1:Math.pow(2,a-48),c=r.fromNumber(n),f=c.multiply(t);f.isNegative()||f.greaterThan(i);)n-=u,c=r.fromNumber(n),f=c.multiply(t);c.isZero()&&(c=r.ONE),s=s.add(c),i=i.subtract(f)}return s},r.prototype.modulo=function(t){return this.subtract(this.div(t).multiply(t))},r.prototype.not=function(){return r.fromBits(~this.low_,~this.high_)},r.prototype.and=function(t){return r.fromBits(this.low_&t.low_,this.high_&t.high_)},r.prototype.or=function(t){return r.fromBits(this.low_|t.low_,this.high_|t.high_)},r.prototype.xor=function(t){return r.fromBits(this.low_^t.low_,this.high_^t.high_)},r.prototype.shiftLeft=function(t){if(t&=63,0==t)return this;var e=this.low_;if(32>t){var n=this.high_;return r.fromBits(e<<t,n<<t|e>>>32-t)}return r.fromBits(0,e<<t-32)},r.prototype.shiftRight=function(t){if(t&=63,0==t)return this;var e=this.high_;if(32>t){var n=this.low_;return r.fromBits(n>>>t|e<<32-t,e>>t)}return r.fromBits(e>>t-32,e>=0?0:-1)},r.prototype.shiftRightUnsigned=function(t){if(t&=63,0==t)return this;var e=this.high_;if(32>t){var n=this.low_;return r.fromBits(n>>>t|e<<32-t,e>>>t)}return 32==t?r.fromBits(e,0):r.fromBits(e>>>t-32,0)},r.fromInt=function(t){if(t>=-128&&128>t){var e=r.INT_CACHE_[t];if(e)return e}var n=new r(0|t,0>t?-1:0);return t>=-128&&128>t&&(r.INT_CACHE_[t]=n),n},r.fromNumber=function(t){return isNaN(t)||!isFinite(t)?r.ZERO:t<=-r.TWO_PWR_63_DBL_?r.MIN_VALUE:t+1>=r.TWO_PWR_63_DBL_?r.MAX_VALUE:0>t?r.fromNumber(-t).negate():new r(t%r.TWO_PWR_32_DBL_|0,t/r.TWO_PWR_32_DBL_|0)},r.fromBits=function(t,e){return new r(t,e)},r.fromString=function(t,e){if(0==t.length)throw Error("number format error: empty string");var n=e||10;if(2>n||n>36)throw Error("radix out of range: "+n);if("-"==t.charAt(0))return r.fromString(t.substring(1),n).negate();if(t.indexOf("-")>=0)throw Error('number format error: interior "-" character: '+t);for(var i=r.fromNumber(Math.pow(n,8)),o=r.ZERO,s=0;s<t.length;s+=8){var a=Math.min(8,t.length-s),u=parseInt(t.substring(s,s+a),n);if(8>a){var c=r.fromNumber(Math.pow(n,a));o=o.multiply(c).add(r.fromNumber(u))}else o=o.multiply(i),o=o.add(r.fromNumber(u))}return o},r.INT_CACHE_={},r.TWO_PWR_16_DBL_=65536,r.TWO_PWR_24_DBL_=1<<24,r.TWO_PWR_32_DBL_=r.TWO_PWR_16_DBL_*r.TWO_PWR_16_DBL_,r.TWO_PWR_31_DBL_=r.TWO_PWR_32_DBL_/2,r.TWO_PWR_48_DBL_=r.TWO_PWR_32_DBL_*r.TWO_PWR_16_DBL_,r.TWO_PWR_64_DBL_=r.TWO_PWR_32_DBL_*r.TWO_PWR_32_DBL_,r.TWO_PWR_63_DBL_=r.TWO_PWR_64_DBL_/2,r.ZERO=r.fromInt(0),r.ONE=r.fromInt(1),r.NEG_ONE=r.fromInt(-1),r.MAX_VALUE=r.fromBits(-1,2147483647),r.MIN_VALUE=r.fromBits(0,-2147483648),r.TWO_PWR_24_=r.fromInt(1<<24),e.exports=r,e.exports.Timestamp=r},{}],69:[function(t,e){function r(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,n){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||_.apply(s,o))},d=function(t){if("function"==typeof a)return a(t);if(n)return n.call(s,t);throw t},y=function(){if(arguments[0]instanceof Error)return d(arguments[0]);var t,e,n=Array.prototype.slice.call(arguments);if(!n.length||null==arguments[0]&&"function"==typeof a||(o=n),++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?[r(y),r(p)]:[r(y)]).concat(o),t.apply(s,e)}return l?void 0:_.apply(s,o)},_=function(){var t,n,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<n){if(t=c[i],t.length<1)throw new Error("Your post must have a next argument -- e.g., function (next, ...)");return e=[r(u)].concat(o),t.apply(s,e)}return"function"==typeof a?a.apply(s,arguments):void 0},"function"==typeof a&&(l[l.length-1]=r(u)),n=c.length,i=-1,t=e.apply(s,l),n&&"function"!=typeof a?u():t):void 0};return y.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)}}},{}],70:[function(t,e){(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:53}],71:[function(t,e,r){e.exports=r=t("./lib")},{"./lib":72}],72:[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 y=0;y<h.length&&y<e.length;++y)r.set(d,e[y],h[y],o,s,f);else for(var y=0;y<h.length;++y)r.set(d,e,h[y],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;y<h.length&&y<e.length;++y)_=h[y],_&&(_[o]&&(_=_[o]),_[c]=s(e[y]));else for(var y=0;y<h.length;++y)_=h[y],_&&(_[o]&&(_=_[o]),_[c]=s(e));else h[c]=s(e)}}},{}],73:[function(t,e){(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 this.onFulfill("function"==typeof t?s(r,t):r.fulfill.bind(r)),this.onReject("function"==typeof e?s(r,e):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),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:53,events:51,util:55}],74:[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},{}],75:[function(t,e){"use strict";var r=t("../env");if("unknown"==r.type)throw new Error("Unknown environment");e.exports=t(r.isNode?"./node":r.isMongo?"./collection":"./collection")},{"../env":77,"./collection":74,"./node":76}],76:[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":80,"./collection":74}],77:[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:53,buffer:47}],78:[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(n,i){r.exec(function(o,s){return r=t=e=null,o?i(o):void n(s)})});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("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)},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||(n.$set=t.$set?t.$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":75,"./collection/collection":74,"./env":77,"./permissions":79,"./utils":80,assert:46,bluebird:81,debug:82,sliced:87,util:55}],79:[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},{}],80:[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:53,buffer:47,"regexp-clone":86}],81:[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){"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){"use strict";function r(){this._isTickUsed=!1,this._lateQueue=new u(16),this._normalQueue=new u(16),this._trampolineEnabled=!0;var t=this;this.drainQueues=function(){t._drainQueues()},this._schedule=a.isStatic?a(this.drainQueues):a}function n(t,e,r){var n=this._getDomain();void 0!==n&&(t=n.bind(t)),this._lateQueue.push(t,e,r),this._queueTick()}function i(t,e,r){var n=this._getDomain();void 0!==n&&(t=n.bind(t)),this._normalQueue.push(t,e,r),this._queueTick()}function o(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 s;try{throw new Error}catch(t){s=t}var a=t("./schedule.js"),u=t("./queue.js"),c=t("./util.js");r.prototype.disableTrampolineIfNecessary=function(){c.hasDevTools&&(this._trampolineEnabled=!1)},r.prototype.enableTrampoline=function(){this._trampolineEnabled||(this._trampolineEnabled=!0,this._schedule=function(t){setTimeout(t,0)})},r.prototype.haveItemsQueued=function(){return this._normalQueue.length()>0},r.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")}},r.prototype._getDomain=function(){};c.hasDevTools?(r.prototype.invokeLater=function(t,e,r){this._trampolineEnabled?n.call(this,t,e,r):setTimeout(function(){t.call(e,r)},100)},r.prototype.invoke=function(t,e,r){this._trampolineEnabled?i.call(this,t,e,r):setTimeout(function(){t.call(e,r)},0)},r.prototype.settlePromises=function(t){this._trampolineEnabled?o.call(this,t):setTimeout(function(){t._settlePromises()},0)}):(r.prototype.invokeLater=n,r.prototype.invoke=i,r.prototype.settlePromises=o),r.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()},r.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()}},r.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._drainQueue(this._lateQueue)},r.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},r.prototype._reset=function(){this._isTickUsed=!1},e.exports=new r,e.exports.firstLineError=s},{"./queue.js":28,"./schedule.js":31,"./util.js":38,events:39}],3:[function(t,e){"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){"use strict";function r(){try{Promise===i&&(Promise=n)}catch(t){}return i}var n;"undefined"!=typeof Promise&&(n=Promise);var i=t("./promise.js")();i.noConflict=r,e.exports=i},{"./promise.js":23}],5:[function(t,e){"use strict";var r=Object.create;if(r){var n=r(null),i=r(null);n[" size"]=i[" 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){"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){"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=y.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||y.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)/,y=null,_=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+_(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 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 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||(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,y=t,_=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?(_=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):(y=t,_=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("[31m"+e+"[39m\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){"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){"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){"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=!1||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){"use strict";var r=t("./util.js"),n=r.isPrimitive,i=r.wrapsPrimitiveReceiver;e.exports=function(t){var e=function(){return this},r=function(){throw this},o=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(o):i&&n(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):i&&n(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){"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){"use strict";function r(t,e){function r(n){return this instanceof r?(f(this,"message","string"==typeof n?n:e),f(this,"name",t),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new r(n)}return c(r,Error),r}function n(t){return this instanceof n?(f(this,"name","OperationalError"),f(this,"message",t),this.cause=t,this.isOperational=!0,void(t instanceof Error?(f(this,"message",t.message),f(this,"stack",t.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new n(t)}var i,o,s=t("./es5.js"),a=s.freeze,u=t("./util.js"),c=u.inherits,f=u.notEnumerableProp,h=r("Warning","warning"),l=r("CancellationError","cancellation error"),p=r("TimeoutError","timeout error"),d=r("AggregateError","aggregate error");try{i=TypeError,o=RangeError}catch(t){i=r("TypeError","type error"),o=r("RangeError","range error")}for(var y="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),_=0;_<y.length;++_)"function"==typeof Array.prototype[y[_]]&&(d.prototype[y[_]]=Array.prototype[y[_]]);s.defineProperty(d.prototype,"length",{value:0,configurable:!1,writable:!0,enumerable:!0}),d.prototype.isOperational=!0;var g=0;d.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},c(n,Error);var v=Error.__BluebirdErrorTypes__;v||(v=a({CancellationError:l,TimeoutError:p,OperationalError:n,RejectionError:n,AggregateError:d}),f(Error,"__BluebirdErrorTypes__",v)),e.exports={Error:Error,TypeError:i,RangeError:o,CancellationError:v.CancellationError,OperationalError:v.OperationalError,TimeoutError:v.TimeoutError,AggregateError:v.AggregateError,Warning:h}},{"./es5.js":14,"./util.js":38}],14:[function(t,e){var r=function(){"use strict";return void 0===this}();if(r)e.exports={freeze:Object.freeze,defineProperty:Object.defineProperty,getDescriptor:Object.getOwnPropertyDescriptor,keys:Object.keys,names:Object.getOwnPropertyNames,getPrototypeOf:Object.getPrototypeOf,isArray:Array.isArray,isES5:r,propertyIsWritable:function(t,e){var r=Object.getOwnPropertyDescriptor(t,e);return!(r&&!r.writable&&!r.set)}};else{var n={}.hasOwnProperty,i={}.toString,o={}.constructor.prototype,s=function(t){var e=[];for(var r in t)n.call(t,r)&&e.push(r);return e},a=function(t,e){return{value:t[e]}},u=function(t,e,r){return t[e]=r.value,t},c=function(t){return t},f=function(t){try{return Object(t).constructor.prototype}catch(t){return o}},h=function(t){try{return"[object Array]"===i.call(t)}catch(t){return!1}};e.exports={isArray:h,keys:s,names:s,defineProperty:u,getDescriptor:a,freeze:c,getPrototypeOf:f,isES5:r,propertyIsWritable:function(){return!0}}}},{}],15:[function(t,e){"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){"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){"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){"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){"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 y=++this._totalResolved;y>=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){"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){"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){"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){"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),y=t("./captured_trace.js")(),_=t("./debuggability.js")(e,y),g=t("./context.js")(e,y,_),v=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 v(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(_()&&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)},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(y.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,g),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)),y.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){"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){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){"use strict";function r(t){return t instanceof Error&&l.getPrototypeOf(t)===Error.prototype}function n(t){var e;if(r(t)){e=new f(t),e.name=t.name,e.message=t.message,e.stack=t.stack;for(var n=l.keys(t),i=0;i<n.length;++i){var o=n[i];p.test(o)||(e[o]=t[o])}return e}return s.markAsOriginatingFromRejection(t),t}function i(t){return function(e,r){if(null!==t){if(e){var i=n(a(e));t._attachExtraTrace(i),t._reject(i)}else if(arguments.length>2){for(var o=arguments.length,s=new Array(o-1),u=1;o>u;++u)s[u-1]=arguments[u];t._fulfill(s)}else t._fulfill(r);t=null}}}var o,s=t("./util.js"),a=s.maybeWrapAsError,u=t("./errors.js"),c=u.TimeoutError,f=u.OperationalError,h=s.haveGetters,l=t("./es5.js"),p=/^(?:name|message|stack|cause)$/;if(o=h?function(t){this.promise=t}:function(t){this.promise=t,this.asCallback=i(t),this.callback=this.asCallback},h){var d={get:function(){return i(this.promise)}};l.defineProperty(o.prototype,"asCallback",d),l.defineProperty(o.prototype,"callback",d)}o._nodebackForPromise=i,o.prototype.toString=function(){return"[object PromiseResolver]"},o.prototype.resolve=o.prototype.fulfill=function(t){if(!(this instanceof o))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)},o.prototype.reject=function(t){if(!(this instanceof o))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)},o.prototype.progress=function(t){if(!(this instanceof o))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)},o.prototype.cancel=function(t){this.promise.cancel(t)},o.prototype.timeout=function(){this.reject(new c("timeout"))},o.prototype.isResolved=function(){return this.promise.isResolved()},o.prototype.toJSON=function(){return this.promise.toJSON()},e.exports=o},{"./errors.js":13,"./es5.js":14,"./util.js":38}],26:[function(t,e){"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 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],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,y(arguments,c))}catch(t){o._rejectCallback(_(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(O(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===A?A(c,l,c,f,e):n(f,function(){return A(c,l,c,f,e)})}return p.toFastProperties(t),t}function f(t,e){return A(t,e,void 0,t)}var h,l={},p=t("./util.js"),d=t("./promise_resolver.js")._nodebackForPromise,y=p.withAppended,_=p.maybeWrapAsError,g=p.canEvaluate,v=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)},O=function(t){return t.replace(/([$])/,"\\$")},A=g?h: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?l: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=E);var i=e.promisifier;if("function"!=typeof i&&(i=A),!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){"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){"use strict";function r(t,e,r,n,i){for(var o=0;i>o;++o)r[o+n]=t[o+e],t[o+e]=void 0}function n(t){this._capacity=t,this._length=0,this._front=0}n.prototype._willBeOverCapacity=function(t){return this._capacity<t},n.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},n.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},n.prototype.unshift=function(t,e,r){this._unshiftOne(r),this._unshiftOne(e),this._unshiftOne(t)},n.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},n.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},n.prototype.length=function(){return this._length},n.prototype._checkCapacity=function(t){this._capacity<t&&this._resizeTo(this._capacity<<1)},n.prototype._resizeTo=function(t){var e=this._capacity;this._capacity=t;var n=this._front,i=this._length,o=n+i&e-1;r(this,0,this,e,o)},e.exports=n},{}],29:[function(t,e){"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){"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,y=this._promise._boundTo,_=this._reducingIndex;s>_;++_)if(o=f[_],2!==o){if(1!==o)return;if(t=n[_],this._promise._pushContext(),u?(a.push(t),p=h(d).call(y,t,_,s)):p=h(d).call(y,this._accum,t,_,s),this._promise._popContext(),p===l)return this._reject(p.e);var g=i(p,this._promise);if(g instanceof e){if(g=g._target(),g._isPending())return f[_]=4,g._proxyPromiseArray(this,_);if(!g._isFulfilled())return this._reject(g._reason());p=g._value()}this._reducingIndex=_+1,this._accum=p}else this._reducingIndex=_+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){"use strict";var i,o=function(){throw new Error("No async scheduler available\n\n    See http://goo.gl/m3OTXk\n")};if(e("./util.js").isNode){var s=t.versions.node.split(".").map(Number);i=0===s[0]&&s[1]>10||s[0]>0?function(t){n.setImmediate(t)}:t.nextTick,i||(i="undefined"!=typeof setImmediate?setImmediate:"undefined"!=typeof setTimeout?setTimeout:o)}else"undefined"!=typeof MutationObserver?(i=function(t){var e=document.createElement("div"),r=new MutationObserver(t);return r.observe(e,{attributes:!0}),function(){e.classList.toggle("foo")}},i.isStatic=!0):i="undefined"!=typeof setImmediate?function(t){setImmediate(t)}:"undefined"!=typeof setTimeout?function(t){setTimeout(t,0)}:o;r.exports=i},{"./util.js":38}],32:[function(t,e){"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){"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(),this._resolve(1===this.howMany()&&this._unwrap?this._values[0]: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){"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){"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){"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){"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 _;return e._settledValue=t,e._bitField=268435456,u(this,e).thenReturn(t)}function f(t){var e=new _;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,y=t("./util.js").inherits,_=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},y(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 y=e.settle(s).then(o).then(function(t){y._pushContext();var e;try{e=i.apply(void 0,t)}finally{y._popContext()}return e})._then(c,f,void 0,s,void 0);return s.promise=y,y},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 B.apply(this,arguments)}catch(t){return S.e=t,S}}function o(t){return B=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 h(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 l(t){throw t}function p(t){try{if("function"==typeof t){var e=O.names(t.prototype);return O.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 y(t){return k.test(t)}function _(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{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&&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];r(o)&&O.defineProperty(e,o,O.getDescriptor(t,o))}}var O=e("./es5.js"),A="undefined"==typeof navigator,j=function(){try{var t={};return O.defineProperty(t,"f",{get:function(){return 3}}),3===t.f}catch(t){return!1}}(),S={e:{}},B,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},N=function(){return"string"!==this}.call("string"),T=function(){if(O.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=O.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(g(t))}:function(t){if(b(t))return t;try{throw new Error(g(t))}catch(t){return t}}}(),P={isClass:p,isIdentifier:y,inheritedDataKeys:T,getDataPropertyOrDefault:f,thrower:l,isArray:O.isArray,haveGetters:j,notEnumerableProp:h,isPrimitive:s,isObject:a,canEvaluate:A,errorObj:S,tryCatch:o,inherits:x,withAppended:c,maybeWrapAsError:u,wrapsPrimitiveReceiver:N,toFastProperties:d,filledRange:_,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()};try{throw new Error}catch(t){P.lastLineError=t}r.exports=P},{"./es5.js":14}],39:[function(t,e){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(t){return"function"==typeof t}function i(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(t){if(!i(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},r.prototype.emit=function(t){var e,r,i,a,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(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],s(r))return!1;if(n(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(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];r.apply(this,a)}else if(o(r)){for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];for(c=r.slice(),i=c.length,u=0;i>u;u++)c[u].apply(this,a)}return!0},r.prototype.addListener=function(t,e){var i;if(!n(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,n(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned){var i;i=s(this._maxListeners)?r.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[t].length>i&&(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},r.prototype.on=r.prototype.addListener,r.prototype.once=function(t,e){function r(){this.removeListener(t,r),i||(i=!0,e.apply(this,arguments))}if(!n(e))throw TypeError("listener must be a function");var i=!1;return r.listener=e,this.on(t,r),this},r.prototype.removeListener=function(t,e){var r,i,s,a;if(!n(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],s=r.length,i=-1,r===e||n(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(r)){for(a=s;a-->0;)if(r[a]===e||r[a].listener&&r[a].listener===e){i=a;break}if(0>i)return this;1===r.length?(r.length=0,delete this._events[t]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},r.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],n(r))this.removeListener(t,r);else for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},r.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?n(this._events[t])?[this._events[t]]:this._events[t].slice():[]},r.listenerCount=function(t,e){var r;return r=t._events&&t._events[e]?n(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:53}],82:[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":83}],83:[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:84}],84:[function(t,e){function r(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*f;case"days":case"day":case"d":return r*c;case"hours":case"hour":case"hrs":case"hr":case"h":return r*u;case"minutes":case"minute":case"mins":case"min":case"m":return r*a;case"seconds":case"second":case"secs":case"sec":case"s":return r*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}}}function n(t){return t>=c?Math.round(t/c)+"d":t>=u?Math.round(t/u)+"h":t>=a?Math.round(t/a)+"m":t>=s?Math.round(t/s)+"s":t+"ms"}function i(t){return o(t,c,"day")||o(t,u,"hour")||o(t,a,"minute")||o(t,s,"second")||t+" ms"}function o(t,e,r){return e>t?void 0:1.5*e>t?Math.floor(t/e)+" "+r:Math.ceil(t/e)+" "+r+"s"}var s=1e3,a=60*s,u=60*a,c=24*u,f=365.25*c;e.exports=function(t,e){return e=e||{},"string"==typeof t?r(t):e.long?i(t):n(t)}},{}],85:[function(t,e){!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)},{}],86:[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(""))}},{}],87:[function(t,e,r){e.exports=r=t("./lib/sliced")},{"./lib/sliced":88}],88:[function(t,e){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]);