@cloudbase/js-sdk 2.5.24-beta.0 → 2.5.26-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see database.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_database",[],e):"object"==typeof exports?exports.cloudbase_database=e():t.cloudbase_database=e()}("undefined"!=typeof window?window:this,(()=>(()=>{"use strict";var t={617:(t,e,n)=>{n.r(e),n.d(e,{CollectionReference:()=>gn,Db:()=>Un,DocumentReference:()=>$t,Query:()=>qt});var r,o,i={};n.r(i),n.d(i,{LineString:()=>z,MultiLineString:()=>nt,MultiPoint:()=>tt,MultiPolygon:()=>ot,Point:()=>Q,Polygon:()=>K}),function(t){t.DocIDError="文档ID不合法",t.CollNameError="集合名称不合法",t.OpStrError="操作符不合法",t.DirectionError="排序字符不合法",t.IntergerError="must be integer",t.QueryParamTypeError="查询参数必须为对象",t.QueryParamValueError="查询参数对象值不能均为undefined"}(o||(o={}));var u,s,a="Object",f="GeoPoint",c="GeoLineString",h="GeoPolygon",p="GeoMultiPoint",l="GeoMultiLineString",d="GeoMultiPolygon",y="Date",g="ServerDate",m=["desc","asc"],w=["<","<=","==",">=",">"];!function(t){t.lt="<",t.gt=">",t.lte="<=",t.gte=">=",t.eq="=="}(u||(u={})),(r={})[u.eq]="$eq",r[u.lt]="$lt",r[u.lte]="$lte",r[u.gt]="$gt",r[u.gte]="$gte",function(t){t.WHERE="WHERE",t.DOC="DOC"}(s||(s={}));var b,v=(b=function(t,e){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},b(t,e)},function(t,e){function n(){this.constructor=t}b(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),_=[],E={},O=function(t){function e(e,n){if(n!==E)throw new TypeError("InternalSymbol cannot be constructed with new operator");return t.call(this,e)||this}return v(e,t),e.for=function(t){for(var n=0,r=_.length;n<r;n++)if(_[n].target===t)return _[n].instance;var o=new e(t,E);return _.push({target:t,instance:o}),o},e}((function(t){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:t}})}));const N=O;var S=N.for("UNSET_FIELD_NAME"),x=N.for("UPDATE_COMMAND"),I=N.for("QUERY_COMMAND"),A=N.for("LOGIC_COMMAND"),T=N.for("GEO_POINT"),B=N.for("SYMBOL_GEO_LINE_STRING"),L=N.for("SYMBOL_GEO_POLYGON"),j=N.for("SYMBOL_GEO_MULTI_POINT"),P=N.for("SYMBOL_GEO_MULTI_LINE_STRING"),R=N.for("SYMBOL_GEO_MULTI_POLYGON"),U=N.for("SERVER_DATE"),$=N.for("REGEXP"),D=function(){function t(t){var e=(void 0===t?{}:t).offset,n=void 0===e?0:e;this.offset=n}return Object.defineProperty(t.prototype,"_internalType",{get:function(){return U},enumerable:!0,configurable:!0}),t.prototype.parse=function(){return{$date:{offset:this.offset}}},t}();function C(t){return new D(t)}var M,q=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u},k=function(){function t(){}return t.formatResDocumentData=function(e){return e.map((function(e){return t.formatField(e)}))},t.formatField=function(e){var n=Object.keys(e),r={};return Array.isArray(e)&&(r=[]),n.forEach((function(n){var o,i=e[n];switch(t.whichType(i)){case f:o=new Q(i.coordinates[0],i.coordinates[1]);break;case c:o=new z(i.coordinates.map((function(t){return new Q(t[0],t[1])})));break;case h:o=new K(i.coordinates.map((function(t){return new z(t.map((function(t){var e=q(t,2),n=e[0],r=e[1];return new Q(n,r)})))})));break;case p:o=new tt(i.coordinates.map((function(t){return new Q(t[0],t[1])})));break;case l:o=new nt(i.coordinates.map((function(t){return new z(t.map((function(t){var e=q(t,2),n=e[0],r=e[1];return new Q(n,r)})))})));break;case d:o=new ot(i.coordinates.map((function(t){return new K(t.map((function(t){return new z(t.map((function(t){var e=q(t,2),n=e[0],r=e[1];return new Q(n,r)})))})))})));break;case y:o=new Date(1e3*i.$timestamp);break;case a:case"Array":o=t.formatField(i);break;case g:o=new Date(i.$date);break;default:o=i}Array.isArray(r)?r.push(o):r[n]=o})),r},t.whichType=function(t){var e=Object.prototype.toString.call(t).slice(8,-1);if(e===y)return"BsonDate";if(e===a){if(t instanceof Q)return f;if(t instanceof Date)return y;if(t instanceof D)return g;t.$timestamp?e=y:t.$date?e=g:Q.validate(t)?e=f:z.validate(t)?e=c:K.validate(t)?e=h:tt.validate(t)?e=p:nt.validate(t)?e=l:ot.validate(t)&&(e=d)}return e},t.generateDocId=function(){for(var t="ABCDEFabcdef0123456789",e="",n=0;n<24;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e},t}(),F=function(){function t(){}return t.isGeopoint=function(t,e){if("Number"!==k.whichType(e))throw new Error("Geo Point must be number type");var n=Math.abs(e);if("latitude"===t&&n>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===t&&n>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},t.isInteger=function(t,e){if(!Number.isInteger(e))throw new Error(t+o.IntergerError);return!0},t.isFieldOrder=function(t){if(-1===m.indexOf(t))throw new Error(o.DirectionError);return!0},t.isFieldPath=function(t){if(!/^[a-zA-Z0-9-_\.]/.test(t))throw new Error;return!0},t.isOperator=function(t){if(-1===w.indexOf(t))throw new Error(o.OpStrError);return!0},t.isCollName=function(t){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(t))throw new Error(o.CollNameError);return!0},t.isDocID=function(t){if(!/^([a-fA-F0-9]){24}$/.test(t))throw new Error(o.DocIDError);return!0},t}(),J=function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},V=function(t){return"object"===J(t)},H=function(t){return"number"===J(t)},G=function(t){return Array.isArray(t)},W=function(t){return"date"===J(t)},Z=function(t){return"regexp"===J(t)},Y=function(t){return t&&t._internalType instanceof O},Q=function(){function t(t,e){F.isGeopoint("longitude",t),F.isGeopoint("latitude",e),this.longitude=t,this.latitude=e}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Point",coordinates:[this.longitude,this.latitude]},e},t.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},t.prototype.toReadableString=function(){return"["+this.longitude+","+this.latitude+"]"},t.validate=function(t){return"Point"===t.type&&G(t.coordinates)&&F.isGeopoint("longitude",t.coordinates[0])&&F.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return T},enumerable:!0,configurable:!0}),t}(),z=function(){function t(t){if(!G(t))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t);if(t.length<2)throw new Error('"points" must contain 2 points at least');t.forEach((function(t){if(!(t instanceof Q))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t+"[]")})),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"LineString",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))},e},t.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))}},t.validate=function(t){var e,n;if("LineString"!==t.type||!G(t.coordinates))return!1;try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!H(i[0])||!H(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!0},t.isClosed=function(t){var e=t.points[0],n=t.points[t.points.length-1];if(e.latitude===n.latitude&&e.longitude===n.longitude)return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return B},enumerable:!0,configurable:!0}),t}(),X=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},K=function(){function t(t){if(!G(t))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t);if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof z))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t+"[]");if(!z.isClosed(t))throw new Error("LineString "+t.points.map((function(t){return t.toReadableString()}))+" is not a closed cycle")})),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Polygon",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))},e},t.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}},t.validate=function(t){var e,n,r,o;if("Polygon"!==t.type||!G(t.coordinates))return!1;try{for(var i=X(t.coordinates),u=i.next();!u.done;u=i.next()){var s=u.value;if(!this.isCloseLineString(s))return!1;try{for(var a=(r=void 0,X(s)),f=a.next();!f.done;f=a.next()){var c=f.value;if(!H(c[0])||!H(c[1]))return!1}}catch(t){r={error:t}}finally{try{f&&!f.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},t.isCloseLineString=function(t){var e=t[0],n=t[t.length-1];return e[0]===n[0]&&e[1]===n[1]},Object.defineProperty(t.prototype,"_internalType",{get:function(){return R},enumerable:!0,configurable:!0}),t}(),tt=function(){function t(t){if(!G(t))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t);if(0===t.length)throw new Error('"points" must contain 1 point at least');t.forEach((function(t){if(!(t instanceof Q))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t+"[]")})),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPoint",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))},e},t.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))}},t.validate=function(t){var e,n;if("MultiPoint"!==t.type||!G(t.coordinates))return!1;try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(t.coordinates),o=r.next();!o.done;o=r.next()){var i=o.value;if(!H(i[0])||!H(i[1]))return!1}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return j},enumerable:!0,configurable:!0}),t}(),et=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},nt=function(){function t(t){if(!G(t))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t);if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof z))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t+"[]")})),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiLineString",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))},e},t.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}},t.validate=function(t){var e,n,r,o;if("MultiLineString"!==t.type||!G(t.coordinates))return!1;try{for(var i=et(t.coordinates),u=i.next();!u.done;u=i.next()){var s=u.value;try{for(var a=(r=void 0,et(s)),f=a.next();!f.done;f=a.next()){var c=f.value;if(!H(c[0])||!H(c[1]))return!1}}catch(t){r={error:t}}finally{try{f&&!f.done&&(o=a.return)&&o.call(a)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return P},enumerable:!0,configurable:!0}),t}(),rt=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")},ot=function(){function t(t){var e,n;if(!G(t))throw new TypeError('"polygons" must be of type Polygon[]. Received type '+typeof t);if(0===t.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var r=rt(t),o=r.next();!o.done;o=r.next()){var i=o.value;if(!(i instanceof K))throw new TypeError('"polygon" must be of type Polygon[]. Received type '+typeof i+"[]")}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}this.polygons=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPolygon",coordinates:this.polygons.map((function(t){return t.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}))},e},t.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map((function(t){return t.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}))}},t.validate=function(t){var e,n,r,o,i,u;if("MultiPolygon"!==t.type||!G(t.coordinates))return!1;try{for(var s=rt(t.coordinates),a=s.next();!a.done;a=s.next()){var f=a.value;try{for(var c=(r=void 0,rt(f)),h=c.next();!h.done;h=c.next()){var p=h.value;try{for(var l=(i=void 0,rt(p)),d=l.next();!d.done;d=l.next()){var y=d.value;if(!H(y[0])||!H(y[1]))return!1}}catch(t){i={error:t}}finally{try{d&&!d.done&&(u=l.return)&&u.call(l)}finally{if(i)throw i.error}}}}catch(t){r={error:t}}finally{try{h&&!h.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return L},enumerable:!0,configurable:!0}),t}(),it=function(){var t;if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var n=new Promise((function(e,n){t=function(t,r){return t?n(t):e(r)}}));return t.promise=n,t};!function(t){t.SET="set",t.REMOVE="remove",t.INC="inc",t.MUL="mul",t.PUSH="push",t.PULL="pull",t.PULL_ALL="pullAll",t.POP="pop",t.SHIFT="shift",t.UNSHIFT="unshift",t.ADD_TO_SET="addToSet",t.BIT="bit",t.RENAME="rename",t.MAX="max",t.MIN="min"}(M||(M={}));var ut,st=function(){function t(t,e,n){this._internalType=x,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||S}return t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t}();function at(t){return t&&t instanceof st&&t._internalType===x}!function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(ut||(ut={}));var ft=function(){function t(t,e,n){if(this._internalType=A,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||S,this.fieldName!==S)if(Array.isArray(e)){e=e.slice(),this.operands=e;for(var r=0,o=e.length;r<o;r++)(ct(i=e[r])||dt(i))&&(e[r]=i._setFieldName(this.fieldName))}else{var i;(ct(i=e)||dt(i))&&(e=i._setFieldName(this.fieldName))}}return t.prototype._setFieldName=function(e){var n=this.operands.map((function(n){return n instanceof t?n._setFieldName(e):n}));return new t(this.operator,n,e)},t.prototype.and=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new t(ut.AND,r,this.fieldName)},t.prototype.or=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return r.unshift(this),new t(ut.OR,r,this.fieldName)},t}();function ct(t){return t&&t instanceof ft&&t._internalType===A}var ht,pt=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(t){t.EQ="eq",t.NEQ="neq",t.GT="gt",t.GTE="gte",t.LT="lt",t.LTE="lte",t.IN="in",t.NIN="nin",t.ALL="all",t.ELEM_MATCH="elemMatch",t.EXISTS="exists",t.SIZE="size",t.MOD="mod",t.GEO_NEAR="geoNear",t.GEO_WITHIN="geoWithin",t.GEO_INTERSECTS="geoIntersects"}(ht||(ht={}));var lt=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o.operator=e,o._internalType=I,o}return pt(e,t),e.prototype.toJSON=function(){var t,e;switch(this.operator){case ht.IN:case ht.NIN:return(t={})["$"+this.operator]=this.operands,t;default:return(e={})["$"+this.operator]=this.operands[0],e}},e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e.prototype.eq=function(t){var n=new e(ht.EQ,[t],this.fieldName);return this.and(n)},e.prototype.neq=function(t){var n=new e(ht.NEQ,[t],this.fieldName);return this.and(n)},e.prototype.gt=function(t){var n=new e(ht.GT,[t],this.fieldName);return this.and(n)},e.prototype.gte=function(t){var n=new e(ht.GTE,[t],this.fieldName);return this.and(n)},e.prototype.lt=function(t){var n=new e(ht.LT,[t],this.fieldName);return this.and(n)},e.prototype.lte=function(t){var n=new e(ht.LTE,[t],this.fieldName);return this.and(n)},e.prototype.in=function(t){var n=new e(ht.IN,t,this.fieldName);return this.and(n)},e.prototype.nin=function(t){var n=new e(ht.NIN,t,this.fieldName);return this.and(n)},e.prototype.geoNear=function(t){if(!(t.geometry instanceof Q))throw new TypeError('"geometry" must be of type Point. Received type '+typeof t.geometry);if(void 0!==t.maxDistance&&!H(t.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof t.maxDistance);if(void 0!==t.minDistance&&!H(t.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof t.minDistance);var n=new e(ht.GEO_NEAR,[t],this.fieldName);return this.and(n)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof ot||t.geometry instanceof K))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof t.geometry);var n=new e(ht.GEO_WITHIN,[t],this.fieldName);return this.and(n)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof Q||t.geometry instanceof z||t.geometry instanceof K||t.geometry instanceof tt||t.geometry instanceof nt||t.geometry instanceof ot))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof t.geometry);var n=new e(ht.GEO_INTERSECTS,[t],this.fieldName);return this.and(n)},e}(ft);function dt(t){return t&&t instanceof lt&&t._internalType===I}function yt(t){return dt(t)}var gt={};for(var mt in ht)gt[mt]="$"+mt;for(var mt in ut)gt[mt]="$"+mt;for(var mt in M)gt[mt]="$"+mt;function wt(t){return gt[t]||"$"+t}gt[ht.NEQ]="$ne",gt[M.REMOVE]="$unset",gt[M.SHIFT]="$pop",gt[M.UNSHIFT]="$push";var bt=function(){return bt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},bt.apply(this,arguments)},vt=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u},_t=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(vt(arguments[e]));return t};function Et(t){return Ot(t,[t])}function Ot(t,e){if(!Y(t)){if(W(t))return{$date:+t};if(Z(t))return{$regex:t.source,$options:t.flags};if(G(t))return t.map((function(t){if(e.indexOf(t)>-1)throw new Error("Cannot convert circular structure to JSON");return Ot(t,_t(e,[t]))}));if(V(t)){var n=bt({},t);for(var r in n){if(e.indexOf(n[r])>-1)throw new Error("Cannot convert circular structure to JSON");n[r]=Ot(n[r],_t(e,[n[r]]))}return n}return t}switch(t._internalType){case T:return t.toJSON();case U:case $:return t.parse();default:return t.toJSON?t.toJSON():t}}var Nt=function(){return Nt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Nt.apply(this,arguments)},St=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u},xt=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(St(arguments[e]));return t};function It(t,e,n,r){var o=Nt({},t);for(var i in t)if(!/^\$/.test(i)){var u=t[i];if(u&&V(u)&&!e(u)){if(r.indexOf(u)>-1)throw new Error("Cannot convert circular structure to JSON");var s=It(u,e,xt(n,[i]),xt(r,[u]));o[i]=s;var a=!1;for(var f in s)/^\$/.test(f)?a=!0:(o[i+"."+f]=s[f],delete o[i][f]);a||delete o[i]}}return o}function At(t){return It(t,Bt,[],[t])}function Tt(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?G(t[r])?t[r].push(e[r]):V(t[r])?V(e[r])?Object.assign(t[r],e[r]):(console.warn("unmergable condition, query is object but condition is "+J(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+J(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]}function Bt(t){return Y(t)||W(t)||Z(t)}function Lt(t){return Et(t)}var jt=function(){function t(){}return t.encode=function(e){return(new t).encodeUpdate(e)},t.prototype.encodeUpdate=function(t){return at(t)?this.encodeUpdateCommand(t):"object"===J(t)?this.encodeUpdateObject(t):t},t.prototype.encodeUpdateCommand=function(t){if(t.fieldName===S)throw new Error("Cannot encode a comparison command with unset field name");switch(t.operator){case M.PUSH:case M.PULL:case M.PULL_ALL:case M.POP:case M.SHIFT:case M.UNSHIFT:case M.ADD_TO_SET:return this.encodeArrayUpdateCommand(t);default:return this.encodeFieldUpdateCommand(t)}},t.prototype.encodeFieldUpdateCommand=function(t){var e,n,r,o,i=wt(t.operator);return t.operator===M.REMOVE?((e={})[i]=((n={})[t.fieldName]="",n),e):((r={})[i]=((o={})[t.fieldName]=t.operands[0],o),r)},t.prototype.encodeArrayUpdateCommand=function(t){var e,n,r,o,i,u,s,a,f,c,h=wt(t.operator);switch(t.operator){case M.PUSH:var p=void 0;return p=G(t.operands)?{$each:t.operands.map(Lt)}:t.operands,(e={})[h]=((n={})[t.fieldName]=p,n),e;case M.UNSHIFT:return p={$each:t.operands.map(Lt),$position:0},(r={})[h]=((o={})[t.fieldName]=p,o),r;case M.POP:return(i={})[h]=((u={})[t.fieldName]=1,u),i;case M.SHIFT:return(s={})[h]=((a={})[t.fieldName]=-1,a),s;default:return(f={})[h]=((c={})[t.fieldName]=Lt(t.operands),c),f}},t.prototype.encodeUpdateObject=function(t){var e=At(t);for(var n in e)if(!/^\$/.test(n)){var r=e[n];if(at(r))e[n]=r._setFieldName(n),Tt(e,this.encodeUpdateCommand(e[n]),n);else{e[n]=r=Lt(r);var o=new st(M.SET,[r],n);Tt(e,this.encodeUpdateCommand(o),n)}}return e},t}(),Pt={};function Rt(t){if(!Un.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return Pt[e]||(Pt[e]=new Un.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new Un.reqClass(t.config)}}})),Pt[e]}for(var Ut=function(){return Ut=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ut.apply(this,arguments)},$t=function(){function t(t,e,n,r){var o=this;void 0===r&&(r={}),this.watch=function(t){return Rt(o._db).watch(Ut(Ut({},t),{envId:o._db.config.env,collectionName:o._coll,query:JSON.stringify({_id:o.id})}))},this._db=t,this._coll=e,this.id=n,this.request=new Un.reqClass(this._db.config),this.projection=r}return t.prototype.create=function(t,e){e=e||it();var n={collectionName:this._coll,data:Et(t)};return this.id&&(n._id=this.id),this.request.send("database.addDocument",n).then((function(t){t.code?e(0,t):e(0,{id:t.data._id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.set=function(t,e){if(e=e||it(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n=!1,r=function(t){if("object"==typeof t)for(var e in t)t[e]instanceof st?n=!0:"object"==typeof t[e]&&r(t[e])};if(r(t),n)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var o={collectionName:this._coll,queryType:s.DOC,data:Et(t),multi:!1,merge:!1,upsert:!0};return this.id&&(o.query={_id:this.id}),this.request.send("database.updateDocument",o).then((function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.update=function(t,e){if(e=e||it(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={_id:this.id},r={collectionName:this._coll,data:jt.encode(t),query:n,queryType:s.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",r).then((function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.remove=function(t){t=t||it();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:s.DOC,multi:!1};return this.request.send("database.deleteDocument",n).then((function(e){e.code?t(0,e):t(0,{deleted:e.data.deleted,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},t.prototype.get=function(t){t=t||it();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:s.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",n).then((function(e){if(e.code)t(0,e);else{var n=k.formatResDocumentData(e.data.list);t(0,{data:n,requestId:e.requestId,total:e.TotalCount,limit:e.Limit,offset:e.Offset})}})).catch((function(e){t(e)})),t.promise},t.prototype.field=function(e){for(var n in e)e[n]?e[n]=1:e[n]=0;return new t(this._db,this._coll,this.id,e)},t}(),Dt=function(){function t(){}return t.encode=function(t){return(new Ct).encodeQuery(t)},t}(),Ct=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var n;return Bt(t)?ct(t)?this.encodeLogicCommand(t):dt(t)?this.encodeQueryCommand(t):((n={})[e]=this.encodeQueryObject(t),n):V(t)?this.encodeQueryObject(t):t},t.prototype.encodeRegExp=function(t){return{$regex:t.source,$options:t.flags}},t.prototype.encodeLogicCommand=function(t){var e,n,r,o,i,u,s,a=this;switch(t.operator){case ut.NOR:case ut.AND:case ut.OR:var f=wt(t.operator),c=t.operands.map((function(e){return a.encodeQuery(e,t.fieldName)}));return(e={})[f]=c,e;case ut.NOT:f=wt(t.operator);var h=t.operands[0];return Z(h)?((n={})[t.fieldName]=((r={})[f]=this.encodeRegExp(h),r),n):(c=this.encodeQuery(h)[t.fieldName],(o={})[t.fieldName]=((i={})[f]=c,i),o);default:if(f=wt(t.operator),1===t.operands.length){var p=this.encodeQuery(t.operands[0]);return(u={})[f]=p,u}return c=t.operands.map(this.encodeQuery.bind(this)),(s={})[f]=c,s}},t.prototype.encodeQueryCommand=function(t){return yt(t),this.encodeComparisonCommand(t)},t.prototype.encodeComparisonCommand=function(t){var e,n,r,o,i,u,s,a,f;if(t.fieldName===S)throw new Error("Cannot encode a comparison command with unset field name");var c=wt(t.operator);switch(t.operator){case ht.EQ:case ht.NEQ:case ht.LT:case ht.LTE:case ht.GT:case ht.GTE:case ht.ELEM_MATCH:case ht.EXISTS:case ht.SIZE:case ht.MOD:return(e={})[t.fieldName]=((n={})[c]=Lt(t.operands[0]),n),e;case ht.IN:case ht.NIN:case ht.ALL:return(r={})[t.fieldName]=((o={})[c]=Lt(t.operands),o),r;case ht.GEO_NEAR:var h=t.operands[0];return(i={})[t.fieldName]={$nearSphere:{$geometry:h.geometry.toJSON(),$maxDistance:h.maxDistance,$minDistance:h.minDistance}},i;case ht.GEO_WITHIN:return h=t.operands[0],(u={})[t.fieldName]={$geoWithin:{$geometry:h.geometry.toJSON()}},u;case ht.GEO_INTERSECTS:return h=t.operands[0],(s={})[t.fieldName]={$geoIntersects:{$geometry:h.geometry.toJSON()}},s;default:return(a={})[t.fieldName]=((f={})[c]=Lt(t.operands[0]),f),a}},t.prototype.encodeQueryObject=function(t){var e=At(t);for(var n in e){var r=e[n];if(ct(r)){e[n]=r._setFieldName(n);var o=this.encodeLogicCommand(e[n]);this.mergeConditionAfterEncode(e,o,n)}else yt(r)?(e[n]=r._setFieldName(n),o=this.encodeComparisonCommand(e[n]),this.mergeConditionAfterEncode(e,o,n)):Bt(r)&&(e[n]=Lt(r))}return e},t.prototype.mergeConditionAfterEncode=function(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?G(t[r])?t[r]=t[r].concat(e[r]):V(t[r])?V(e[r])?Object.assign(t,e):(console.warn("unmergable condition, query is object but condition is "+J(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+J(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]},t}(),Mt=function(){return Mt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Mt.apply(this,arguments)},qt=function(){function t(t,e,n,r,o){var i=this;this.watch=function(t){return Rt(i._db).watch(Mt(Mt({},t),{envId:i._db.config.env,collectionName:i._coll,query:JSON.stringify(i._fieldFilters||{}),limit:i._queryOptions.limit,orderBy:i._fieldOrders?i._fieldOrders.reduce((function(t,e){return t[e.field]=e.direction,t}),{}):void 0}))},this._db=t,this._coll=e,this._fieldFilters=n,this._fieldOrders=r||[],this._queryOptions=o||{},this._request=new Un.reqClass(this._db.config)}return t.prototype.get=function(t){t=t||it();var e=[];this._fieldOrders&&this._fieldOrders.forEach((function(t){e.push(t)}));var n={collectionName:this._coll,queryType:s.WHERE};return this._fieldFilters&&(n.query=this._fieldFilters),e.length>0&&(n.order=e),this._queryOptions.offset&&(n.offset=this._queryOptions.offset),this._queryOptions.limit?n.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:n.limit=100,this._queryOptions.projection&&(n.projection=this._queryOptions.projection),this._request.send("database.queryDocument",n).then((function(e){if(e.code)t(0,e);else{var n={data:k.formatResDocumentData(e.data.list),requestId:e.requestId};e.TotalCount&&(n.total=e.TotalCount),e.Limit&&(n.limit=e.Limit),e.Offset&&(n.offset=e.Offset),t(0,n)}})).catch((function(e){t(e)})),t.promise},t.prototype.count=function(t){t=t||it();var e={collectionName:this._coll,queryType:s.WHERE};return this._fieldFilters&&(e.query=this._fieldFilters),this._request.send("database.countDocument",e).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,total:e.data.total})})).catch((function(e){t(e)})),t.promise},t.prototype.where=function(e){if("Object"!==Object.prototype.toString.call(e).slice(8,-1))throw Error(o.QueryParamTypeError);var n=Object.keys(e),r=n.some((function(t){return void 0!==e[t]}));if(n.length&&!r)throw Error(o.QueryParamValueError);return new t(this._db,this._coll,Dt.encode(e),this._fieldOrders,this._queryOptions)},t.prototype.orderBy=function(e,n){F.isFieldPath(e),F.isFieldOrder(n);var r={field:e,direction:n},o=this._fieldOrders.concat(r);return new t(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},t.prototype.limit=function(e){F.isInteger("limit",e);var n=Mt({},this._queryOptions);return n.limit=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.skip=function(e){F.isInteger("offset",e);var n=Mt({},this._queryOptions);return n.offset=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.update=function(t,e){if(e=e||it(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={collectionName:this._coll,query:this._fieldFilters,queryType:s.WHERE,multi:!0,merge:!0,upsert:!1,data:jt.encode(t)};return this._request.send("database.updateDocument",n).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,updated:t.data.updated,upsertId:t.data.upsert_id})})).catch((function(t){e(t)})),e.promise},t.prototype.field=function(e){for(var n in e)e[n]?"object"!=typeof e[n]&&(e[n]=1):e[n]=0;var r=Mt({},this._queryOptions);return r.projection=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,r)},t.prototype.remove=function(t){t=t||it(),Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation");var e={collectionName:this._coll,query:Dt.encode(this._fieldFilters),queryType:s.WHERE,multi:!0};return this._request.send("database.deleteDocument",e).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,deleted:e.data.deleted})})).catch((function(e){t(e)})),t.promise},t}(),kt=[],Ft=[],Jt="undefined"!=typeof Uint8Array?Uint8Array:Array,Vt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ht=0,Gt=Vt.length;Ht<Gt;++Ht)kt[Ht]=Vt[Ht],Ft[Vt.charCodeAt(Ht)]=Ht;function Wt(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function Zt(t,e,n){for(var r,o,i=[],u=e;u<n;u+=3)r=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(255&t[u+2]),i.push(kt[(o=r)>>18&63]+kt[o>>12&63]+kt[o>>6&63]+kt[63&o]);return i.join("")}Ft["-".charCodeAt(0)]=62,Ft["_".charCodeAt(0)]=63;var Yt=function(t){var e,n,r=Wt(t),o=r[0],i=r[1],u=new Jt(function(t,e,n){return 3*(e+n)/4-n}(0,o,i)),s=0,a=i>0?o-4:o;for(n=0;n<a;n+=4)e=Ft[t.charCodeAt(n)]<<18|Ft[t.charCodeAt(n+1)]<<12|Ft[t.charCodeAt(n+2)]<<6|Ft[t.charCodeAt(n+3)],u[s++]=e>>16&255,u[s++]=e>>8&255,u[s++]=255&e;return 2===i&&(e=Ft[t.charCodeAt(n)]<<2|Ft[t.charCodeAt(n+1)]>>4,u[s++]=255&e),1===i&&(e=Ft[t.charCodeAt(n)]<<10|Ft[t.charCodeAt(n+1)]<<4|Ft[t.charCodeAt(n+2)]>>2,u[s++]=e>>8&255,u[s++]=255&e),u},Qt=function(t){for(var e,n=t.length,r=n%3,o=[],i=16383,u=0,s=n-r;u<s;u+=i)o.push(Zt(t,u,u+i>s?s:u+i));return 1===r?(e=t[n-1],o.push(kt[e>>2]+kt[e<<4&63]+"==")):2===r&&(e=(t[n-2]<<8)+t[n-1],o.push(kt[e>>10]+kt[e>>4&63]+kt[e<<2&63]+"=")),o.join("")},zt=function(t,e,n,r,o){var i,u,s=8*o-r-1,a=(1<<s)-1,f=a>>1,c=-7,h=n?o-1:0,p=n?-1:1,l=t[e+h];for(h+=p,i=l&(1<<-c)-1,l>>=-c,c+=s;c>0;i=256*i+t[e+h],h+=p,c-=8);for(u=i&(1<<-c)-1,i>>=-c,c+=r;c>0;u=256*u+t[e+h],h+=p,c-=8);if(0===i)i=1-f;else{if(i===a)return u?NaN:1/0*(l?-1:1);u+=Math.pow(2,r),i-=f}return(l?-1:1)*u*Math.pow(2,i-r)},Xt=function(t,e,n,r,o,i){var u,s,a,f=8*i-o-1,c=(1<<f)-1,h=c>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=r?0:i-1,d=r?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,u=c):(u=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-u))<1&&(u--,a*=2),(e+=u+h>=1?p/a:p*Math.pow(2,1-h))*a>=2&&(u++,a/=2),u+h>=c?(s=0,u=c):u+h>=1?(s=(e*a-1)*Math.pow(2,o),u+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,o),u=0));o>=8;t[n+l]=255&s,l+=d,s/=256,o-=8);for(u=u<<o|s,f+=o;f>0;t[n+l]=255&u,l+=d,u/=256,f-=8);t[n+l-d]|=128*y},Kt=function(t,e){return function(t,e){var n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=i,e.SlowBuffer=function(t){return+t!=t&&(t=0),i.alloc(+t)},e.INSPECT_MAX_BYTES=50;var r=2147483647;function o(t){if(t>r)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,i.prototype),e}function i(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return a(t)}return u(t,e,n)}function u(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!i.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var n=0|p(t,e),r=o(n),u=r.write(t,e);return u!==n&&(r=r.slice(0,u)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(C(t,Uint8Array)){var e=new Uint8Array(t);return c(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(t));if(C(t,ArrayBuffer)||t&&C(t.buffer,ArrayBuffer))return c(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(C(t,SharedArrayBuffer)||t&&C(t.buffer,SharedArrayBuffer)))return c(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return i.from(r,e,n);var u=function(t){if(i.isBuffer(t)){var e=0|h(t.length),n=o(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||M(t.length)?o(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(u)return u;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return i.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(t))}function s(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function a(t){return s(t),o(t<0?0:0|h(t))}function f(t){for(var e=t.length<0?0:0|h(t.length),n=o(e),r=0;r<e;r+=1)n[r]=255&t[r];return n}function c(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,i.prototype),r}function h(t){if(t>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|t}function p(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||C(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+babelHelpers.typeof(t));var n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return U(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return $(t).length;default:if(o)return r?-1:U(t).length;e=(""+e).toLowerCase(),o=!0}}function l(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,e,n);case"utf8":case"utf-8":return O(this,e,n);case"ascii":return S(this,e,n);case"latin1":case"binary":return x(this,e,n);case"base64":return E(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function d(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function y(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),M(n=+n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=i.from(e,r)),i.isBuffer(e))return 0===e.length?-1:g(t,e,n,r,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):g(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function g(t,e,n,r,o){var i,u=1,s=t.length,a=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;u=2,s/=2,a/=2,n/=2}function f(t,e){return 1===u?t[e]:t.readUInt16BE(e*u)}if(o){var c=-1;for(i=n;i<s;i++)if(f(t,i)===f(e,-1===c?0:i-c)){if(-1===c&&(c=i),i-c+1===a)return c*u}else-1!==c&&(i-=i-c),c=-1}else for(n+a>s&&(n=s-a),i=n;i>=0;i--){for(var h=!0,p=0;p<a;p++)if(f(t,i+p)!==f(e,p)){h=!1;break}if(h)return i}return-1}function m(t,e,n,r){n=Number(n)||0;var o=t.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=e.length;r>i/2&&(r=i/2);for(var u=0;u<r;++u){var s=parseInt(e.substr(2*u,2),16);if(M(s))return u;t[n+u]=s}return u}function w(t,e,n,r){return D(U(e,t.length-n),t,n,r)}function b(t,e,n,r){return D(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function v(t,e,n,r){return D($(e),t,n,r)}function _(t,e,n,r){return D(function(t,e){for(var n,r,o,i=[],u=0;u<t.length&&!((e-=2)<0);++u)r=(n=t.charCodeAt(u))>>8,o=n%256,i.push(o),i.push(r);return i}(e,t.length-n),t,n,r)}function E(t,e,n){return 0===e&&n===t.length?Qt(t):Qt(t.slice(e,n))}function O(t,e,n){n=Math.min(t.length,n);for(var r=[],o=e;o<n;){var i,u,s,a,f=t[o],c=null,h=f>239?4:f>223?3:f>191?2:1;if(o+h<=n)switch(h){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(a=(31&f)<<6|63&i)>127&&(c=a);break;case 3:i=t[o+1],u=t[o+2],128==(192&i)&&128==(192&u)&&(a=(15&f)<<12|(63&i)<<6|63&u)>2047&&(a<55296||a>57343)&&(c=a);break;case 4:i=t[o+1],u=t[o+2],s=t[o+3],128==(192&i)&&128==(192&u)&&128==(192&s)&&(a=(15&f)<<18|(63&i)<<12|(63&u)<<6|63&s)>65535&&a<1114112&&(c=a)}null===c?(c=65533,h=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),o+=h}return function(t){var e=t.length;if(e<=N)return String.fromCharCode.apply(String,t);for(var n="",r=0;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=N));return n}(r)}e.kMaxLength=r,i.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),i.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(i.prototype,"parent",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.buffer}}),Object.defineProperty(i.prototype,"offset",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.byteOffset}}),i.poolSize=8192,i.from=function(t,e,n){return u(t,e,n)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array),i.alloc=function(t,e,n){return function(t,e,n){return s(t),t<=0?o(t):void 0!==e?"string"==typeof n?o(t).fill(e,n):o(t).fill(e):o(t)}(t,e,n)},i.allocUnsafe=function(t){return a(t)},i.allocUnsafeSlow=function(t){return a(t)},i.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==i.prototype},i.compare=function(t,e){if(C(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),C(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var n=t.length,r=e.length,o=0,u=Math.min(n,r);o<u;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return n<r?-1:r<n?1:0},i.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},i.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return i.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=i.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){var u=t[n];if(C(u,Uint8Array))o+u.length>r.length?i.from(u).copy(r,o):Uint8Array.prototype.set.call(r,u,o);else{if(!i.isBuffer(u))throw new TypeError('"list" argument must be an Array of Buffers');u.copy(r,o)}o+=u.length}return r},i.byteLength=p,i.prototype._isBuffer=!0,i.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)d(this,e,e+1);return this},i.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)d(this,e,e+3),d(this,e+1,e+2);return this},i.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)d(this,e,e+7),d(this,e+1,e+6),d(this,e+2,e+5),d(this,e+3,e+4);return this},i.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?O(this,0,t):l.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===i.compare(this,t)},i.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},n&&(i.prototype[n]=i.prototype.inspect),i.prototype.compare=function(t,e,n,r,o){if(C(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+babelHelpers.typeof(t));if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(this===t)return 0;for(var u=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(e>>>=0),a=Math.min(u,s),f=this.slice(r,o),c=t.slice(e,n),h=0;h<a;++h)if(f[h]!==c[h]){u=f[h],s=c[h];break}return u<s?-1:s<u?1:0},i.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},i.prototype.indexOf=function(t,e,n){return y(this,t,e,n,!0)},i.prototype.lastIndexOf=function(t,e,n){return y(this,t,e,n,!1)},i.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return m(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":case"latin1":case"binary":return b(this,t,e,n);case"base64":return v(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var N=4096;function S(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(127&t[o]);return r}function x(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function I(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=e;i<n;++i)o+=q[t[i]];return o}function A(t,e,n){for(var r=t.slice(e,n),o="",i=0;i<r.length-1;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function T(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function B(t,e,n,r,o,u){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<u)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function L(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function j(t,e,n,r,o){return e=+e,n>>>=0,o||L(t,0,n,4),Xt(t,e,n,r,23,4),n+4}function P(t,e,n,r,o){return e=+e,n>>>=0,o||L(t,0,n,8),Xt(t,e,n,r,52,8),n+8}i.prototype.slice=function(t,e){var n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);var r=this.subarray(t,e);return Object.setPrototypeOf(r,i.prototype),r},i.prototype.readUintLE=i.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||T(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r},i.prototype.readUintBE=i.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||T(t,e,this.length);for(var r=this[t+--e],o=1;e>0&&(o*=256);)r+=this[t+--e]*o;return r},i.prototype.readUint8=i.prototype.readUInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),this[t]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||T(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUint32BE=i.prototype.readUInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||T(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*e)),r},i.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||T(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},i.prototype.readInt8=function(t,e){return t>>>=0,e||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||T(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt16BE=function(t,e){t>>>=0,e||T(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t>>>=0,e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readFloatLE=function(t,e){return t>>>=0,e||T(t,4,this.length),zt(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||T(t,4,this.length),zt(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||T(t,8,this.length),zt(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||T(t,8,this.length),zt(this,t,!1,52,8)},i.prototype.writeUintLE=i.prototype.writeUIntLE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||B(this,t,e,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[e]=255&t;++i<n&&(o*=256);)this[e+i]=t/o&255;return e+n},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||B(this,t,e,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+n},i.prototype.writeUint8=i.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeUint16BE=i.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeUint32LE=i.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},i.prototype.writeUint32BE=i.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var o=Math.pow(2,8*n-1);B(this,t,e,n,o-1,-o)}var i=0,u=1,s=0;for(this[e]=255&t;++i<n&&(u*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/u>>0)-s&255;return e+n},i.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var o=Math.pow(2,8*n-1);B(this,t,e,n,o-1,-o)}var i=n-1,u=1,s=0;for(this[e+i]=255&t;--i>=0&&(u*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/u>>0)-s&255;return e+n},i.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},i.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeFloatLE=function(t,e,n){return j(this,t,e,!0,n)},i.prototype.writeFloatBE=function(t,e,n){return j(this,t,e,!1,n)},i.prototype.writeDoubleLE=function(t,e,n){return P(this,t,e,!0,n)},i.prototype.writeDoubleBE=function(t,e,n){return P(this,t,e,!1,n)},i.prototype.copy=function(t,e,n,r){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var o=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),o},i.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!i.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){var o=t.charCodeAt(0);("utf8"===r&&o<128||"latin1"===r)&&(t=o)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var u;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(u=e;u<n;++u)this[u]=t;else{var s=i.isBuffer(t)?t:i.from(t,r),a=s.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(u=0;u<n-e;++u)this[u+e]=s[u%a]}return this};var R=/[^+/0-9A-Za-z-_]/g;function U(t,e){var n;e=e||1/0;for(var r=t.length,o=null,i=[],u=0;u<r;++u){if((n=t.charCodeAt(u))>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(u+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function $(t){return Yt(function(t){if((t=(t=t.split("=")[0]).trim().replace(R,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function D(t,e,n,r){for(var o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function C(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function M(t){return t!=t}var q=function(){for(var t="0123456789abcdef",e=new Array(256),n=0;n<16;++n)for(var r=16*n,o=0;o<16;++o)e[r+o]=t[n]+t[o];return e}()}(e={exports:{}},e.exports),e.exports}(),te=Kt.Buffer;Kt.SlowBuffer,Kt.INSPECT_MAX_BYTES,Kt.kMaxLength;var ee=function(t,e){return ee=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},ee(t,e)};function ne(t,e){function n(){this.constructor=t}ee(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var re=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return ne(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),e}(Error),oe=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return ne(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONTypeError"},enumerable:!1,configurable:!0}),e}(TypeError);function ie(t){return t&&t.Math==Math&&t}function ue(){return ie("object"==typeof globalThis&&globalThis)||ie("object"==typeof window&&window)||ie("object"==typeof self&&self)||ie("object"==typeof n.g&&n.g)||Function("return this")()}var se=function(t){var e,n="object"==typeof(e=ue()).navigator&&"ReactNative"===e.navigator.product?"BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.":"BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.";console.warn(n);for(var r=te.alloc(t),o=0;o<t;++o)r[o]=Math.floor(256*Math.random());return r},ae=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(t&&t.getRandomValues)return function(e){return t.getRandomValues(te.alloc(e))}}return void 0!==n.g&&n.g.crypto&&n.g.crypto.getRandomValues?function(t){return n.g.crypto.getRandomValues(te.alloc(t))}:se}();function fe(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)}function ce(t){return"object"==typeof t&&null!==t}function he(t,e){var n=!1;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return n||(console.warn(e),n=!0),t.apply(this,r)}}function pe(t){if(ArrayBuffer.isView(t))return te.from(t.buffer,t.byteOffset,t.byteLength);if(e=t,["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(e)))return te.from(t);var e;throw new oe("Must use either Buffer or TypedArray")}var le=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i,de=function(t){return"string"==typeof t&&le.test(t)},ye=function(t){if(!de(t))throw new oe('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".');var e=t.replace(/-/g,"");return te.from(e,"hex")},ge=function(t,e){return void 0===e&&(e=!0),e?t.toString("hex",0,4)+"-"+t.toString("hex",4,6)+"-"+t.toString("hex",6,8)+"-"+t.toString("hex",8,10)+"-"+t.toString("hex",10,16):t.toString("hex")},me=(Math.pow(2,63),Math.pow(2,63),Math.pow(2,53)),we=-Math.pow(2,53),be=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);if(!(null==e||"string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Array.isArray(e)))throw new oe("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=null!=n?n:t.BSON_BINARY_SUBTYPE_DEFAULT,null==e?(this.buffer=te.alloc(t.BUFFER_SIZE),this.position=0):("string"==typeof e?this.buffer=te.from(e,"binary"):Array.isArray(e)?this.buffer=te.from(e):this.buffer=pe(e),this.position=this.buffer.byteLength)}return t.prototype.put=function(e){if("string"==typeof e&&1!==e.length)throw new oe("only accepts single character String");if("number"!=typeof e&&1!==e.length)throw new oe("only accepts single character Uint8Array or Array");var n;if((n="string"==typeof e?e.charCodeAt(0):"number"==typeof e?e:e[0])<0||n>255)throw new oe("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=n;else{var r=te.alloc(t.BUFFER_SIZE+this.buffer.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r,this.buffer[this.position++]=n}},t.prototype.write=function(t,e){if(e="number"==typeof e?e:this.position,this.buffer.length<e+t.length){var n=te.alloc(this.buffer.length+t.length);this.buffer.copy(n,0,0,this.buffer.length),this.buffer=n}ArrayBuffer.isView(t)?(this.buffer.set(pe(t),e),this.position=e+t.byteLength>this.position?e+t.length:this.position):"string"==typeof t&&(this.buffer.write(t,e,t.length,"binary"),this.position=e+t.length>this.position?e+t.length:this.position)},t.prototype.read=function(t,e){return e=e&&e>0?e:this.position,this.buffer.slice(t,t+e)},t.prototype.value=function(t){return(t=!!t)&&this.buffer.length===this.position?this.buffer:t?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position)},t.prototype.length=function(){return this.position},t.prototype.toJSON=function(){return this.buffer.toString("base64")},t.prototype.toString=function(t){return this.buffer.toString(t)},t.prototype.toExtendedJSON=function(t){t=t||{};var e=this.buffer.toString("base64"),n=Number(this.sub_type).toString(16);return t.legacy?{$binary:e,$type:1===n.length?"0"+n:n}:{$binary:{base64:e,subType:1===n.length?"0"+n:n}}},t.prototype.toUUID=function(){if(this.sub_type===t.SUBTYPE_UUID)return new ve(this.buffer.slice(0,this.position));throw new re('Binary sub_type "'.concat(this.sub_type,'" is not supported for converting to UUID. Only "').concat(t.SUBTYPE_UUID,'" is currently supported.'))},t.fromExtendedJSON=function(e,n){var r,o;if(n=n||{},"$binary"in e?n.legacy&&"string"==typeof e.$binary&&"$type"in e?(o=e.$type?parseInt(e.$type,16):0,r=te.from(e.$binary,"base64")):"string"!=typeof e.$binary&&(o=e.$binary.subType?parseInt(e.$binary.subType,16):0,r=te.from(e.$binary.base64,"base64")):"$uuid"in e&&(o=4,r=ye(e.$uuid)),!r)throw new oe("Unexpected Binary Extended JSON format ".concat(JSON.stringify(e)));return 4===o?new ve(r):new t(r,o)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.value(!0);return'new Binary(Buffer.from("'.concat(t.toString("hex"),'", "hex"), ').concat(this.sub_type,")")},t.BSON_BINARY_SUBTYPE_DEFAULT=0,t.BUFFER_SIZE=256,t.SUBTYPE_DEFAULT=0,t.SUBTYPE_FUNCTION=1,t.SUBTYPE_BYTE_ARRAY=2,t.SUBTYPE_UUID_OLD=3,t.SUBTYPE_UUID=4,t.SUBTYPE_MD5=5,t.SUBTYPE_ENCRYPTED=6,t.SUBTYPE_COLUMN=7,t.SUBTYPE_USER_DEFINED=128,t}();Object.defineProperty(be.prototype,"_bsontype",{value:"Binary"});var ve=function(t){function e(n){var r,o,i=this;if(null==n)r=e.generate();else if(n instanceof e)r=te.from(n.buffer),o=n.__id;else if(ArrayBuffer.isView(n)&&16===n.byteLength)r=pe(n);else{if("string"!=typeof n)throw new oe("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");r=ye(n)}return(i=t.call(this,r,4)||this).__id=o,i}return ne(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this.buffer},set:function(t){this.buffer=t,e.cacheHexString&&(this.__id=ge(t))},enumerable:!1,configurable:!0}),e.prototype.toHexString=function(t){if(void 0===t&&(t=!0),e.cacheHexString&&this.__id)return this.__id;var n=ge(this.id,t);return e.cacheHexString&&(this.__id=n),n},e.prototype.toString=function(t){return t?this.id.toString(t):this.toHexString()},e.prototype.toJSON=function(){return this.toHexString()},e.prototype.equals=function(t){if(!t)return!1;if(t instanceof e)return t.id.equals(this.id);try{return new e(t).id.equals(this.id)}catch(t){return!1}},e.prototype.toBinary=function(){return new be(this.id,be.SUBTYPE_UUID)},e.generate=function(){var t=ae(16);return t[6]=15&t[6]|64,t[8]=63&t[8]|128,te.from(t)},e.isValid=function(t){return!!t&&(t instanceof e||("string"==typeof t?de(t):!!fe(t)&&16===t.length&&64==(240&t[6])&&128==(128&t[8])))},e.createFromHexString=function(t){return new e(ye(t))},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new UUID("'.concat(this.toHexString(),'")')},e}(be),_e=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);this.code=e,this.scope=n}return t.prototype.toJSON=function(){return{code:this.code,scope:this.scope}},t.prototype.toExtendedJSON=function(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}},t.fromExtendedJSON=function(e){return new t(e.$code,e.$scope)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.toJSON();return'new Code("'.concat(String(t.code),'"').concat(t.scope?", ".concat(JSON.stringify(t.scope)):"",")")},t}();Object.defineProperty(_e.prototype,"_bsontype",{value:"Code"});var Ee=function(){function t(e,n,r,o){if(!(this instanceof t))return new t(e,n,r,o);var i=e.split(".");2===i.length&&(r=i.shift(),e=i.shift()),this.collection=e,this.oid=n,this.db=r,this.fields=o||{}}return Object.defineProperty(t.prototype,"namespace",{get:function(){return this.collection},set:function(t){this.collection=t},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){var t=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(t.$db=this.db),t},t.prototype.toExtendedJSON=function(t){t=t||{};var e={$ref:this.collection,$id:this.oid};return t.legacy?e:(this.db&&(e.$db=this.db),e=Object.assign(e,this.fields))},t.fromExtendedJSON=function(e){var n=Object.assign({},e);return delete n.$ref,delete n.$id,delete n.$db,new t(e.$ref,e.$id,e.$db,n)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=void 0===this.oid||void 0===this.oid.toString?this.oid:this.oid.toString();return'new DBRef("'.concat(this.namespace,'", new ObjectId("').concat(String(t),'")').concat(this.db?', "'.concat(this.db,'"'):"",")")},t}();Object.defineProperty(Ee.prototype,"_bsontype",{value:"DBRef"});var Oe=void 0;try{Oe=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(r){}var Ne=4294967296,Se=0x10000000000000000,xe=Se/2,Ie={},Ae={},Te=function(){function t(e,n,r){if(void 0===e&&(e=0),!(this instanceof t))return new t(e,n,r);"bigint"==typeof e?Object.assign(this,t.fromBigInt(e,!!n)):"string"==typeof e?Object.assign(this,t.fromString(e,!!n)):(this.low=0|e,this.high=0|n,this.unsigned=!!r),Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}return t.fromBits=function(e,n,r){return new t(e,n,r)},t.fromInt=function(e,n){var r,o,i;return n?(i=0<=(e>>>=0)&&e<256)&&(o=Ae[e])?o:(r=t.fromBits(e,(0|e)<0?-1:0,!0),i&&(Ae[e]=r),r):(i=-128<=(e|=0)&&e<128)&&(o=Ie[e])?o:(r=t.fromBits(e,e<0?-1:0,!1),i&&(Ie[e]=r),r)},t.fromNumber=function(e,n){if(isNaN(e))return n?t.UZERO:t.ZERO;if(n){if(e<0)return t.UZERO;if(e>=Se)return t.MAX_UNSIGNED_VALUE}else{if(e<=-xe)return t.MIN_VALUE;if(e+1>=xe)return t.MAX_VALUE}return e<0?t.fromNumber(-e,n).neg():t.fromBits(e%Ne|0,e/Ne|0,n)},t.fromBigInt=function(e,n){return t.fromString(e.toString(),n)},t.fromString=function(e,n,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t.ZERO;if("number"==typeof n?(r=n,n=!1):n=!!n,(r=r||10)<2||36<r)throw RangeError("radix");var o;if((o=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===o)return t.fromString(e.substring(1),n,r).neg();for(var i=t.fromNumber(Math.pow(r,8)),u=t.ZERO,s=0;s<e.length;s+=8){var a=Math.min(8,e.length-s),f=parseInt(e.substring(s,s+a),r);if(a<8){var c=t.fromNumber(Math.pow(r,a));u=u.mul(c).add(t.fromNumber(f))}else u=(u=u.mul(i)).add(t.fromNumber(f))}return u.unsigned=n,u},t.fromBytes=function(e,n,r){return r?t.fromBytesLE(e,n):t.fromBytesBE(e,n)},t.fromBytesLE=function(e,n){return new t(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)},t.fromBytesBE=function(e,n){return new t(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)},t.isLong=function(t){return ce(t)&&!0===t.__isLong__},t.fromValue=function(e,n){return"number"==typeof e?t.fromNumber(e,n):"string"==typeof e?t.fromString(e,n):t.fromBits(e.low,e.high,"boolean"==typeof n?n:e.unsigned)},t.prototype.add=function(e){t.isLong(e)||(e=t.fromValue(e));var n=this.high>>>16,r=65535&this.high,o=this.low>>>16,i=65535&this.low,u=e.high>>>16,s=65535&e.high,a=e.low>>>16,f=0,c=0,h=0,p=0;return h+=(p+=i+(65535&e.low))>>>16,p&=65535,c+=(h+=o+a)>>>16,h&=65535,f+=(c+=r+s)>>>16,c&=65535,f+=n+u,f&=65535,t.fromBits(h<<16|p,f<<16|c,this.unsigned)},t.prototype.and=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low&e.low,this.high&e.high,this.unsigned)},t.prototype.compare=function(e){if(t.isLong(e)||(e=t.fromValue(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},t.prototype.comp=function(t){return this.compare(t)},t.prototype.divide=function(e){if(t.isLong(e)||(e=t.fromValue(e)),e.isZero())throw Error("division by zero");if(Oe){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;var n=(this.unsigned?Oe.div_u:Oe.div_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,Oe.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?t.UZERO:t.ZERO;var r,o,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return t.UZERO;if(e.gt(this.shru(1)))return t.UONE;i=t.UZERO}else{if(this.eq(t.MIN_VALUE))return e.eq(t.ONE)||e.eq(t.NEG_ONE)?t.MIN_VALUE:e.eq(t.MIN_VALUE)?t.ONE:(r=this.shr(1).div(e).shl(1)).eq(t.ZERO)?e.isNegative()?t.ONE:t.NEG_ONE:(o=this.sub(e.mul(r)),i=r.add(o.div(e)));if(e.eq(t.MIN_VALUE))return this.unsigned?t.UZERO:t.ZERO;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=t.ZERO}for(o=this;o.gte(e);){r=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var u=Math.ceil(Math.log(r)/Math.LN2),s=u<=48?1:Math.pow(2,u-48),a=t.fromNumber(r),f=a.mul(e);f.isNegative()||f.gt(o);)r-=s,f=(a=t.fromNumber(r,this.unsigned)).mul(e);a.isZero()&&(a=t.ONE),i=i.add(a),o=o.sub(f)}return i},t.prototype.div=function(t){return this.divide(t)},t.prototype.equals=function(e){return t.isLong(e)||(e=t.fromValue(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},t.prototype.eq=function(t){return this.equals(t)},t.prototype.getHighBits=function(){return this.high},t.prototype.getHighBitsUnsigned=function(){return this.high>>>0},t.prototype.getLowBits=function(){return this.low},t.prototype.getLowBitsUnsigned=function(){return this.low>>>0},t.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(t.MIN_VALUE)?64:this.neg().getNumBitsAbs();var e,n=0!==this.high?this.high:this.low;for(e=31;e>0&&0==(n&1<<e);e--);return 0!==this.high?e+33:e+1},t.prototype.greaterThan=function(t){return this.comp(t)>0},t.prototype.gt=function(t){return this.greaterThan(t)},t.prototype.greaterThanOrEqual=function(t){return this.comp(t)>=0},t.prototype.gte=function(t){return this.greaterThanOrEqual(t)},t.prototype.ge=function(t){return this.greaterThanOrEqual(t)},t.prototype.isEven=function(){return 0==(1&this.low)},t.prototype.isNegative=function(){return!this.unsigned&&this.high<0},t.prototype.isOdd=function(){return 1==(1&this.low)},t.prototype.isPositive=function(){return this.unsigned||this.high>=0},t.prototype.isZero=function(){return 0===this.high&&0===this.low},t.prototype.lessThan=function(t){return this.comp(t)<0},t.prototype.lt=function(t){return this.lessThan(t)},t.prototype.lessThanOrEqual=function(t){return this.comp(t)<=0},t.prototype.lte=function(t){return this.lessThanOrEqual(t)},t.prototype.modulo=function(e){if(t.isLong(e)||(e=t.fromValue(e)),Oe){var n=(this.unsigned?Oe.rem_u:Oe.rem_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,Oe.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))},t.prototype.mod=function(t){return this.modulo(t)},t.prototype.rem=function(t){return this.modulo(t)},t.prototype.multiply=function(e){if(this.isZero())return t.ZERO;if(t.isLong(e)||(e=t.fromValue(e)),Oe){var n=Oe.mul(this.low,this.high,e.low,e.high);return t.fromBits(n,Oe.get_high(),this.unsigned)}if(e.isZero())return t.ZERO;if(this.eq(t.MIN_VALUE))return e.isOdd()?t.MIN_VALUE:t.ZERO;if(e.eq(t.MIN_VALUE))return this.isOdd()?t.MIN_VALUE:t.ZERO;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(t.TWO_PWR_24)&&e.lt(t.TWO_PWR_24))return t.fromNumber(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,o=65535&this.high,i=this.low>>>16,u=65535&this.low,s=e.high>>>16,a=65535&e.high,f=e.low>>>16,c=65535&e.low,h=0,p=0,l=0,d=0;return l+=(d+=u*c)>>>16,d&=65535,p+=(l+=i*c)>>>16,l&=65535,p+=(l+=u*f)>>>16,l&=65535,h+=(p+=o*c)>>>16,p&=65535,h+=(p+=i*f)>>>16,p&=65535,h+=(p+=u*a)>>>16,p&=65535,h+=r*c+o*f+i*a+u*s,h&=65535,t.fromBits(l<<16|d,h<<16|p,this.unsigned)},t.prototype.mul=function(t){return this.multiply(t)},t.prototype.negate=function(){return!this.unsigned&&this.eq(t.MIN_VALUE)?t.MIN_VALUE:this.not().add(t.ONE)},t.prototype.neg=function(){return this.negate()},t.prototype.not=function(){return t.fromBits(~this.low,~this.high,this.unsigned)},t.prototype.notEquals=function(t){return!this.equals(t)},t.prototype.neq=function(t){return this.notEquals(t)},t.prototype.ne=function(t){return this.notEquals(t)},t.prototype.or=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low|e.low,this.high|e.high,this.unsigned)},t.prototype.shiftLeft=function(e){return t.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?t.fromBits(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):t.fromBits(0,this.low<<e-32,this.unsigned)},t.prototype.shl=function(t){return this.shiftLeft(t)},t.prototype.shiftRight=function(e){return t.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?t.fromBits(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):t.fromBits(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},t.prototype.shr=function(t){return this.shiftRight(t)},t.prototype.shiftRightUnsigned=function(e){if(t.isLong(e)&&(e=e.toInt()),0==(e&=63))return this;var n=this.high;if(e<32){var r=this.low;return t.fromBits(r>>>e|n<<32-e,n>>>e,this.unsigned)}return 32===e?t.fromBits(n,0,this.unsigned):t.fromBits(n>>>e-32,0,this.unsigned)},t.prototype.shr_u=function(t){return this.shiftRightUnsigned(t)},t.prototype.shru=function(t){return this.shiftRightUnsigned(t)},t.prototype.subtract=function(e){return t.isLong(e)||(e=t.fromValue(e)),this.add(e.neg())},t.prototype.sub=function(t){return this.subtract(t)},t.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},t.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*Ne+(this.low>>>0):this.high*Ne+(this.low>>>0)},t.prototype.toBigInt=function(){return BigInt(this.toString())},t.prototype.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},t.prototype.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},t.prototype.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,e>>>24,e>>>16&255,e>>>8&255,255&e]},t.prototype.toSigned=function(){return this.unsigned?t.fromBits(this.low,this.high,!1):this},t.prototype.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(t.MIN_VALUE)){var n=t.fromNumber(e),r=this.div(n),o=r.mul(n).sub(this);return r.toString(e)+o.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=t.fromNumber(Math.pow(e,6),this.unsigned),u=this,s="";;){var a=u.div(i),f=(u.sub(a.mul(i)).toInt()>>>0).toString(e);if((u=a).isZero())return f+s;for(;f.length<6;)f="0"+f;s=""+f+s}},t.prototype.toUnsigned=function(){return this.unsigned?this:t.fromBits(this.low,this.high,!0)},t.prototype.xor=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low^e.low,this.high^e.high,this.unsigned)},t.prototype.eqz=function(){return this.isZero()},t.prototype.le=function(t){return this.lessThanOrEqual(t)},t.prototype.toExtendedJSON=function(t){return t&&t.relaxed?this.toNumber():{$numberLong:this.toString()}},t.fromExtendedJSON=function(e,n){var r=t.fromString(e.$numberLong);return n&&n.relaxed?r.toNumber():r},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new Long("'.concat(this.toString(),'"').concat(this.unsigned?", true":"",")")},t.TWO_PWR_24=t.fromInt(16777216),t.MAX_UNSIGNED_VALUE=t.fromBits(-1,-1,!0),t.ZERO=t.fromInt(0),t.UZERO=t.fromInt(0,!0),t.ONE=t.fromInt(1),t.UONE=t.fromInt(1,!0),t.NEG_ONE=t.fromInt(-1),t.MAX_VALUE=t.fromBits(-1,2147483647,!1),t.MIN_VALUE=t.fromBits(0,-2147483648,!1),t}();Object.defineProperty(Te.prototype,"__isLong__",{value:!0}),Object.defineProperty(Te.prototype,"_bsontype",{value:"Long"});var Be=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,Le=/^(\+|-)?(Infinity|inf)$/i,je=/^(\+|-)?NaN$/i,Pe=6111,Re=-6176,Ue=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),$e=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),De=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),Ce=/^([-+])?(\d+)?$/;function Me(t){return!isNaN(parseInt(t,10))}function qe(t){var e=Te.fromNumber(1e9),n=Te.fromNumber(0);if(!(t.parts[0]||t.parts[1]||t.parts[2]||t.parts[3]))return{quotient:t,rem:n};for(var r=0;r<=3;r++)n=(n=n.shiftLeft(32)).add(new Te(t.parts[r],0)),t.parts[r]=n.div(e).low,n=n.modulo(e);return{quotient:t,rem:n}}function ke(t,e){throw new oe('"'.concat(t,'" is not a valid Decimal128 string - ').concat(e))}var Fe=function(){function t(e){if(!(this instanceof t))return new t(e);if("string"==typeof e)this.bytes=t.fromString(e).bytes;else{if(!fe(e))throw new oe("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new oe("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}return t.fromString=function(e){var n,r=!1,o=!1,i=!1,u=0,s=0,a=0,f=0,c=0,h=[0],p=0,l=0,d=0,y=0,g=0,m=0,w=new Te(0,0),b=new Te(0,0),v=0;if(e.length>=7e3)throw new oe(e+" not a valid Decimal128 string");var _=e.match(Be),E=e.match(Le),O=e.match(je);if(!_&&!E&&!O||0===e.length)throw new oe(e+" not a valid Decimal128 string");if(_){var N=_[2],S=_[4],x=_[5],I=_[6];S&&void 0===I&&ke(e,"missing exponent power"),S&&void 0===N&&ke(e,"missing exponent base"),void 0===S&&(x||I)&&ke(e,"missing e before exponent")}if("+"!==e[v]&&"-"!==e[v]||(r="-"===e[v++]),!Me(e[v])&&"."!==e[v]){if("i"===e[v]||"I"===e[v])return new t(te.from(r?$e:De));if("N"===e[v])return new t(te.from(Ue))}for(;Me(e[v])||"."===e[v];)"."!==e[v]?(p<34&&("0"!==e[v]||i)&&(i||(c=s),i=!0,h[l++]=parseInt(e[v],10),p+=1),i&&(a+=1),o&&(f+=1),s+=1,v+=1):(o&&ke(e,"contains multiple periods"),o=!0,v+=1);if(o&&!s)throw new oe(e+" not a valid Decimal128 string");if("e"===e[v]||"E"===e[v]){var A=e.substr(++v).match(Ce);if(!A||!A[2])return new t(te.from(Ue));g=parseInt(A[0],10),v+=A[0].length}if(e[v])return new t(te.from(Ue));if(d=0,p){if(y=p-1,1!==(u=a))for(;0===h[c+u-1];)u-=1}else d=0,y=0,h[0]=0,a=1,p=1,u=0;for(g<=f&&f-g>16384?g=Re:g-=f;g>Pe;){if((y+=1)-d>34){if(h.join("").match(/^0+$/)){g=Pe;break}ke(e,"overflow")}g-=1}for(;g<Re||p<a;){if(0===y&&u<p){g=Re,u=0;break}if(p<a?a-=1:y-=1,g<Pe)g+=1;else{if(h.join("").match(/^0+$/)){g=Pe;break}ke(e,"overflow")}}if(y-d+1<u){var T=s;o&&(c+=1,T+=1),r&&(c+=1,T+=1);var B=parseInt(e[c+y+1],10),L=0;if(B>=5&&(L=1,5===B))for(L=h[y]%2==1?1:0,m=c+y+2;m<T;m++)if(parseInt(e[m],10)){L=1;break}if(L)for(var j=y;j>=0;j--)if(++h[j]>9&&(h[j]=0,0===j)){if(!(g<Pe))return new t(te.from(r?$e:De));g+=1,h[j]=1}}if(w=Te.fromNumber(0),b=Te.fromNumber(0),0===u)w=Te.fromNumber(0),b=Te.fromNumber(0);else if(y-d<17)for(j=d,b=Te.fromNumber(h[j++]),w=new Te(0,0);j<=y;j++)b=(b=b.multiply(Te.fromNumber(10))).add(Te.fromNumber(h[j]));else{for(j=d,w=Te.fromNumber(h[j++]);j<=y-17;j++)w=(w=w.multiply(Te.fromNumber(10))).add(Te.fromNumber(h[j]));for(b=Te.fromNumber(h[j++]);j<=y;j++)b=(b=b.multiply(Te.fromNumber(10))).add(Te.fromNumber(h[j]))}var P,R,U,$,D=function(t,e){if(!t&&!e)return{high:Te.fromNumber(0),low:Te.fromNumber(0)};var n=t.shiftRightUnsigned(32),r=new Te(t.getLowBits(),0),o=e.shiftRightUnsigned(32),i=new Te(e.getLowBits(),0),u=n.multiply(o),s=n.multiply(i),a=r.multiply(o),f=r.multiply(i);return u=u.add(s.shiftRightUnsigned(32)),s=new Te(s.getLowBits(),0).add(a).add(f.shiftRightUnsigned(32)),{high:u=u.add(s.shiftRightUnsigned(32)),low:f=s.shiftLeft(32).add(new Te(f.getLowBits(),0))}}(w,Te.fromString("100000000000000000"));D.low=D.low.add(b),R=b,((U=(P=D.low).high>>>0)<($=R.high>>>0)||U===$&&P.low>>>0<R.low>>>0)&&(D.high=D.high.add(Te.fromNumber(1))),n=g+6176;var C={low:Te.fromNumber(0),high:Te.fromNumber(0)};D.high.shiftRightUnsigned(49).and(Te.fromNumber(1)).equals(Te.fromNumber(1))?(C.high=C.high.or(Te.fromNumber(3).shiftLeft(61)),C.high=C.high.or(Te.fromNumber(n).and(Te.fromNumber(16383).shiftLeft(47))),C.high=C.high.or(D.high.and(Te.fromNumber(0x7fffffffffff)))):(C.high=C.high.or(Te.fromNumber(16383&n).shiftLeft(49)),C.high=C.high.or(D.high.and(Te.fromNumber(562949953421311)))),C.low=D.low,r&&(C.high=C.high.or(Te.fromString("9223372036854775808")));var M=te.alloc(16);return v=0,M[v++]=255&C.low.low,M[v++]=C.low.low>>8&255,M[v++]=C.low.low>>16&255,M[v++]=C.low.low>>24&255,M[v++]=255&C.low.high,M[v++]=C.low.high>>8&255,M[v++]=C.low.high>>16&255,M[v++]=C.low.high>>24&255,M[v++]=255&C.high.low,M[v++]=C.high.low>>8&255,M[v++]=C.high.low>>16&255,M[v++]=C.high.low>>24&255,M[v++]=255&C.high.high,M[v++]=C.high.high>>8&255,M[v++]=C.high.high>>16&255,M[v++]=C.high.high>>24&255,new t(M)},t.prototype.toString=function(){for(var t,e=0,n=new Array(36),r=0;r<n.length;r++)n[r]=0;var o,i,u,s=0,a=!1,f={parts:[0,0,0,0]},c=[];s=0;var h=this.bytes,p=h[s++]|h[s++]<<8|h[s++]<<16|h[s++]<<24,l=h[s++]|h[s++]<<8|h[s++]<<16|h[s++]<<24,d=h[s++]|h[s++]<<8|h[s++]<<16|h[s++]<<24,y=h[s++]|h[s++]<<8|h[s++]<<16|h[s++]<<24;s=0,(new Te(p,l),new Te(d,y)).lessThan(Te.ZERO)&&c.push("-");var g=y>>26&31;if(g>>3==3){if(30===g)return c.join("")+"Infinity";if(31===g)return"NaN";t=y>>15&16383,o=8+(y>>14&1)}else o=y>>14&7,t=y>>17&16383;var m=t-6176;if(f.parts[0]=(16383&y)+((15&o)<<14),f.parts[1]=d,f.parts[2]=l,f.parts[3]=p,0===f.parts[0]&&0===f.parts[1]&&0===f.parts[2]&&0===f.parts[3])a=!0;else for(u=3;u>=0;u--){var w=0,b=qe(f);if(f=b.quotient,w=b.rem.low)for(i=8;i>=0;i--)n[9*u+i]=w%10,w=Math.floor(w/10)}if(a)e=1,n[s]=0;else for(e=36;!n[s];)e-=1,s+=1;var v=e-1+m;if(v>=34||v<=-7||m>0){if(e>34)return c.push("".concat(0)),m>0?c.push("E+".concat(m)):m<0&&c.push("E".concat(m)),c.join("");for(c.push("".concat(n[s++])),(e-=1)&&c.push("."),r=0;r<e;r++)c.push("".concat(n[s++]));c.push("E"),v>0?c.push("+".concat(v)):c.push("".concat(v))}else if(m>=0)for(r=0;r<e;r++)c.push("".concat(n[s++]));else{var _=e+m;if(_>0)for(r=0;r<_;r++)c.push("".concat(n[s++]));else c.push("0");for(c.push(".");_++<0;)c.push("0");for(r=0;r<e-Math.max(_-1,0);r++)c.push("".concat(n[s++]))}return c.join("")},t.prototype.toJSON=function(){return{$numberDecimal:this.toString()}},t.prototype.toExtendedJSON=function(){return{$numberDecimal:this.toString()}},t.fromExtendedJSON=function(e){return t.fromString(e.$numberDecimal)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new Decimal128("'.concat(this.toString(),'")')},t}();Object.defineProperty(Fe.prototype,"_bsontype",{value:"Decimal128"});var Je=function(){function t(e){if(!(this instanceof t))return new t(e);e instanceof Number&&(e=e.valueOf()),this.value=+e}return t.prototype.valueOf=function(){return this.value},t.prototype.toJSON=function(){return this.value},t.prototype.toString=function(t){return this.value.toString(t)},t.prototype.toExtendedJSON=function(t){return t&&(t.legacy||t.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-".concat(this.value.toFixed(1))}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}},t.fromExtendedJSON=function(e,n){var r=parseFloat(e.$numberDouble);return n&&n.relaxed?r:new t(r)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.toExtendedJSON();return"new Double(".concat(t.$numberDouble,")")},t}();Object.defineProperty(Je.prototype,"_bsontype",{value:"Double"});var Ve=function(){function t(e){if(!(this instanceof t))return new t(e);e instanceof Number&&(e=e.valueOf()),this.value=0|+e}return t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(t){return this.value.toString(t)},t.prototype.toJSON=function(){return this.value},t.prototype.toExtendedJSON=function(t){return t&&(t.relaxed||t.legacy)?this.value:{$numberInt:this.value.toString()}},t.fromExtendedJSON=function(e,n){return n&&n.relaxed?parseInt(e.$numberInt,10):new t(e.$numberInt)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new Int32(".concat(this.valueOf(),")")},t}();Object.defineProperty(Ve.prototype,"_bsontype",{value:"Int32"});var He=function(){function t(){if(!(this instanceof t))return new t}return t.prototype.toExtendedJSON=function(){return{$maxKey:1}},t.fromExtendedJSON=function(){return new t},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new MaxKey()"},t}();Object.defineProperty(He.prototype,"_bsontype",{value:"MaxKey"});var Ge=function(){function t(){if(!(this instanceof t))return new t}return t.prototype.toExtendedJSON=function(){return{$minKey:1}},t.fromExtendedJSON=function(){return new t},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new MinKey()"},t}();Object.defineProperty(Ge.prototype,"_bsontype",{value:"MinKey"});var We=new RegExp("^[0-9a-fA-F]{24}$"),Ze=null,Ye=Symbol("id"),Qe=function(){function t(e){if(!(this instanceof t))return new t(e);var n;if("object"==typeof e&&e&&"id"in e){if("string"!=typeof e.id&&!ArrayBuffer.isView(e.id))throw new oe("Argument passed in must have an id that is of type string or Buffer");n="toHexString"in e&&"function"==typeof e.toHexString?te.from(e.toHexString(),"hex"):e.id}else n=e;if(null==n||"number"==typeof n)this[Ye]=t.generate("number"==typeof n?n:void 0);else if(ArrayBuffer.isView(n)&&12===n.byteLength)this[Ye]=n instanceof te?n:pe(n);else{if("string"!=typeof n)throw new oe("Argument passed in does not match the accepted types");if(12===n.length){var r=te.from(n);if(12!==r.byteLength)throw new oe("Argument passed in must be a string of 12 bytes");this[Ye]=r}else{if(24!==n.length||!We.test(n))throw new oe("Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer");this[Ye]=te.from(n,"hex")}}t.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(t.prototype,"id",{get:function(){return this[Ye]},set:function(e){this[Ye]=e,t.cacheHexString&&(this.__id=e.toString("hex"))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"generationTime",{get:function(){return this.id.readInt32BE(0)},set:function(t){this.id.writeUInt32BE(t,0)},enumerable:!1,configurable:!0}),t.prototype.toHexString=function(){if(t.cacheHexString&&this.__id)return this.__id;var e=this.id.toString("hex");return t.cacheHexString&&!this.__id&&(this.__id=e),e},t.getInc=function(){return t.index=(t.index+1)%16777215},t.generate=function(e){"number"!=typeof e&&(e=Math.floor(Date.now()/1e3));var n=t.getInc(),r=te.alloc(12);return r.writeUInt32BE(e,0),null===Ze&&(Ze=ae(5)),r[4]=Ze[0],r[5]=Ze[1],r[6]=Ze[2],r[7]=Ze[3],r[8]=Ze[4],r[11]=255&n,r[10]=n>>8&255,r[9]=n>>16&255,r},t.prototype.toString=function(t){return t?this.id.toString(t):this.toHexString()},t.prototype.toJSON=function(){return this.toHexString()},t.prototype.equals=function(e){if(null==e)return!1;if(e instanceof t)return this[Ye][11]===e[Ye][11]&&this[Ye].equals(e[Ye]);if("string"==typeof e&&t.isValid(e)&&12===e.length&&fe(this.id))return e===te.prototype.toString.call(this.id,"latin1");if("string"==typeof e&&t.isValid(e)&&24===e.length)return e.toLowerCase()===this.toHexString();if("string"==typeof e&&t.isValid(e)&&12===e.length)return te.from(e).equals(this.id);if("object"==typeof e&&"toHexString"in e&&"function"==typeof e.toHexString){var n=e.toHexString(),r=this.toHexString().toLowerCase();return"string"==typeof n&&n.toLowerCase()===r}return!1},t.prototype.getTimestamp=function(){var t=new Date,e=this.id.readUInt32BE(0);return t.setTime(1e3*Math.floor(e)),t},t.createPk=function(){return new t},t.createFromTime=function(e){var n=te.from([0,0,0,0,0,0,0,0,0,0,0,0]);return n.writeUInt32BE(e,0),new t(n)},t.createFromHexString=function(e){if(void 0===e||null!=e&&24!==e.length)throw new oe("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new t(te.from(e,"hex"))},t.isValid=function(e){if(null==e)return!1;try{return new t(e),!0}catch(t){return!1}},t.prototype.toExtendedJSON=function(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}},t.fromExtendedJSON=function(e){return new t(e.$oid)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new ObjectId("'.concat(this.toHexString(),'")')},t.index=Math.floor(16777215*Math.random()),t}();Object.defineProperty(Qe.prototype,"generate",{value:he((function(t){return Qe.generate(t)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(Qe.prototype,"getInc",{value:he((function(){return Qe.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Qe.prototype,"get_inc",{value:he((function(){return Qe.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Qe,"get_inc",{value:he((function(){return Qe.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(Qe.prototype,"_bsontype",{value:"ObjectID"});var ze=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);if(this.pattern=e,this.options=(null!=n?n:"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new re("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern)));if(-1!==this.options.indexOf("\0"))throw new re("BSON Regex options cannot contain null bytes, found: ".concat(JSON.stringify(this.options)));for(var r=0;r<this.options.length;r++)if("i"!==this.options[r]&&"m"!==this.options[r]&&"x"!==this.options[r]&&"l"!==this.options[r]&&"s"!==this.options[r]&&"u"!==this.options[r])throw new re("The regular expression option [".concat(this.options[r],"] is not supported"))}return t.parseOptions=function(t){return t?t.split("").sort().join(""):""},t.prototype.toExtendedJSON=function(t){return(t=t||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}},t.fromExtendedJSON=function(e){if("$regex"in e){if("string"==typeof e.$regex)return new t(e.$regex,t.parseOptions(e.$options));if("BSONRegExp"===e.$regex._bsontype)return e}if("$regularExpression"in e)return new t(e.$regularExpression.pattern,t.parseOptions(e.$regularExpression.options));throw new oe("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(e)))},t}();Object.defineProperty(ze.prototype,"_bsontype",{value:"BSONRegExp"});var Xe=function(){function t(e){if(!(this instanceof t))return new t(e);this.value=e}return t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(){return this.value},t.prototype.inspect=function(){return'new BSONSymbol("'.concat(this.value,'")')},t.prototype.toJSON=function(){return this.value},t.prototype.toExtendedJSON=function(){return{$symbol:this.value}},t.fromExtendedJSON=function(e){return new t(e.$symbol)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t}();Object.defineProperty(Xe.prototype,"_bsontype",{value:"Symbol"});var Ke=function(t){function e(n,r){var o=this;return o instanceof e?(o=Te.isLong(n)?t.call(this,n.low,n.high,!0)||this:ce(n)&&void 0!==n.t&&void 0!==n.i?t.call(this,n.i,n.t,!0)||this:t.call(this,n,r,!0)||this,Object.defineProperty(o,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1}),o):new e(n,r)}return ne(e,t),e.prototype.toJSON=function(){return{$timestamp:this.toString()}},e.fromInt=function(t){return new e(Te.fromInt(t,!0))},e.fromNumber=function(t){return new e(Te.fromNumber(t,!0))},e.fromBits=function(t,n){return new e(t,n)},e.fromString=function(t,n){return new e(Te.fromString(t,!0,n))},e.prototype.toExtendedJSON=function(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}},e.fromExtendedJSON=function(t){return new e(t.$timestamp)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new Timestamp({ t: ".concat(this.getHighBits(),", i: ").concat(this.getLowBits()," })")},e.MAX_VALUE=Te.MAX_UNSIGNED_VALUE,e}(Te);var tn=2147483647,en=-2147483648,nn=0x8000000000000000,rn=-0x8000000000000000,on={$oid:Qe,$binary:be,$uuid:be,$symbol:Xe,$numberInt:Ve,$numberDecimal:Fe,$numberDouble:Je,$numberLong:Te,$minKey:Ge,$maxKey:He,$regex:ze,$regularExpression:ze,$timestamp:Ke};function un(t,e){if(void 0===e&&(e={}),"number"==typeof t){if(e.relaxed||e.legacy)return t;if(Math.floor(t)===t){if(t>=en&&t<=tn)return new Ve(t);if(t>=rn&&t<=nn)return Te.fromNumber(t)}return new Je(t)}if(null==t||"object"!=typeof t)return t;if(t.$undefined)return null;for(var n=Object.keys(t).filter((function(e){return e.startsWith("$")&&null!=t[e]})),r=0;r<n.length;r++){var o=on[n[r]];if(o)return o.fromExtendedJSON(t,e)}if(null!=t.$date){var i=t.$date,u=new Date;return e.legacy?"number"==typeof i?u.setTime(i):"string"==typeof i&&u.setTime(Date.parse(i)):"string"==typeof i?u.setTime(Date.parse(i)):Te.isLong(i)?u.setTime(i.toNumber()):"number"==typeof i&&e.relaxed&&u.setTime(i),u}if(null!=t.$code){var s=Object.assign({},t);return t.$scope&&(s.$scope=un(t.$scope)),_e.fromExtendedJSON(t)}if(function(t){return ce(t)&&null!=t.$id&&"string"==typeof t.$ref&&(null==t.$db||"string"==typeof t.$db)}(t)||t.$dbPointer){var a=t.$ref?t:t.$dbPointer;if(a instanceof Ee)return a;var f=Object.keys(a).filter((function(t){return t.startsWith("$")})),c=!0;if(f.forEach((function(t){-1===["$ref","$id","$db"].indexOf(t)&&(c=!1)})),c)return Ee.fromExtendedJSON(a)}return t}function sn(t){var e=t.toISOString();return 0!==t.getUTCMilliseconds()?e:e.slice(0,-5)+"Z"}function an(t,e){if(("object"==typeof t||"function"==typeof t)&&null!==t){var n=e.seenObjects.findIndex((function(e){return e.obj===t}));if(-1!==n){var r=e.seenObjects.map((function(t){return t.propertyName})),o=r.slice(0,n).map((function(t){return"".concat(t," -> ")})).join(""),i=r[n],u=" -> "+r.slice(n+1,r.length-1).map((function(t){return"".concat(t," -> ")})).join(""),s=r[r.length-1],a=" ".repeat(o.length+i.length/2),f="-".repeat(u.length+(i.length+s.length)/2-1);throw new oe("Converting circular structure to EJSON:\n"+" ".concat(o).concat(i).concat(u).concat(s,"\n")+" ".concat(a,"\\").concat(f,"/"))}e.seenObjects[e.seenObjects.length-1].obj=t}if(Array.isArray(t))return function(t,e){return t.map((function(t,n){e.seenObjects.push({propertyName:"index ".concat(n),obj:null});try{return an(t,e)}finally{e.seenObjects.pop()}}))}(t,e);if(void 0===t)return null;if(t instanceof Date||ce(p=t)&&"[object Date]"===Object.prototype.toString.call(p)){var c=t.getTime(),h=c>-1&&c<2534023188e5;return e.legacy?e.relaxed&&h?{$date:t.getTime()}:{$date:sn(t)}:e.relaxed&&h?{$date:sn(t)}:{$date:{$numberLong:t.getTime().toString()}}}var p;if(!("number"!=typeof t||e.relaxed&&isFinite(t))){if(Math.floor(t)===t){var l=t>=rn&&t<=nn;if(t>=en&&t<=tn)return{$numberInt:t.toString()};if(l)return{$numberLong:t.toString()}}return{$numberDouble:t.toString()}}if(t instanceof RegExp||function(t){return"[object RegExp]"===Object.prototype.toString.call(t)}(t)){var d=t.flags;if(void 0===d){var y=t.toString().match(/[gimuy]*$/);y&&(d=y[0])}return new ze(t.source,d).toExtendedJSON(e)}return null!=t&&"object"==typeof t?function(t,e){if(null==t||"object"!=typeof t)throw new re("not an object instance");var n=t._bsontype;if(void 0===n){var r={};for(var o in t){e.seenObjects.push({propertyName:o,obj:null});try{var i=an(t[o],e);"__proto__"===o?Object.defineProperty(r,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):r[o]=i}finally{e.seenObjects.pop()}}return r}if(function(t){return ce(t)&&Reflect.has(t,"_bsontype")&&"string"==typeof t._bsontype}(t)){var u=t;if("function"!=typeof u.toExtendedJSON){var s=cn[t._bsontype];if(!s)throw new oe("Unrecognized or invalid _bsontype: "+t._bsontype);u=s(u)}return"Code"===n&&u.scope?u=new _e(u.code,an(u.scope,e)):"DBRef"===n&&u.oid&&(u=new Ee(an(u.collection,e),an(u.oid,e),an(u.db,e),an(u.fields,e))),u.toExtendedJSON(e)}throw new re("_bsontype must be a string, but was: "+typeof n)}(t,e):t}var fn,cn={Binary:function(t){return new be(t.value(),t.sub_type)},Code:function(t){return new _e(t.code,t.scope)},DBRef:function(t){return new Ee(t.collection||t.namespace,t.oid,t.db,t.fields)},Decimal128:function(t){return new Fe(t.bytes)},Double:function(t){return new Je(t.value)},Int32:function(t){return new Ve(t.value)},Long:function(t){return Te.fromBits(null!=t.low?t.low:t.low_,null!=t.low?t.high:t.high_,null!=t.low?t.unsigned:t.unsigned_)},MaxKey:function(){return new He},MinKey:function(){return new Ge},ObjectID:function(t){return new Qe(t)},ObjectId:function(t){return new Qe(t)},BSONRegExp:function(t){return new ze(t.pattern,t.options)},Symbol:function(t){return new Xe(t.value)},Timestamp:function(t){return Ke.fromBits(t.low,t.high)}};!function(t){function e(t,e){var n=Object.assign({},{relaxed:!0,legacy:!1},e);return"boolean"==typeof n.relaxed&&(n.strict=!n.relaxed),"boolean"==typeof n.strict&&(n.relaxed=!n.strict),JSON.parse(t,(function(t,e){if(-1!==t.indexOf("\0"))throw new re("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(t)));return un(e,n)}))}function n(t,e,n,r){null!=n&&"object"==typeof n&&(r=n,n=0),null==e||"object"!=typeof e||Array.isArray(e)||(r=e,e=void 0,n=0);var o=an(t,Object.assign({relaxed:!0,legacy:!1},r,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,e,n)}t.parse=e,t.stringify=n,t.serialize=function(t,e){return e=e||{},JSON.parse(n(t,e))},t.deserialize=function(t,n){return n=n||{},e(JSON.stringify(t),n)}}(fn||(fn={}));var hn=ue();hn.Map?hn.Map:function(){function t(t){void 0===t&&(t=[]),this._keys=[],this._values={};for(var e=0;e<t.length;e++)if(null!=t[e]){var n=t[e],r=n[0],o=n[1];this._keys.push(r),this._values[r]={v:o,i:this._keys.length-1}}}t.prototype.clear=function(){this._keys=[],this._values={}},t.prototype.delete=function(t){var e=this._values[t];return null!=e&&(delete this._values[t],this._keys.splice(e.i,1),!0)},t.prototype.entries=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?[n,t._values[n].v]:void 0,done:void 0===n}}}},t.prototype.forEach=function(t,e){e=e||this;for(var n=0;n<this._keys.length;n++){var r=this._keys[n];t.call(e,this._values[r].v,r,e)}},t.prototype.get=function(t){return this._values[t]?this._values[t].v:void 0},t.prototype.has=function(t){return null!=this._values[t]},t.prototype.keys=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?n:void 0,done:void 0===n}}}},t.prototype.set=function(t,e){return this._values[t]?(this._values[t].v=e,this):(this._keys.push(t),this._values[t]={v:e,i:this._keys.length-1},this)},t.prototype.values=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?t._values[n].v:void 0,done:void 0===n}}}},Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!1,configurable:!0})}(),Te.fromNumber(me),Te.fromNumber(we),new Set(["$db","$ref","$id","$clusterTime"]);var pn=new Uint8Array(8);new DataView(pn.buffer,pn.byteOffset,pn.byteLength);te.alloc(17825792);var ln=function(){function t(t,e){this._stages=[],t&&e&&(this._db=t,this._request=new Un.reqClass(this._db.config),this._collectionName=e)}return t.prototype.end=function(){return t=this,e=void 0,r=function(){var t;return function(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,(function(e){switch(e.label){case 0:if(!this._collectionName||!this._db)throw new Error("Aggregation pipeline cannot send request");return[4,this._request.send("database.aggregate",{collectionName:this._collectionName,stages:this._stages})];case 1:return(t=e.sent())&&t.data&&t.data.list?[2,{requestId:t.requestId,data:JSON.parse(t.data.list).map(fn.parse)}]:[2,t]}}))},new((n=void 0)||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}));var t,e,n,r},t.prototype.unwrap=function(){return this._stages},t.prototype.done=function(){return this._stages.map((function(t){var e,n=t.stageKey,r=t.stageValue;return(e={})[n]=JSON.parse(r),e}))},t.prototype._pipe=function(t,e){return this._stages.push({stageKey:"$"+t,stageValue:JSON.stringify(e)}),this},t.prototype.addFields=function(t){return this._pipe("addFields",t)},t.prototype.bucket=function(t){return this._pipe("bucket",t)},t.prototype.bucketAuto=function(t){return this._pipe("bucketAuto",t)},t.prototype.count=function(t){return this._pipe("count",t)},t.prototype.geoNear=function(t){return t.query&&(t.query=Dt.encode(t.query)),t.distanceMultiplier&&"number"==typeof t.distanceMultiplier&&(t.distanceMultiplier=t.distanceMultiplier),t.near&&(t.near=new Q(t.near.longitude,t.near.latitude).toJSON()),this._pipe("geoNear",t)},t.prototype.group=function(t){return this._pipe("group",t)},t.prototype.limit=function(t){return this._pipe("limit",t)},t.prototype.match=function(t){return this._pipe("match",Dt.encode(t))},t.prototype.project=function(t){return this._pipe("project",t)},t.prototype.lookup=function(t){return this._pipe("lookup",t)},t.prototype.replaceRoot=function(t){return this._pipe("replaceRoot",t)},t.prototype.sample=function(t){return this._pipe("sample",t)},t.prototype.skip=function(t){return this._pipe("skip",t)},t.prototype.sort=function(t){return this._pipe("sort",t)},t.prototype.sortByCount=function(t){return this._pipe("sortByCount",t)},t.prototype.unwind=function(t){return this._pipe("unwind",t)},t}();const dn=ln;var yn=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),gn=function(t){function e(e,n){return t.call(this,e,n)||this}return yn(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new $t(this._db,this._coll,t)},e.prototype.add=function(t,e){return new $t(this._db,this._coll,void 0).create(t,e)},e.prototype.aggregate=function(){return new dn(this._db,this._coll)},e}(qt),mn={eq:function(t){return new lt(ht.EQ,[t])},neq:function(t){return new lt(ht.NEQ,[t])},lt:function(t){return new lt(ht.LT,[t])},lte:function(t){return new lt(ht.LTE,[t])},gt:function(t){return new lt(ht.GT,[t])},gte:function(t){return new lt(ht.GTE,[t])},in:function(t){return new lt(ht.IN,t)},nin:function(t){return new lt(ht.NIN,t)},all:function(t){return new lt(ht.ALL,t)},elemMatch:function(t){return new lt(ht.ELEM_MATCH,[t])},exists:function(t){return new lt(ht.EXISTS,[t])},size:function(t){return new lt(ht.SIZE,[t])},mod:function(t){return new lt(ht.MOD,[t])},geoNear:function(t){return new lt(ht.GEO_NEAR,[t])},geoWithin:function(t){return new lt(ht.GEO_WITHIN,[t])},geoIntersects:function(t){return new lt(ht.GEO_INTERSECTS,[t])},and:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=G(arguments[0])?arguments[0]:Array.from(arguments);return new ft(ut.AND,n)},nor:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=G(arguments[0])?arguments[0]:Array.from(arguments);return new ft(ut.NOR,n)},or:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=G(arguments[0])?arguments[0]:Array.from(arguments);return new ft(ut.OR,n)},not:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=G(arguments[0])?arguments[0]:Array.from(arguments);return new ft(ut.NOT,n)},set:function(t){return new st(M.SET,[t])},remove:function(){return new st(M.REMOVE,[])},inc:function(t){return new st(M.INC,[t])},mul:function(t){return new st(M.MUL,[t])},push:function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(V(e[0])&&e[0].hasOwnProperty("each")){var r=e[0];t={$each:r.each,$position:r.position,$sort:r.sort,$slice:r.slice}}else t=G(e[0])?e[0]:Array.from(e);return new st(M.PUSH,t)},pull:function(t){return new st(M.PULL,t)},pullAll:function(t){return new st(M.PULL_ALL,t)},pop:function(){return new st(M.POP,[])},shift:function(){return new st(M.SHIFT,[])},unshift:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=G(arguments[0])?arguments[0]:Array.from(arguments);return new st(M.UNSHIFT,n)},addToSet:function(t){return new st(M.ADD_TO_SET,t)},rename:function(t){return new st(M.RENAME,[t])},bit:function(t){return new st(M.BIT,[t])},max:function(t){return new st(M.MAX,[t])},min:function(t){return new st(M.MIN,[t])},expr:function(t){return{$expr:t}},jsonSchema:function(t){return{$jsonSchema:t}},text:function(t){return"string"===J(t)?{$search:t.search}:{$search:t.search,$language:t.language,$caseSensitive:t.caseSensitive,$diacriticSensitive:t.diacriticSensitive}},aggregate:{pipeline:function(){return new dn},abs:function(t){return new wn("abs",t)},add:function(t){return new wn("add",t)},ceil:function(t){return new wn("ceil",t)},divide:function(t){return new wn("divide",t)},exp:function(t){return new wn("exp",t)},floor:function(t){return new wn("floor",t)},ln:function(t){return new wn("ln",t)},log:function(t){return new wn("log",t)},log10:function(t){return new wn("log10",t)},mod:function(t){return new wn("mod",t)},multiply:function(t){return new wn("multiply",t)},pow:function(t){return new wn("pow",t)},sqrt:function(t){return new wn("sqrt",t)},subtract:function(t){return new wn("subtract",t)},trunc:function(t){return new wn("trunc",t)},arrayElemAt:function(t){return new wn("arrayElemAt",t)},arrayToObject:function(t){return new wn("arrayToObject",t)},concatArrays:function(t){return new wn("concatArrays",t)},filter:function(t){return new wn("filter",t)},in:function(t){return new wn("in",t)},indexOfArray:function(t){return new wn("indexOfArray",t)},isArray:function(t){return new wn("isArray",t)},map:function(t){return new wn("map",t)},range:function(t){return new wn("range",t)},reduce:function(t){return new wn("reduce",t)},reverseArray:function(t){return new wn("reverseArray",t)},size:function(t){return new wn("size",t)},slice:function(t){return new wn("slice",t)},zip:function(t){return new wn("zip",t)},and:function(t){return new wn("and",t)},not:function(t){return new wn("not",t)},or:function(t){return new wn("or",t)},cmp:function(t){return new wn("cmp",t)},eq:function(t){return new wn("eq",t)},gt:function(t){return new wn("gt",t)},gte:function(t){return new wn("gte",t)},lt:function(t){return new wn("lt",t)},lte:function(t){return new wn("lte",t)},neq:function(t){return new wn("ne",t)},cond:function(t){return new wn("cond",t)},ifNull:function(t){return new wn("ifNull",t)},switch:function(t){return new wn("switch",t)},dateFromParts:function(t){return new wn("dateFromParts",t)},dateFromString:function(t){return new wn("dateFromString",t)},dayOfMonth:function(t){return new wn("dayOfMonth",t)},dayOfWeek:function(t){return new wn("dayOfWeek",t)},dayOfYear:function(t){return new wn("dayOfYear",t)},isoDayOfWeek:function(t){return new wn("isoDayOfWeek",t)},isoWeek:function(t){return new wn("isoWeek",t)},isoWeekYear:function(t){return new wn("isoWeekYear",t)},millisecond:function(t){return new wn("millisecond",t)},minute:function(t){return new wn("minute",t)},month:function(t){return new wn("month",t)},second:function(t){return new wn("second",t)},hour:function(t){return new wn("hour",t)},week:function(t){return new wn("week",t)},year:function(t){return new wn("year",t)},literal:function(t){return new wn("literal",t)},mergeObjects:function(t){return new wn("mergeObjects",t)},objectToArray:function(t){return new wn("objectToArray",t)},allElementsTrue:function(t){return new wn("allElementsTrue",t)},anyElementTrue:function(t){return new wn("anyElementTrue",t)},setDifference:function(t){return new wn("setDifference",t)},setEquals:function(t){return new wn("setEquals",t)},setIntersection:function(t){return new wn("setIntersection",t)},setIsSubset:function(t){return new wn("setIsSubset",t)},setUnion:function(t){return new wn("setUnion",t)},concat:function(t){return new wn("concat",t)},dateToString:function(t){return new wn("dateToString",t)},indexOfBytes:function(t){return new wn("indexOfBytes",t)},indexOfCP:function(t){return new wn("indexOfCP",t)},split:function(t){return new wn("split",t)},strLenBytes:function(t){return new wn("strLenBytes",t)},strLenCP:function(t){return new wn("strLenCP",t)},strcasecmp:function(t){return new wn("strcasecmp",t)},substr:function(t){return new wn("substr",t)},substrBytes:function(t){return new wn("substrBytes",t)},substrCP:function(t){return new wn("substrCP",t)},toLower:function(t){return new wn("toLower",t)},toUpper:function(t){return new wn("toUpper",t)},meta:function(t){return new wn("meta",t)},addToSet:function(t){return new wn("addToSet",t)},avg:function(t){return new wn("avg",t)},first:function(t){return new wn("first",t)},last:function(t){return new wn("last",t)},max:function(t){return new wn("max",t)},min:function(t){return new wn("min",t)},push:function(t){return new wn("push",t)},stdDevPop:function(t){return new wn("stdDevPop",t)},stdDevSamp:function(t){return new wn("stdDevSamp",t)},sum:function(t){return new wn("sum",t)},let:function(t){return new wn("let",t)}},project:{slice:function(t){return new bn("slice",t)},elemMatch:function(t){return new bn("elemMatch",t)}}},wn=function(t,e){this["$"+t]=e},bn=function(t,e){this["$"+t]=e},vn=function(){function t(t){var e=t.regexp,n=t.options;if(!e)throw new TypeError("regexp must be a string");this.$regex=e,this.$options=n}return t.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(t.prototype,"_internalType",{get:function(){return $},enumerable:!0,configurable:!0}),t}();function _n(t){return new vn(t)}var En={CREATE_WATCH_NET_ERROR:{code:"CREATE_WATCH_NET_ERROR",message:"create watch network error"},CREATE_WACTH_EXCEED_ERROR:{code:"CREATE_WACTH_EXCEED_ERROR",message:"maximum connections exceed"},CREATE_WATCH_SERVER_ERROR:{code:"CREATE_WATCH_SERVER_ERROR",message:"create watch server error"},CONN_ERROR:{code:"CONN_ERROR",message:"connection error"},INVALID_PARAM:{code:"INVALID_PARAM",message:"Invalid request param"},INSERT_DOC_FAIL:{code:"INSERT_DOC_FAIL",message:"insert document failed"},DATABASE_TRANSACTION_CONFLICT:{code:"DATABASE_TRANSACTION_CONFLICT",message:"database transaction conflict"}},On=function(){return On=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},On.apply(this,arguments)},Nn=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}))},Sn=function(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},xn="database.updateDocInTransaction",In=function(){function t(t,e,n){this._coll=e,this.id=n,this._transaction=t,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return t.prototype.create=function(t){return Nn(this,void 0,void 0,(function(){var e,n,r,o;return Sn(this,(function(i){switch(i.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,data:fn.stringify(Et(t),{relaxed:!1})},this.id&&(e._id=this.id),[4,this._request.send("database.insertDocInTransaction",e)];case 1:if((n=i.sent()).code)throw n;if(r=fn.parse(n.inserted),1==(o=fn.parse(n.ok))&&1==r)return[2,On(On({},n),{ok:o,inserted:r})];throw new Error(En.INSERT_DOC_FAIL.message)}}))}))},t.prototype.get=function(){return Nn(this,void 0,void 0,(function(){var t,e;return Sn(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,{data:"null"!==e.data?k.formatField(fn.parse(e.data)):fn.parse(e.data),requestId:e.requestId}]}}))}))},t.prototype.set=function(t){return Nn(this,void 0,void 0,(function(){var e,n;return Sn(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:fn.stringify(Et(t),{relaxed:!1}),upsert:!0},[4,this._request.send(xn,e)];case 1:if((n=r.sent()).code)throw n;return[2,On(On({},n),{updated:fn.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},t.prototype.update=function(t){return Nn(this,void 0,void 0,(function(){var e,n;return Sn(this,(function(r){switch(r.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:fn.stringify(jt.encode(t),{relaxed:!1})},[4,this._request.send(xn,e)];case 1:if((n=r.sent()).code)throw n;return[2,On(On({},n),{updated:fn.parse(n.updated)})]}}))}))},t.prototype.delete=function(){return Nn(this,void 0,void 0,(function(){var t,e;return Sn(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,On(On({},e),{deleted:fn.parse(e.deleted)})]}}))}))},t}(),An=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},t(e,n)};return function(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),Tn=function(t){function e(e,n){return t.call(this,e,n)||this}return An(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new In(this._transaction,this._coll,t)},e.prototype.add=function(t){var e;return void 0!==t._id&&(e=t._id),new In(this._transaction,this._coll,e).create(t)},e}((function(t,e){this._coll=e,this._transaction=t})),Bn=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}))},Ln=function(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},jn=function(){function t(t){this._db=t,this._request=new Un.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return Bn(this,void 0,void 0,(function(){var t;return Ln(this,(function(e){switch(e.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((t=e.sent()).code)throw t;return this.inited=!0,this._id=t.transactionId,[2]}}))}))},t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new Tn(this,t)},t.prototype.getTransactionId=function(){return this._id},t.prototype.getRequestMethod=function(){return this._request},t.prototype.commit=function(){return Bn(this,void 0,void 0,(function(){var t,e;return Ln(this,(function(n){switch(n.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.commitTransaction",t)];case 1:if((e=n.sent()).code)throw e;return this.commited=!0,[2,e]}}))}))},t.prototype.rollback=function(t){return Bn(this,void 0,void 0,(function(){var e,n;return Ln(this,(function(r){switch(r.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.abortTransaction",e)];case 1:if((n=r.sent()).code)throw n;return this.aborted=!0,this.abortReason=t,[2,n]}}))}))},t}();function Pn(){return Bn(this,void 0,void 0,(function(){var t;return Ln(this,(function(e){switch(e.label){case 0:return[4,(t=new jn(this)).init()];case 1:return e.sent(),[2,t]}}))}))}function Rn(t,e){return void 0===e&&(e=3),Bn(this,void 0,void 0,(function(){var n,r,o,i,u=this;return Ln(this,(function(s){switch(s.label){case 0:return s.trys.push([0,4,,10]),[4,(n=new jn(this)).init()];case 1:return s.sent(),[4,t(n)];case 2:if(r=s.sent(),!0===n.aborted)throw n.abortReason;return[4,n.commit()];case 3:return s.sent(),[2,r];case 4:if(o=s.sent(),!1===n.inited)throw o;return i=function(t){return Bn(u,void 0,void 0,(function(){return Ln(this,(function(e){switch(e.label){case 0:if(n.aborted||n.commited)return[3,5];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,n.rollback()];case 2:case 3:return e.sent(),[3,4];case 4:throw t;case 5:if(!0===n.aborted)throw n.abortReason;throw t}}))}))},e<=0?[4,i(o)]:[3,6];case 5:s.sent(),s.label=6;case 6:return o&&o.code===En.DATABASE_TRANSACTION_CONFLICT.code?[4,Rn.bind(this)(t,--e)]:[3,8];case 7:return[2,s.sent()];case 8:return[4,i(o)];case 9:return s.sent(),[3,10];case 10:return[2]}}))}))}var Un=function(){function t(t){this.config=t,this.Geo=i,this.serverDate=C,this.command=mn,this.RegExp=_n,this.startTransaction=Pn,this.runTransaction=Rn,this.logicCommand=ft,this.updateCommand=st,this.queryCommand=lt}return t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new gn(this,t)},t.prototype.createCollection=function(e){var n={collectionName:e};return new t.reqClass(this.config).send("database.addCollection",n)},t}()},258:function(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.registerDatabase=void 0;var o=n(617),i={name:"database",entity:{database:function(t){var e=this.platform,n=e.adapter,i=e.runtime;return o.Db.reqClass=this.request.constructor,o.Db.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},o.Db.runtime=i,this.wsClientClass&&(o.Db.wsClass=n.wsClass,o.Db.wsClientClass=this.wsClientClass),o.Db.ws||(o.Db.ws=null),new o.Db(r(r(r({},this.config),{_fromApp:this}),t))}}};try{cloudbase.registerComponent(i)}catch(t){}e.registerDatabase=function(t){try{t.registerComponent(i)}catch(t){console.warn(t)}}}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,n),i.exports}return n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n(258)})()));
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cloudbase_database",[],e):"object"==typeof exports?exports.cloudbase_database=e():t.cloudbase_database=e()}("undefined"!=typeof window?window:this,(()=>(()=>{"use strict";var t={626:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};Object.defineProperty(e,"__esModule",{value:!0});var i=n(672),u=n(762),s=n(947),a=n(458),f=function(){function t(t,e){this._stages=[],t&&e&&(this._db=t,this._request=new i.Db.reqClass(this._db.config),this._collectionName=e)}return t.prototype.end=function(){return r(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:if(!this._collectionName||!this._db)throw new Error("Aggregation pipeline cannot send request");return[4,this._request.send("database.aggregate",{collectionName:this._collectionName,stages:this._stages})];case 1:return(t=e.sent())&&t.data&&t.data.list?[2,{requestId:t.requestId,data:JSON.parse(t.data.list).map(u.EJSON.parse)}]:[2,t]}}))}))},t.prototype.unwrap=function(){return this._stages},t.prototype.done=function(){return this._stages.map((function(t){var e,n=t.stageKey,r=t.stageValue;return(e={})[n]=JSON.parse(r),e}))},t.prototype._pipe=function(t,e){return this._stages.push({stageKey:"$"+t,stageValue:JSON.stringify(e)}),this},t.prototype.addFields=function(t){return this._pipe("addFields",t)},t.prototype.bucket=function(t){return this._pipe("bucket",t)},t.prototype.bucketAuto=function(t){return this._pipe("bucketAuto",t)},t.prototype.count=function(t){return this._pipe("count",t)},t.prototype.geoNear=function(t){return t.query&&(t.query=s.QuerySerializer.encode(t.query)),t.distanceMultiplier&&"number"==typeof t.distanceMultiplier&&(t.distanceMultiplier=t.distanceMultiplier),t.near&&(t.near=new a.Point(t.near.longitude,t.near.latitude).toJSON()),this._pipe("geoNear",t)},t.prototype.group=function(t){return this._pipe("group",t)},t.prototype.limit=function(t){return this._pipe("limit",t)},t.prototype.match=function(t){return this._pipe("match",s.QuerySerializer.encode(t))},t.prototype.project=function(t){return this._pipe("project",t)},t.prototype.lookup=function(t){return this._pipe("lookup",t)},t.prototype.replaceRoot=function(t){return this._pipe("replaceRoot",t)},t.prototype.sample=function(t){return this._pipe("sample",t)},t.prototype.skip=function(t){return this._pipe("skip",t)},t.prototype.sort=function(t){return this._pipe("sort",t)},t.prototype.sortByCount=function(t){return this._pipe("sortByCount",t)},t.prototype.unwind=function(t){return this._pipe("unwind",t)},t}();e.default=f},318:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},r(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var i=n(929),u=n(660),s=n(626),a=function(t){function e(e,n){return t.call(this,e,n)||this}return o(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new i.DocumentReference(this._db,this._coll,t)},e.prototype.add=function(t,e){return new i.DocumentReference(this._db,this._coll,void 0).create(t,e)},e.prototype.aggregate=function(){return new s.default(this._db,this._coll)},e}(u.Query);e.CollectionReference=a},407:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=n(488),o=n(443),i=n(750),u=n(428),s=n(626);e.Command={eq:function(t){return new r.QueryCommand(r.QUERY_COMMANDS_LITERAL.EQ,[t])},neq:function(t){return new r.QueryCommand(r.QUERY_COMMANDS_LITERAL.NEQ,[t])},lt:function(t){return new r.QueryCommand(r.QUERY_COMMANDS_LITERAL.LT,[t])},lte:function(t){return new r.QueryCommand(r.QUERY_COMMANDS_LITERAL.LTE,[t])},gt:function(t){return new r.QueryCommand(r.QUERY_COMMANDS_LITERAL.GT,[t])},gte:function(t){return new r.QueryCommand(r.QUERY_COMMANDS_LITERAL.GTE,[t])},in:function(t){return new r.QueryCommand(r.QUERY_COMMANDS_LITERAL.IN,t)},nin:function(t){return new r.QueryCommand(r.QUERY_COMMANDS_LITERAL.NIN,t)},all:function(t){return new r.QueryCommand(r.QUERY_COMMANDS_LITERAL.ALL,t)},elemMatch:function(t){return new r.QueryCommand(r.QUERY_COMMANDS_LITERAL.ELEM_MATCH,[t])},exists:function(t){return new r.QueryCommand(r.QUERY_COMMANDS_LITERAL.EXISTS,[t])},size:function(t){return new r.QueryCommand(r.QUERY_COMMANDS_LITERAL.SIZE,[t])},mod:function(t){return new r.QueryCommand(r.QUERY_COMMANDS_LITERAL.MOD,[t])},geoNear:function(t){return new r.QueryCommand(r.QUERY_COMMANDS_LITERAL.GEO_NEAR,[t])},geoWithin:function(t){return new r.QueryCommand(r.QUERY_COMMANDS_LITERAL.GEO_WITHIN,[t])},geoIntersects:function(t){return new r.QueryCommand(r.QUERY_COMMANDS_LITERAL.GEO_INTERSECTS,[t])},and:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=u.isArray(arguments[0])?arguments[0]:Array.from(arguments);return new o.LogicCommand(o.LOGIC_COMMANDS_LITERAL.AND,n)},nor:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=u.isArray(arguments[0])?arguments[0]:Array.from(arguments);return new o.LogicCommand(o.LOGIC_COMMANDS_LITERAL.NOR,n)},or:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=u.isArray(arguments[0])?arguments[0]:Array.from(arguments);return new o.LogicCommand(o.LOGIC_COMMANDS_LITERAL.OR,n)},not:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=u.isArray(arguments[0])?arguments[0]:Array.from(arguments);return new o.LogicCommand(o.LOGIC_COMMANDS_LITERAL.NOT,n)},set:function(t){return new i.UpdateCommand(i.UPDATE_COMMANDS_LITERAL.SET,[t])},remove:function(){return new i.UpdateCommand(i.UPDATE_COMMANDS_LITERAL.REMOVE,[])},inc:function(t){return new i.UpdateCommand(i.UPDATE_COMMANDS_LITERAL.INC,[t])},mul:function(t){return new i.UpdateCommand(i.UPDATE_COMMANDS_LITERAL.MUL,[t])},push:function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(u.isObject(e[0])&&e[0].hasOwnProperty("each")){var r=e[0];t={$each:r.each,$position:r.position,$sort:r.sort,$slice:r.slice}}else t=u.isArray(e[0])?e[0]:Array.from(e);return new i.UpdateCommand(i.UPDATE_COMMANDS_LITERAL.PUSH,t)},pull:function(t){return new i.UpdateCommand(i.UPDATE_COMMANDS_LITERAL.PULL,t)},pullAll:function(t){return new i.UpdateCommand(i.UPDATE_COMMANDS_LITERAL.PULL_ALL,t)},pop:function(){return new i.UpdateCommand(i.UPDATE_COMMANDS_LITERAL.POP,[])},shift:function(){return new i.UpdateCommand(i.UPDATE_COMMANDS_LITERAL.SHIFT,[])},unshift:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=u.isArray(arguments[0])?arguments[0]:Array.from(arguments);return new i.UpdateCommand(i.UPDATE_COMMANDS_LITERAL.UNSHIFT,n)},addToSet:function(t){return new i.UpdateCommand(i.UPDATE_COMMANDS_LITERAL.ADD_TO_SET,t)},rename:function(t){return new i.UpdateCommand(i.UPDATE_COMMANDS_LITERAL.RENAME,[t])},bit:function(t){return new i.UpdateCommand(i.UPDATE_COMMANDS_LITERAL.BIT,[t])},max:function(t){return new i.UpdateCommand(i.UPDATE_COMMANDS_LITERAL.MAX,[t])},min:function(t){return new i.UpdateCommand(i.UPDATE_COMMANDS_LITERAL.MIN,[t])},expr:function(t){return{$expr:t}},jsonSchema:function(t){return{$jsonSchema:t}},text:function(t){return u.isString(t)?{$search:t.search}:{$search:t.search,$language:t.language,$caseSensitive:t.caseSensitive,$diacriticSensitive:t.diacriticSensitive}},aggregate:{pipeline:function(){return new s.default},abs:function(t){return new a("abs",t)},add:function(t){return new a("add",t)},ceil:function(t){return new a("ceil",t)},divide:function(t){return new a("divide",t)},exp:function(t){return new a("exp",t)},floor:function(t){return new a("floor",t)},ln:function(t){return new a("ln",t)},log:function(t){return new a("log",t)},log10:function(t){return new a("log10",t)},mod:function(t){return new a("mod",t)},multiply:function(t){return new a("multiply",t)},pow:function(t){return new a("pow",t)},sqrt:function(t){return new a("sqrt",t)},subtract:function(t){return new a("subtract",t)},trunc:function(t){return new a("trunc",t)},arrayElemAt:function(t){return new a("arrayElemAt",t)},arrayToObject:function(t){return new a("arrayToObject",t)},concatArrays:function(t){return new a("concatArrays",t)},filter:function(t){return new a("filter",t)},in:function(t){return new a("in",t)},indexOfArray:function(t){return new a("indexOfArray",t)},isArray:function(t){return new a("isArray",t)},map:function(t){return new a("map",t)},range:function(t){return new a("range",t)},reduce:function(t){return new a("reduce",t)},reverseArray:function(t){return new a("reverseArray",t)},size:function(t){return new a("size",t)},slice:function(t){return new a("slice",t)},zip:function(t){return new a("zip",t)},and:function(t){return new a("and",t)},not:function(t){return new a("not",t)},or:function(t){return new a("or",t)},cmp:function(t){return new a("cmp",t)},eq:function(t){return new a("eq",t)},gt:function(t){return new a("gt",t)},gte:function(t){return new a("gte",t)},lt:function(t){return new a("lt",t)},lte:function(t){return new a("lte",t)},neq:function(t){return new a("ne",t)},cond:function(t){return new a("cond",t)},ifNull:function(t){return new a("ifNull",t)},switch:function(t){return new a("switch",t)},dateFromParts:function(t){return new a("dateFromParts",t)},dateFromString:function(t){return new a("dateFromString",t)},dayOfMonth:function(t){return new a("dayOfMonth",t)},dayOfWeek:function(t){return new a("dayOfWeek",t)},dayOfYear:function(t){return new a("dayOfYear",t)},isoDayOfWeek:function(t){return new a("isoDayOfWeek",t)},isoWeek:function(t){return new a("isoWeek",t)},isoWeekYear:function(t){return new a("isoWeekYear",t)},millisecond:function(t){return new a("millisecond",t)},minute:function(t){return new a("minute",t)},month:function(t){return new a("month",t)},second:function(t){return new a("second",t)},hour:function(t){return new a("hour",t)},week:function(t){return new a("week",t)},year:function(t){return new a("year",t)},literal:function(t){return new a("literal",t)},mergeObjects:function(t){return new a("mergeObjects",t)},objectToArray:function(t){return new a("objectToArray",t)},allElementsTrue:function(t){return new a("allElementsTrue",t)},anyElementTrue:function(t){return new a("anyElementTrue",t)},setDifference:function(t){return new a("setDifference",t)},setEquals:function(t){return new a("setEquals",t)},setIntersection:function(t){return new a("setIntersection",t)},setIsSubset:function(t){return new a("setIsSubset",t)},setUnion:function(t){return new a("setUnion",t)},concat:function(t){return new a("concat",t)},dateToString:function(t){return new a("dateToString",t)},indexOfBytes:function(t){return new a("indexOfBytes",t)},indexOfCP:function(t){return new a("indexOfCP",t)},split:function(t){return new a("split",t)},strLenBytes:function(t){return new a("strLenBytes",t)},strLenCP:function(t){return new a("strLenCP",t)},strcasecmp:function(t){return new a("strcasecmp",t)},substr:function(t){return new a("substr",t)},substrBytes:function(t){return new a("substrBytes",t)},substrCP:function(t){return new a("substrCP",t)},toLower:function(t){return new a("toLower",t)},toUpper:function(t){return new a("toUpper",t)},meta:function(t){return new a("meta",t)},addToSet:function(t){return new a("addToSet",t)},avg:function(t){return new a("avg",t)},first:function(t){return new a("first",t)},last:function(t){return new a("last",t)},max:function(t){return new a("max",t)},min:function(t){return new a("min",t)},push:function(t){return new a("push",t)},stdDevPop:function(t){return new a("stdDevPop",t)},stdDevSamp:function(t){return new a("stdDevSamp",t)},sum:function(t){return new a("sum",t)},let:function(t){return new a("let",t)}},project:{slice:function(t){return new f("slice",t)},elemMatch:function(t){return new f("elemMatch",t)}}};var a=function(t,e){this["$"+t]=e},f=function(t,e){this["$"+t]=e};e.default=e.Command},443:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var r,o=n(703),i=n(488);e.AND="and",e.OR="or",e.NOT="not",e.NOR="nor",function(t){t.AND="and",t.OR="or",t.NOT="not",t.NOR="nor"}(r=e.LOGIC_COMMANDS_LITERAL||(e.LOGIC_COMMANDS_LITERAL={}));var u=function(){function t(t,e,n){if(this._internalType=o.SYMBOL_LOGIC_COMMAND,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||o.SYMBOL_UNSET_FIELD_NAME,this.fieldName!==o.SYMBOL_UNSET_FIELD_NAME)if(Array.isArray(e)){e=e.slice(),this.operands=e;for(var r=0,u=e.length;r<u;r++)(s(a=e[r])||i.isQueryCommand(a))&&(e[r]=a._setFieldName(this.fieldName))}else{var a;(s(a=e)||i.isQueryCommand(a))&&(e=a._setFieldName(this.fieldName))}}return t.prototype._setFieldName=function(e){var n=this.operands.map((function(n){return n instanceof t?n._setFieldName(e):n}));return new t(this.operator,n,e)},t.prototype.and=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return o.unshift(this),new t(r.AND,o,this.fieldName)},t.prototype.or=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var o=Array.isArray(arguments[0])?arguments[0]:Array.from(arguments);return o.unshift(this),new t(r.OR,o,this.fieldName)},t}();function s(t){return t&&t instanceof u&&t._internalType===o.SYMBOL_LOGIC_COMMAND}e.LogicCommand=u,e.isLogicCommand=s,e.isKnownLogicCommand=function(t){return s&&t.operator.toUpperCase()in r},e.default=u},488:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},r(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var i,u=n(443),s=n(703),a=n(458),f=n(428);e.EQ="eq",e.NEQ="neq",e.GT="gt",e.GTE="gte",e.LT="lt",e.LTE="lte",e.IN="in",e.NIN="nin",e.ALL="all",e.ELEM_MATCH="elemMatch",e.EXISTS="exists",e.SIZE="size",e.MOD="mod",function(t){t.EQ="eq",t.NEQ="neq",t.GT="gt",t.GTE="gte",t.LT="lt",t.LTE="lte",t.IN="in",t.NIN="nin",t.ALL="all",t.ELEM_MATCH="elemMatch",t.EXISTS="exists",t.SIZE="size",t.MOD="mod",t.GEO_NEAR="geoNear",t.GEO_WITHIN="geoWithin",t.GEO_INTERSECTS="geoIntersects"}(i=e.QUERY_COMMANDS_LITERAL||(e.QUERY_COMMANDS_LITERAL={}));var c=function(t){function e(e,n,r){var o=t.call(this,e,n,r)||this;return o.operator=e,o._internalType=s.SYMBOL_QUERY_COMMAND,o}return o(e,t),e.prototype.toJSON=function(){var t,e;switch(this.operator){case i.IN:case i.NIN:return(t={})["$"+this.operator]=this.operands,t;default:return(e={})["$"+this.operator]=this.operands[0],e}},e.prototype._setFieldName=function(t){return new e(this.operator,this.operands,t)},e.prototype.eq=function(t){var n=new e(i.EQ,[t],this.fieldName);return this.and(n)},e.prototype.neq=function(t){var n=new e(i.NEQ,[t],this.fieldName);return this.and(n)},e.prototype.gt=function(t){var n=new e(i.GT,[t],this.fieldName);return this.and(n)},e.prototype.gte=function(t){var n=new e(i.GTE,[t],this.fieldName);return this.and(n)},e.prototype.lt=function(t){var n=new e(i.LT,[t],this.fieldName);return this.and(n)},e.prototype.lte=function(t){var n=new e(i.LTE,[t],this.fieldName);return this.and(n)},e.prototype.in=function(t){var n=new e(i.IN,t,this.fieldName);return this.and(n)},e.prototype.nin=function(t){var n=new e(i.NIN,t,this.fieldName);return this.and(n)},e.prototype.geoNear=function(t){if(!(t.geometry instanceof a.Point))throw new TypeError('"geometry" must be of type Point. Received type '+typeof t.geometry);if(void 0!==t.maxDistance&&!f.isNumber(t.maxDistance))throw new TypeError('"maxDistance" must be of type Number. Received type '+typeof t.maxDistance);if(void 0!==t.minDistance&&!f.isNumber(t.minDistance))throw new TypeError('"minDistance" must be of type Number. Received type '+typeof t.minDistance);var n=new e(i.GEO_NEAR,[t],this.fieldName);return this.and(n)},e.prototype.geoWithin=function(t){if(!(t.geometry instanceof a.MultiPolygon||t.geometry instanceof a.Polygon))throw new TypeError('"geometry" must be of type Polygon or MultiPolygon. Received type '+typeof t.geometry);var n=new e(i.GEO_WITHIN,[t],this.fieldName);return this.and(n)},e.prototype.geoIntersects=function(t){if(!(t.geometry instanceof a.Point||t.geometry instanceof a.LineString||t.geometry instanceof a.Polygon||t.geometry instanceof a.MultiPoint||t.geometry instanceof a.MultiLineString||t.geometry instanceof a.MultiPolygon))throw new TypeError('"geometry" must be of type Point, LineString, Polygon, MultiPoint, MultiLineString or MultiPolygon. Received type '+typeof t.geometry);var n=new e(i.GEO_INTERSECTS,[t],this.fieldName);return this.and(n)},e}(u.LogicCommand);function l(t){return t&&t instanceof c&&t._internalType===s.SYMBOL_QUERY_COMMAND}e.QueryCommand=c,e.isQueryCommand=l,e.isKnownQueryCommand=function(t){return l(t)&&t.operator.toUpperCase()in i},e.isComparisonCommand=function(t){return l(t)},e.default=c},750:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var r,o=n(703);!function(t){t.SET="set",t.REMOVE="remove",t.INC="inc",t.MUL="mul",t.PUSH="push",t.PULL="pull",t.PULL_ALL="pullAll",t.POP="pop",t.SHIFT="shift",t.UNSHIFT="unshift",t.ADD_TO_SET="addToSet",t.BIT="bit",t.RENAME="rename",t.MAX="max",t.MIN="min"}(r=e.UPDATE_COMMANDS_LITERAL||(e.UPDATE_COMMANDS_LITERAL={}));var i=function(){function t(t,e,n){this._internalType=o.SYMBOL_UPDATE_COMMAND,Object.defineProperties(this,{_internalType:{enumerable:!1,configurable:!1}}),this.operator=t,this.operands=e,this.fieldName=n||o.SYMBOL_UNSET_FIELD_NAME}return t.prototype._setFieldName=function(e){return new t(this.operator,this.operands,e)},t}();function u(t){return t&&t instanceof i&&t._internalType===o.SYMBOL_UPDATE_COMMAND}e.UpdateCommand=i,e.isUpdateCommand=u,e.isKnownUpdateCommand=function(t){return u(t)&&t.operator.toUpperCase()in r},e.default=i},659:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ERRORS={CREATE_WATCH_NET_ERROR:{code:"CREATE_WATCH_NET_ERROR",message:"create watch network error"},CREATE_WACTH_EXCEED_ERROR:{code:"CREATE_WACTH_EXCEED_ERROR",message:"maximum connections exceed"},CREATE_WATCH_SERVER_ERROR:{code:"CREATE_WATCH_SERVER_ERROR",message:"create watch server error"},CONN_ERROR:{code:"CONN_ERROR",message:"connection error"},INVALID_PARAM:{code:"INVALID_PARAM",message:"Invalid request param"},INSERT_DOC_FAIL:{code:"INSERT_DOC_FAIL",message:"insert document failed"},DATABASE_TRANSACTION_CONFLICT:{code:"DATABASE_TRANSACTION_CONFLICT",message:"database transaction conflict"}}},952:(t,e)=>{var n,r,o;Object.defineProperty(e,"__esModule",{value:!0}),function(t){t.DocIDError="文档ID不合法",t.CollNameError="集合名称不合法",t.OpStrError="操作符不合法",t.DirectionError="排序字符不合法",t.IntergerError="must be integer",t.QueryParamTypeError="查询参数必须为对象",t.QueryParamValueError="查询参数对象值不能均为undefined"}(r||(r={})),e.ErrorCode=r,e.FieldType={String:"String",Number:"Number",Object:"Object",Array:"Array",Boolean:"Boolean",Null:"Null",GeoPoint:"GeoPoint",GeoLineString:"GeoLineString",GeoPolygon:"GeoPolygon",GeoMultiPoint:"GeoMultiPoint",GeoMultiLineString:"GeoMultiLineString",GeoMultiPolygon:"GeoMultiPolygon",Timestamp:"Date",Command:"Command",ServerDate:"ServerDate",BsonDate:"BsonDate"},e.OrderDirectionList=["desc","asc"],e.WhereFilterOpList=["<","<=","==",">=",">"],function(t){t.lt="<",t.gt=">",t.lte="<=",t.gte=">=",t.eq="=="}(o||(o={})),e.Opeartor=o;var i,u=((n={})[o.eq]="$eq",n[o.lt]="$lt",n[o.lte]="$lte",n[o.gt]="$gt",n[o.gte]="$gte",n);e.OperatorMap=u,e.UpdateOperatorList=["$set","$inc","$mul","$unset","$push","$pop","$unshift","$shift","$currentDate","$each","$position"],function(t){t.WHERE="WHERE",t.DOC="DOC"}(i||(i={})),e.QueryType=i},929:function(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var o=n(393),i=n(672),u=n(355),s=n(840),a=n(537),f=n(750),c=n(952),l=n(195),p=function(){function t(t,e,n,o){var u=this;void 0===o&&(o={}),this.watch=function(t){return l.getWsInstance(u._db).watch(r(r({},t),{envId:u._db.config.env,collectionName:u._coll,query:JSON.stringify({_id:u.id})}))},this._db=t,this._coll=e,this.id=n,this.request=new i.Db.reqClass(this._db.config),this.projection=o}return t.prototype.create=function(t,e){e=e||o.createPromiseCallback();var n={collectionName:this._coll,data:a.serialize(t)};return this.id&&(n._id=this.id),this.request.send("database.addDocument",n).then((function(t){t.code?e(0,t):e(0,{id:t.data._id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.set=function(t,e){if(e=e||o.createPromiseCallback(),!this.id)return Promise.resolve({code:"INVALID_PARAM",message:"docId不能为空"});if(!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n=!1,r=function(t){if("object"==typeof t)for(var e in t)t[e]instanceof f.UpdateCommand?n=!0:"object"==typeof t[e]&&r(t[e])};if(r(t),n)return Promise.resolve({code:"DATABASE_REQUEST_FAILED",message:"update operator complicit"});var i={collectionName:this._coll,queryType:c.QueryType.DOC,data:a.serialize(t),multi:!1,merge:!1,upsert:!0};return this.id&&(i.query={_id:this.id}),this.request.send("database.updateDocument",i).then((function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.update=function(t,e){if(e=e||o.createPromiseCallback(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={_id:this.id},r={collectionName:this._coll,data:s.UpdateSerializer.encode(t),query:n,queryType:c.QueryType.DOC,multi:!1,merge:!0,upsert:!1};return this.request.send("database.updateDocument",r).then((function(t){t.code?e(0,t):e(0,{updated:t.data.updated,upsertedId:t.data.upserted_id,requestId:t.requestId})})).catch((function(t){e(t)})),e.promise},t.prototype.remove=function(t){t=t||o.createPromiseCallback();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:c.QueryType.DOC,multi:!1};return this.request.send("database.deleteDocument",n).then((function(e){e.code?t(0,e):t(0,{deleted:e.data.deleted,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},t.prototype.get=function(t){t=t||o.createPromiseCallback();var e={_id:this.id},n={collectionName:this._coll,query:e,queryType:c.QueryType.DOC,multi:!1,projection:this.projection};return this.request.send("database.queryDocument",n).then((function(e){if(e.code)t(0,e);else{var n=u.Util.formatResDocumentData(e.data.list);t(0,{data:n,requestId:e.requestId})}})).catch((function(e){t(e)})),t.promise},t.prototype.field=function(e){for(var n in e)e[n]?e[n]=1:e[n]=0;return new t(this._db,this._coll,this.id,e)},t}();e.DocumentReference=p},458:(t,e,n)=>{function r(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}Object.defineProperty(e,"__esModule",{value:!0}),r(n(536)),r(n(252)),r(n(663)),r(n(625)),r(n(303)),r(n(777))},252:function(t,e,n){var r=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0});var o=n(703),i=n(536),u=n(428),s=function(){function t(t){if(!u.isArray(t))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t);if(t.length<2)throw new Error('"points" must contain 2 points at least');t.forEach((function(t){if(!(t instanceof i.Point))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t+"[]")})),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"LineString",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))},e},t.prototype.toJSON=function(){return{type:"LineString",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))}},t.validate=function(t){var e,n;if("LineString"!==t.type||!u.isArray(t.coordinates))return!1;try{for(var o=r(t.coordinates),i=o.next();!i.done;i=o.next()){var s=i.value;if(!u.isNumber(s[0])||!u.isNumber(s[1]))return!1}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return!0},t.isClosed=function(t){var e=t.points[0],n=t.points[t.points.length-1];if(e.latitude===n.latitude&&e.longitude===n.longitude)return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return o.SYMBOL_GEO_LINE_STRING},enumerable:!0,configurable:!0}),t}();e.LineString=s},303:function(t,e,n){var r=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0});var o=n(703),i=n(428),u=n(252),s=function(){function t(t){if(!i.isArray(t))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t);if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof u.LineString))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t+"[]")})),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiLineString",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))},e},t.prototype.toJSON=function(){return{type:"MultiLineString",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}},t.validate=function(t){var e,n,o,u;if("MultiLineString"!==t.type||!i.isArray(t.coordinates))return!1;try{for(var s=r(t.coordinates),a=s.next();!a.done;a=s.next()){var f=a.value;try{for(var c=(o=void 0,r(f)),l=c.next();!l.done;l=c.next()){var p=l.value;if(!i.isNumber(p[0])||!i.isNumber(p[1]))return!1}}catch(t){o={error:t}}finally{try{l&&!l.done&&(u=c.return)&&u.call(c)}finally{if(o)throw o.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return o.SYMBOL_GEO_MULTI_LINE_STRING},enumerable:!0,configurable:!0}),t}();e.MultiLineString=s},625:function(t,e,n){var r=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0});var o=n(703),i=n(536),u=n(428),s=function(){function t(t){if(!u.isArray(t))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t);if(0===t.length)throw new Error('"points" must contain 1 point at least');t.forEach((function(t){if(!(t instanceof i.Point))throw new TypeError('"points" must be of type Point[]. Received type '+typeof t+"[]")})),this.points=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPoint",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))},e},t.prototype.toJSON=function(){return{type:"MultiPoint",coordinates:this.points.map((function(t){return t.toJSON().coordinates}))}},t.validate=function(t){var e,n;if("MultiPoint"!==t.type||!u.isArray(t.coordinates))return!1;try{for(var o=r(t.coordinates),i=o.next();!i.done;i=o.next()){var s=i.value;if(!u.isNumber(s[0])||!u.isNumber(s[1]))return!1}}catch(t){e={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return o.SYMBOL_GEO_MULTI_POINT},enumerable:!0,configurable:!0}),t}();e.MultiPoint=s},777:function(t,e,n){var r=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0});var o=n(703),i=n(428),u=n(663),s=function(){function t(t){var e,n;if(!i.isArray(t))throw new TypeError('"polygons" must be of type Polygon[]. Received type '+typeof t);if(0===t.length)throw new Error("MultiPolygon must contain 1 polygon at least");try{for(var o=r(t),s=o.next();!s.done;s=o.next()){var a=s.value;if(!(a instanceof u.Polygon))throw new TypeError('"polygon" must be of type Polygon[]. Received type '+typeof a+"[]")}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}this.polygons=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"MultiPolygon",coordinates:this.polygons.map((function(t){return t.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}))},e},t.prototype.toJSON=function(){return{type:"MultiPolygon",coordinates:this.polygons.map((function(t){return t.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}))}},t.validate=function(t){var e,n,o,u,s,a;if("MultiPolygon"!==t.type||!i.isArray(t.coordinates))return!1;try{for(var f=r(t.coordinates),c=f.next();!c.done;c=f.next()){var l=c.value;try{for(var p=(o=void 0,r(l)),h=p.next();!h.done;h=p.next()){var d=h.value;try{for(var y=(s=void 0,r(d)),g=y.next();!g.done;g=y.next()){var m=g.value;if(!i.isNumber(m[0])||!i.isNumber(m[1]))return!1}}catch(t){s={error:t}}finally{try{g&&!g.done&&(a=y.return)&&a.call(y)}finally{if(s)throw s.error}}}}catch(t){o={error:t}}finally{try{h&&!h.done&&(u=p.return)&&u.call(p)}finally{if(o)throw o.error}}}}catch(t){e={error:t}}finally{try{c&&!c.done&&(n=f.return)&&n.call(f)}finally{if(e)throw e.error}}return!0},Object.defineProperty(t.prototype,"_internalType",{get:function(){return o.SYMBOL_GEO_POLYGON},enumerable:!0,configurable:!0}),t}();e.MultiPolygon=s},536:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=n(353),o=n(703),i=n(428),u=function(){function t(t,e){r.Validate.isGeopoint("longitude",t),r.Validate.isGeopoint("latitude",e),this.longitude=t,this.latitude=e}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Point",coordinates:[this.longitude,this.latitude]},e},t.prototype.toJSON=function(){return{type:"Point",coordinates:[this.longitude,this.latitude]}},t.prototype.toReadableString=function(){return"["+this.longitude+","+this.latitude+"]"},t.validate=function(t){return"Point"===t.type&&i.isArray(t.coordinates)&&r.Validate.isGeopoint("longitude",t.coordinates[0])&&r.Validate.isGeopoint("latitude",t.coordinates[1])},Object.defineProperty(t.prototype,"_internalType",{get:function(){return o.SYMBOL_GEO_POINT},enumerable:!0,configurable:!0}),t}();e.Point=u},663:function(t,e,n){var r=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(e,"__esModule",{value:!0});var o=n(703),i=n(428),u=n(252),s=function(){function t(t){if(!i.isArray(t))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t);if(0===t.length)throw new Error("Polygon must contain 1 linestring at least");t.forEach((function(t){if(!(t instanceof u.LineString))throw new TypeError('"lines" must be of type LineString[]. Received type '+typeof t+"[]");if(!u.LineString.isClosed(t))throw new Error("LineString "+t.points.map((function(t){return t.toReadableString()}))+" is not a closed cycle")})),this.lines=t}return t.prototype.parse=function(t){var e;return(e={})[t]={type:"Polygon",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))},e},t.prototype.toJSON=function(){return{type:"Polygon",coordinates:this.lines.map((function(t){return t.points.map((function(t){return[t.longitude,t.latitude]}))}))}},t.validate=function(t){var e,n,o,u;if("Polygon"!==t.type||!i.isArray(t.coordinates))return!1;try{for(var s=r(t.coordinates),a=s.next();!a.done;a=s.next()){var f=a.value;if(!this.isCloseLineString(f))return!1;try{for(var c=(o=void 0,r(f)),l=c.next();!l.done;l=c.next()){var p=l.value;if(!i.isNumber(p[0])||!i.isNumber(p[1]))return!1}}catch(t){o={error:t}}finally{try{l&&!l.done&&(u=c.return)&&u.call(c)}finally{if(o)throw o.error}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}return!0},t.isCloseLineString=function(t){var e=t[0],n=t[t.length-1];return e[0]===n[0]&&e[1]===n[1]},Object.defineProperty(t.prototype,"_internalType",{get:function(){return o.SYMBOL_GEO_MULTI_POLYGON},enumerable:!0,configurable:!0}),t}();e.Polygon=s},703:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=n(278);!function(t){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n])}(n(278)),e.SYMBOL_UNSET_FIELD_NAME=r.default.for("UNSET_FIELD_NAME"),e.SYMBOL_UPDATE_COMMAND=r.default.for("UPDATE_COMMAND"),e.SYMBOL_QUERY_COMMAND=r.default.for("QUERY_COMMAND"),e.SYMBOL_LOGIC_COMMAND=r.default.for("LOGIC_COMMAND"),e.SYMBOL_GEO_POINT=r.default.for("GEO_POINT"),e.SYMBOL_GEO_LINE_STRING=r.default.for("SYMBOL_GEO_LINE_STRING"),e.SYMBOL_GEO_POLYGON=r.default.for("SYMBOL_GEO_POLYGON"),e.SYMBOL_GEO_MULTI_POINT=r.default.for("SYMBOL_GEO_MULTI_POINT"),e.SYMBOL_GEO_MULTI_LINE_STRING=r.default.for("SYMBOL_GEO_MULTI_LINE_STRING"),e.SYMBOL_GEO_MULTI_POLYGON=r.default.for("SYMBOL_GEO_MULTI_POLYGON"),e.SYMBOL_SERVER_DATE=r.default.for("SERVER_DATE"),e.SYMBOL_REGEXP=r.default.for("REGEXP")},672:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=n(458),o=n(318),i=n(407),u=n(564),s=n(773),a=n(39),f=n(443),c=n(488),l=n(750),p=n(660);e.Query=p.Query;var h=n(318);e.CollectionReference=h.CollectionReference;var d=n(929);e.DocumentReference=d.DocumentReference;var y=function(){function t(t){this.config=t,this.Geo=r,this.serverDate=u.ServerDateConstructor,this.command=i.Command,this.RegExp=s.RegExpConstructor,this.startTransaction=a.startTransaction,this.runTransaction=a.runTransaction,this.logicCommand=f.LogicCommand,this.updateCommand=l.UpdateCommand,this.queryCommand=c.QueryCommand}return t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new o.CollectionReference(this,t)},t.prototype.createCollection=function(e){var n={collectionName:e};return new t.reqClass(this.config).send("database.addCollection",n)},t}();e.Db=y},393:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createPromiseCallback=function(){var t;if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var n=new Promise((function(e,n){t=function(t,r){return t?n(t):e(r)}}));return t.promise=n,t}},908:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=n(488),o=n(443),i=n(750);for(var u in e.OperatorMap={},r.QUERY_COMMANDS_LITERAL)e.OperatorMap[u]="$"+u;for(var u in o.LOGIC_COMMANDS_LITERAL)e.OperatorMap[u]="$"+u;for(var u in i.UPDATE_COMMANDS_LITERAL)e.OperatorMap[u]="$"+u;e.OperatorMap[r.QUERY_COMMANDS_LITERAL.NEQ]="$ne",e.OperatorMap[i.UPDATE_COMMANDS_LITERAL.REMOVE]="$unset",e.OperatorMap[i.UPDATE_COMMANDS_LITERAL.SHIFT]="$pop",e.OperatorMap[i.UPDATE_COMMANDS_LITERAL.UNSHIFT]="$push",e.operatorToString=function(t){return e.OperatorMap[t]||"$"+t}},660:function(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var o=n(393),i=n(952),u=n(672),s=n(353),a=n(355),f=n(947),c=n(840),l=n(952),p=n(195),h=function(){function t(t,e,n,o,i){var s=this;this.watch=function(t){return p.getWsInstance(s._db).watch(r(r({},t),{envId:s._db.config.env,collectionName:s._coll,query:JSON.stringify(s._fieldFilters||{}),limit:s._queryOptions.limit,orderBy:s._fieldOrders?s._fieldOrders.reduce((function(t,e){return t[e.field]=e.direction,t}),{}):void 0}))},this._db=t,this._coll=e,this._fieldFilters=n,this._fieldOrders=o||[],this._queryOptions=i||{},this._request=new u.Db.reqClass(this._db.config)}return t.prototype.get=function(t){t=t||o.createPromiseCallback();var e=[];this._fieldOrders&&this._fieldOrders.forEach((function(t){e.push(t)}));var n={collectionName:this._coll,queryType:i.QueryType.WHERE};return this._fieldFilters&&(n.query=this._fieldFilters),e.length>0&&(n.order=e),this._queryOptions.offset&&(n.offset=this._queryOptions.offset),this._queryOptions.limit?n.limit=this._queryOptions.limit<1e3?this._queryOptions.limit:1e3:n.limit=100,this._queryOptions.projection&&(n.projection=this._queryOptions.projection),this._request.send("database.queryDocument",n).then((function(e){if(e.code)t(0,e);else{var n={data:a.Util.formatResDocumentData(e.data.list),requestId:e.requestId};e.total&&(n.total=e.total),e.limit&&(n.limit=e.limit),e.offset&&(n.offset=e.offset),t(0,n)}})).catch((function(e){t(e)})),t.promise},t.prototype.count=function(t){t=t||o.createPromiseCallback();var e={collectionName:this._coll,queryType:i.QueryType.WHERE};return this._fieldFilters&&(e.query=this._fieldFilters),this._request.send("database.countDocument",e).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,total:e.data.total})})).catch((function(e){t(e)})),t.promise},t.prototype.where=function(e){if("Object"!==Object.prototype.toString.call(e).slice(8,-1))throw Error(l.ErrorCode.QueryParamTypeError);var n=Object.keys(e),r=n.some((function(t){return void 0!==e[t]}));if(n.length&&!r)throw Error(l.ErrorCode.QueryParamValueError);return new t(this._db,this._coll,f.QuerySerializer.encode(e),this._fieldOrders,this._queryOptions)},t.prototype.orderBy=function(e,n){s.Validate.isFieldPath(e),s.Validate.isFieldOrder(n);var r={field:e,direction:n},o=this._fieldOrders.concat(r);return new t(this._db,this._coll,this._fieldFilters,o,this._queryOptions)},t.prototype.limit=function(e){s.Validate.isInteger("limit",e);var n=r({},this._queryOptions);return n.limit=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.skip=function(e){s.Validate.isInteger("offset",e);var n=r({},this._queryOptions);return n.offset=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,n)},t.prototype.update=function(t,e){if(e=e||o.createPromiseCallback(),!t||"object"!=typeof t)return Promise.resolve({code:"INVALID_PARAM",message:"参数必需是非空对象"});if(t.hasOwnProperty("_id"))return Promise.resolve({code:"INVALID_PARAM",message:"不能更新_id的值"});var n={collectionName:this._coll,query:this._fieldFilters,queryType:i.QueryType.WHERE,multi:!0,merge:!0,upsert:!1,data:c.UpdateSerializer.encode(t)};return this._request.send("database.updateDocument",n).then((function(t){t.code?e(0,t):e(0,{requestId:t.requestId,updated:t.data.updated,upsertId:t.data.upsert_id})})).catch((function(t){e(t)})),e.promise},t.prototype.field=function(e){for(var n in e)e[n]?"object"!=typeof e[n]&&(e[n]=1):e[n]=0;var o=r({},this._queryOptions);return o.projection=e,new t(this._db,this._coll,this._fieldFilters,this._fieldOrders,o)},t.prototype.remove=function(t){t=t||o.createPromiseCallback(),Object.keys(this._queryOptions).length>0&&console.warn("`offset`, `limit` and `projection` are not supported in remove() operation"),this._fieldOrders.length>0&&console.warn("`orderBy` is not supported in remove() operation");var e={collectionName:this._coll,query:f.QuerySerializer.encode(this._fieldFilters),queryType:i.QueryType.WHERE,multi:!0};return this._request.send("database.deleteDocument",e).then((function(e){e.code?t(0,e):t(0,{requestId:e.requestId,deleted:e.data.deleted})})).catch((function(e){t(e)})),t.promise},t}();e.Query=h},773:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=n(703),o=function(){function t(t){var e=t.regexp,n=t.options;if(!e)throw new TypeError("regexp must be a string");this.$regex=e,this.$options=n}return t.prototype.parse=function(){return{$regex:this.$regex,$options:this.$options}},Object.defineProperty(t.prototype,"_internalType",{get:function(){return r.SYMBOL_REGEXP},enumerable:!0,configurable:!0}),t}();e.RegExp=o,e.RegExpConstructor=function(t){return new o(t)}},107:function(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u},i=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(o(arguments[e]));return t};Object.defineProperty(e,"__esModule",{value:!0});var u=n(428),s=n(537);function a(t,e,n,o){var s=r({},t);for(var f in t)if(!/^\$/.test(f)){var c=t[f];if(c&&u.isObject(c)&&!e(c)){if(o.indexOf(c)>-1)throw new Error("Cannot convert circular structure to JSON");var l=a(c,e,i(n,[f]),i(o,[c]));s[f]=l;var p=!1;for(var h in l)/^\$/.test(h)?p=!0:(s[f+"."+h]=l[h],delete s[f][h]);p||delete s[f]}}return s}function f(t){return u.isInternalObject(t)||u.isDate(t)||u.isRegExp(t)}e.flattenQueryObject=function(t){return a(t,f,[],[t])},e.flattenObject=function(t){return a(t,(function(t){return!1}),[],[t])},e.mergeConditionAfterEncode=function(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?u.isArray(t[r])?t[r].push(e[r]):u.isObject(t[r])?u.isObject(e[r])?Object.assign(t[r],e[r]):(console.warn("unmergable condition, query is object but condition is "+u.getType(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+u.getType(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]},e.isConversionRequired=f,e.encodeInternalDataType=function(t){return s.serialize(t)},e.decodeInternalDataType=function(t){return s.deserialize(t)}},537:function(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u},i=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(o(arguments[e]));return t};Object.defineProperty(e,"__esModule",{value:!0});var u=n(703),s=n(428),a=n(458),f=n(564);function c(t,e){if(!s.isInternalObject(t)){if(s.isDate(t))return{$date:+t};if(s.isRegExp(t))return{$regex:t.source,$options:t.flags};if(s.isArray(t))return t.map((function(t){if(e.indexOf(t)>-1)throw new Error("Cannot convert circular structure to JSON");return c(t,i(e,[t]))}));if(s.isObject(t)){var n=r({},t);for(var o in n){if(e.indexOf(n[o])>-1)throw new Error("Cannot convert circular structure to JSON");n[o]=c(n[o],i(e,[n[o]]))}return n}return t}switch(t._internalType){case u.SYMBOL_GEO_POINT:return t.toJSON();case u.SYMBOL_SERVER_DATE:case u.SYMBOL_REGEXP:return t.parse();default:return t.toJSON?t.toJSON():t}}e.serialize=function(t){return c(t,[t])},e.deserialize=function(t){var e=r({},t);for(var n in e)switch(n){case"$date":switch(s.getType(e[n])){case"number":return new Date(e[n]);case"object":return new f.ServerDate(e[n])}break;case"type":if("Point"===e.type&&s.isArray(e.coordinates)&&s.isNumber(e.coordinates[0])&&s.isNumber(e.coordinates[1]))return new a.Point(e.coordinates[0],e.coordinates[1])}return t}},947:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=n(488),o=n(443),i=n(703),u=n(428),s=n(908),a=n(107),f=function(){function t(){}return t.encode=function(t){return(new c).encodeQuery(t)},t}();e.QuerySerializer=f;var c=function(){function t(){}return t.prototype.encodeQuery=function(t,e){var n;return a.isConversionRequired(t)?o.isLogicCommand(t)?this.encodeLogicCommand(t):r.isQueryCommand(t)?this.encodeQueryCommand(t):((n={})[e]=this.encodeQueryObject(t),n):u.isObject(t)?this.encodeQueryObject(t):t},t.prototype.encodeRegExp=function(t){return{$regex:t.source,$options:t.flags}},t.prototype.encodeLogicCommand=function(t){var e,n,r,i,a,f,c,l=this;switch(t.operator){case o.LOGIC_COMMANDS_LITERAL.NOR:case o.LOGIC_COMMANDS_LITERAL.AND:case o.LOGIC_COMMANDS_LITERAL.OR:var p=s.operatorToString(t.operator),h=t.operands.map((function(e){return l.encodeQuery(e,t.fieldName)}));return(e={})[p]=h,e;case o.LOGIC_COMMANDS_LITERAL.NOT:p=s.operatorToString(t.operator);var d=t.operands[0];return u.isRegExp(d)?((n={})[t.fieldName]=((r={})[p]=this.encodeRegExp(d),r),n):(h=this.encodeQuery(d)[t.fieldName],(i={})[t.fieldName]=((a={})[p]=h,a),i);default:if(p=s.operatorToString(t.operator),1===t.operands.length){var y=this.encodeQuery(t.operands[0]);return(f={})[p]=y,f}return h=t.operands.map(this.encodeQuery.bind(this)),(c={})[p]=h,c}},t.prototype.encodeQueryCommand=function(t){return r.isComparisonCommand(t),this.encodeComparisonCommand(t)},t.prototype.encodeComparisonCommand=function(t){var e,n,o,u,f,c,l,p,h;if(t.fieldName===i.SYMBOL_UNSET_FIELD_NAME)throw new Error("Cannot encode a comparison command with unset field name");var d=s.operatorToString(t.operator);switch(t.operator){case r.QUERY_COMMANDS_LITERAL.EQ:case r.QUERY_COMMANDS_LITERAL.NEQ:case r.QUERY_COMMANDS_LITERAL.LT:case r.QUERY_COMMANDS_LITERAL.LTE:case r.QUERY_COMMANDS_LITERAL.GT:case r.QUERY_COMMANDS_LITERAL.GTE:case r.QUERY_COMMANDS_LITERAL.ELEM_MATCH:case r.QUERY_COMMANDS_LITERAL.EXISTS:case r.QUERY_COMMANDS_LITERAL.SIZE:case r.QUERY_COMMANDS_LITERAL.MOD:return(e={})[t.fieldName]=((n={})[d]=a.encodeInternalDataType(t.operands[0]),n),e;case r.QUERY_COMMANDS_LITERAL.IN:case r.QUERY_COMMANDS_LITERAL.NIN:case r.QUERY_COMMANDS_LITERAL.ALL:return(o={})[t.fieldName]=((u={})[d]=a.encodeInternalDataType(t.operands),u),o;case r.QUERY_COMMANDS_LITERAL.GEO_NEAR:var y=t.operands[0];return(f={})[t.fieldName]={$nearSphere:{$geometry:y.geometry.toJSON(),$maxDistance:y.maxDistance,$minDistance:y.minDistance}},f;case r.QUERY_COMMANDS_LITERAL.GEO_WITHIN:return y=t.operands[0],(c={})[t.fieldName]={$geoWithin:{$geometry:y.geometry.toJSON()}},c;case r.QUERY_COMMANDS_LITERAL.GEO_INTERSECTS:return y=t.operands[0],(l={})[t.fieldName]={$geoIntersects:{$geometry:y.geometry.toJSON()}},l;default:return(p={})[t.fieldName]=((h={})[d]=a.encodeInternalDataType(t.operands[0]),h),p}},t.prototype.encodeQueryObject=function(t){var e=a.flattenQueryObject(t);for(var n in e){var i=e[n];if(o.isLogicCommand(i)){e[n]=i._setFieldName(n);var u=this.encodeLogicCommand(e[n]);this.mergeConditionAfterEncode(e,u,n)}else r.isComparisonCommand(i)?(e[n]=i._setFieldName(n),u=this.encodeComparisonCommand(e[n]),this.mergeConditionAfterEncode(e,u,n)):a.isConversionRequired(i)&&(e[n]=a.encodeInternalDataType(i))}return e},t.prototype.mergeConditionAfterEncode=function(t,e,n){for(var r in e[n]||delete t[n],e)t[r]?u.isArray(t[r])?t[r]=t[r].concat(e[r]):u.isObject(t[r])?u.isObject(e[r])?Object.assign(t,e):(console.warn("unmergable condition, query is object but condition is "+u.getType(e)+", can only overwrite",e,n),t[r]=e[r]):(console.warn("to-merge query is of type "+u.getType(t)+", can only overwrite",t,e,n),t[r]=e[r]):t[r]=e[r]},t}()},840:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=n(750),o=n(703),i=n(428),u=n(908),s=n(107),a=function(){function t(){}return t.encode=function(e){return(new t).encodeUpdate(e)},t.prototype.encodeUpdate=function(t){return r.isUpdateCommand(t)?this.encodeUpdateCommand(t):"object"===i.getType(t)?this.encodeUpdateObject(t):t},t.prototype.encodeUpdateCommand=function(t){if(t.fieldName===o.SYMBOL_UNSET_FIELD_NAME)throw new Error("Cannot encode a comparison command with unset field name");switch(t.operator){case r.UPDATE_COMMANDS_LITERAL.PUSH:case r.UPDATE_COMMANDS_LITERAL.PULL:case r.UPDATE_COMMANDS_LITERAL.PULL_ALL:case r.UPDATE_COMMANDS_LITERAL.POP:case r.UPDATE_COMMANDS_LITERAL.SHIFT:case r.UPDATE_COMMANDS_LITERAL.UNSHIFT:case r.UPDATE_COMMANDS_LITERAL.ADD_TO_SET:return this.encodeArrayUpdateCommand(t);default:return this.encodeFieldUpdateCommand(t)}},t.prototype.encodeFieldUpdateCommand=function(t){var e,n,o,i,s=u.operatorToString(t.operator);return t.operator===r.UPDATE_COMMANDS_LITERAL.REMOVE?((e={})[s]=((n={})[t.fieldName]="",n),e):((o={})[s]=((i={})[t.fieldName]=t.operands[0],i),o)},t.prototype.encodeArrayUpdateCommand=function(t){var e,n,o,a,f,c,l,p,h,d,y=u.operatorToString(t.operator);switch(t.operator){case r.UPDATE_COMMANDS_LITERAL.PUSH:var g=void 0;return g=i.isArray(t.operands)?{$each:t.operands.map(s.encodeInternalDataType)}:t.operands,(e={})[y]=((n={})[t.fieldName]=g,n),e;case r.UPDATE_COMMANDS_LITERAL.UNSHIFT:return g={$each:t.operands.map(s.encodeInternalDataType),$position:0},(o={})[y]=((a={})[t.fieldName]=g,a),o;case r.UPDATE_COMMANDS_LITERAL.POP:return(f={})[y]=((c={})[t.fieldName]=1,c),f;case r.UPDATE_COMMANDS_LITERAL.SHIFT:return(l={})[y]=((p={})[t.fieldName]=-1,p),l;default:return(h={})[y]=((d={})[t.fieldName]=s.encodeInternalDataType(t.operands),d),h}},t.prototype.encodeUpdateObject=function(t){var e=s.flattenQueryObject(t);for(var n in e)if(!/^\$/.test(n)){var o=e[n];if(r.isUpdateCommand(o)){e[n]=o._setFieldName(n);var i=this.encodeUpdateCommand(e[n]);s.mergeConditionAfterEncode(e,i,n)}else{e[n]=o=s.encodeInternalDataType(o);var u=new r.UpdateCommand(r.UPDATE_COMMANDS_LITERAL.SET,[o],n);i=this.encodeUpdateCommand(u),s.mergeConditionAfterEncode(e,i,n)}}return e},t}();e.UpdateSerializer=a},564:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=n(703),o=function(){function t(t){var e=(void 0===t?{}:t).offset,n=void 0===e?0:e;this.offset=n}return Object.defineProperty(t.prototype,"_internalType",{get:function(){return r.SYMBOL_SERVER_DATE},enumerable:!0,configurable:!0}),t.prototype.parse=function(){return{$date:{offset:this.offset}}},t}();e.ServerDate=o,e.ServerDateConstructor=function(t){return new o(t)}},621:function(t,e,n){var r,o=this&&this.__extends||(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},r(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var i=n(873),u=function(t){function e(e,n){return t.call(this,e,n)||this}return o(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return this._coll},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){if("string"!=typeof t&&"number"!=typeof t)throw new Error("docId必须为字符串或数字");return new i.DocumentReference(this._transaction,this._coll,t)},e.prototype.add=function(t){var e;return void 0!==t._id&&(e=t._id),new i.DocumentReference(this._transaction,this._coll,e).create(t)},e}(n(918).Query);e.CollectionReference=u},873:function(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};Object.defineProperty(e,"__esModule",{value:!0});var u=n(762),s=n(659),a=n(840),f=n(537),c=n(355),l="database.updateDocInTransaction",p=function(){function t(t,e,n){this._coll=e,this.id=n,this._transaction=t,this._request=this._transaction.getRequestMethod(),this._transactionId=this._transaction.getTransactionId()}return t.prototype.create=function(t){return o(this,void 0,void 0,(function(){var e,n,o,a;return i(this,(function(i){switch(i.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,data:u.EJSON.stringify(f.serialize(t),{relaxed:!1})},this.id&&(e._id=this.id),[4,this._request.send("database.insertDocInTransaction",e)];case 1:if((n=i.sent()).code)throw n;if(o=u.EJSON.parse(n.inserted),1==(a=u.EJSON.parse(n.ok))&&1==o)return[2,r(r({},n),{ok:a,inserted:o})];throw new Error(s.ERRORS.INSERT_DOC_FAIL.message)}}))}))},t.prototype.get=function(){return o(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.getInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,{data:"null"!==e.data?c.Util.formatField(u.EJSON.parse(e.data)):u.EJSON.parse(e.data),requestId:e.requestId}]}}))}))},t.prototype.set=function(t){return o(this,void 0,void 0,(function(){var e,n;return i(this,(function(o){switch(o.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:u.EJSON.stringify(f.serialize(t),{relaxed:!1}),upsert:!0},[4,this._request.send(l,e)];case 1:if((n=o.sent()).code)throw n;return[2,r(r({},n),{updated:u.EJSON.parse(n.updated),upserted:n.upserted?JSON.parse(n.upserted):null})]}}))}))},t.prototype.update=function(t){return o(this,void 0,void 0,(function(){var e,n;return i(this,(function(o){switch(o.label){case 0:return e={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}},data:u.EJSON.stringify(a.UpdateSerializer.encode(t),{relaxed:!1})},[4,this._request.send(l,e)];case 1:if((n=o.sent()).code)throw n;return[2,r(r({},n),{updated:u.EJSON.parse(n.updated)})]}}))}))},t.prototype.delete=function(){return o(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return t={collectionName:this._coll,transactionId:this._transactionId,query:{_id:{$eq:this.id}}},[4,this._request.send("database.deleteDocInTransaction",t)];case 1:if((e=n.sent()).code)throw e;return[2,r(r({},e),{deleted:u.EJSON.parse(e.deleted)})]}}))}))},t}();e.DocumentReference=p},39:function(t,e,n){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}a((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!((o=(o=u.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}};Object.defineProperty(e,"__esModule",{value:!0});var i=n(672),u=n(621),s=n(659),a=function(){function t(t){this._db=t,this._request=new i.Db.reqClass(this._db.config),this.aborted=!1,this.commited=!1,this.inited=!1}return t.prototype.init=function(){return r(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return[4,this._request.send("database.startTransaction")];case 1:if((t=e.sent()).code)throw t;return this.inited=!0,this._id=t.transactionId,[2]}}))}))},t.prototype.collection=function(t){if(!t)throw new Error("Collection name is required");return new u.CollectionReference(this,t)},t.prototype.getTransactionId=function(){return this._id},t.prototype.getRequestMethod=function(){return this._request},t.prototype.commit=function(){return r(this,void 0,void 0,(function(){var t,e;return o(this,(function(n){switch(n.label){case 0:return t={transactionId:this._id},[4,this._request.send("database.commitTransaction",t)];case 1:if((e=n.sent()).code)throw e;return this.commited=!0,[2,e]}}))}))},t.prototype.rollback=function(t){return r(this,void 0,void 0,(function(){var e,n;return o(this,(function(r){switch(r.label){case 0:return e={transactionId:this._id},[4,this._request.send("database.abortTransaction",e)];case 1:if((n=r.sent()).code)throw n;return this.aborted=!0,this.abortReason=t,[2,n]}}))}))},t}();e.Transaction=a,e.startTransaction=function(){return r(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return[4,(t=new a(this)).init()];case 1:return e.sent(),[2,t]}}))}))},e.runTransaction=function t(e,n){return void 0===n&&(n=3),r(this,void 0,void 0,(function(){var i,u,f,c,l=this;return o(this,(function(p){switch(p.label){case 0:return p.trys.push([0,4,,10]),[4,(i=new a(this)).init()];case 1:return p.sent(),[4,e(i)];case 2:if(u=p.sent(),!0===i.aborted)throw i.abortReason;return[4,i.commit()];case 3:return p.sent(),[2,u];case 4:if(f=p.sent(),!1===i.inited)throw f;return c=function(t){return r(l,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:if(i.aborted||i.commited)return[3,5];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,i.rollback()];case 2:case 3:return e.sent(),[3,4];case 4:throw t;case 5:if(!0===i.aborted)throw i.abortReason;throw t}}))}))},n<=0?[4,c(f)]:[3,6];case 5:p.sent(),p.label=6;case 6:return f&&f.code===s.ERRORS.DATABASE_TRANSACTION_CONFLICT.code?[4,t.bind(this)(e,--n)]:[3,8];case 7:return[2,p.sent()];case 8:return[4,c(f)];case 9:return p.sent(),[3,10];case 10:return[2]}}))}))}},918:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});e.Query=function(t,e){this._coll=e,this._transaction=t}},355:function(t,e,n){var r=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u};Object.defineProperty(e,"__esModule",{value:!0});var o=n(952),i=n(458),u=n(564),s=function(){function t(){}return t.formatResDocumentData=function(e){return e.map((function(e){return t.formatField(e)}))},t.formatField=function(e){var n=Object.keys(e),u={};return Array.isArray(e)&&(u=[]),n.forEach((function(n){var s,a=e[n];switch(t.whichType(a)){case o.FieldType.GeoPoint:s=new i.Point(a.coordinates[0],a.coordinates[1]);break;case o.FieldType.GeoLineString:s=new i.LineString(a.coordinates.map((function(t){return new i.Point(t[0],t[1])})));break;case o.FieldType.GeoPolygon:s=new i.Polygon(a.coordinates.map((function(t){return new i.LineString(t.map((function(t){var e=r(t,2),n=e[0],o=e[1];return new i.Point(n,o)})))})));break;case o.FieldType.GeoMultiPoint:s=new i.MultiPoint(a.coordinates.map((function(t){return new i.Point(t[0],t[1])})));break;case o.FieldType.GeoMultiLineString:s=new i.MultiLineString(a.coordinates.map((function(t){return new i.LineString(t.map((function(t){var e=r(t,2),n=e[0],o=e[1];return new i.Point(n,o)})))})));break;case o.FieldType.GeoMultiPolygon:s=new i.MultiPolygon(a.coordinates.map((function(t){return new i.Polygon(t.map((function(t){return new i.LineString(t.map((function(t){var e=r(t,2),n=e[0],o=e[1];return new i.Point(n,o)})))})))})));break;case o.FieldType.Timestamp:s=new Date(1e3*a.$timestamp);break;case o.FieldType.Object:case o.FieldType.Array:s=t.formatField(a);break;case o.FieldType.ServerDate:s=new Date(a.$date);break;default:s=a}Array.isArray(u)?u.push(s):u[n]=s})),u},t.whichType=function(t){var e=Object.prototype.toString.call(t).slice(8,-1);if(e===o.FieldType.Timestamp)return o.FieldType.BsonDate;if(e===o.FieldType.Object){if(t instanceof i.Point)return o.FieldType.GeoPoint;if(t instanceof Date)return o.FieldType.Timestamp;if(t instanceof u.ServerDate)return o.FieldType.ServerDate;t.$timestamp?e=o.FieldType.Timestamp:t.$date?e=o.FieldType.ServerDate:i.Point.validate(t)?e=o.FieldType.GeoPoint:i.LineString.validate(t)?e=o.FieldType.GeoLineString:i.Polygon.validate(t)?e=o.FieldType.GeoPolygon:i.MultiPoint.validate(t)?e=o.FieldType.GeoMultiPoint:i.MultiLineString.validate(t)?e=o.FieldType.GeoMultiLineString:i.MultiPolygon.validate(t)&&(e=o.FieldType.GeoMultiPolygon)}return e},t.generateDocId=function(){for(var t="ABCDEFabcdef0123456789",e="",n=0;n<24;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e},t}();e.Util=s},278:function(t,e){var n,r=this&&this.__extends||(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},n(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(e,"__esModule",{value:!0});var o=[],i={},u=function(t){function e(e,n){if(n!==i)throw new TypeError("InternalSymbol cannot be constructed with new operator");return t.call(this,e)||this}return r(e,t),e.for=function(t){for(var n=0,r=o.length;n<r;n++)if(o[n].target===t)return o[n].instance;var u=new e(t,i);return o.push({target:t,instance:u}),u},e}((function(t){Object.defineProperties(this,{target:{enumerable:!1,writable:!1,configurable:!1,value:t}})}));e.InternalSymbol=u,e.default=u},428:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=n(278);e.getType=function(t){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()},e.isObject=function(t){return"object"===e.getType(t)},e.isString=function(t){return"string"===e.getType(t)},e.isNumber=function(t){return"number"===e.getType(t)},e.isPromise=function(t){return"promise"===e.getType(t)},e.isFunction=function(t){return"function"==typeof t},e.isArray=function(t){return Array.isArray(t)},e.isDate=function(t){return"date"===e.getType(t)},e.isRegExp=function(t){return"regexp"===e.getType(t)},e.isInternalObject=function(t){return t&&t._internalType instanceof r.InternalSymbol},e.isPlainObject=function(t){if("object"!=typeof t||null===t)return!1;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}},195:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=n(672);e.sleep=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))};var o={};e.autoCount=function(t){return void 0===t&&(t="any"),o[t]||(o[t]=0),o[t]++};var i={};e.getWsInstance=function(t){if(!r.Db.wsClientClass)throw new Error("to use realtime you must import realtime module first");var e=t.config.env;return i[e]||(i[e]=new r.Db.wsClientClass({context:{appConfig:{docSizeLimit:1e3,realtimePingInterval:1e4,realtimePongWaitTimeout:5e3,request:new r.Db.reqClass(t.config)}}})),i[e]}},353:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0});var r=n(952),o=n(355),i=function(){function t(){}return t.isGeopoint=function(t,e){if(o.Util.whichType(e)!==r.FieldType.Number)throw new Error("Geo Point must be number type");var n=Math.abs(e);if("latitude"===t&&n>90)throw new Error("latitude should be a number ranges from -90 to 90");if("longitude"===t&&n>180)throw new Error("longitude should be a number ranges from -180 to 180");return!0},t.isInteger=function(t,e){if(!Number.isInteger(e))throw new Error(t+r.ErrorCode.IntergerError);return!0},t.isFieldOrder=function(t){if(-1===r.OrderDirectionList.indexOf(t))throw new Error(r.ErrorCode.DirectionError);return!0},t.isFieldPath=function(t){if(!/^[a-zA-Z0-9-_\.]/.test(t))throw new Error;return!0},t.isOperator=function(t){if(-1===r.WhereFilterOpList.indexOf(t))throw new Error(r.ErrorCode.OpStrError);return!0},t.isCollName=function(t){if(!/^[a-zA-Z0-9]([a-zA-Z0-9-_]){1,32}$/.test(t))throw new Error(r.ErrorCode.CollNameError);return!0},t.isDocID=function(t){if(!/^([a-fA-F0-9]){24}$/.test(t))throw new Error(r.ErrorCode.DocIDError);return!0},t}();e.Validate=i},762:(t,e,n)=>{n.r(e),n.d(e,{BSONError:()=>v,BSONRegExp:()=>ee,BSONSymbol:()=>ne,BSONTypeError:()=>_,BSON_BINARY_SUBTYPE_BYTE_ARRAY:()=>yt,BSON_BINARY_SUBTYPE_COLUMN:()=>vt,BSON_BINARY_SUBTYPE_DEFAULT:()=>ht,BSON_BINARY_SUBTYPE_ENCRYPTED:()=>wt,BSON_BINARY_SUBTYPE_FUNCTION:()=>dt,BSON_BINARY_SUBTYPE_MD5:()=>bt,BSON_BINARY_SUBTYPE_USER_DEFINED:()=>_t,BSON_BINARY_SUBTYPE_UUID:()=>gt,BSON_BINARY_SUBTYPE_UUID_NEW:()=>mt,BSON_DATA_ARRAY:()=>H,BSON_DATA_BINARY:()=>W,BSON_DATA_BOOLEAN:()=>X,BSON_DATA_CODE:()=>ot,BSON_DATA_CODE_W_SCOPE:()=>ut,BSON_DATA_DATE:()=>tt,BSON_DATA_DBPOINTER:()=>rt,BSON_DATA_DECIMAL128:()=>ct,BSON_DATA_INT:()=>st,BSON_DATA_LONG:()=>ft,BSON_DATA_MAX_KEY:()=>pt,BSON_DATA_MIN_KEY:()=>lt,BSON_DATA_NULL:()=>et,BSON_DATA_NUMBER:()=>J,BSON_DATA_OBJECT:()=>V,BSON_DATA_OID:()=>K,BSON_DATA_REGEXP:()=>nt,BSON_DATA_STRING:()=>z,BSON_DATA_SYMBOL:()=>it,BSON_DATA_TIMESTAMP:()=>at,BSON_DATA_UNDEFINED:()=>Z,BSON_INT32_MAX:()=>q,BSON_INT32_MIN:()=>Y,BSON_INT64_MAX:()=>F,BSON_INT64_MIN:()=>k,Binary:()=>Ot,Code:()=>St,DBRef:()=>At,Decimal128:()=>Jt,Double:()=>zt,EJSON:()=>de,Int32:()=>Vt,Long:()=>xt,LongWithoutOverridesClass:()=>re,Map:()=>ye,MaxKey:()=>Ht,MinKey:()=>Wt,ObjectID:()=>te,ObjectId:()=>te,Timestamp:()=>oe,UUID:()=>Et,calculateObjectSize:()=>gn,default:()=>bn,deserialize:()=>yn,deserializeStream:()=>mn,serialize:()=>hn,serializeWithBufferAndIndex:()=>dn,setInternalBufferSize:()=>pn});for(var r=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,a=u.length;s<a;++s)r[s]=u[s],o[u.charCodeAt(s)]=s;function f(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function c(t,e,n){for(var o,i,u=[],s=e;s<n;s+=3)o=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),u.push(r[(i=o)>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return u.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63;var l=function(t){var e,n,r=f(t),u=r[0],s=r[1],a=new i(function(t,e,n){return 3*(e+n)/4-n}(0,u,s)),c=0,l=s>0?u-4:u;for(n=0;n<l;n+=4)e=o[t.charCodeAt(n)]<<18|o[t.charCodeAt(n+1)]<<12|o[t.charCodeAt(n+2)]<<6|o[t.charCodeAt(n+3)],a[c++]=e>>16&255,a[c++]=e>>8&255,a[c++]=255&e;return 2===s&&(e=o[t.charCodeAt(n)]<<2|o[t.charCodeAt(n+1)]>>4,a[c++]=255&e),1===s&&(e=o[t.charCodeAt(n)]<<10|o[t.charCodeAt(n+1)]<<4|o[t.charCodeAt(n+2)]>>2,a[c++]=e>>8&255,a[c++]=255&e),a},p=function(t){for(var e,n=t.length,o=n%3,i=[],u=16383,s=0,a=n-o;s<a;s+=u)i.push(c(t,s,s+u>a?a:s+u));return 1===o?(e=t[n-1],i.push(r[e>>2]+r[e<<4&63]+"==")):2===o&&(e=(t[n-2]<<8)+t[n-1],i.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),i.join("")},h=function(t,e,n,r,o){var i,u,s=8*o-r-1,a=(1<<s)-1,f=a>>1,c=-7,l=n?o-1:0,p=n?-1:1,h=t[e+l];for(l+=p,i=h&(1<<-c)-1,h>>=-c,c+=s;c>0;i=256*i+t[e+l],l+=p,c-=8);for(u=i&(1<<-c)-1,i>>=-c,c+=r;c>0;u=256*u+t[e+l],l+=p,c-=8);if(0===i)i=1-f;else{if(i===a)return u?NaN:1/0*(h?-1:1);u+=Math.pow(2,r),i-=f}return(h?-1:1)*u*Math.pow(2,i-r)},d=function(t,e,n,r,o,i){var u,s,a,f=8*i-o-1,c=(1<<f)-1,l=c>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,d=r?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,u=c):(u=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-u))<1&&(u--,a*=2),(e+=u+l>=1?p/a:p*Math.pow(2,1-l))*a>=2&&(u++,a/=2),u+l>=c?(s=0,u=c):u+l>=1?(s=(e*a-1)*Math.pow(2,o),u+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,o),u=0));o>=8;t[n+h]=255&s,h+=d,s/=256,o-=8);for(u=u<<o|s,f+=o;f>0;t[n+h]=255&u,h+=d,u/=256,f-=8);t[n+h-d]|=128*y},y=function(t,e){return function(t,e){var n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=i,e.SlowBuffer=function(t){return+t!=t&&(t=0),i.alloc(+t)},e.INSPECT_MAX_BYTES=50;var r=2147483647;function o(t){if(t>r)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,i.prototype),e}function i(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return a(t)}return u(t,e,n)}function u(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!i.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var n=0|g(t,e),r=o(n),u=r.write(t,e);return u!==n&&(r=r.slice(0,u)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(F(t,Uint8Array)){var e=new Uint8Array(t);return c(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(t));if(F(t,ArrayBuffer)||t&&F(t.buffer,ArrayBuffer))return c(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(F(t,SharedArrayBuffer)||t&&F(t.buffer,SharedArrayBuffer)))return c(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return i.from(r,e,n);var u=function(t){if(i.isBuffer(t)){var e=0|y(t.length),n=o(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||k(t.length)?o(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(u)return u;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return i.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+babelHelpers.typeof(t))}function s(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function a(t){return s(t),o(t<0?0:0|y(t))}function f(t){for(var e=t.length<0?0:0|y(t.length),n=o(e),r=0;r<e;r+=1)n[r]=255&t[r];return n}function c(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');var r;return r=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(r,i.prototype),r}function y(t){if(t>=r)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+r.toString(16)+" bytes");return 0|t}function g(t,e){if(i.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||F(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+babelHelpers.typeof(t));var n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;for(var o=!1;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return $(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return q(t).length;default:if(o)return r?-1:$(t).length;e=(""+e).toLowerCase(),o=!0}}function m(t,e,n){var r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return D(this,e,n);case"utf8":case"utf-8":return T(this,e,n);case"ascii":return I(this,e,n);case"latin1":case"binary":return M(this,e,n);case"base64":return A(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function b(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function w(t,e,n,r,o){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),k(n=+n)&&(n=o?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(o)return-1;n=t.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=i.from(e,r)),i.isBuffer(e))return 0===e.length?-1:v(t,e,n,r,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):v(t,[e],n,r,o);throw new TypeError("val must be string, number or Buffer")}function v(t,e,n,r,o){var i,u=1,s=t.length,a=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;u=2,s/=2,a/=2,n/=2}function f(t,e){return 1===u?t[e]:t.readUInt16BE(e*u)}if(o){var c=-1;for(i=n;i<s;i++)if(f(t,i)===f(e,-1===c?0:i-c)){if(-1===c&&(c=i),i-c+1===a)return c*u}else-1!==c&&(i-=i-c),c=-1}else for(n+a>s&&(n=s-a),i=n;i>=0;i--){for(var l=!0,p=0;p<a;p++)if(f(t,i+p)!==f(e,p)){l=!1;break}if(l)return i}return-1}function _(t,e,n,r){n=Number(n)||0;var o=t.length-n;r?(r=Number(r))>o&&(r=o):r=o;var i=e.length;r>i/2&&(r=i/2);for(var u=0;u<r;++u){var s=parseInt(e.substr(2*u,2),16);if(k(s))return u;t[n+u]=s}return u}function O(t,e,n,r){return Y($(e,t.length-n),t,n,r)}function E(t,e,n,r){return Y(function(t){for(var e=[],n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,r)}function S(t,e,n,r){return Y(q(e),t,n,r)}function N(t,e,n,r){return Y(function(t,e){for(var n,r,o,i=[],u=0;u<t.length&&!((e-=2)<0);++u)r=(n=t.charCodeAt(u))>>8,o=n%256,i.push(o),i.push(r);return i}(e,t.length-n),t,n,r)}function A(t,e,n){return 0===e&&n===t.length?p(t):p(t.slice(e,n))}function T(t,e,n){n=Math.min(t.length,n);for(var r=[],o=e;o<n;){var i,u,s,a,f=t[o],c=null,l=f>239?4:f>223?3:f>191?2:1;if(o+l<=n)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(i=t[o+1]))&&(a=(31&f)<<6|63&i)>127&&(c=a);break;case 3:i=t[o+1],u=t[o+2],128==(192&i)&&128==(192&u)&&(a=(15&f)<<12|(63&i)<<6|63&u)>2047&&(a<55296||a>57343)&&(c=a);break;case 4:i=t[o+1],u=t[o+2],s=t[o+3],128==(192&i)&&128==(192&u)&&128==(192&s)&&(a=(15&f)<<18|(63&i)<<12|(63&u)<<6|63&s)>65535&&a<1114112&&(c=a)}null===c?(c=65533,l=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),o+=l}return function(t){var e=t.length;if(e<=L)return String.fromCharCode.apply(String,t);for(var n="",r=0;r<e;)n+=String.fromCharCode.apply(String,t.slice(r,r+=L));return n}(r)}e.kMaxLength=r,i.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),i.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(i.prototype,"parent",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.buffer}}),Object.defineProperty(i.prototype,"offset",{enumerable:!0,get:function(){if(i.isBuffer(this))return this.byteOffset}}),i.poolSize=8192,i.from=function(t,e,n){return u(t,e,n)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array),i.alloc=function(t,e,n){return function(t,e,n){return s(t),t<=0?o(t):void 0!==e?"string"==typeof n?o(t).fill(e,n):o(t).fill(e):o(t)}(t,e,n)},i.allocUnsafe=function(t){return a(t)},i.allocUnsafeSlow=function(t){return a(t)},i.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==i.prototype},i.compare=function(t,e){if(F(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),F(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;for(var n=t.length,r=e.length,o=0,u=Math.min(n,r);o<u;++o)if(t[o]!==e[o]){n=t[o],r=e[o];break}return n<r?-1:r<n?1:0},i.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},i.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return i.alloc(0);var n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var r=i.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){var u=t[n];if(F(u,Uint8Array))o+u.length>r.length?i.from(u).copy(r,o):Uint8Array.prototype.set.call(r,u,o);else{if(!i.isBuffer(u))throw new TypeError('"list" argument must be an Array of Buffers');u.copy(r,o)}o+=u.length}return r},i.byteLength=g,i.prototype._isBuffer=!0,i.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)b(this,e,e+1);return this},i.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)b(this,e,e+3),b(this,e+1,e+2);return this},i.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)b(this,e,e+7),b(this,e+1,e+6),b(this,e+2,e+5),b(this,e+3,e+4);return this},i.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?T(this,0,t):m.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===i.compare(this,t)},i.prototype.inspect=function(){var t="",n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},n&&(i.prototype[n]=i.prototype.inspect),i.prototype.compare=function(t,e,n,r,o){if(F(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+babelHelpers.typeof(t));if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),e<0||n>t.length||r<0||o>this.length)throw new RangeError("out of range index");if(r>=o&&e>=n)return 0;if(r>=o)return-1;if(e>=n)return 1;if(this===t)return 0;for(var u=(o>>>=0)-(r>>>=0),s=(n>>>=0)-(e>>>=0),a=Math.min(u,s),f=this.slice(r,o),c=t.slice(e,n),l=0;l<a;++l)if(f[l]!==c[l]){u=f[l],s=c[l];break}return u<s?-1:s<u?1:0},i.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},i.prototype.indexOf=function(t,e,n){return w(this,t,e,n,!0)},i.prototype.lastIndexOf=function(t,e,n){return w(this,t,e,n,!1)},i.prototype.write=function(t,e,n,r){if(void 0===e)r="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)r=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var o=this.length-e;if((void 0===n||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return _(this,t,e,n);case"utf8":case"utf-8":return O(this,t,e,n);case"ascii":case"latin1":case"binary":return E(this,t,e,n);case"base64":return S(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(this,t,e,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var L=4096;function I(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(127&t[o]);return r}function M(t,e,n){var r="";n=Math.min(t.length,n);for(var o=e;o<n;++o)r+=String.fromCharCode(t[o]);return r}function D(t,e,n){var r=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>r)&&(n=r);for(var o="",i=e;i<n;++i)o+=G[t[i]];return o}function R(t,e,n){for(var r=t.slice(e,n),o="",i=0;i<r.length-1;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}function x(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function B(t,e,n,r,o,u){if(!i.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<u)throw new RangeError('"value" argument is out of bounds');if(n+r>t.length)throw new RangeError("Index out of range")}function C(t,e,n,r,o,i){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function P(t,e,n,r,o){return e=+e,n>>>=0,o||C(t,0,n,4),d(t,e,n,r,23,4),n+4}function U(t,e,n,r,o){return e=+e,n>>>=0,o||C(t,0,n,8),d(t,e,n,r,52,8),n+8}i.prototype.slice=function(t,e){var n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);var r=this.subarray(t,e);return Object.setPrototypeOf(r,i.prototype),r},i.prototype.readUintLE=i.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||x(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r},i.prototype.readUintBE=i.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||x(t,e,this.length);for(var r=this[t+--e],o=1;e>0&&(o*=256);)r+=this[t+--e]*o;return r},i.prototype.readUint8=i.prototype.readUInt8=function(t,e){return t>>>=0,e||x(t,1,this.length),this[t]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(t,e){return t>>>=0,e||x(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(t,e){return t>>>=0,e||x(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(t,e){return t>>>=0,e||x(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},i.prototype.readUint32BE=i.prototype.readUInt32BE=function(t,e){return t>>>=0,e||x(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||x(t,e,this.length);for(var r=this[t],o=1,i=0;++i<e&&(o*=256);)r+=this[t+i]*o;return r>=(o*=128)&&(r-=Math.pow(2,8*e)),r},i.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||x(t,e,this.length);for(var r=e,o=1,i=this[t+--r];r>0&&(o*=256);)i+=this[t+--r]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},i.prototype.readInt8=function(t,e){return t>>>=0,e||x(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},i.prototype.readInt16LE=function(t,e){t>>>=0,e||x(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt16BE=function(t,e){t>>>=0,e||x(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt32LE=function(t,e){return t>>>=0,e||x(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t>>>=0,e||x(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readFloatLE=function(t,e){return t>>>=0,e||x(t,4,this.length),h(this,t,!0,23,4)},i.prototype.readFloatBE=function(t,e){return t>>>=0,e||x(t,4,this.length),h(this,t,!1,23,4)},i.prototype.readDoubleLE=function(t,e){return t>>>=0,e||x(t,8,this.length),h(this,t,!0,52,8)},i.prototype.readDoubleBE=function(t,e){return t>>>=0,e||x(t,8,this.length),h(this,t,!1,52,8)},i.prototype.writeUintLE=i.prototype.writeUIntLE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||B(this,t,e,n,Math.pow(2,8*n)-1,0);var o=1,i=0;for(this[e]=255&t;++i<n&&(o*=256);)this[e+i]=t/o&255;return e+n},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||B(this,t,e,n,Math.pow(2,8*n)-1,0);var o=n-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+n},i.prototype.writeUint8=i.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,1,255,0),this[e]=255&t,e+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeUint16BE=i.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeUint32LE=i.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},i.prototype.writeUint32BE=i.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var o=Math.pow(2,8*n-1);B(this,t,e,n,o-1,-o)}var i=0,u=1,s=0;for(this[e]=255&t;++i<n&&(u*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/u>>0)-s&255;return e+n},i.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){var o=Math.pow(2,8*n-1);B(this,t,e,n,o-1,-o)}var i=n-1,u=1,s=0;for(this[e+i]=255&t;--i>=0&&(u*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/u>>0)-s&255;return e+n},i.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},i.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},i.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},i.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||B(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},i.prototype.writeFloatLE=function(t,e,n){return P(this,t,e,!0,n)},i.prototype.writeFloatBE=function(t,e,n){return P(this,t,e,!1,n)},i.prototype.writeDoubleLE=function(t,e,n){return U(this,t,e,!0,n)},i.prototype.writeDoubleBE=function(t,e,n){return U(this,t,e,!1,n)},i.prototype.copy=function(t,e,n,r){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e<r-n&&(r=t.length-e+n);var o=r-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,r):Uint8Array.prototype.set.call(t,this.subarray(n,r),e),o},i.prototype.fill=function(t,e,n,r){if("string"==typeof t){if("string"==typeof e?(r=e,e=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!i.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===t.length){var o=t.charCodeAt(0);("utf8"===r&&o<128||"latin1"===r)&&(t=o)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;var u;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(u=e;u<n;++u)this[u]=t;else{var s=i.isBuffer(t)?t:i.from(t,r),a=s.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(u=0;u<n-e;++u)this[u+e]=s[u%a]}return this};var j=/[^+/0-9A-Za-z-_]/g;function $(t,e){var n;e=e||1/0;for(var r=t.length,o=null,i=[],u=0;u<r;++u){if((n=t.charCodeAt(u))>55295&&n<57344){if(!o){if(n>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(u+1===r){(e-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(e-=3)>-1&&i.push(239,191,189),o=n;continue}n=65536+(o-55296<<10|n-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((e-=1)<0)break;i.push(n)}else if(n<2048){if((e-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function q(t){return l(function(t){if((t=(t=t.split("=")[0]).trim().replace(j,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Y(t,e,n,r){for(var o=0;o<r&&!(o+n>=e.length||o>=t.length);++o)e[o+n]=t[o];return o}function F(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function k(t){return t!=t}var G=function(){for(var t="0123456789abcdef",e=new Array(256),n=0;n<16;++n)for(var r=16*n,o=0;o<16;++o)e[r+o]=t[n]+t[o];return e}()}(e={exports:{}},e.exports),e.exports}(),g=y.Buffer;y.SlowBuffer,y.INSPECT_MAX_BYTES,y.kMaxLength;var m=function(t,e){return m=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},m(t,e)};function b(t,e){function n(){this.constructor=t}m(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var w=function(){return w=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},w.apply(this,arguments)},v=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return b(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),e}(Error),_=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r}return b(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"BSONTypeError"},enumerable:!1,configurable:!0}),e}(TypeError);function O(t){return t&&t.Math==Math&&t}function E(){return O("object"==typeof globalThis&&globalThis)||O("object"==typeof window&&window)||O("object"==typeof self&&self)||O("object"==typeof n.g&&n.g)||Function("return this")()}function S(t){return t.toString().replace("function(","function (")}var N=function(t){var e,n="object"==typeof(e=E()).navigator&&"ReactNative"===e.navigator.product?"BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.":"BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.";console.warn(n);for(var r=g.alloc(t),o=0;o<t;++o)r[o]=Math.floor(256*Math.random());return r},A=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(t&&t.getRandomValues)return function(e){return t.getRandomValues(g.alloc(e))}}return void 0!==n.g&&n.g.crypto&&n.g.crypto.getRandomValues?function(t){return n.g.crypto.getRandomValues(g.alloc(t))}:N}();function T(t){return["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(t))}function L(t){return"[object Uint8Array]"===Object.prototype.toString.call(t)}function I(t){return"[object BigInt64Array]"===Object.prototype.toString.call(t)}function M(t){return"[object BigUint64Array]"===Object.prototype.toString.call(t)}function D(t){return"[object RegExp]"===Object.prototype.toString.call(t)}function R(t){return x(t)&&"[object Date]"===Object.prototype.toString.call(t)}function x(t){return"object"==typeof t&&null!==t}function B(t,e){var n=!1;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return n||(console.warn(e),n=!0),t.apply(this,r)}}function C(t){if(ArrayBuffer.isView(t))return g.from(t.buffer,t.byteOffset,t.byteLength);if(T(t))return g.from(t);throw new _("Must use either Buffer or TypedArray")}var P=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i,U=function(t){return"string"==typeof t&&P.test(t)},j=function(t){if(!U(t))throw new _('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".');var e=t.replace(/-/g,"");return g.from(e,"hex")},$=function(t,e){return void 0===e&&(e=!0),e?t.toString("hex",0,4)+"-"+t.toString("hex",4,6)+"-"+t.toString("hex",6,8)+"-"+t.toString("hex",8,10)+"-"+t.toString("hex",10,16):t.toString("hex")},q=2147483647,Y=-2147483648,F=Math.pow(2,63)-1,k=-Math.pow(2,63),G=Math.pow(2,53),Q=-Math.pow(2,53),J=1,z=2,V=3,H=4,W=5,Z=6,K=7,X=8,tt=9,et=10,nt=11,rt=12,ot=13,it=14,ut=15,st=16,at=17,ft=18,ct=19,lt=255,pt=127,ht=0,dt=1,yt=2,gt=3,mt=4,bt=5,wt=6,vt=7,_t=128,Ot=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);if(!(null==e||"string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Array.isArray(e)))throw new _("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=null!=n?n:t.BSON_BINARY_SUBTYPE_DEFAULT,null==e?(this.buffer=g.alloc(t.BUFFER_SIZE),this.position=0):("string"==typeof e?this.buffer=g.from(e,"binary"):Array.isArray(e)?this.buffer=g.from(e):this.buffer=C(e),this.position=this.buffer.byteLength)}return t.prototype.put=function(e){if("string"==typeof e&&1!==e.length)throw new _("only accepts single character String");if("number"!=typeof e&&1!==e.length)throw new _("only accepts single character Uint8Array or Array");var n;if((n="string"==typeof e?e.charCodeAt(0):"number"==typeof e?e:e[0])<0||n>255)throw new _("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=n;else{var r=g.alloc(t.BUFFER_SIZE+this.buffer.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r,this.buffer[this.position++]=n}},t.prototype.write=function(t,e){if(e="number"==typeof e?e:this.position,this.buffer.length<e+t.length){var n=g.alloc(this.buffer.length+t.length);this.buffer.copy(n,0,0,this.buffer.length),this.buffer=n}ArrayBuffer.isView(t)?(this.buffer.set(C(t),e),this.position=e+t.byteLength>this.position?e+t.length:this.position):"string"==typeof t&&(this.buffer.write(t,e,t.length,"binary"),this.position=e+t.length>this.position?e+t.length:this.position)},t.prototype.read=function(t,e){return e=e&&e>0?e:this.position,this.buffer.slice(t,t+e)},t.prototype.value=function(t){return(t=!!t)&&this.buffer.length===this.position?this.buffer:t?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position)},t.prototype.length=function(){return this.position},t.prototype.toJSON=function(){return this.buffer.toString("base64")},t.prototype.toString=function(t){return this.buffer.toString(t)},t.prototype.toExtendedJSON=function(t){t=t||{};var e=this.buffer.toString("base64"),n=Number(this.sub_type).toString(16);return t.legacy?{$binary:e,$type:1===n.length?"0"+n:n}:{$binary:{base64:e,subType:1===n.length?"0"+n:n}}},t.prototype.toUUID=function(){if(this.sub_type===t.SUBTYPE_UUID)return new Et(this.buffer.slice(0,this.position));throw new v('Binary sub_type "'.concat(this.sub_type,'" is not supported for converting to UUID. Only "').concat(t.SUBTYPE_UUID,'" is currently supported.'))},t.fromExtendedJSON=function(e,n){var r,o;if(n=n||{},"$binary"in e?n.legacy&&"string"==typeof e.$binary&&"$type"in e?(o=e.$type?parseInt(e.$type,16):0,r=g.from(e.$binary,"base64")):"string"!=typeof e.$binary&&(o=e.$binary.subType?parseInt(e.$binary.subType,16):0,r=g.from(e.$binary.base64,"base64")):"$uuid"in e&&(o=4,r=j(e.$uuid)),!r)throw new _("Unexpected Binary Extended JSON format ".concat(JSON.stringify(e)));return o===mt?new Et(r):new t(r,o)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.value(!0);return'new Binary(Buffer.from("'.concat(t.toString("hex"),'", "hex"), ').concat(this.sub_type,")")},t.BSON_BINARY_SUBTYPE_DEFAULT=0,t.BUFFER_SIZE=256,t.SUBTYPE_DEFAULT=0,t.SUBTYPE_FUNCTION=1,t.SUBTYPE_BYTE_ARRAY=2,t.SUBTYPE_UUID_OLD=3,t.SUBTYPE_UUID=4,t.SUBTYPE_MD5=5,t.SUBTYPE_ENCRYPTED=6,t.SUBTYPE_COLUMN=7,t.SUBTYPE_USER_DEFINED=128,t}();Object.defineProperty(Ot.prototype,"_bsontype",{value:"Binary"});var Et=function(t){function e(n){var r,o,i=this;if(null==n)r=e.generate();else if(n instanceof e)r=g.from(n.buffer),o=n.__id;else if(ArrayBuffer.isView(n)&&16===n.byteLength)r=C(n);else{if("string"!=typeof n)throw new _("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");r=j(n)}return(i=t.call(this,r,mt)||this).__id=o,i}return b(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this.buffer},set:function(t){this.buffer=t,e.cacheHexString&&(this.__id=$(t))},enumerable:!1,configurable:!0}),e.prototype.toHexString=function(t){if(void 0===t&&(t=!0),e.cacheHexString&&this.__id)return this.__id;var n=$(this.id,t);return e.cacheHexString&&(this.__id=n),n},e.prototype.toString=function(t){return t?this.id.toString(t):this.toHexString()},e.prototype.toJSON=function(){return this.toHexString()},e.prototype.equals=function(t){if(!t)return!1;if(t instanceof e)return t.id.equals(this.id);try{return new e(t).id.equals(this.id)}catch(t){return!1}},e.prototype.toBinary=function(){return new Ot(this.id,Ot.SUBTYPE_UUID)},e.generate=function(){var t=A(16);return t[6]=15&t[6]|64,t[8]=63&t[8]|128,g.from(t)},e.isValid=function(t){return!!t&&(t instanceof e||("string"==typeof t?U(t):!!L(t)&&16===t.length&&64==(240&t[6])&&128==(128&t[8])))},e.createFromHexString=function(t){return new e(j(t))},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new UUID("'.concat(this.toHexString(),'")')},e}(Ot),St=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);this.code=e,this.scope=n}return t.prototype.toJSON=function(){return{code:this.code,scope:this.scope}},t.prototype.toExtendedJSON=function(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}},t.fromExtendedJSON=function(e){return new t(e.$code,e.$scope)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.toJSON();return'new Code("'.concat(String(t.code),'"').concat(t.scope?", ".concat(JSON.stringify(t.scope)):"",")")},t}();function Nt(t){return x(t)&&null!=t.$id&&"string"==typeof t.$ref&&(null==t.$db||"string"==typeof t.$db)}Object.defineProperty(St.prototype,"_bsontype",{value:"Code"});var At=function(){function t(e,n,r,o){if(!(this instanceof t))return new t(e,n,r,o);var i=e.split(".");2===i.length&&(r=i.shift(),e=i.shift()),this.collection=e,this.oid=n,this.db=r,this.fields=o||{}}return Object.defineProperty(t.prototype,"namespace",{get:function(){return this.collection},set:function(t){this.collection=t},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){var t=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(t.$db=this.db),t},t.prototype.toExtendedJSON=function(t){t=t||{};var e={$ref:this.collection,$id:this.oid};return t.legacy?e:(this.db&&(e.$db=this.db),e=Object.assign(e,this.fields))},t.fromExtendedJSON=function(e){var n=Object.assign({},e);return delete n.$ref,delete n.$id,delete n.$db,new t(e.$ref,e.$id,e.$db,n)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=void 0===this.oid||void 0===this.oid.toString?this.oid:this.oid.toString();return'new DBRef("'.concat(this.namespace,'", new ObjectId("').concat(String(t),'")').concat(this.db?', "'.concat(this.db,'"'):"",")")},t}();Object.defineProperty(At.prototype,"_bsontype",{value:"DBRef"});var Tt=void 0;try{Tt=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(t){}var Lt=4294967296,It=0x10000000000000000,Mt=It/2,Dt={},Rt={},xt=function(){function t(e,n,r){if(void 0===e&&(e=0),!(this instanceof t))return new t(e,n,r);"bigint"==typeof e?Object.assign(this,t.fromBigInt(e,!!n)):"string"==typeof e?Object.assign(this,t.fromString(e,!!n)):(this.low=0|e,this.high=0|n,this.unsigned=!!r),Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}return t.fromBits=function(e,n,r){return new t(e,n,r)},t.fromInt=function(e,n){var r,o,i;return n?(i=0<=(e>>>=0)&&e<256)&&(o=Rt[e])?o:(r=t.fromBits(e,(0|e)<0?-1:0,!0),i&&(Rt[e]=r),r):(i=-128<=(e|=0)&&e<128)&&(o=Dt[e])?o:(r=t.fromBits(e,e<0?-1:0,!1),i&&(Dt[e]=r),r)},t.fromNumber=function(e,n){if(isNaN(e))return n?t.UZERO:t.ZERO;if(n){if(e<0)return t.UZERO;if(e>=It)return t.MAX_UNSIGNED_VALUE}else{if(e<=-Mt)return t.MIN_VALUE;if(e+1>=Mt)return t.MAX_VALUE}return e<0?t.fromNumber(-e,n).neg():t.fromBits(e%Lt|0,e/Lt|0,n)},t.fromBigInt=function(e,n){return t.fromString(e.toString(),n)},t.fromString=function(e,n,r){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t.ZERO;if("number"==typeof n?(r=n,n=!1):n=!!n,(r=r||10)<2||36<r)throw RangeError("radix");var o;if((o=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===o)return t.fromString(e.substring(1),n,r).neg();for(var i=t.fromNumber(Math.pow(r,8)),u=t.ZERO,s=0;s<e.length;s+=8){var a=Math.min(8,e.length-s),f=parseInt(e.substring(s,s+a),r);if(a<8){var c=t.fromNumber(Math.pow(r,a));u=u.mul(c).add(t.fromNumber(f))}else u=(u=u.mul(i)).add(t.fromNumber(f))}return u.unsigned=n,u},t.fromBytes=function(e,n,r){return r?t.fromBytesLE(e,n):t.fromBytesBE(e,n)},t.fromBytesLE=function(e,n){return new t(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,n)},t.fromBytesBE=function(e,n){return new t(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],n)},t.isLong=function(t){return x(t)&&!0===t.__isLong__},t.fromValue=function(e,n){return"number"==typeof e?t.fromNumber(e,n):"string"==typeof e?t.fromString(e,n):t.fromBits(e.low,e.high,"boolean"==typeof n?n:e.unsigned)},t.prototype.add=function(e){t.isLong(e)||(e=t.fromValue(e));var n=this.high>>>16,r=65535&this.high,o=this.low>>>16,i=65535&this.low,u=e.high>>>16,s=65535&e.high,a=e.low>>>16,f=0,c=0,l=0,p=0;return l+=(p+=i+(65535&e.low))>>>16,p&=65535,c+=(l+=o+a)>>>16,l&=65535,f+=(c+=r+s)>>>16,c&=65535,f+=n+u,f&=65535,t.fromBits(l<<16|p,f<<16|c,this.unsigned)},t.prototype.and=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low&e.low,this.high&e.high,this.unsigned)},t.prototype.compare=function(e){if(t.isLong(e)||(e=t.fromValue(e)),this.eq(e))return 0;var n=this.isNegative(),r=e.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},t.prototype.comp=function(t){return this.compare(t)},t.prototype.divide=function(e){if(t.isLong(e)||(e=t.fromValue(e)),e.isZero())throw Error("division by zero");if(Tt){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;var n=(this.unsigned?Tt.div_u:Tt.div_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,Tt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?t.UZERO:t.ZERO;var r,o,i;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return t.UZERO;if(e.gt(this.shru(1)))return t.UONE;i=t.UZERO}else{if(this.eq(t.MIN_VALUE))return e.eq(t.ONE)||e.eq(t.NEG_ONE)?t.MIN_VALUE:e.eq(t.MIN_VALUE)?t.ONE:(r=this.shr(1).div(e).shl(1)).eq(t.ZERO)?e.isNegative()?t.ONE:t.NEG_ONE:(o=this.sub(e.mul(r)),i=r.add(o.div(e)));if(e.eq(t.MIN_VALUE))return this.unsigned?t.UZERO:t.ZERO;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();i=t.ZERO}for(o=this;o.gte(e);){r=Math.max(1,Math.floor(o.toNumber()/e.toNumber()));for(var u=Math.ceil(Math.log(r)/Math.LN2),s=u<=48?1:Math.pow(2,u-48),a=t.fromNumber(r),f=a.mul(e);f.isNegative()||f.gt(o);)r-=s,f=(a=t.fromNumber(r,this.unsigned)).mul(e);a.isZero()&&(a=t.ONE),i=i.add(a),o=o.sub(f)}return i},t.prototype.div=function(t){return this.divide(t)},t.prototype.equals=function(e){return t.isLong(e)||(e=t.fromValue(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},t.prototype.eq=function(t){return this.equals(t)},t.prototype.getHighBits=function(){return this.high},t.prototype.getHighBitsUnsigned=function(){return this.high>>>0},t.prototype.getLowBits=function(){return this.low},t.prototype.getLowBitsUnsigned=function(){return this.low>>>0},t.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(t.MIN_VALUE)?64:this.neg().getNumBitsAbs();var e,n=0!==this.high?this.high:this.low;for(e=31;e>0&&0==(n&1<<e);e--);return 0!==this.high?e+33:e+1},t.prototype.greaterThan=function(t){return this.comp(t)>0},t.prototype.gt=function(t){return this.greaterThan(t)},t.prototype.greaterThanOrEqual=function(t){return this.comp(t)>=0},t.prototype.gte=function(t){return this.greaterThanOrEqual(t)},t.prototype.ge=function(t){return this.greaterThanOrEqual(t)},t.prototype.isEven=function(){return 0==(1&this.low)},t.prototype.isNegative=function(){return!this.unsigned&&this.high<0},t.prototype.isOdd=function(){return 1==(1&this.low)},t.prototype.isPositive=function(){return this.unsigned||this.high>=0},t.prototype.isZero=function(){return 0===this.high&&0===this.low},t.prototype.lessThan=function(t){return this.comp(t)<0},t.prototype.lt=function(t){return this.lessThan(t)},t.prototype.lessThanOrEqual=function(t){return this.comp(t)<=0},t.prototype.lte=function(t){return this.lessThanOrEqual(t)},t.prototype.modulo=function(e){if(t.isLong(e)||(e=t.fromValue(e)),Tt){var n=(this.unsigned?Tt.rem_u:Tt.rem_s)(this.low,this.high,e.low,e.high);return t.fromBits(n,Tt.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))},t.prototype.mod=function(t){return this.modulo(t)},t.prototype.rem=function(t){return this.modulo(t)},t.prototype.multiply=function(e){if(this.isZero())return t.ZERO;if(t.isLong(e)||(e=t.fromValue(e)),Tt){var n=Tt.mul(this.low,this.high,e.low,e.high);return t.fromBits(n,Tt.get_high(),this.unsigned)}if(e.isZero())return t.ZERO;if(this.eq(t.MIN_VALUE))return e.isOdd()?t.MIN_VALUE:t.ZERO;if(e.eq(t.MIN_VALUE))return this.isOdd()?t.MIN_VALUE:t.ZERO;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(t.TWO_PWR_24)&&e.lt(t.TWO_PWR_24))return t.fromNumber(this.toNumber()*e.toNumber(),this.unsigned);var r=this.high>>>16,o=65535&this.high,i=this.low>>>16,u=65535&this.low,s=e.high>>>16,a=65535&e.high,f=e.low>>>16,c=65535&e.low,l=0,p=0,h=0,d=0;return h+=(d+=u*c)>>>16,d&=65535,p+=(h+=i*c)>>>16,h&=65535,p+=(h+=u*f)>>>16,h&=65535,l+=(p+=o*c)>>>16,p&=65535,l+=(p+=i*f)>>>16,p&=65535,l+=(p+=u*a)>>>16,p&=65535,l+=r*c+o*f+i*a+u*s,l&=65535,t.fromBits(h<<16|d,l<<16|p,this.unsigned)},t.prototype.mul=function(t){return this.multiply(t)},t.prototype.negate=function(){return!this.unsigned&&this.eq(t.MIN_VALUE)?t.MIN_VALUE:this.not().add(t.ONE)},t.prototype.neg=function(){return this.negate()},t.prototype.not=function(){return t.fromBits(~this.low,~this.high,this.unsigned)},t.prototype.notEquals=function(t){return!this.equals(t)},t.prototype.neq=function(t){return this.notEquals(t)},t.prototype.ne=function(t){return this.notEquals(t)},t.prototype.or=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low|e.low,this.high|e.high,this.unsigned)},t.prototype.shiftLeft=function(e){return t.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?t.fromBits(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):t.fromBits(0,this.low<<e-32,this.unsigned)},t.prototype.shl=function(t){return this.shiftLeft(t)},t.prototype.shiftRight=function(e){return t.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?t.fromBits(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):t.fromBits(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},t.prototype.shr=function(t){return this.shiftRight(t)},t.prototype.shiftRightUnsigned=function(e){if(t.isLong(e)&&(e=e.toInt()),0==(e&=63))return this;var n=this.high;if(e<32){var r=this.low;return t.fromBits(r>>>e|n<<32-e,n>>>e,this.unsigned)}return 32===e?t.fromBits(n,0,this.unsigned):t.fromBits(n>>>e-32,0,this.unsigned)},t.prototype.shr_u=function(t){return this.shiftRightUnsigned(t)},t.prototype.shru=function(t){return this.shiftRightUnsigned(t)},t.prototype.subtract=function(e){return t.isLong(e)||(e=t.fromValue(e)),this.add(e.neg())},t.prototype.sub=function(t){return this.subtract(t)},t.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},t.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*Lt+(this.low>>>0):this.high*Lt+(this.low>>>0)},t.prototype.toBigInt=function(){return BigInt(this.toString())},t.prototype.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},t.prototype.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24,255&t,t>>>8&255,t>>>16&255,t>>>24]},t.prototype.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24,t>>>16&255,t>>>8&255,255&t,e>>>24,e>>>16&255,e>>>8&255,255&e]},t.prototype.toSigned=function(){return this.unsigned?t.fromBits(this.low,this.high,!1):this},t.prototype.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(t.MIN_VALUE)){var n=t.fromNumber(e),r=this.div(n),o=r.mul(n).sub(this);return r.toString(e)+o.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var i=t.fromNumber(Math.pow(e,6),this.unsigned),u=this,s="";;){var a=u.div(i),f=(u.sub(a.mul(i)).toInt()>>>0).toString(e);if((u=a).isZero())return f+s;for(;f.length<6;)f="0"+f;s=""+f+s}},t.prototype.toUnsigned=function(){return this.unsigned?this:t.fromBits(this.low,this.high,!0)},t.prototype.xor=function(e){return t.isLong(e)||(e=t.fromValue(e)),t.fromBits(this.low^e.low,this.high^e.high,this.unsigned)},t.prototype.eqz=function(){return this.isZero()},t.prototype.le=function(t){return this.lessThanOrEqual(t)},t.prototype.toExtendedJSON=function(t){return t&&t.relaxed?this.toNumber():{$numberLong:this.toString()}},t.fromExtendedJSON=function(e,n){var r=t.fromString(e.$numberLong);return n&&n.relaxed?r.toNumber():r},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new Long("'.concat(this.toString(),'"').concat(this.unsigned?", true":"",")")},t.TWO_PWR_24=t.fromInt(16777216),t.MAX_UNSIGNED_VALUE=t.fromBits(-1,-1,!0),t.ZERO=t.fromInt(0),t.UZERO=t.fromInt(0,!0),t.ONE=t.fromInt(1),t.UONE=t.fromInt(1,!0),t.NEG_ONE=t.fromInt(-1),t.MAX_VALUE=t.fromBits(-1,2147483647,!1),t.MIN_VALUE=t.fromBits(0,-2147483648,!1),t}();Object.defineProperty(xt.prototype,"__isLong__",{value:!0}),Object.defineProperty(xt.prototype,"_bsontype",{value:"Long"});var Bt=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,Ct=/^(\+|-)?(Infinity|inf)$/i,Pt=/^(\+|-)?NaN$/i,Ut=6111,jt=-6176,$t=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),qt=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),Yt=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),Ft=/^([-+])?(\d+)?$/;function kt(t){return!isNaN(parseInt(t,10))}function Gt(t){var e=xt.fromNumber(1e9),n=xt.fromNumber(0);if(!(t.parts[0]||t.parts[1]||t.parts[2]||t.parts[3]))return{quotient:t,rem:n};for(var r=0;r<=3;r++)n=(n=n.shiftLeft(32)).add(new xt(t.parts[r],0)),t.parts[r]=n.div(e).low,n=n.modulo(e);return{quotient:t,rem:n}}function Qt(t,e){throw new _('"'.concat(t,'" is not a valid Decimal128 string - ').concat(e))}var Jt=function(){function t(e){if(!(this instanceof t))return new t(e);if("string"==typeof e)this.bytes=t.fromString(e).bytes;else{if(!L(e))throw new _("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new _("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}return t.fromString=function(e){var n,r=!1,o=!1,i=!1,u=0,s=0,a=0,f=0,c=0,l=[0],p=0,h=0,d=0,y=0,m=0,b=0,w=new xt(0,0),v=new xt(0,0),O=0;if(e.length>=7e3)throw new _(e+" not a valid Decimal128 string");var E=e.match(Bt),S=e.match(Ct),N=e.match(Pt);if(!E&&!S&&!N||0===e.length)throw new _(e+" not a valid Decimal128 string");if(E){var A=E[2],T=E[4],L=E[5],I=E[6];T&&void 0===I&&Qt(e,"missing exponent power"),T&&void 0===A&&Qt(e,"missing exponent base"),void 0===T&&(L||I)&&Qt(e,"missing e before exponent")}if("+"!==e[O]&&"-"!==e[O]||(r="-"===e[O++]),!kt(e[O])&&"."!==e[O]){if("i"===e[O]||"I"===e[O])return new t(g.from(r?qt:Yt));if("N"===e[O])return new t(g.from($t))}for(;kt(e[O])||"."===e[O];)"."!==e[O]?(p<34&&("0"!==e[O]||i)&&(i||(c=s),i=!0,l[h++]=parseInt(e[O],10),p+=1),i&&(a+=1),o&&(f+=1),s+=1,O+=1):(o&&Qt(e,"contains multiple periods"),o=!0,O+=1);if(o&&!s)throw new _(e+" not a valid Decimal128 string");if("e"===e[O]||"E"===e[O]){var M=e.substr(++O).match(Ft);if(!M||!M[2])return new t(g.from($t));m=parseInt(M[0],10),O+=M[0].length}if(e[O])return new t(g.from($t));if(d=0,p){if(y=p-1,1!==(u=a))for(;0===l[c+u-1];)u-=1}else d=0,y=0,l[0]=0,a=1,p=1,u=0;for(m<=f&&f-m>16384?m=jt:m-=f;m>Ut;){if((y+=1)-d>34){if(l.join("").match(/^0+$/)){m=Ut;break}Qt(e,"overflow")}m-=1}for(;m<jt||p<a;){if(0===y&&u<p){m=jt,u=0;break}if(p<a?a-=1:y-=1,m<Ut)m+=1;else{if(l.join("").match(/^0+$/)){m=Ut;break}Qt(e,"overflow")}}if(y-d+1<u){var D=s;o&&(c+=1,D+=1),r&&(c+=1,D+=1);var R=parseInt(e[c+y+1],10),x=0;if(R>=5&&(x=1,5===R))for(x=l[y]%2==1?1:0,b=c+y+2;b<D;b++)if(parseInt(e[b],10)){x=1;break}if(x)for(var B=y;B>=0;B--)if(++l[B]>9&&(l[B]=0,0===B)){if(!(m<Ut))return new t(g.from(r?qt:Yt));m+=1,l[B]=1}}if(w=xt.fromNumber(0),v=xt.fromNumber(0),0===u)w=xt.fromNumber(0),v=xt.fromNumber(0);else if(y-d<17)for(B=d,v=xt.fromNumber(l[B++]),w=new xt(0,0);B<=y;B++)v=(v=v.multiply(xt.fromNumber(10))).add(xt.fromNumber(l[B]));else{for(B=d,w=xt.fromNumber(l[B++]);B<=y-17;B++)w=(w=w.multiply(xt.fromNumber(10))).add(xt.fromNumber(l[B]));for(v=xt.fromNumber(l[B++]);B<=y;B++)v=(v=v.multiply(xt.fromNumber(10))).add(xt.fromNumber(l[B]))}var C,P,U,j,$=function(t,e){if(!t&&!e)return{high:xt.fromNumber(0),low:xt.fromNumber(0)};var n=t.shiftRightUnsigned(32),r=new xt(t.getLowBits(),0),o=e.shiftRightUnsigned(32),i=new xt(e.getLowBits(),0),u=n.multiply(o),s=n.multiply(i),a=r.multiply(o),f=r.multiply(i);return u=u.add(s.shiftRightUnsigned(32)),s=new xt(s.getLowBits(),0).add(a).add(f.shiftRightUnsigned(32)),{high:u=u.add(s.shiftRightUnsigned(32)),low:f=s.shiftLeft(32).add(new xt(f.getLowBits(),0))}}(w,xt.fromString("100000000000000000"));$.low=$.low.add(v),P=v,((U=(C=$.low).high>>>0)<(j=P.high>>>0)||U===j&&C.low>>>0<P.low>>>0)&&($.high=$.high.add(xt.fromNumber(1))),n=m+6176;var q={low:xt.fromNumber(0),high:xt.fromNumber(0)};$.high.shiftRightUnsigned(49).and(xt.fromNumber(1)).equals(xt.fromNumber(1))?(q.high=q.high.or(xt.fromNumber(3).shiftLeft(61)),q.high=q.high.or(xt.fromNumber(n).and(xt.fromNumber(16383).shiftLeft(47))),q.high=q.high.or($.high.and(xt.fromNumber(0x7fffffffffff)))):(q.high=q.high.or(xt.fromNumber(16383&n).shiftLeft(49)),q.high=q.high.or($.high.and(xt.fromNumber(562949953421311)))),q.low=$.low,r&&(q.high=q.high.or(xt.fromString("9223372036854775808")));var Y=g.alloc(16);return O=0,Y[O++]=255&q.low.low,Y[O++]=q.low.low>>8&255,Y[O++]=q.low.low>>16&255,Y[O++]=q.low.low>>24&255,Y[O++]=255&q.low.high,Y[O++]=q.low.high>>8&255,Y[O++]=q.low.high>>16&255,Y[O++]=q.low.high>>24&255,Y[O++]=255&q.high.low,Y[O++]=q.high.low>>8&255,Y[O++]=q.high.low>>16&255,Y[O++]=q.high.low>>24&255,Y[O++]=255&q.high.high,Y[O++]=q.high.high>>8&255,Y[O++]=q.high.high>>16&255,Y[O++]=q.high.high>>24&255,new t(Y)},t.prototype.toString=function(){for(var t,e=0,n=new Array(36),r=0;r<n.length;r++)n[r]=0;var o,i,u,s=0,a=!1,f={parts:[0,0,0,0]},c=[];s=0;var l=this.bytes,p=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,h=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,d=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,y=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24;s=0,(new xt(p,h),new xt(d,y)).lessThan(xt.ZERO)&&c.push("-");var g=y>>26&31;if(g>>3==3){if(30===g)return c.join("")+"Infinity";if(31===g)return"NaN";t=y>>15&16383,o=8+(y>>14&1)}else o=y>>14&7,t=y>>17&16383;var m=t-6176;if(f.parts[0]=(16383&y)+((15&o)<<14),f.parts[1]=d,f.parts[2]=h,f.parts[3]=p,0===f.parts[0]&&0===f.parts[1]&&0===f.parts[2]&&0===f.parts[3])a=!0;else for(u=3;u>=0;u--){var b=0,w=Gt(f);if(f=w.quotient,b=w.rem.low)for(i=8;i>=0;i--)n[9*u+i]=b%10,b=Math.floor(b/10)}if(a)e=1,n[s]=0;else for(e=36;!n[s];)e-=1,s+=1;var v=e-1+m;if(v>=34||v<=-7||m>0){if(e>34)return c.push("".concat(0)),m>0?c.push("E+".concat(m)):m<0&&c.push("E".concat(m)),c.join("");for(c.push("".concat(n[s++])),(e-=1)&&c.push("."),r=0;r<e;r++)c.push("".concat(n[s++]));c.push("E"),v>0?c.push("+".concat(v)):c.push("".concat(v))}else if(m>=0)for(r=0;r<e;r++)c.push("".concat(n[s++]));else{var _=e+m;if(_>0)for(r=0;r<_;r++)c.push("".concat(n[s++]));else c.push("0");for(c.push(".");_++<0;)c.push("0");for(r=0;r<e-Math.max(_-1,0);r++)c.push("".concat(n[s++]))}return c.join("")},t.prototype.toJSON=function(){return{$numberDecimal:this.toString()}},t.prototype.toExtendedJSON=function(){return{$numberDecimal:this.toString()}},t.fromExtendedJSON=function(e){return t.fromString(e.$numberDecimal)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new Decimal128("'.concat(this.toString(),'")')},t}();Object.defineProperty(Jt.prototype,"_bsontype",{value:"Decimal128"});var zt=function(){function t(e){if(!(this instanceof t))return new t(e);e instanceof Number&&(e=e.valueOf()),this.value=+e}return t.prototype.valueOf=function(){return this.value},t.prototype.toJSON=function(){return this.value},t.prototype.toString=function(t){return this.value.toString(t)},t.prototype.toExtendedJSON=function(t){return t&&(t.legacy||t.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-".concat(this.value.toFixed(1))}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}},t.fromExtendedJSON=function(e,n){var r=parseFloat(e.$numberDouble);return n&&n.relaxed?r:new t(r)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){var t=this.toExtendedJSON();return"new Double(".concat(t.$numberDouble,")")},t}();Object.defineProperty(zt.prototype,"_bsontype",{value:"Double"});var Vt=function(){function t(e){if(!(this instanceof t))return new t(e);e instanceof Number&&(e=e.valueOf()),this.value=0|+e}return t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(t){return this.value.toString(t)},t.prototype.toJSON=function(){return this.value},t.prototype.toExtendedJSON=function(t){return t&&(t.relaxed||t.legacy)?this.value:{$numberInt:this.value.toString()}},t.fromExtendedJSON=function(e,n){return n&&n.relaxed?parseInt(e.$numberInt,10):new t(e.$numberInt)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new Int32(".concat(this.valueOf(),")")},t}();Object.defineProperty(Vt.prototype,"_bsontype",{value:"Int32"});var Ht=function(){function t(){if(!(this instanceof t))return new t}return t.prototype.toExtendedJSON=function(){return{$maxKey:1}},t.fromExtendedJSON=function(){return new t},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new MaxKey()"},t}();Object.defineProperty(Ht.prototype,"_bsontype",{value:"MaxKey"});var Wt=function(){function t(){if(!(this instanceof t))return new t}return t.prototype.toExtendedJSON=function(){return{$minKey:1}},t.fromExtendedJSON=function(){return new t},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new MinKey()"},t}();Object.defineProperty(Wt.prototype,"_bsontype",{value:"MinKey"});var Zt=new RegExp("^[0-9a-fA-F]{24}$"),Kt=null,Xt=Symbol("id"),te=function(){function t(e){if(!(this instanceof t))return new t(e);var n;if("object"==typeof e&&e&&"id"in e){if("string"!=typeof e.id&&!ArrayBuffer.isView(e.id))throw new _("Argument passed in must have an id that is of type string or Buffer");n="toHexString"in e&&"function"==typeof e.toHexString?g.from(e.toHexString(),"hex"):e.id}else n=e;if(null==n||"number"==typeof n)this[Xt]=t.generate("number"==typeof n?n:void 0);else if(ArrayBuffer.isView(n)&&12===n.byteLength)this[Xt]=n instanceof g?n:C(n);else{if("string"!=typeof n)throw new _("Argument passed in does not match the accepted types");if(12===n.length){var r=g.from(n);if(12!==r.byteLength)throw new _("Argument passed in must be a string of 12 bytes");this[Xt]=r}else{if(24!==n.length||!Zt.test(n))throw new _("Argument passed in must be a string of 12 bytes or a string of 24 hex characters or an integer");this[Xt]=g.from(n,"hex")}}t.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(t.prototype,"id",{get:function(){return this[Xt]},set:function(e){this[Xt]=e,t.cacheHexString&&(this.__id=e.toString("hex"))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"generationTime",{get:function(){return this.id.readInt32BE(0)},set:function(t){this.id.writeUInt32BE(t,0)},enumerable:!1,configurable:!0}),t.prototype.toHexString=function(){if(t.cacheHexString&&this.__id)return this.__id;var e=this.id.toString("hex");return t.cacheHexString&&!this.__id&&(this.__id=e),e},t.getInc=function(){return t.index=(t.index+1)%16777215},t.generate=function(e){"number"!=typeof e&&(e=Math.floor(Date.now()/1e3));var n=t.getInc(),r=g.alloc(12);return r.writeUInt32BE(e,0),null===Kt&&(Kt=A(5)),r[4]=Kt[0],r[5]=Kt[1],r[6]=Kt[2],r[7]=Kt[3],r[8]=Kt[4],r[11]=255&n,r[10]=n>>8&255,r[9]=n>>16&255,r},t.prototype.toString=function(t){return t?this.id.toString(t):this.toHexString()},t.prototype.toJSON=function(){return this.toHexString()},t.prototype.equals=function(e){if(null==e)return!1;if(e instanceof t)return this[Xt][11]===e[Xt][11]&&this[Xt].equals(e[Xt]);if("string"==typeof e&&t.isValid(e)&&12===e.length&&L(this.id))return e===g.prototype.toString.call(this.id,"latin1");if("string"==typeof e&&t.isValid(e)&&24===e.length)return e.toLowerCase()===this.toHexString();if("string"==typeof e&&t.isValid(e)&&12===e.length)return g.from(e).equals(this.id);if("object"==typeof e&&"toHexString"in e&&"function"==typeof e.toHexString){var n=e.toHexString(),r=this.toHexString().toLowerCase();return"string"==typeof n&&n.toLowerCase()===r}return!1},t.prototype.getTimestamp=function(){var t=new Date,e=this.id.readUInt32BE(0);return t.setTime(1e3*Math.floor(e)),t},t.createPk=function(){return new t},t.createFromTime=function(e){var n=g.from([0,0,0,0,0,0,0,0,0,0,0,0]);return n.writeUInt32BE(e,0),new t(n)},t.createFromHexString=function(e){if(void 0===e||null!=e&&24!==e.length)throw new _("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new t(g.from(e,"hex"))},t.isValid=function(e){if(null==e)return!1;try{return new t(e),!0}catch(t){return!1}},t.prototype.toExtendedJSON=function(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}},t.fromExtendedJSON=function(e){return new t(e.$oid)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return'new ObjectId("'.concat(this.toHexString(),'")')},t.index=Math.floor(16777215*Math.random()),t}();Object.defineProperty(te.prototype,"generate",{value:B((function(t){return te.generate(t)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(te.prototype,"getInc",{value:B((function(){return te.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(te.prototype,"get_inc",{value:B((function(){return te.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(te,"get_inc",{value:B((function(){return te.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(te.prototype,"_bsontype",{value:"ObjectID"});var ee=function(){function t(e,n){if(!(this instanceof t))return new t(e,n);if(this.pattern=e,this.options=(null!=n?n:"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new v("BSON Regex patterns cannot contain null bytes, found: ".concat(JSON.stringify(this.pattern)));if(-1!==this.options.indexOf("\0"))throw new v("BSON Regex options cannot contain null bytes, found: ".concat(JSON.stringify(this.options)));for(var r=0;r<this.options.length;r++)if("i"!==this.options[r]&&"m"!==this.options[r]&&"x"!==this.options[r]&&"l"!==this.options[r]&&"s"!==this.options[r]&&"u"!==this.options[r])throw new v("The regular expression option [".concat(this.options[r],"] is not supported"))}return t.parseOptions=function(t){return t?t.split("").sort().join(""):""},t.prototype.toExtendedJSON=function(t){return(t=t||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}},t.fromExtendedJSON=function(e){if("$regex"in e){if("string"==typeof e.$regex)return new t(e.$regex,t.parseOptions(e.$options));if("BSONRegExp"===e.$regex._bsontype)return e}if("$regularExpression"in e)return new t(e.$regularExpression.pattern,t.parseOptions(e.$regularExpression.options));throw new _("Unexpected BSONRegExp EJSON object form: ".concat(JSON.stringify(e)))},t}();Object.defineProperty(ee.prototype,"_bsontype",{value:"BSONRegExp"});var ne=function(){function t(e){if(!(this instanceof t))return new t(e);this.value=e}return t.prototype.valueOf=function(){return this.value},t.prototype.toString=function(){return this.value},t.prototype.inspect=function(){return'new BSONSymbol("'.concat(this.value,'")')},t.prototype.toJSON=function(){return this.value},t.prototype.toExtendedJSON=function(){return{$symbol:this.value}},t.fromExtendedJSON=function(e){return new t(e.$symbol)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t}();Object.defineProperty(ne.prototype,"_bsontype",{value:"Symbol"});var re=xt,oe=function(t){function e(n,r){var o=this;return o instanceof e?(o=xt.isLong(n)?t.call(this,n.low,n.high,!0)||this:x(n)&&void 0!==n.t&&void 0!==n.i?t.call(this,n.i,n.t,!0)||this:t.call(this,n,r,!0)||this,Object.defineProperty(o,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1}),o):new e(n,r)}return b(e,t),e.prototype.toJSON=function(){return{$timestamp:this.toString()}},e.fromInt=function(t){return new e(xt.fromInt(t,!0))},e.fromNumber=function(t){return new e(xt.fromNumber(t,!0))},e.fromBits=function(t,n){return new e(t,n)},e.fromString=function(t,n){return new e(xt.fromString(t,!0,n))},e.prototype.toExtendedJSON=function(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}},e.fromExtendedJSON=function(t){return new e(t.$timestamp)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new Timestamp({ t: ".concat(this.getHighBits(),", i: ").concat(this.getLowBits()," })")},e.MAX_VALUE=xt.MAX_UNSIGNED_VALUE,e}(re);function ie(t){return x(t)&&Reflect.has(t,"_bsontype")&&"string"==typeof t._bsontype}var ue=2147483647,se=-2147483648,ae=0x8000000000000000,fe=-0x8000000000000000,ce={$oid:te,$binary:Ot,$uuid:Ot,$symbol:ne,$numberInt:Vt,$numberDecimal:Jt,$numberDouble:zt,$numberLong:xt,$minKey:Wt,$maxKey:Ht,$regex:ee,$regularExpression:ee,$timestamp:oe};function le(t,e){if(void 0===e&&(e={}),"number"==typeof t){if(e.relaxed||e.legacy)return t;if(Math.floor(t)===t){if(t>=se&&t<=ue)return new Vt(t);if(t>=fe&&t<=ae)return xt.fromNumber(t)}return new zt(t)}if(null==t||"object"!=typeof t)return t;if(t.$undefined)return null;for(var n=Object.keys(t).filter((function(e){return e.startsWith("$")&&null!=t[e]})),r=0;r<n.length;r++){var o=ce[n[r]];if(o)return o.fromExtendedJSON(t,e)}if(null!=t.$date){var i=t.$date,u=new Date;return e.legacy?"number"==typeof i?u.setTime(i):"string"==typeof i&&u.setTime(Date.parse(i)):"string"==typeof i?u.setTime(Date.parse(i)):xt.isLong(i)?u.setTime(i.toNumber()):"number"==typeof i&&e.relaxed&&u.setTime(i),u}if(null!=t.$code){var s=Object.assign({},t);return t.$scope&&(s.$scope=le(t.$scope)),St.fromExtendedJSON(t)}if(Nt(t)||t.$dbPointer){var a=t.$ref?t:t.$dbPointer;if(a instanceof At)return a;var f=Object.keys(a).filter((function(t){return t.startsWith("$")})),c=!0;if(f.forEach((function(t){-1===["$ref","$id","$db"].indexOf(t)&&(c=!1)})),c)return At.fromExtendedJSON(a)}return t}function pe(t){var e=t.toISOString();return 0!==t.getUTCMilliseconds()?e:e.slice(0,-5)+"Z"}function he(t,e){if(("object"==typeof t||"function"==typeof t)&&null!==t){var n=e.seenObjects.findIndex((function(e){return e.obj===t}));if(-1!==n){var r=e.seenObjects.map((function(t){return t.propertyName})),o=r.slice(0,n).map((function(t){return"".concat(t," -> ")})).join(""),i=r[n],u=" -> "+r.slice(n+1,r.length-1).map((function(t){return"".concat(t," -> ")})).join(""),s=r[r.length-1],a=" ".repeat(o.length+i.length/2),f="-".repeat(u.length+(i.length+s.length)/2-1);throw new _("Converting circular structure to EJSON:\n"+" ".concat(o).concat(i).concat(u).concat(s,"\n")+" ".concat(a,"\\").concat(f,"/"))}e.seenObjects[e.seenObjects.length-1].obj=t}if(Array.isArray(t))return function(t,e){return t.map((function(t,n){e.seenObjects.push({propertyName:"index ".concat(n),obj:null});try{return he(t,e)}finally{e.seenObjects.pop()}}))}(t,e);if(void 0===t)return null;if(t instanceof Date||R(t)){var c=t.getTime(),l=c>-1&&c<2534023188e5;return e.legacy?e.relaxed&&l?{$date:t.getTime()}:{$date:pe(t)}:e.relaxed&&l?{$date:pe(t)}:{$date:{$numberLong:t.getTime().toString()}}}if(!("number"!=typeof t||e.relaxed&&isFinite(t))){if(Math.floor(t)===t){var p=t>=fe&&t<=ae;if(t>=se&&t<=ue)return{$numberInt:t.toString()};if(p)return{$numberLong:t.toString()}}return{$numberDouble:t.toString()}}if(t instanceof RegExp||D(t)){var h=t.flags;if(void 0===h){var d=t.toString().match(/[gimuy]*$/);d&&(h=d[0])}return new ee(t.source,h).toExtendedJSON(e)}return null!=t&&"object"==typeof t?function(t,e){if(null==t||"object"!=typeof t)throw new v("not an object instance");var n=t._bsontype;if(void 0===n){var r={};for(var o in t){e.seenObjects.push({propertyName:o,obj:null});try{var i=he(t[o],e);"__proto__"===o?Object.defineProperty(r,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):r[o]=i}finally{e.seenObjects.pop()}}return r}if(ie(t)){var u=t;if("function"!=typeof u.toExtendedJSON){var s=ge[t._bsontype];if(!s)throw new _("Unrecognized or invalid _bsontype: "+t._bsontype);u=s(u)}return"Code"===n&&u.scope?u=new St(u.code,he(u.scope,e)):"DBRef"===n&&u.oid&&(u=new At(he(u.collection,e),he(u.oid,e),he(u.db,e),he(u.fields,e))),u.toExtendedJSON(e)}throw new v("_bsontype must be a string, but was: "+typeof n)}(t,e):t}var de,ye,ge={Binary:function(t){return new Ot(t.value(),t.sub_type)},Code:function(t){return new St(t.code,t.scope)},DBRef:function(t){return new At(t.collection||t.namespace,t.oid,t.db,t.fields)},Decimal128:function(t){return new Jt(t.bytes)},Double:function(t){return new zt(t.value)},Int32:function(t){return new Vt(t.value)},Long:function(t){return xt.fromBits(null!=t.low?t.low:t.low_,null!=t.low?t.high:t.high_,null!=t.low?t.unsigned:t.unsigned_)},MaxKey:function(){return new Ht},MinKey:function(){return new Wt},ObjectID:function(t){return new te(t)},ObjectId:function(t){return new te(t)},BSONRegExp:function(t){return new ee(t.pattern,t.options)},Symbol:function(t){return new ne(t.value)},Timestamp:function(t){return oe.fromBits(t.low,t.high)}};!function(t){function e(t,e){var n=Object.assign({},{relaxed:!0,legacy:!1},e);return"boolean"==typeof n.relaxed&&(n.strict=!n.relaxed),"boolean"==typeof n.strict&&(n.relaxed=!n.strict),JSON.parse(t,(function(t,e){if(-1!==t.indexOf("\0"))throw new v("BSON Document field names cannot contain null bytes, found: ".concat(JSON.stringify(t)));return le(e,n)}))}function n(t,e,n,r){null!=n&&"object"==typeof n&&(r=n,n=0),null==e||"object"!=typeof e||Array.isArray(e)||(r=e,e=void 0,n=0);var o=he(t,Object.assign({relaxed:!0,legacy:!1},r,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,e,n)}t.parse=e,t.stringify=n,t.serialize=function(t,e){return e=e||{},JSON.parse(n(t,e))},t.deserialize=function(t,n){return n=n||{},e(JSON.stringify(t),n)}}(de||(de={}));var me=E();function be(t,e,n){var r=5;if(Array.isArray(t))for(var o=0;o<t.length;o++)r+=we(o.toString(),t[o],e,!0,n);else for(var i in"function"==typeof(null==t?void 0:t.toBSON)&&(t=t.toBSON()),t)r+=we(i,t[i],e,!1,n);return r}function we(t,e,n,r,o){switch(void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===o&&(o=!1),"function"==typeof(null==e?void 0:e.toBSON)&&(e=e.toBSON()),typeof e){case"string":return 1+g.byteLength(t,"utf8")+1+4+g.byteLength(e,"utf8")+1;case"number":return Math.floor(e)===e&&e>=Q&&e<=G&&e>=Y&&e<=q?(null!=t?g.byteLength(t,"utf8")+1:0)+5:(null!=t?g.byteLength(t,"utf8")+1:0)+9;case"undefined":return r||!o?(null!=t?g.byteLength(t,"utf8")+1:0)+1:0;case"boolean":return(null!=t?g.byteLength(t,"utf8")+1:0)+2;case"object":if(null==e||"MinKey"===e._bsontype||"MaxKey"===e._bsontype)return(null!=t?g.byteLength(t,"utf8")+1:0)+1;if("ObjectId"===e._bsontype||"ObjectID"===e._bsontype)return(null!=t?g.byteLength(t,"utf8")+1:0)+13;if(e instanceof Date||R(e))return(null!=t?g.byteLength(t,"utf8")+1:0)+9;if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||T(e))return(null!=t?g.byteLength(t,"utf8")+1:0)+6+e.byteLength;if("Long"===e._bsontype||"Double"===e._bsontype||"Timestamp"===e._bsontype)return(null!=t?g.byteLength(t,"utf8")+1:0)+9;if("Decimal128"===e._bsontype)return(null!=t?g.byteLength(t,"utf8")+1:0)+17;if("Code"===e._bsontype)return null!=e.scope&&Object.keys(e.scope).length>0?(null!=t?g.byteLength(t,"utf8")+1:0)+1+4+4+g.byteLength(e.code.toString(),"utf8")+1+be(e.scope,n,o):(null!=t?g.byteLength(t,"utf8")+1:0)+1+4+g.byteLength(e.code.toString(),"utf8")+1;if("Binary"===e._bsontype){var i=e;return i.sub_type===Ot.SUBTYPE_BYTE_ARRAY?(null!=t?g.byteLength(t,"utf8")+1:0)+(i.position+1+4+1+4):(null!=t?g.byteLength(t,"utf8")+1:0)+(i.position+1+4+1)}if("Symbol"===e._bsontype)return(null!=t?g.byteLength(t,"utf8")+1:0)+g.byteLength(e.value,"utf8")+4+1+1;if("DBRef"===e._bsontype){var u=Object.assign({$ref:e.collection,$id:e.oid},e.fields);return null!=e.db&&(u.$db=e.db),(null!=t?g.byteLength(t,"utf8")+1:0)+1+be(u,n,o)}return e instanceof RegExp||D(e)?(null!=t?g.byteLength(t,"utf8")+1:0)+1+g.byteLength(e.source,"utf8")+1+(e.global?1:0)+(e.ignoreCase?1:0)+(e.multiline?1:0)+1:"BSONRegExp"===e._bsontype?(null!=t?g.byteLength(t,"utf8")+1:0)+1+g.byteLength(e.pattern,"utf8")+1+g.byteLength(e.options,"utf8")+1:(null!=t?g.byteLength(t,"utf8")+1:0)+be(e,n,o)+1;case"function":if(e instanceof RegExp||D(e)||"[object RegExp]"===String.call(e))return(null!=t?g.byteLength(t,"utf8")+1:0)+1+g.byteLength(e.source,"utf8")+1+(e.global?1:0)+(e.ignoreCase?1:0)+(e.multiline?1:0)+1;if(n&&null!=e.scope&&Object.keys(e.scope).length>0)return(null!=t?g.byteLength(t,"utf8")+1:0)+1+4+4+g.byteLength(S(e),"utf8")+1+be(e.scope,n,o);if(n)return(null!=t?g.byteLength(t,"utf8")+1:0)+1+4+g.byteLength(S(e),"utf8")+1}return 0}ye=me.Map?me.Map:function(){function t(t){void 0===t&&(t=[]),this._keys=[],this._values={};for(var e=0;e<t.length;e++)if(null!=t[e]){var n=t[e],r=n[0],o=n[1];this._keys.push(r),this._values[r]={v:o,i:this._keys.length-1}}}return t.prototype.clear=function(){this._keys=[],this._values={}},t.prototype.delete=function(t){var e=this._values[t];return null!=e&&(delete this._values[t],this._keys.splice(e.i,1),!0)},t.prototype.entries=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?[n,t._values[n].v]:void 0,done:void 0===n}}}},t.prototype.forEach=function(t,e){e=e||this;for(var n=0;n<this._keys.length;n++){var r=this._keys[n];t.call(e,this._values[r].v,r,e)}},t.prototype.get=function(t){return this._values[t]?this._values[t].v:void 0},t.prototype.has=function(t){return null!=this._values[t]},t.prototype.keys=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?n:void 0,done:void 0===n}}}},t.prototype.set=function(t,e){return this._values[t]?(this._values[t].v=e,this):(this._keys.push(t),this._values[t]={v:e,i:this._keys.length-1},this)},t.prototype.values=function(){var t=this,e=0;return{next:function(){var n=t._keys[e++];return{value:void 0!==n?t._values[n].v:void 0,done:void 0===n}}}},Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!1,configurable:!0}),t}();var ve=128,_e=192,Oe=224,Ee=240,Se=248,Ne=192,Ae=224,Te=240,Le=128;function Ie(t,e,n){for(var r=0,o=e;o<n;o+=1){var i=t[o];if(r){if((i&_e)!==Le)return!1;r-=1}else if(i&ve)if((i&Oe)===Ne)r=1;else if((i&Ee)===Ae)r=2;else{if((i&Se)!==Te)return!1;r=3}}return!r}var Me=xt.fromNumber(G),De=xt.fromNumber(Q),Re={};function xe(t,e,n){var r=(e=null==e?{}:e)&&e.index?e.index:0,o=t[r]|t[r+1]<<8|t[r+2]<<16|t[r+3]<<24;if(o<5)throw new v("bson size must be >= 5, is ".concat(o));if(e.allowObjectSmallerThanBufferSize&&t.length<o)throw new v("buffer length ".concat(t.length," must be >= bson size ").concat(o));if(!e.allowObjectSmallerThanBufferSize&&t.length!==o)throw new v("buffer length ".concat(t.length," must === bson size ").concat(o));if(o+r>t.byteLength)throw new v("(bson size ".concat(o," + options.index ").concat(r," must be <= buffer length ").concat(t.byteLength,")"));if(0!==t[r+o-1])throw new v("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return Ce(t,r,e,n)}var Be=/^\$ref$|^\$id$|^\$db$/;function Ce(t,e,n,r){void 0===r&&(r=!1);var o,i=null!=n.evalFunctions&&n.evalFunctions,u=null!=n.cacheFunctions&&n.cacheFunctions,s=null==n.fieldsAsRaw?null:n.fieldsAsRaw,a=null!=n.raw&&n.raw,f="boolean"==typeof n.bsonRegExp&&n.bsonRegExp,c=null!=n.promoteBuffers&&n.promoteBuffers,l=null==n.promoteLongs||n.promoteLongs,p=null==n.promoteValues||n.promoteValues,h=null==n.validation?{utf8:!0}:n.validation,d=!0,y=new Set,m=h.utf8;if("boolean"==typeof m)o=m;else{d=!1;var b=Object.keys(m).map((function(t){return m[t]}));if(0===b.length)throw new v("UTF-8 validation setting cannot be empty");if("boolean"!=typeof b[0])throw new v("Invalid UTF-8 validation option, must specify boolean values");if(o=b[0],!b.every((function(t){return t===o})))throw new v("Invalid UTF-8 validation option - keys must be all true or all false")}if(!d)for(var _=0,O=Object.keys(m);_<O.length;_++){var E=O[_];y.add(E)}var S=e;if(t.length<5)throw new v("corrupt bson message < 5 bytes long");var N=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;if(N<5||N>t.length)throw new v("corrupt bson message");for(var A=r?[]:{},T=0,L=!r&&null,I=new DataView(t.buffer,t.byteOffset,t.byteLength);;){var M=t[e++];if(0===M)break;for(var D=e;0!==t[D]&&D<t.length;)D++;if(D>=t.byteLength)throw new v("Bad BSON Document: illegal CString");var R,x=r?T++:t.toString("utf8",e,D);R=d||y.has(x)?o:!o,!1!==L&&"$"===x[0]&&(L=Be.test(x));var B=void 0;if(e=D+1,M===z){if((Mt=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<=0||Mt>t.length-e||0!==t[e+Mt-1])throw new v("bad string length in bson");B=Ue(t,e,e+Mt-1,R),e+=Mt}else if(M===K){var C=g.alloc(12);t.copy(C,0,e,e+12),B=new te(C),e+=12}else if(M===st&&!1===p)B=new Vt(t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24);else if(M===st)B=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;else if(M===J&&!1===p)B=new zt(I.getFloat64(e,!0)),e+=8;else if(M===J)B=I.getFloat64(e,!0),e+=8;else if(M===tt){var P=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,U=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;B=new Date(new xt(P,U).toNumber())}else if(M===X){if(0!==t[e]&&1!==t[e])throw new v("illegal boolean type value");B=1===t[e++]}else if(M===V){var j=e;if((Lt=t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)<=0||Lt>t.length-e)throw new v("bad embedded document length in bson");if(a)B=t.slice(e,e+Lt);else{var $=n;d||($=w(w({},n),{validation:{utf8:R}})),B=Ce(t,j,$,!1)}e+=Lt}else if(M===H){j=e;var q=n,Y=e+(Lt=t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24);if(s&&s[x]){for(var F in q={},n)q[F]=n[F];q.raw=!0}if(d||(q=w(w({},q),{validation:{utf8:R}})),B=Ce(t,j,q,!0),0!==t[(e+=Lt)-1])throw new v("invalid array terminator byte");if(e!==Y)throw new v("corrupted array bson")}else if(M===Z)B=void 0;else if(M===et)B=null;else if(M===ft){P=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,U=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;var k=new xt(P,U);B=l&&!0===p&&k.lessThanOrEqual(Me)&&k.greaterThanOrEqual(De)?k.toNumber():k}else if(M===ct){var G=g.alloc(16);t.copy(G,0,e,e+16),e+=16;var Q=new Jt(G);B="toObject"in Q&&"function"==typeof Q.toObject?Q.toObject():Q}else if(M===W){var ht=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,dt=ht,yt=t[e++];if(ht<0)throw new v("Negative binary type element size found");if(ht>t.byteLength)throw new v("Binary type size larger than document size");if(null!=t.slice){if(yt===Ot.SUBTYPE_BYTE_ARRAY){if((ht=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<0)throw new v("Negative binary type element size found for subtype 0x02");if(ht>dt-4)throw new v("Binary type with subtype 0x02 contains too long binary size");if(ht<dt-4)throw new v("Binary type with subtype 0x02 contains too short binary size")}c&&p?B=t.slice(e,e+ht):(B=new Ot(t.slice(e,e+ht),yt),yt===mt&&(B=B.toUUID()))}else{var gt=g.alloc(ht);if(yt===Ot.SUBTYPE_BYTE_ARRAY){if((ht=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<0)throw new v("Negative binary type element size found for subtype 0x02");if(ht>dt-4)throw new v("Binary type with subtype 0x02 contains too long binary size");if(ht<dt-4)throw new v("Binary type with subtype 0x02 contains too short binary size")}for(D=0;D<ht;D++)gt[D]=t[e+D];B=c&&p?gt:yt===mt?new Ot(t.slice(e,e+ht),yt).toUUID():new Ot(t.slice(e,e+ht),yt)}e+=ht}else if(M===nt&&!1===f){for(D=e;0!==t[D]&&D<t.length;)D++;if(D>=t.length)throw new v("Bad BSON Document: illegal CString");var bt=t.toString("utf8",e,D);for(D=e=D+1;0!==t[D]&&D<t.length;)D++;if(D>=t.length)throw new v("Bad BSON Document: illegal CString");var wt=t.toString("utf8",e,D);e=D+1;var vt=new Array(wt.length);for(D=0;D<wt.length;D++)switch(wt[D]){case"m":vt[D]="m";break;case"s":vt[D]="g";break;case"i":vt[D]="i"}B=new RegExp(bt,vt.join(""))}else if(M===nt&&!0===f){for(D=e;0!==t[D]&&D<t.length;)D++;if(D>=t.length)throw new v("Bad BSON Document: illegal CString");for(bt=t.toString("utf8",e,D),D=e=D+1;0!==t[D]&&D<t.length;)D++;if(D>=t.length)throw new v("Bad BSON Document: illegal CString");wt=t.toString("utf8",e,D),e=D+1,B=new ee(bt,wt)}else if(M===it){if((Mt=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<=0||Mt>t.length-e||0!==t[e+Mt-1])throw new v("bad string length in bson");var _t=Ue(t,e,e+Mt-1,R);B=p?_t:new ne(_t),e+=Mt}else if(M===at)P=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,U=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,B=new oe(P,U);else if(M===lt)B=new Wt;else if(M===pt)B=new Ht;else if(M===ot){if((Mt=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<=0||Mt>t.length-e||0!==t[e+Mt-1])throw new v("bad string length in bson");var Et=Ue(t,e,e+Mt-1,R);B=i?u?Pe(Et,Re,A):Pe(Et):new St(Et),e+=Mt}else if(M===ut){var Tt=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;if(Tt<13)throw new v("code_w_scope total size shorter minimum expected length");if((Mt=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<=0||Mt>t.length-e||0!==t[e+Mt-1])throw new v("bad string length in bson");Et=Ue(t,e,e+Mt-1,R),j=e+=Mt;var Lt=t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24,It=Ce(t,j,n,!1);if(e+=Lt,Tt<8+Lt+Mt)throw new v("code_w_scope total size is too short, truncating scope");if(Tt>8+Lt+Mt)throw new v("code_w_scope total size is too long, clips outer document");i?(B=u?Pe(Et,Re,A):Pe(Et)).scope=It:B=new St(Et,It)}else{if(M!==rt)throw new v("Detected unknown BSON type ".concat(M.toString(16),' for fieldname "').concat(x,'"'));var Mt;if((Mt=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<=0||Mt>t.length-e||0!==t[e+Mt-1])throw new v("bad string length in bson");if(null!=h&&h.utf8&&!Ie(t,e,e+Mt-1))throw new v("Invalid UTF-8 string in BSON document");var Dt=t.toString("utf8",e,e+Mt-1);e+=Mt;var Rt=g.alloc(12);t.copy(Rt,0,e,e+12),C=new te(Rt),e+=12,B=new At(Dt,C)}"__proto__"===x?Object.defineProperty(A,x,{value:B,writable:!0,enumerable:!0,configurable:!0}):A[x]=B}if(N!==e-S){if(r)throw new v("corrupt array bson");throw new v("corrupt object bson")}if(!L)return A;if(Nt(A)){var Bt=Object.assign({},A);return delete Bt.$ref,delete Bt.$id,delete Bt.$db,new At(A.$ref,A.$id,A.$db,Bt)}return A}function Pe(t,e,n){return e?(null==e[t]&&(e[t]=new Function(t)),e[t].bind(n)):new Function(t)}function Ue(t,e,n,r){var o=t.toString("utf8",e,n);if(r)for(var i=0;i<o.length;i++)if(65533===o.charCodeAt(i)){if(!Ie(t,e,n))throw new v("Invalid UTF-8 string in BSON document");break}return o}var je=/\x00/,$e=new Set(["$db","$ref","$id","$clusterTime"]);function qe(t,e,n,r,o){t[r++]=z;var i=o?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8");t[(r=r+i+1)-1]=0;var u=t.write(n,r+4,void 0,"utf8");return t[r+3]=u+1>>24&255,t[r+2]=u+1>>16&255,t[r+1]=u+1>>8&255,t[r]=u+1&255,r=r+4+u,t[r++]=0,r}var Ye=new Uint8Array(8),Fe=new DataView(Ye.buffer,Ye.byteOffset,Ye.byteLength);function ke(t,e,n,r,o){return Number.isInteger(n)&&n>=Y&&n<=q?(t[r++]=st,r+=o?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0,t[r++]=255&n,t[r++]=n>>8&255,t[r++]=n>>16&255,t[r++]=n>>24&255):(t[r++]=J,r+=o?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0,Fe.setFloat64(0,n,!0),t.set(Ye,r),r+=8),r}function Ge(t,e,n,r,o){return t[r++]=et,r+=o?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0,r}function Qe(t,e,n,r,o){return t[r++]=X,r+=o?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0,t[r++]=n?1:0,r}function Je(t,e,n,r,o){t[r++]=tt,r+=o?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0;var i=xt.fromNumber(n.getTime()),u=i.getLowBits(),s=i.getHighBits();return t[r++]=255&u,t[r++]=u>>8&255,t[r++]=u>>16&255,t[r++]=u>>24&255,t[r++]=255&s,t[r++]=s>>8&255,t[r++]=s>>16&255,t[r++]=s>>24&255,r}function ze(t,e,n,r,o){if(t[r++]=nt,r+=o?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0,n.source&&null!=n.source.match(je))throw Error("value "+n.source+" must not contain null bytes");return r+=t.write(n.source,r,void 0,"utf8"),t[r++]=0,n.ignoreCase&&(t[r++]=105),n.global&&(t[r++]=115),n.multiline&&(t[r++]=109),t[r++]=0,r}function Ve(t,e,n,r,o){if(t[r++]=nt,r+=o?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0,null!=n.pattern.match(je))throw Error("pattern "+n.pattern+" must not contain null bytes");return r+=t.write(n.pattern,r,void 0,"utf8"),t[r++]=0,r+=t.write(n.options.split("").sort().join(""),r,void 0,"utf8"),t[r++]=0,r}function He(t,e,n,r,o){return null===n?t[r++]=et:"MinKey"===n._bsontype?t[r++]=lt:t[r++]=pt,r+=o?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0,r}function We(t,e,n,r,o){if(t[r++]=K,r+=o?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0,"string"==typeof n.id)t.write(n.id,r,void 0,"binary");else{if(!L(n.id))throw new _("object ["+JSON.stringify(n)+"] is not a valid ObjectId");t.set(n.id.subarray(0,12),r)}return r+12}function Ze(t,e,n,r,o){t[r++]=W,r+=o?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0;var i=n.length;return t[r++]=255&i,t[r++]=i>>8&255,t[r++]=i>>16&255,t[r++]=i>>24&255,t[r++]=ht,t.set(C(n),r),r+i}function Ke(t,e,n,r,o,i,u,s,a,f){void 0===o&&(o=!1),void 0===i&&(i=0),void 0===u&&(u=!1),void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===f&&(f=[]);for(var c=0;c<f.length;c++)if(f[c]===n)throw new v("cyclic dependency detected");f.push(n),t[r++]=Array.isArray(n)?H:V,r+=a?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0;var l=fn(t,n,o,r,i+1,u,s,f);return f.pop(),l}function Xe(t,e,n,r,o){return t[r++]=ct,r+=o?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0,t.set(n.bytes.subarray(0,16),r),r+16}function tn(t,e,n,r,o){t[r++]="Long"===n._bsontype?ft:at,r+=o?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0;var i=n.getLowBits(),u=n.getHighBits();return t[r++]=255&i,t[r++]=i>>8&255,t[r++]=i>>16&255,t[r++]=i>>24&255,t[r++]=255&u,t[r++]=u>>8&255,t[r++]=u>>16&255,t[r++]=u>>24&255,r}function en(t,e,n,r,o){return n=n.valueOf(),t[r++]=st,r+=o?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0,t[r++]=255&n,t[r++]=n>>8&255,t[r++]=n>>16&255,t[r++]=n>>24&255,r}function nn(t,e,n,r,o){return t[r++]=J,r+=o?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0,Fe.setFloat64(0,n.value,!0),t.set(Ye,r),r+8}function rn(t,e,n,r,o,i,u){t[r++]=ot,r+=u?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0;var s=S(n),a=t.write(s,r+4,void 0,"utf8")+1;return t[r]=255&a,t[r+1]=a>>8&255,t[r+2]=a>>16&255,t[r+3]=a>>24&255,r=r+4+a-1,t[r++]=0,r}function on(t,e,n,r,o,i,u,s,a){if(void 0===o&&(o=!1),void 0===i&&(i=0),void 0===u&&(u=!1),void 0===s&&(s=!0),void 0===a&&(a=!1),n.scope&&"object"==typeof n.scope){t[r++]=ut,r+=a?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0;var f=r,c="string"==typeof n.code?n.code:n.code.toString();r+=4;var l=t.write(c,r+4,void 0,"utf8")+1;t[r]=255&l,t[r+1]=l>>8&255,t[r+2]=l>>16&255,t[r+3]=l>>24&255,t[r+4+l-1]=0,r=r+l+4;var p=fn(t,n.scope,o,r,i+1,u,s);r=p-1;var h=p-f;t[f++]=255&h,t[f++]=h>>8&255,t[f++]=h>>16&255,t[f++]=h>>24&255,t[r++]=0}else{t[r++]=ot,r+=a?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0,c=n.code.toString();var d=t.write(c,r+4,void 0,"utf8")+1;t[r]=255&d,t[r+1]=d>>8&255,t[r+2]=d>>16&255,t[r+3]=d>>24&255,r=r+4+d-1,t[r++]=0}return r}function un(t,e,n,r,o){t[r++]=W,r+=o?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0;var i=n.value(!0),u=n.position;return n.sub_type===Ot.SUBTYPE_BYTE_ARRAY&&(u+=4),t[r++]=255&u,t[r++]=u>>8&255,t[r++]=u>>16&255,t[r++]=u>>24&255,t[r++]=n.sub_type,n.sub_type===Ot.SUBTYPE_BYTE_ARRAY&&(u-=4,t[r++]=255&u,t[r++]=u>>8&255,t[r++]=u>>16&255,t[r++]=u>>24&255),t.set(i,r),r+n.position}function sn(t,e,n,r,o){t[r++]=it,r+=o?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0;var i=t.write(n.value,r+4,void 0,"utf8")+1;return t[r]=255&i,t[r+1]=i>>8&255,t[r+2]=i>>16&255,t[r+3]=i>>24&255,r=r+4+i-1,t[r++]=0,r}function an(t,e,n,r,o,i,u){t[r++]=V,r+=u?t.write(e,r,void 0,"ascii"):t.write(e,r,void 0,"utf8"),t[r++]=0;var s=r,a={$ref:n.collection||n.namespace,$id:n.oid};null!=n.db&&(a.$db=n.db);var f=fn(t,a=Object.assign(a,n.fields),!1,r,o+1,i),c=f-s;return t[s++]=255&c,t[s++]=c>>8&255,t[s++]=c>>16&255,t[s++]=c>>24&255,f}function fn(t,e,n,r,o,i,u,s){void 0===n&&(n=!1),void 0===r&&(r=0),void 0===o&&(o=0),void 0===i&&(i=!1),void 0===u&&(u=!0),void 0===s&&(s=[]),r=r||0,(s=s||[]).push(e);var a,f=r+4;if(Array.isArray(e))for(var c=0;c<e.length;c++){var l="".concat(c);if("function"==typeof(null==(g=e[c])?void 0:g.toBSON)&&(g=g.toBSON()),"string"==typeof g)f=qe(t,l,g,f,!0);else if("number"==typeof g)f=ke(t,l,g,f,!0);else{if("bigint"==typeof g)throw new _("Unsupported type BigInt, please use Decimal128");if("boolean"==typeof g)f=Qe(t,l,g,f,!0);else if(g instanceof Date||R(g))f=Je(t,l,g,f,!0);else if(void 0===g)f=Ge(t,l,0,f,!0);else if(null===g)f=Ge(t,l,0,f,!0);else if("ObjectId"===g._bsontype||"ObjectID"===g._bsontype)f=We(t,l,g,f,!0);else if(L(g))f=Ze(t,l,g,f,!0);else if(g instanceof RegExp||D(g))f=ze(t,l,g,f,!0);else if("object"==typeof g&&null==g._bsontype)f=Ke(t,l,g,f,n,o,i,u,!0,s);else if("object"==typeof g&&ie(g)&&"Decimal128"===g._bsontype)f=Xe(t,l,g,f,!0);else if("Long"===g._bsontype||"Timestamp"===g._bsontype)f=tn(t,l,g,f,!0);else if("Double"===g._bsontype)f=nn(t,l,g,f,!0);else if("function"==typeof g&&i)f=rn(t,l,g,f,0,0,!0);else if("Code"===g._bsontype)f=on(t,l,g,f,n,o,i,u,!0);else if("Binary"===g._bsontype)f=un(t,l,g,f,!0);else if("Symbol"===g._bsontype)f=sn(t,l,g,f,!0);else if("DBRef"===g._bsontype)f=an(t,l,g,f,o,i,!0);else if("BSONRegExp"===g._bsontype)f=Ve(t,l,g,f,!0);else if("Int32"===g._bsontype)f=en(t,l,g,f,!0);else if("MinKey"===g._bsontype||"MaxKey"===g._bsontype)f=He(t,l,g,f,!0);else if(void 0!==g._bsontype)throw new _("Unrecognized or invalid _bsontype: ".concat(String(g._bsontype)))}}else if(e instanceof ye||(a=e,"[object Map]"===Object.prototype.toString.call(a)))for(var p=e.entries(),h=!1;!h;){var d=p.next();if(!(h=!!d.done)){l=d.value[0];var y=typeof(g=d.value[1]);if("string"==typeof l&&!$e.has(l)){if(null!=l.match(je))throw Error("key "+l+" must not contain null bytes");if(n){if("$"===l[0])throw Error("key "+l+" must not start with '$'");if(~l.indexOf("."))throw Error("key "+l+" must not contain '.'")}}if("string"===y)f=qe(t,l,g,f);else if("number"===y)f=ke(t,l,g,f);else{if("bigint"===y||I(g)||M(g))throw new _("Unsupported type BigInt, please use Decimal128");if("boolean"===y)f=Qe(t,l,g,f);else if(g instanceof Date||R(g))f=Je(t,l,g,f);else if(null===g||void 0===g&&!1===u)f=Ge(t,l,0,f);else if("ObjectId"===g._bsontype||"ObjectID"===g._bsontype)f=We(t,l,g,f);else if(L(g))f=Ze(t,l,g,f);else if(g instanceof RegExp||D(g))f=ze(t,l,g,f);else if("object"===y&&null==g._bsontype)f=Ke(t,l,g,f,n,o,i,u,!1,s);else if("object"===y&&"Decimal128"===g._bsontype)f=Xe(t,l,g,f);else if("Long"===g._bsontype||"Timestamp"===g._bsontype)f=tn(t,l,g,f);else if("Double"===g._bsontype)f=nn(t,l,g,f);else if("Code"===g._bsontype)f=on(t,l,g,f,n,o,i,u);else if("function"==typeof g&&i)f=rn(t,l,g,f,0,0,i);else if("Binary"===g._bsontype)f=un(t,l,g,f);else if("Symbol"===g._bsontype)f=sn(t,l,g,f);else if("DBRef"===g._bsontype)f=an(t,l,g,f,o,i);else if("BSONRegExp"===g._bsontype)f=Ve(t,l,g,f);else if("Int32"===g._bsontype)f=en(t,l,g,f);else if("MinKey"===g._bsontype||"MaxKey"===g._bsontype)f=He(t,l,g,f);else if(void 0!==g._bsontype)throw new _("Unrecognized or invalid _bsontype: ".concat(String(g._bsontype)))}}}else{if("function"==typeof(null==e?void 0:e.toBSON)&&null!=(e=e.toBSON())&&"object"!=typeof e)throw new _("toBSON function did not return an object");for(var l in e){var g;if("function"==typeof(null==(g=e[l])?void 0:g.toBSON)&&(g=g.toBSON()),y=typeof g,"string"==typeof l&&!$e.has(l)){if(null!=l.match(je))throw Error("key "+l+" must not contain null bytes");if(n){if("$"===l[0])throw Error("key "+l+" must not start with '$'");if(~l.indexOf("."))throw Error("key "+l+" must not contain '.'")}}if("string"===y)f=qe(t,l,g,f);else if("number"===y)f=ke(t,l,g,f);else{if("bigint"===y)throw new _("Unsupported type BigInt, please use Decimal128");if("boolean"===y)f=Qe(t,l,g,f);else if(g instanceof Date||R(g))f=Je(t,l,g,f);else if(void 0===g)!1===u&&(f=Ge(t,l,0,f));else if(null===g)f=Ge(t,l,0,f);else if("ObjectId"===g._bsontype||"ObjectID"===g._bsontype)f=We(t,l,g,f);else if(L(g))f=Ze(t,l,g,f);else if(g instanceof RegExp||D(g))f=ze(t,l,g,f);else if("object"===y&&null==g._bsontype)f=Ke(t,l,g,f,n,o,i,u,!1,s);else if("object"===y&&"Decimal128"===g._bsontype)f=Xe(t,l,g,f);else if("Long"===g._bsontype||"Timestamp"===g._bsontype)f=tn(t,l,g,f);else if("Double"===g._bsontype)f=nn(t,l,g,f);else if("Code"===g._bsontype)f=on(t,l,g,f,n,o,i,u);else if("function"==typeof g&&i)f=rn(t,l,g,f,0,0,i);else if("Binary"===g._bsontype)f=un(t,l,g,f);else if("Symbol"===g._bsontype)f=sn(t,l,g,f);else if("DBRef"===g._bsontype)f=an(t,l,g,f,o,i);else if("BSONRegExp"===g._bsontype)f=Ve(t,l,g,f);else if("Int32"===g._bsontype)f=en(t,l,g,f);else if("MinKey"===g._bsontype||"MaxKey"===g._bsontype)f=He(t,l,g,f);else if(void 0!==g._bsontype)throw new _("Unrecognized or invalid _bsontype: ".concat(String(g._bsontype)))}}}s.pop(),t[f++]=0;var m=f-r;return t[r++]=255&m,t[r++]=m>>8&255,t[r++]=m>>16&255,t[r++]=m>>24&255,f}var cn=17825792,ln=g.alloc(cn);function pn(t){ln.length<t&&(ln=g.alloc(t))}function hn(t,e){void 0===e&&(e={});var n="boolean"==typeof e.checkKeys&&e.checkKeys,r="boolean"==typeof e.serializeFunctions&&e.serializeFunctions,o="boolean"!=typeof e.ignoreUndefined||e.ignoreUndefined,i="number"==typeof e.minInternalBufferSize?e.minInternalBufferSize:cn;ln.length<i&&(ln=g.alloc(i));var u=fn(ln,t,n,0,0,r,o,[]),s=g.alloc(u);return ln.copy(s,0,0,s.length),s}function dn(t,e,n){void 0===n&&(n={});var r="boolean"==typeof n.checkKeys&&n.checkKeys,o="boolean"==typeof n.serializeFunctions&&n.serializeFunctions,i="boolean"!=typeof n.ignoreUndefined||n.ignoreUndefined,u="number"==typeof n.index?n.index:0,s=fn(ln,t,r,0,0,o,i);return ln.copy(e,u,0,s),u+s-1}function yn(t,e){return void 0===e&&(e={}),xe(t instanceof g?t:C(t),e)}function gn(t,e){return void 0===e&&(e={}),be(t,"boolean"==typeof(e=e||{}).serializeFunctions&&e.serializeFunctions,"boolean"!=typeof e.ignoreUndefined||e.ignoreUndefined)}function mn(t,e,n,r,o,i){for(var u=Object.assign({allowObjectSmallerThanBufferSize:!0,index:0},i),s=C(t),a=e,f=0;f<n;f++){var c=s[a]|s[a+1]<<8|s[a+2]<<16|s[a+3]<<24;u.index=a,r[o+f]=xe(s,u),a+=c}return a}const bn={Binary:Ot,Code:St,DBRef:At,Decimal128:Jt,Double:zt,Int32:Vt,Long:xt,UUID:Et,Map:ye,MaxKey:Ht,MinKey:Wt,ObjectId:te,ObjectID:te,BSONRegExp:ee,BSONSymbol:ne,Timestamp:oe,EJSON:de,setInternalBufferSize:pn,serialize:hn,serializeWithBufferAndIndex:dn,deserialize:yn,calculateObjectSize:gn,deserializeStream:mn,BSONError:v,BSONTypeError:_}},258:function(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.registerDatabase=void 0;var o=n(672),i={name:"database",entity:{database:function(t){var e=this.platform,n=e.adapter,i=e.runtime;return o.Db.reqClass=this.request.constructor,o.Db.getAccessToken=this.authInstance?this.authInstance.getAccessToken.bind(this.authInstance):function(){return""},o.Db.runtime=i,this.wsClientClass&&(o.Db.wsClass=n.wsClass,o.Db.wsClientClass=this.wsClientClass),o.Db.ws||(o.Db.ws=null),new o.Db(r(r(r({},this.config),{_fromApp:this}),t))}}};try{cloudbase.registerComponent(i)}catch(t){}e.registerDatabase=function(t){try{t.registerComponent(i)}catch(t){console.warn(t)}}}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,n),i.exports}return n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n(258)})()));
|