@cloudbase/js-sdk 2.0.0-alpha.1 → 2.0.0-alpha.2

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.
@@ -14,7 +14,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
14
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
15
  PERFORMANCE OF THIS SOFTWARE.
16
16
  ***************************************************************************** */
17
- var dt=function(t,e){return(dt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};var yt=function(){return(yt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function gt(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function bt(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}function _t(t){return this instanceof _t?(this.v=t,this):new _t(t)}var mt=Object.freeze({__proto__:null,__extends:function(t,e){function r(){this.constructor=t}dt(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)},get __assign(){return yt},__rest:function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r},__decorate:function(t,e,r,n){var o,i=arguments.length,u=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"===("undefined"==typeof Reflect?"undefined":babelHelpers.typeof(Reflect))&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(u=(i<3?o(u):i>3?o(e,r,u):o(e,r))||u);return i>3&&u&&Object.defineProperty(e,r,u),u},__param:function(t,e){return function(r,n){e(r,n,t)}},__metadata:function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":babelHelpers.typeof(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},__awaiter:function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function u(t){try{f(n.next(t))}catch(t){i(t)}}function s(t){try{f(n.throw(t))}catch(t){i(t)}}function f(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,s)}f((n=n.apply(t,e||[])).next())}))},__generator:function(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=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++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.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],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},__createBinding:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]},__exportStar:function(t,e){for(var r in t)"default"===r||e.hasOwnProperty(r)||(e[r]=t[r])},__values:gt,__read:bt,__spread:function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(bt(arguments[e]));return t},__spreadArrays:function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),o=0;for(e=0;e<r;e++)for(var i=arguments[e],u=0,s=i.length;u<s;u++,o++)n[o]=i[u];return n},__await:_t,__asyncGenerator:function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(t,e||[]),i=[];return n={},u("next"),u("throw"),u("return"),n[Symbol.asyncIterator]=function(){return this},n;function u(t){o[t]&&(n[t]=function(e){return new Promise((function(r,n){i.push([t,e,r,n])>1||s(t,e)}))})}function s(t,e){try{(r=o[t](e)).value instanceof _t?Promise.resolve(r.value.v).then(f,a):c(i[0][2],r)}catch(t){c(i[0][3],t)}var r}function f(t){s("next",t)}function a(t){s("throw",t)}function c(t,e){t(e),i.shift(),i.length&&s(i[0][0],i[0][1])}},__asyncDelegator:function(t){var e,r;return e={},n("next"),n("throw",(function(t){throw t})),n("return"),e[Symbol.iterator]=function(){return this},e;function n(n,o){e[n]=t[n]?function(e){return(r=!r)?{value:_t(t[n](e)),done:"return"===n}:o?o(e):e}:o}},__asyncValues:function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=gt(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,o){(function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)})(n,o,(e=t[r](e)).done,e.value)}))}}},__makeTemplateObject:function(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t},__importStar:function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e},__importDefault:function(t){return t&&t.__esModule?t:{default:t}},__classPrivateFieldGet:function(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)},__classPrivateFieldSet:function(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}}),wt=u((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Timestamp=e.LongWithoutOverridesClass=void 0,e.LongWithoutOverridesClass=it.Long;var r=function(t){function e(r,n){var o=this;return o instanceof e?(o=it.Long.isLong(r)?t.call(this,r.low,r.high,!0)||this:t.call(this,r,n,!0)||this,Object.defineProperty(o,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1}),o):new e(r,n)}return mt.__extends(e,t),e.prototype.toJSON=function(){return{$timestamp:this.toString()}},e.fromInt=function(t){return new e(it.Long.fromInt(t,!0))},e.fromNumber=function(t){return new e(it.Long.fromNumber(t,!0))},e.fromBits=function(t,r){return new e(t,r)},e.fromString=function(t,r){return new e(it.Long.fromString(t,!0,r))},e.prototype.toExtendedJSON=function(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}},e.fromExtendedJSON=function(t){return new e(t.$timestamp.i,t.$timestamp.t)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new Timestamp("+this.getLowBits().toString()+", "+this.getHighBits().toString()+")"},e.MAX_VALUE=it.Long.MAX_UNSIGNED_VALUE,e}(e.LongWithoutOverridesClass);e.Timestamp=r}));i(wt),wt.Timestamp,wt.LongWithoutOverridesClass;var vt=u((function(t,e){function r(t){return Z.isObjectLike(t)&&Reflect.has(t,"_bsontype")&&"string"==typeof t._bsontype}Object.defineProperty(e,"__esModule",{value:!0}),e.EJSON=e.isBSONType=void 0,e.isBSONType=r;var n={$oid:lt.ObjectId,$binary:rt.Binary,$uuid:rt.Binary,$symbol:ht.BSONSymbol,$numberInt:ft.Int32,$numberDecimal:ut.Decimal128,$numberDouble:st.Double,$numberLong:it.Long,$minKey:ct.MinKey,$maxKey:at.MaxKey,$regex:pt.BSONRegExp,$regularExpression:pt.BSONRegExp,$timestamp:wt.Timestamp};function o(t){var e=t.toISOString();return 0!==t.getUTCMilliseconds()?e:e.slice(0,-5)+"Z"}function i(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 s=e.seenObjects.map((function(t){return t.propertyName})),f=s.slice(0,n).map((function(t){return t+" -> "})).join(""),a=s[n],c=" -> "+s.slice(n+1,s.length-1).map((function(t){return t+" -> "})).join(""),l=s[s.length-1],p=" ".repeat(f.length+a.length/2),h="-".repeat(c.length+(a.length+l.length)/2-1);throw new TypeError("Converting circular structure to EJSON:\n "+f+a+c+l+"\n "+p+"\\"+h+"/")}e.seenObjects[e.seenObjects.length-1].obj=t}if(Array.isArray(t))return function(t,e){return t.map((function(t,r){e.seenObjects.push({propertyName:"index "+r,obj:null});try{return i(t,e)}finally{e.seenObjects.pop()}}))}(t,e);if(void 0===t)return null;if(t instanceof Date||Z.isDate(t)){var d=t.getTime(),y=d>-1&&d<2534023188e5;return e.legacy?e.relaxed&&y?{$date:t.getTime()}:{$date:o(t)}:e.relaxed&&y?{$date:o(t)}:{$date:{$numberLong:t.getTime().toString()}}}if("number"==typeof t&&!e.relaxed){if(Math.floor(t)===t){var g=t>=-0x8000000000000000&&t<=0x8000000000000000;if(t>=-2147483648&&t<=2147483647)return{$numberInt:t.toString()};if(g)return{$numberLong:t.toString()}}return{$numberDouble:t.toString()}}if(t instanceof RegExp||Z.isRegExp(t)){var b=t.flags;if(void 0===b){var _=t.toString().match(/[gimuy]*$/);_&&(b=_[0])}return new pt.BSONRegExp(t.source,b).toExtendedJSON(e)}return null!=t&&"object"==typeof t?function(t,e){if(null==t||"object"!=typeof t)throw new Error("not an object instance");var n=t._bsontype;if(void 0===n){var o={};for(var s in t){e.seenObjects.push({propertyName:s,obj:null});try{o[s]=i(t[s],e)}finally{e.seenObjects.pop()}}return o}if(r(t)){var f=t;if("function"!=typeof f.toExtendedJSON){var a=u[t._bsontype];if(!a)throw new TypeError("Unrecognized or invalid _bsontype: "+t._bsontype);f=a(f)}return"Code"===n&&f.scope?f=new nt.Code(f.code,i(f.scope,e)):"DBRef"===n&&f.oid&&(f=new ot.DBRef(f.collection,i(f.oid,e),f.db,f.fields)),f.toExtendedJSON(e)}throw new Error("_bsontype must be a string, but was: "+typeof n)}(t,e):t}var u={Binary:function(t){return new rt.Binary(t.value(),t.sub_type)},Code:function(t){return new nt.Code(t.code,t.scope)},DBRef:function(t){return new ot.DBRef(t.collection||t.namespace,t.oid,t.db,t.fields)},Decimal128:function(t){return new ut.Decimal128(t.bytes)},Double:function(t){return new st.Double(t.value)},Int32:function(t){return new ft.Int32(t.value)},Long:function(t){return it.Long.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 at.MaxKey},MinKey:function(){return new ct.MinKey},ObjectID:function(t){return new lt.ObjectId(t)},ObjectId:function(t){return new lt.ObjectId(t)},BSONRegExp:function(t){return new pt.BSONRegExp(t.pattern,t.options)},Symbol:function(t){return new ht.BSONSymbol(t.value)},Timestamp:function(t){return wt.Timestamp.fromBits(t.low,t.high)}};!function(t){function e(t,e){var r=Object.assign({},{relaxed:!0,legacy:!1},e);return"boolean"==typeof r.relaxed&&(r.strict=!r.relaxed),"boolean"==typeof r.strict&&(r.relaxed=!r.strict),JSON.parse(t,(function(t,e){return function t(e,r){if(void 0===r&&(r={}),"number"==typeof e){if(r.relaxed||r.legacy)return e;if(Math.floor(e)===e){if(e>=-2147483648&&e<=2147483647)return new ft.Int32(e);if(e>=-0x8000000000000000&&e<=0x8000000000000000)return it.Long.fromNumber(e)}return new st.Double(e)}if(null==e||"object"!=typeof e)return e;if(e.$undefined)return null;for(var o=Object.keys(e).filter((function(t){return t.startsWith("$")&&null!=e[t]})),i=0;i<o.length;i++){var u=n[o[i]];if(u)return u.fromExtendedJSON(e,r)}if(null!=e.$date){var s=e.$date,f=new Date;return r.legacy?"number"==typeof s?f.setTime(s):"string"==typeof s&&f.setTime(Date.parse(s)):"string"==typeof s?f.setTime(Date.parse(s)):it.Long.isLong(s)?f.setTime(s.toNumber()):"number"==typeof s&&r.relaxed&&f.setTime(s),f}if(null!=e.$code){var a=Object.assign({},e);return e.$scope&&(a.$scope=t(e.$scope)),nt.Code.fromExtendedJSON(e)}if(null!=e.$ref||null!=e.$dbPointer){var c=e.$ref?e:e.$dbPointer;if(c instanceof ot.DBRef)return c;var l=Object.keys(c).filter((function(t){return t.startsWith("$")})),p=!0;if(l.forEach((function(t){-1===["$ref","$id","$db"].indexOf(t)&&(p=!1)})),p)return ot.DBRef.fromExtendedJSON(c)}return e}(e,r)}))}function r(t,e,r,n){null!=r&&"object"==typeof r&&(n=r,r=0),null==e||"object"!=typeof e||Array.isArray(e)||(n=e,e=void 0,r=0);var o=i(t,Object.assign({relaxed:!0,legacy:!1},n,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,e,r)}t.parse=e,t.stringify=r,t.serialize=function(t,e){return e=e||{},JSON.parse(r(t,e))},t.deserialize=function(t,r){return r=r||{},e(JSON.stringify(t),r)}}(e.EJSON||(e.EJSON={}))}));i(vt),vt.EJSON,vt.isBSONType;var Ot=u((function(t,e){var r;Object.defineProperty(e,"__esModule",{value:!0}),e.Map=void 0,e.Map=r;var n=function(t){return t&&t.Math==Math&&t};var i=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof o&&o)||Function("return this")();Object.prototype.hasOwnProperty.call(i,"Map")?e.Map=r=i.Map:e.Map=r=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 r=t[e],n=r[0],o=r[1];this._keys.push(n),this._values[n]={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 r=t._keys[e++];return{value:void 0!==r?[r,t._values[r].v]:void 0,done:void 0===r}}}},t.prototype.forEach=function(t,e){e=e||this;for(var r=0;r<this._keys.length;r++){var n=this._keys[r];t.call(e,this._values[n].v,n,e)}},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 r=t._keys[e++];return{value:void 0!==r?r:void 0,done:void 0===r}}}},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 r=t._keys[e++];return{value:void 0!==r?t._values[r].v:void 0,done:void 0===r}}}},Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!1,configurable:!0}),t}()}));i(Ot),Ot.Map;var St=u((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.BSON_BINARY_SUBTYPE_USER_DEFINED=e.BSON_BINARY_SUBTYPE_MD5=e.BSON_BINARY_SUBTYPE_UUID_NEW=e.BSON_BINARY_SUBTYPE_UUID=e.BSON_BINARY_SUBTYPE_BYTE_ARRAY=e.BSON_BINARY_SUBTYPE_FUNCTION=e.BSON_BINARY_SUBTYPE_DEFAULT=e.BSON_DATA_MAX_KEY=e.BSON_DATA_MIN_KEY=e.BSON_DATA_DECIMAL128=e.BSON_DATA_LONG=e.BSON_DATA_TIMESTAMP=e.BSON_DATA_INT=e.BSON_DATA_CODE_W_SCOPE=e.BSON_DATA_SYMBOL=e.BSON_DATA_CODE=e.BSON_DATA_DBPOINTER=e.BSON_DATA_REGEXP=e.BSON_DATA_NULL=e.BSON_DATA_DATE=e.BSON_DATA_BOOLEAN=e.BSON_DATA_OID=e.BSON_DATA_UNDEFINED=e.BSON_DATA_BINARY=e.BSON_DATA_ARRAY=e.BSON_DATA_OBJECT=e.BSON_DATA_STRING=e.BSON_DATA_NUMBER=e.JS_INT_MIN=e.JS_INT_MAX=e.BSON_INT64_MIN=e.BSON_INT64_MAX=e.BSON_INT32_MIN=e.BSON_INT32_MAX=void 0,e.BSON_INT32_MAX=2147483647,e.BSON_INT32_MIN=-2147483648,e.BSON_INT64_MAX=Math.pow(2,63)-1,e.BSON_INT64_MIN=-Math.pow(2,63),e.JS_INT_MAX=Math.pow(2,53),e.JS_INT_MIN=-Math.pow(2,53),e.BSON_DATA_NUMBER=1,e.BSON_DATA_STRING=2,e.BSON_DATA_OBJECT=3,e.BSON_DATA_ARRAY=4,e.BSON_DATA_BINARY=5,e.BSON_DATA_UNDEFINED=6,e.BSON_DATA_OID=7,e.BSON_DATA_BOOLEAN=8,e.BSON_DATA_DATE=9,e.BSON_DATA_NULL=10,e.BSON_DATA_REGEXP=11,e.BSON_DATA_DBPOINTER=12,e.BSON_DATA_CODE=13,e.BSON_DATA_SYMBOL=14,e.BSON_DATA_CODE_W_SCOPE=15,e.BSON_DATA_INT=16,e.BSON_DATA_TIMESTAMP=17,e.BSON_DATA_LONG=18,e.BSON_DATA_DECIMAL128=19,e.BSON_DATA_MIN_KEY=255,e.BSON_DATA_MAX_KEY=127,e.BSON_BINARY_SUBTYPE_DEFAULT=0,e.BSON_BINARY_SUBTYPE_FUNCTION=1,e.BSON_BINARY_SUBTYPE_BYTE_ARRAY=2,e.BSON_BINARY_SUBTYPE_UUID=3,e.BSON_BINARY_SUBTYPE_UUID_NEW=4,e.BSON_BINARY_SUBTYPE_MD5=5,e.BSON_BINARY_SUBTYPE_USER_DEFINED=128}));i(St),St.BSON_BINARY_SUBTYPE_USER_DEFINED,St.BSON_BINARY_SUBTYPE_MD5,St.BSON_BINARY_SUBTYPE_UUID_NEW,St.BSON_BINARY_SUBTYPE_UUID,St.BSON_BINARY_SUBTYPE_BYTE_ARRAY,St.BSON_BINARY_SUBTYPE_FUNCTION,St.BSON_BINARY_SUBTYPE_DEFAULT,St.BSON_DATA_MAX_KEY,St.BSON_DATA_MIN_KEY,St.BSON_DATA_DECIMAL128,St.BSON_DATA_LONG,St.BSON_DATA_TIMESTAMP,St.BSON_DATA_INT,St.BSON_DATA_CODE_W_SCOPE,St.BSON_DATA_SYMBOL,St.BSON_DATA_CODE,St.BSON_DATA_DBPOINTER,St.BSON_DATA_REGEXP,St.BSON_DATA_NULL,St.BSON_DATA_DATE,St.BSON_DATA_BOOLEAN,St.BSON_DATA_OID,St.BSON_DATA_UNDEFINED,St.BSON_DATA_BINARY,St.BSON_DATA_ARRAY,St.BSON_DATA_OBJECT,St.BSON_DATA_STRING,St.BSON_DATA_NUMBER,St.JS_INT_MIN,St.JS_INT_MAX,St.BSON_INT64_MIN,St.BSON_INT64_MAX,St.BSON_INT32_MIN,St.BSON_INT32_MAX;var Nt=u((function(t,e){function r(t,e,r){var o=5;if(Array.isArray(t))for(var i=0;i<t.length;i++)o+=n(i.toString(),t[i],e,!0,r);else for(var u in t.toBSON&&(t=t.toBSON()),t)o+=n(u,t[u],e,!1,r);return o}function n(t,e,n,o,i){switch(void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===i&&(i=!1),e&&e.toBSON&&(e=e.toBSON()),typeof e){case"string":return 1+v.Buffer.byteLength(t,"utf8")+1+4+v.Buffer.byteLength(e,"utf8")+1;case"number":return Math.floor(e)===e&&e>=St.JS_INT_MIN&&e<=St.JS_INT_MAX&&e>=St.BSON_INT32_MIN&&e<=St.BSON_INT32_MAX?(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+5:(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+9;case"undefined":return o||!i?(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+1:0;case"boolean":return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+2;case"object":if(null==e||"MinKey"===e._bsontype||"MaxKey"===e._bsontype)return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+1;if("ObjectId"===e._bsontype||"ObjectID"===e._bsontype)return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+13;if(e instanceof Date||Z.isDate(e))return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+9;if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Z.isAnyArrayBuffer(e))return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+6+e.byteLength;if("Long"===e._bsontype||"Double"===e._bsontype||"Timestamp"===e._bsontype)return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+9;if("Decimal128"===e._bsontype)return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+17;if("Code"===e._bsontype)return null!=e.scope&&Object.keys(e.scope).length>0?(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+1+4+4+v.Buffer.byteLength(e.code.toString(),"utf8")+1+r(e.scope,n,i):(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+1+4+v.Buffer.byteLength(e.code.toString(),"utf8")+1;if("Binary"===e._bsontype)return e.sub_type===rt.Binary.SUBTYPE_BYTE_ARRAY?(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+(e.position+1+4+1+4):(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+(e.position+1+4+1);if("Symbol"===e._bsontype)return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+v.Buffer.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?v.Buffer.byteLength(t,"utf8")+1:0)+1+r(u,n,i)}return e instanceof RegExp||Z.isRegExp(e)?(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+1+v.Buffer.byteLength(e.source,"utf8")+1+(e.global?1:0)+(e.ignoreCase?1:0)+(e.multiline?1:0)+1:"BSONRegExp"===e._bsontype?(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+1+v.Buffer.byteLength(e.pattern,"utf8")+1+v.Buffer.byteLength(e.options,"utf8")+1:(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+r(e,n,i)+1;case"function":if(e instanceof RegExp||Z.isRegExp(e)||"[object RegExp]"===String.call(e))return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+1+v.Buffer.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?v.Buffer.byteLength(t,"utf8")+1:0)+1+4+4+v.Buffer.byteLength(Z.normalizedFunctionString(e),"utf8")+1+r(e.scope,n,i);if(n)return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+1+4+v.Buffer.byteLength(Z.normalizedFunctionString(e),"utf8")+1}return 0}Object.defineProperty(e,"__esModule",{value:!0}),e.calculateObjectSize=void 0,e.calculateObjectSize=r}));i(Nt),Nt.calculateObjectSize;var Bt=u((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateUtf8=void 0;e.validateUtf8=function(t,e,r){for(var n=0,o=e;o<r;o+=1){var i=t[o];if(n){if(128!=(192&i))return!1;n-=1}else if(128&i)if(192==(224&i))n=1;else if(224==(240&i))n=2;else{if(240!=(248&i))return!1;n=3}}return!n}}));i(Bt),Bt.validateUtf8;var Et=u((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.deserialize=void 0;var r=it.Long.fromNumber(St.JS_INT_MAX),n=it.Long.fromNumber(St.JS_INT_MIN),o={};function i(t,e,s,f){void 0===f&&(f=!1);var a=null!=s.evalFunctions&&s.evalFunctions,c=null!=s.cacheFunctions&&s.cacheFunctions,l=null==s.fieldsAsRaw?null:s.fieldsAsRaw,p=null!=s.raw&&s.raw,h="boolean"==typeof s.bsonRegExp&&s.bsonRegExp,d=null!=s.promoteBuffers&&s.promoteBuffers,y=null==s.promoteLongs||s.promoteLongs,g=null==s.promoteValues||s.promoteValues,b=e;if(t.length<5)throw new Error("corrupt bson message < 5 bytes long");var _=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;if(_<5||_>t.length)throw new Error("corrupt bson message");for(var m=f?[]:{},w=0;;){var O=t[e++];if(0===O)break;for(var S=e;0!==t[S]&&S<t.length;)S++;if(S>=t.byteLength)throw new Error("Bad BSON Document: illegal CString");var N=f?w++:t.toString("utf8",e,S),B=void 0;if(e=S+1,O===St.BSON_DATA_STRING){if((V=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<=0||V>t.length-e||0!==t[e+V-1])throw new Error("bad string length in bson");if(!Bt.validateUtf8(t,e,e+V-1))throw new Error("Invalid UTF-8 string in BSON document");B=t.toString("utf8",e,e+V-1),e+=V}else if(O===St.BSON_DATA_OID){var E=v.Buffer.alloc(12);t.copy(E,0,e,e+12),B=new lt.ObjectId(E),e+=12}else if(O===St.BSON_DATA_INT&&!1===g)B=new ft.Int32(t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24);else if(O===St.BSON_DATA_INT)B=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;else if(O===St.BSON_DATA_NUMBER&&!1===g)B=new st.Double(t.readDoubleLE(e)),e+=8;else if(O===St.BSON_DATA_NUMBER)B=t.readDoubleLE(e),e+=8;else if(O===St.BSON_DATA_DATE){var A=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,T=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;B=new Date(new it.Long(A,T).toNumber())}else if(O===St.BSON_DATA_BOOLEAN){if(0!==t[e]&&1!==t[e])throw new Error("illegal boolean type value");B=1===t[e++]}else if(O===St.BSON_DATA_OBJECT){var I=e;if((G=t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)<=0||G>t.length-e)throw new Error("bad embedded document length in bson");B=p?t.slice(e,e+G):i(t,I,s,!1),e+=G}else if(O===St.BSON_DATA_ARRAY){I=e;var D=s,x=e+(G=t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24);if(l&&l[N]){for(var R in D={},s)D[R]=s[R];D.raw=!0}if(B=i(t,I,D,!0),0!==t[(e+=G)-1])throw new Error("invalid array terminator byte");if(e!==x)throw new Error("corrupted array bson")}else if(O===St.BSON_DATA_UNDEFINED)B=void 0;else if(O===St.BSON_DATA_NULL)B=null;else if(O===St.BSON_DATA_LONG){A=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,T=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;var P=new it.Long(A,T);B=y&&!0===g&&P.lessThanOrEqual(r)&&P.greaterThanOrEqual(n)?P.toNumber():P}else if(O===St.BSON_DATA_DECIMAL128){var U=v.Buffer.alloc(16);t.copy(U,0,e,e+16),e+=16;var L=new ut.Decimal128(U);B="toObject"in L&&"function"==typeof L.toObject?L.toObject():L}else if(O===St.BSON_DATA_BINARY){var j=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,M=j,C=t[e++];if(j<0)throw new Error("Negative binary type element size found");if(j>t.byteLength)throw new Error("Binary type size larger than document size");if(null!=t.slice){if(C===rt.Binary.SUBTYPE_BYTE_ARRAY){if((j=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<0)throw new Error("Negative binary type element size found for subtype 0x02");if(j>M-4)throw new Error("Binary type with subtype 0x02 contains too long binary size");if(j<M-4)throw new Error("Binary type with subtype 0x02 contains too short binary size")}B=d&&g?t.slice(e,e+j):new rt.Binary(t.slice(e,e+j),C)}else{var Y=v.Buffer.alloc(j);if(C===rt.Binary.SUBTYPE_BYTE_ARRAY){if((j=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<0)throw new Error("Negative binary type element size found for subtype 0x02");if(j>M-4)throw new Error("Binary type with subtype 0x02 contains too long binary size");if(j<M-4)throw new Error("Binary type with subtype 0x02 contains too short binary size")}for(S=0;S<j;S++)Y[S]=t[e+S];B=d&&g?Y:new rt.Binary(Y,C)}e+=j}else if(O===St.BSON_DATA_REGEXP&&!1===h){for(S=e;0!==t[S]&&S<t.length;)S++;if(S>=t.length)throw new Error("Bad BSON Document: illegal CString");var $=t.toString("utf8",e,S);for(S=e=S+1;0!==t[S]&&S<t.length;)S++;if(S>=t.length)throw new Error("Bad BSON Document: illegal CString");var q=t.toString("utf8",e,S);e=S+1;var F=new Array(q.length);for(S=0;S<q.length;S++)switch(q[S]){case"m":F[S]="m";break;case"s":F[S]="g";break;case"i":F[S]="i"}B=new RegExp($,F.join(""))}else if(O===St.BSON_DATA_REGEXP&&!0===h){for(S=e;0!==t[S]&&S<t.length;)S++;if(S>=t.length)throw new Error("Bad BSON Document: illegal CString");$=t.toString("utf8",e,S);for(S=e=S+1;0!==t[S]&&S<t.length;)S++;if(S>=t.length)throw new Error("Bad BSON Document: illegal CString");q=t.toString("utf8",e,S);e=S+1,B=new pt.BSONRegExp($,q)}else if(O===St.BSON_DATA_SYMBOL){if((V=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<=0||V>t.length-e||0!==t[e+V-1])throw new Error("bad string length in bson");var k=t.toString("utf8",e,e+V-1);B=g?k:new ht.BSONSymbol(k),e+=V}else if(O===St.BSON_DATA_TIMESTAMP){A=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,T=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;B=new wt.Timestamp(A,T)}else if(O===St.BSON_DATA_MIN_KEY)B=new ct.MinKey;else if(O===St.BSON_DATA_MAX_KEY)B=new at.MaxKey;else if(O===St.BSON_DATA_CODE){if((V=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<=0||V>t.length-e||0!==t[e+V-1])throw new Error("bad string length in bson");var z=t.toString("utf8",e,e+V-1);B=a?c?u(z,o,m):u(z):new nt.Code(z),e+=V}else if(O===St.BSON_DATA_CODE_W_SCOPE){var J=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;if(J<13)throw new Error("code_w_scope total size shorter minimum expected length");if((V=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<=0||V>t.length-e||0!==t[e+V-1])throw new Error("bad string length in bson");z=t.toString("utf8",e,e+V-1),I=e+=V;var G=t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24,H=i(t,I,s,!1);if(e+=G,J<8+G+V)throw new Error("code_w_scope total size is too short, truncating scope");if(J>8+G+V)throw new Error("code_w_scope total size is too long, clips outer document");a?(B=c?u(z,o,m):u(z)).scope=H:B=new nt.Code(z,H)}else{if(O!==St.BSON_DATA_DBPOINTER)throw new Error("Detected unknown BSON type "+O.toString(16)+' for fieldname "'+N+'"');var V;if((V=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<=0||V>t.length-e||0!==t[e+V-1])throw new Error("bad string length in bson");if(!Bt.validateUtf8(t,e,e+V-1))throw new Error("Invalid UTF-8 string in BSON document");var K=t.toString("utf8",e,e+V-1);e+=V;var W=v.Buffer.alloc(12);t.copy(W,0,e,e+12);E=new lt.ObjectId(W);e+=12,B=new ot.DBRef(K,E)}"__proto__"===N?Object.defineProperty(m,N,{value:B,writable:!0,enumerable:!0,configurable:!0}):m[N]=B}if(_!==e-b){if(f)throw new Error("corrupt array bson");throw new Error("corrupt object bson")}var X=Object.keys(m).filter((function(t){return t.startsWith("$")})),Z=!0;if(X.forEach((function(t){-1===["$ref","$id","$db"].indexOf(t)&&(Z=!1)})),!Z)return m;if(ot.isDBRefLike(m)){var Q=Object.assign({},m);return delete Q.$ref,delete Q.$id,delete Q.$db,new ot.DBRef(m.$ref,m.$id,m.$db,Q)}return m}function u(t,e,r){return e?(null==e[t]&&(e[t]=new Function(t)),e[t].bind(r)):new Function(t)}e.deserialize=function(t,e,r){var n=(e=null==e?{}:e)&&e.index?e.index:0,o=t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24;if(o<5)throw new Error("bson size must be >= 5, is "+o);if(e.allowObjectSmallerThanBufferSize&&t.length<o)throw new Error("buffer length "+t.length+" must be >= bson size "+o);if(!e.allowObjectSmallerThanBufferSize&&t.length!==o)throw new Error("buffer length "+t.length+" must === bson size "+o);if(o+n>t.byteLength)throw new Error("(bson size "+o+" + options.index "+n+" must be <= buffer length "+t.byteLength+")");if(0!==t[n+o-1])throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return i(t,n,e,r)}}));i(Et),Et.deserialize;var At=u((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.writeIEEE754=e.readIEEE754=void 0,e.readIEEE754=function(t,e,r,n,o){var i,u,s="big"===r,f=8*o-n-1,a=(1<<f)-1,c=a>>1,l=-7,p=s?0:o-1,h=s?1:-1,d=t[e+p];for(p+=h,i=d&(1<<-l)-1,d>>=-l,l+=f;l>0;i=256*i+t[e+p],p+=h,l-=8);for(u=i&(1<<-l)-1,i>>=-l,l+=n;l>0;u=256*u+t[e+p],p+=h,l-=8);if(0===i)i=1-c;else{if(i===a)return u?NaN:1/0*(d?-1:1);u+=Math.pow(2,n),i-=c}return(d?-1:1)*u*Math.pow(2,i-n)},e.writeIEEE754=function(t,e,r,n,o,i){var u,s,f,a="big"===n,c=8*i-o-1,l=(1<<c)-1,p=l>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=a?i-1:0,y=a?-1:1,g=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=l):(u=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-u))<1&&(u--,f*=2),(e+=u+p>=1?h/f:h*Math.pow(2,1-p))*f>=2&&(u++,f/=2),u+p>=l?(s=0,u=l):u+p>=1?(s=(e*f-1)*Math.pow(2,o),u+=p):(s=e*Math.pow(2,p-1)*Math.pow(2,o),u=0)),isNaN(e)&&(s=0);o>=8;)t[r+d]=255&s,d+=y,s/=256,o-=8;for(u=u<<o|s,isNaN(e)&&(u+=8),c+=o;c>0;)t[r+d]=255&u,d+=y,u/=256,c-=8;t[r+d-y]|=128*g}}));i(At),At.writeIEEE754,At.readIEEE754;var Tt=u((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.serializeInto=void 0;var r=/\x00/,n=new Set(["$db","$ref","$id","$clusterTime"]);function o(t,e,r,n,o){t[n++]=St.BSON_DATA_STRING;var i=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8");t[(n=n+i+1)-1]=0;var u=t.write(r,n+4,void 0,"utf8");return t[n+3]=u+1>>24&255,t[n+2]=u+1>>16&255,t[n+1]=u+1>>8&255,t[n]=u+1&255,n=n+4+u,t[n++]=0,n}function i(t,e,r,n,o){Number.isInteger(r)&&r>=St.BSON_INT32_MIN&&r<=St.BSON_INT32_MAX?(t[n++]=St.BSON_DATA_INT,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,t[n++]=255&r,t[n++]=r>>8&255,t[n++]=r>>16&255,t[n++]=r>>24&255):(t[n++]=St.BSON_DATA_NUMBER,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,At.writeIEEE754(t,r,n,"little",52,8),n+=8);return n}function u(t,e,r,n,o){return t[n++]=St.BSON_DATA_NULL,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,n}function s(t,e,r,n,o){return t[n++]=St.BSON_DATA_BOOLEAN,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,t[n++]=r?1:0,n}function f(t,e,r,n,o){t[n++]=St.BSON_DATA_DATE,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var i=it.Long.fromNumber(r.getTime()),u=i.getLowBits(),s=i.getHighBits();return t[n++]=255&u,t[n++]=u>>8&255,t[n++]=u>>16&255,t[n++]=u>>24&255,t[n++]=255&s,t[n++]=s>>8&255,t[n++]=s>>16&255,t[n++]=s>>24&255,n}function a(t,e,n,o,i){if(t[o++]=St.BSON_DATA_REGEXP,o+=i?t.write(e,o,void 0,"ascii"):t.write(e,o,void 0,"utf8"),t[o++]=0,n.source&&null!=n.source.match(r))throw Error("value "+n.source+" must not contain null bytes");return o+=t.write(n.source,o,void 0,"utf8"),t[o++]=0,n.ignoreCase&&(t[o++]=105),n.global&&(t[o++]=115),n.multiline&&(t[o++]=109),t[o++]=0,o}function c(t,e,n,o,i){if(t[o++]=St.BSON_DATA_REGEXP,o+=i?t.write(e,o,void 0,"ascii"):t.write(e,o,void 0,"utf8"),t[o++]=0,null!=n.pattern.match(r))throw Error("pattern "+n.pattern+" must not contain null bytes");return o+=t.write(n.pattern,o,void 0,"utf8"),t[o++]=0,o+=t.write(n.options.split("").sort().join(""),o,void 0,"utf8"),t[o++]=0,o}function l(t,e,r,n,o){return null===r?t[n++]=St.BSON_DATA_NULL:"MinKey"===r._bsontype?t[n++]=St.BSON_DATA_MIN_KEY:t[n++]=St.BSON_DATA_MAX_KEY,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,n}function p(t,e,r,n,o){if(t[n++]=St.BSON_DATA_OID,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,"string"==typeof r.id)t.write(r.id,n,void 0,"binary");else{if(!r.id||!r.id.copy)throw new TypeError("object ["+JSON.stringify(r)+"] is not a valid ObjectId");r.id.copy(t,n,0,12)}return n+12}function h(t,e,r,n,o){t[n++]=St.BSON_DATA_BINARY,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var i=r.length;return t[n++]=255&i,t[n++]=i>>8&255,t[n++]=i>>16&255,t[n++]=i>>24&255,t[n++]=St.BSON_BINARY_SUBTYPE_DEFAULT,t.set(Q.ensureBuffer(r),n),n+=i}function d(t,e,r,n,o,i,u,s,f,a){void 0===o&&(o=!1),void 0===i&&(i=0),void 0===u&&(u=!1),void 0===s&&(s=!0),void 0===f&&(f=!1),void 0===a&&(a=[]);for(var c=0;c<a.length;c++)if(a[c]===r)throw new Error("cyclic dependency detected");a.push(r),t[n++]=Array.isArray(r)?St.BSON_DATA_ARRAY:St.BSON_DATA_OBJECT,n+=f?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var l=N(t,r,o,n,i+1,u,s,a);return a.pop(),l}function y(t,e,r,n,o){return t[n++]=St.BSON_DATA_DECIMAL128,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,r.bytes.copy(t,n,0,16),n+16}function g(t,e,r,n,o){t[n++]="Long"===r._bsontype?St.BSON_DATA_LONG:St.BSON_DATA_TIMESTAMP,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var i=r.getLowBits(),u=r.getHighBits();return t[n++]=255&i,t[n++]=i>>8&255,t[n++]=i>>16&255,t[n++]=i>>24&255,t[n++]=255&u,t[n++]=u>>8&255,t[n++]=u>>16&255,t[n++]=u>>24&255,n}function b(t,e,r,n,o){return r=r.valueOf(),t[n++]=St.BSON_DATA_INT,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,t[n++]=255&r,t[n++]=r>>8&255,t[n++]=r>>16&255,t[n++]=r>>24&255,n}function _(t,e,r,n,o){return t[n++]=St.BSON_DATA_NUMBER,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,At.writeIEEE754(t,r.value,n,"little",52,8),n+=8}function m(t,e,r,n,o,i,u){t[n++]=St.BSON_DATA_CODE,n+=u?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var s=Z.normalizedFunctionString(r),f=t.write(s,n+4,void 0,"utf8")+1;return t[n]=255&f,t[n+1]=f>>8&255,t[n+2]=f>>16&255,t[n+3]=f>>24&255,n=n+4+f-1,t[n++]=0,n}function w(t,e,r,n,o,i,u,s,f){if(void 0===o&&(o=!1),void 0===i&&(i=0),void 0===u&&(u=!1),void 0===s&&(s=!0),void 0===f&&(f=!1),r.scope&&"object"==typeof r.scope){t[n++]=St.BSON_DATA_CODE_W_SCOPE,n+=f?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var a=n,c="string"==typeof r.code?r.code:r.code.toString();n+=4;var l=t.write(c,n+4,void 0,"utf8")+1;t[n]=255&l,t[n+1]=l>>8&255,t[n+2]=l>>16&255,t[n+3]=l>>24&255,t[n+4+l-1]=0,n=n+l+4;var p=N(t,r.scope,o,n,i+1,u,s);n=p-1;var h=p-a;t[a++]=255&h,t[a++]=h>>8&255,t[a++]=h>>16&255,t[a++]=h>>24&255,t[n++]=0}else{t[n++]=St.BSON_DATA_CODE,n+=f?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;c=r.code.toString();var d=t.write(c,n+4,void 0,"utf8")+1;t[n]=255&d,t[n+1]=d>>8&255,t[n+2]=d>>16&255,t[n+3]=d>>24&255,n=n+4+d-1,t[n++]=0}return n}function v(t,e,r,n,o){t[n++]=St.BSON_DATA_BINARY,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var i=r.value(!0),u=r.position;return r.sub_type===rt.Binary.SUBTYPE_BYTE_ARRAY&&(u+=4),t[n++]=255&u,t[n++]=u>>8&255,t[n++]=u>>16&255,t[n++]=u>>24&255,t[n++]=r.sub_type,r.sub_type===rt.Binary.SUBTYPE_BYTE_ARRAY&&(u-=4,t[n++]=255&u,t[n++]=u>>8&255,t[n++]=u>>16&255,t[n++]=u>>24&255),t.set(i,n),n+=r.position}function O(t,e,r,n,o){t[n++]=St.BSON_DATA_SYMBOL,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var i=t.write(r.value,n+4,void 0,"utf8")+1;return t[n]=255&i,t[n+1]=i>>8&255,t[n+2]=i>>16&255,t[n+3]=i>>24&255,n=n+4+i-1,t[n++]=0,n}function S(t,e,r,n,o,i,u){t[n++]=St.BSON_DATA_OBJECT,n+=u?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var s=n,f={$ref:r.collection||r.namespace,$id:r.oid};null!=r.db&&(f.$db=r.db);var a=N(t,f=Object.assign(f,r.fields),!1,n,o+1,i),c=a-s;return t[s++]=255&c,t[s++]=c>>8&255,t[s++]=c>>16&255,t[s++]=c>>24&255,a}function N(t,e,N,B,E,A,T,I){void 0===N&&(N=!1),void 0===B&&(B=0),void 0===E&&(E=0),void 0===A&&(A=!1),void 0===T&&(T=!0),void 0===I&&(I=[]),B=B||0,(I=I||[]).push(e);var D=B+4;if(Array.isArray(e))for(var x=0;x<e.length;x++){var R=""+x;if((M=e[x])&&M.toBSON){if("function"!=typeof M.toBSON)throw new TypeError("toBSON is not a function");M=M.toBSON()}if("string"==typeof M)D=o(t,R,M,D,!0);else if("number"==typeof M)D=i(t,R,M,D,!0);else{if("bigint"==typeof M)throw new TypeError("Unsupported type BigInt, please use Decimal128");if("boolean"==typeof M)D=s(t,R,M,D,!0);else if(M instanceof Date||Z.isDate(M))D=f(t,R,M,D,!0);else if(void 0===M)D=u(t,R,0,D,!0);else if(null===M)D=u(t,R,0,D,!0);else if("ObjectId"===M._bsontype||"ObjectID"===M._bsontype)D=p(t,R,M,D,!0);else if(Z.isUint8Array(M))D=h(t,R,M,D,!0);else if(M instanceof RegExp||Z.isRegExp(M))D=a(t,R,M,D,!0);else if("object"==typeof M&&null==M._bsontype)D=d(t,R,M,D,N,E,A,T,!0,I);else if("object"==typeof M&&vt.isBSONType(M)&&"Decimal128"===M._bsontype)D=y(t,R,M,D,!0);else if("Long"===M._bsontype||"Timestamp"===M._bsontype)D=g(t,R,M,D,!0);else if("Double"===M._bsontype)D=_(t,R,M,D,!0);else if("function"==typeof M&&A)D=m(t,R,M,D,0,0,!0);else if("Code"===M._bsontype)D=w(t,R,M,D,N,E,A,T,!0);else if("Binary"===M._bsontype)D=v(t,R,M,D,!0);else if("Symbol"===M._bsontype)D=O(t,R,M,D,!0);else if("DBRef"===M._bsontype)D=S(t,R,M,D,E,A,!0);else if("BSONRegExp"===M._bsontype)D=c(t,R,M,D,!0);else if("Int32"===M._bsontype)D=b(t,R,M,D,!0);else if("MinKey"===M._bsontype||"MaxKey"===M._bsontype)D=l(t,R,M,D,!0);else if(void 0!==M._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+M._bsontype)}}else if(e instanceof Ot.Map||Z.isMap(e))for(var P=e.entries(),U=!1;!U;){var L=P.next();if(!(U=!!L.done)){R=L.value[0];var j=typeof(M=L.value[1]);if("string"==typeof R&&!n.has(R)){if(null!=R.match(r))throw Error("key "+R+" must not contain null bytes");if(N){if("$"===R[0])throw Error("key "+R+" must not start with '$'");if(~R.indexOf("."))throw Error("key "+R+" must not contain '.'")}}if("string"===j)D=o(t,R,M,D);else if("number"===j)D=i(t,R,M,D);else{if("bigint"===j||Z.isBigInt64Array(M)||Z.isBigUInt64Array(M))throw new TypeError("Unsupported type BigInt, please use Decimal128");if("boolean"===j)D=s(t,R,M,D);else if(M instanceof Date||Z.isDate(M))D=f(t,R,M,D);else if(null===M||void 0===M&&!1===T)D=u(t,R,0,D);else if("ObjectId"===M._bsontype||"ObjectID"===M._bsontype)D=p(t,R,M,D);else if(Z.isUint8Array(M))D=h(t,R,M,D);else if(M instanceof RegExp||Z.isRegExp(M))D=a(t,R,M,D);else if("object"===j&&null==M._bsontype)D=d(t,R,M,D,N,E,A,T,!1,I);else if("object"===j&&"Decimal128"===M._bsontype)D=y(t,R,M,D);else if("Long"===M._bsontype||"Timestamp"===M._bsontype)D=g(t,R,M,D);else if("Double"===M._bsontype)D=_(t,R,M,D);else if("Code"===M._bsontype)D=w(t,R,M,D,N,E,A,T);else if("function"==typeof M&&A)D=m(t,R,M,D,0,0,A);else if("Binary"===M._bsontype)D=v(t,R,M,D);else if("Symbol"===M._bsontype)D=O(t,R,M,D);else if("DBRef"===M._bsontype)D=S(t,R,M,D,E,A);else if("BSONRegExp"===M._bsontype)D=c(t,R,M,D);else if("Int32"===M._bsontype)D=b(t,R,M,D);else if("MinKey"===M._bsontype||"MaxKey"===M._bsontype)D=l(t,R,M,D);else if(void 0!==M._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+M._bsontype)}}}else{if(e.toBSON){if("function"!=typeof e.toBSON)throw new TypeError("toBSON is not a function");if(null!=(e=e.toBSON())&&"object"!=typeof e)throw new TypeError("toBSON function did not return an object")}for(var R in e){var M;if((M=e[R])&&M.toBSON){if("function"!=typeof M.toBSON)throw new TypeError("toBSON is not a function");M=M.toBSON()}j=typeof M;if("string"==typeof R&&!n.has(R)){if(null!=R.match(r))throw Error("key "+R+" must not contain null bytes");if(N){if("$"===R[0])throw Error("key "+R+" must not start with '$'");if(~R.indexOf("."))throw Error("key "+R+" must not contain '.'")}}if("string"===j)D=o(t,R,M,D);else if("number"===j)D=i(t,R,M,D);else{if("bigint"===j)throw new TypeError("Unsupported type BigInt, please use Decimal128");if("boolean"===j)D=s(t,R,M,D);else if(M instanceof Date||Z.isDate(M))D=f(t,R,M,D);else if(void 0===M)!1===T&&(D=u(t,R,0,D));else if(null===M)D=u(t,R,0,D);else if("ObjectId"===M._bsontype||"ObjectID"===M._bsontype)D=p(t,R,M,D);else if(Z.isUint8Array(M))D=h(t,R,M,D);else if(M instanceof RegExp||Z.isRegExp(M))D=a(t,R,M,D);else if("object"===j&&null==M._bsontype)D=d(t,R,M,D,N,E,A,T,!1,I);else if("object"===j&&"Decimal128"===M._bsontype)D=y(t,R,M,D);else if("Long"===M._bsontype||"Timestamp"===M._bsontype)D=g(t,R,M,D);else if("Double"===M._bsontype)D=_(t,R,M,D);else if("Code"===M._bsontype)D=w(t,R,M,D,N,E,A,T);else if("function"==typeof M&&A)D=m(t,R,M,D,0,0,A);else if("Binary"===M._bsontype)D=v(t,R,M,D);else if("Symbol"===M._bsontype)D=O(t,R,M,D);else if("DBRef"===M._bsontype)D=S(t,R,M,D,E,A);else if("BSONRegExp"===M._bsontype)D=c(t,R,M,D);else if("Int32"===M._bsontype)D=b(t,R,M,D);else if("MinKey"===M._bsontype||"MaxKey"===M._bsontype)D=l(t,R,M,D);else if(void 0!==M._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+M._bsontype)}}}I.pop(),t[D++]=0;var C=D-B;return t[B++]=255&C,t[B++]=C>>8&255,t[B++]=C>>16&255,t[B++]=C>>24&255,D}e.serializeInto=N}));i(Tt),Tt.serializeInto;var It=u((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.ObjectID=e.Decimal128=e.BSONRegExp=e.MaxKey=e.MinKey=e.Int32=e.Double=e.Timestamp=e.Long=e.UUID=e.ObjectId=e.Binary=e.DBRef=e.BSONSymbol=e.Map=e.Code=e.LongWithoutOverridesClass=e.EJSON=e.BSON_INT64_MIN=e.BSON_INT64_MAX=e.BSON_INT32_MIN=e.BSON_INT32_MAX=e.BSON_DATA_UNDEFINED=e.BSON_DATA_TIMESTAMP=e.BSON_DATA_SYMBOL=e.BSON_DATA_STRING=e.BSON_DATA_REGEXP=e.BSON_DATA_OID=e.BSON_DATA_OBJECT=e.BSON_DATA_NUMBER=e.BSON_DATA_NULL=e.BSON_DATA_MIN_KEY=e.BSON_DATA_MAX_KEY=e.BSON_DATA_LONG=e.BSON_DATA_INT=e.BSON_DATA_DECIMAL128=e.BSON_DATA_DBPOINTER=e.BSON_DATA_DATE=e.BSON_DATA_CODE_W_SCOPE=e.BSON_DATA_CODE=e.BSON_DATA_BOOLEAN=e.BSON_DATA_BINARY=e.BSON_DATA_ARRAY=e.BSON_BINARY_SUBTYPE_UUID_NEW=e.BSON_BINARY_SUBTYPE_UUID=e.BSON_BINARY_SUBTYPE_USER_DEFINED=e.BSON_BINARY_SUBTYPE_MD5=e.BSON_BINARY_SUBTYPE_FUNCTION=e.BSON_BINARY_SUBTYPE_DEFAULT=e.BSON_BINARY_SUBTYPE_BYTE_ARRAY=void 0,e.deserializeStream=e.calculateObjectSize=e.deserialize=e.serializeWithBufferAndIndex=e.serialize=e.setInternalBufferSize=void 0,Object.defineProperty(e,"Binary",{enumerable:!0,get:function(){return rt.Binary}}),Object.defineProperty(e,"Code",{enumerable:!0,get:function(){return nt.Code}}),Object.defineProperty(e,"DBRef",{enumerable:!0,get:function(){return ot.DBRef}}),Object.defineProperty(e,"Decimal128",{enumerable:!0,get:function(){return ut.Decimal128}}),Object.defineProperty(e,"Double",{enumerable:!0,get:function(){return st.Double}}),Object.defineProperty(e,"Int32",{enumerable:!0,get:function(){return ft.Int32}}),Object.defineProperty(e,"Long",{enumerable:!0,get:function(){return it.Long}}),Object.defineProperty(e,"Map",{enumerable:!0,get:function(){return Ot.Map}}),Object.defineProperty(e,"MaxKey",{enumerable:!0,get:function(){return at.MaxKey}}),Object.defineProperty(e,"MinKey",{enumerable:!0,get:function(){return ct.MinKey}}),Object.defineProperty(e,"ObjectId",{enumerable:!0,get:function(){return lt.ObjectId}}),Object.defineProperty(e,"ObjectID",{enumerable:!0,get:function(){return lt.ObjectId}}),Object.defineProperty(e,"BSONRegExp",{enumerable:!0,get:function(){return pt.BSONRegExp}}),Object.defineProperty(e,"BSONSymbol",{enumerable:!0,get:function(){return ht.BSONSymbol}}),Object.defineProperty(e,"Timestamp",{enumerable:!0,get:function(){return wt.Timestamp}}),Object.defineProperty(e,"UUID",{enumerable:!0,get:function(){return et.UUID}}),Object.defineProperty(e,"BSON_BINARY_SUBTYPE_BYTE_ARRAY",{enumerable:!0,get:function(){return St.BSON_BINARY_SUBTYPE_BYTE_ARRAY}}),Object.defineProperty(e,"BSON_BINARY_SUBTYPE_DEFAULT",{enumerable:!0,get:function(){return St.BSON_BINARY_SUBTYPE_DEFAULT}}),Object.defineProperty(e,"BSON_BINARY_SUBTYPE_FUNCTION",{enumerable:!0,get:function(){return St.BSON_BINARY_SUBTYPE_FUNCTION}}),Object.defineProperty(e,"BSON_BINARY_SUBTYPE_MD5",{enumerable:!0,get:function(){return St.BSON_BINARY_SUBTYPE_MD5}}),Object.defineProperty(e,"BSON_BINARY_SUBTYPE_USER_DEFINED",{enumerable:!0,get:function(){return St.BSON_BINARY_SUBTYPE_USER_DEFINED}}),Object.defineProperty(e,"BSON_BINARY_SUBTYPE_UUID",{enumerable:!0,get:function(){return St.BSON_BINARY_SUBTYPE_UUID}}),Object.defineProperty(e,"BSON_BINARY_SUBTYPE_UUID_NEW",{enumerable:!0,get:function(){return St.BSON_BINARY_SUBTYPE_UUID_NEW}}),Object.defineProperty(e,"BSON_DATA_ARRAY",{enumerable:!0,get:function(){return St.BSON_DATA_ARRAY}}),Object.defineProperty(e,"BSON_DATA_BINARY",{enumerable:!0,get:function(){return St.BSON_DATA_BINARY}}),Object.defineProperty(e,"BSON_DATA_BOOLEAN",{enumerable:!0,get:function(){return St.BSON_DATA_BOOLEAN}}),Object.defineProperty(e,"BSON_DATA_CODE",{enumerable:!0,get:function(){return St.BSON_DATA_CODE}}),Object.defineProperty(e,"BSON_DATA_CODE_W_SCOPE",{enumerable:!0,get:function(){return St.BSON_DATA_CODE_W_SCOPE}}),Object.defineProperty(e,"BSON_DATA_DATE",{enumerable:!0,get:function(){return St.BSON_DATA_DATE}}),Object.defineProperty(e,"BSON_DATA_DBPOINTER",{enumerable:!0,get:function(){return St.BSON_DATA_DBPOINTER}}),Object.defineProperty(e,"BSON_DATA_DECIMAL128",{enumerable:!0,get:function(){return St.BSON_DATA_DECIMAL128}}),Object.defineProperty(e,"BSON_DATA_INT",{enumerable:!0,get:function(){return St.BSON_DATA_INT}}),Object.defineProperty(e,"BSON_DATA_LONG",{enumerable:!0,get:function(){return St.BSON_DATA_LONG}}),Object.defineProperty(e,"BSON_DATA_MAX_KEY",{enumerable:!0,get:function(){return St.BSON_DATA_MAX_KEY}}),Object.defineProperty(e,"BSON_DATA_MIN_KEY",{enumerable:!0,get:function(){return St.BSON_DATA_MIN_KEY}}),Object.defineProperty(e,"BSON_DATA_NULL",{enumerable:!0,get:function(){return St.BSON_DATA_NULL}}),Object.defineProperty(e,"BSON_DATA_NUMBER",{enumerable:!0,get:function(){return St.BSON_DATA_NUMBER}}),Object.defineProperty(e,"BSON_DATA_OBJECT",{enumerable:!0,get:function(){return St.BSON_DATA_OBJECT}}),Object.defineProperty(e,"BSON_DATA_OID",{enumerable:!0,get:function(){return St.BSON_DATA_OID}}),Object.defineProperty(e,"BSON_DATA_REGEXP",{enumerable:!0,get:function(){return St.BSON_DATA_REGEXP}}),Object.defineProperty(e,"BSON_DATA_STRING",{enumerable:!0,get:function(){return St.BSON_DATA_STRING}}),Object.defineProperty(e,"BSON_DATA_SYMBOL",{enumerable:!0,get:function(){return St.BSON_DATA_SYMBOL}}),Object.defineProperty(e,"BSON_DATA_TIMESTAMP",{enumerable:!0,get:function(){return St.BSON_DATA_TIMESTAMP}}),Object.defineProperty(e,"BSON_DATA_UNDEFINED",{enumerable:!0,get:function(){return St.BSON_DATA_UNDEFINED}}),Object.defineProperty(e,"BSON_INT32_MAX",{enumerable:!0,get:function(){return St.BSON_INT32_MAX}}),Object.defineProperty(e,"BSON_INT32_MIN",{enumerable:!0,get:function(){return St.BSON_INT32_MIN}}),Object.defineProperty(e,"BSON_INT64_MAX",{enumerable:!0,get:function(){return St.BSON_INT64_MAX}}),Object.defineProperty(e,"BSON_INT64_MIN",{enumerable:!0,get:function(){return St.BSON_INT64_MIN}});var r=vt;Object.defineProperty(e,"EJSON",{enumerable:!0,get:function(){return r.EJSON}});var n=wt;Object.defineProperty(e,"LongWithoutOverridesClass",{enumerable:!0,get:function(){return n.LongWithoutOverridesClass}});var o=v.Buffer.alloc(17825792);function i(t){o.length<t&&(o=v.Buffer.alloc(t))}function u(t,e){void 0===e&&(e={});var r="boolean"==typeof e.checkKeys&&e.checkKeys,n="boolean"==typeof e.serializeFunctions&&e.serializeFunctions,i="boolean"!=typeof e.ignoreUndefined||e.ignoreUndefined,u="number"==typeof e.minInternalBufferSize?e.minInternalBufferSize:17825792;o.length<u&&(o=v.Buffer.alloc(u));var s=Tt.serializeInto(o,t,r,0,0,n,i,[]),f=v.Buffer.alloc(s);return o.copy(f,0,0,f.length),f}function s(t,e,r){void 0===r&&(r={});var n="boolean"==typeof r.checkKeys&&r.checkKeys,i="boolean"==typeof r.serializeFunctions&&r.serializeFunctions,u="boolean"!=typeof r.ignoreUndefined||r.ignoreUndefined,s="number"==typeof r.index?r.index:0,f=Tt.serializeInto(o,t,n,0,0,i,u);return o.copy(e,s,0,f),s+f-1}function f(t,e){return void 0===e&&(e={}),Et.deserialize(Q.ensureBuffer(t),e)}function a(t,e){void 0===e&&(e={});var r="boolean"==typeof(e=e||{}).serializeFunctions&&e.serializeFunctions,n="boolean"!=typeof e.ignoreUndefined||e.ignoreUndefined;return Nt.calculateObjectSize(t,r,n)}function c(t,e,r,n,o,i){for(var u=Object.assign({allowObjectSmallerThanBufferSize:!0,index:0},i),s=Q.ensureBuffer(t),f=e,a=0;a<r;a++){var c=s[f]|s[f+1]<<8|s[f+2]<<16|s[f+3]<<24;u.index=f,n[o+a]=Et.deserialize(s,u),f+=c}return f}e.setInternalBufferSize=i,e.serialize=u,e.serializeWithBufferAndIndex=s,e.deserialize=f,e.calculateObjectSize=a,e.deserializeStream=c;var l={Binary:rt.Binary,Code:nt.Code,DBRef:ot.DBRef,Decimal128:ut.Decimal128,Double:st.Double,Int32:ft.Int32,Long:it.Long,UUID:et.UUID,Map:Ot.Map,MaxKey:at.MaxKey,MinKey:ct.MinKey,ObjectId:lt.ObjectId,ObjectID:lt.ObjectId,BSONRegExp:pt.BSONRegExp,BSONSymbol:ht.BSONSymbol,Timestamp:wt.Timestamp,EJSON:vt.EJSON,setInternalBufferSize:i,serialize:u,serializeWithBufferAndIndex:s,deserialize:f,calculateObjectSize:a,deserializeStream:c};e.default=l})),Dt=(i(It),It.ObjectID,It.Decimal128,It.BSONRegExp,It.MaxKey,It.MinKey,It.Int32,It.Double,It.Timestamp,It.Long,It.UUID,It.ObjectId,It.Binary,It.DBRef,It.BSONSymbol,It.Map,It.Code,It.LongWithoutOverridesClass,It.EJSON);It.BSON_INT64_MIN,It.BSON_INT64_MAX,It.BSON_INT32_MIN,It.BSON_INT32_MAX,It.BSON_DATA_UNDEFINED,It.BSON_DATA_TIMESTAMP,It.BSON_DATA_SYMBOL,It.BSON_DATA_STRING,It.BSON_DATA_REGEXP,It.BSON_DATA_OID,It.BSON_DATA_OBJECT,It.BSON_DATA_NUMBER,It.BSON_DATA_NULL,It.BSON_DATA_MIN_KEY,It.BSON_DATA_MAX_KEY,It.BSON_DATA_LONG,It.BSON_DATA_INT,It.BSON_DATA_DECIMAL128,It.BSON_DATA_DBPOINTER,It.BSON_DATA_DATE,It.BSON_DATA_CODE_W_SCOPE,It.BSON_DATA_CODE,It.BSON_DATA_BOOLEAN,It.BSON_DATA_BINARY,It.BSON_DATA_ARRAY,It.BSON_BINARY_SUBTYPE_UUID_NEW,It.BSON_BINARY_SUBTYPE_UUID,It.BSON_BINARY_SUBTYPE_USER_DEFINED,It.BSON_BINARY_SUBTYPE_MD5,It.BSON_BINARY_SUBTYPE_FUNCTION,It.BSON_BINARY_SUBTYPE_DEFAULT,It.BSON_BINARY_SUBTYPE_BYTE_ARRAY,It.deserializeStream,It.calculateObjectSize,It.deserialize,It.serializeWithBufferAndIndex,It.serialize,It.setInternalBufferSize}).call(this,r(1),r(3).Buffer)},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.registerDatabase=void 0;var o=r(7);var i={name:"database",entity:{database:function(t){var e=this.platform,r=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=r.wsClass,o.Db.wsClientClass=this.wsClientClass),o.Db.ws||(o.Db.ws=null),new o.Db(n(n({},this.config),t))}}};try{cloudbase.registerComponent(i)}catch(t){}e.registerDatabase=function(t){try{t.registerComponent(i)}catch(t){console.warn(t)}}},function(t,e,r){"use strict";(function(t){
17
+ var dt=function(t,e){return(dt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};var yt=function(){return(yt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function gt(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function bt(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}function _t(t){return this instanceof _t?(this.v=t,this):new _t(t)}var mt=Object.freeze({__proto__:null,__extends:function(t,e){function r(){this.constructor=t}dt(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)},get __assign(){return yt},__rest:function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r},__decorate:function(t,e,r,n){var o,i=arguments.length,u=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"===("undefined"==typeof Reflect?"undefined":babelHelpers.typeof(Reflect))&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,r,n);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(u=(i<3?o(u):i>3?o(e,r,u):o(e,r))||u);return i>3&&u&&Object.defineProperty(e,r,u),u},__param:function(t,e){return function(r,n){e(r,n,t)}},__metadata:function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":babelHelpers.typeof(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},__awaiter:function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function u(t){try{f(n.next(t))}catch(t){i(t)}}function s(t){try{f(n.throw(t))}catch(t){i(t)}}function f(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,s)}f((n=n.apply(t,e||[])).next())}))},__generator:function(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=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++,n=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.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],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},__createBinding:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]},__exportStar:function(t,e){for(var r in t)"default"===r||e.hasOwnProperty(r)||(e[r]=t[r])},__values:gt,__read:bt,__spread:function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(bt(arguments[e]));return t},__spreadArrays:function(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;var n=Array(t),o=0;for(e=0;e<r;e++)for(var i=arguments[e],u=0,s=i.length;u<s;u++,o++)n[o]=i[u];return n},__await:_t,__asyncGenerator:function(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(t,e||[]),i=[];return n={},u("next"),u("throw"),u("return"),n[Symbol.asyncIterator]=function(){return this},n;function u(t){o[t]&&(n[t]=function(e){return new Promise((function(r,n){i.push([t,e,r,n])>1||s(t,e)}))})}function s(t,e){try{(r=o[t](e)).value instanceof _t?Promise.resolve(r.value.v).then(f,a):c(i[0][2],r)}catch(t){c(i[0][3],t)}var r}function f(t){s("next",t)}function a(t){s("throw",t)}function c(t,e){t(e),i.shift(),i.length&&s(i[0][0],i[0][1])}},__asyncDelegator:function(t){var e,r;return e={},n("next"),n("throw",(function(t){throw t})),n("return"),e[Symbol.iterator]=function(){return this},e;function n(n,o){e[n]=t[n]?function(e){return(r=!r)?{value:_t(t[n](e)),done:"return"===n}:o?o(e):e}:o}},__asyncValues:function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=gt(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,o){(function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)})(n,o,(e=t[r](e)).done,e.value)}))}}},__makeTemplateObject:function(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t},__importStar:function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e},__importDefault:function(t){return t&&t.__esModule?t:{default:t}},__classPrivateFieldGet:function(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)},__classPrivateFieldSet:function(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}}),wt=u((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Timestamp=e.LongWithoutOverridesClass=void 0,e.LongWithoutOverridesClass=it.Long;var r=function(t){function e(r,n){var o=this;return o instanceof e?(o=it.Long.isLong(r)?t.call(this,r.low,r.high,!0)||this:t.call(this,r,n,!0)||this,Object.defineProperty(o,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1}),o):new e(r,n)}return mt.__extends(e,t),e.prototype.toJSON=function(){return{$timestamp:this.toString()}},e.fromInt=function(t){return new e(it.Long.fromInt(t,!0))},e.fromNumber=function(t){return new e(it.Long.fromNumber(t,!0))},e.fromBits=function(t,r){return new e(t,r)},e.fromString=function(t,r){return new e(it.Long.fromString(t,!0,r))},e.prototype.toExtendedJSON=function(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}},e.fromExtendedJSON=function(t){return new e(t.$timestamp.i,t.$timestamp.t)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new Timestamp("+this.getLowBits().toString()+", "+this.getHighBits().toString()+")"},e.MAX_VALUE=it.Long.MAX_UNSIGNED_VALUE,e}(e.LongWithoutOverridesClass);e.Timestamp=r}));i(wt),wt.Timestamp,wt.LongWithoutOverridesClass;var vt=u((function(t,e){function r(t){return Z.isObjectLike(t)&&Reflect.has(t,"_bsontype")&&"string"==typeof t._bsontype}Object.defineProperty(e,"__esModule",{value:!0}),e.EJSON=e.isBSONType=void 0,e.isBSONType=r;var n={$oid:lt.ObjectId,$binary:rt.Binary,$uuid:rt.Binary,$symbol:ht.BSONSymbol,$numberInt:ft.Int32,$numberDecimal:ut.Decimal128,$numberDouble:st.Double,$numberLong:it.Long,$minKey:ct.MinKey,$maxKey:at.MaxKey,$regex:pt.BSONRegExp,$regularExpression:pt.BSONRegExp,$timestamp:wt.Timestamp};function o(t){var e=t.toISOString();return 0!==t.getUTCMilliseconds()?e:e.slice(0,-5)+"Z"}function i(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 s=e.seenObjects.map((function(t){return t.propertyName})),f=s.slice(0,n).map((function(t){return t+" -> "})).join(""),a=s[n],c=" -> "+s.slice(n+1,s.length-1).map((function(t){return t+" -> "})).join(""),l=s[s.length-1],p=" ".repeat(f.length+a.length/2),h="-".repeat(c.length+(a.length+l.length)/2-1);throw new TypeError("Converting circular structure to EJSON:\n "+f+a+c+l+"\n "+p+"\\"+h+"/")}e.seenObjects[e.seenObjects.length-1].obj=t}if(Array.isArray(t))return function(t,e){return t.map((function(t,r){e.seenObjects.push({propertyName:"index "+r,obj:null});try{return i(t,e)}finally{e.seenObjects.pop()}}))}(t,e);if(void 0===t)return null;if(t instanceof Date||Z.isDate(t)){var d=t.getTime(),y=d>-1&&d<2534023188e5;return e.legacy?e.relaxed&&y?{$date:t.getTime()}:{$date:o(t)}:e.relaxed&&y?{$date:o(t)}:{$date:{$numberLong:t.getTime().toString()}}}if("number"==typeof t&&!e.relaxed){if(Math.floor(t)===t){var g=t>=-0x8000000000000000&&t<=0x8000000000000000;if(t>=-2147483648&&t<=2147483647)return{$numberInt:t.toString()};if(g)return{$numberLong:t.toString()}}return{$numberDouble:t.toString()}}if(t instanceof RegExp||Z.isRegExp(t)){var b=t.flags;if(void 0===b){var _=t.toString().match(/[gimuy]*$/);_&&(b=_[0])}return new pt.BSONRegExp(t.source,b).toExtendedJSON(e)}return null!=t&&"object"==typeof t?function(t,e){if(null==t||"object"!=typeof t)throw new Error("not an object instance");var n=t._bsontype;if(void 0===n){var o={};for(var s in t){e.seenObjects.push({propertyName:s,obj:null});try{o[s]=i(t[s],e)}finally{e.seenObjects.pop()}}return o}if(r(t)){var f=t;if("function"!=typeof f.toExtendedJSON){var a=u[t._bsontype];if(!a)throw new TypeError("Unrecognized or invalid _bsontype: "+t._bsontype);f=a(f)}return"Code"===n&&f.scope?f=new nt.Code(f.code,i(f.scope,e)):"DBRef"===n&&f.oid&&(f=new ot.DBRef(f.collection,i(f.oid,e),f.db,f.fields)),f.toExtendedJSON(e)}throw new Error("_bsontype must be a string, but was: "+typeof n)}(t,e):t}var u={Binary:function(t){return new rt.Binary(t.value(),t.sub_type)},Code:function(t){return new nt.Code(t.code,t.scope)},DBRef:function(t){return new ot.DBRef(t.collection||t.namespace,t.oid,t.db,t.fields)},Decimal128:function(t){return new ut.Decimal128(t.bytes)},Double:function(t){return new st.Double(t.value)},Int32:function(t){return new ft.Int32(t.value)},Long:function(t){return it.Long.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 at.MaxKey},MinKey:function(){return new ct.MinKey},ObjectID:function(t){return new lt.ObjectId(t)},ObjectId:function(t){return new lt.ObjectId(t)},BSONRegExp:function(t){return new pt.BSONRegExp(t.pattern,t.options)},Symbol:function(t){return new ht.BSONSymbol(t.value)},Timestamp:function(t){return wt.Timestamp.fromBits(t.low,t.high)}};!function(t){function e(t,e){var r=Object.assign({},{relaxed:!0,legacy:!1},e);return"boolean"==typeof r.relaxed&&(r.strict=!r.relaxed),"boolean"==typeof r.strict&&(r.relaxed=!r.strict),JSON.parse(t,(function(t,e){return function t(e,r){if(void 0===r&&(r={}),"number"==typeof e){if(r.relaxed||r.legacy)return e;if(Math.floor(e)===e){if(e>=-2147483648&&e<=2147483647)return new ft.Int32(e);if(e>=-0x8000000000000000&&e<=0x8000000000000000)return it.Long.fromNumber(e)}return new st.Double(e)}if(null==e||"object"!=typeof e)return e;if(e.$undefined)return null;for(var o=Object.keys(e).filter((function(t){return t.startsWith("$")&&null!=e[t]})),i=0;i<o.length;i++){var u=n[o[i]];if(u)return u.fromExtendedJSON(e,r)}if(null!=e.$date){var s=e.$date,f=new Date;return r.legacy?"number"==typeof s?f.setTime(s):"string"==typeof s&&f.setTime(Date.parse(s)):"string"==typeof s?f.setTime(Date.parse(s)):it.Long.isLong(s)?f.setTime(s.toNumber()):"number"==typeof s&&r.relaxed&&f.setTime(s),f}if(null!=e.$code){var a=Object.assign({},e);return e.$scope&&(a.$scope=t(e.$scope)),nt.Code.fromExtendedJSON(e)}if(null!=e.$ref||null!=e.$dbPointer){var c=e.$ref?e:e.$dbPointer;if(c instanceof ot.DBRef)return c;var l=Object.keys(c).filter((function(t){return t.startsWith("$")})),p=!0;if(l.forEach((function(t){-1===["$ref","$id","$db"].indexOf(t)&&(p=!1)})),p)return ot.DBRef.fromExtendedJSON(c)}return e}(e,r)}))}function r(t,e,r,n){null!=r&&"object"==typeof r&&(n=r,r=0),null==e||"object"!=typeof e||Array.isArray(e)||(n=e,e=void 0,r=0);var o=i(t,Object.assign({relaxed:!0,legacy:!1},n,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,e,r)}t.parse=e,t.stringify=r,t.serialize=function(t,e){return e=e||{},JSON.parse(r(t,e))},t.deserialize=function(t,r){return r=r||{},e(JSON.stringify(t),r)}}(e.EJSON||(e.EJSON={}))}));i(vt),vt.EJSON,vt.isBSONType;var Ot=u((function(t,e){var r;Object.defineProperty(e,"__esModule",{value:!0}),e.Map=void 0,e.Map=r;var n=function(t){return t&&t.Math==Math&&t};var i=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof o&&o)||Function("return this")();Object.prototype.hasOwnProperty.call(i,"Map")?e.Map=r=i.Map:e.Map=r=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 r=t[e],n=r[0],o=r[1];this._keys.push(n),this._values[n]={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 r=t._keys[e++];return{value:void 0!==r?[r,t._values[r].v]:void 0,done:void 0===r}}}},t.prototype.forEach=function(t,e){e=e||this;for(var r=0;r<this._keys.length;r++){var n=this._keys[r];t.call(e,this._values[n].v,n,e)}},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 r=t._keys[e++];return{value:void 0!==r?r:void 0,done:void 0===r}}}},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 r=t._keys[e++];return{value:void 0!==r?t._values[r].v:void 0,done:void 0===r}}}},Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!1,configurable:!0}),t}()}));i(Ot),Ot.Map;var St=u((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.BSON_BINARY_SUBTYPE_USER_DEFINED=e.BSON_BINARY_SUBTYPE_MD5=e.BSON_BINARY_SUBTYPE_UUID_NEW=e.BSON_BINARY_SUBTYPE_UUID=e.BSON_BINARY_SUBTYPE_BYTE_ARRAY=e.BSON_BINARY_SUBTYPE_FUNCTION=e.BSON_BINARY_SUBTYPE_DEFAULT=e.BSON_DATA_MAX_KEY=e.BSON_DATA_MIN_KEY=e.BSON_DATA_DECIMAL128=e.BSON_DATA_LONG=e.BSON_DATA_TIMESTAMP=e.BSON_DATA_INT=e.BSON_DATA_CODE_W_SCOPE=e.BSON_DATA_SYMBOL=e.BSON_DATA_CODE=e.BSON_DATA_DBPOINTER=e.BSON_DATA_REGEXP=e.BSON_DATA_NULL=e.BSON_DATA_DATE=e.BSON_DATA_BOOLEAN=e.BSON_DATA_OID=e.BSON_DATA_UNDEFINED=e.BSON_DATA_BINARY=e.BSON_DATA_ARRAY=e.BSON_DATA_OBJECT=e.BSON_DATA_STRING=e.BSON_DATA_NUMBER=e.JS_INT_MIN=e.JS_INT_MAX=e.BSON_INT64_MIN=e.BSON_INT64_MAX=e.BSON_INT32_MIN=e.BSON_INT32_MAX=void 0,e.BSON_INT32_MAX=2147483647,e.BSON_INT32_MIN=-2147483648,e.BSON_INT64_MAX=Math.pow(2,63)-1,e.BSON_INT64_MIN=-Math.pow(2,63),e.JS_INT_MAX=Math.pow(2,53),e.JS_INT_MIN=-Math.pow(2,53),e.BSON_DATA_NUMBER=1,e.BSON_DATA_STRING=2,e.BSON_DATA_OBJECT=3,e.BSON_DATA_ARRAY=4,e.BSON_DATA_BINARY=5,e.BSON_DATA_UNDEFINED=6,e.BSON_DATA_OID=7,e.BSON_DATA_BOOLEAN=8,e.BSON_DATA_DATE=9,e.BSON_DATA_NULL=10,e.BSON_DATA_REGEXP=11,e.BSON_DATA_DBPOINTER=12,e.BSON_DATA_CODE=13,e.BSON_DATA_SYMBOL=14,e.BSON_DATA_CODE_W_SCOPE=15,e.BSON_DATA_INT=16,e.BSON_DATA_TIMESTAMP=17,e.BSON_DATA_LONG=18,e.BSON_DATA_DECIMAL128=19,e.BSON_DATA_MIN_KEY=255,e.BSON_DATA_MAX_KEY=127,e.BSON_BINARY_SUBTYPE_DEFAULT=0,e.BSON_BINARY_SUBTYPE_FUNCTION=1,e.BSON_BINARY_SUBTYPE_BYTE_ARRAY=2,e.BSON_BINARY_SUBTYPE_UUID=3,e.BSON_BINARY_SUBTYPE_UUID_NEW=4,e.BSON_BINARY_SUBTYPE_MD5=5,e.BSON_BINARY_SUBTYPE_USER_DEFINED=128}));i(St),St.BSON_BINARY_SUBTYPE_USER_DEFINED,St.BSON_BINARY_SUBTYPE_MD5,St.BSON_BINARY_SUBTYPE_UUID_NEW,St.BSON_BINARY_SUBTYPE_UUID,St.BSON_BINARY_SUBTYPE_BYTE_ARRAY,St.BSON_BINARY_SUBTYPE_FUNCTION,St.BSON_BINARY_SUBTYPE_DEFAULT,St.BSON_DATA_MAX_KEY,St.BSON_DATA_MIN_KEY,St.BSON_DATA_DECIMAL128,St.BSON_DATA_LONG,St.BSON_DATA_TIMESTAMP,St.BSON_DATA_INT,St.BSON_DATA_CODE_W_SCOPE,St.BSON_DATA_SYMBOL,St.BSON_DATA_CODE,St.BSON_DATA_DBPOINTER,St.BSON_DATA_REGEXP,St.BSON_DATA_NULL,St.BSON_DATA_DATE,St.BSON_DATA_BOOLEAN,St.BSON_DATA_OID,St.BSON_DATA_UNDEFINED,St.BSON_DATA_BINARY,St.BSON_DATA_ARRAY,St.BSON_DATA_OBJECT,St.BSON_DATA_STRING,St.BSON_DATA_NUMBER,St.JS_INT_MIN,St.JS_INT_MAX,St.BSON_INT64_MIN,St.BSON_INT64_MAX,St.BSON_INT32_MIN,St.BSON_INT32_MAX;var Nt=u((function(t,e){function r(t,e,r){var o=5;if(Array.isArray(t))for(var i=0;i<t.length;i++)o+=n(i.toString(),t[i],e,!0,r);else for(var u in t.toBSON&&(t=t.toBSON()),t)o+=n(u,t[u],e,!1,r);return o}function n(t,e,n,o,i){switch(void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===i&&(i=!1),e&&e.toBSON&&(e=e.toBSON()),typeof e){case"string":return 1+v.Buffer.byteLength(t,"utf8")+1+4+v.Buffer.byteLength(e,"utf8")+1;case"number":return Math.floor(e)===e&&e>=St.JS_INT_MIN&&e<=St.JS_INT_MAX&&e>=St.BSON_INT32_MIN&&e<=St.BSON_INT32_MAX?(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+5:(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+9;case"undefined":return o||!i?(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+1:0;case"boolean":return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+2;case"object":if(null==e||"MinKey"===e._bsontype||"MaxKey"===e._bsontype)return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+1;if("ObjectId"===e._bsontype||"ObjectID"===e._bsontype)return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+13;if(e instanceof Date||Z.isDate(e))return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+9;if(ArrayBuffer.isView(e)||e instanceof ArrayBuffer||Z.isAnyArrayBuffer(e))return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+6+e.byteLength;if("Long"===e._bsontype||"Double"===e._bsontype||"Timestamp"===e._bsontype)return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+9;if("Decimal128"===e._bsontype)return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+17;if("Code"===e._bsontype)return null!=e.scope&&Object.keys(e.scope).length>0?(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+1+4+4+v.Buffer.byteLength(e.code.toString(),"utf8")+1+r(e.scope,n,i):(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+1+4+v.Buffer.byteLength(e.code.toString(),"utf8")+1;if("Binary"===e._bsontype)return e.sub_type===rt.Binary.SUBTYPE_BYTE_ARRAY?(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+(e.position+1+4+1+4):(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+(e.position+1+4+1);if("Symbol"===e._bsontype)return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+v.Buffer.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?v.Buffer.byteLength(t,"utf8")+1:0)+1+r(u,n,i)}return e instanceof RegExp||Z.isRegExp(e)?(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+1+v.Buffer.byteLength(e.source,"utf8")+1+(e.global?1:0)+(e.ignoreCase?1:0)+(e.multiline?1:0)+1:"BSONRegExp"===e._bsontype?(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+1+v.Buffer.byteLength(e.pattern,"utf8")+1+v.Buffer.byteLength(e.options,"utf8")+1:(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+r(e,n,i)+1;case"function":if(e instanceof RegExp||Z.isRegExp(e)||"[object RegExp]"===String.call(e))return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+1+v.Buffer.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?v.Buffer.byteLength(t,"utf8")+1:0)+1+4+4+v.Buffer.byteLength(Z.normalizedFunctionString(e),"utf8")+1+r(e.scope,n,i);if(n)return(null!=t?v.Buffer.byteLength(t,"utf8")+1:0)+1+4+v.Buffer.byteLength(Z.normalizedFunctionString(e),"utf8")+1}return 0}Object.defineProperty(e,"__esModule",{value:!0}),e.calculateObjectSize=void 0,e.calculateObjectSize=r}));i(Nt),Nt.calculateObjectSize;var Bt=u((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateUtf8=void 0;e.validateUtf8=function(t,e,r){for(var n=0,o=e;o<r;o+=1){var i=t[o];if(n){if(128!=(192&i))return!1;n-=1}else if(128&i)if(192==(224&i))n=1;else if(224==(240&i))n=2;else{if(240!=(248&i))return!1;n=3}}return!n}}));i(Bt),Bt.validateUtf8;var Et=u((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.deserialize=void 0;var r=it.Long.fromNumber(St.JS_INT_MAX),n=it.Long.fromNumber(St.JS_INT_MIN),o={};function i(t,e,s,f){void 0===f&&(f=!1);var a=null!=s.evalFunctions&&s.evalFunctions,c=null!=s.cacheFunctions&&s.cacheFunctions,l=null==s.fieldsAsRaw?null:s.fieldsAsRaw,p=null!=s.raw&&s.raw,h="boolean"==typeof s.bsonRegExp&&s.bsonRegExp,d=null!=s.promoteBuffers&&s.promoteBuffers,y=null==s.promoteLongs||s.promoteLongs,g=null==s.promoteValues||s.promoteValues,b=e;if(t.length<5)throw new Error("corrupt bson message < 5 bytes long");var _=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;if(_<5||_>t.length)throw new Error("corrupt bson message");for(var m=f?[]:{},w=0;;){var O=t[e++];if(0===O)break;for(var S=e;0!==t[S]&&S<t.length;)S++;if(S>=t.byteLength)throw new Error("Bad BSON Document: illegal CString");var N=f?w++:t.toString("utf8",e,S),B=void 0;if(e=S+1,O===St.BSON_DATA_STRING){if((V=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<=0||V>t.length-e||0!==t[e+V-1])throw new Error("bad string length in bson");if(!Bt.validateUtf8(t,e,e+V-1))throw new Error("Invalid UTF-8 string in BSON document");B=t.toString("utf8",e,e+V-1),e+=V}else if(O===St.BSON_DATA_OID){var E=v.Buffer.alloc(12);t.copy(E,0,e,e+12),B=new lt.ObjectId(E),e+=12}else if(O===St.BSON_DATA_INT&&!1===g)B=new ft.Int32(t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24);else if(O===St.BSON_DATA_INT)B=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;else if(O===St.BSON_DATA_NUMBER&&!1===g)B=new st.Double(t.readDoubleLE(e)),e+=8;else if(O===St.BSON_DATA_NUMBER)B=t.readDoubleLE(e),e+=8;else if(O===St.BSON_DATA_DATE){var A=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,T=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;B=new Date(new it.Long(A,T).toNumber())}else if(O===St.BSON_DATA_BOOLEAN){if(0!==t[e]&&1!==t[e])throw new Error("illegal boolean type value");B=1===t[e++]}else if(O===St.BSON_DATA_OBJECT){var I=e;if((G=t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)<=0||G>t.length-e)throw new Error("bad embedded document length in bson");B=p?t.slice(e,e+G):i(t,I,s,!1),e+=G}else if(O===St.BSON_DATA_ARRAY){I=e;var D=s,x=e+(G=t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24);if(l&&l[N]){for(var R in D={},s)D[R]=s[R];D.raw=!0}if(B=i(t,I,D,!0),0!==t[(e+=G)-1])throw new Error("invalid array terminator byte");if(e!==x)throw new Error("corrupted array bson")}else if(O===St.BSON_DATA_UNDEFINED)B=void 0;else if(O===St.BSON_DATA_NULL)B=null;else if(O===St.BSON_DATA_LONG){A=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,T=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;var P=new it.Long(A,T);B=y&&!0===g&&P.lessThanOrEqual(r)&&P.greaterThanOrEqual(n)?P.toNumber():P}else if(O===St.BSON_DATA_DECIMAL128){var U=v.Buffer.alloc(16);t.copy(U,0,e,e+16),e+=16;var L=new ut.Decimal128(U);B="toObject"in L&&"function"==typeof L.toObject?L.toObject():L}else if(O===St.BSON_DATA_BINARY){var j=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,M=j,C=t[e++];if(j<0)throw new Error("Negative binary type element size found");if(j>t.byteLength)throw new Error("Binary type size larger than document size");if(null!=t.slice){if(C===rt.Binary.SUBTYPE_BYTE_ARRAY){if((j=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<0)throw new Error("Negative binary type element size found for subtype 0x02");if(j>M-4)throw new Error("Binary type with subtype 0x02 contains too long binary size");if(j<M-4)throw new Error("Binary type with subtype 0x02 contains too short binary size")}B=d&&g?t.slice(e,e+j):new rt.Binary(t.slice(e,e+j),C)}else{var Y=v.Buffer.alloc(j);if(C===rt.Binary.SUBTYPE_BYTE_ARRAY){if((j=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<0)throw new Error("Negative binary type element size found for subtype 0x02");if(j>M-4)throw new Error("Binary type with subtype 0x02 contains too long binary size");if(j<M-4)throw new Error("Binary type with subtype 0x02 contains too short binary size")}for(S=0;S<j;S++)Y[S]=t[e+S];B=d&&g?Y:new rt.Binary(Y,C)}e+=j}else if(O===St.BSON_DATA_REGEXP&&!1===h){for(S=e;0!==t[S]&&S<t.length;)S++;if(S>=t.length)throw new Error("Bad BSON Document: illegal CString");var $=t.toString("utf8",e,S);for(S=e=S+1;0!==t[S]&&S<t.length;)S++;if(S>=t.length)throw new Error("Bad BSON Document: illegal CString");var q=t.toString("utf8",e,S);e=S+1;var F=new Array(q.length);for(S=0;S<q.length;S++)switch(q[S]){case"m":F[S]="m";break;case"s":F[S]="g";break;case"i":F[S]="i"}B=new RegExp($,F.join(""))}else if(O===St.BSON_DATA_REGEXP&&!0===h){for(S=e;0!==t[S]&&S<t.length;)S++;if(S>=t.length)throw new Error("Bad BSON Document: illegal CString");$=t.toString("utf8",e,S);for(S=e=S+1;0!==t[S]&&S<t.length;)S++;if(S>=t.length)throw new Error("Bad BSON Document: illegal CString");q=t.toString("utf8",e,S);e=S+1,B=new pt.BSONRegExp($,q)}else if(O===St.BSON_DATA_SYMBOL){if((V=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<=0||V>t.length-e||0!==t[e+V-1])throw new Error("bad string length in bson");var k=t.toString("utf8",e,e+V-1);B=g?k:new ht.BSONSymbol(k),e+=V}else if(O===St.BSON_DATA_TIMESTAMP){A=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24,T=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;B=new wt.Timestamp(A,T)}else if(O===St.BSON_DATA_MIN_KEY)B=new ct.MinKey;else if(O===St.BSON_DATA_MAX_KEY)B=new at.MaxKey;else if(O===St.BSON_DATA_CODE){if((V=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<=0||V>t.length-e||0!==t[e+V-1])throw new Error("bad string length in bson");var z=t.toString("utf8",e,e+V-1);B=a?c?u(z,o,m):u(z):new nt.Code(z),e+=V}else if(O===St.BSON_DATA_CODE_W_SCOPE){var J=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24;if(J<13)throw new Error("code_w_scope total size shorter minimum expected length");if((V=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<=0||V>t.length-e||0!==t[e+V-1])throw new Error("bad string length in bson");z=t.toString("utf8",e,e+V-1),I=e+=V;var G=t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24,H=i(t,I,s,!1);if(e+=G,J<8+G+V)throw new Error("code_w_scope total size is too short, truncating scope");if(J>8+G+V)throw new Error("code_w_scope total size is too long, clips outer document");a?(B=c?u(z,o,m):u(z)).scope=H:B=new nt.Code(z,H)}else{if(O!==St.BSON_DATA_DBPOINTER)throw new Error("Detected unknown BSON type "+O.toString(16)+' for fieldname "'+N+'"');var V;if((V=t[e++]|t[e++]<<8|t[e++]<<16|t[e++]<<24)<=0||V>t.length-e||0!==t[e+V-1])throw new Error("bad string length in bson");if(!Bt.validateUtf8(t,e,e+V-1))throw new Error("Invalid UTF-8 string in BSON document");var K=t.toString("utf8",e,e+V-1);e+=V;var W=v.Buffer.alloc(12);t.copy(W,0,e,e+12);E=new lt.ObjectId(W);e+=12,B=new ot.DBRef(K,E)}"__proto__"===N?Object.defineProperty(m,N,{value:B,writable:!0,enumerable:!0,configurable:!0}):m[N]=B}if(_!==e-b){if(f)throw new Error("corrupt array bson");throw new Error("corrupt object bson")}var X=Object.keys(m).filter((function(t){return t.startsWith("$")})),Z=!0;if(X.forEach((function(t){-1===["$ref","$id","$db"].indexOf(t)&&(Z=!1)})),!Z)return m;if(ot.isDBRefLike(m)){var Q=Object.assign({},m);return delete Q.$ref,delete Q.$id,delete Q.$db,new ot.DBRef(m.$ref,m.$id,m.$db,Q)}return m}function u(t,e,r){return e?(null==e[t]&&(e[t]=new Function(t)),e[t].bind(r)):new Function(t)}e.deserialize=function(t,e,r){var n=(e=null==e?{}:e)&&e.index?e.index:0,o=t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24;if(o<5)throw new Error("bson size must be >= 5, is "+o);if(e.allowObjectSmallerThanBufferSize&&t.length<o)throw new Error("buffer length "+t.length+" must be >= bson size "+o);if(!e.allowObjectSmallerThanBufferSize&&t.length!==o)throw new Error("buffer length "+t.length+" must === bson size "+o);if(o+n>t.byteLength)throw new Error("(bson size "+o+" + options.index "+n+" must be <= buffer length "+t.byteLength+")");if(0!==t[n+o-1])throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return i(t,n,e,r)}}));i(Et),Et.deserialize;var At=u((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.writeIEEE754=e.readIEEE754=void 0,e.readIEEE754=function(t,e,r,n,o){var i,u,s="big"===r,f=8*o-n-1,a=(1<<f)-1,c=a>>1,l=-7,p=s?0:o-1,h=s?1:-1,d=t[e+p];for(p+=h,i=d&(1<<-l)-1,d>>=-l,l+=f;l>0;i=256*i+t[e+p],p+=h,l-=8);for(u=i&(1<<-l)-1,i>>=-l,l+=n;l>0;u=256*u+t[e+p],p+=h,l-=8);if(0===i)i=1-c;else{if(i===a)return u?NaN:1/0*(d?-1:1);u+=Math.pow(2,n),i-=c}return(d?-1:1)*u*Math.pow(2,i-n)},e.writeIEEE754=function(t,e,r,n,o,i){var u,s,f,a="big"===n,c=8*i-o-1,l=(1<<c)-1,p=l>>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=a?i-1:0,y=a?-1:1,g=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=l):(u=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-u))<1&&(u--,f*=2),(e+=u+p>=1?h/f:h*Math.pow(2,1-p))*f>=2&&(u++,f/=2),u+p>=l?(s=0,u=l):u+p>=1?(s=(e*f-1)*Math.pow(2,o),u+=p):(s=e*Math.pow(2,p-1)*Math.pow(2,o),u=0)),isNaN(e)&&(s=0);o>=8;)t[r+d]=255&s,d+=y,s/=256,o-=8;for(u=u<<o|s,isNaN(e)&&(u+=8),c+=o;c>0;)t[r+d]=255&u,d+=y,u/=256,c-=8;t[r+d-y]|=128*g}}));i(At),At.writeIEEE754,At.readIEEE754;var Tt=u((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.serializeInto=void 0;var r=/\x00/,n=new Set(["$db","$ref","$id","$clusterTime"]);function o(t,e,r,n,o){t[n++]=St.BSON_DATA_STRING;var i=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8");t[(n=n+i+1)-1]=0;var u=t.write(r,n+4,void 0,"utf8");return t[n+3]=u+1>>24&255,t[n+2]=u+1>>16&255,t[n+1]=u+1>>8&255,t[n]=u+1&255,n=n+4+u,t[n++]=0,n}function i(t,e,r,n,o){Number.isInteger(r)&&r>=St.BSON_INT32_MIN&&r<=St.BSON_INT32_MAX?(t[n++]=St.BSON_DATA_INT,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,t[n++]=255&r,t[n++]=r>>8&255,t[n++]=r>>16&255,t[n++]=r>>24&255):(t[n++]=St.BSON_DATA_NUMBER,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,At.writeIEEE754(t,r,n,"little",52,8),n+=8);return n}function u(t,e,r,n,o){return t[n++]=St.BSON_DATA_NULL,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,n}function s(t,e,r,n,o){return t[n++]=St.BSON_DATA_BOOLEAN,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,t[n++]=r?1:0,n}function f(t,e,r,n,o){t[n++]=St.BSON_DATA_DATE,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var i=it.Long.fromNumber(r.getTime()),u=i.getLowBits(),s=i.getHighBits();return t[n++]=255&u,t[n++]=u>>8&255,t[n++]=u>>16&255,t[n++]=u>>24&255,t[n++]=255&s,t[n++]=s>>8&255,t[n++]=s>>16&255,t[n++]=s>>24&255,n}function a(t,e,n,o,i){if(t[o++]=St.BSON_DATA_REGEXP,o+=i?t.write(e,o,void 0,"ascii"):t.write(e,o,void 0,"utf8"),t[o++]=0,n.source&&null!=n.source.match(r))throw Error("value "+n.source+" must not contain null bytes");return o+=t.write(n.source,o,void 0,"utf8"),t[o++]=0,n.ignoreCase&&(t[o++]=105),n.global&&(t[o++]=115),n.multiline&&(t[o++]=109),t[o++]=0,o}function c(t,e,n,o,i){if(t[o++]=St.BSON_DATA_REGEXP,o+=i?t.write(e,o,void 0,"ascii"):t.write(e,o,void 0,"utf8"),t[o++]=0,null!=n.pattern.match(r))throw Error("pattern "+n.pattern+" must not contain null bytes");return o+=t.write(n.pattern,o,void 0,"utf8"),t[o++]=0,o+=t.write(n.options.split("").sort().join(""),o,void 0,"utf8"),t[o++]=0,o}function l(t,e,r,n,o){return null===r?t[n++]=St.BSON_DATA_NULL:"MinKey"===r._bsontype?t[n++]=St.BSON_DATA_MIN_KEY:t[n++]=St.BSON_DATA_MAX_KEY,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,n}function p(t,e,r,n,o){if(t[n++]=St.BSON_DATA_OID,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,"string"==typeof r.id)t.write(r.id,n,void 0,"binary");else{if(!r.id||!r.id.copy)throw new TypeError("object ["+JSON.stringify(r)+"] is not a valid ObjectId");r.id.copy(t,n,0,12)}return n+12}function h(t,e,r,n,o){t[n++]=St.BSON_DATA_BINARY,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var i=r.length;return t[n++]=255&i,t[n++]=i>>8&255,t[n++]=i>>16&255,t[n++]=i>>24&255,t[n++]=St.BSON_BINARY_SUBTYPE_DEFAULT,t.set(Q.ensureBuffer(r),n),n+=i}function d(t,e,r,n,o,i,u,s,f,a){void 0===o&&(o=!1),void 0===i&&(i=0),void 0===u&&(u=!1),void 0===s&&(s=!0),void 0===f&&(f=!1),void 0===a&&(a=[]);for(var c=0;c<a.length;c++)if(a[c]===r)throw new Error("cyclic dependency detected");a.push(r),t[n++]=Array.isArray(r)?St.BSON_DATA_ARRAY:St.BSON_DATA_OBJECT,n+=f?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var l=N(t,r,o,n,i+1,u,s,a);return a.pop(),l}function y(t,e,r,n,o){return t[n++]=St.BSON_DATA_DECIMAL128,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,r.bytes.copy(t,n,0,16),n+16}function g(t,e,r,n,o){t[n++]="Long"===r._bsontype?St.BSON_DATA_LONG:St.BSON_DATA_TIMESTAMP,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var i=r.getLowBits(),u=r.getHighBits();return t[n++]=255&i,t[n++]=i>>8&255,t[n++]=i>>16&255,t[n++]=i>>24&255,t[n++]=255&u,t[n++]=u>>8&255,t[n++]=u>>16&255,t[n++]=u>>24&255,n}function b(t,e,r,n,o){return r=r.valueOf(),t[n++]=St.BSON_DATA_INT,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,t[n++]=255&r,t[n++]=r>>8&255,t[n++]=r>>16&255,t[n++]=r>>24&255,n}function _(t,e,r,n,o){return t[n++]=St.BSON_DATA_NUMBER,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0,At.writeIEEE754(t,r.value,n,"little",52,8),n+=8}function m(t,e,r,n,o,i,u){t[n++]=St.BSON_DATA_CODE,n+=u?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var s=Z.normalizedFunctionString(r),f=t.write(s,n+4,void 0,"utf8")+1;return t[n]=255&f,t[n+1]=f>>8&255,t[n+2]=f>>16&255,t[n+3]=f>>24&255,n=n+4+f-1,t[n++]=0,n}function w(t,e,r,n,o,i,u,s,f){if(void 0===o&&(o=!1),void 0===i&&(i=0),void 0===u&&(u=!1),void 0===s&&(s=!0),void 0===f&&(f=!1),r.scope&&"object"==typeof r.scope){t[n++]=St.BSON_DATA_CODE_W_SCOPE,n+=f?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var a=n,c="string"==typeof r.code?r.code:r.code.toString();n+=4;var l=t.write(c,n+4,void 0,"utf8")+1;t[n]=255&l,t[n+1]=l>>8&255,t[n+2]=l>>16&255,t[n+3]=l>>24&255,t[n+4+l-1]=0,n=n+l+4;var p=N(t,r.scope,o,n,i+1,u,s);n=p-1;var h=p-a;t[a++]=255&h,t[a++]=h>>8&255,t[a++]=h>>16&255,t[a++]=h>>24&255,t[n++]=0}else{t[n++]=St.BSON_DATA_CODE,n+=f?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;c=r.code.toString();var d=t.write(c,n+4,void 0,"utf8")+1;t[n]=255&d,t[n+1]=d>>8&255,t[n+2]=d>>16&255,t[n+3]=d>>24&255,n=n+4+d-1,t[n++]=0}return n}function v(t,e,r,n,o){t[n++]=St.BSON_DATA_BINARY,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var i=r.value(!0),u=r.position;return r.sub_type===rt.Binary.SUBTYPE_BYTE_ARRAY&&(u+=4),t[n++]=255&u,t[n++]=u>>8&255,t[n++]=u>>16&255,t[n++]=u>>24&255,t[n++]=r.sub_type,r.sub_type===rt.Binary.SUBTYPE_BYTE_ARRAY&&(u-=4,t[n++]=255&u,t[n++]=u>>8&255,t[n++]=u>>16&255,t[n++]=u>>24&255),t.set(i,n),n+=r.position}function O(t,e,r,n,o){t[n++]=St.BSON_DATA_SYMBOL,n+=o?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var i=t.write(r.value,n+4,void 0,"utf8")+1;return t[n]=255&i,t[n+1]=i>>8&255,t[n+2]=i>>16&255,t[n+3]=i>>24&255,n=n+4+i-1,t[n++]=0,n}function S(t,e,r,n,o,i,u){t[n++]=St.BSON_DATA_OBJECT,n+=u?t.write(e,n,void 0,"ascii"):t.write(e,n,void 0,"utf8"),t[n++]=0;var s=n,f={$ref:r.collection||r.namespace,$id:r.oid};null!=r.db&&(f.$db=r.db);var a=N(t,f=Object.assign(f,r.fields),!1,n,o+1,i),c=a-s;return t[s++]=255&c,t[s++]=c>>8&255,t[s++]=c>>16&255,t[s++]=c>>24&255,a}function N(t,e,N,B,E,A,T,I){void 0===N&&(N=!1),void 0===B&&(B=0),void 0===E&&(E=0),void 0===A&&(A=!1),void 0===T&&(T=!0),void 0===I&&(I=[]),B=B||0,(I=I||[]).push(e);var D=B+4;if(Array.isArray(e))for(var x=0;x<e.length;x++){var R=""+x;if((M=e[x])&&M.toBSON){if("function"!=typeof M.toBSON)throw new TypeError("toBSON is not a function");M=M.toBSON()}if("string"==typeof M)D=o(t,R,M,D,!0);else if("number"==typeof M)D=i(t,R,M,D,!0);else{if("bigint"==typeof M)throw new TypeError("Unsupported type BigInt, please use Decimal128");if("boolean"==typeof M)D=s(t,R,M,D,!0);else if(M instanceof Date||Z.isDate(M))D=f(t,R,M,D,!0);else if(void 0===M)D=u(t,R,0,D,!0);else if(null===M)D=u(t,R,0,D,!0);else if("ObjectId"===M._bsontype||"ObjectID"===M._bsontype)D=p(t,R,M,D,!0);else if(Z.isUint8Array(M))D=h(t,R,M,D,!0);else if(M instanceof RegExp||Z.isRegExp(M))D=a(t,R,M,D,!0);else if("object"==typeof M&&null==M._bsontype)D=d(t,R,M,D,N,E,A,T,!0,I);else if("object"==typeof M&&vt.isBSONType(M)&&"Decimal128"===M._bsontype)D=y(t,R,M,D,!0);else if("Long"===M._bsontype||"Timestamp"===M._bsontype)D=g(t,R,M,D,!0);else if("Double"===M._bsontype)D=_(t,R,M,D,!0);else if("function"==typeof M&&A)D=m(t,R,M,D,0,0,!0);else if("Code"===M._bsontype)D=w(t,R,M,D,N,E,A,T,!0);else if("Binary"===M._bsontype)D=v(t,R,M,D,!0);else if("Symbol"===M._bsontype)D=O(t,R,M,D,!0);else if("DBRef"===M._bsontype)D=S(t,R,M,D,E,A,!0);else if("BSONRegExp"===M._bsontype)D=c(t,R,M,D,!0);else if("Int32"===M._bsontype)D=b(t,R,M,D,!0);else if("MinKey"===M._bsontype||"MaxKey"===M._bsontype)D=l(t,R,M,D,!0);else if(void 0!==M._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+M._bsontype)}}else if(e instanceof Ot.Map||Z.isMap(e))for(var P=e.entries(),U=!1;!U;){var L=P.next();if(!(U=!!L.done)){R=L.value[0];var j=typeof(M=L.value[1]);if("string"==typeof R&&!n.has(R)){if(null!=R.match(r))throw Error("key "+R+" must not contain null bytes");if(N){if("$"===R[0])throw Error("key "+R+" must not start with '$'");if(~R.indexOf("."))throw Error("key "+R+" must not contain '.'")}}if("string"===j)D=o(t,R,M,D);else if("number"===j)D=i(t,R,M,D);else{if("bigint"===j||Z.isBigInt64Array(M)||Z.isBigUInt64Array(M))throw new TypeError("Unsupported type BigInt, please use Decimal128");if("boolean"===j)D=s(t,R,M,D);else if(M instanceof Date||Z.isDate(M))D=f(t,R,M,D);else if(null===M||void 0===M&&!1===T)D=u(t,R,0,D);else if("ObjectId"===M._bsontype||"ObjectID"===M._bsontype)D=p(t,R,M,D);else if(Z.isUint8Array(M))D=h(t,R,M,D);else if(M instanceof RegExp||Z.isRegExp(M))D=a(t,R,M,D);else if("object"===j&&null==M._bsontype)D=d(t,R,M,D,N,E,A,T,!1,I);else if("object"===j&&"Decimal128"===M._bsontype)D=y(t,R,M,D);else if("Long"===M._bsontype||"Timestamp"===M._bsontype)D=g(t,R,M,D);else if("Double"===M._bsontype)D=_(t,R,M,D);else if("Code"===M._bsontype)D=w(t,R,M,D,N,E,A,T);else if("function"==typeof M&&A)D=m(t,R,M,D,0,0,A);else if("Binary"===M._bsontype)D=v(t,R,M,D);else if("Symbol"===M._bsontype)D=O(t,R,M,D);else if("DBRef"===M._bsontype)D=S(t,R,M,D,E,A);else if("BSONRegExp"===M._bsontype)D=c(t,R,M,D);else if("Int32"===M._bsontype)D=b(t,R,M,D);else if("MinKey"===M._bsontype||"MaxKey"===M._bsontype)D=l(t,R,M,D);else if(void 0!==M._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+M._bsontype)}}}else{if(e.toBSON){if("function"!=typeof e.toBSON)throw new TypeError("toBSON is not a function");if(null!=(e=e.toBSON())&&"object"!=typeof e)throw new TypeError("toBSON function did not return an object")}for(var R in e){var M;if((M=e[R])&&M.toBSON){if("function"!=typeof M.toBSON)throw new TypeError("toBSON is not a function");M=M.toBSON()}j=typeof M;if("string"==typeof R&&!n.has(R)){if(null!=R.match(r))throw Error("key "+R+" must not contain null bytes");if(N){if("$"===R[0])throw Error("key "+R+" must not start with '$'");if(~R.indexOf("."))throw Error("key "+R+" must not contain '.'")}}if("string"===j)D=o(t,R,M,D);else if("number"===j)D=i(t,R,M,D);else{if("bigint"===j)throw new TypeError("Unsupported type BigInt, please use Decimal128");if("boolean"===j)D=s(t,R,M,D);else if(M instanceof Date||Z.isDate(M))D=f(t,R,M,D);else if(void 0===M)!1===T&&(D=u(t,R,0,D));else if(null===M)D=u(t,R,0,D);else if("ObjectId"===M._bsontype||"ObjectID"===M._bsontype)D=p(t,R,M,D);else if(Z.isUint8Array(M))D=h(t,R,M,D);else if(M instanceof RegExp||Z.isRegExp(M))D=a(t,R,M,D);else if("object"===j&&null==M._bsontype)D=d(t,R,M,D,N,E,A,T,!1,I);else if("object"===j&&"Decimal128"===M._bsontype)D=y(t,R,M,D);else if("Long"===M._bsontype||"Timestamp"===M._bsontype)D=g(t,R,M,D);else if("Double"===M._bsontype)D=_(t,R,M,D);else if("Code"===M._bsontype)D=w(t,R,M,D,N,E,A,T);else if("function"==typeof M&&A)D=m(t,R,M,D,0,0,A);else if("Binary"===M._bsontype)D=v(t,R,M,D);else if("Symbol"===M._bsontype)D=O(t,R,M,D);else if("DBRef"===M._bsontype)D=S(t,R,M,D,E,A);else if("BSONRegExp"===M._bsontype)D=c(t,R,M,D);else if("Int32"===M._bsontype)D=b(t,R,M,D);else if("MinKey"===M._bsontype||"MaxKey"===M._bsontype)D=l(t,R,M,D);else if(void 0!==M._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+M._bsontype)}}}I.pop(),t[D++]=0;var C=D-B;return t[B++]=255&C,t[B++]=C>>8&255,t[B++]=C>>16&255,t[B++]=C>>24&255,D}e.serializeInto=N}));i(Tt),Tt.serializeInto;var It=u((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.ObjectID=e.Decimal128=e.BSONRegExp=e.MaxKey=e.MinKey=e.Int32=e.Double=e.Timestamp=e.Long=e.UUID=e.ObjectId=e.Binary=e.DBRef=e.BSONSymbol=e.Map=e.Code=e.LongWithoutOverridesClass=e.EJSON=e.BSON_INT64_MIN=e.BSON_INT64_MAX=e.BSON_INT32_MIN=e.BSON_INT32_MAX=e.BSON_DATA_UNDEFINED=e.BSON_DATA_TIMESTAMP=e.BSON_DATA_SYMBOL=e.BSON_DATA_STRING=e.BSON_DATA_REGEXP=e.BSON_DATA_OID=e.BSON_DATA_OBJECT=e.BSON_DATA_NUMBER=e.BSON_DATA_NULL=e.BSON_DATA_MIN_KEY=e.BSON_DATA_MAX_KEY=e.BSON_DATA_LONG=e.BSON_DATA_INT=e.BSON_DATA_DECIMAL128=e.BSON_DATA_DBPOINTER=e.BSON_DATA_DATE=e.BSON_DATA_CODE_W_SCOPE=e.BSON_DATA_CODE=e.BSON_DATA_BOOLEAN=e.BSON_DATA_BINARY=e.BSON_DATA_ARRAY=e.BSON_BINARY_SUBTYPE_UUID_NEW=e.BSON_BINARY_SUBTYPE_UUID=e.BSON_BINARY_SUBTYPE_USER_DEFINED=e.BSON_BINARY_SUBTYPE_MD5=e.BSON_BINARY_SUBTYPE_FUNCTION=e.BSON_BINARY_SUBTYPE_DEFAULT=e.BSON_BINARY_SUBTYPE_BYTE_ARRAY=void 0,e.deserializeStream=e.calculateObjectSize=e.deserialize=e.serializeWithBufferAndIndex=e.serialize=e.setInternalBufferSize=void 0,Object.defineProperty(e,"Binary",{enumerable:!0,get:function(){return rt.Binary}}),Object.defineProperty(e,"Code",{enumerable:!0,get:function(){return nt.Code}}),Object.defineProperty(e,"DBRef",{enumerable:!0,get:function(){return ot.DBRef}}),Object.defineProperty(e,"Decimal128",{enumerable:!0,get:function(){return ut.Decimal128}}),Object.defineProperty(e,"Double",{enumerable:!0,get:function(){return st.Double}}),Object.defineProperty(e,"Int32",{enumerable:!0,get:function(){return ft.Int32}}),Object.defineProperty(e,"Long",{enumerable:!0,get:function(){return it.Long}}),Object.defineProperty(e,"Map",{enumerable:!0,get:function(){return Ot.Map}}),Object.defineProperty(e,"MaxKey",{enumerable:!0,get:function(){return at.MaxKey}}),Object.defineProperty(e,"MinKey",{enumerable:!0,get:function(){return ct.MinKey}}),Object.defineProperty(e,"ObjectId",{enumerable:!0,get:function(){return lt.ObjectId}}),Object.defineProperty(e,"ObjectID",{enumerable:!0,get:function(){return lt.ObjectId}}),Object.defineProperty(e,"BSONRegExp",{enumerable:!0,get:function(){return pt.BSONRegExp}}),Object.defineProperty(e,"BSONSymbol",{enumerable:!0,get:function(){return ht.BSONSymbol}}),Object.defineProperty(e,"Timestamp",{enumerable:!0,get:function(){return wt.Timestamp}}),Object.defineProperty(e,"UUID",{enumerable:!0,get:function(){return et.UUID}}),Object.defineProperty(e,"BSON_BINARY_SUBTYPE_BYTE_ARRAY",{enumerable:!0,get:function(){return St.BSON_BINARY_SUBTYPE_BYTE_ARRAY}}),Object.defineProperty(e,"BSON_BINARY_SUBTYPE_DEFAULT",{enumerable:!0,get:function(){return St.BSON_BINARY_SUBTYPE_DEFAULT}}),Object.defineProperty(e,"BSON_BINARY_SUBTYPE_FUNCTION",{enumerable:!0,get:function(){return St.BSON_BINARY_SUBTYPE_FUNCTION}}),Object.defineProperty(e,"BSON_BINARY_SUBTYPE_MD5",{enumerable:!0,get:function(){return St.BSON_BINARY_SUBTYPE_MD5}}),Object.defineProperty(e,"BSON_BINARY_SUBTYPE_USER_DEFINED",{enumerable:!0,get:function(){return St.BSON_BINARY_SUBTYPE_USER_DEFINED}}),Object.defineProperty(e,"BSON_BINARY_SUBTYPE_UUID",{enumerable:!0,get:function(){return St.BSON_BINARY_SUBTYPE_UUID}}),Object.defineProperty(e,"BSON_BINARY_SUBTYPE_UUID_NEW",{enumerable:!0,get:function(){return St.BSON_BINARY_SUBTYPE_UUID_NEW}}),Object.defineProperty(e,"BSON_DATA_ARRAY",{enumerable:!0,get:function(){return St.BSON_DATA_ARRAY}}),Object.defineProperty(e,"BSON_DATA_BINARY",{enumerable:!0,get:function(){return St.BSON_DATA_BINARY}}),Object.defineProperty(e,"BSON_DATA_BOOLEAN",{enumerable:!0,get:function(){return St.BSON_DATA_BOOLEAN}}),Object.defineProperty(e,"BSON_DATA_CODE",{enumerable:!0,get:function(){return St.BSON_DATA_CODE}}),Object.defineProperty(e,"BSON_DATA_CODE_W_SCOPE",{enumerable:!0,get:function(){return St.BSON_DATA_CODE_W_SCOPE}}),Object.defineProperty(e,"BSON_DATA_DATE",{enumerable:!0,get:function(){return St.BSON_DATA_DATE}}),Object.defineProperty(e,"BSON_DATA_DBPOINTER",{enumerable:!0,get:function(){return St.BSON_DATA_DBPOINTER}}),Object.defineProperty(e,"BSON_DATA_DECIMAL128",{enumerable:!0,get:function(){return St.BSON_DATA_DECIMAL128}}),Object.defineProperty(e,"BSON_DATA_INT",{enumerable:!0,get:function(){return St.BSON_DATA_INT}}),Object.defineProperty(e,"BSON_DATA_LONG",{enumerable:!0,get:function(){return St.BSON_DATA_LONG}}),Object.defineProperty(e,"BSON_DATA_MAX_KEY",{enumerable:!0,get:function(){return St.BSON_DATA_MAX_KEY}}),Object.defineProperty(e,"BSON_DATA_MIN_KEY",{enumerable:!0,get:function(){return St.BSON_DATA_MIN_KEY}}),Object.defineProperty(e,"BSON_DATA_NULL",{enumerable:!0,get:function(){return St.BSON_DATA_NULL}}),Object.defineProperty(e,"BSON_DATA_NUMBER",{enumerable:!0,get:function(){return St.BSON_DATA_NUMBER}}),Object.defineProperty(e,"BSON_DATA_OBJECT",{enumerable:!0,get:function(){return St.BSON_DATA_OBJECT}}),Object.defineProperty(e,"BSON_DATA_OID",{enumerable:!0,get:function(){return St.BSON_DATA_OID}}),Object.defineProperty(e,"BSON_DATA_REGEXP",{enumerable:!0,get:function(){return St.BSON_DATA_REGEXP}}),Object.defineProperty(e,"BSON_DATA_STRING",{enumerable:!0,get:function(){return St.BSON_DATA_STRING}}),Object.defineProperty(e,"BSON_DATA_SYMBOL",{enumerable:!0,get:function(){return St.BSON_DATA_SYMBOL}}),Object.defineProperty(e,"BSON_DATA_TIMESTAMP",{enumerable:!0,get:function(){return St.BSON_DATA_TIMESTAMP}}),Object.defineProperty(e,"BSON_DATA_UNDEFINED",{enumerable:!0,get:function(){return St.BSON_DATA_UNDEFINED}}),Object.defineProperty(e,"BSON_INT32_MAX",{enumerable:!0,get:function(){return St.BSON_INT32_MAX}}),Object.defineProperty(e,"BSON_INT32_MIN",{enumerable:!0,get:function(){return St.BSON_INT32_MIN}}),Object.defineProperty(e,"BSON_INT64_MAX",{enumerable:!0,get:function(){return St.BSON_INT64_MAX}}),Object.defineProperty(e,"BSON_INT64_MIN",{enumerable:!0,get:function(){return St.BSON_INT64_MIN}});var r=vt;Object.defineProperty(e,"EJSON",{enumerable:!0,get:function(){return r.EJSON}});var n=wt;Object.defineProperty(e,"LongWithoutOverridesClass",{enumerable:!0,get:function(){return n.LongWithoutOverridesClass}});var o=v.Buffer.alloc(17825792);function i(t){o.length<t&&(o=v.Buffer.alloc(t))}function u(t,e){void 0===e&&(e={});var r="boolean"==typeof e.checkKeys&&e.checkKeys,n="boolean"==typeof e.serializeFunctions&&e.serializeFunctions,i="boolean"!=typeof e.ignoreUndefined||e.ignoreUndefined,u="number"==typeof e.minInternalBufferSize?e.minInternalBufferSize:17825792;o.length<u&&(o=v.Buffer.alloc(u));var s=Tt.serializeInto(o,t,r,0,0,n,i,[]),f=v.Buffer.alloc(s);return o.copy(f,0,0,f.length),f}function s(t,e,r){void 0===r&&(r={});var n="boolean"==typeof r.checkKeys&&r.checkKeys,i="boolean"==typeof r.serializeFunctions&&r.serializeFunctions,u="boolean"!=typeof r.ignoreUndefined||r.ignoreUndefined,s="number"==typeof r.index?r.index:0,f=Tt.serializeInto(o,t,n,0,0,i,u);return o.copy(e,s,0,f),s+f-1}function f(t,e){return void 0===e&&(e={}),Et.deserialize(Q.ensureBuffer(t),e)}function a(t,e){void 0===e&&(e={});var r="boolean"==typeof(e=e||{}).serializeFunctions&&e.serializeFunctions,n="boolean"!=typeof e.ignoreUndefined||e.ignoreUndefined;return Nt.calculateObjectSize(t,r,n)}function c(t,e,r,n,o,i){for(var u=Object.assign({allowObjectSmallerThanBufferSize:!0,index:0},i),s=Q.ensureBuffer(t),f=e,a=0;a<r;a++){var c=s[f]|s[f+1]<<8|s[f+2]<<16|s[f+3]<<24;u.index=f,n[o+a]=Et.deserialize(s,u),f+=c}return f}e.setInternalBufferSize=i,e.serialize=u,e.serializeWithBufferAndIndex=s,e.deserialize=f,e.calculateObjectSize=a,e.deserializeStream=c;var l={Binary:rt.Binary,Code:nt.Code,DBRef:ot.DBRef,Decimal128:ut.Decimal128,Double:st.Double,Int32:ft.Int32,Long:it.Long,UUID:et.UUID,Map:Ot.Map,MaxKey:at.MaxKey,MinKey:ct.MinKey,ObjectId:lt.ObjectId,ObjectID:lt.ObjectId,BSONRegExp:pt.BSONRegExp,BSONSymbol:ht.BSONSymbol,Timestamp:wt.Timestamp,EJSON:vt.EJSON,setInternalBufferSize:i,serialize:u,serializeWithBufferAndIndex:s,deserialize:f,calculateObjectSize:a,deserializeStream:c};e.default=l})),Dt=(i(It),It.ObjectID,It.Decimal128,It.BSONRegExp,It.MaxKey,It.MinKey,It.Int32,It.Double,It.Timestamp,It.Long,It.UUID,It.ObjectId,It.Binary,It.DBRef,It.BSONSymbol,It.Map,It.Code,It.LongWithoutOverridesClass,It.EJSON);It.BSON_INT64_MIN,It.BSON_INT64_MAX,It.BSON_INT32_MIN,It.BSON_INT32_MAX,It.BSON_DATA_UNDEFINED,It.BSON_DATA_TIMESTAMP,It.BSON_DATA_SYMBOL,It.BSON_DATA_STRING,It.BSON_DATA_REGEXP,It.BSON_DATA_OID,It.BSON_DATA_OBJECT,It.BSON_DATA_NUMBER,It.BSON_DATA_NULL,It.BSON_DATA_MIN_KEY,It.BSON_DATA_MAX_KEY,It.BSON_DATA_LONG,It.BSON_DATA_INT,It.BSON_DATA_DECIMAL128,It.BSON_DATA_DBPOINTER,It.BSON_DATA_DATE,It.BSON_DATA_CODE_W_SCOPE,It.BSON_DATA_CODE,It.BSON_DATA_BOOLEAN,It.BSON_DATA_BINARY,It.BSON_DATA_ARRAY,It.BSON_BINARY_SUBTYPE_UUID_NEW,It.BSON_BINARY_SUBTYPE_UUID,It.BSON_BINARY_SUBTYPE_USER_DEFINED,It.BSON_BINARY_SUBTYPE_MD5,It.BSON_BINARY_SUBTYPE_FUNCTION,It.BSON_BINARY_SUBTYPE_DEFAULT,It.BSON_BINARY_SUBTYPE_BYTE_ARRAY,It.deserializeStream,It.calculateObjectSize,It.deserialize,It.serializeWithBufferAndIndex,It.serialize,It.setInternalBufferSize}).call(this,r(1),r(3).Buffer)},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0}),e.registerDatabase=void 0;var o=r(7);var i={name:"database",entity:{database:function(t){var e=this.platform,r=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=r.wsClass,o.Db.wsClientClass=this.wsClientClass),o.Db.ws||(o.Db.ws=null),new o.Db(n(n(n({},this.config),{_fromApp:this}),t))}}};try{cloudbase.registerComponent(i)}catch(t){}e.registerDatabase=function(t){try{t.registerComponent(i)}catch(t){console.warn(t)}}},function(t,e,r){"use strict";(function(t){
18
18
  /*!
19
19
  * The buffer module from node.js, for the browser.
20
20
  *