<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[928],{97560:function(e,t,n){var r=n(27310).Buffer;const i=new WeakMap,o="[object ArrayBuffer]",s="[object SharedArrayBuffer]",u="[object Uint8Array]",f="[object RegExp]",l="[object Map]",a="[object Date]";function h(e){let t=i.get(e);return t||(t=Object.prototype.toString.call(e),null!==e&amp;&amp;"object"===typeof e&amp;&amp;i.set(e,t)),t}function c(e){const t=h(e);return t===o||t===s}function g(e){return h(e)===u}function b(e){return h(e)===f}function d(e){return h(e)===l}function p(e){return h(e)===a}function m(e,t){return JSON.stringify(e,((e,t)=&gt;"bigint"===typeof t?{$numberLong:`${t}`}:d(t)?Object.fromEntries(t):t))}const y=Symbol.for("@@mdb.bson.version"),w=2147483647,S=-2147483648,B=Math.pow(2,63)-1,N=-Math.pow(2,63),E=Math.pow(2,53),x=-Math.pow(2,53),O=Object.freeze({double:1,string:2,object:3,array:4,binData:5,undefined:6,objectId:7,bool:8,date:9,null:10,regex:11,dbPointer:12,javascript:13,symbol:14,javascriptWithScope:15,int:16,timestamp:17,long:18,decimal:19,minKey:-1,maxKey:127});class I extends Error{get bsonError(){return!0}get name(){return"BSONError"}constructor(e,t){super(e,t)}static isBSONError(e){return null!=e&amp;&amp;"object"===typeof e&amp;&amp;"bsonError"in e&amp;&amp;!0===e.bsonError&amp;&amp;"name"in e&amp;&amp;"message"in e&amp;&amp;"stack"in e}}class $ extends I{get name(){return"BSONVersionError"}constructor(){super("Unsupported BSON version, bson types must be from bson 6.x.x")}}class _ extends I{get name(){return"BSONRuntimeError"}constructor(e){super(e)}}class L extends I{get name(){return"BSONOffsetError"}constructor(e,t,n){super(`${e}. offset: ${t}`,n),this.offset=t}}let U,T;function v(e,t,n,r){if(r){U??=new TextDecoder("utf8",{fatal:!0});try{return U.decode(e.subarray(t,n))}catch(i){throw new I("Invalid UTF-8 string in BSON document",{cause:i})}}return T??=new TextDecoder("utf8",{fatal:!1}),T.decode(e.subarray(t,n))}function A(e,t,n){if(0===e.length)return"";const r=n-t;if(0===r)return"";if(r&gt;20)return null;if(1===r&amp;&amp;e[t]&lt;128)return String.fromCharCode(e[t]);if(2===r&amp;&amp;e[t]&lt;128&amp;&amp;e[t+1]&lt;128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1]);if(3===r&amp;&amp;e[t]&lt;128&amp;&amp;e[t+1]&lt;128&amp;&amp;e[t+2]&lt;128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1])+String.fromCharCode(e[t+2]);const i=[];for(let o=t;o&lt;n;o++){const t=e[o];if(t&gt;127)return null;i.push(t)}return String.fromCharCode(...i)}function j(e){return R.fromNumberArray(Array.from({length:e},(()=&gt;Math.floor(256*Math.random()))))}const R={toLocalBufferType(e){if(r.isBuffer(e))return e;if(ArrayBuffer.isView(e))return r.from(e.buffer,e.byteOffset,e.byteLength);const t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if("ArrayBuffer"===t||"SharedArrayBuffer"===t||"[object ArrayBuffer]"===t||"[object SharedArrayBuffer]"===t)return r.from(e);throw new I(`Cannot create Buffer from ${String(e)}`)},allocate:e=&gt;r.alloc(e),allocateUnsafe:e=&gt;r.allocUnsafe(e),equals:(e,t)=&gt;R.toLocalBufferType(e).equals(t),fromNumberArray:e=&gt;r.from(e),fromBase64:e=&gt;r.from(e,"base64"),toBase64:e=&gt;R.toLocalBufferType(e).toString("base64"),fromISO88591:e=&gt;r.from(e,"binary"),toISO88591:e=&gt;R.toLocalBufferType(e).toString("binary"),fromHex:e=&gt;r.from(e,"hex"),toHex:e=&gt;R.toLocalBufferType(e).toString("hex"),toUTF8(e,t,n,r){const i=n-t&lt;=20?A(e,t,n):null;if(null!=i)return i;const o=R.toLocalBufferType(e).toString("utf8",t,n);if(r)for(let s=0;s&lt;o.length;s++)if(65533===o.charCodeAt(s)){v(e,t,n,!0);break}return o},utf8ByteLength:e=&gt;r.byteLength(e,"utf8"),encodeUTF8Into(e,t,n){const r=function(e,t,n){if(0===t.length)return 0;if(t.length&gt;25)return null;if(e.length-n&lt;t.length)return null;for(let r=0,i=n;r&lt;t.length;r++,i++){const n=t.charCodeAt(r);if(n&gt;127)return null;e[i]=n}return t.length}(e,t,n);return null!=r?r:R.toLocalBufferType(e).write(t,n,void 0,"utf8")},randomBytes:(()=&gt;{try{return n(79280).randomBytes}catch{return j}})()};function D(e){if(e&lt;0)throw new RangeError(`The argument 'byteLength' is invalid. Received ${e}`);return z.fromNumberArray(Array.from({length:e},(()=&gt;Math.floor(256*Math.random()))))}const F=(()=&gt;{const{crypto:e}=globalThis;if(null!=e&amp;&amp;"function"===typeof e.getRandomValues)return t=&gt;e.getRandomValues(z.allocate(t));if(function(){const{navigator:e}=globalThis;return"object"===typeof e&amp;&amp;"ReactNative"===e.product}()){const{console:e}=globalThis;e?.warn?.("BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.")}return D})(),M=/(\d|[a-f])/i,z={toLocalBufferType(e){const t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if("Uint8Array"===t)return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));if("ArrayBuffer"===t||"SharedArrayBuffer"===t||"[object ArrayBuffer]"===t||"[object SharedArrayBuffer]"===t)return new Uint8Array(e);throw new I(`Cannot make a Uint8Array from ${String(e)}`)},allocate(e){if("number"!==typeof e)throw new TypeError(`The "size" argument must be of type number. Received ${String(e)}`);return new Uint8Array(e)},allocateUnsafe:e=&gt;z.allocate(e),equals(e,t){if(e.byteLength!==t.byteLength)return!1;for(let n=0;n&lt;e.byteLength;n++)if(e[n]!==t[n])return!1;return!0},fromNumberArray:e=&gt;Uint8Array.from(e),fromBase64:e=&gt;Uint8Array.from(atob(e),(e=&gt;e.charCodeAt(0))),toBase64:e=&gt;btoa(z.toISO88591(e)),fromISO88591:e=&gt;Uint8Array.from(e,(e=&gt;255&amp;e.charCodeAt(0))),toISO88591:e=&gt;Array.from(Uint16Array.from(e),(e=&gt;String.fromCharCode(e))).join(""),fromHex(e){const t=e.length%2===0?e:e.slice(0,e.length-1),n=[];for(let r=0;r&lt;t.length;r+=2){const e=t[r],i=t[r+1];if(!M.test(e))break;if(!M.test(i))break;const o=Number.parseInt(`${e}${i}`,16);n.push(o)}return Uint8Array.from(n)},toHex:e=&gt;Array.from(e,(e=&gt;e.toString(16).padStart(2,"0"))).join(""),toUTF8(e,t,n,r){const i=n-t&lt;=20?A(e,t,n):null;return null!=i?i:v(e,t,n,r)},utf8ByteLength:e=&gt;(new TextEncoder).encode(e).byteLength,encodeUTF8Into(e,t,n){const r=(new TextEncoder).encode(t);return e.set(r,n),r.byteLength},randomBytes:F},J="function"===typeof r&amp;&amp;!0!==r.prototype?._isBuffer?R:z;class V{get[y](){return 6}[Symbol.for("nodejs.util.inspect.custom")](e,t,n){return this.inspect(e,t,n)}}class C extends V{get _bsontype(){return"Binary"}constructor(e,t){if(super(),null!=e&amp;&amp;"string"===typeof e&amp;&amp;!ArrayBuffer.isView(e)&amp;&amp;!c(e)&amp;&amp;!Array.isArray(e))throw new I("Binary can only be constructed from Uint8Array or number[]");this.sub_type=t??C.BSON_BINARY_SUBTYPE_DEFAULT,null==e?(this.buffer=J.allocate(C.BUFFER_SIZE),this.position=0):(this.buffer=Array.isArray(e)?J.fromNumberArray(e):J.toLocalBufferType(e),this.position=this.buffer.byteLength)}put(e){if("string"===typeof e&amp;&amp;1!==e.length)throw new I("only accepts single character String");if("number"!==typeof e&amp;&amp;1!==e.length)throw new I("only accepts single character Uint8Array or Array");let t;if(t="string"===typeof e?e.charCodeAt(0):"number"===typeof e?e:e[0],t&lt;0||t&gt;255)throw new I("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.byteLength&gt;this.position)this.buffer[this.position++]=t;else{const e=J.allocate(C.BUFFER_SIZE+this.buffer.length);e.set(this.buffer,0),this.buffer=e,this.buffer[this.position++]=t}}write(e,t){if(t="number"===typeof t?t:this.position,this.buffer.byteLength&lt;t+e.length){const t=J.allocate(this.buffer.byteLength+e.length);t.set(this.buffer,0),this.buffer=t}if(ArrayBuffer.isView(e))this.buffer.set(J.toLocalBufferType(e),t),this.position=t+e.byteLength&gt;this.position?t+e.length:this.position;else if("string"===typeof e)throw new I("input cannot be string")}read(e,t){return t=t&amp;&amp;t&gt;0?t:this.position,this.buffer.slice(e,e+t)}value(){return this.buffer.length===this.position?this.buffer:this.buffer.subarray(0,this.position)}length(){return this.position}toJSON(){return J.toBase64(this.buffer.subarray(0,this.position))}toString(e){return"hex"===e?J.toHex(this.buffer.subarray(0,this.position)):"base64"===e?J.toBase64(this.buffer.subarray(0,this.position)):J.toUTF8(this.buffer,0,this.position,!1)}toExtendedJSON(e){e=e||{};const t=J.toBase64(this.buffer),n=Number(this.sub_type).toString(16);return e.legacy?{$binary:t,$type:1===n.length?"0"+n:n}:{$binary:{base64:t,subType:1===n.length?"0"+n:n}}}toUUID(){if(this.sub_type===C.SUBTYPE_UUID)return new q(this.buffer.slice(0,this.position));throw new I(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${C.SUBTYPE_UUID}" is currently supported.`)}static createFromHexString(e,t){return new C(J.fromHex(e),t)}static createFromBase64(e,t){return new C(J.fromBase64(e),t)}static fromExtendedJSON(e,t){let n,r;if(t=t||{},"$binary"in e?t.legacy&amp;&amp;"string"===typeof e.$binary&amp;&amp;"$type"in e?(r=e.$type?parseInt(e.$type,16):0,n=J.fromBase64(e.$binary)):"string"!==typeof e.$binary&amp;&amp;(r=e.$binary.subType?parseInt(e.$binary.subType,16):0,n=J.fromBase64(e.$binary.base64)):"$uuid"in e&amp;&amp;(r=4,n=q.bytesFromString(e.$uuid)),!n)throw new I(`Unexpected Binary Extended JSON format ${JSON.stringify(e)}`);return 4===r?new q(n):new C(n,r)}inspect(e,t,n){n??=m;return`Binary.createFromBase64(${n(J.toBase64(this.buffer.subarray(0,this.position)),t)}, ${n(this.sub_type,t)})`}}C.BSON_BINARY_SUBTYPE_DEFAULT=0,C.BUFFER_SIZE=256,C.SUBTYPE_DEFAULT=0,C.SUBTYPE_FUNCTION=1,C.SUBTYPE_BYTE_ARRAY=2,C.SUBTYPE_UUID_OLD=3,C.SUBTYPE_UUID=4,C.SUBTYPE_MD5=5,C.SUBTYPE_ENCRYPTED=6,C.SUBTYPE_COLUMN=7,C.SUBTYPE_SENSITIVE=8,C.SUBTYPE_USER_DEFINED=128;const H=/^[0-9A-F]{32}$/i,k=/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i;class q extends C{constructor(e){let t;if(null==e)t=q.generate();else if(e instanceof q)t=J.toLocalBufferType(new Uint8Array(e.buffer));else if(ArrayBuffer.isView(e)&amp;&amp;16===e.byteLength)t=J.toLocalBufferType(e);else{if("string"!==typeof e)throw new I("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");t=q.bytesFromString(e)}super(t,4)}get id(){return this.buffer}set id(e){this.buffer=e}toHexString(e=!0){return e?[J.toHex(this.buffer.subarray(0,4)),J.toHex(this.buffer.subarray(4,6)),J.toHex(this.buffer.subarray(6,8)),J.toHex(this.buffer.subarray(8,10)),J.toHex(this.buffer.subarray(10,16))].join("-"):J.toHex(this.buffer)}toString(e){return"hex"===e?J.toHex(this.id):"base64"===e?J.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}equals(e){if(!e)return!1;if(e instanceof q)return J.equals(e.id,this.id);try{return J.equals(new q(e).id,this.id)}catch{return!1}}toBinary(){return new C(this.id,C.SUBTYPE_UUID)}static generate(){const e=J.randomBytes(16);return e[6]=15&amp;e[6]|64,e[8]=63&amp;e[8]|128,e}static isValid(e){return!!e&amp;&amp;("string"===typeof e?q.isValidUUIDString(e):g(e)?16===e.byteLength:"Binary"===e._bsontype&amp;&amp;e.sub_type===this.SUBTYPE_UUID&amp;&amp;16===e.buffer.byteLength)}static createFromHexString(e){const t=q.bytesFromString(e);return new q(t)}static createFromBase64(e){return new q(J.fromBase64(e))}static bytesFromString(e){if(!q.isValidUUIDString(e))throw new I("UUID string representation must be 32 hex digits or canonical hyphenated representation");return J.fromHex(e.replace(/-/g,""))}static isValidUUIDString(e){return H.test(e)||k.test(e)}inspect(e,t,n){return n??=m,`new UUID(${n(this.toHexString(),t)})`}}class Y extends V{get _bsontype(){return"Code"}constructor(e,t){super(),this.code=e.toString(),this.scope=t??null}toJSON(){return null!=this.scope?{code:this.code,scope:this.scope}:{code:this.code}}toExtendedJSON(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}static fromExtendedJSON(e){return new Y(e.$code,e.$scope)}inspect(e,t,n){n??=m;let r=n(this.code,t);const i=r.includes("\n");null!=this.scope&amp;&amp;(r+=`,${i?"\n":" "}${n(this.scope,t)}`);return`new Code(${i?"\n":""}${r}${i&amp;&amp;null===this.scope?"\n":""})`}}function P(e){return null!=e&amp;&amp;"object"===typeof e&amp;&amp;"$id"in e&amp;&amp;null!=e.$id&amp;&amp;"$ref"in e&amp;&amp;"string"===typeof e.$ref&amp;&amp;(!("$db"in e)||"$db"in e&amp;&amp;"string"===typeof e.$db)}class Z extends V{get _bsontype(){return"DBRef"}constructor(e,t,n,r){super();const i=e.split(".");2===i.length&amp;&amp;(n=i.shift(),e=i.shift()),this.collection=e,this.oid=t,this.db=n,this.fields=r||{}}get namespace(){return this.collection}set namespace(e){this.collection=e}toJSON(){const e=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&amp;&amp;(e.$db=this.db),e}toExtendedJSON(e){e=e||{};let t={$ref:this.collection,$id:this.oid};return e.legacy||(this.db&amp;&amp;(t.$db=this.db),t=Object.assign(t,this.fields)),t}static fromExtendedJSON(e){const t=Object.assign({},e);return delete t.$ref,delete t.$id,delete t.$db,new Z(e.$ref,e.$id,e.$db,t)}inspect(e,t,n){n??=m;const r=[n(this.namespace,t),n(this.oid,t),...this.db?[n(this.db,t)]:[],...Object.keys(this.fields).length&gt;0?[n(this.fields,t)]:[]];return r[1]=n===m?`new ObjectId(${r[1]})`:r[1],`new DBRef(${r.join(", ")})`}}function K(e){if(""===e)return e;let t=0;const n="-"===e[t],r="+"===e[t];(r||n)&amp;&amp;(t+=1);let i=!1;for(;t&lt;e.length&amp;&amp;"0"===e[t];++t)i=!0;return i?`${n?"-":""}${e.length===t?"0":e.slice(t)}`:r?e.slice(1):e}let W;try{W=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}const G=4294967296,X=0x10000000000000000,Q=X/2,ee={},te={},ne=/^(\+?0|(\+|-)?[1-9][0-9]*)$/;class re extends V{get _bsontype(){return"Long"}get __isLong__(){return!0}constructor(e=0,t,n){super();const r="boolean"===typeof t?t:Boolean(n),i="number"===typeof t?t:0,o="string"===typeof e?re.fromString(e,r):"bigint"===typeof e?re.fromBigInt(e,r):{low:0|e,high:0|i,unsigned:r};this.low=o.low,this.high=o.high,this.unsigned=o.unsigned}static fromBits(e,t,n){return new re(e,t,n)}static fromInt(e,t){let n,r,i;return t?(i=0&lt;=(e&gt;&gt;&gt;=0)&amp;&amp;e&lt;256)&amp;&amp;(r=te[e],r)?r:(n=re.fromBits(e,(0|e)&lt;0?-1:0,!0),i&amp;&amp;(te[e]=n),n):(i=-128&lt;=(e|=0)&amp;&amp;e&lt;128)&amp;&amp;(r=ee[e],r)?r:(n=re.fromBits(e,e&lt;0?-1:0,!1),i&amp;&amp;(ee[e]=n),n)}static fromNumber(e,t){if(isNaN(e))return t?re.UZERO:re.ZERO;if(t){if(e&lt;0)return re.UZERO;if(e&gt;=X)return re.MAX_UNSIGNED_VALUE}else{if(e&lt;=-Q)return re.MIN_VALUE;if(e+1&gt;=Q)return re.MAX_VALUE}return e&lt;0?re.fromNumber(-e,t).neg():re.fromBits(e%G|0,e/G|0,t)}static fromBigInt(e,t){const n=BigInt(4294967295),r=BigInt(32);return new re(Number(e&amp;n),Number(e&gt;&gt;r&amp;n),t)}static _fromString(e,t,n){if(0===e.length)throw new I("empty string");if(n&lt;2||36&lt;n)throw new I("radix");let r;if((r=e.indexOf("-"))&gt;0)throw new I("interior hyphen");if(0===r)return re._fromString(e.substring(1),t,n).neg();const i=re.fromNumber(Math.pow(n,8));let o=re.ZERO;for(let s=0;s&lt;e.length;s+=8){const t=Math.min(8,e.length-s),r=parseInt(e.substring(s,s+t),n);if(t&lt;8){const e=re.fromNumber(Math.pow(n,t));o=o.mul(e).add(re.fromNumber(r))}else o=o.mul(i),o=o.add(re.fromNumber(r))}return o.unsigned=t,o}static fromStringStrict(e,t,n){let r=!1;if("number"===typeof t?(n=t,t=!1):r=!!t,n??=10,e.trim()!==e)throw new I(`Input: '${e}' contains leading and/or trailing whitespace`);if(!function(e,t){const n="0123456789abcdefghijklmnopqrstuvwxyz".slice(0,t=t??10);return!new RegExp(`[^-+${n}]`,"i").test(e)&amp;&amp;e}(e,n))throw new I(`Input: '${e}' contains invalid characters for radix: ${n}`);const i=K(e),o=re._fromString(i,r,n);if(o.toString(n).toLowerCase()!==i.toLowerCase())throw new I(`Input: ${e} is not representable as ${o.unsigned?"an unsigned":"a signed"} 64-bit Long ${null!=n?`with radix: ${n}`:""}`);return o}static fromString(e,t,n){let r=!1;return"number"===typeof t?(n=t,t=!1):r=!!t,n??=10,"NaN"===e&amp;&amp;n&lt;24||("Infinity"===e||"+Infinity"===e||"-Infinity"===e)&amp;&amp;n&lt;35?re.ZERO:re._fromString(e,r,n)}static fromBytes(e,t,n){return n?re.fromBytesLE(e,t):re.fromBytesBE(e,t)}static fromBytesLE(e,t){return new re(e[0]|e[1]&lt;&lt;8|e[2]&lt;&lt;16|e[3]&lt;&lt;24,e[4]|e[5]&lt;&lt;8|e[6]&lt;&lt;16|e[7]&lt;&lt;24,t)}static fromBytesBE(e,t){return new re(e[4]&lt;&lt;24|e[5]&lt;&lt;16|e[6]&lt;&lt;8|e[7],e[0]&lt;&lt;24|e[1]&lt;&lt;16|e[2]&lt;&lt;8|e[3],t)}static isLong(e){return null!=e&amp;&amp;"object"===typeof e&amp;&amp;"__isLong__"in e&amp;&amp;!0===e.__isLong__}static fromValue(e,t){return"number"===typeof e?re.fromNumber(e,t):"string"===typeof e?re.fromString(e,t):re.fromBits(e.low,e.high,"boolean"===typeof t?t:e.unsigned)}add(e){re.isLong(e)||(e=re.fromValue(e));const t=this.high&gt;&gt;&gt;16,n=65535&amp;this.high,r=this.low&gt;&gt;&gt;16,i=65535&amp;this.low,o=e.high&gt;&gt;&gt;16,s=65535&amp;e.high,u=e.low&gt;&gt;&gt;16;let f=0,l=0,a=0,h=0;return h+=i+(65535&amp;e.low),a+=h&gt;&gt;&gt;16,h&amp;=65535,a+=r+u,l+=a&gt;&gt;&gt;16,a&amp;=65535,l+=n+s,f+=l&gt;&gt;&gt;16,l&amp;=65535,f+=t+o,f&amp;=65535,re.fromBits(a&lt;&lt;16|h,f&lt;&lt;16|l,this.unsigned)}and(e){return re.isLong(e)||(e=re.fromValue(e)),re.fromBits(this.low&amp;e.low,this.high&amp;e.high,this.unsigned)}compare(e){if(re.isLong(e)||(e=re.fromValue(e)),this.eq(e))return 0;const t=this.isNegative(),n=e.isNegative();return t&amp;&amp;!n?-1:!t&amp;&amp;n?1:this.unsigned?e.high&gt;&gt;&gt;0&gt;this.high&gt;&gt;&gt;0||e.high===this.high&amp;&amp;e.low&gt;&gt;&gt;0&gt;this.low&gt;&gt;&gt;0?-1:1:this.sub(e).isNegative()?-1:1}comp(e){return this.compare(e)}divide(e){if(re.isLong(e)||(e=re.fromValue(e)),e.isZero())throw new I("division by zero");if(W){if(!this.unsigned&amp;&amp;-2147483648===this.high&amp;&amp;-1===e.low&amp;&amp;-1===e.high)return this;const t=(this.unsigned?W.div_u:W.div_s)(this.low,this.high,e.low,e.high);return re.fromBits(t,W.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?re.UZERO:re.ZERO;let t,n,r;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return re.UZERO;if(e.gt(this.shru(1)))return re.UONE;r=re.UZERO}else{if(this.eq(re.MIN_VALUE)){if(e.eq(re.ONE)||e.eq(re.NEG_ONE))return re.MIN_VALUE;if(e.eq(re.MIN_VALUE))return re.ONE;return t=this.shr(1).div(e).shl(1),t.eq(re.ZERO)?e.isNegative()?re.ONE:re.NEG_ONE:(n=this.sub(e.mul(t)),r=t.add(n.div(e)),r)}if(e.eq(re.MIN_VALUE))return this.unsigned?re.UZERO:re.ZERO;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();r=re.ZERO}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));const i=Math.ceil(Math.log(t)/Math.LN2),o=i&lt;=48?1:Math.pow(2,i-48);let s=re.fromNumber(t),u=s.mul(e);for(;u.isNegative()||u.gt(n);)t-=o,s=re.fromNumber(t,this.unsigned),u=s.mul(e);s.isZero()&amp;&amp;(s=re.ONE),r=r.add(s),n=n.sub(u)}return r}div(e){return this.divide(e)}equals(e){return re.isLong(e)||(e=re.fromValue(e)),(this.unsigned===e.unsigned||this.high&gt;&gt;&gt;31!==1||e.high&gt;&gt;&gt;31!==1)&amp;&amp;(this.high===e.high&amp;&amp;this.low===e.low)}eq(e){return this.equals(e)}getHighBits(){return this.high}getHighBitsUnsigned(){return this.high&gt;&gt;&gt;0}getLowBits(){return this.low}getLowBitsUnsigned(){return this.low&gt;&gt;&gt;0}getNumBitsAbs(){if(this.isNegative())return this.eq(re.MIN_VALUE)?64:this.neg().getNumBitsAbs();const e=0!==this.high?this.high:this.low;let t;for(t=31;t&gt;0&amp;&amp;0===(e&amp;1&lt;&lt;t);t--);return 0!==this.high?t+33:t+1}greaterThan(e){return this.comp(e)&gt;0}gt(e){return this.greaterThan(e)}greaterThanOrEqual(e){return this.comp(e)&gt;=0}gte(e){return this.greaterThanOrEqual(e)}ge(e){return this.greaterThanOrEqual(e)}isEven(){return 0===(1&amp;this.low)}isNegative(){return!this.unsigned&amp;&amp;this.high&lt;0}isOdd(){return 1===(1&amp;this.low)}isPositive(){return this.unsigned||this.high&gt;=0}isZero(){return 0===this.high&amp;&amp;0===this.low}lessThan(e){return this.comp(e)&lt;0}lt(e){return this.lessThan(e)}lessThanOrEqual(e){return this.comp(e)&lt;=0}lte(e){return this.lessThanOrEqual(e)}modulo(e){if(re.isLong(e)||(e=re.fromValue(e)),W){const t=(this.unsigned?W.rem_u:W.rem_s)(this.low,this.high,e.low,e.high);return re.fromBits(t,W.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))}mod(e){return this.modulo(e)}rem(e){return this.modulo(e)}multiply(e){if(this.isZero())return re.ZERO;if(re.isLong(e)||(e=re.fromValue(e)),W){const t=W.mul(this.low,this.high,e.low,e.high);return re.fromBits(t,W.get_high(),this.unsigned)}if(e.isZero())return re.ZERO;if(this.eq(re.MIN_VALUE))return e.isOdd()?re.MIN_VALUE:re.ZERO;if(e.eq(re.MIN_VALUE))return this.isOdd()?re.MIN_VALUE:re.ZERO;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(re.TWO_PWR_24)&amp;&amp;e.lt(re.TWO_PWR_24))return re.fromNumber(this.toNumber()*e.toNumber(),this.unsigned);const t=this.high&gt;&gt;&gt;16,n=65535&amp;this.high,r=this.low&gt;&gt;&gt;16,i=65535&amp;this.low,o=e.high&gt;&gt;&gt;16,s=65535&amp;e.high,u=e.low&gt;&gt;&gt;16,f=65535&amp;e.low;let l=0,a=0,h=0,c=0;return c+=i*f,h+=c&gt;&gt;&gt;16,c&amp;=65535,h+=r*f,a+=h&gt;&gt;&gt;16,h&amp;=65535,h+=i*u,a+=h&gt;&gt;&gt;16,h&amp;=65535,a+=n*f,l+=a&gt;&gt;&gt;16,a&amp;=65535,a+=r*u,l+=a&gt;&gt;&gt;16,a&amp;=65535,a+=i*s,l+=a&gt;&gt;&gt;16,a&amp;=65535,l+=t*f+n*u+r*s+i*o,l&amp;=65535,re.fromBits(h&lt;&lt;16|c,l&lt;&lt;16|a,this.unsigned)}mul(e){return this.multiply(e)}negate(){return!this.unsigned&amp;&amp;this.eq(re.MIN_VALUE)?re.MIN_VALUE:this.not().add(re.ONE)}neg(){return this.negate()}not(){return re.fromBits(~this.low,~this.high,this.unsigned)}notEquals(e){return!this.equals(e)}neq(e){return this.notEquals(e)}ne(e){return this.notEquals(e)}or(e){return re.isLong(e)||(e=re.fromValue(e)),re.fromBits(this.low|e.low,this.high|e.high,this.unsigned)}shiftLeft(e){return re.isLong(e)&amp;&amp;(e=e.toInt()),0===(e&amp;=63)?this:e&lt;32?re.fromBits(this.low&lt;&lt;e,this.high&lt;&lt;e|this.low&gt;&gt;&gt;32-e,this.unsigned):re.fromBits(0,this.low&lt;&lt;e-32,this.unsigned)}shl(e){return this.shiftLeft(e)}shiftRight(e){return re.isLong(e)&amp;&amp;(e=e.toInt()),0===(e&amp;=63)?this:e&lt;32?re.fromBits(this.low&gt;&gt;&gt;e|this.high&lt;&lt;32-e,this.high&gt;&gt;e,this.unsigned):re.fromBits(this.high&gt;&gt;e-32,this.high&gt;=0?0:-1,this.unsigned)}shr(e){return this.shiftRight(e)}shiftRightUnsigned(e){if(re.isLong(e)&amp;&amp;(e=e.toInt()),0===(e&amp;=63))return this;{const t=this.high;if(e&lt;32){const n=this.low;return re.fromBits(n&gt;&gt;&gt;e|t&lt;&lt;32-e,t&gt;&gt;&gt;e,this.unsigned)}return 32===e?re.fromBits(t,0,this.unsigned):re.fromBits(t&gt;&gt;&gt;e-32,0,this.unsigned)}}shr_u(e){return this.shiftRightUnsigned(e)}shru(e){return this.shiftRightUnsigned(e)}subtract(e){return re.isLong(e)||(e=re.fromValue(e)),this.add(e.neg())}sub(e){return this.subtract(e)}toInt(){return this.unsigned?this.low&gt;&gt;&gt;0:this.low}toNumber(){return this.unsigned?(this.high&gt;&gt;&gt;0)*G+(this.low&gt;&gt;&gt;0):this.high*G+(this.low&gt;&gt;&gt;0)}toBigInt(){return BigInt(this.toString())}toBytes(e){return e?this.toBytesLE():this.toBytesBE()}toBytesLE(){const e=this.high,t=this.low;return[255&amp;t,t&gt;&gt;&gt;8&amp;255,t&gt;&gt;&gt;16&amp;255,t&gt;&gt;&gt;24,255&amp;e,e&gt;&gt;&gt;8&amp;255,e&gt;&gt;&gt;16&amp;255,e&gt;&gt;&gt;24]}toBytesBE(){const e=this.high,t=this.low;return[e&gt;&gt;&gt;24,e&gt;&gt;&gt;16&amp;255,e&gt;&gt;&gt;8&amp;255,255&amp;e,t&gt;&gt;&gt;24,t&gt;&gt;&gt;16&amp;255,t&gt;&gt;&gt;8&amp;255,255&amp;t]}toSigned(){return this.unsigned?re.fromBits(this.low,this.high,!1):this}toString(e){if((e=e||10)&lt;2||36&lt;e)throw new I("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(re.MIN_VALUE)){const t=re.fromNumber(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}const t=re.fromNumber(Math.pow(e,6),this.unsigned);let n=this,r="";for(;;){const i=n.div(t);let o=(n.sub(i.mul(t)).toInt()&gt;&gt;&gt;0).toString(e);if(n=i,n.isZero())return o+r;for(;o.length&lt;6;)o="0"+o;r=""+o+r}}toUnsigned(){return this.unsigned?this:re.fromBits(this.low,this.high,!0)}xor(e){return re.isLong(e)||(e=re.fromValue(e)),re.fromBits(this.low^e.low,this.high^e.high,this.unsigned)}eqz(){return this.isZero()}le(e){return this.lessThanOrEqual(e)}toExtendedJSON(e){return e&amp;&amp;e.relaxed?this.toNumber():{$numberLong:this.toString()}}static fromExtendedJSON(e,t){const{useBigInt64:n=!1,relaxed:r=!0}={...t};if(e.$numberLong.length&gt;20)throw new I("$numberLong string is too long");if(!ne.test(e.$numberLong))throw new I(`$numberLong string "${e.$numberLong}" is in an invalid format`);if(n){const t=BigInt(e.$numberLong);return BigInt.asIntN(64,t)}const i=re.fromString(e.$numberLong);return r?i.toNumber():i}inspect(e,t,n){n??=m;return`new Long(${n(this.toString(),t)}${this.unsigned?`, ${n(this.unsigned,t)}`:""})`}}re.TWO_PWR_24=re.fromInt(1&lt;&lt;24),re.MAX_UNSIGNED_VALUE=re.fromBits(-1,-1,!0),re.ZERO=re.fromInt(0),re.UZERO=re.fromInt(0,!0),re.ONE=re.fromInt(1),re.UONE=re.fromInt(1,!0),re.NEG_ONE=re.fromInt(-1),re.MAX_VALUE=re.fromBits(-1,2147483647,!1),re.MIN_VALUE=re.fromBits(0,-2147483648,!1);const ie=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,oe=/^(\+|-)?(Infinity|inf)$/i,se=/^(\+|-)?NaN$/i,ue=6111,fe=-6176,le=J.fromNumberArray([124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),ae=J.fromNumberArray([248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),he=J.fromNumberArray([120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),ce=/^([-+])?(\d+)?$/;function ge(e){return!isNaN(parseInt(e,10))}function be(e){const t=re.fromNumber(1e9);let n=re.fromNumber(0);if(!e.parts[0]&amp;&amp;!e.parts[1]&amp;&amp;!e.parts[2]&amp;&amp;!e.parts[3])return{quotient:e,rem:n};for(let r=0;r&lt;=3;r++)n=n.shiftLeft(32),n=n.add(new re(e.parts[r],0)),e.parts[r]=n.div(t).low,n=n.modulo(t);return{quotient:e,rem:n}}function de(e,t){throw new I(`"${e}" is not a valid Decimal128 string - ${t}`)}class pe extends V{get _bsontype(){return"Decimal128"}constructor(e){if(super(),"string"===typeof e)this.bytes=pe.fromString(e).bytes;else{if(!(e instanceof Uint8Array||g(e)))throw new I("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new I("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}static fromString(e){return pe._fromString(e,{allowRounding:!1})}static fromStringWithRounding(e){return pe._fromString(e,{allowRounding:!0})}static _fromString(e,t){let n=!1,r=!1,i=!1,o=!1,s=0,u=0,f=0,l=0,a=0;const h=[0];let c=0,g=0,b=0,d=0,p=new re(0,0),m=new re(0,0),y=0,w=0;if(e.length&gt;=7e3)throw new I(e+" not a valid Decimal128 string");const S=e.match(ie),B=e.match(oe),N=e.match(se);if(!S&amp;&amp;!B&amp;&amp;!N||0===e.length)throw new I(e+" not a valid Decimal128 string");if(S){const t=S[2],n=S[4],r=S[5],i=S[6];n&amp;&amp;void 0===i&amp;&amp;de(e,"missing exponent power"),n&amp;&amp;void 0===t&amp;&amp;de(e,"missing exponent base"),void 0===n&amp;&amp;(r||i)&amp;&amp;de(e,"missing e before exponent")}if("+"!==e[w]&amp;&amp;"-"!==e[w]||(r=!0,n="-"===e[w++]),!ge(e[w])&amp;&amp;"."!==e[w]){if("i"===e[w]||"I"===e[w])return new pe(n?ae:he);if("N"===e[w])return new pe(le)}for(;ge(e[w])||"."===e[w];)"."!==e[w]?(c&lt;34&amp;&amp;("0"!==e[w]||o)&amp;&amp;(o||(a=u),o=!0,h[g++]=parseInt(e[w],10),c+=1),o&amp;&amp;(f+=1),i&amp;&amp;(l+=1),u+=1,w+=1):(i&amp;&amp;de(e,"contains multiple periods"),i=!0,w+=1);if(i&amp;&amp;!u)throw new I(e+" not a valid Decimal128 string");if("e"===e[w]||"E"===e[w]){const t=e.substr(++w).match(ce);if(!t||!t[2])return new pe(le);d=parseInt(t[0],10),w+=t[0].length}if(e[w])return new pe(le);if(c){if(b=c-1,s=f,1!==s)for(;"0"===e[a+s-1+Number(r)+Number(i)];)s-=1}else h[0]=0,f=1,c=1,s=0;for(d&lt;=l&amp;&amp;l&gt;d+16384?d=fe:d-=l;d&gt;ue;){if(b+=1,b&gt;=34){if(0===s){d=ue;break}de(e,"overflow")}d-=1}if(t.allowRounding){for(;d&lt;fe||c&lt;f;){if(0===b&amp;&amp;s&lt;c){d=fe,s=0;break}if(c&lt;f?f-=1:b-=1,d&lt;ue)d+=1;else{if(h.join("").match(/^0+$/)){d=ue;break}de(e,"overflow")}}if(b+1&lt;s){let t=u;i&amp;&amp;(a+=1,t+=1),r&amp;&amp;(a+=1,t+=1);const o=parseInt(e[a+b+1],10);let s=0;if(o&gt;=5&amp;&amp;(s=1,5===o)){s=h[b]%2===1?1:0;for(let n=a+b+2;n&lt;t;n++)if(parseInt(e[n],10)){s=1;break}}if(s){let e=b;for(;e&gt;=0&amp;&amp;++h[e]&gt;9;e--)if(h[e]=0,0===e){if(!(d&lt;ue))return new pe(n?ae:he);d+=1,h[e]=1}}}}else{for(;d&lt;fe||c&lt;f;){if(0===b){if(0===s){d=fe;break}de(e,"exponent underflow")}c&lt;f?("0"!==e[f-1+Number(r)+Number(i)]&amp;&amp;0!==s&amp;&amp;de(e,"inexact rounding"),f-=1):(0!==h[b]&amp;&amp;de(e,"inexact rounding"),b-=1),d&lt;ue?d+=1:de(e,"overflow")}if(b+1&lt;s){i&amp;&amp;(a+=1),r&amp;&amp;(a+=1);0!==parseInt(e[a+b+1],10)&amp;&amp;de(e,"inexact rounding")}}if(p=re.fromNumber(0),m=re.fromNumber(0),0===s)p=re.fromNumber(0),m=re.fromNumber(0);else if(b&lt;17){let e=0;for(m=re.fromNumber(h[e++]),p=new re(0,0);e&lt;=b;e++)m=m.multiply(re.fromNumber(10)),m=m.add(re.fromNumber(h[e]))}else{let e=0;for(p=re.fromNumber(h[e++]);e&lt;=b-17;e++)p=p.multiply(re.fromNumber(10)),p=p.add(re.fromNumber(h[e]));for(m=re.fromNumber(h[e++]);e&lt;=b;e++)m=m.multiply(re.fromNumber(10)),m=m.add(re.fromNumber(h[e]))}const E=function(e,t){if(!e&amp;&amp;!t)return{high:re.fromNumber(0),low:re.fromNumber(0)};const n=e.shiftRightUnsigned(32),r=new re(e.getLowBits(),0),i=t.shiftRightUnsigned(32),o=new re(t.getLowBits(),0);let s=n.multiply(i),u=n.multiply(o);const f=r.multiply(i);let l=r.multiply(o);return s=s.add(u.shiftRightUnsigned(32)),u=new re(u.getLowBits(),0).add(f).add(l.shiftRightUnsigned(32)),s=s.add(u.shiftRightUnsigned(32)),l=u.shiftLeft(32).add(new re(l.getLowBits(),0)),{high:s,low:l}}(p,re.fromString("100000000000000000"));E.low=E.low.add(m),function(e,t){const n=e.high&gt;&gt;&gt;0,r=t.high&gt;&gt;&gt;0;if(n&lt;r)return!0;if(n===r&amp;&amp;e.low&gt;&gt;&gt;0&lt;t.low&gt;&gt;&gt;0)return!0;return!1}(E.low,m)&amp;&amp;(E.high=E.high.add(re.fromNumber(1))),y=d+6176;const x={low:re.fromNumber(0),high:re.fromNumber(0)};E.high.shiftRightUnsigned(49).and(re.fromNumber(1)).equals(re.fromNumber(1))?(x.high=x.high.or(re.fromNumber(3).shiftLeft(61)),x.high=x.high.or(re.fromNumber(y).and(re.fromNumber(16383).shiftLeft(47))),x.high=x.high.or(E.high.and(re.fromNumber(0x7fffffffffff)))):(x.high=x.high.or(re.fromNumber(16383&amp;y).shiftLeft(49)),x.high=x.high.or(E.high.and(re.fromNumber(562949953421311)))),x.low=E.low,n&amp;&amp;(x.high=x.high.or(re.fromString("9223372036854775808")));const O=J.allocateUnsafe(16);return w=0,O[w++]=255&amp;x.low.low,O[w++]=x.low.low&gt;&gt;8&amp;255,O[w++]=x.low.low&gt;&gt;16&amp;255,O[w++]=x.low.low&gt;&gt;24&amp;255,O[w++]=255&amp;x.low.high,O[w++]=x.low.high&gt;&gt;8&amp;255,O[w++]=x.low.high&gt;&gt;16&amp;255,O[w++]=x.low.high&gt;&gt;24&amp;255,O[w++]=255&amp;x.high.low,O[w++]=x.high.low&gt;&gt;8&amp;255,O[w++]=x.high.low&gt;&gt;16&amp;255,O[w++]=x.high.low&gt;&gt;24&amp;255,O[w++]=255&amp;x.high.high,O[w++]=x.high.high&gt;&gt;8&amp;255,O[w++]=x.high.high&gt;&gt;16&amp;255,O[w++]=x.high.high&gt;&gt;24&amp;255,new pe(O)}toString(){let e,t=0;const n=new Array(36);for(let y=0;y&lt;n.length;y++)n[y]=0;let r,i,o,s=0,u=!1,f={parts:[0,0,0,0]};const l=[];s=0;const a=this.bytes,h=a[s++]|a[s++]&lt;&lt;8|a[s++]&lt;&lt;16|a[s++]&lt;&lt;24,c=a[s++]|a[s++]&lt;&lt;8|a[s++]&lt;&lt;16|a[s++]&lt;&lt;24,g=a[s++]|a[s++]&lt;&lt;8|a[s++]&lt;&lt;16|a[s++]&lt;&lt;24,b=a[s++]|a[s++]&lt;&lt;8|a[s++]&lt;&lt;16|a[s++]&lt;&lt;24;s=0;({low:new re(h,c),high:new re(g,b)}).high.lessThan(re.ZERO)&amp;&amp;l.push("-");const d=b&gt;&gt;26&amp;31;if(d&gt;&gt;3===3){if(30===d)return l.join("")+"Infinity";if(31===d)return"NaN";e=b&gt;&gt;15&amp;16383,r=8+(b&gt;&gt;14&amp;1)}else r=b&gt;&gt;14&amp;7,e=b&gt;&gt;17&amp;16383;const p=e-6176;if(f.parts[0]=(16383&amp;b)+((15&amp;r)&lt;&lt;14),f.parts[1]=g,f.parts[2]=c,f.parts[3]=h,0===f.parts[0]&amp;&amp;0===f.parts[1]&amp;&amp;0===f.parts[2]&amp;&amp;0===f.parts[3])u=!0;else for(o=3;o&gt;=0;o--){let e=0;const t=be(f);if(f=t.quotient,e=t.rem.low,e)for(i=8;i&gt;=0;i--)n[9*o+i]=e%10,e=Math.floor(e/10)}if(u)t=1,n[s]=0;else for(t=36;!n[s];)t-=1,s+=1;const m=t-1+p;if(m&gt;=34||m&lt;=-7||p&gt;0){if(t&gt;34)return l.push("0"),p&gt;0?l.push(`E+${p}`):p&lt;0&amp;&amp;l.push(`E${p}`),l.join("");l.push(`${n[s++]}`),t-=1,t&amp;&amp;l.push(".");for(let e=0;e&lt;t;e++)l.push(`${n[s++]}`);l.push("E"),m&gt;0?l.push(`+${m}`):l.push(`${m}`)}else if(p&gt;=0)for(let y=0;y&lt;t;y++)l.push(`${n[s++]}`);else{let e=t+p;if(e&gt;0)for(let t=0;t&lt;e;t++)l.push(`${n[s++]}`);else l.push("0");for(l.push(".");e++&lt;0;)l.push("0");for(let r=0;r&lt;t-Math.max(e-1,0);r++)l.push(`${n[s++]}`)}return l.join("")}toJSON(){return{$numberDecimal:this.toString()}}toExtendedJSON(){return{$numberDecimal:this.toString()}}static fromExtendedJSON(e){return pe.fromString(e.$numberDecimal)}inspect(e,t,n){n??=m;return`new Decimal128(${n(this.toString(),t)})`}}class me extends V{get _bsontype(){return"Double"}constructor(e){super(),e instanceof Number&amp;&amp;(e=e.valueOf()),this.value=+e}static fromString(e){const t=Number(e);if("NaN"===e)return new me(NaN);if("Infinity"===e)return new me(1/0);if("-Infinity"===e)return new me(-1/0);if(!Number.isFinite(t))throw new I(`Input: ${e} is not representable as a Double`);if(e.trim()!==e)throw new I(`Input: '${e}' contains whitespace`);if(""===e)throw new I("Input is an empty string");if(/[^-0-9.+eE]/.test(e))throw new I(`Input: '${e}' is not in decimal or exponential notation`);return new me(t)}valueOf(){return this.value}toJSON(){return this.value}toString(e){return this.value.toString(e)}toExtendedJSON(e){return e&amp;&amp;(e.legacy||e.relaxed&amp;&amp;isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-0.0"}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}}static fromExtendedJSON(e,t){const n=parseFloat(e.$numberDouble);return t&amp;&amp;t.relaxed?n:new me(n)}inspect(e,t,n){return n??=m,`new Double(${n(this.value,t)})`}}class ye extends V{get _bsontype(){return"Int32"}constructor(e){super(),e instanceof Number&amp;&amp;(e=e.valueOf()),this.value=0|+e}static fromString(e){const t=K(e),n=Number(e);if(w&lt;n)throw new I(`Input: '${e}' is larger than the maximum value for Int32`);if(S&gt;n)throw new I(`Input: '${e}' is smaller than the minimum value for Int32`);if(!Number.isSafeInteger(n))throw new I(`Input: '${e}' is not a safe integer`);if(n.toString()!==t)throw new I(`Input: '${e}' is not a valid Int32 string`);return new ye(n)}valueOf(){return this.value}toString(e){return this.value.toString(e)}toJSON(){return this.value}toExtendedJSON(e){return e&amp;&amp;(e.relaxed||e.legacy)?this.value:{$numberInt:this.value.toString()}}static fromExtendedJSON(e,t){return t&amp;&amp;t.relaxed?parseInt(e.$numberInt,10):new ye(e.$numberInt)}inspect(e,t,n){return n??=m,`new Int32(${n(this.value,t)})`}}class we extends V{get _bsontype(){return"MaxKey"}toExtendedJSON(){return{$maxKey:1}}static fromExtendedJSON(){return new we}inspect(){return"new MaxKey()"}}class Se extends V{get _bsontype(){return"MinKey"}toExtendedJSON(){return{$minKey:1}}static fromExtendedJSON(){return new Se}inspect(){return"new MinKey()"}}const Be=new Float64Array(1),Ne=new Uint8Array(Be.buffer,0,8);Be[0]=-1;const Ee=0===Ne[7],xe={getNonnegativeInt32LE(e,t){if(e[t+3]&gt;127)throw new RangeError(`Size cannot be negative at offset: ${t}`);return e[t]|e[t+1]&lt;&lt;8|e[t+2]&lt;&lt;16|e[t+3]&lt;&lt;24},getInt32LE:(e,t)=&gt;e[t]|e[t+1]&lt;&lt;8|e[t+2]&lt;&lt;16|e[t+3]&lt;&lt;24,getUint32LE:(e,t)=&gt;e[t]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3],getUint32BE:(e,t)=&gt;e[t+3]+256*e[t+2]+65536*e[t+1]+16777216*e[t],getBigInt64LE(e,t){const n=xe.getUint32LE(e,t),r=xe.getUint32LE(e,t+4);return(BigInt(r)&lt;&lt;BigInt(32))+BigInt(n)},getFloat64LE:Ee?(e,t)=&gt;(Ne[7]=e[t],Ne[6]=e[t+1],Ne[5]=e[t+2],Ne[4]=e[t+3],Ne[3]=e[t+4],Ne[2]=e[t+5],Ne[1]=e[t+6],Ne[0]=e[t+7],Be[0]):(e,t)=&gt;(Ne[0]=e[t],Ne[1]=e[t+1],Ne[2]=e[t+2],Ne[3]=e[t+3],Ne[4]=e[t+4],Ne[5]=e[t+5],Ne[6]=e[t+6],Ne[7]=e[t+7],Be[0]),setInt32BE:(e,t,n)=&gt;(e[t+3]=n,n&gt;&gt;&gt;=8,e[t+2]=n,n&gt;&gt;&gt;=8,e[t+1]=n,n&gt;&gt;&gt;=8,e[t]=n,4),setInt32LE:(e,t,n)=&gt;(e[t]=n,n&gt;&gt;&gt;=8,e[t+1]=n,n&gt;&gt;&gt;=8,e[t+2]=n,n&gt;&gt;&gt;=8,e[t+3]=n,4),setBigInt64LE(e,t,n){const r=BigInt(4294967295);let i=Number(n&amp;r);e[t]=i,i&gt;&gt;=8,e[t+1]=i,i&gt;&gt;=8,e[t+2]=i,i&gt;&gt;=8,e[t+3]=i;let o=Number(n&gt;&gt;BigInt(32)&amp;r);return e[t+4]=o,o&gt;&gt;=8,e[t+5]=o,o&gt;&gt;=8,e[t+6]=o,o&gt;&gt;=8,e[t+7]=o,8},setFloat64LE:Ee?(e,t,n)=&gt;(Be[0]=n,e[t]=Ne[7],e[t+1]=Ne[6],e[t+2]=Ne[5],e[t+3]=Ne[4],e[t+4]=Ne[3],e[t+5]=Ne[2],e[t+6]=Ne[1],e[t+7]=Ne[0],8):(e,t,n)=&gt;(Be[0]=n,e[t]=Ne[0],e[t+1]=Ne[1],e[t+2]=Ne[2],e[t+3]=Ne[3],e[t+4]=Ne[4],e[t+5]=Ne[5],e[t+6]=Ne[6],e[t+7]=Ne[7],8)};let Oe=null;class Ie extends V{get _bsontype(){return"ObjectId"}constructor(e){let t;if(super(),"object"===typeof e&amp;&amp;e&amp;&amp;"id"in e){if("string"!==typeof e.id&amp;&amp;!ArrayBuffer.isView(e.id))throw new I("Argument passed in must have an id that is of type string or Buffer");t="toHexString"in e&amp;&amp;"function"===typeof e.toHexString?J.fromHex(e.toHexString()):e.id}else t=e;if(null==t||"number"===typeof t)this.buffer=Ie.generate("number"===typeof t?t:void 0);else if(ArrayBuffer.isView(t)&amp;&amp;12===t.byteLength)this.buffer=J.toLocalBufferType(t);else{if("string"!==typeof t)throw new I("Argument passed in does not match the accepted types");if(!Ie.validateHexString(t))throw new I("input must be a 24 character hex string, 12 byte Uint8Array, or an integer");this.buffer=J.fromHex(t)}Ie.cacheHexString&amp;&amp;(this.__id=J.toHex(this.id))}get id(){return this.buffer}set id(e){this.buffer=e,Ie.cacheHexString&amp;&amp;(this.__id=J.toHex(e))}static validateHexString(e){if(24!==e?.length)return!1;for(let t=0;t&lt;24;t++){const n=e.charCodeAt(t);if(!(n&gt;=48&amp;&amp;n&lt;=57||n&gt;=97&amp;&amp;n&lt;=102||n&gt;=65&amp;&amp;n&lt;=70))return!1}return!0}toHexString(){if(Ie.cacheHexString&amp;&amp;this.__id)return this.__id;const e=J.toHex(this.id);return Ie.cacheHexString&amp;&amp;!this.__id&amp;&amp;(this.__id=e),e}static getInc(){return Ie.index=(Ie.index+1)%16777215}static generate(e){"number"!==typeof e&amp;&amp;(e=Math.floor(Date.now()/1e3));const t=Ie.getInc(),n=J.allocateUnsafe(12);return xe.setInt32BE(n,0,e),null===Oe&amp;&amp;(Oe=J.randomBytes(5)),n[4]=Oe[0],n[5]=Oe[1],n[6]=Oe[2],n[7]=Oe[3],n[8]=Oe[4],n[11]=255&amp;t,n[10]=t&gt;&gt;8&amp;255,n[9]=t&gt;&gt;16&amp;255,n}toString(e){return"base64"===e?J.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}static is(e){return null!=e&amp;&amp;"object"===typeof e&amp;&amp;"_bsontype"in e&amp;&amp;"ObjectId"===e._bsontype}equals(e){if(void 0===e||null===e)return!1;if(Ie.is(e))return this.buffer[11]===e.buffer[11]&amp;&amp;J.equals(this.buffer,e.buffer);if("string"===typeof e)return e.toLowerCase()===this.toHexString();if("object"===typeof e&amp;&amp;"function"===typeof e.toHexString){const t=e.toHexString(),n=this.toHexString();return"string"===typeof t&amp;&amp;t.toLowerCase()===n}return!1}getTimestamp(){const e=new Date,t=xe.getUint32BE(this.buffer,0);return e.setTime(1e3*Math.floor(t)),e}static createPk(){return new Ie}serializeInto(e,t){return e[t]=this.buffer[0],e[t+1]=this.buffer[1],e[t+2]=this.buffer[2],e[t+3]=this.buffer[3],e[t+4]=this.buffer[4],e[t+5]=this.buffer[5],e[t+6]=this.buffer[6],e[t+7]=this.buffer[7],e[t+8]=this.buffer[8],e[t+9]=this.buffer[9],e[t+10]=this.buffer[10],e[t+11]=this.buffer[11],12}static createFromTime(e){const t=J.allocate(12);for(let n=11;n&gt;=4;n--)t[n]=0;return xe.setInt32BE(t,0,e),new Ie(t)}static createFromHexString(e){if(24!==e?.length)throw new I("hex string must be 24 characters");return new Ie(J.fromHex(e))}static createFromBase64(e){if(16!==e?.length)throw new I("base64 string must be 16 characters");return new Ie(J.fromBase64(e))}static isValid(e){if(null==e)return!1;if("string"===typeof e)return Ie.validateHexString(e);try{return new Ie(e),!0}catch{return!1}}toExtendedJSON(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}static fromExtendedJSON(e){return new Ie(e.$oid)}inspect(e,t,n){return n??=m,`new ObjectId(${n(this.toHexString(),t)})`}}function $e(e,t,n){let r=5;if(Array.isArray(e))for(let i=0;i&lt;e.length;i++)r+=_e(i.toString(),e[i],t,!0,n);else{"function"===typeof e?.toBSON&amp;&amp;(e=e.toBSON());for(const i of Object.keys(e))r+=_e(i,e[i],t,!1,n)}return r}function _e(e,t,n=!1,r=!1,i=!1){switch("function"===typeof t?.toBSON&amp;&amp;(t=t.toBSON()),typeof t){case"string":return 1+J.utf8ByteLength(e)+1+4+J.utf8ByteLength(t)+1;case"number":return Math.floor(t)===t&amp;&amp;t&gt;=x&amp;&amp;t&lt;=E&amp;&amp;t&gt;=S&amp;&amp;t&lt;=w?(null!=e?J.utf8ByteLength(e)+1:0)+5:(null!=e?J.utf8ByteLength(e)+1:0)+9;case"undefined":return r||!i?(null!=e?J.utf8ByteLength(e)+1:0)+1:0;case"boolean":return(null!=e?J.utf8ByteLength(e)+1:0)+2;case"object":if(null!=t&amp;&amp;"string"===typeof t._bsontype&amp;&amp;6!==t[y])throw new $;if(null==t||"MinKey"===t._bsontype||"MaxKey"===t._bsontype)return(null!=e?J.utf8ByteLength(e)+1:0)+1;if("ObjectId"===t._bsontype)return(null!=e?J.utf8ByteLength(e)+1:0)+13;if(t instanceof Date||p(t))return(null!=e?J.utf8ByteLength(e)+1:0)+9;if(ArrayBuffer.isView(t)||t instanceof ArrayBuffer||c(t))return(null!=e?J.utf8ByteLength(e)+1:0)+6+t.byteLength;if("Long"===t._bsontype||"Double"===t._bsontype||"Timestamp"===t._bsontype)return(null!=e?J.utf8ByteLength(e)+1:0)+9;if("Decimal128"===t._bsontype)return(null!=e?J.utf8ByteLength(e)+1:0)+17;if("Code"===t._bsontype)return null!=t.scope&amp;&amp;Object.keys(t.scope).length&gt;0?(null!=e?J.utf8ByteLength(e)+1:0)+1+4+4+J.utf8ByteLength(t.code.toString())+1+$e(t.scope,n,i):(null!=e?J.utf8ByteLength(e)+1:0)+1+4+J.utf8ByteLength(t.code.toString())+1;if("Binary"===t._bsontype){const n=t;return n.sub_type===C.SUBTYPE_BYTE_ARRAY?(null!=e?J.utf8ByteLength(e)+1:0)+(n.position+1+4+1+4):(null!=e?J.utf8ByteLength(e)+1:0)+(n.position+1+4+1)}if("Symbol"===t._bsontype)return(null!=e?J.utf8ByteLength(e)+1:0)+J.utf8ByteLength(t.value)+4+1+1;if("DBRef"===t._bsontype){const r=Object.assign({$ref:t.collection,$id:t.oid},t.fields);return null!=t.db&amp;&amp;(r.$db=t.db),(null!=e?J.utf8ByteLength(e)+1:0)+1+$e(r,n,i)}return t instanceof RegExp||b(t)?(null!=e?J.utf8ByteLength(e)+1:0)+1+J.utf8ByteLength(t.source)+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1:"BSONRegExp"===t._bsontype?(null!=e?J.utf8ByteLength(e)+1:0)+1+J.utf8ByteLength(t.pattern)+1+J.utf8ByteLength(t.options)+1:(null!=e?J.utf8ByteLength(e)+1:0)+$e(t,n,i)+1;case"function":if(n)return(null!=e?J.utf8ByteLength(e)+1:0)+1+4+J.utf8ByteLength(t.toString())+1}return 0}Ie.index=Math.floor(16777215*Math.random());class Le extends V{get _bsontype(){return"BSONRegExp"}constructor(e,t){if(super(),this.pattern=e,this.options=(t??"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new I(`BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}`);if(-1!==this.options.indexOf("\0"))throw new I(`BSON Regex options cannot contain null bytes, found: ${JSON.stringify(this.options)}`);for(let n=0;n&lt;this.options.length;n++)if("i"!==this.options[n]&amp;&amp;"m"!==this.options[n]&amp;&amp;"x"!==this.options[n]&amp;&amp;"l"!==this.options[n]&amp;&amp;"s"!==this.options[n]&amp;&amp;"u"!==this.options[n])throw new I(`The regular expression option [${this.options[n]}] is not supported`)}static parseOptions(e){return e?e.split("").sort().join(""):""}toExtendedJSON(e){return(e=e||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}}static fromExtendedJSON(e){if("$regex"in e){if("string"===typeof e.$regex)return new Le(e.$regex,Le.parseOptions(e.$options));if("BSONRegExp"===e.$regex._bsontype)return e}if("$regularExpression"in e)return new Le(e.$regularExpression.pattern,Le.parseOptions(e.$regularExpression.options));throw new I(`Unexpected BSONRegExp EJSON object form: ${JSON.stringify(e)}`)}inspect(e,t,n){const r=function(e){if(null!=e&amp;&amp;"object"===typeof e&amp;&amp;"stylize"in e&amp;&amp;"function"===typeof e.stylize)return e.stylize}(t)??(e=&gt;e);n??=m;return`new BSONRegExp(${r(n(this.pattern),"regexp")}, ${r(n(this.options),"regexp")})`}}class Ue extends V{get _bsontype(){return"BSONSymbol"}constructor(e){super(),this.value=e}valueOf(){return this.value}toString(){return this.value}toJSON(){return this.value}toExtendedJSON(){return{$symbol:this.value}}static fromExtendedJSON(e){return new Ue(e.$symbol)}inspect(e,t,n){return n??=m,`new BSONSymbol(${n(this.value,t)})`}}const Te=re;class ve extends Te{get _bsontype(){return"Timestamp"}get i(){return this.low&gt;&gt;&gt;0}get t(){return this.high&gt;&gt;&gt;0}constructor(e){if(null==e)super(0,0,!0);else if("bigint"===typeof e)super(e,!0);else if(re.isLong(e))super(e.low,e.high,!0);else{if("object"!==typeof e||!("t"in e)||!("i"in e))throw new I("A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }");{if("number"!==typeof e.t&amp;&amp;("object"!==typeof e.t||"Int32"!==e.t._bsontype))throw new I("Timestamp constructed from { t, i } must provide t as a number");if("number"!==typeof e.i&amp;&amp;("object"!==typeof e.i||"Int32"!==e.i._bsontype))throw new I("Timestamp constructed from { t, i } must provide i as a number");const t=Number(e.t),n=Number(e.i);if(t&lt;0||Number.isNaN(t))throw new I("Timestamp constructed from { t, i } must provide a positive t");if(n&lt;0||Number.isNaN(n))throw new I("Timestamp constructed from { t, i } must provide a positive i");if(t&gt;4294967295)throw new I("Timestamp constructed from { t, i } must provide t equal or less than uint32 max");if(n&gt;4294967295)throw new I("Timestamp constructed from { t, i } must provide i equal or less than uint32 max");super(n,t,!0)}}}toJSON(){return{$timestamp:this.toString()}}static fromInt(e){return new ve(re.fromInt(e,!0))}static fromNumber(e){return new ve(re.fromNumber(e,!0))}static fromBits(e,t){return new ve({i:e,t:t})}static fromString(e,t){return new ve(re.fromString(e,!0,t))}toExtendedJSON(){return{$timestamp:{t:this.t,i:this.i}}}static fromExtendedJSON(e){const t=re.isLong(e.$timestamp.i)?e.$timestamp.i.getLowBitsUnsigned():e.$timestamp.i,n=re.isLong(e.$timestamp.t)?e.$timestamp.t.getLowBitsUnsigned():e.$timestamp.t;return new ve({t:n,i:t})}inspect(e,t,n){n??=m;return`new Timestamp({ t: ${n(this.t,t)}, i: ${n(this.i,t)} })`}}ve.MAX_VALUE=re.MAX_UNSIGNED_VALUE;const Ae=re.fromNumber(E),je=re.fromNumber(x);function Re(e,t,n){const r=(t=null==t?{}:t)&amp;&amp;t.index?t.index:0,i=xe.getInt32LE(e,r);if(i&lt;5)throw new I(`bson size must be &gt;= 5, is ${i}`);if(t.allowObjectSmallerThanBufferSize&amp;&amp;e.length&lt;i)throw new I(`buffer length ${e.length} must be &gt;= bson size ${i}`);if(!t.allowObjectSmallerThanBufferSize&amp;&amp;e.length!==i)throw new I(`buffer length ${e.length} must === bson size ${i}`);if(i+r&gt;e.byteLength)throw new I(`(bson size ${i} + options.index ${r} must be &lt;= buffer length ${e.byteLength})`);if(0!==e[r+i-1])throw new I("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return Fe(e,r,t,n)}const De=/^\$ref$|^\$id$|^\$db$/;function Fe(e,t,n,r=!1){const i=null==n.fieldsAsRaw?null:n.fieldsAsRaw,o=null!=n.raw&amp;&amp;n.raw,s="boolean"===typeof n.bsonRegExp&amp;&amp;n.bsonRegExp,u=n.promoteBuffers??!1,f=n.promoteLongs??!0,l=n.promoteValues??!0,a=n.useBigInt64??!1;if(a&amp;&amp;!l)throw new I("Must either request bigint or Long for int64 deserialization");if(a&amp;&amp;!f)throw new I("Must either request bigint or Long for int64 deserialization");let h,c,g=!0;const b=(null==n.validation?{utf8:!0}:n.validation).utf8;if("boolean"===typeof b)h=b;else{g=!1;const e=Object.keys(b).map((function(e){return b[e]}));if(0===e.length)throw new I("UTF-8 validation setting cannot be empty");if("boolean"!==typeof e[0])throw new I("Invalid UTF-8 validation option, must specify boolean values");if(h=e[0],!e.every((e=&gt;e===h)))throw new I("Invalid UTF-8 validation option - keys must be all true or all false")}if(!g){c=new Set;for(const e of Object.keys(b))c.add(e)}const d=t;if(e.length&lt;5)throw new I("corrupt bson message &lt; 5 bytes long");const p=xe.getInt32LE(e,t);if(t+=4,p&lt;5||p&gt;e.length)throw new I("corrupt bson message");const m=r?[]:{};let y=0;let w=!r&amp;&amp;null;for(;;){const b=e[t++];if(0===b)break;let d=t;for(;0!==e[d]&amp;&amp;d&lt;e.length;)d++;if(d&gt;=e.byteLength)throw new I("Bad BSON Document: illegal CString");const p=r?y++:J.toUTF8(e,t,d,!1);let S,B=!0;if(B=g||c?.has(p)?h:!h,!1!==w&amp;&amp;"$"===p[0]&amp;&amp;(w=De.test(p)),t=d+1,2===b){const n=xe.getInt32LE(e,t);if(t+=4,n&lt;=0||n&gt;e.length-t||0!==e[t+n-1])throw new I("bad string length in bson");S=J.toUTF8(e,t,t+n-1,B),t+=n}else if(7===b){const n=J.allocateUnsafe(12);for(let r=0;r&lt;12;r++)n[r]=e[t+r];S=new Ie(n),t+=12}else if(16===b&amp;&amp;!1===l)S=new ye(xe.getInt32LE(e,t)),t+=4;else if(16===b)S=xe.getInt32LE(e,t),t+=4;else if(1===b)S=xe.getFloat64LE(e,t),t+=8,!1===l&amp;&amp;(S=new me(S));else if(9===b){const n=xe.getInt32LE(e,t),r=xe.getInt32LE(e,t+4);t+=8,S=new Date(new re(n,r).toNumber())}else if(8===b){if(0!==e[t]&amp;&amp;1!==e[t])throw new I("illegal boolean type value");S=1===e[t++]}else if(3===b){const r=t,i=xe.getInt32LE(e,t);if(i&lt;=0||i&gt;e.length-t)throw new I("bad embedded document length in bson");if(o)S=e.slice(t,t+i);else{let t=n;g||(t={...n,validation:{utf8:B}}),S=Fe(e,r,t,!1)}t+=i}else if(4===b){const r=t,o=xe.getInt32LE(e,t);let s=n;const u=t+o;if(i&amp;&amp;i[p]&amp;&amp;(s={...n,raw:!0}),g||(s={...s,validation:{utf8:B}}),S=Fe(e,r,s,!0),0!==e[(t+=o)-1])throw new I("invalid array terminator byte");if(t!==u)throw new I("corrupted array bson")}else if(6===b)S=void 0;else if(10===b)S=null;else if(18===b)if(a)S=xe.getBigInt64LE(e,t),t+=8;else{const n=xe.getInt32LE(e,t),r=xe.getInt32LE(e,t+4);t+=8;const i=new re(n,r);S=f&amp;&amp;!0===l&amp;&amp;i.lessThanOrEqual(Ae)&amp;&amp;i.greaterThanOrEqual(je)?i.toNumber():i}else if(19===b){const n=J.allocateUnsafe(16);for(let r=0;r&lt;16;r++)n[r]=e[t+r];t+=16,S=new pe(n)}else if(5===b){let n=xe.getInt32LE(e,t);t+=4;const r=n,i=e[t++];if(n&lt;0)throw new I("Negative binary type element size found");if(n&gt;e.byteLength)throw new I("Binary type size larger than document size");if(null!=e.slice){if(i===C.SUBTYPE_BYTE_ARRAY){if(n=xe.getInt32LE(e,t),t+=4,n&lt;0)throw new I("Negative binary type element size found for subtype 0x02");if(n&gt;r-4)throw new I("Binary type with subtype 0x02 contains too long binary size");if(n&lt;r-4)throw new I("Binary type with subtype 0x02 contains too short binary size")}u&amp;&amp;l?S=J.toLocalBufferType(e.slice(t,t+n)):(S=new C(e.slice(t,t+n),i),4===i&amp;&amp;q.isValid(S)&amp;&amp;(S=S.toUUID()))}else{if(i===C.SUBTYPE_BYTE_ARRAY){if(n=xe.getInt32LE(e,t),t+=4,n&lt;0)throw new I("Negative binary type element size found for subtype 0x02");if(n&gt;r-4)throw new I("Binary type with subtype 0x02 contains too long binary size");if(n&lt;r-4)throw new I("Binary type with subtype 0x02 contains too short binary size")}if(u&amp;&amp;l)for(S=J.allocateUnsafe(n),d=0;d&lt;n;d++)S[d]=e[t+d];else S=new C(e.slice(t,t+n),i),4===i&amp;&amp;q.isValid(S)&amp;&amp;(S=S.toUUID())}t+=n}else if(11===b&amp;&amp;!1===s){for(d=t;0!==e[d]&amp;&amp;d&lt;e.length;)d++;if(d&gt;=e.length)throw new I("Bad BSON Document: illegal CString");const n=J.toUTF8(e,t,d,!1);for(d=t=d+1;0!==e[d]&amp;&amp;d&lt;e.length;)d++;if(d&gt;=e.length)throw new I("Bad BSON Document: illegal CString");const r=J.toUTF8(e,t,d,!1);t=d+1;const i=new Array(r.length);for(d=0;d&lt;r.length;d++)switch(r[d]){case"m":i[d]="m";break;case"s":i[d]="g";break;case"i":i[d]="i"}S=new RegExp(n,i.join(""))}else if(11===b&amp;&amp;!0===s){for(d=t;0!==e[d]&amp;&amp;d&lt;e.length;)d++;if(d&gt;=e.length)throw new I("Bad BSON Document: illegal CString");const n=J.toUTF8(e,t,d,!1);for(d=t=d+1;0!==e[d]&amp;&amp;d&lt;e.length;)d++;if(d&gt;=e.length)throw new I("Bad BSON Document: illegal CString");const r=J.toUTF8(e,t,d,!1);t=d+1,S=new Le(n,r)}else if(14===b){const n=xe.getInt32LE(e,t);if(t+=4,n&lt;=0||n&gt;e.length-t||0!==e[t+n-1])throw new I("bad string length in bson");const r=J.toUTF8(e,t,t+n-1,B);S=l?r:new Ue(r),t+=n}else if(17===b)S=new ve({i:xe.getUint32LE(e,t),t:xe.getUint32LE(e,t+4)}),t+=8;else if(255===b)S=new Se;else if(127===b)S=new we;else if(13===b){const n=xe.getInt32LE(e,t);if(t+=4,n&lt;=0||n&gt;e.length-t||0!==e[t+n-1])throw new I("bad string length in bson");const r=J.toUTF8(e,t,t+n-1,B);S=new Y(r),t+=n}else if(15===b){const r=xe.getInt32LE(e,t);if(t+=4,r&lt;13)throw new I("code_w_scope total size shorter minimum expected length");const i=xe.getInt32LE(e,t);if(t+=4,i&lt;=0||i&gt;e.length-t||0!==e[t+i-1])throw new I("bad string length in bson");const o=J.toUTF8(e,t,t+i-1,B),s=t+=i,u=xe.getInt32LE(e,t),f=Fe(e,s,n,!1);if(t+=u,r&lt;8+u+i)throw new I("code_w_scope total size is too short, truncating scope");if(r&gt;8+u+i)throw new I("code_w_scope total size is too long, clips outer document");S=new Y(o,f)}else{if(12!==b)throw new I(`Detected unknown BSON type ${b.toString(16)} for fieldname "${p}"`);{const n=xe.getInt32LE(e,t);if(t+=4,n&lt;=0||n&gt;e.length-t||0!==e[t+n-1])throw new I("bad string length in bson");const r=J.toUTF8(e,t,t+n-1,B);t+=n;const i=J.allocateUnsafe(12);for(let s=0;s&lt;12;s++)i[s]=e[t+s];const o=new Ie(i);t+=12,S=new Z(r,o)}}"__proto__"===p?Object.defineProperty(m,p,{value:S,writable:!0,enumerable:!0,configurable:!0}):m[p]=S}if(p!==t-d){if(r)throw new I("corrupt array bson");throw new I("corrupt object bson")}if(!w)return m;if(P(m)){const e=Object.assign({},m);return delete e.$ref,delete e.$id,delete e.$db,new Z(m.$ref,m.$id,m.$db,e)}return m}const Me=/\x00/,ze=new Set(["$db","$ref","$id","$clusterTime"]);function Je(e,t,n,r){e[r++]=2;e[(r=r+J.encodeUTF8Into(e,t,r)+1)-1]=0;const i=J.encodeUTF8Into(e,n,r+4);return xe.setInt32LE(e,r,i+1),r=r+4+i,e[r++]=0,r}function Ve(e,t,n,r){const i=!Object.is(n,-0)&amp;&amp;Number.isSafeInteger(n)&amp;&amp;n&lt;=w&amp;&amp;n&gt;=S?16:1;e[r++]=i;return r+=J.encodeUTF8Into(e,t,r),e[r++]=0,r+=16===i?xe.setInt32LE(e,r,n):xe.setFloat64LE(e,r,n)}function Ce(e,t,n,r){e[r++]=18;return r+=J.encodeUTF8Into(e,t,r),e[r++]=0,r+=xe.setBigInt64LE(e,r,n)}function He(e,t,n,r){e[r++]=10;return r+=J.encodeUTF8Into(e,t,r),e[r++]=0,r}function ke(e,t,n,r){e[r++]=8;return r+=J.encodeUTF8Into(e,t,r),e[r++]=0,e[r++]=n?1:0,r}function qe(e,t,n,r){e[r++]=9;r+=J.encodeUTF8Into(e,t,r),e[r++]=0;const i=re.fromNumber(n.getTime()),o=i.getLowBits(),s=i.getHighBits();return r+=xe.setInt32LE(e,r,o),r+=xe.setInt32LE(e,r,s)}function Ye(e,t,n,r){e[r++]=11;if(r+=J.encodeUTF8Into(e,t,r),e[r++]=0,n.source&amp;&amp;null!=n.source.match(Me))throw new I("value "+n.source+" must not contain null bytes");return r+=J.encodeUTF8Into(e,n.source,r),e[r++]=0,n.ignoreCase&amp;&amp;(e[r++]=105),n.global&amp;&amp;(e[r++]=115),n.multiline&amp;&amp;(e[r++]=109),e[r++]=0,r}function Pe(e,t,n,r){e[r++]=11;if(r+=J.encodeUTF8Into(e,t,r),e[r++]=0,null!=n.pattern.match(Me))throw new I("pattern "+n.pattern+" must not contain null bytes");r+=J.encodeUTF8Into(e,n.pattern,r),e[r++]=0;const i=n.options.split("").sort().join("");return r+=J.encodeUTF8Into(e,i,r),e[r++]=0,r}function Ze(e,t,n,r){null===n?e[r++]=10:"MinKey"===n._bsontype?e[r++]=255:e[r++]=127;return r+=J.encodeUTF8Into(e,t,r),e[r++]=0,r}function Ke(e,t,n,r){e[r++]=7;return r+=J.encodeUTF8Into(e,t,r),e[r++]=0,r+=n.serializeInto(e,r)}function We(e,t,n,r){e[r++]=5;r+=J.encodeUTF8Into(e,t,r),e[r++]=0;const i=n.length;if(r+=xe.setInt32LE(e,r,i),e[r++]=0,i&lt;=16)for(let o=0;o&lt;i;o++)e[r+o]=n[o];else e.set(n,r);return r+=i}function Ge(e,t,n,r,i,o,s,u,f){if(f.has(n))throw new I("Cannot convert circular structure to BSON");f.add(n),e[r++]=Array.isArray(n)?4:3;r+=J.encodeUTF8Into(e,t,r),e[r++]=0;const l=ut(e,n,i,r,o+1,s,u,f);return f.delete(n),l}function Xe(e,t,n,r){e[r++]=19;r+=J.encodeUTF8Into(e,t,r),e[r++]=0;for(let i=0;i&lt;16;i++)e[r+i]=n.bytes[i];return r+16}function Qe(e,t,n,r){e[r++]="Long"===n._bsontype?18:17;r+=J.encodeUTF8Into(e,t,r),e[r++]=0;const i=n.getLowBits(),o=n.getHighBits();return r+=xe.setInt32LE(e,r,i),r+=xe.setInt32LE(e,r,o)}function et(e,t,n,r){n=n.valueOf(),e[r++]=16;return r+=J.encodeUTF8Into(e,t,r),e[r++]=0,r+=xe.setInt32LE(e,r,n)}function tt(e,t,n,r){e[r++]=1;return r+=J.encodeUTF8Into(e,t,r),e[r++]=0,r+=xe.setFloat64LE(e,r,n.value)}function nt(e,t,n,r){e[r++]=13;r+=J.encodeUTF8Into(e,t,r),e[r++]=0;const i=n.toString(),o=J.encodeUTF8Into(e,i,r+4)+1;return xe.setInt32LE(e,r,o),r=r+4+o-1,e[r++]=0,r}function rt(e,t,n,r,i=!1,o=0,s=!1,u=!0,f){if(n.scope&amp;&amp;"object"===typeof n.scope){e[r++]=15;r+=J.encodeUTF8Into(e,t,r),e[r++]=0;let l=r;const a=n.code;r+=4;const h=J.encodeUTF8Into(e,a,r+4)+1;xe.setInt32LE(e,r,h),e[r+4+h-1]=0,r=r+h+4;const c=ut(e,n.scope,i,r,o+1,s,u,f);r=c-1;const g=c-l;l+=xe.setInt32LE(e,l,g),e[r++]=0}else{e[r++]=13;r+=J.encodeUTF8Into(e,t,r),e[r++]=0;const i=n.code.toString(),o=J.encodeUTF8Into(e,i,r+4)+1;xe.setInt32LE(e,r,o),r=r+4+o-1,e[r++]=0}return r}function it(e,t,n,r){e[r++]=5;r+=J.encodeUTF8Into(e,t,r),e[r++]=0;const i=n.buffer;let o=n.position;if(n.sub_type===C.SUBTYPE_BYTE_ARRAY&amp;&amp;(o+=4),r+=xe.setInt32LE(e,r,o),e[r++]=n.sub_type,n.sub_type===C.SUBTYPE_BYTE_ARRAY&amp;&amp;(o-=4,r+=xe.setInt32LE(e,r,o)),o&lt;=16)for(let s=0;s&lt;o;s++)e[r+s]=i[s];else e.set(i,r);return r+=n.position}function ot(e,t,n,r){e[r++]=14;r+=J.encodeUTF8Into(e,t,r),e[r++]=0;const i=J.encodeUTF8Into(e,n.value,r+4)+1;return xe.setInt32LE(e,r,i),r=r+4+i-1,e[r++]=0,r}function st(e,t,n,r,i,o,s){e[r++]=3;r+=J.encodeUTF8Into(e,t,r),e[r++]=0;let u=r,f={$ref:n.collection||n.namespace,$id:n.oid};null!=n.db&amp;&amp;(f.$db=n.db),f=Object.assign(f,n.fields);const l=ut(e,f,!1,r,i+1,o,!0,s),a=l-u;return u+=xe.setInt32LE(e,r,a),l}function ut(e,t,n,r,i,o,s,u){if(null==u){if(null==t)return e[0]=5,e[1]=0,e[2]=0,e[3]=0,e[4]=0,5;if(Array.isArray(t))throw new I("serialize does not support an array as the root input");if("object"!==typeof t)throw new I("serialize does not support non-object as the root input");if("_bsontype"in t&amp;&amp;"string"===typeof t._bsontype)throw new I("BSON types cannot be serialized as a document");if(p(t)||b(t)||g(t)||c(t))throw new I("date, regexp, typedarray, and arraybuffer cannot be BSON documents");u=new Set}u.add(t);let f=r+4;if(Array.isArray(t))for(let a=0;a&lt;t.length;a++){const r=`${a}`;let l=t[a];"function"===typeof l?.toBSON&amp;&amp;(l=l.toBSON());const h=typeof l;if(void 0===l)f=He(e,r,0,f);else if(null===l)f=He(e,r,0,f);else if("string"===h)f=Je(e,r,l,f);else if("number"===h)f=Ve(e,r,l,f);else if("bigint"===h)f=Ce(e,r,l,f);else if("boolean"===h)f=ke(e,r,l,f);else if("object"===h&amp;&amp;null==l._bsontype)f=l instanceof Date||p(l)?qe(e,r,l,f):l instanceof Uint8Array||g(l)?We(e,r,l,f):l instanceof RegExp||b(l)?Ye(e,r,l,f):Ge(e,r,l,f,n,i,o,s,u);else if("object"===h){if(6!==l[y])throw new $;if("ObjectId"===l._bsontype)f=Ke(e,r,l,f);else if("Decimal128"===l._bsontype)f=Xe(e,r,l,f);else if("Long"===l._bsontype||"Timestamp"===l._bsontype)f=Qe(e,r,l,f);else if("Double"===l._bsontype)f=tt(e,r,l,f);else if("Code"===l._bsontype)f=rt(e,r,l,f,n,i,o,s,u);else if("Binary"===l._bsontype)f=it(e,r,l,f);else if("BSONSymbol"===l._bsontype)f=ot(e,r,l,f);else if("DBRef"===l._bsontype)f=st(e,r,l,f,i,o,u);else if("BSONRegExp"===l._bsontype)f=Pe(e,r,l,f);else if("Int32"===l._bsontype)f=et(e,r,l,f);else if("MinKey"===l._bsontype||"MaxKey"===l._bsontype)f=Ze(e,r,l,f);else if("undefined"!==typeof l._bsontype)throw new I(`Unrecognized or invalid _bsontype: ${String(l._bsontype)}`)}else"function"===h&amp;&amp;o&amp;&amp;(f=nt(e,r,l,f))}else if(t instanceof Map||d(t)){const r=t.entries();let l=!1;for(;!l;){const t=r.next();if(l=!!t.done,l)continue;const a=t.value[0];let h=t.value[1];"function"===typeof h?.toBSON&amp;&amp;(h=h.toBSON());const c=typeof h;if("string"===typeof a&amp;&amp;!ze.has(a)){if(null!=a.match(Me))throw new I("key "+a+" must not contain null bytes");if(n){if("$"===a[0])throw new I("key "+a+" must not start with '$'");if(a.includes("."))throw new I("key "+a+" must not contain '.'")}}if(void 0===h)!1===s&amp;&amp;(f=He(e,a,0,f));else if(null===h)f=He(e,a,0,f);else if("string"===c)f=Je(e,a,h,f);else if("number"===c)f=Ve(e,a,h,f);else if("bigint"===c)f=Ce(e,a,h,f);else if("boolean"===c)f=ke(e,a,h,f);else if("object"===c&amp;&amp;null==h._bsontype)f=h instanceof Date||p(h)?qe(e,a,h,f):h instanceof Uint8Array||g(h)?We(e,a,h,f):h instanceof RegExp||b(h)?Ye(e,a,h,f):Ge(e,a,h,f,n,i,o,s,u);else if("object"===c){if(6!==h[y])throw new $;if("ObjectId"===h._bsontype)f=Ke(e,a,h,f);else if("Decimal128"===h._bsontype)f=Xe(e,a,h,f);else if("Long"===h._bsontype||"Timestamp"===h._bsontype)f=Qe(e,a,h,f);else if("Double"===h._bsontype)f=tt(e,a,h,f);else if("Code"===h._bsontype)f=rt(e,a,h,f,n,i,o,s,u);else if("Binary"===h._bsontype)f=it(e,a,h,f);else if("BSONSymbol"===h._bsontype)f=ot(e,a,h,f);else if("DBRef"===h._bsontype)f=st(e,a,h,f,i,o,u);else if("BSONRegExp"===h._bsontype)f=Pe(e,a,h,f);else if("Int32"===h._bsontype)f=et(e,a,h,f);else if("MinKey"===h._bsontype||"MaxKey"===h._bsontype)f=Ze(e,a,h,f);else if("undefined"!==typeof h._bsontype)throw new I(`Unrecognized or invalid _bsontype: ${String(h._bsontype)}`)}else"function"===c&amp;&amp;o&amp;&amp;(f=nt(e,a,h,f))}}else{if("function"===typeof t?.toBSON&amp;&amp;null!=(t=t.toBSON())&amp;&amp;"object"!==typeof t)throw new I("toBSON function did not return an object");for(const r of Object.keys(t)){let l=t[r];"function"===typeof l?.toBSON&amp;&amp;(l=l.toBSON());const a=typeof l;if("string"===typeof r&amp;&amp;!ze.has(r)){if(null!=r.match(Me))throw new I("key "+r+" must not contain null bytes");if(n){if("$"===r[0])throw new I("key "+r+" must not start with '$'");if(r.includes("."))throw new I("key "+r+" must not contain '.'")}}if(void 0===l)!1===s&amp;&amp;(f=He(e,r,0,f));else if(null===l)f=He(e,r,0,f);else if("string"===a)f=Je(e,r,l,f);else if("number"===a)f=Ve(e,r,l,f);else if("bigint"===a)f=Ce(e,r,l,f);else if("boolean"===a)f=ke(e,r,l,f);else if("object"===a&amp;&amp;null==l._bsontype)f=l instanceof Date||p(l)?qe(e,r,l,f):l instanceof Uint8Array||g(l)?We(e,r,l,f):l instanceof RegExp||b(l)?Ye(e,r,l,f):Ge(e,r,l,f,n,i,o,s,u);else if("object"===a){if(6!==l[y])throw new $;if("ObjectId"===l._bsontype)f=Ke(e,r,l,f);else if("Decimal128"===l._bsontype)f=Xe(e,r,l,f);else if("Long"===l._bsontype||"Timestamp"===l._bsontype)f=Qe(e,r,l,f);else if("Double"===l._bsontype)f=tt(e,r,l,f);else if("Code"===l._bsontype)f=rt(e,r,l,f,n,i,o,s,u);else if("Binary"===l._bsontype)f=it(e,r,l,f);else if("BSONSymbol"===l._bsontype)f=ot(e,r,l,f);else if("DBRef"===l._bsontype)f=st(e,r,l,f,i,o,u);else if("BSONRegExp"===l._bsontype)f=Pe(e,r,l,f);else if("Int32"===l._bsontype)f=et(e,r,l,f);else if("MinKey"===l._bsontype||"MaxKey"===l._bsontype)f=Ze(e,r,l,f);else if("undefined"!==typeof l._bsontype)throw new I(`Unrecognized or invalid _bsontype: ${String(l._bsontype)}`)}else"function"===a&amp;&amp;o&amp;&amp;(f=nt(e,r,l,f))}}u.delete(t),e[f++]=0;const l=f-r;return r+=xe.setInt32LE(e,r,l),f}const ft={$oid:Ie,$binary:C,$uuid:C,$symbol:Ue,$numberInt:ye,$numberDecimal:pe,$numberDouble:me,$numberLong:re,$minKey:Se,$maxKey:we,$regex:Le,$regularExpression:Le,$timestamp:ve};function lt(e,t={}){if("number"===typeof e){const n=e&lt;=w&amp;&amp;e&gt;=S,r=e&lt;=B&amp;&amp;e&gt;=N;if(t.relaxed||t.legacy)return e;if(Number.isInteger(e)&amp;&amp;!Object.is(e,-0)){if(n)return new ye(e);if(r)return t.useBigInt64?BigInt(e):re.fromNumber(e)}return new me(e)}if(null==e||"object"!==typeof e)return e;if(e.$undefined)return null;const n=Object.keys(e).filter((t=&gt;t.startsWith("$")&amp;&amp;null!=e[t]));for(let r=0;r&lt;n.length;r++){const i=ft[n[r]];if(i)return i.fromExtendedJSON(e,t)}if(null!=e.$date){const n=e.$date,r=new Date;if(t.legacy)if("number"===typeof n)r.setTime(n);else if("string"===typeof n)r.setTime(Date.parse(n));else{if("bigint"!==typeof n)throw new _("Unrecognized type for EJSON date: "+typeof n);r.setTime(Number(n))}else if("string"===typeof n)r.setTime(Date.parse(n));else if(re.isLong(n))r.setTime(n.toNumber());else if("number"===typeof n&amp;&amp;t.relaxed)r.setTime(n);else{if("bigint"!==typeof n)throw new _("Unrecognized type for EJSON date: "+typeof n);r.setTime(Number(n))}return r}if(null!=e.$code){const t=Object.assign({},e);return e.$scope&amp;&amp;(t.$scope=lt(e.$scope)),Y.fromExtendedJSON(e)}if(P(e)||e.$dbPointer){const t=e.$ref?e:e.$dbPointer;if(t instanceof Z)return t;const n=Object.keys(t).filter((e=&gt;e.startsWith("$")));let r=!0;if(n.forEach((e=&gt;{-1===["$ref","$id","$db"].indexOf(e)&amp;&amp;(r=!1)})),r)return Z.fromExtendedJSON(t)}return e}function at(e){const t=e.toISOString();return 0!==e.getUTCMilliseconds()?t:t.slice(0,-5)+"Z"}function ht(e,t){if(e instanceof Map||d(e)){const n=Object.create(null);for(const[t,r]of e){if("string"!==typeof t)throw new I("Can only serialize maps with string keys");n[t]=r}return ht(n,t)}if(("object"===typeof e||"function"===typeof e)&amp;&amp;null!==e){const n=t.seenObjects.findIndex((t=&gt;t.obj===e));if(-1!==n){const e=t.seenObjects.map((e=&gt;e.propertyName)),r=e.slice(0,n).map((e=&gt;`${e} -&gt; `)).join(""),i=e[n],o=" -&gt; "+e.slice(n+1,e.length-1).map((e=&gt;`${e} -&gt; `)).join(""),s=e[e.length-1],u=" ".repeat(r.length+i.length/2),f="-".repeat(o.length+(i.length+s.length)/2-1);throw new I(`Converting circular structure to EJSON:\n    ${r}${i}${o}${s}\n    ${u}\\${f}/`)}t.seenObjects[t.seenObjects.length-1].obj=e}if(Array.isArray(e))return function(e,t){return e.map(((e,n)=&gt;{t.seenObjects.push({propertyName:`index ${n}`,obj:null});try{return ht(e,t)}finally{t.seenObjects.pop()}}))}(e,t);if(void 0===e)return null;if(e instanceof Date||p(e)){const n=e.getTime(),r=n&gt;-1&amp;&amp;n&lt;2534023188e5;return t.legacy?t.relaxed&amp;&amp;r?{$date:e.getTime()}:{$date:at(e)}:t.relaxed&amp;&amp;r?{$date:at(e)}:{$date:{$numberLong:e.getTime().toString()}}}if("number"===typeof e&amp;&amp;(!t.relaxed||!isFinite(e))){if(Number.isInteger(e)&amp;&amp;!Object.is(e,-0)){if(e&gt;=S&amp;&amp;e&lt;=w)return{$numberInt:e.toString()};if(e&gt;=N&amp;&amp;e&lt;=B)return{$numberLong:e.toString()}}return{$numberDouble:Object.is(e,-0)?"-0.0":e.toString()}}if("bigint"===typeof e)return t.relaxed?Number(BigInt.asIntN(64,e)):{$numberLong:BigInt.asIntN(64,e).toString()};if(e instanceof RegExp||b(e)){let n=e.flags;if(void 0===n){const t=e.toString().match(/[gimuy]*$/);t&amp;&amp;(n=t[0])}return new Le(e.source,n).toExtendedJSON(t)}return null!=e&amp;&amp;"object"===typeof e?function(e,t){if(null==e||"object"!==typeof e)throw new I("not an object instance");const n=e._bsontype;if("undefined"===typeof n){const n={};for(const r of Object.keys(e)){t.seenObjects.push({propertyName:r,obj:null});try{const i=ht(e[r],t);"__proto__"===r?Object.defineProperty(n,r,{value:i,writable:!0,enumerable:!0,configurable:!0}):n[r]=i}finally{t.seenObjects.pop()}}return n}if(null!=e&amp;&amp;"object"===typeof e&amp;&amp;"string"===typeof e._bsontype&amp;&amp;6!==e[y])throw new $;if(function(e){return null!=e&amp;&amp;"object"===typeof e&amp;&amp;"_bsontype"in e&amp;&amp;"string"===typeof e._bsontype}(e)){let r=e;if("function"!==typeof r.toExtendedJSON){const t=ct[e._bsontype];if(!t)throw new I("Unrecognized or invalid _bsontype: "+e._bsontype);r=t(r)}return"Code"===n&amp;&amp;r.scope?r=new Y(r.code,ht(r.scope,t)):"DBRef"===n&amp;&amp;r.oid&amp;&amp;(r=new Z(ht(r.collection,t),ht(r.oid,t),ht(r.db,t),ht(r.fields,t))),r.toExtendedJSON(t)}throw new I("_bsontype must be a string, but was: "+typeof n)}(e,t):e}const ct={Binary:e=&gt;new C(e.value(),e.sub_type),Code:e=&gt;new Y(e.code,e.scope),DBRef:e=&gt;new Z(e.collection||e.namespace,e.oid,e.db,e.fields),Decimal128:e=&gt;new pe(e.bytes),Double:e=&gt;new me(e.value),Int32:e=&gt;new ye(e.value),Long:e=&gt;re.fromBits(null!=e.low?e.low:e.low_,null!=e.low?e.high:e.high_,null!=e.low?e.unsigned:e.unsigned_),MaxKey:()=&gt;new we,MinKey:()=&gt;new Se,ObjectId:e=&gt;new Ie(e),BSONRegExp:e=&gt;new Le(e.pattern,e.options),BSONSymbol:e=&gt;new Ue(e.value),Timestamp:e=&gt;ve.fromBits(e.low,e.high)};function gt(e,t){const n={useBigInt64:t?.useBigInt64??!1,relaxed:t?.relaxed??!0,legacy:t?.legacy??!1};return JSON.parse(e,((e,t)=&gt;{if(-1!==e.indexOf("\0"))throw new I(`BSON Document field names cannot contain null bytes, found: ${JSON.stringify(e)}`);return lt(t,n)}))}function bt(e,t,n,r){null!=n&amp;&amp;"object"===typeof n&amp;&amp;(r=n,n=0),null==t||"object"!==typeof t||Array.isArray(t)||(r=t,t=void 0,n=0);const i=ht(e,Object.assign({relaxed:!0,legacy:!1},r,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(i,t,n)}const dt=Object.create(null);function pt(e,t){try{return xe.getNonnegativeInt32LE(e,t)}catch(n){throw new L("BSON size cannot be negative",t,{cause:n})}}function mt(e,t){let n=t;for(;0!==e[n];n++);if(n===e.length-1)throw new L("Null terminator not found",t);return n}dt.parse=gt,dt.stringify=bt,dt.serialize=function(e,t){return t=t||{},JSON.parse(bt(e,t))},dt.deserialize=function(e,t){return t=t||{},gt(JSON.stringify(e),t)},Object.freeze(dt);const yt=Object.create(null);yt.parseToElements=function(e,t=0){if(t??=0,e.length&lt;5)throw new L(`Input must be at least 5 bytes, got ${e.length} bytes`,t);const n=pt(e,t);if(n&gt;e.length-t)throw new L(`Parsed documentSize (${n} bytes) does not match input length (${e.length} bytes)`,t);if(0!==e[t+n-1])throw new L("BSON documents must end in 0x00",t+n);const r=[];let i=t+4;for(;i&lt;=n+t;){const o=e[i];if(i+=1,0===o){if(i-t!==n)throw new L("Invalid 0x00 type byte",i);break}const s=i,u=mt(e,i)-s;let f;if(i+=u+1,1===o||18===o||9===o||17===o)f=8;else if(16===o)f=4;else if(7===o)f=12;else if(19===o)f=16;else if(8===o)f=1;else if(10===o||6===o||127===o||255===o)f=0;else if(11===o)f=mt(e,mt(e,i)+1)+1-i;else if(3===o||4===o||15===o)f=pt(e,i);else{if(2!==o&amp;&amp;5!==o&amp;&amp;12!==o&amp;&amp;13!==o&amp;&amp;14!==o)throw new L(`Invalid 0x${o.toString(16).padStart(2,"0")} type byte`,i);f=pt(e,i)+4,5===o&amp;&amp;(f+=1),12===o&amp;&amp;(f+=12)}if(f&gt;n)throw new L("value reports length larger than document",i);r.push([o,s,u,i,f]),i+=f}return r},yt.ByteUtils=J,yt.NumberUtils=xe,Object.freeze(yt);const wt=17825792;let St=J.allocate(wt);function Bt(e){St.length&lt;e&amp;&amp;(St=J.allocate(e))}function Nt(e,t={}){const n="boolean"===typeof t.checkKeys&amp;&amp;t.checkKeys,r="boolean"===typeof t.serializeFunctions&amp;&amp;t.serializeFunctions,i="boolean"!==typeof t.ignoreUndefined||t.ignoreUndefined,o="number"===typeof t.minInternalBufferSize?t.minInternalBufferSize:wt;St.length&lt;o&amp;&amp;(St=J.allocate(o));const s=ut(St,e,n,0,0,r,i,null),u=J.allocateUnsafe(s);return u.set(St.subarray(0,s),0),u}function Et(e,t,n={}){const r="boolean"===typeof n.checkKeys&amp;&amp;n.checkKeys,i="boolean"===typeof n.serializeFunctions&amp;&amp;n.serializeFunctions,o="boolean"!==typeof n.ignoreUndefined||n.ignoreUndefined,s="number"===typeof n.index?n.index:0,u=ut(St,e,r,0,0,i,o,null);return t.set(St.subarray(0,u),s),s+u-1}function xt(e,t={}){return Re(J.toLocalBufferType(e),t)}function Ot(e,t={}){return $e(e,"boolean"===typeof(t=t||{}).serializeFunctions&amp;&amp;t.serializeFunctions,"boolean"!==typeof t.ignoreUndefined||t.ignoreUndefined)}function It(e,t,n,r,i,o){const s=Object.assign({allowObjectSmallerThanBufferSize:!0,index:0},o),u=J.toLocalBufferType(e);let f=t;for(let l=0;l&lt;n;l++){const e=xe.getInt32LE(u,f);s.index=f,r[i+l]=Re(u,s),f+=e}return f}var $t=Object.freeze({__proto__:null,BSONError:I,BSONOffsetError:L,BSONRegExp:Le,BSONRuntimeError:_,BSONSymbol:Ue,BSONType:O,BSONValue:V,BSONVersionError:$,Binary:C,Code:Y,DBRef:Z,Decimal128:pe,Double:me,EJSON:dt,Int32:ye,Long:re,MaxKey:we,MinKey:Se,ObjectId:Ie,Timestamp:ve,UUID:q,calculateObjectSize:Ot,deserialize:xt,deserializeStream:It,onDemand:yt,serialize:Nt,serializeWithBufferAndIndex:Et,setInternalBufferSize:Bt});t.BSON=$t,t.BSONError=I,t.BSONOffsetError=L,t.BSONRegExp=Le,t.BSONRuntimeError=_,t.BSONSymbol=Ue,t.BSONType=O,t.BSONValue=V,t.BSONVersionError=$,t.Binary=C,t.Code=Y,t.DBRef=Z,t.Decimal128=pe,t.Double=me,t.EJSON=dt,t.Int32=ye,t.Long=re,t.MaxKey=we,t.MinKey=Se,t.ObjectId=Ie,t.Timestamp=ve,t.UUID=q,t.calculateObjectSize=Ot,t.deserialize=xt,t.deserializeStream=It,t.onDemand=yt,t.serialize=Nt,t.serializeWithBufferAndIndex=Et,t.setInternalBufferSize=Bt}}]);</pre></body></html>