@mongosh/node-runtime-worker-thread 1.0.7 → 1.1.4
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.
- package/AUTHORS +1 -0
- package/dist/child-process-proxy.js +1 -2
- package/dist/index.js +1 -2
- package/dist/worker-runtime.js +8 -8
- package/dist/worker-runtime.js.LICENSE.txt +0 -15
- package/package.json +10 -10
- package/src/index.spec.ts +1 -1
- package/dist/child-process-proxy.js.LICENSE.txt +0 -14
- package/dist/index.js.LICENSE.txt +0 -14
package/dist/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
/*! For license information please see index.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(global,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=7)}([function(e,t){e.exports=require("buffer")},function(e,t,r){"use strict";var n,i,o,s=r(15),u="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";function f(){o=!1}function a(e){if(e){if(e!==n){if(e.length!==u.length)throw new Error("Custom alphabet for shortid must be "+u.length+" unique characters. You submitted "+e.length+" characters: "+e);var t=e.split("").filter((function(e,t,r){return t!==r.lastIndexOf(e)}));if(t.length)throw new Error("Custom alphabet for shortid must be "+u.length+" unique characters. These characters were not unique: "+t.join(", "));n=e,f()}}else n!==u&&(n=u,f())}function l(){return o||(o=function(){n||a(u);for(var e,t=n.split(""),r=[],i=s.nextValue();t.length>0;)i=s.nextValue(),e=Math.floor(i*t.length),r.push(t.splice(e,1)[0]);return r.join("")}())}e.exports={get:function(){return n||u},characters:function(e){return a(e),n},seed:function(e){s.seed(e),i!==e&&(f(),i=e)},lookup:function(e){return l()[e]},shuffled:l}},function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.createCaller=t.exposeAll=t.cancel=t.close=t.removeTrailingUndefined=t.deserialize=t.serialize=void 0;const i=n(r(10)),o=r(11),s=r(6);function u(e){return`data:;base64,${i.default.serialize(e).toString("base64")}`}function f(e){return/^data:;base64,.+/.test(e)?i.default.deserialize(Buffer.from(e.replace("data:;base64,",""),"base64")):e}var a;function l(e){return e&&"object"==typeof e&&"id"in e&&"sender"in e}function c(e){return l(e)&&"postmsg-rpc/server"===e.sender}function h(e){return l(e)&&"postmsg-rpc/client"===e.sender}function p(e){if(Array.isArray(e))for(e=[...e];e.length>0&&void 0===e[e.length-1];)e.pop();return e}function d(e){return{addListener:e.on.bind(e),removeListener:e.off.bind(e),postMessage(t){if(h(t)&&Array.isArray(t.args)&&(t.args=u(p(t.args))),c(t))try{t.res=u(t.res)}catch(e){t.res=u({type:a.Error,payload:s.serializeError(e)})}return function(e,t){"postMessage"in e&&"function"==typeof e.postMessage&&e.postMessage(t),"send"in e&&"function"==typeof e.send&&e.send(t)}(e,t)},getMessageData:e=>(h(e)&&e.args&&"string"==typeof e.args&&(e.args=f(e.args)),c(e)&&"string"==typeof e.res&&(e.res=f(e.res)),e)}}t.serialize=u,t.deserialize=f,function(e){e[e.Message=0]="Message",e[e.Error=1]="Error"}(a||(a={})),t.removeTrailingUndefined=p,t.close=Symbol("@@rpc.close"),t.cancel=Symbol("@@rpc.cancel"),t.exposeAll=function(e,r){return Object.entries(e).forEach((([e,t])=>{const{close:n}=o.expose(e,(async(...e)=>{try{return{type:a.Message,payload:await t(...e)}}catch(e){return{type:a.Error,payload:s.serializeError(e)}}}),d(r));t.close=n})),Object.defineProperty(e,t.close,{enumerable:!1,value(){Object.values(e).forEach((e=>{e.close()}))}}),e},t.createCaller=function(e,r){const n={},i=new Set;return e.forEach((e=>{const t=o.caller(e,d(r));n[e]=async(...e)=>{const r=t(...e);i.add(r);const n=await r;if(i.delete(r),(o=n)&&"object"==typeof o&&o.type===a.Error)throw s.deserializeError(n.payload);var o;return n.payload}})),Object.defineProperty(n,t.cancel,{enumerable:!1,value(){for(const e of i)e.cancel(),i.delete(e)}}),n}},function(e,t){e.exports=require("child_process")},function(e,t){e.exports=require("events")},function(e,t){e.exports=require("crypto")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deserializeEvaluationResult=t.serializeEvaluationResult=t.SerializedResultTypes=t.deserializeError=t.serializeError=void 0;const n=r(25),i=r(26);function o(e){var t;return(t=e,Object.getOwnPropertyNames(t)).concat("name").reduce(((t,r)=>(t[r]=e[r],t)),{})}function s(e){return Object.assign(new Error,e)}var u;t.serializeError=o,t.deserializeError=s,function(e){e.SerializedErrorResult="SerializedErrorResult",e.InspectResult="InspectResult",e.SerializedShellApiResult="SerializedShellApiResult"}(u=t.SerializedResultTypes||(t.SerializedResultTypes={})),t.serializeEvaluationResult=function({type:e,printable:t,source:r}){return"object"!=typeof(s=t)&&"function"!=typeof s||null===s?{type:e,printable:t,source:r}:function(e){return e&&e.name&&e.message&&e.stack}(t)?{type:u.SerializedErrorResult,printable:o(t),source:r}:null===e?{type:u.InspectResult,printable:n.inspect(t),source:r}:{type:u.SerializedShellApiResult,printable:{origType:e,serializedValue:i.EJSON.serialize(t)}};var s},t.deserializeEvaluationResult=function({type:e,printable:t,source:r}){return e===u.SerializedErrorResult?{type:e,printable:s(t),source:r}:e===u.SerializedShellApiResult?{type:t.origType,printable:i.EJSON.deserialize(t.serializedValue),source:r}:{type:e,printable:t,source:r}}},function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WorkerRuntime=void 0;const i=r(3),o=n(r(8)),s=r(4),u=r(9),f=r(2),a=r(27),l=r(6),c=r(28);t.WorkerRuntime=class WorkerRuntime{constructor(e,t={},r={},n={},i=new s.EventEmitter){this.evaluationListener=null,this.childProcessProxySrcPath=process.env.CHILD_PROCESS_PROXY_SRC_PATH_DO_NOT_USE_THIS_EXCEPT_FOR_TESTING||o.default.resolve(__dirname,"child-process-proxy.js"),this.initOptions={uri:e,driverOptions:t,cliOptions:r,spawnOptions:n},this.eventEmitter=i,this.initWorkerPromise=this.initWorker()}async initWorker(){var e,t,r;const{uri:n,driverOptions:o,cliOptions:u,spawnOptions:l}=this.initOptions;this.childProcess=i.spawn(process.execPath,[this.childProcessProxySrcPath],{stdio:["inherit","inherit","pipe","ipc"],...l});let h="";null===(r=null===(t=null===(e=this.childProcess)||void 0===e?void 0:e.stderr)||void 0===t?void 0:t.setEncoding("utf8"))||void 0===r||r.on("data",(e=>{h+=e}));await Promise.race([(async()=>{let e;for(;[e]=await s.once(this.childProcess,"message");)if("ready"===e)return})(),(async()=>{const[e]=await s.once(this.childProcess,"exit");if(e){let t=function(e){const[,t]=e.split(/^\s*\^\s*$/m).map((e=>e.trim()));if(t){const e=new Error,r=t.substring(0,t.search(/^\s*at/m))||t,[n,...i]=r.split(": ");return e.name=n,e.message=i.join(": ").trim(),e.stack=t,e}return null}(h);throw t?t.message=`Child process failed to start with the following error: ${t.message}`:t=new Error(`Worker runtime failed to start: child process exited with code ${e}`),t}})()]),this.childProcess.setMaxListeners(25),this.childProcessRuntime=f.createCaller(["init","evaluate","getCompletions","setEvaluationListener","getShellPrompt","interrupt"],this.childProcess),this.childProcessEvaluationListener=new a.ChildProcessEvaluationListener(this,this.childProcess),this.childProcessMongoshBus=new c.ChildProcessMongoshBus(this.eventEmitter,this.childProcess),await this.childProcessRuntime.init(n,o,u)}async evaluate(e){return await this.initWorkerPromise,l.deserializeEvaluationResult(await this.childProcessRuntime.evaluate(e))}async getCompletions(e){return await this.initWorkerPromise,await this.childProcessRuntime.getCompletions(e)}async getShellPrompt(){return await this.initWorkerPromise,await this.childProcessRuntime.getShellPrompt()}setEvaluationListener(e){const t=this.evaluationListener;return this.evaluationListener=e,t}async terminate(){try{await this.initWorkerPromise}catch(e){}await u.kill(this.childProcess),this.childProcessRuntime&&this.childProcessRuntime[f.cancel](),this.childProcessEvaluationListener&&this.childProcessEvaluationListener.terminate(),this.childProcessMongoshBus&&this.childProcessMongoshBus.terminate()}async interrupt(){return await this.initWorkerPromise,this.childProcessRuntime.interrupt()}async waitForRuntimeToBeReady(){await this.initWorkerPromise}}},function(e,t){e.exports=require("path")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.kill=void 0;const n=r(3),i=r(4);async function o(e,t="SIGTERM"){e.kill(t),null===e.exitCode&&null===e.signalCode&&await i.once(e,"exit")}t.kill=o,t.default=function(e,t={},r,i="inherit",s="inherit"){return new Promise((async(u,f)=>{const a=Date.now().toString(32),l=n.spawn(process.execPath,{stdio:["pipe",i,s,"ipc"],...t});if(!l.stdin)return await o(l),f(new Error("Can't write src to the spawned process, missing stdin"));let c;function h(){c&&clearTimeout(c),l.stdin&&l.stdin.off("error",d),l.off("message",g),l.off("exit",p)}function p(e){e&&e>0&&(h(),f(new Error("Child process exited with error before starting")))}async function d(e){h(),await o(l),f(e)}function g(e){e===a&&(h(),u(l))}l.on("message",g),l.on("exit",p),l.stdin.on("error",d),l.stdin.write(e),l.stdin.write(`;process.send(${JSON.stringify(a)})`),l.stdin.end(),c=void 0!==r?setTimeout((async function(){h(),await o(l),f(new Error("Timed out while waiting for child process to start"))}),r):null}))}},function(e,t){e.exports=require("v8")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(12);Object.defineProperty(t,"caller",{enumerable:!0,get:function(){return o(n).default}}),Object.defineProperty(t,"call",{enumerable:!0,get:function(){return n.call}});var i=r(24);function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"expose",{enumerable:!0,get:function(){return o(i).default}})},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=s,t.call=function(e){return s(e).apply(null,[].slice.call(arguments,1))};var n,i=r(13),o=(n=i)&&n.__esModule?n:{default:n};function s(e,t){var r=(t=t||{}).addListener||window.addEventListener,n=t.removeListener||window.removeEventListener,i=t.postMessage||window.postMessage,s=t.targetOrigin||"*",u=t.getMessageData||function(e){return e.data};return function(){var t={sender:"postmsg-rpc/client",id:(0,o.default)(),func:e,args:Array.from(arguments)},f=void 0,a=new Promise((function(o,a){var l=function r(){var i=u.apply(null,arguments);if(i&&"postmsg-rpc/server"===i.sender&&i.id===t.id){if(n("message",r),i.err){var s=new Error("Unexpected error calling "+e);return Object.assign(s,i.err),a(s)}o(i.res)}};f=function(){n("message",l);var t=new Error("Canceled call to "+e);t.isCanceled=!0,a(t)},r("message",l),i(t,s)}));return a.cancel=function(){return f()},a}}},function(e,t,r){"use strict";e.exports=r(14)},function(e,t,r){"use strict";var n=r(1),i=r(16),o=r(21),s=r(22)||0;function u(){return i(s)}e.exports=u,e.exports.generate=u,e.exports.seed=function(t){return n.seed(t),e.exports},e.exports.worker=function(t){return s=t,e.exports},e.exports.characters=function(e){return void 0!==e&&n.characters(e),n.shuffled()},e.exports.isValid=o},function(e,t,r){"use strict";var n=1;e.exports={nextValue:function(){return(n=(9301*n+49297)%233280)/233280},seed:function(e){n=e}}},function(e,t,r){"use strict";var n,i,o=r(17);r(1);e.exports=function(e){var t="",r=Math.floor(.001*(Date.now()-1567752802062));return r===i?n++:(n=0,i=r),t+=o(7),t+=o(e),n>0&&(t+=o(n)),t+=o(r)}},function(e,t,r){"use strict";var n=r(1),i=r(18),o=r(20);e.exports=function(e){for(var t,r=0,s="";!t;)s+=o(i,n.get(),1),t=e<Math.pow(16,r+1),r++;return s}},function(e,t,r){e.exports=r(19)},function(e,t,r){var n=r(5);if(n.randomFillSync){var i={};e.exports=function(e){var t=i[e];return t||(t=Buffer.allocUnsafe(e),e<=255&&(i[e]=t)),n.randomFillSync(t)}}else e.exports=n.randomBytes},function(e,t){e.exports=function(e,t,r){for(var n=(2<<31-Math.clz32(t.length-1|1))-1,i=Math.ceil(1.6*n*r/t.length),o="";;)for(var s=e(i),u=i;u--;)if((o+=t[s[u]&n]||"").length===+r)return o}},function(e,t,r){"use strict";var n=r(1);e.exports=function(e){return!(!e||"string"!=typeof e||e.length<6)&&!new RegExp("[^"+n.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]").test(e)}},function(e,t,r){"use strict";var n=r(23),i=0;!n.isMaster&&n.worker&&(i=n.worker.id),e.exports=parseInt(process.env.NODE_UNIQUE_ID||i,10)},function(e,t){e.exports=require("cluster")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){var n=(r=r||{}).addListener||window.addEventListener,i=r.removeListener||window.removeEventListener,o=r.postMessage||window.postMessage,s=r.targetOrigin||"*",u=r.getMessageData||function(e){return e.data},f=r.isCallback||!1,a=function(){var r=u.apply(null,arguments);if(r&&"postmsg-rpc/client"===r.sender&&r.func===e){var n={sender:"postmsg-rpc/server",id:r.id},i=function(e){n.res=e,o(n,s)},a=function(e){n.err=Object.assign({message:e.message},e.output&&e.output.payload),o(n,s)};if(f)t.apply(null,r.args.concat((function(e,t){if(e)return a(e);i(t)})));else{var l=t.apply(null,r.args);Promise.resolve(l).then(i).catch(a)}}};return n("message",a),{close:function(){return i("message",a)}}}},function(e,t){e.exports=require("util")},function(e,t,r){"use strict";r.r(t),r.d(t,"BSONRegExp",(function(){return re})),r.d(t,"BSONSymbol",(function(){return ne})),r.d(t,"BSON_BINARY_SUBTYPE_BYTE_ARRAY",(function(){return Ke})),r.d(t,"BSON_BINARY_SUBTYPE_DEFAULT",(function(){return He})),r.d(t,"BSON_BINARY_SUBTYPE_FUNCTION",(function(){return Ze})),r.d(t,"BSON_BINARY_SUBTYPE_MD5",(function(){return Ge})),r.d(t,"BSON_BINARY_SUBTYPE_USER_DEFINED",(function(){return Qe})),r.d(t,"BSON_BINARY_SUBTYPE_UUID",(function(){return We})),r.d(t,"BSON_BINARY_SUBTYPE_UUID_NEW",(function(){return Xe})),r.d(t,"BSON_DATA_ARRAY",(function(){return Ie})),r.d(t,"BSON_DATA_BINARY",(function(){return Te})),r.d(t,"BSON_DATA_BOOLEAN",(function(){return Pe})),r.d(t,"BSON_DATA_CODE",(function(){return De})),r.d(t,"BSON_DATA_CODE_W_SCOPE",(function(){return Ce})),r.d(t,"BSON_DATA_DATE",(function(){return Ue})),r.d(t,"BSON_DATA_DBPOINTER",(function(){return Me})),r.d(t,"BSON_DATA_DECIMAL128",(function(){return Ye})),r.d(t,"BSON_DATA_INT",(function(){return ke})),r.d(t,"BSON_DATA_LONG",(function(){return Ve})),r.d(t,"BSON_DATA_MAX_KEY",(function(){return Fe})),r.d(t,"BSON_DATA_MIN_KEY",(function(){return qe})),r.d(t,"BSON_DATA_NULL",(function(){return Re})),r.d(t,"BSON_DATA_NUMBER",(function(){return Be})),r.d(t,"BSON_DATA_OBJECT",(function(){return je})),r.d(t,"BSON_DATA_OID",(function(){return Ae})),r.d(t,"BSON_DATA_REGEXP",(function(){return $e})),r.d(t,"BSON_DATA_STRING",(function(){return Ne})),r.d(t,"BSON_DATA_SYMBOL",(function(){return ze})),r.d(t,"BSON_DATA_TIMESTAMP",(function(){return Je})),r.d(t,"BSON_DATA_UNDEFINED",(function(){return Le})),r.d(t,"BSON_INT32_MAX",(function(){return we})),r.d(t,"BSON_INT32_MIN",(function(){return _e})),r.d(t,"BSON_INT64_MAX",(function(){return Se})),r.d(t,"BSON_INT64_MIN",(function(){return Ee})),r.d(t,"Binary",(function(){return x})),r.d(t,"Code",(function(){return O})),r.d(t,"DBRef",(function(){return N})),r.d(t,"Decimal128",(function(){return H})),r.d(t,"Double",(function(){return Z})),r.d(t,"EJSON",(function(){return ye})),r.d(t,"Int32",(function(){return K})),r.d(t,"Long",(function(){return U})),r.d(t,"LongWithoutOverridesClass",(function(){return oe})),r.d(t,"Map",(function(){return be})),r.d(t,"MaxKey",(function(){return W})),r.d(t,"MinKey",(function(){return X})),r.d(t,"ObjectID",(function(){return te})),r.d(t,"ObjectId",(function(){return te})),r.d(t,"Timestamp",(function(){return se})),r.d(t,"UUID",(function(){return E})),r.d(t,"calculateObjectSize",(function(){return Ct})),r.d(t,"deserialize",(function(){return zt})),r.d(t,"deserializeStream",(function(){return kt})),r.d(t,"serialize",(function(){return Mt})),r.d(t,"serializeWithBufferAndIndex",(function(){return Dt})),r.d(t,"setInternalBufferSize",(function(){return $t}));var n=r(0);function i(e){return e&&e.Math==Math&&e}function o(){return i("object"==typeof globalThis&&globalThis)||i("object"==typeof window&&window)||i("object"==typeof self&&self)||i("object"==typeof global&&global)||Function("return this")()}function s(e){return e.toString().replace("function(","function (")}var u=function(e){var t,r="object"==typeof(t=o()).navigator&&"ReactNative"===t.navigator.product?"BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.":"BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.";console.warn(r);for(var i=n.Buffer.alloc(e),s=0;s<e;++s)i[s]=Math.floor(256*Math.random());return i},f=function(){if("undefined"!=typeof window){var e=window.crypto||window.msCrypto;if(e&&e.getRandomValues)return function(t){return e.getRandomValues(n.Buffer.alloc(t))}}if("undefined"!=typeof global&&global.crypto&&global.crypto.getRandomValues)return function(e){return global.crypto.getRandomValues(n.Buffer.alloc(e))};var t;try{t=r(5).randomBytes}catch(e){}return t||u}();function a(e){return["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(e))}function l(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)}function c(e){return"[object BigInt64Array]"===Object.prototype.toString.call(e)}function h(e){return"[object BigUint64Array]"===Object.prototype.toString.call(e)}function p(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function d(e){return g(e)&&"[object Date]"===Object.prototype.toString.call(e)}function g(e){return"object"==typeof e&&null!==e}function y(e,t){var r=!1;return function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];return r||(console.warn(t),r=!0),e.apply(this,n)}}function b(e){if(ArrayBuffer.isView(e))return n.Buffer.from(e.buffer,e.byteOffset,e.byteLength);if(a(e))return n.Buffer.from(e);throw new TypeError("Must use either Buffer or TypedArray")}var m=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i,v=function(e){return"string"==typeof e&&m.test(e)},w=function(e){if(!v(e))throw new TypeError('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".');var t=e.replace(/-/g,"");return n.Buffer.from(t,"hex")},_=function(e,t){return void 0===t&&(t=!0),t?e.toString("hex",0,4)+"-"+e.toString("hex",4,6)+"-"+e.toString("hex",6,8)+"-"+e.toString("hex",8,10)+"-"+e.toString("hex",10,16):e.toString("hex")},S=Symbol("id"),E=function(){function e(t){if(void 0===t)this.id=e.generate();else if(t instanceof e)this[S]=n.Buffer.from(t.id),this.__id=t.__id;else if(ArrayBuffer.isView(t)&&16===t.byteLength)this.id=b(t);else{if("string"!=typeof t)throw new TypeError("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).");this.id=w(t)}}return Object.defineProperty(e.prototype,"id",{get:function(){return this[S]},set:function(t){this[S]=t,e.cacheHexString&&(this.__id=_(t))},enumerable:!1,configurable:!0}),e.prototype.toHexString=function(t){if(void 0===t&&(t=!0),e.cacheHexString&&this.__id)return this.__id;var r=_(this.id,t);return e.cacheHexString&&(this.__id=r),r},e.prototype.toString=function(e){return e?this.id.toString(e):this.toHexString()},e.prototype.toJSON=function(){return this.toHexString()},e.prototype.equals=function(t){if(!t)return!1;if(t instanceof e)return t.id.equals(this.id);try{return new e(t).id.equals(this.id)}catch(e){return!1}},e.prototype.toBinary=function(){return new x(this.id,x.SUBTYPE_UUID)},e.generate=function(){var e=f(16);return e[6]=15&e[6]|64,e[8]=63&e[8]|128,n.Buffer.from(e)},e.isValid=function(t){if(!t)return!1;if(t instanceof e)return!0;if("string"==typeof t)return v(t);if(l(t)){if(16!==t.length)return!1;try{return parseInt(t[6].toString(16)[0],10)===x.SUBTYPE_UUID}catch(e){return!1}}return!1},e.createFromHexString=function(t){return new e(w(t))},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new UUID("'+this.toHexString()+'")'},e}();Object.defineProperty(E.prototype,"_bsontype",{value:"UUID"});var x=function(){function e(t,r){if(!(this instanceof e))return new e(t,r);if(!(null==t||"string"==typeof t||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||Array.isArray(t)))throw new TypeError("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=null!=r?r:e.BSON_BINARY_SUBTYPE_DEFAULT,null==t?(this.buffer=n.Buffer.alloc(e.BUFFER_SIZE),this.position=0):("string"==typeof t?this.buffer=n.Buffer.from(t,"binary"):Array.isArray(t)?this.buffer=n.Buffer.from(t):this.buffer=b(t),this.position=this.buffer.byteLength)}return e.prototype.put=function(t){if("string"==typeof t&&1!==t.length)throw new TypeError("only accepts single character String");if("number"!=typeof t&&1!==t.length)throw new TypeError("only accepts single character Uint8Array or Array");var r;if((r="string"==typeof t?t.charCodeAt(0):"number"==typeof t?t:t[0])<0||r>255)throw new TypeError("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=r;else{var i=n.Buffer.alloc(e.BUFFER_SIZE+this.buffer.length);this.buffer.copy(i,0,0,this.buffer.length),this.buffer=i,this.buffer[this.position++]=r}},e.prototype.write=function(e,t){if(t="number"==typeof t?t:this.position,this.buffer.length<t+e.length){var r=n.Buffer.alloc(this.buffer.length+e.length);this.buffer.copy(r,0,0,this.buffer.length),this.buffer=r}ArrayBuffer.isView(e)?(this.buffer.set(b(e),t),this.position=t+e.byteLength>this.position?t+e.length:this.position):"string"==typeof e&&(this.buffer.write(e,t,e.length,"binary"),this.position=t+e.length>this.position?t+e.length:this.position)},e.prototype.read=function(e,t){return t=t&&t>0?t:this.position,this.buffer.slice(e,e+t)},e.prototype.value=function(e){return(e=!!e)&&this.buffer.length===this.position?this.buffer:e?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position)},e.prototype.length=function(){return this.position},e.prototype.toJSON=function(){return this.buffer.toString("base64")},e.prototype.toString=function(e){return this.buffer.toString(e)},e.prototype.toExtendedJSON=function(e){e=e||{};var t=this.buffer.toString("base64"),r=Number(this.sub_type).toString(16);return e.legacy?{$binary:t,$type:1===r.length?"0"+r:r}:{$binary:{base64:t,subType:1===r.length?"0"+r:r}}},e.prototype.toUUID=function(){if(this.sub_type===e.SUBTYPE_UUID)return new E(this.buffer.slice(0,this.position));throw new Error('Binary sub_type "'+this.sub_type+'" is not supported for converting to UUID. Only "'+e.SUBTYPE_UUID+'" is currently supported.')},e.fromExtendedJSON=function(t,r){var i,o;if(r=r||{},"$binary"in t?r.legacy&&"string"==typeof t.$binary&&"$type"in t?(o=t.$type?parseInt(t.$type,16):0,i=n.Buffer.from(t.$binary,"base64")):"string"!=typeof t.$binary&&(o=t.$binary.subType?parseInt(t.$binary.subType,16):0,i=n.Buffer.from(t.$binary.base64,"base64")):"$uuid"in t&&(o=4,i=w(t.$uuid)),!i)throw new TypeError("Unexpected Binary Extended JSON format "+JSON.stringify(t));return new e(i,o)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new Binary(Buffer.from("'+this.value(!0).toString("hex")+'", "hex"), '+this.sub_type+")"},e.BSON_BINARY_SUBTYPE_DEFAULT=0,e.BUFFER_SIZE=256,e.SUBTYPE_DEFAULT=0,e.SUBTYPE_FUNCTION=1,e.SUBTYPE_BYTE_ARRAY=2,e.SUBTYPE_UUID_OLD=3,e.SUBTYPE_UUID=4,e.SUBTYPE_MD5=5,e.SUBTYPE_USER_DEFINED=128,e}();Object.defineProperty(x.prototype,"_bsontype",{value:"Binary"});var O=function(){function e(t,r){if(!(this instanceof e))return new e(t,r);this.code=t,this.scope=r}return e.prototype.toJSON=function(){return{code:this.code,scope:this.scope}},e.prototype.toExtendedJSON=function(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}},e.fromExtendedJSON=function(t){return new e(t.$code,t.$scope)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){var e=this.toJSON();return'new Code("'+e.code+'"'+(e.scope?", "+JSON.stringify(e.scope):"")+")"},e}();function B(e){return g(e)&&null!=e.$id&&"string"==typeof e.$ref&&(null==e.$db||"string"==typeof e.$db)}Object.defineProperty(O.prototype,"_bsontype",{value:"Code"});var N=function(){function e(t,r,n,i){if(!(this instanceof e))return new e(t,r,n,i);var o=t.split(".");2===o.length&&(n=o.shift(),t=o.shift()),this.collection=t,this.oid=r,this.db=n,this.fields=i||{}}return Object.defineProperty(e.prototype,"namespace",{get:function(){return this.collection},set:function(e){this.collection=e},enumerable:!1,configurable:!0}),e.prototype.toJSON=function(){var e=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(e.$db=this.db),e},e.prototype.toExtendedJSON=function(e){e=e||{};var t={$ref:this.collection,$id:this.oid};return e.legacy?t:(this.db&&(t.$db=this.db),t=Object.assign(t,this.fields))},e.fromExtendedJSON=function(t){var r=Object.assign({},t);return delete r.$ref,delete r.$id,delete r.$db,new e(t.$ref,t.$id,t.$db,r)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){var e=void 0===this.oid||void 0===this.oid.toString?this.oid:this.oid.toString();return'new DBRef("'+this.namespace+'", new ObjectId("'+e+'")'+(this.db?', "'+this.db+'"':"")+")"},e}();Object.defineProperty(N.prototype,"_bsontype",{value:"DBRef"});var j=void 0;try{j=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(e){}var I=4294967296,T=0x10000000000000000,L=T/2,A={},P={},U=function(){function e(t,r,n){if(void 0===t&&(t=0),!(this instanceof e))return new e(t,r,n);"bigint"==typeof t?Object.assign(this,e.fromBigInt(t,!!r)):"string"==typeof t?Object.assign(this,e.fromString(t,!!r)):(this.low=0|t,this.high=0|r,this.unsigned=!!n),Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}return e.fromBits=function(t,r,n){return new e(t,r,n)},e.fromInt=function(t,r){var n,i,o;return r?(o=0<=(t>>>=0)&&t<256)&&(i=P[t])?i:(n=e.fromBits(t,(0|t)<0?-1:0,!0),o&&(P[t]=n),n):(o=-128<=(t|=0)&&t<128)&&(i=A[t])?i:(n=e.fromBits(t,t<0?-1:0,!1),o&&(A[t]=n),n)},e.fromNumber=function(t,r){if(isNaN(t))return r?e.UZERO:e.ZERO;if(r){if(t<0)return e.UZERO;if(t>=T)return e.MAX_UNSIGNED_VALUE}else{if(t<=-L)return e.MIN_VALUE;if(t+1>=L)return e.MAX_VALUE}return t<0?e.fromNumber(-t,r).neg():e.fromBits(t%I|0,t/I|0,r)},e.fromBigInt=function(t,r){return e.fromString(t.toString(),r)},e.fromString=function(t,r,n){if(0===t.length)throw Error("empty string");if("NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return e.ZERO;if("number"==typeof r?(n=r,r=!1):r=!!r,(n=n||10)<2||36<n)throw RangeError("radix");var i;if((i=t.indexOf("-"))>0)throw Error("interior hyphen");if(0===i)return e.fromString(t.substring(1),r,n).neg();for(var o=e.fromNumber(Math.pow(n,8)),s=e.ZERO,u=0;u<t.length;u+=8){var f=Math.min(8,t.length-u),a=parseInt(t.substring(u,u+f),n);if(f<8){var l=e.fromNumber(Math.pow(n,f));s=s.mul(l).add(e.fromNumber(a))}else s=(s=s.mul(o)).add(e.fromNumber(a))}return s.unsigned=r,s},e.fromBytes=function(t,r,n){return n?e.fromBytesLE(t,r):e.fromBytesBE(t,r)},e.fromBytesLE=function(t,r){return new e(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,r)},e.fromBytesBE=function(t,r){return new e(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],r)},e.isLong=function(e){return g(e)&&!0===e.__isLong__},e.fromValue=function(t,r){return"number"==typeof t?e.fromNumber(t,r):"string"==typeof t?e.fromString(t,r):e.fromBits(t.low,t.high,"boolean"==typeof r?r:t.unsigned)},e.prototype.add=function(t){e.isLong(t)||(t=e.fromValue(t));var r=this.high>>>16,n=65535&this.high,i=this.low>>>16,o=65535&this.low,s=t.high>>>16,u=65535&t.high,f=t.low>>>16,a=0,l=0,c=0,h=0;return c+=(h+=o+(65535&t.low))>>>16,h&=65535,l+=(c+=i+f)>>>16,c&=65535,a+=(l+=n+u)>>>16,l&=65535,a+=r+s,a&=65535,e.fromBits(c<<16|h,a<<16|l,this.unsigned)},e.prototype.and=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low&t.low,this.high&t.high,this.unsigned)},e.prototype.compare=function(t){if(e.isLong(t)||(t=e.fromValue(t)),this.eq(t))return 0;var r=this.isNegative(),n=t.isNegative();return r&&!n?-1:!r&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},e.prototype.comp=function(e){return this.compare(e)},e.prototype.divide=function(t){if(e.isLong(t)||(t=e.fromValue(t)),t.isZero())throw Error("division by zero");if(j){if(!this.unsigned&&-2147483648===this.high&&-1===t.low&&-1===t.high)return this;var r=(this.unsigned?j.div_u:j.div_s)(this.low,this.high,t.low,t.high);return e.fromBits(r,j.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?e.UZERO:e.ZERO;var n,i,o;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return e.UZERO;if(t.gt(this.shru(1)))return e.UONE;o=e.UZERO}else{if(this.eq(e.MIN_VALUE))return t.eq(e.ONE)||t.eq(e.NEG_ONE)?e.MIN_VALUE:t.eq(e.MIN_VALUE)?e.ONE:(n=this.shr(1).div(t).shl(1)).eq(e.ZERO)?t.isNegative()?e.ONE:e.NEG_ONE:(i=this.sub(t.mul(n)),o=n.add(i.div(t)));if(t.eq(e.MIN_VALUE))return this.unsigned?e.UZERO:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();o=e.ZERO}for(i=this;i.gte(t);){n=Math.max(1,Math.floor(i.toNumber()/t.toNumber()));for(var s=Math.ceil(Math.log(n)/Math.LN2),u=s<=48?1:Math.pow(2,s-48),f=e.fromNumber(n),a=f.mul(t);a.isNegative()||a.gt(i);)n-=u,a=(f=e.fromNumber(n,this.unsigned)).mul(t);f.isZero()&&(f=e.ONE),o=o.add(f),i=i.sub(a)}return o},e.prototype.div=function(e){return this.divide(e)},e.prototype.equals=function(t){return e.isLong(t)||(t=e.fromValue(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&(this.high===t.high&&this.low===t.low)},e.prototype.eq=function(e){return this.equals(e)},e.prototype.getHighBits=function(){return this.high},e.prototype.getHighBitsUnsigned=function(){return this.high>>>0},e.prototype.getLowBits=function(){return this.low},e.prototype.getLowBitsUnsigned=function(){return this.low>>>0},e.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(e.MIN_VALUE)?64:this.neg().getNumBitsAbs();var t,r=0!==this.high?this.high:this.low;for(t=31;t>0&&0==(r&1<<t);t--);return 0!==this.high?t+33:t+1},e.prototype.greaterThan=function(e){return this.comp(e)>0},e.prototype.gt=function(e){return this.greaterThan(e)},e.prototype.greaterThanOrEqual=function(e){return this.comp(e)>=0},e.prototype.gte=function(e){return this.greaterThanOrEqual(e)},e.prototype.ge=function(e){return this.greaterThanOrEqual(e)},e.prototype.isEven=function(){return 0==(1&this.low)},e.prototype.isNegative=function(){return!this.unsigned&&this.high<0},e.prototype.isOdd=function(){return 1==(1&this.low)},e.prototype.isPositive=function(){return this.unsigned||this.high>=0},e.prototype.isZero=function(){return 0===this.high&&0===this.low},e.prototype.lessThan=function(e){return this.comp(e)<0},e.prototype.lt=function(e){return this.lessThan(e)},e.prototype.lessThanOrEqual=function(e){return this.comp(e)<=0},e.prototype.lte=function(e){return this.lessThanOrEqual(e)},e.prototype.modulo=function(t){if(e.isLong(t)||(t=e.fromValue(t)),j){var r=(this.unsigned?j.rem_u:j.rem_s)(this.low,this.high,t.low,t.high);return e.fromBits(r,j.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))},e.prototype.mod=function(e){return this.modulo(e)},e.prototype.rem=function(e){return this.modulo(e)},e.prototype.multiply=function(t){if(this.isZero())return e.ZERO;if(e.isLong(t)||(t=e.fromValue(t)),j){var r=j.mul(this.low,this.high,t.low,t.high);return e.fromBits(r,j.get_high(),this.unsigned)}if(t.isZero())return e.ZERO;if(this.eq(e.MIN_VALUE))return t.isOdd()?e.MIN_VALUE:e.ZERO;if(t.eq(e.MIN_VALUE))return this.isOdd()?e.MIN_VALUE:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(e.TWO_PWR_24)&&t.lt(e.TWO_PWR_24))return e.fromNumber(this.toNumber()*t.toNumber(),this.unsigned);var n=this.high>>>16,i=65535&this.high,o=this.low>>>16,s=65535&this.low,u=t.high>>>16,f=65535&t.high,a=t.low>>>16,l=65535&t.low,c=0,h=0,p=0,d=0;return p+=(d+=s*l)>>>16,d&=65535,h+=(p+=o*l)>>>16,p&=65535,h+=(p+=s*a)>>>16,p&=65535,c+=(h+=i*l)>>>16,h&=65535,c+=(h+=o*a)>>>16,h&=65535,c+=(h+=s*f)>>>16,h&=65535,c+=n*l+i*a+o*f+s*u,c&=65535,e.fromBits(p<<16|d,c<<16|h,this.unsigned)},e.prototype.mul=function(e){return this.multiply(e)},e.prototype.negate=function(){return!this.unsigned&&this.eq(e.MIN_VALUE)?e.MIN_VALUE:this.not().add(e.ONE)},e.prototype.neg=function(){return this.negate()},e.prototype.not=function(){return e.fromBits(~this.low,~this.high,this.unsigned)},e.prototype.notEquals=function(e){return!this.equals(e)},e.prototype.neq=function(e){return this.notEquals(e)},e.prototype.ne=function(e){return this.notEquals(e)},e.prototype.or=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low|t.low,this.high|t.high,this.unsigned)},e.prototype.shiftLeft=function(t){return e.isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?e.fromBits(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):e.fromBits(0,this.low<<t-32,this.unsigned)},e.prototype.shl=function(e){return this.shiftLeft(e)},e.prototype.shiftRight=function(t){return e.isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?e.fromBits(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):e.fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},e.prototype.shr=function(e){return this.shiftRight(e)},e.prototype.shiftRightUnsigned=function(t){if(e.isLong(t)&&(t=t.toInt()),0===(t&=63))return this;var r=this.high;if(t<32){var n=this.low;return e.fromBits(n>>>t|r<<32-t,r>>>t,this.unsigned)}return 32===t?e.fromBits(r,0,this.unsigned):e.fromBits(r>>>t-32,0,this.unsigned)},e.prototype.shr_u=function(e){return this.shiftRightUnsigned(e)},e.prototype.shru=function(e){return this.shiftRightUnsigned(e)},e.prototype.subtract=function(t){return e.isLong(t)||(t=e.fromValue(t)),this.add(t.neg())},e.prototype.sub=function(e){return this.subtract(e)},e.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},e.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*I+(this.low>>>0):this.high*I+(this.low>>>0)},e.prototype.toBigInt=function(){return BigInt(this.toString())},e.prototype.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},e.prototype.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},e.prototype.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},e.prototype.toSigned=function(){return this.unsigned?e.fromBits(this.low,this.high,!1):this},e.prototype.toString=function(t){if((t=t||10)<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(e.MIN_VALUE)){var r=e.fromNumber(t),n=this.div(r),i=n.mul(r).sub(this);return n.toString(t)+i.toInt().toString(t)}return"-"+this.neg().toString(t)}for(var o=e.fromNumber(Math.pow(t,6),this.unsigned),s=this,u="";;){var f=s.div(o),a=(s.sub(f.mul(o)).toInt()>>>0).toString(t);if((s=f).isZero())return a+u;for(;a.length<6;)a="0"+a;u=""+a+u}},e.prototype.toUnsigned=function(){return this.unsigned?this:e.fromBits(this.low,this.high,!0)},e.prototype.xor=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low^t.low,this.high^t.high,this.unsigned)},e.prototype.eqz=function(){return this.isZero()},e.prototype.le=function(e){return this.lessThanOrEqual(e)},e.prototype.toExtendedJSON=function(e){return e&&e.relaxed?this.toNumber():{$numberLong:this.toString()}},e.fromExtendedJSON=function(t,r){var n=e.fromString(t.$numberLong);return r&&r.relaxed?n.toNumber():n},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new Long("'+this.toString()+'"'+(this.unsigned?", true":"")+")"},e.TWO_PWR_24=e.fromInt(16777216),e.MAX_UNSIGNED_VALUE=e.fromBits(-1,-1,!0),e.ZERO=e.fromInt(0),e.UZERO=e.fromInt(0,!0),e.ONE=e.fromInt(1),e.UONE=e.fromInt(1,!0),e.NEG_ONE=e.fromInt(-1),e.MAX_VALUE=e.fromBits(-1,2147483647,!1),e.MIN_VALUE=e.fromBits(0,-2147483648,!1),e}();Object.defineProperty(U.prototype,"__isLong__",{value:!0}),Object.defineProperty(U.prototype,"_bsontype",{value:"Long"});var R=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,$=/^(\+|-)?(Infinity|inf)$/i,M=/^(\+|-)?NaN$/i,D=6111,z=-6176,C=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),k=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),J=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),V=/^([-+])?(\d+)?$/;function Y(e){return!isNaN(parseInt(e,10))}function q(e){var t=U.fromNumber(1e9),r=U.fromNumber(0);if(!(e.parts[0]||e.parts[1]||e.parts[2]||e.parts[3]))return{quotient:e,rem:r};for(var n=0;n<=3;n++)r=(r=r.shiftLeft(32)).add(new U(e.parts[n],0)),e.parts[n]=r.div(t).low,r=r.modulo(t);return{quotient:e,rem:r}}function F(e,t){throw new TypeError('"'+e+'" is not a valid Decimal128 string - '+t)}var H=function(){function e(t){if(!(this instanceof e))return new e(t);this.bytes="string"==typeof t?e.fromString(t).bytes:t}return e.fromString=function(t){var r,i=!1,o=!1,s=!1,u=0,f=0,a=0,l=0,c=0,h=[0],p=0,d=0,g=0,y=0,b=0,m=0,v=new U(0,0),w=new U(0,0),_=0;if(t.length>=7e3)throw new TypeError(t+" not a valid Decimal128 string");var S=t.match(R),E=t.match($),x=t.match(M);if(!S&&!E&&!x||0===t.length)throw new TypeError(t+" not a valid Decimal128 string");if(S){var O=S[2],B=S[4],N=S[5],j=S[6];B&&void 0===j&&F(t,"missing exponent power"),B&&void 0===O&&F(t,"missing exponent base"),void 0===B&&(N||j)&&F(t,"missing e before exponent")}if("+"!==t[_]&&"-"!==t[_]||(i="-"===t[_++]),!Y(t[_])&&"."!==t[_]){if("i"===t[_]||"I"===t[_])return new e(n.Buffer.from(i?k:J));if("N"===t[_])return new e(n.Buffer.from(C))}for(;Y(t[_])||"."===t[_];)"."!==t[_]?(p<34&&("0"!==t[_]||s)&&(s||(c=f),s=!0,h[d++]=parseInt(t[_],10),p+=1),s&&(a+=1),o&&(l+=1),f+=1,_+=1):(o&&F(t,"contains multiple periods"),o=!0,_+=1);if(o&&!f)throw new TypeError(t+" not a valid Decimal128 string");if("e"===t[_]||"E"===t[_]){var I=t.substr(++_).match(V);if(!I||!I[2])return new e(n.Buffer.from(C));b=parseInt(I[0],10),_+=I[0].length}if(t[_])return new e(n.Buffer.from(C));if(g=0,p){if(y=p-1,1!==(u=a))for(;0===h[c+u-1];)u-=1}else g=0,y=0,h[0]=0,a=1,p=1,u=0;for(b<=l&&l-b>16384?b=z:b-=l;b>D;){if((y+=1)-g>34){if(h.join("").match(/^0+$/)){b=D;break}F(t,"overflow")}b-=1}for(;b<z||p<a;){if(0===y&&u<p){b=z,u=0;break}if(p<a?a-=1:y-=1,b<D)b+=1;else{if(h.join("").match(/^0+$/)){b=D;break}F(t,"overflow")}}if(y-g+1<u){var T=f;o&&(c+=1,T+=1),i&&(c+=1,T+=1);var L=parseInt(t[c+y+1],10),A=0;if(L>=5&&(A=1,5===L))for(A=h[y]%2==1?1:0,m=c+y+2;m<T;m++)if(parseInt(t[m],10)){A=1;break}if(A)for(var P=y;P>=0;P--)if(++h[P]>9&&(h[P]=0,0===P)){if(!(b<D))return new e(n.Buffer.from(i?k:J));b+=1,h[P]=1}}if(v=U.fromNumber(0),w=U.fromNumber(0),0===u)v=U.fromNumber(0),w=U.fromNumber(0);else if(y-g<17){P=g;for(w=U.fromNumber(h[P++]),v=new U(0,0);P<=y;P++)w=(w=w.multiply(U.fromNumber(10))).add(U.fromNumber(h[P]))}else{P=g;for(v=U.fromNumber(h[P++]);P<=y-17;P++)v=(v=v.multiply(U.fromNumber(10))).add(U.fromNumber(h[P]));for(w=U.fromNumber(h[P++]);P<=y;P++)w=(w=w.multiply(U.fromNumber(10))).add(U.fromNumber(h[P]))}var q,H,Z,K,W=function(e,t){if(!e&&!t)return{high:U.fromNumber(0),low:U.fromNumber(0)};var r=e.shiftRightUnsigned(32),n=new U(e.getLowBits(),0),i=t.shiftRightUnsigned(32),o=new U(t.getLowBits(),0),s=r.multiply(i),u=r.multiply(o),f=n.multiply(i),a=n.multiply(o);return s=s.add(u.shiftRightUnsigned(32)),u=new U(u.getLowBits(),0).add(f).add(a.shiftRightUnsigned(32)),{high:s=s.add(u.shiftRightUnsigned(32)),low:a=u.shiftLeft(32).add(new U(a.getLowBits(),0))}}(v,U.fromString("100000000000000000"));W.low=W.low.add(w),q=W.low,H=w,Z=q.high>>>0,K=H.high>>>0,(Z<K||Z===K&&q.low>>>0<H.low>>>0)&&(W.high=W.high.add(U.fromNumber(1))),r=b+6176;var X={low:U.fromNumber(0),high:U.fromNumber(0)};W.high.shiftRightUnsigned(49).and(U.fromNumber(1)).equals(U.fromNumber(1))?(X.high=X.high.or(U.fromNumber(3).shiftLeft(61)),X.high=X.high.or(U.fromNumber(r).and(U.fromNumber(16383).shiftLeft(47))),X.high=X.high.or(W.high.and(U.fromNumber(0x7fffffffffff)))):(X.high=X.high.or(U.fromNumber(16383&r).shiftLeft(49)),X.high=X.high.or(W.high.and(U.fromNumber(562949953421311)))),X.low=W.low,i&&(X.high=X.high.or(U.fromString("9223372036854775808")));var G=n.Buffer.alloc(16);return _=0,G[_++]=255&X.low.low,G[_++]=X.low.low>>8&255,G[_++]=X.low.low>>16&255,G[_++]=X.low.low>>24&255,G[_++]=255&X.low.high,G[_++]=X.low.high>>8&255,G[_++]=X.low.high>>16&255,G[_++]=X.low.high>>24&255,G[_++]=255&X.high.low,G[_++]=X.high.low>>8&255,G[_++]=X.high.low>>16&255,G[_++]=X.high.low>>24&255,G[_++]=255&X.high.high,G[_++]=X.high.high>>8&255,G[_++]=X.high.high>>16&255,G[_++]=X.high.high>>24&255,new e(G)},e.prototype.toString=function(){for(var e,t=0,r=new Array(36),n=0;n<r.length;n++)r[n]=0;var i,o,s,u=0,f=!1,a={parts:[0,0,0,0]},l=[];u=0;var c=this.bytes,h=c[u++]|c[u++]<<8|c[u++]<<16|c[u++]<<24,p=c[u++]|c[u++]<<8|c[u++]<<16|c[u++]<<24,d=c[u++]|c[u++]<<8|c[u++]<<16|c[u++]<<24,g=c[u++]|c[u++]<<8|c[u++]<<16|c[u++]<<24;u=0,{low:new U(h,p),high:new U(d,g)}.high.lessThan(U.ZERO)&&l.push("-");var y=g>>26&31;if(y>>3==3){if(30===y)return l.join("")+"Infinity";if(31===y)return"NaN";e=g>>15&16383,i=8+(g>>14&1)}else i=g>>14&7,e=g>>17&16383;var b=e-6176;if(a.parts[0]=(16383&g)+((15&i)<<14),a.parts[1]=d,a.parts[2]=p,a.parts[3]=h,0===a.parts[0]&&0===a.parts[1]&&0===a.parts[2]&&0===a.parts[3])f=!0;else for(s=3;s>=0;s--){var m=0,v=q(a);if(a=v.quotient,m=v.rem.low)for(o=8;o>=0;o--)r[9*s+o]=m%10,m=Math.floor(m/10)}if(f)t=1,r[u]=0;else for(t=36;!r[u];)t-=1,u+=1;var w=t-1+b;if(w>=34||w<=-7||b>0){if(t>34)return l.push("0"),b>0?l.push("E+"+b):b<0&&l.push("E"+b),l.join("");l.push(""+r[u++]),(t-=1)&&l.push(".");for(n=0;n<t;n++)l.push(""+r[u++]);l.push("E"),w>0?l.push("+"+w):l.push(""+w)}else if(b>=0)for(n=0;n<t;n++)l.push(""+r[u++]);else{var _=t+b;if(_>0)for(n=0;n<_;n++)l.push(""+r[u++]);else l.push("0");for(l.push(".");_++<0;)l.push("0");for(n=0;n<t-Math.max(_-1,0);n++)l.push(""+r[u++])}return l.join("")},e.prototype.toJSON=function(){return{$numberDecimal:this.toString()}},e.prototype.toExtendedJSON=function(){return{$numberDecimal:this.toString()}},e.fromExtendedJSON=function(t){return e.fromString(t.$numberDecimal)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new Decimal128("'+this.toString()+'")'},e}();Object.defineProperty(H.prototype,"_bsontype",{value:"Decimal128"});var Z=function(){function e(t){if(!(this instanceof e))return new e(t);t instanceof Number&&(t=t.valueOf()),this.value=+t}return e.prototype.valueOf=function(){return this.value},e.prototype.toJSON=function(){return this.value},e.prototype.toString=function(e){return this.value.toString(e)},e.prototype.toExtendedJSON=function(e){return e&&(e.legacy||e.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-"+this.value.toFixed(1)}:(Number.isInteger(this.value)?(t=this.value.toFixed(1)).length>=13&&(t=this.value.toExponential(13).toUpperCase()):t=this.value.toString(),{$numberDouble:t});var t},e.fromExtendedJSON=function(t,r){var n=parseFloat(t.$numberDouble);return r&&r.relaxed?n:new e(n)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new Double("+this.toExtendedJSON().$numberDouble+")"},e}();Object.defineProperty(Z.prototype,"_bsontype",{value:"Double"});var K=function(){function e(t){if(!(this instanceof e))return new e(t);t instanceof Number&&(t=t.valueOf()),this.value=+t}return e.prototype.valueOf=function(){return this.value},e.prototype.toString=function(e){return this.value.toString(e)},e.prototype.toJSON=function(){return this.value},e.prototype.toExtendedJSON=function(e){return e&&(e.relaxed||e.legacy)?this.value:{$numberInt:this.value.toString()}},e.fromExtendedJSON=function(t,r){return r&&r.relaxed?parseInt(t.$numberInt,10):new e(t.$numberInt)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new Int32("+this.valueOf()+")"},e}();Object.defineProperty(K.prototype,"_bsontype",{value:"Int32"});var W=function(){function e(){if(!(this instanceof e))return new e}return e.prototype.toExtendedJSON=function(){return{$maxKey:1}},e.fromExtendedJSON=function(){return new e},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new MaxKey()"},e}();Object.defineProperty(W.prototype,"_bsontype",{value:"MaxKey"});var X=function(){function e(){if(!(this instanceof e))return new e}return e.prototype.toExtendedJSON=function(){return{$minKey:1}},e.fromExtendedJSON=function(){return new e},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new MinKey()"},e}();Object.defineProperty(X.prototype,"_bsontype",{value:"MinKey"});var G=new RegExp("^[0-9a-fA-F]{24}$"),Q=null,ee=Symbol("id"),te=function(){function e(t){if(!(this instanceof e))return new e(t);if(t instanceof e&&(this[ee]=t.id,this.__id=t.__id),"object"==typeof t&&t&&"id"in t&&("toHexString"in t&&"function"==typeof t.toHexString?this[ee]=n.Buffer.from(t.toHexString(),"hex"):this[ee]="string"==typeof t.id?n.Buffer.from(t.id):t.id),null!=t&&"number"!=typeof t||(this[ee]=e.generate("number"==typeof t?t:void 0),e.cacheHexString&&(this.__id=this.id.toString("hex"))),ArrayBuffer.isView(t)&&12===t.byteLength&&(this[ee]=b(t)),"string"==typeof t)if(12===t.length){var r=n.Buffer.from(t);12===r.byteLength&&(this[ee]=r)}else{if(24!==t.length||!G.test(t))throw new TypeError("Argument passed in must be a Buffer or string of 12 bytes or a string of 24 hex characters");this[ee]=n.Buffer.from(t,"hex")}e.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(e.prototype,"id",{get:function(){return this[ee]},set:function(t){this[ee]=t,e.cacheHexString&&(this.__id=t.toString("hex"))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"generationTime",{get:function(){return this.id.readInt32BE(0)},set:function(e){this.id.writeUInt32BE(e,0)},enumerable:!1,configurable:!0}),e.prototype.toHexString=function(){if(e.cacheHexString&&this.__id)return this.__id;var t=this.id.toString("hex");return e.cacheHexString&&!this.__id&&(this.__id=t),t},e.getInc=function(){return e.index=(e.index+1)%16777215},e.generate=function(t){"number"!=typeof t&&(t=~~(Date.now()/1e3));var r=e.getInc(),i=n.Buffer.alloc(12);return i.writeUInt32BE(t,0),null===Q&&(Q=f(5)),i[4]=Q[0],i[5]=Q[1],i[6]=Q[2],i[7]=Q[3],i[8]=Q[4],i[11]=255&r,i[10]=r>>8&255,i[9]=r>>16&255,i},e.prototype.toString=function(e){return e?this.id.toString(e):this.toHexString()},e.prototype.toJSON=function(){return this.toHexString()},e.prototype.equals=function(t){return null!=t&&(t instanceof e?this.toString()===t.toString():"string"==typeof t&&e.isValid(t)&&12===t.length&&l(this.id)?t===n.Buffer.prototype.toString.call(this.id,"latin1"):"string"==typeof t&&e.isValid(t)&&24===t.length?t.toLowerCase()===this.toHexString():"string"==typeof t&&e.isValid(t)&&12===t.length?n.Buffer.from(t).equals(this.id):"object"==typeof t&&"toHexString"in t&&"function"==typeof t.toHexString&&t.toHexString()===this.toHexString())},e.prototype.getTimestamp=function(){var e=new Date,t=this.id.readUInt32BE(0);return e.setTime(1e3*Math.floor(t)),e},e.createPk=function(){return new e},e.createFromTime=function(t){var r=n.Buffer.from([0,0,0,0,0,0,0,0,0,0,0,0]);return r.writeUInt32BE(t,0),new e(r)},e.createFromHexString=function(t){if(void 0===t||null!=t&&24!==t.length)throw new TypeError("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new e(n.Buffer.from(t,"hex"))},e.isValid=function(t){return null!=t&&("number"==typeof t||("string"==typeof t?12===t.length||24===t.length&&G.test(t):t instanceof e||(!(!l(t)||12!==t.length)||"object"==typeof t&&"toHexString"in t&&"function"==typeof t.toHexString&&("string"==typeof t.id?12===t.id.length:24===t.toHexString().length&&G.test(t.id.toString("hex"))))))},e.prototype.toExtendedJSON=function(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}},e.fromExtendedJSON=function(t){return new e(t.$oid)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new ObjectId("'+this.toHexString()+'")'},e.index=~~(16777215*Math.random()),e}();Object.defineProperty(te.prototype,"generate",{value:y((function(e){return te.generate(e)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(te.prototype,"getInc",{value:y((function(){return te.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(te.prototype,"get_inc",{value:y((function(){return te.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(te,"get_inc",{value:y((function(){return te.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(te.prototype,"_bsontype",{value:"ObjectID"});var re=function(){function e(t,r){if(!(this instanceof e))return new e(t,r);this.pattern=t,this.options=(null!=r?r:"").split("").sort().join("");for(var n=0;n<this.options.length;n++)if("i"!==this.options[n]&&"m"!==this.options[n]&&"x"!==this.options[n]&&"l"!==this.options[n]&&"s"!==this.options[n]&&"u"!==this.options[n])throw new Error("The regular expression option ["+this.options[n]+"] is not supported")}return e.parseOptions=function(e){return e?e.split("").sort().join(""):""},e.prototype.toExtendedJSON=function(e){return(e=e||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}},e.fromExtendedJSON=function(t){if("$regex"in t){if("string"==typeof t.$regex)return new e(t.$regex,e.parseOptions(t.$options));if("BSONRegExp"===t.$regex._bsontype)return t}if("$regularExpression"in t)return new e(t.$regularExpression.pattern,e.parseOptions(t.$regularExpression.options));throw new TypeError("Unexpected BSONRegExp EJSON object form: "+JSON.stringify(t))},e}();Object.defineProperty(re.prototype,"_bsontype",{value:"BSONRegExp"});var ne=function(){function e(t){if(!(this instanceof e))return new e(t);this.value=t}return e.prototype.valueOf=function(){return this.value},e.prototype.toString=function(){return this.value},e.prototype.inspect=function(){return'new BSONSymbol("'+this.value+'")'},e.prototype.toJSON=function(){return this.value},e.prototype.toExtendedJSON=function(){return{$symbol:this.value}},e.fromExtendedJSON=function(t){return new e(t.$symbol)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e}();Object.defineProperty(ne.prototype,"_bsontype",{value:"Symbol"});var ie=function(e,t){return(ie=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};var oe=U,se=function(e){function t(r,n){var i=this;return i instanceof t?(i=U.isLong(r)?e.call(this,r.low,r.high,!0)||this:g(r)&&void 0!==r.t&&void 0!==r.i?e.call(this,r.i,r.t,!0)||this:e.call(this,r,n,!0)||this,Object.defineProperty(i,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1}),i):new t(r,n)}return function(e,t){function r(){this.constructor=e}ie(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t.prototype.toJSON=function(){return{$timestamp:this.toString()}},t.fromInt=function(e){return new t(U.fromInt(e,!0))},t.fromNumber=function(e){return new t(U.fromNumber(e,!0))},t.fromBits=function(e,r){return new t(e,r)},t.fromString=function(e,r){return new t(U.fromString(e,!0,r))},t.prototype.toExtendedJSON=function(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}},t.fromExtendedJSON=function(e){return new t(e.$timestamp)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new Timestamp({ t: "+this.getHighBits()+", i: "+this.getLowBits()+" })"},t.MAX_VALUE=U.MAX_UNSIGNED_VALUE,t}(oe);function ue(e){return g(e)&&Reflect.has(e,"_bsontype")&&"string"==typeof e._bsontype}var fe=2147483647,ae=-2147483648,le=0x8000000000000000,ce=-0x8000000000000000,he={$oid:te,$binary:x,$uuid:x,$symbol:ne,$numberInt:K,$numberDecimal:H,$numberDouble:Z,$numberLong:U,$minKey:X,$maxKey:W,$regex:re,$regularExpression:re,$timestamp:se};function pe(e,t){if(void 0===t&&(t={}),"number"==typeof e){if(t.relaxed||t.legacy)return e;if(Math.floor(e)===e){if(e>=ae&&e<=fe)return new K(e);if(e>=ce&&e<=le)return U.fromNumber(e)}return new Z(e)}if(null==e||"object"!=typeof e)return e;if(e.$undefined)return null;for(var r=Object.keys(e).filter((function(t){return t.startsWith("$")&&null!=e[t]})),n=0;n<r.length;n++){var i=he[r[n]];if(i)return i.fromExtendedJSON(e,t)}if(null!=e.$date){var o=e.$date,s=new Date;return t.legacy?"number"==typeof o?s.setTime(o):"string"==typeof o&&s.setTime(Date.parse(o)):"string"==typeof o?s.setTime(Date.parse(o)):U.isLong(o)?s.setTime(o.toNumber()):"number"==typeof o&&t.relaxed&&s.setTime(o),s}if(null!=e.$code){var u=Object.assign({},e);return e.$scope&&(u.$scope=pe(e.$scope)),O.fromExtendedJSON(e)}if(B(e)||e.$dbPointer){var f=e.$ref?e:e.$dbPointer;if(f instanceof N)return f;var a=Object.keys(f).filter((function(e){return e.startsWith("$")})),l=!0;if(a.forEach((function(e){-1===["$ref","$id","$db"].indexOf(e)&&(l=!1)})),l)return N.fromExtendedJSON(f)}return e}function de(e){var t=e.toISOString();return 0!==e.getUTCMilliseconds()?t:t.slice(0,-5)+"Z"}function ge(e,t){if(("object"==typeof e||"function"==typeof e)&&null!==e){var r=t.seenObjects.findIndex((function(t){return t.obj===e}));if(-1!==r){var n=t.seenObjects.map((function(e){return e.propertyName})),i=n.slice(0,r).map((function(e){return e+" -> "})).join(""),o=n[r],s=" -> "+n.slice(r+1,n.length-1).map((function(e){return e+" -> "})).join(""),u=n[n.length-1],f=" ".repeat(i.length+o.length/2),a="-".repeat(s.length+(o.length+u.length)/2-1);throw new TypeError("Converting circular structure to EJSON:\n "+i+o+s+u+"\n "+f+"\\"+a+"/")}t.seenObjects[t.seenObjects.length-1].obj=e}if(Array.isArray(e))return function(e,t){return e.map((function(e,r){t.seenObjects.push({propertyName:"index "+r,obj:null});try{return ge(e,t)}finally{t.seenObjects.pop()}}))}(e,t);if(void 0===e)return null;if(e instanceof Date||d(e)){var l=e.getTime(),c=l>-1&&l<2534023188e5;return t.legacy?t.relaxed&&c?{$date:e.getTime()}:{$date:de(e)}:t.relaxed&&c?{$date:de(e)}:{$date:{$numberLong:e.getTime().toString()}}}if(!("number"!=typeof e||t.relaxed&&isFinite(e))){if(Math.floor(e)===e){var h=e>=ce&&e<=le;if(e>=ae&&e<=fe)return{$numberInt:e.toString()};if(h)return{$numberLong:e.toString()}}return{$numberDouble:e.toString()}}if(e instanceof RegExp||p(e)){var g=e.flags;if(void 0===g){var y=e.toString().match(/[gimuy]*$/);y&&(g=y[0])}return new re(e.source,g).toExtendedJSON(t)}return null!=e&&"object"==typeof e?function(e,t){if(null==e||"object"!=typeof e)throw new Error("not an object instance");var r=e._bsontype;if(void 0===r){var n={};for(var i in e){t.seenObjects.push({propertyName:i,obj:null});try{n[i]=ge(e[i],t)}finally{t.seenObjects.pop()}}return n}if(ue(e)){var o=e;if("function"!=typeof o.toExtendedJSON){var s=me[e._bsontype];if(!s)throw new TypeError("Unrecognized or invalid _bsontype: "+e._bsontype);o=s(o)}return"Code"===r&&o.scope?o=new O(o.code,ge(o.scope,t)):"DBRef"===r&&o.oid&&(o=new N(ge(o.collection,t),ge(o.oid,t),ge(o.db,t),ge(o.fields,t))),o.toExtendedJSON(t)}throw new Error("_bsontype must be a string, but was: "+typeof r)}(e,t):e}var ye,be,me={Binary:function(e){return new x(e.value(),e.sub_type)},Code:function(e){return new O(e.code,e.scope)},DBRef:function(e){return new N(e.collection||e.namespace,e.oid,e.db,e.fields)},Decimal128:function(e){return new H(e.bytes)},Double:function(e){return new Z(e.value)},Int32:function(e){return new K(e.value)},Long:function(e){return U.fromBits(null!=e.low?e.low:e.low_,null!=e.low?e.high:e.high_,null!=e.low?e.unsigned:e.unsigned_)},MaxKey:function(){return new W},MinKey:function(){return new X},ObjectID:function(e){return new te(e)},ObjectId:function(e){return new te(e)},BSONRegExp:function(e){return new re(e.pattern,e.options)},Symbol:function(e){return new ne(e.value)},Timestamp:function(e){return se.fromBits(e.low,e.high)}};!function(e){function t(e,t){var r=Object.assign({},{relaxed:!0,legacy:!1},t);return"boolean"==typeof r.relaxed&&(r.strict=!r.relaxed),"boolean"==typeof r.strict&&(r.relaxed=!r.strict),JSON.parse(e,(function(e,t){return pe(t,r)}))}function r(e,t,r,n){null!=r&&"object"==typeof r&&(n=r,r=0),null==t||"object"!=typeof t||Array.isArray(t)||(n=t,t=void 0,r=0);var i=ge(e,Object.assign({relaxed:!0,legacy:!1},n,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(i,t,r)}e.parse=t,e.stringify=r,e.serialize=function(e,t){return t=t||{},JSON.parse(r(e,t))},e.deserialize=function(e,r){return r=r||{},t(JSON.stringify(e),r)}}(ye||(ye={}));var ve=o();be=ve.Map?ve.Map:function(){function e(e){void 0===e&&(e=[]),this._keys=[],this._values={};for(var t=0;t<e.length;t++)if(null!=e[t]){var r=e[t],n=r[0],i=r[1];this._keys.push(n),this._values[n]={v:i,i:this._keys.length-1}}}return e.prototype.clear=function(){this._keys=[],this._values={}},e.prototype.delete=function(e){var t=this._values[e];return null!=t&&(delete this._values[e],this._keys.splice(t.i,1),!0)},e.prototype.entries=function(){var e=this,t=0;return{next:function(){var r=e._keys[t++];return{value:void 0!==r?[r,e._values[r].v]:void 0,done:void 0===r}}}},e.prototype.forEach=function(e,t){t=t||this;for(var r=0;r<this._keys.length;r++){var n=this._keys[r];e.call(t,this._values[n].v,n,t)}},e.prototype.get=function(e){return this._values[e]?this._values[e].v:void 0},e.prototype.has=function(e){return null!=this._values[e]},e.prototype.keys=function(){var e=this,t=0;return{next:function(){var r=e._keys[t++];return{value:void 0!==r?r:void 0,done:void 0===r}}}},e.prototype.set=function(e,t){return this._values[e]?(this._values[e].v=t,this):(this._keys.push(e),this._values[e]={v:t,i:this._keys.length-1},this)},e.prototype.values=function(){var e=this,t=0;return{next:function(){var r=e._keys[t++];return{value:void 0!==r?e._values[r].v:void 0,done:void 0===r}}}},Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!1,configurable:!0}),e}();var we=2147483647,_e=-2147483648,Se=Math.pow(2,63)-1,Ee=-Math.pow(2,63),xe=Math.pow(2,53),Oe=-Math.pow(2,53),Be=1,Ne=2,je=3,Ie=4,Te=5,Le=6,Ae=7,Pe=8,Ue=9,Re=10,$e=11,Me=12,De=13,ze=14,Ce=15,ke=16,Je=17,Ve=18,Ye=19,qe=255,Fe=127,He=0,Ze=1,Ke=2,We=3,Xe=4,Ge=5,Qe=128;function et(e,t,r){var n=5;if(Array.isArray(e))for(var i=0;i<e.length;i++)n+=tt(i.toString(),e[i],t,!0,r);else for(var o in e.toBSON&&(e=e.toBSON()),e)n+=tt(o,e[o],t,!1,r);return n}function tt(e,t,r,i,o){switch(void 0===r&&(r=!1),void 0===i&&(i=!1),void 0===o&&(o=!1),t&&t.toBSON&&(t=t.toBSON()),typeof t){case"string":return 1+n.Buffer.byteLength(e,"utf8")+1+4+n.Buffer.byteLength(t,"utf8")+1;case"number":return Math.floor(t)===t&&t>=Oe&&t<=xe&&t>=_e&&t<=we?(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+5:(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+9;case"undefined":return i||!o?(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+1:0;case"boolean":return(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+2;case"object":if(null==t||"MinKey"===t._bsontype||"MaxKey"===t._bsontype)return(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+1;if("ObjectId"===t._bsontype||"ObjectID"===t._bsontype)return(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+13;if(t instanceof Date||d(t))return(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+9;if(ArrayBuffer.isView(t)||t instanceof ArrayBuffer||a(t))return(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+6+t.byteLength;if("Long"===t._bsontype||"Double"===t._bsontype||"Timestamp"===t._bsontype)return(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+9;if("Decimal128"===t._bsontype)return(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+17;if("Code"===t._bsontype)return null!=t.scope&&Object.keys(t.scope).length>0?(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+1+4+4+n.Buffer.byteLength(t.code.toString(),"utf8")+1+et(t.scope,r,o):(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+1+4+n.Buffer.byteLength(t.code.toString(),"utf8")+1;if("Binary"===t._bsontype)return t.sub_type===x.SUBTYPE_BYTE_ARRAY?(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+(t.position+1+4+1+4):(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+(t.position+1+4+1);if("Symbol"===t._bsontype)return(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+n.Buffer.byteLength(t.value,"utf8")+4+1+1;if("DBRef"===t._bsontype){var u=Object.assign({$ref:t.collection,$id:t.oid},t.fields);return null!=t.db&&(u.$db=t.db),(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+1+et(u,r,o)}return t instanceof RegExp||p(t)?(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+1+n.Buffer.byteLength(t.source,"utf8")+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1:"BSONRegExp"===t._bsontype?(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+1+n.Buffer.byteLength(t.pattern,"utf8")+1+n.Buffer.byteLength(t.options,"utf8")+1:(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+et(t,r,o)+1;case"function":if(t instanceof RegExp||p(t)||"[object RegExp]"===String.call(t))return(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+1+n.Buffer.byteLength(t.source,"utf8")+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1;if(r&&null!=t.scope&&Object.keys(t.scope).length>0)return(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+1+4+4+n.Buffer.byteLength(s(t),"utf8")+1+et(t.scope,r,o);if(r)return(null!=e?n.Buffer.byteLength(e,"utf8")+1:0)+1+4+n.Buffer.byteLength(s(t),"utf8")+1}return 0}function rt(e,t,r){for(var n=0,i=t;i<r;i+=1){var o=e[i];if(n){if(128!=(192&o))return!1;n-=1}else if(128&o)if(192==(224&o))n=1;else if(224==(240&o))n=2;else{if(240!=(248&o))return!1;n=3}}return!n}var nt=U.fromNumber(xe),it=U.fromNumber(Oe),ot={};function st(e,t,r){var n=(t=null==t?{}:t)&&t.index?t.index:0,i=e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24;if(i<5)throw new Error("bson size must be >= 5, is "+i);if(t.allowObjectSmallerThanBufferSize&&e.length<i)throw new Error("buffer length "+e.length+" must be >= bson size "+i);if(!t.allowObjectSmallerThanBufferSize&&e.length!==i)throw new Error("buffer length "+e.length+" must === bson size "+i);if(i+n>e.byteLength)throw new Error("(bson size "+i+" + options.index "+n+" must be <= buffer length "+e.byteLength+")");if(0!==e[n+i-1])throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return ft(e,n,t,r)}var ut=/^\$ref$|^\$id$|^\$db$/;function ft(e,t,r,i){void 0===i&&(i=!1);var o=null!=r.evalFunctions&&r.evalFunctions,s=null!=r.cacheFunctions&&r.cacheFunctions,u=null==r.fieldsAsRaw?null:r.fieldsAsRaw,f=null!=r.raw&&r.raw,a="boolean"==typeof r.bsonRegExp&&r.bsonRegExp,l=null!=r.promoteBuffers&&r.promoteBuffers,c=null==r.promoteLongs||r.promoteLongs,h=null==r.promoteValues||r.promoteValues,p=t;if(e.length<5)throw new Error("corrupt bson message < 5 bytes long");var d=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(d<5||d>e.length)throw new Error("corrupt bson message");for(var g=i?[]:{},y=0,b=!i&&null;;){var m=e[t++];if(0===m)break;for(var v=t;0!==e[v]&&v<e.length;)v++;if(v>=e.byteLength)throw new Error("Bad BSON Document: illegal CString");var w=i?y++:e.toString("utf8",t,v);!1!==b&&"$"===w[0]&&(b=ut.test(w));var _=void 0;if(t=v+1,m===Ne){if((ie=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<=0||ie>e.length-t||0!==e[t+ie-1])throw new Error("bad string length in bson");_=e.toString("utf8",t,t+ie-1);for(var S=0;S<_.length;S++)if(65533===_.charCodeAt(S)){if(!rt(e,t,t+ie-1))throw new Error("Invalid UTF-8 string in BSON document");break}t+=ie}else if(m===Ae){var E=n.Buffer.alloc(12);e.copy(E,0,t,t+12),_=new te(E),t+=12}else if(m===ke&&!1===h)_=new K(e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24);else if(m===ke)_=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;else if(m===Be&&!1===h)_=new Z(e.readDoubleLE(t)),t+=8;else if(m===Be)_=e.readDoubleLE(t),t+=8;else if(m===Ue){var j=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,I=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;_=new Date(new U(j,I).toNumber())}else if(m===Pe){if(0!==e[t]&&1!==e[t])throw new Error("illegal boolean type value");_=1===e[t++]}else if(m===je){var T=t;if((Q=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)<=0||Q>e.length-t)throw new Error("bad embedded document length in bson");_=f?e.slice(t,t+Q):ft(e,T,r,!1),t+=Q}else if(m===Ie){T=t;var L=r,A=t+(Q=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24);if(u&&u[w]){for(var P in L={},r)L[P]=r[P];L.raw=!0}if(_=ft(e,T,L,!0),0!==e[(t+=Q)-1])throw new Error("invalid array terminator byte");if(t!==A)throw new Error("corrupted array bson")}else if(m===Le)_=void 0;else if(m===Re)_=null;else if(m===Ve){j=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,I=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;var R=new U(j,I);_=c&&!0===h&&R.lessThanOrEqual(nt)&&R.greaterThanOrEqual(it)?R.toNumber():R}else if(m===Ye){var $=n.Buffer.alloc(16);e.copy($,0,t,t+16),t+=16;var M=new H($);_="toObject"in M&&"function"==typeof M.toObject?M.toObject():M}else if(m===Te){var D=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,z=D,C=e[t++];if(D<0)throw new Error("Negative binary type element size found");if(D>e.byteLength)throw new Error("Binary type size larger than document size");if(null!=e.slice){if(C===x.SUBTYPE_BYTE_ARRAY){if((D=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<0)throw new Error("Negative binary type element size found for subtype 0x02");if(D>z-4)throw new Error("Binary type with subtype 0x02 contains too long binary size");if(D<z-4)throw new Error("Binary type with subtype 0x02 contains too short binary size")}_=l&&h?e.slice(t,t+D):new x(e.slice(t,t+D),C)}else{var k=n.Buffer.alloc(D);if(C===x.SUBTYPE_BYTE_ARRAY){if((D=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<0)throw new Error("Negative binary type element size found for subtype 0x02");if(D>z-4)throw new Error("Binary type with subtype 0x02 contains too long binary size");if(D<z-4)throw new Error("Binary type with subtype 0x02 contains too short binary size")}for(v=0;v<D;v++)k[v]=e[t+v];_=l&&h?k:new x(k,C)}t+=D}else if(m===$e&&!1===a){for(v=t;0!==e[v]&&v<e.length;)v++;if(v>=e.length)throw new Error("Bad BSON Document: illegal CString");var J=e.toString("utf8",t,v);for(v=t=v+1;0!==e[v]&&v<e.length;)v++;if(v>=e.length)throw new Error("Bad BSON Document: illegal CString");var V=e.toString("utf8",t,v);t=v+1;var Y=new Array(V.length);for(v=0;v<V.length;v++)switch(V[v]){case"m":Y[v]="m";break;case"s":Y[v]="g";break;case"i":Y[v]="i"}_=new RegExp(J,Y.join(""))}else if(m===$e&&!0===a){for(v=t;0!==e[v]&&v<e.length;)v++;if(v>=e.length)throw new Error("Bad BSON Document: illegal CString");J=e.toString("utf8",t,v);for(v=t=v+1;0!==e[v]&&v<e.length;)v++;if(v>=e.length)throw new Error("Bad BSON Document: illegal CString");V=e.toString("utf8",t,v);t=v+1,_=new re(J,V)}else if(m===ze){if((ie=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<=0||ie>e.length-t||0!==e[t+ie-1])throw new Error("bad string length in bson");var q=e.toString("utf8",t,t+ie-1);_=h?q:new ne(q),t+=ie}else if(m===Je){j=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,I=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;_=new se(j,I)}else if(m===qe)_=new X;else if(m===Fe)_=new W;else if(m===De){if((ie=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<=0||ie>e.length-t||0!==e[t+ie-1])throw new Error("bad string length in bson");var F=e.toString("utf8",t,t+ie-1);_=o?s?at(F,ot,g):at(F):new O(F),t+=ie}else if(m===Ce){var G=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(G<13)throw new Error("code_w_scope total size shorter minimum expected length");if((ie=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<=0||ie>e.length-t||0!==e[t+ie-1])throw new Error("bad string length in bson");F=e.toString("utf8",t,t+ie-1),T=t+=ie;var Q=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,ee=ft(e,T,r,!1);if(t+=Q,G<8+Q+ie)throw new Error("code_w_scope total size is too short, truncating scope");if(G>8+Q+ie)throw new Error("code_w_scope total size is too long, clips outer document");o?(_=s?at(F,ot,g):at(F)).scope=ee:_=new O(F,ee)}else{if(m!==Me)throw new Error("Detected unknown BSON type "+m.toString(16)+' for fieldname "'+w+'"');var ie;if((ie=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<=0||ie>e.length-t||0!==e[t+ie-1])throw new Error("bad string length in bson");if(!rt(e,t,t+ie-1))throw new Error("Invalid UTF-8 string in BSON document");var oe=e.toString("utf8",t,t+ie-1);t+=ie;var ue=n.Buffer.alloc(12);e.copy(ue,0,t,t+12);E=new te(ue);t+=12,_=new N(oe,E)}"__proto__"===w?Object.defineProperty(g,w,{value:_,writable:!0,enumerable:!0,configurable:!0}):g[w]=_}if(d!==t-p){if(i)throw new Error("corrupt array bson");throw new Error("corrupt object bson")}if(!b)return g;if(B(g)){var fe=Object.assign({},g);return delete fe.$ref,delete fe.$id,delete fe.$db,new N(g.$ref,g.$id,g.$db,fe)}return g}function at(e,t,r){return t?(null==t[e]&&(t[e]=new Function(e)),t[e].bind(r)):new Function(e)}function lt(e,t,r,n,i,o){var s,u,f,a="big"===n,l=8*o-i-1,c=(1<<l)-1,h=c>>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=a?o-1:0,g=a?-1:1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-s))<1&&(s--,f*=2),(t+=s+h>=1?p/f:p*Math.pow(2,1-h))*f>=2&&(s++,f/=2),s+h>=c?(u=0,s=c):s+h>=1?(u=(t*f-1)*Math.pow(2,i),s+=h):(u=t*Math.pow(2,h-1)*Math.pow(2,i),s=0)),isNaN(t)&&(u=0);i>=8;)e[r+d]=255&u,d+=g,u/=256,i-=8;for(s=s<<i|u,isNaN(t)&&(s+=8),l+=i;l>0;)e[r+d]=255&s,d+=g,s/=256,l-=8;e[r+d-g]|=128*y}var ct=/\x00/,ht=new Set(["$db","$ref","$id","$clusterTime"]);function pt(e,t,r,n,i){e[n++]=Ne;var o=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8");e[(n=n+o+1)-1]=0;var s=e.write(r,n+4,void 0,"utf8");return e[n+3]=s+1>>24&255,e[n+2]=s+1>>16&255,e[n+1]=s+1>>8&255,e[n]=s+1&255,n=n+4+s,e[n++]=0,n}function dt(e,t,r,n,i){Number.isInteger(r)&&r>=_e&&r<=we?(e[n++]=ke,n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,e[n++]=255&r,e[n++]=r>>8&255,e[n++]=r>>16&255,e[n++]=r>>24&255):(e[n++]=Be,n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,lt(e,r,n,"little",52,8),n+=8);return n}function gt(e,t,r,n,i){return e[n++]=Re,n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,n}function yt(e,t,r,n,i){return e[n++]=Pe,n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,e[n++]=r?1:0,n}function bt(e,t,r,n,i){e[n++]=Ue,n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;var o=U.fromNumber(r.getTime()),s=o.getLowBits(),u=o.getHighBits();return e[n++]=255&s,e[n++]=s>>8&255,e[n++]=s>>16&255,e[n++]=s>>24&255,e[n++]=255&u,e[n++]=u>>8&255,e[n++]=u>>16&255,e[n++]=u>>24&255,n}function mt(e,t,r,n,i){if(e[n++]=$e,n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,r.source&&null!=r.source.match(ct))throw Error("value "+r.source+" must not contain null bytes");return n+=e.write(r.source,n,void 0,"utf8"),e[n++]=0,r.ignoreCase&&(e[n++]=105),r.global&&(e[n++]=115),r.multiline&&(e[n++]=109),e[n++]=0,n}function vt(e,t,r,n,i){if(e[n++]=$e,n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,null!=r.pattern.match(ct))throw Error("pattern "+r.pattern+" must not contain null bytes");return n+=e.write(r.pattern,n,void 0,"utf8"),e[n++]=0,n+=e.write(r.options.split("").sort().join(""),n,void 0,"utf8"),e[n++]=0,n}function wt(e,t,r,n,i){return null===r?e[n++]=Re:"MinKey"===r._bsontype?e[n++]=qe:e[n++]=Fe,n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,n}function _t(e,t,r,n,i){if(e[n++]=Ae,n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,"string"==typeof r.id)e.write(r.id,n,void 0,"binary");else{if(!l(r.id))throw new TypeError("object ["+JSON.stringify(r)+"] is not a valid ObjectId");e.set(r.id.subarray(0,12),n)}return n+12}function St(e,t,r,n,i){e[n++]=Te,n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;var o=r.length;return e[n++]=255&o,e[n++]=o>>8&255,e[n++]=o>>16&255,e[n++]=o>>24&255,e[n++]=He,e.set(b(r),n),n+=o}function Et(e,t,r,n,i,o,s,u,f,a){void 0===i&&(i=!1),void 0===o&&(o=0),void 0===s&&(s=!1),void 0===u&&(u=!0),void 0===f&&(f=!1),void 0===a&&(a=[]);for(var l=0;l<a.length;l++)if(a[l]===r)throw new Error("cyclic dependency detected");a.push(r),e[n++]=Array.isArray(r)?Ie:je,n+=f?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;var c=Pt(e,r,i,n,o+1,s,u,a);return a.pop(),c}function xt(e,t,r,n,i){return e[n++]=Ye,n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,e.set(r.bytes.subarray(0,16),n),n+16}function Ot(e,t,r,n,i){e[n++]="Long"===r._bsontype?Ve:Je,n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;var o=r.getLowBits(),s=r.getHighBits();return e[n++]=255&o,e[n++]=o>>8&255,e[n++]=o>>16&255,e[n++]=o>>24&255,e[n++]=255&s,e[n++]=s>>8&255,e[n++]=s>>16&255,e[n++]=s>>24&255,n}function Bt(e,t,r,n,i){return r=r.valueOf(),e[n++]=ke,n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,e[n++]=255&r,e[n++]=r>>8&255,e[n++]=r>>16&255,e[n++]=r>>24&255,n}function Nt(e,t,r,n,i){return e[n++]=Be,n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0,lt(e,r.value,n,"little",52,8),n+=8}function jt(e,t,r,n,i,o,u){e[n++]=De,n+=u?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;var f=s(r),a=e.write(f,n+4,void 0,"utf8")+1;return e[n]=255&a,e[n+1]=a>>8&255,e[n+2]=a>>16&255,e[n+3]=a>>24&255,n=n+4+a-1,e[n++]=0,n}function It(e,t,r,n,i,o,s,u,f){if(void 0===i&&(i=!1),void 0===o&&(o=0),void 0===s&&(s=!1),void 0===u&&(u=!0),void 0===f&&(f=!1),r.scope&&"object"==typeof r.scope){e[n++]=Ce,n+=f?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;var a=n,l="string"==typeof r.code?r.code:r.code.toString();n+=4;var c=e.write(l,n+4,void 0,"utf8")+1;e[n]=255&c,e[n+1]=c>>8&255,e[n+2]=c>>16&255,e[n+3]=c>>24&255,e[n+4+c-1]=0,n=n+c+4;var h=Pt(e,r.scope,i,n,o+1,s,u);n=h-1;var p=h-a;e[a++]=255&p,e[a++]=p>>8&255,e[a++]=p>>16&255,e[a++]=p>>24&255,e[n++]=0}else{e[n++]=De,n+=f?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;l=r.code.toString();var d=e.write(l,n+4,void 0,"utf8")+1;e[n]=255&d,e[n+1]=d>>8&255,e[n+2]=d>>16&255,e[n+3]=d>>24&255,n=n+4+d-1,e[n++]=0}return n}function Tt(e,t,r,n,i){e[n++]=Te,n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;var o=r.value(!0),s=r.position;return r.sub_type===x.SUBTYPE_BYTE_ARRAY&&(s+=4),e[n++]=255&s,e[n++]=s>>8&255,e[n++]=s>>16&255,e[n++]=s>>24&255,e[n++]=r.sub_type,r.sub_type===x.SUBTYPE_BYTE_ARRAY&&(s-=4,e[n++]=255&s,e[n++]=s>>8&255,e[n++]=s>>16&255,e[n++]=s>>24&255),e.set(o,n),n+=r.position}function Lt(e,t,r,n,i){e[n++]=ze,n+=i?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;var o=e.write(r.value,n+4,void 0,"utf8")+1;return e[n]=255&o,e[n+1]=o>>8&255,e[n+2]=o>>16&255,e[n+3]=o>>24&255,n=n+4+o-1,e[n++]=0,n}function At(e,t,r,n,i,o,s){e[n++]=je,n+=s?e.write(t,n,void 0,"ascii"):e.write(t,n,void 0,"utf8"),e[n++]=0;var u=n,f={$ref:r.collection||r.namespace,$id:r.oid};null!=r.db&&(f.$db=r.db);var a=Pt(e,f=Object.assign(f,r.fields),!1,n,i+1,o),l=a-u;return e[u++]=255&l,e[u++]=l>>8&255,e[u++]=l>>16&255,e[u++]=l>>24&255,a}function Pt(e,t,r,n,i,o,s,u){void 0===r&&(r=!1),void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=!1),void 0===s&&(s=!0),void 0===u&&(u=[]),n=n||0,(u=u||[]).push(t);var f,a=n+4;if(Array.isArray(t))for(var g=0;g<t.length;g++){var y=""+g;if((_=t[g])&&_.toBSON){if("function"!=typeof _.toBSON)throw new TypeError("toBSON is not a function");_=_.toBSON()}if("string"==typeof _)a=pt(e,y,_,a,!0);else if("number"==typeof _)a=dt(e,y,_,a,!0);else{if("bigint"==typeof _)throw new TypeError("Unsupported type BigInt, please use Decimal128");if("boolean"==typeof _)a=yt(e,y,_,a,!0);else if(_ instanceof Date||d(_))a=bt(e,y,_,a,!0);else if(void 0===_)a=gt(e,y,0,a,!0);else if(null===_)a=gt(e,y,0,a,!0);else if("ObjectId"===_._bsontype||"ObjectID"===_._bsontype)a=_t(e,y,_,a,!0);else if(l(_))a=St(e,y,_,a,!0);else if(_ instanceof RegExp||p(_))a=mt(e,y,_,a,!0);else if("object"==typeof _&&null==_._bsontype)a=Et(e,y,_,a,r,i,o,s,!0,u);else if("object"==typeof _&&ue(_)&&"Decimal128"===_._bsontype)a=xt(e,y,_,a,!0);else if("Long"===_._bsontype||"Timestamp"===_._bsontype)a=Ot(e,y,_,a,!0);else if("Double"===_._bsontype)a=Nt(e,y,_,a,!0);else if("function"==typeof _&&o)a=jt(e,y,_,a,0,0,!0);else if("Code"===_._bsontype)a=It(e,y,_,a,r,i,o,s,!0);else if("Binary"===_._bsontype)a=Tt(e,y,_,a,!0);else if("Symbol"===_._bsontype)a=Lt(e,y,_,a,!0);else if("DBRef"===_._bsontype)a=At(e,y,_,a,i,o,!0);else if("BSONRegExp"===_._bsontype)a=vt(e,y,_,a,!0);else if("Int32"===_._bsontype)a=Bt(e,y,_,a,!0);else if("MinKey"===_._bsontype||"MaxKey"===_._bsontype)a=wt(e,y,_,a,!0);else if(void 0!==_._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+_._bsontype)}}else if(t instanceof be||(f=t,"[object Map]"===Object.prototype.toString.call(f)))for(var b=t.entries(),m=!1;!m;){var v=b.next();if(!(m=!!v.done)){y=v.value[0];var w=typeof(_=v.value[1]);if("string"==typeof y&&!ht.has(y)){if(null!=y.match(ct))throw Error("key "+y+" must not contain null bytes");if(r){if("$"===y[0])throw Error("key "+y+" must not start with '$'");if(~y.indexOf("."))throw Error("key "+y+" must not contain '.'")}}if("string"===w)a=pt(e,y,_,a);else if("number"===w)a=dt(e,y,_,a);else{if("bigint"===w||c(_)||h(_))throw new TypeError("Unsupported type BigInt, please use Decimal128");if("boolean"===w)a=yt(e,y,_,a);else if(_ instanceof Date||d(_))a=bt(e,y,_,a);else if(null===_||void 0===_&&!1===s)a=gt(e,y,0,a);else if("ObjectId"===_._bsontype||"ObjectID"===_._bsontype)a=_t(e,y,_,a);else if(l(_))a=St(e,y,_,a);else if(_ instanceof RegExp||p(_))a=mt(e,y,_,a);else if("object"===w&&null==_._bsontype)a=Et(e,y,_,a,r,i,o,s,!1,u);else if("object"===w&&"Decimal128"===_._bsontype)a=xt(e,y,_,a);else if("Long"===_._bsontype||"Timestamp"===_._bsontype)a=Ot(e,y,_,a);else if("Double"===_._bsontype)a=Nt(e,y,_,a);else if("Code"===_._bsontype)a=It(e,y,_,a,r,i,o,s);else if("function"==typeof _&&o)a=jt(e,y,_,a,0,0,o);else if("Binary"===_._bsontype)a=Tt(e,y,_,a);else if("Symbol"===_._bsontype)a=Lt(e,y,_,a);else if("DBRef"===_._bsontype)a=At(e,y,_,a,i,o);else if("BSONRegExp"===_._bsontype)a=vt(e,y,_,a);else if("Int32"===_._bsontype)a=Bt(e,y,_,a);else if("MinKey"===_._bsontype||"MaxKey"===_._bsontype)a=wt(e,y,_,a);else if(void 0!==_._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+_._bsontype)}}}else{if(t.toBSON){if("function"!=typeof t.toBSON)throw new TypeError("toBSON is not a function");if(null!=(t=t.toBSON())&&"object"!=typeof t)throw new TypeError("toBSON function did not return an object")}for(var y in t){var _;if((_=t[y])&&_.toBSON){if("function"!=typeof _.toBSON)throw new TypeError("toBSON is not a function");_=_.toBSON()}w=typeof _;if("string"==typeof y&&!ht.has(y)){if(null!=y.match(ct))throw Error("key "+y+" must not contain null bytes");if(r){if("$"===y[0])throw Error("key "+y+" must not start with '$'");if(~y.indexOf("."))throw Error("key "+y+" must not contain '.'")}}if("string"===w)a=pt(e,y,_,a);else if("number"===w)a=dt(e,y,_,a);else{if("bigint"===w)throw new TypeError("Unsupported type BigInt, please use Decimal128");if("boolean"===w)a=yt(e,y,_,a);else if(_ instanceof Date||d(_))a=bt(e,y,_,a);else if(void 0===_)!1===s&&(a=gt(e,y,0,a));else if(null===_)a=gt(e,y,0,a);else if("ObjectId"===_._bsontype||"ObjectID"===_._bsontype)a=_t(e,y,_,a);else if(l(_))a=St(e,y,_,a);else if(_ instanceof RegExp||p(_))a=mt(e,y,_,a);else if("object"===w&&null==_._bsontype)a=Et(e,y,_,a,r,i,o,s,!1,u);else if("object"===w&&"Decimal128"===_._bsontype)a=xt(e,y,_,a);else if("Long"===_._bsontype||"Timestamp"===_._bsontype)a=Ot(e,y,_,a);else if("Double"===_._bsontype)a=Nt(e,y,_,a);else if("Code"===_._bsontype)a=It(e,y,_,a,r,i,o,s);else if("function"==typeof _&&o)a=jt(e,y,_,a,0,0,o);else if("Binary"===_._bsontype)a=Tt(e,y,_,a);else if("Symbol"===_._bsontype)a=Lt(e,y,_,a);else if("DBRef"===_._bsontype)a=At(e,y,_,a,i,o);else if("BSONRegExp"===_._bsontype)a=vt(e,y,_,a);else if("Int32"===_._bsontype)a=Bt(e,y,_,a);else if("MinKey"===_._bsontype||"MaxKey"===_._bsontype)a=wt(e,y,_,a);else if(void 0!==_._bsontype)throw new TypeError("Unrecognized or invalid _bsontype: "+_._bsontype)}}}u.pop(),e[a++]=0;var S=a-n;return e[n++]=255&S,e[n++]=S>>8&255,e[n++]=S>>16&255,e[n++]=S>>24&255,a}var Ut=17825792,Rt=n.Buffer.alloc(Ut);function $t(e){Rt.length<e&&(Rt=n.Buffer.alloc(e))}function Mt(e,t){void 0===t&&(t={});var r="boolean"==typeof t.checkKeys&&t.checkKeys,i="boolean"==typeof t.serializeFunctions&&t.serializeFunctions,o="boolean"!=typeof t.ignoreUndefined||t.ignoreUndefined,s="number"==typeof t.minInternalBufferSize?t.minInternalBufferSize:Ut;Rt.length<s&&(Rt=n.Buffer.alloc(s));var u=Pt(Rt,e,r,0,0,i,o,[]),f=n.Buffer.alloc(u);return Rt.copy(f,0,0,f.length),f}function Dt(e,t,r){void 0===r&&(r={});var n="boolean"==typeof r.checkKeys&&r.checkKeys,i="boolean"==typeof r.serializeFunctions&&r.serializeFunctions,o="boolean"!=typeof r.ignoreUndefined||r.ignoreUndefined,s="number"==typeof r.index?r.index:0,u=Pt(Rt,e,n,0,0,i,o);return Rt.copy(t,s,0,u),s+u-1}function zt(e,t){return void 0===t&&(t={}),st(e instanceof n.Buffer?e:b(e),t)}function Ct(e,t){return void 0===t&&(t={}),et(e,"boolean"==typeof(t=t||{}).serializeFunctions&&t.serializeFunctions,"boolean"!=typeof t.ignoreUndefined||t.ignoreUndefined)}function kt(e,t,r,n,i,o){for(var s=Object.assign({allowObjectSmallerThanBufferSize:!0,index:0},o),u=b(e),f=t,a=0;a<r;a++){var l=u[f]|u[f+1]<<8|u[f+2]<<16|u[f+3]<<24;s.index=f,n[i+a]=st(u,s),f+=l}return f}var Jt={Binary:x,Code:O,DBRef:N,Decimal128:H,Double:Z,Int32:K,Long:U,UUID:E,Map:be,MaxKey:W,MinKey:X,ObjectId:te,ObjectID:te,BSONRegExp:re,BSONSymbol:ne,Timestamp:se,EJSON:ye,setInternalBufferSize:$t,serialize:Mt,serializeWithBufferAndIndex:Dt,deserialize:zt,calculateObjectSize:Ct,deserializeStream:kt};t.default=Jt},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChildProcessEvaluationListener=void 0;const n=r(2);t.ChildProcessEvaluationListener=class ChildProcessEvaluationListener{constructor(e,t){this.exposedListener=n.exposeAll({onPrompt(t,r){var n,i,o;return null!==(o=null===(i=null===(n=e.evaluationListener)||void 0===n?void 0:n.onPrompt)||void 0===i?void 0:i.call(n,t,r))&&void 0!==o?o:""},onPrint(t){var r,n;return null===(n=null===(r=e.evaluationListener)||void 0===r?void 0:r.onPrint)||void 0===n?void 0:n.call(r,t)},setConfig(t,r){var n,i,o;return null!==(o=null===(i=null===(n=e.evaluationListener)||void 0===n?void 0:n.setConfig)||void 0===i?void 0:i.call(n,t,r))&&void 0!==o?o:Promise.resolve("ignored")},validateConfig(t,r){var n,i,o;return null!==(o=null===(i=null===(n=e.evaluationListener)||void 0===n?void 0:n.validateConfig)||void 0===i?void 0:i.call(n,t,r))&&void 0!==o?o:Promise.resolve(null)},getConfig(t){var r,n;return null===(n=null===(r=e.evaluationListener)||void 0===r?void 0:r.getConfig)||void 0===n?void 0:n.call(r,t)},listConfigOptions(){var t,r;return null===(r=null===(t=e.evaluationListener)||void 0===t?void 0:t.listConfigOptions)||void 0===r?void 0:r.call(t)},onClearCommand(){var t,r;return null===(r=null===(t=e.evaluationListener)||void 0===t?void 0:t.onClearCommand)||void 0===r?void 0:r.call(t)},onExit(t){var r,n,i;return null!==(i=null===(n=null===(r=e.evaluationListener)||void 0===r?void 0:r.onExit)||void 0===n?void 0:n.call(r,t))&&void 0!==i?i:Promise.resolve()}},t)}terminate(){this.exposedListener[n.close]()}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChildProcessMongoshBus=void 0;const n=r(2);t.ChildProcessMongoshBus=class ChildProcessMongoshBus{constructor(e,t){const r=n.exposeAll({emit(...t){e.emit(...t)},on(){throw new Error("Can't use `on` method on ChildProcessMongoshBus")},once(){throw new Error("Can't use `once` method on ChildProcessMongoshBus")}},t);this.exposedEmitter=r}terminate(){this.exposedEmitter[n.close]()}}}])}));
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(global,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t){e.exports=require("buffer")},function(e,t,n){"use strict";var r,i,o,s=n(15),u="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";function f(){o=!1}function a(e){if(e){if(e!==r){if(e.length!==u.length)throw new Error("Custom alphabet for shortid must be "+u.length+" unique characters. You submitted "+e.length+" characters: "+e);var t=e.split("").filter((function(e,t,n){return t!==n.lastIndexOf(e)}));if(t.length)throw new Error("Custom alphabet for shortid must be "+u.length+" unique characters. These characters were not unique: "+t.join(", "));r=e,f()}}else r!==u&&(r=u,f())}function l(){return o||(o=function(){r||a(u);for(var e,t=r.split(""),n=[],i=s.nextValue();t.length>0;)i=s.nextValue(),e=Math.floor(i*t.length),n.push(t.splice(e,1)[0]);return n.join("")}())}e.exports={get:function(){return r||u},characters:function(e){return a(e),r},seed:function(e){s.seed(e),i!==e&&(f(),i=e)},lookup:function(e){return l()[e]},shuffled:l}},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.createCaller=t.exposeAll=t.cancel=t.close=t.removeTrailingUndefined=t.deserialize=t.serialize=void 0;const i=r(n(10)),o=n(11),s=n(6);function u(e){return`data:;base64,${i.default.serialize(e).toString("base64")}`}function f(e){return/^data:;base64,.+/.test(e)?i.default.deserialize(Buffer.from(e.replace("data:;base64,",""),"base64")):e}var a;function l(e){return e&&"object"==typeof e&&"id"in e&&"sender"in e}function c(e){return l(e)&&"postmsg-rpc/server"===e.sender}function h(e){return l(e)&&"postmsg-rpc/client"===e.sender}function p(e){if(Array.isArray(e))for(e=[...e];e.length>0&&void 0===e[e.length-1];)e.pop();return e}function d(e){return{addListener:e.on.bind(e),removeListener:e.off.bind(e),postMessage(t){if(h(t)&&Array.isArray(t.args)&&(t.args=u(p(t.args))),c(t))try{t.res=u(t.res)}catch(e){t.res=u({type:a.Error,payload:s.serializeError(e)})}return function(e,t){"postMessage"in e&&"function"==typeof e.postMessage&&e.postMessage(t),"send"in e&&"function"==typeof e.send&&e.send(t)}(e,t)},getMessageData:e=>(h(e)&&e.args&&"string"==typeof e.args&&(e.args=f(e.args)),c(e)&&"string"==typeof e.res&&(e.res=f(e.res)),e)}}t.serialize=u,t.deserialize=f,function(e){e[e.Message=0]="Message",e[e.Error=1]="Error"}(a||(a={})),t.removeTrailingUndefined=p,t.close=Symbol("@@rpc.close"),t.cancel=Symbol("@@rpc.cancel"),t.exposeAll=function(e,n){return Object.entries(e).forEach((([e,t])=>{const{close:r}=o.expose(e,(async(...e)=>{try{return{type:a.Message,payload:await t(...e)}}catch(e){return{type:a.Error,payload:s.serializeError(e)}}}),d(n));t.close=r})),Object.defineProperty(e,t.close,{enumerable:!1,value(){Object.values(e).forEach((e=>{e.close()}))}}),e},t.createCaller=function(e,n){const r={},i=new Set;return e.forEach((e=>{const t=o.caller(e,d(n));r[e]=async(...e)=>{const n=t(...e);i.add(n);const r=await n;if(i.delete(n),(o=r)&&"object"==typeof o&&o.type===a.Error)throw s.deserializeError(r.payload);var o;return r.payload}})),Object.defineProperty(r,t.cancel,{enumerable:!1,value(){for(const e of i)e.cancel(),i.delete(e)}}),r}},function(e,t){e.exports=require("child_process")},function(e,t){e.exports=require("events")},function(e,t){e.exports=require("crypto")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deserializeEvaluationResult=t.serializeEvaluationResult=t.SerializedResultTypes=t.deserializeError=t.serializeError=void 0;const r=n(25),i=n(26);function o(e){var t;return(t=e,Object.getOwnPropertyNames(t)).concat("name").reduce(((t,n)=>(t[n]=e[n],t)),{})}function s(e){return Object.assign(new Error,e)}var u;t.serializeError=o,t.deserializeError=s,function(e){e.SerializedErrorResult="SerializedErrorResult",e.InspectResult="InspectResult",e.SerializedShellApiResult="SerializedShellApiResult"}(u=t.SerializedResultTypes||(t.SerializedResultTypes={})),t.serializeEvaluationResult=function({type:e,printable:t,source:n}){return"object"!=typeof(s=t)&&"function"!=typeof s||null===s?{type:e,printable:t,source:n}:function(e){return e&&e.name&&e.message&&e.stack}(t)?{type:u.SerializedErrorResult,printable:o(t),source:n}:null===e?{type:u.InspectResult,printable:r.inspect(t),source:n}:{type:u.SerializedShellApiResult,printable:{origType:e,serializedValue:i.EJSON.serialize(t)}};var s},t.deserializeEvaluationResult=function({type:e,printable:t,source:n}){return e===u.SerializedErrorResult?{type:e,printable:s(t),source:n}:e===u.SerializedShellApiResult?{type:t.origType,printable:i.EJSON.deserialize(t.serializedValue),source:n}:{type:e,printable:t,source:n}}},function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.WorkerRuntime=void 0;const i=n(3),o=r(n(8)),s=n(4),u=n(9),f=n(2),a=n(27),l=n(6),c=n(28);t.WorkerRuntime=class WorkerRuntime{constructor(e,t={},n={},r={},i=new s.EventEmitter){this.evaluationListener=null,this.childProcessProxySrcPath=process.env.CHILD_PROCESS_PROXY_SRC_PATH_DO_NOT_USE_THIS_EXCEPT_FOR_TESTING||o.default.resolve(__dirname,"child-process-proxy.js"),this.initOptions={uri:e,driverOptions:t,cliOptions:n,spawnOptions:r},this.eventEmitter=i,this.initWorkerPromise=this.initWorker()}async initWorker(){var e,t,n;const{uri:r,driverOptions:o,cliOptions:u,spawnOptions:l}=this.initOptions;this.childProcess=i.spawn(process.execPath,[this.childProcessProxySrcPath],{stdio:["inherit","inherit","pipe","ipc"],...l});let h="";null===(n=null===(t=null===(e=this.childProcess)||void 0===e?void 0:e.stderr)||void 0===t?void 0:t.setEncoding("utf8"))||void 0===n||n.on("data",(e=>{h+=e}));await Promise.race([(async()=>{let e;for(;[e]=await s.once(this.childProcess,"message");)if("ready"===e)return})(),(async()=>{const[e]=await s.once(this.childProcess,"exit");if(e){let t=function(e){const[,t]=e.split(/^\s*\^\s*$/m).map((e=>e.trim()));if(t){const e=new Error,n=t.substring(0,t.search(/^\s*at/m))||t,[r,...i]=n.split(": ");return e.name=r,e.message=i.join(": ").trim(),e.stack=t,e}return null}(h);throw t?t.message=`Child process failed to start with the following error: ${t.message}`:t=new Error(`Worker runtime failed to start: child process exited with code ${e}`),t}})()]),this.childProcess.setMaxListeners(25),this.childProcessRuntime=f.createCaller(["init","evaluate","getCompletions","setEvaluationListener","getShellPrompt","interrupt"],this.childProcess),this.childProcessEvaluationListener=new a.ChildProcessEvaluationListener(this,this.childProcess),this.childProcessMongoshBus=new c.ChildProcessMongoshBus(this.eventEmitter,this.childProcess),await this.childProcessRuntime.init(r,o,u)}async evaluate(e){return await this.initWorkerPromise,l.deserializeEvaluationResult(await this.childProcessRuntime.evaluate(e))}async getCompletions(e){return await this.initWorkerPromise,await this.childProcessRuntime.getCompletions(e)}async getShellPrompt(){return await this.initWorkerPromise,await this.childProcessRuntime.getShellPrompt()}setEvaluationListener(e){const t=this.evaluationListener;return this.evaluationListener=e,t}async terminate(){try{await this.initWorkerPromise}catch(e){}await u.kill(this.childProcess),this.childProcessRuntime&&this.childProcessRuntime[f.cancel](),this.childProcessEvaluationListener&&this.childProcessEvaluationListener.terminate(),this.childProcessMongoshBus&&this.childProcessMongoshBus.terminate()}async interrupt(){return await this.initWorkerPromise,this.childProcessRuntime.interrupt()}async waitForRuntimeToBeReady(){await this.initWorkerPromise}}},function(e,t){e.exports=require("path")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.kill=void 0;const r=n(3),i=n(4);async function o(e,t="SIGTERM"){e.kill(t),null===e.exitCode&&null===e.signalCode&&await i.once(e,"exit")}t.kill=o,t.default=function(e,t={},n,i="inherit",s="inherit"){return new Promise((async(u,f)=>{const a=Date.now().toString(32),l=r.spawn(process.execPath,{stdio:["pipe",i,s,"ipc"],...t});if(!l.stdin)return await o(l),f(new Error("Can't write src to the spawned process, missing stdin"));let c;function h(){c&&clearTimeout(c),l.stdin&&l.stdin.off("error",d),l.off("message",g),l.off("exit",p)}function p(e){e&&e>0&&(h(),f(new Error("Child process exited with error before starting")))}async function d(e){h(),await o(l),f(e)}function g(e){e===a&&(h(),u(l))}l.on("message",g),l.on("exit",p),l.stdin.on("error",d),l.stdin.write(e),l.stdin.write(`;process.send(${JSON.stringify(a)})`),l.stdin.end(),c=void 0!==n?setTimeout((async function(){h(),await o(l),f(new Error("Timed out while waiting for child process to start"))}),n):null}))}},function(e,t){e.exports=require("v8")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(12);Object.defineProperty(t,"caller",{enumerable:!0,get:function(){return o(r).default}}),Object.defineProperty(t,"call",{enumerable:!0,get:function(){return r.call}});var i=n(24);function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"expose",{enumerable:!0,get:function(){return o(i).default}})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=s,t.call=function(e){return s(e).apply(null,[].slice.call(arguments,1))};var r,i=n(13),o=(r=i)&&r.__esModule?r:{default:r};function s(e,t){var n=(t=t||{}).addListener||window.addEventListener,r=t.removeListener||window.removeEventListener,i=t.postMessage||window.postMessage,s=t.targetOrigin||"*",u=t.getMessageData||function(e){return e.data};return function(){var t={sender:"postmsg-rpc/client",id:(0,o.default)(),func:e,args:Array.from(arguments)},f=void 0,a=new Promise((function(o,a){var l=function n(){var i=u.apply(null,arguments);if(i&&"postmsg-rpc/server"===i.sender&&i.id===t.id){if(r("message",n),i.err){var s=new Error("Unexpected error calling "+e);return Object.assign(s,i.err),a(s)}o(i.res)}};f=function(){r("message",l);var t=new Error("Canceled call to "+e);t.isCanceled=!0,a(t)},n("message",l),i(t,s)}));return a.cancel=function(){return f()},a}}},function(e,t,n){"use strict";e.exports=n(14)},function(e,t,n){"use strict";var r=n(1),i=n(16),o=n(21),s=n(22)||0;function u(){return i(s)}e.exports=u,e.exports.generate=u,e.exports.seed=function(t){return r.seed(t),e.exports},e.exports.worker=function(t){return s=t,e.exports},e.exports.characters=function(e){return void 0!==e&&r.characters(e),r.shuffled()},e.exports.isValid=o},function(e,t,n){"use strict";var r=1;e.exports={nextValue:function(){return(r=(9301*r+49297)%233280)/233280},seed:function(e){r=e}}},function(e,t,n){"use strict";var r,i,o=n(17);n(1);e.exports=function(e){var t="",n=Math.floor(.001*(Date.now()-1567752802062));return n===i?r++:(r=0,i=n),t+=o(7),t+=o(e),r>0&&(t+=o(r)),t+=o(n)}},function(e,t,n){"use strict";var r=n(1),i=n(18),o=n(20);e.exports=function(e){for(var t,n=0,s="";!t;)s+=o(i,r.get(),1),t=e<Math.pow(16,n+1),n++;return s}},function(e,t,n){e.exports=n(19)},function(e,t,n){var r=n(5);if(r.randomFillSync){var i={};e.exports=function(e){var t=i[e];return t||(t=Buffer.allocUnsafe(e),e<=255&&(i[e]=t)),r.randomFillSync(t)}}else e.exports=r.randomBytes},function(e,t){e.exports=function(e,t,n){for(var r=(2<<31-Math.clz32(t.length-1|1))-1,i=Math.ceil(1.6*r*n/t.length),o="";;)for(var s=e(i),u=i;u--;)if((o+=t[s[u]&r]||"").length===+n)return o}},function(e,t,n){"use strict";var r=n(1);e.exports=function(e){return!(!e||"string"!=typeof e||e.length<6)&&!new RegExp("[^"+r.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]").test(e)}},function(e,t,n){"use strict";var r=n(23),i=0;!r.isMaster&&r.worker&&(i=r.worker.id),e.exports=parseInt(process.env.NODE_UNIQUE_ID||i,10)},function(e,t){e.exports=require("cluster")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,n){var r=(n=n||{}).addListener||window.addEventListener,i=n.removeListener||window.removeEventListener,o=n.postMessage||window.postMessage,s=n.targetOrigin||"*",u=n.getMessageData||function(e){return e.data},f=n.isCallback||!1,a=function(){var n=u.apply(null,arguments);if(n&&"postmsg-rpc/client"===n.sender&&n.func===e){var r={sender:"postmsg-rpc/server",id:n.id},i=function(e){r.res=e,o(r,s)},a=function(e){r.err=Object.assign({message:e.message},e.output&&e.output.payload),o(r,s)};if(f)t.apply(null,n.args.concat((function(e,t){if(e)return a(e);i(t)})));else{var l=t.apply(null,n.args);Promise.resolve(l).then(i).catch(a)}}};return r("message",a),{close:function(){return i("message",a)}}}},function(e,t){e.exports=require("util")},function(e,t,n){"use strict";n.r(t),n.d(t,"BSONError",(function(){return s})),n.d(t,"BSONRegExp",(function(){return se})),n.d(t,"BSONSymbol",(function(){return ue})),n.d(t,"BSONTypeError",(function(){return u})),n.d(t,"BSON_BINARY_SUBTYPE_BYTE_ARRAY",(function(){return Ge})),n.d(t,"BSON_BINARY_SUBTYPE_COLUMN",(function(){return rt})),n.d(t,"BSON_BINARY_SUBTYPE_DEFAULT",(function(){return We})),n.d(t,"BSON_BINARY_SUBTYPE_ENCRYPTED",(function(){return nt})),n.d(t,"BSON_BINARY_SUBTYPE_FUNCTION",(function(){return Xe})),n.d(t,"BSON_BINARY_SUBTYPE_MD5",(function(){return tt})),n.d(t,"BSON_BINARY_SUBTYPE_USER_DEFINED",(function(){return it})),n.d(t,"BSON_BINARY_SUBTYPE_UUID",(function(){return Qe})),n.d(t,"BSON_BINARY_SUBTYPE_UUID_NEW",(function(){return et})),n.d(t,"BSON_DATA_ARRAY",(function(){return Pe})),n.d(t,"BSON_DATA_BINARY",(function(){return Ue})),n.d(t,"BSON_DATA_BOOLEAN",(function(){return Me})),n.d(t,"BSON_DATA_CODE",(function(){return ke})),n.d(t,"BSON_DATA_CODE_W_SCOPE",(function(){return Ye})),n.d(t,"BSON_DATA_DATE",(function(){return De})),n.d(t,"BSON_DATA_DBPOINTER",(function(){return Ce})),n.d(t,"BSON_DATA_DECIMAL128",(function(){return He})),n.d(t,"BSON_DATA_INT",(function(){return Ve})),n.d(t,"BSON_DATA_LONG",(function(){return Fe})),n.d(t,"BSON_DATA_MAX_KEY",(function(){return Ke})),n.d(t,"BSON_DATA_MIN_KEY",(function(){return Ze})),n.d(t,"BSON_DATA_NULL",(function(){return $e})),n.d(t,"BSON_DATA_NUMBER",(function(){return Ie})),n.d(t,"BSON_DATA_OBJECT",(function(){return Le})),n.d(t,"BSON_DATA_OID",(function(){return Te})),n.d(t,"BSON_DATA_REGEXP",(function(){return ze})),n.d(t,"BSON_DATA_STRING",(function(){return Ae})),n.d(t,"BSON_DATA_SYMBOL",(function(){return Je})),n.d(t,"BSON_DATA_TIMESTAMP",(function(){return qe})),n.d(t,"BSON_DATA_UNDEFINED",(function(){return Re})),n.d(t,"BSON_INT32_MAX",(function(){return Oe})),n.d(t,"BSON_INT32_MIN",(function(){return xe})),n.d(t,"BSON_INT64_MAX",(function(){return Be})),n.d(t,"BSON_INT64_MIN",(function(){return Ne})),n.d(t,"Binary",(function(){return j})),n.d(t,"Code",(function(){return I})),n.d(t,"DBRef",(function(){return L})),n.d(t,"Decimal128",(function(){return X})),n.d(t,"Double",(function(){return G})),n.d(t,"EJSON",(function(){return ve})),n.d(t,"Int32",(function(){return Q})),n.d(t,"Long",(function(){return $})),n.d(t,"LongWithoutOverridesClass",(function(){return fe})),n.d(t,"Map",(function(){return we})),n.d(t,"MaxKey",(function(){return ee})),n.d(t,"MinKey",(function(){return te})),n.d(t,"ObjectID",(function(){return oe})),n.d(t,"ObjectId",(function(){return oe})),n.d(t,"Timestamp",(function(){return ae})),n.d(t,"UUID",(function(){return E})),n.d(t,"calculateObjectSize",(function(){return Ft})),n.d(t,"deserialize",(function(){return qt})),n.d(t,"deserializeStream",(function(){return Ht})),n.d(t,"serialize",(function(){return Yt})),n.d(t,"serializeWithBufferAndIndex",(function(){return Vt})),n.d(t,"setInternalBufferSize",(function(){return Jt}));var r=n(0),i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)};function o(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"BSONError"},enumerable:!1,configurable:!0}),t}(Error),u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"BSONTypeError"},enumerable:!1,configurable:!0}),t}(TypeError);function f(e){return e&&e.Math==Math&&e}function a(){return f("object"==typeof globalThis&&globalThis)||f("object"==typeof window&&window)||f("object"==typeof self&&self)||f("object"==typeof global&&global)||Function("return this")()}function l(e){return e.toString().replace("function(","function (")}var c=function(e){var t,n="object"==typeof(t=a()).navigator&&"ReactNative"===t.navigator.product?"BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.":"BSON: No cryptographic implementation for random bytes present, falling back to a less secure implementation.";console.warn(n);for(var i=r.Buffer.alloc(e),o=0;o<e;++o)i[o]=Math.floor(256*Math.random());return i},h=function(){if("undefined"!=typeof window){var e=window.crypto||window.msCrypto;if(e&&e.getRandomValues)return function(t){return e.getRandomValues(r.Buffer.alloc(t))}}if("undefined"!=typeof global&&global.crypto&&global.crypto.getRandomValues)return function(e){return global.crypto.getRandomValues(r.Buffer.alloc(e))};var t;try{t=n(5).randomBytes}catch(e){}return t||c}();function p(e){return["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(e))}function d(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)}function g(e){return"[object BigInt64Array]"===Object.prototype.toString.call(e)}function y(e){return"[object BigUint64Array]"===Object.prototype.toString.call(e)}function b(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function m(e){return v(e)&&"[object Date]"===Object.prototype.toString.call(e)}function v(e){return"object"==typeof e&&null!==e}function w(e,t){var n=!1;return function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return n||(console.warn(t),n=!0),e.apply(this,r)}}function _(e){if(ArrayBuffer.isView(e))return r.Buffer.from(e.buffer,e.byteOffset,e.byteLength);if(p(e))return r.Buffer.from(e);throw new u("Must use either Buffer or TypedArray")}var S=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15})$/i,O=function(e){return"string"==typeof e&&S.test(e)},x=function(e){if(!O(e))throw new u('UUID string representations must be a 32 or 36 character hex string (dashes excluded/included). Format: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" or "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".');var t=e.replace(/-/g,"");return r.Buffer.from(t,"hex")},B=function(e,t){return void 0===t&&(t=!0),t?e.toString("hex",0,4)+"-"+e.toString("hex",4,6)+"-"+e.toString("hex",6,8)+"-"+e.toString("hex",8,10)+"-"+e.toString("hex",10,16):e.toString("hex")},N=Symbol("id"),E=function(){function e(t){if(void 0===t)this.id=e.generate();else if(t instanceof e)this[N]=r.Buffer.from(t.id),this.__id=t.__id;else if(ArrayBuffer.isView(t)&&16===t.byteLength)this.id=_(t);else{if("string"!=typeof t)throw new u("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).");this.id=x(t)}}return Object.defineProperty(e.prototype,"id",{get:function(){return this[N]},set:function(t){this[N]=t,e.cacheHexString&&(this.__id=B(t))},enumerable:!1,configurable:!0}),e.prototype.toHexString=function(t){if(void 0===t&&(t=!0),e.cacheHexString&&this.__id)return this.__id;var n=B(this.id,t);return e.cacheHexString&&(this.__id=n),n},e.prototype.toString=function(e){return e?this.id.toString(e):this.toHexString()},e.prototype.toJSON=function(){return this.toHexString()},e.prototype.equals=function(t){if(!t)return!1;if(t instanceof e)return t.id.equals(this.id);try{return new e(t).id.equals(this.id)}catch(e){return!1}},e.prototype.toBinary=function(){return new j(this.id,j.SUBTYPE_UUID)},e.generate=function(){var e=h(16);return e[6]=15&e[6]|64,e[8]=63&e[8]|128,r.Buffer.from(e)},e.isValid=function(t){if(!t)return!1;if(t instanceof e)return!0;if("string"==typeof t)return O(t);if(d(t)){if(16!==t.length)return!1;try{return parseInt(t[6].toString(16)[0],10)===j.SUBTYPE_UUID}catch(e){return!1}}return!1},e.createFromHexString=function(t){return new e(x(t))},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new UUID("'+this.toHexString()+'")'},e}();Object.defineProperty(E.prototype,"_bsontype",{value:"UUID"});var j=function(){function e(t,n){if(!(this instanceof e))return new e(t,n);if(!(null==t||"string"==typeof t||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||Array.isArray(t)))throw new u("Binary can only be constructed from string, Buffer, TypedArray, or Array<number>");this.sub_type=null!=n?n:e.BSON_BINARY_SUBTYPE_DEFAULT,null==t?(this.buffer=r.Buffer.alloc(e.BUFFER_SIZE),this.position=0):("string"==typeof t?this.buffer=r.Buffer.from(t,"binary"):Array.isArray(t)?this.buffer=r.Buffer.from(t):this.buffer=_(t),this.position=this.buffer.byteLength)}return e.prototype.put=function(t){if("string"==typeof t&&1!==t.length)throw new u("only accepts single character String");if("number"!=typeof t&&1!==t.length)throw new u("only accepts single character Uint8Array or Array");var n;if((n="string"==typeof t?t.charCodeAt(0):"number"==typeof t?t:t[0])<0||n>255)throw new u("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.length>this.position)this.buffer[this.position++]=n;else{var i=r.Buffer.alloc(e.BUFFER_SIZE+this.buffer.length);this.buffer.copy(i,0,0,this.buffer.length),this.buffer=i,this.buffer[this.position++]=n}},e.prototype.write=function(e,t){if(t="number"==typeof t?t:this.position,this.buffer.length<t+e.length){var n=r.Buffer.alloc(this.buffer.length+e.length);this.buffer.copy(n,0,0,this.buffer.length),this.buffer=n}ArrayBuffer.isView(e)?(this.buffer.set(_(e),t),this.position=t+e.byteLength>this.position?t+e.length:this.position):"string"==typeof e&&(this.buffer.write(e,t,e.length,"binary"),this.position=t+e.length>this.position?t+e.length:this.position)},e.prototype.read=function(e,t){return t=t&&t>0?t:this.position,this.buffer.slice(e,e+t)},e.prototype.value=function(e){return(e=!!e)&&this.buffer.length===this.position?this.buffer:e?this.buffer.slice(0,this.position):this.buffer.toString("binary",0,this.position)},e.prototype.length=function(){return this.position},e.prototype.toJSON=function(){return this.buffer.toString("base64")},e.prototype.toString=function(e){return this.buffer.toString(e)},e.prototype.toExtendedJSON=function(e){e=e||{};var t=this.buffer.toString("base64"),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}}},e.prototype.toUUID=function(){if(this.sub_type===e.SUBTYPE_UUID)return new E(this.buffer.slice(0,this.position));throw new s('Binary sub_type "'+this.sub_type+'" is not supported for converting to UUID. Only "'+e.SUBTYPE_UUID+'" is currently supported.')},e.fromExtendedJSON=function(t,n){var i,o;if(n=n||{},"$binary"in t?n.legacy&&"string"==typeof t.$binary&&"$type"in t?(o=t.$type?parseInt(t.$type,16):0,i=r.Buffer.from(t.$binary,"base64")):"string"!=typeof t.$binary&&(o=t.$binary.subType?parseInt(t.$binary.subType,16):0,i=r.Buffer.from(t.$binary.base64,"base64")):"$uuid"in t&&(o=4,i=x(t.$uuid)),!i)throw new u("Unexpected Binary Extended JSON format "+JSON.stringify(t));return new e(i,o)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new Binary(Buffer.from("'+this.value(!0).toString("hex")+'", "hex"), '+this.sub_type+")"},e.BSON_BINARY_SUBTYPE_DEFAULT=0,e.BUFFER_SIZE=256,e.SUBTYPE_DEFAULT=0,e.SUBTYPE_FUNCTION=1,e.SUBTYPE_BYTE_ARRAY=2,e.SUBTYPE_UUID_OLD=3,e.SUBTYPE_UUID=4,e.SUBTYPE_MD5=5,e.SUBTYPE_ENCRYPTED=6,e.SUBTYPE_COLUMN=7,e.SUBTYPE_USER_DEFINED=128,e}();Object.defineProperty(j.prototype,"_bsontype",{value:"Binary"});var I=function(){function e(t,n){if(!(this instanceof e))return new e(t,n);this.code=t,this.scope=n}return e.prototype.toJSON=function(){return{code:this.code,scope:this.scope}},e.prototype.toExtendedJSON=function(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}},e.fromExtendedJSON=function(t){return new e(t.$code,t.$scope)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){var e=this.toJSON();return'new Code("'+e.code+'"'+(e.scope?", "+JSON.stringify(e.scope):"")+")"},e}();function A(e){return v(e)&&null!=e.$id&&"string"==typeof e.$ref&&(null==e.$db||"string"==typeof e.$db)}Object.defineProperty(I.prototype,"_bsontype",{value:"Code"});var L=function(){function e(t,n,r,i){if(!(this instanceof e))return new e(t,n,r,i);var o=t.split(".");2===o.length&&(r=o.shift(),t=o.shift()),this.collection=t,this.oid=n,this.db=r,this.fields=i||{}}return Object.defineProperty(e.prototype,"namespace",{get:function(){return this.collection},set:function(e){this.collection=e},enumerable:!1,configurable:!0}),e.prototype.toJSON=function(){var e=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(e.$db=this.db),e},e.prototype.toExtendedJSON=function(e){e=e||{};var t={$ref:this.collection,$id:this.oid};return e.legacy?t:(this.db&&(t.$db=this.db),t=Object.assign(t,this.fields))},e.fromExtendedJSON=function(t){var n=Object.assign({},t);return delete n.$ref,delete n.$id,delete n.$db,new e(t.$ref,t.$id,t.$db,n)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){var e=void 0===this.oid||void 0===this.oid.toString?this.oid:this.oid.toString();return'new DBRef("'+this.namespace+'", new ObjectId("'+e+'")'+(this.db?', "'+this.db+'"':"")+")"},e}();Object.defineProperty(L.prototype,"_bsontype",{value:"DBRef"});var P=void 0;try{P=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(e){}var U=4294967296,R=0x10000000000000000,T=R/2,M={},D={},$=function(){function e(t,n,r){if(void 0===t&&(t=0),!(this instanceof e))return new e(t,n,r);"bigint"==typeof t?Object.assign(this,e.fromBigInt(t,!!n)):"string"==typeof t?Object.assign(this,e.fromString(t,!!n)):(this.low=0|t,this.high=0|n,this.unsigned=!!r),Object.defineProperty(this,"__isLong__",{value:!0,configurable:!1,writable:!1,enumerable:!1})}return e.fromBits=function(t,n,r){return new e(t,n,r)},e.fromInt=function(t,n){var r,i,o;return n?(o=0<=(t>>>=0)&&t<256)&&(i=D[t])?i:(r=e.fromBits(t,(0|t)<0?-1:0,!0),o&&(D[t]=r),r):(o=-128<=(t|=0)&&t<128)&&(i=M[t])?i:(r=e.fromBits(t,t<0?-1:0,!1),o&&(M[t]=r),r)},e.fromNumber=function(t,n){if(isNaN(t))return n?e.UZERO:e.ZERO;if(n){if(t<0)return e.UZERO;if(t>=R)return e.MAX_UNSIGNED_VALUE}else{if(t<=-T)return e.MIN_VALUE;if(t+1>=T)return e.MAX_VALUE}return t<0?e.fromNumber(-t,n).neg():e.fromBits(t%U|0,t/U|0,n)},e.fromBigInt=function(t,n){return e.fromString(t.toString(),n)},e.fromString=function(t,n,r){if(0===t.length)throw Error("empty string");if("NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return e.ZERO;if("number"==typeof n?(r=n,n=!1):n=!!n,(r=r||10)<2||36<r)throw RangeError("radix");var i;if((i=t.indexOf("-"))>0)throw Error("interior hyphen");if(0===i)return e.fromString(t.substring(1),n,r).neg();for(var o=e.fromNumber(Math.pow(r,8)),s=e.ZERO,u=0;u<t.length;u+=8){var f=Math.min(8,t.length-u),a=parseInt(t.substring(u,u+f),r);if(f<8){var l=e.fromNumber(Math.pow(r,f));s=s.mul(l).add(e.fromNumber(a))}else s=(s=s.mul(o)).add(e.fromNumber(a))}return s.unsigned=n,s},e.fromBytes=function(t,n,r){return r?e.fromBytesLE(t,n):e.fromBytesBE(t,n)},e.fromBytesLE=function(t,n){return new e(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,n)},e.fromBytesBE=function(t,n){return new e(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],n)},e.isLong=function(e){return v(e)&&!0===e.__isLong__},e.fromValue=function(t,n){return"number"==typeof t?e.fromNumber(t,n):"string"==typeof t?e.fromString(t,n):e.fromBits(t.low,t.high,"boolean"==typeof n?n:t.unsigned)},e.prototype.add=function(t){e.isLong(t)||(t=e.fromValue(t));var n=this.high>>>16,r=65535&this.high,i=this.low>>>16,o=65535&this.low,s=t.high>>>16,u=65535&t.high,f=t.low>>>16,a=0,l=0,c=0,h=0;return c+=(h+=o+(65535&t.low))>>>16,h&=65535,l+=(c+=i+f)>>>16,c&=65535,a+=(l+=r+u)>>>16,l&=65535,a+=n+s,a&=65535,e.fromBits(c<<16|h,a<<16|l,this.unsigned)},e.prototype.and=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low&t.low,this.high&t.high,this.unsigned)},e.prototype.compare=function(t){if(e.isLong(t)||(t=e.fromValue(t)),this.eq(t))return 0;var n=this.isNegative(),r=t.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},e.prototype.comp=function(e){return this.compare(e)},e.prototype.divide=function(t){if(e.isLong(t)||(t=e.fromValue(t)),t.isZero())throw Error("division by zero");if(P){if(!this.unsigned&&-2147483648===this.high&&-1===t.low&&-1===t.high)return this;var n=(this.unsigned?P.div_u:P.div_s)(this.low,this.high,t.low,t.high);return e.fromBits(n,P.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?e.UZERO:e.ZERO;var r,i,o;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return e.UZERO;if(t.gt(this.shru(1)))return e.UONE;o=e.UZERO}else{if(this.eq(e.MIN_VALUE))return t.eq(e.ONE)||t.eq(e.NEG_ONE)?e.MIN_VALUE:t.eq(e.MIN_VALUE)?e.ONE:(r=this.shr(1).div(t).shl(1)).eq(e.ZERO)?t.isNegative()?e.ONE:e.NEG_ONE:(i=this.sub(t.mul(r)),o=r.add(i.div(t)));if(t.eq(e.MIN_VALUE))return this.unsigned?e.UZERO:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();o=e.ZERO}for(i=this;i.gte(t);){r=Math.max(1,Math.floor(i.toNumber()/t.toNumber()));for(var s=Math.ceil(Math.log(r)/Math.LN2),u=s<=48?1:Math.pow(2,s-48),f=e.fromNumber(r),a=f.mul(t);a.isNegative()||a.gt(i);)r-=u,a=(f=e.fromNumber(r,this.unsigned)).mul(t);f.isZero()&&(f=e.ONE),o=o.add(f),i=i.sub(a)}return o},e.prototype.div=function(e){return this.divide(e)},e.prototype.equals=function(t){return e.isLong(t)||(t=e.fromValue(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&(this.high===t.high&&this.low===t.low)},e.prototype.eq=function(e){return this.equals(e)},e.prototype.getHighBits=function(){return this.high},e.prototype.getHighBitsUnsigned=function(){return this.high>>>0},e.prototype.getLowBits=function(){return this.low},e.prototype.getLowBitsUnsigned=function(){return this.low>>>0},e.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.eq(e.MIN_VALUE)?64:this.neg().getNumBitsAbs();var t,n=0!==this.high?this.high:this.low;for(t=31;t>0&&0==(n&1<<t);t--);return 0!==this.high?t+33:t+1},e.prototype.greaterThan=function(e){return this.comp(e)>0},e.prototype.gt=function(e){return this.greaterThan(e)},e.prototype.greaterThanOrEqual=function(e){return this.comp(e)>=0},e.prototype.gte=function(e){return this.greaterThanOrEqual(e)},e.prototype.ge=function(e){return this.greaterThanOrEqual(e)},e.prototype.isEven=function(){return 0==(1&this.low)},e.prototype.isNegative=function(){return!this.unsigned&&this.high<0},e.prototype.isOdd=function(){return 1==(1&this.low)},e.prototype.isPositive=function(){return this.unsigned||this.high>=0},e.prototype.isZero=function(){return 0===this.high&&0===this.low},e.prototype.lessThan=function(e){return this.comp(e)<0},e.prototype.lt=function(e){return this.lessThan(e)},e.prototype.lessThanOrEqual=function(e){return this.comp(e)<=0},e.prototype.lte=function(e){return this.lessThanOrEqual(e)},e.prototype.modulo=function(t){if(e.isLong(t)||(t=e.fromValue(t)),P){var n=(this.unsigned?P.rem_u:P.rem_s)(this.low,this.high,t.low,t.high);return e.fromBits(n,P.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))},e.prototype.mod=function(e){return this.modulo(e)},e.prototype.rem=function(e){return this.modulo(e)},e.prototype.multiply=function(t){if(this.isZero())return e.ZERO;if(e.isLong(t)||(t=e.fromValue(t)),P){var n=P.mul(this.low,this.high,t.low,t.high);return e.fromBits(n,P.get_high(),this.unsigned)}if(t.isZero())return e.ZERO;if(this.eq(e.MIN_VALUE))return t.isOdd()?e.MIN_VALUE:e.ZERO;if(t.eq(e.MIN_VALUE))return this.isOdd()?e.MIN_VALUE:e.ZERO;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(e.TWO_PWR_24)&&t.lt(e.TWO_PWR_24))return e.fromNumber(this.toNumber()*t.toNumber(),this.unsigned);var r=this.high>>>16,i=65535&this.high,o=this.low>>>16,s=65535&this.low,u=t.high>>>16,f=65535&t.high,a=t.low>>>16,l=65535&t.low,c=0,h=0,p=0,d=0;return p+=(d+=s*l)>>>16,d&=65535,h+=(p+=o*l)>>>16,p&=65535,h+=(p+=s*a)>>>16,p&=65535,c+=(h+=i*l)>>>16,h&=65535,c+=(h+=o*a)>>>16,h&=65535,c+=(h+=s*f)>>>16,h&=65535,c+=r*l+i*a+o*f+s*u,c&=65535,e.fromBits(p<<16|d,c<<16|h,this.unsigned)},e.prototype.mul=function(e){return this.multiply(e)},e.prototype.negate=function(){return!this.unsigned&&this.eq(e.MIN_VALUE)?e.MIN_VALUE:this.not().add(e.ONE)},e.prototype.neg=function(){return this.negate()},e.prototype.not=function(){return e.fromBits(~this.low,~this.high,this.unsigned)},e.prototype.notEquals=function(e){return!this.equals(e)},e.prototype.neq=function(e){return this.notEquals(e)},e.prototype.ne=function(e){return this.notEquals(e)},e.prototype.or=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low|t.low,this.high|t.high,this.unsigned)},e.prototype.shiftLeft=function(t){return e.isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?e.fromBits(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):e.fromBits(0,this.low<<t-32,this.unsigned)},e.prototype.shl=function(e){return this.shiftLeft(e)},e.prototype.shiftRight=function(t){return e.isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?e.fromBits(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):e.fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},e.prototype.shr=function(e){return this.shiftRight(e)},e.prototype.shiftRightUnsigned=function(t){if(e.isLong(t)&&(t=t.toInt()),0===(t&=63))return this;var n=this.high;if(t<32){var r=this.low;return e.fromBits(r>>>t|n<<32-t,n>>>t,this.unsigned)}return 32===t?e.fromBits(n,0,this.unsigned):e.fromBits(n>>>t-32,0,this.unsigned)},e.prototype.shr_u=function(e){return this.shiftRightUnsigned(e)},e.prototype.shru=function(e){return this.shiftRightUnsigned(e)},e.prototype.subtract=function(t){return e.isLong(t)||(t=e.fromValue(t)),this.add(t.neg())},e.prototype.sub=function(e){return this.subtract(e)},e.prototype.toInt=function(){return this.unsigned?this.low>>>0:this.low},e.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*U+(this.low>>>0):this.high*U+(this.low>>>0)},e.prototype.toBigInt=function(){return BigInt(this.toString())},e.prototype.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},e.prototype.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},e.prototype.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},e.prototype.toSigned=function(){return this.unsigned?e.fromBits(this.low,this.high,!1):this},e.prototype.toString=function(t){if((t=t||10)<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(e.MIN_VALUE)){var n=e.fromNumber(t),r=this.div(n),i=r.mul(n).sub(this);return r.toString(t)+i.toInt().toString(t)}return"-"+this.neg().toString(t)}for(var o=e.fromNumber(Math.pow(t,6),this.unsigned),s=this,u="";;){var f=s.div(o),a=(s.sub(f.mul(o)).toInt()>>>0).toString(t);if((s=f).isZero())return a+u;for(;a.length<6;)a="0"+a;u=""+a+u}},e.prototype.toUnsigned=function(){return this.unsigned?this:e.fromBits(this.low,this.high,!0)},e.prototype.xor=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low^t.low,this.high^t.high,this.unsigned)},e.prototype.eqz=function(){return this.isZero()},e.prototype.le=function(e){return this.lessThanOrEqual(e)},e.prototype.toExtendedJSON=function(e){return e&&e.relaxed?this.toNumber():{$numberLong:this.toString()}},e.fromExtendedJSON=function(t,n){var r=e.fromString(t.$numberLong);return n&&n.relaxed?r.toNumber():r},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new Long("'+this.toString()+'"'+(this.unsigned?", true":"")+")"},e.TWO_PWR_24=e.fromInt(16777216),e.MAX_UNSIGNED_VALUE=e.fromBits(-1,-1,!0),e.ZERO=e.fromInt(0),e.UZERO=e.fromInt(0,!0),e.ONE=e.fromInt(1),e.UONE=e.fromInt(1,!0),e.NEG_ONE=e.fromInt(-1),e.MAX_VALUE=e.fromBits(-1,2147483647,!1),e.MIN_VALUE=e.fromBits(0,-2147483648,!1),e}();Object.defineProperty($.prototype,"__isLong__",{value:!0}),Object.defineProperty($.prototype,"_bsontype",{value:"Long"});var z=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,C=/^(\+|-)?(Infinity|inf)$/i,k=/^(\+|-)?NaN$/i,J=6111,Y=-6176,V=[124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),q=[248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),F=[120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse(),H=/^([-+])?(\d+)?$/;function Z(e){return!isNaN(parseInt(e,10))}function K(e){var t=$.fromNumber(1e9),n=$.fromNumber(0);if(!(e.parts[0]||e.parts[1]||e.parts[2]||e.parts[3]))return{quotient:e,rem:n};for(var r=0;r<=3;r++)n=(n=n.shiftLeft(32)).add(new $(e.parts[r],0)),e.parts[r]=n.div(t).low,n=n.modulo(t);return{quotient:e,rem:n}}function W(e,t){throw new u('"'+e+'" is not a valid Decimal128 string - '+t)}var X=function(){function e(t){if(!(this instanceof e))return new e(t);this.bytes="string"==typeof t?e.fromString(t).bytes:t}return e.fromString=function(t){var n,i=!1,o=!1,s=!1,f=0,a=0,l=0,c=0,h=0,p=[0],d=0,g=0,y=0,b=0,m=0,v=0,w=new $(0,0),_=new $(0,0),S=0;if(t.length>=7e3)throw new u(t+" not a valid Decimal128 string");var O=t.match(z),x=t.match(C),B=t.match(k);if(!O&&!x&&!B||0===t.length)throw new u(t+" not a valid Decimal128 string");if(O){var N=O[2],E=O[4],j=O[5],I=O[6];E&&void 0===I&&W(t,"missing exponent power"),E&&void 0===N&&W(t,"missing exponent base"),void 0===E&&(j||I)&&W(t,"missing e before exponent")}if("+"!==t[S]&&"-"!==t[S]||(i="-"===t[S++]),!Z(t[S])&&"."!==t[S]){if("i"===t[S]||"I"===t[S])return new e(r.Buffer.from(i?q:F));if("N"===t[S])return new e(r.Buffer.from(V))}for(;Z(t[S])||"."===t[S];)"."!==t[S]?(d<34&&("0"!==t[S]||s)&&(s||(h=a),s=!0,p[g++]=parseInt(t[S],10),d+=1),s&&(l+=1),o&&(c+=1),a+=1,S+=1):(o&&W(t,"contains multiple periods"),o=!0,S+=1);if(o&&!a)throw new u(t+" not a valid Decimal128 string");if("e"===t[S]||"E"===t[S]){var A=t.substr(++S).match(H);if(!A||!A[2])return new e(r.Buffer.from(V));m=parseInt(A[0],10),S+=A[0].length}if(t[S])return new e(r.Buffer.from(V));if(y=0,d){if(b=d-1,1!==(f=l))for(;0===p[h+f-1];)f-=1}else y=0,b=0,p[0]=0,l=1,d=1,f=0;for(m<=c&&c-m>16384?m=Y:m-=c;m>J;){if((b+=1)-y>34){if(p.join("").match(/^0+$/)){m=J;break}W(t,"overflow")}m-=1}for(;m<Y||d<l;){if(0===b&&f<d){m=Y,f=0;break}if(d<l?l-=1:b-=1,m<J)m+=1;else{if(p.join("").match(/^0+$/)){m=J;break}W(t,"overflow")}}if(b-y+1<f){var L=a;o&&(h+=1,L+=1),i&&(h+=1,L+=1);var P=parseInt(t[h+b+1],10),U=0;if(P>=5&&(U=1,5===P))for(U=p[b]%2==1?1:0,v=h+b+2;v<L;v++)if(parseInt(t[v],10)){U=1;break}if(U)for(var R=b;R>=0;R--)if(++p[R]>9&&(p[R]=0,0===R)){if(!(m<J))return new e(r.Buffer.from(i?q:F));m+=1,p[R]=1}}if(w=$.fromNumber(0),_=$.fromNumber(0),0===f)w=$.fromNumber(0),_=$.fromNumber(0);else if(b-y<17){R=y;for(_=$.fromNumber(p[R++]),w=new $(0,0);R<=b;R++)_=(_=_.multiply($.fromNumber(10))).add($.fromNumber(p[R]))}else{R=y;for(w=$.fromNumber(p[R++]);R<=b-17;R++)w=(w=w.multiply($.fromNumber(10))).add($.fromNumber(p[R]));for(_=$.fromNumber(p[R++]);R<=b;R++)_=(_=_.multiply($.fromNumber(10))).add($.fromNumber(p[R]))}var T,M,D,K,X=function(e,t){if(!e&&!t)return{high:$.fromNumber(0),low:$.fromNumber(0)};var n=e.shiftRightUnsigned(32),r=new $(e.getLowBits(),0),i=t.shiftRightUnsigned(32),o=new $(t.getLowBits(),0),s=n.multiply(i),u=n.multiply(o),f=r.multiply(i),a=r.multiply(o);return s=s.add(u.shiftRightUnsigned(32)),u=new $(u.getLowBits(),0).add(f).add(a.shiftRightUnsigned(32)),{high:s=s.add(u.shiftRightUnsigned(32)),low:a=u.shiftLeft(32).add(new $(a.getLowBits(),0))}}(w,$.fromString("100000000000000000"));X.low=X.low.add(_),T=X.low,M=_,D=T.high>>>0,K=M.high>>>0,(D<K||D===K&&T.low>>>0<M.low>>>0)&&(X.high=X.high.add($.fromNumber(1))),n=m+6176;var G={low:$.fromNumber(0),high:$.fromNumber(0)};X.high.shiftRightUnsigned(49).and($.fromNumber(1)).equals($.fromNumber(1))?(G.high=G.high.or($.fromNumber(3).shiftLeft(61)),G.high=G.high.or($.fromNumber(n).and($.fromNumber(16383).shiftLeft(47))),G.high=G.high.or(X.high.and($.fromNumber(0x7fffffffffff)))):(G.high=G.high.or($.fromNumber(16383&n).shiftLeft(49)),G.high=G.high.or(X.high.and($.fromNumber(562949953421311)))),G.low=X.low,i&&(G.high=G.high.or($.fromString("9223372036854775808")));var Q=r.Buffer.alloc(16);return S=0,Q[S++]=255&G.low.low,Q[S++]=G.low.low>>8&255,Q[S++]=G.low.low>>16&255,Q[S++]=G.low.low>>24&255,Q[S++]=255&G.low.high,Q[S++]=G.low.high>>8&255,Q[S++]=G.low.high>>16&255,Q[S++]=G.low.high>>24&255,Q[S++]=255&G.high.low,Q[S++]=G.high.low>>8&255,Q[S++]=G.high.low>>16&255,Q[S++]=G.high.low>>24&255,Q[S++]=255&G.high.high,Q[S++]=G.high.high>>8&255,Q[S++]=G.high.high>>16&255,Q[S++]=G.high.high>>24&255,new e(Q)},e.prototype.toString=function(){for(var e,t=0,n=new Array(36),r=0;r<n.length;r++)n[r]=0;var i,o,s,u=0,f=!1,a={parts:[0,0,0,0]},l=[];u=0;var c=this.bytes,h=c[u++]|c[u++]<<8|c[u++]<<16|c[u++]<<24,p=c[u++]|c[u++]<<8|c[u++]<<16|c[u++]<<24,d=c[u++]|c[u++]<<8|c[u++]<<16|c[u++]<<24,g=c[u++]|c[u++]<<8|c[u++]<<16|c[u++]<<24;u=0,{low:new $(h,p),high:new $(d,g)}.high.lessThan($.ZERO)&&l.push("-");var y=g>>26&31;if(y>>3==3){if(30===y)return l.join("")+"Infinity";if(31===y)return"NaN";e=g>>15&16383,i=8+(g>>14&1)}else i=g>>14&7,e=g>>17&16383;var b=e-6176;if(a.parts[0]=(16383&g)+((15&i)<<14),a.parts[1]=d,a.parts[2]=p,a.parts[3]=h,0===a.parts[0]&&0===a.parts[1]&&0===a.parts[2]&&0===a.parts[3])f=!0;else for(s=3;s>=0;s--){var m=0,v=K(a);if(a=v.quotient,m=v.rem.low)for(o=8;o>=0;o--)n[9*s+o]=m%10,m=Math.floor(m/10)}if(f)t=1,n[u]=0;else for(t=36;!n[u];)t-=1,u+=1;var w=t-1+b;if(w>=34||w<=-7||b>0){if(t>34)return l.push("0"),b>0?l.push("E+"+b):b<0&&l.push("E"+b),l.join("");l.push(""+n[u++]),(t-=1)&&l.push(".");for(r=0;r<t;r++)l.push(""+n[u++]);l.push("E"),w>0?l.push("+"+w):l.push(""+w)}else if(b>=0)for(r=0;r<t;r++)l.push(""+n[u++]);else{var _=t+b;if(_>0)for(r=0;r<_;r++)l.push(""+n[u++]);else l.push("0");for(l.push(".");_++<0;)l.push("0");for(r=0;r<t-Math.max(_-1,0);r++)l.push(""+n[u++])}return l.join("")},e.prototype.toJSON=function(){return{$numberDecimal:this.toString()}},e.prototype.toExtendedJSON=function(){return{$numberDecimal:this.toString()}},e.fromExtendedJSON=function(t){return e.fromString(t.$numberDecimal)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new Decimal128("'+this.toString()+'")'},e}();Object.defineProperty(X.prototype,"_bsontype",{value:"Decimal128"});var G=function(){function e(t){if(!(this instanceof e))return new e(t);t instanceof Number&&(t=t.valueOf()),this.value=+t}return e.prototype.valueOf=function(){return this.value},e.prototype.toJSON=function(){return this.value},e.prototype.toString=function(e){return this.value.toString(e)},e.prototype.toExtendedJSON=function(e){return e&&(e.legacy||e.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-"+this.value.toFixed(1)}:(Number.isInteger(this.value)?(t=this.value.toFixed(1)).length>=13&&(t=this.value.toExponential(13).toUpperCase()):t=this.value.toString(),{$numberDouble:t});var t},e.fromExtendedJSON=function(t,n){var r=parseFloat(t.$numberDouble);return n&&n.relaxed?r:new e(r)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new Double("+this.toExtendedJSON().$numberDouble+")"},e}();Object.defineProperty(G.prototype,"_bsontype",{value:"Double"});var Q=function(){function e(t){if(!(this instanceof e))return new e(t);t instanceof Number&&(t=t.valueOf()),this.value=0|+t}return e.prototype.valueOf=function(){return this.value},e.prototype.toString=function(e){return this.value.toString(e)},e.prototype.toJSON=function(){return this.value},e.prototype.toExtendedJSON=function(e){return e&&(e.relaxed||e.legacy)?this.value:{$numberInt:this.value.toString()}},e.fromExtendedJSON=function(t,n){return n&&n.relaxed?parseInt(t.$numberInt,10):new e(t.$numberInt)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new Int32("+this.valueOf()+")"},e}();Object.defineProperty(Q.prototype,"_bsontype",{value:"Int32"});var ee=function(){function e(){if(!(this instanceof e))return new e}return e.prototype.toExtendedJSON=function(){return{$maxKey:1}},e.fromExtendedJSON=function(){return new e},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new MaxKey()"},e}();Object.defineProperty(ee.prototype,"_bsontype",{value:"MaxKey"});var te=function(){function e(){if(!(this instanceof e))return new e}return e.prototype.toExtendedJSON=function(){return{$minKey:1}},e.fromExtendedJSON=function(){return new e},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return"new MinKey()"},e}();Object.defineProperty(te.prototype,"_bsontype",{value:"MinKey"});var ne=new RegExp("^[0-9a-fA-F]{24}$"),re=null,ie=Symbol("id"),oe=function(){function e(t){if(!(this instanceof e))return new e(t);var n;if("object"==typeof t&&t&&"id"in t){if("string"!=typeof t.id&&!ArrayBuffer.isView(t.id))throw new u("Argument passed in must have an id that is of type string or Buffer");n="toHexString"in t&&"function"==typeof t.toHexString?r.Buffer.from(t.toHexString(),"hex"):t.id}else n=t;if(null==n||"number"==typeof n)this[ie]=e.generate("number"==typeof n?n:void 0);else if(ArrayBuffer.isView(n)&&12===n.byteLength)this[ie]=_(n);else{if("string"!=typeof n)throw new u("Argument passed in does not match the accepted types");if(12===n.length){var i=r.Buffer.from(n);if(12!==i.byteLength)throw new u("Argument passed in must be a string of 12 bytes");this[ie]=i}else{if(24!==n.length||!ne.test(n))throw new u("Argument passed in must be a string of 12 bytes or a string of 24 hex characters");this[ie]=r.Buffer.from(n,"hex")}}e.cacheHexString&&(this.__id=this.id.toString("hex"))}return Object.defineProperty(e.prototype,"id",{get:function(){return this[ie]},set:function(t){this[ie]=t,e.cacheHexString&&(this.__id=t.toString("hex"))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"generationTime",{get:function(){return this.id.readInt32BE(0)},set:function(e){this.id.writeUInt32BE(e,0)},enumerable:!1,configurable:!0}),e.prototype.toHexString=function(){if(e.cacheHexString&&this.__id)return this.__id;var t=this.id.toString("hex");return e.cacheHexString&&!this.__id&&(this.__id=t),t},e.getInc=function(){return e.index=(e.index+1)%16777215},e.generate=function(t){"number"!=typeof t&&(t=Math.floor(Date.now()/1e3));var n=e.getInc(),i=r.Buffer.alloc(12);return i.writeUInt32BE(t,0),null===re&&(re=h(5)),i[4]=re[0],i[5]=re[1],i[6]=re[2],i[7]=re[3],i[8]=re[4],i[11]=255&n,i[10]=n>>8&255,i[9]=n>>16&255,i},e.prototype.toString=function(e){return e?this.id.toString(e):this.toHexString()},e.prototype.toJSON=function(){return this.toHexString()},e.prototype.equals=function(t){return null!=t&&(t instanceof e?this.toString()===t.toString():"string"==typeof t&&e.isValid(t)&&12===t.length&&d(this.id)?t===r.Buffer.prototype.toString.call(this.id,"latin1"):"string"==typeof t&&e.isValid(t)&&24===t.length?t.toLowerCase()===this.toHexString():"string"==typeof t&&e.isValid(t)&&12===t.length?r.Buffer.from(t).equals(this.id):"object"==typeof t&&"toHexString"in t&&"function"==typeof t.toHexString&&t.toHexString()===this.toHexString())},e.prototype.getTimestamp=function(){var e=new Date,t=this.id.readUInt32BE(0);return e.setTime(1e3*Math.floor(t)),e},e.createPk=function(){return new e},e.createFromTime=function(t){var n=r.Buffer.from([0,0,0,0,0,0,0,0,0,0,0,0]);return n.writeUInt32BE(t,0),new e(n)},e.createFromHexString=function(t){if(void 0===t||null!=t&&24!==t.length)throw new u("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");return new e(r.Buffer.from(t,"hex"))},e.isValid=function(t){return null!=t&&("number"==typeof t||("string"==typeof t?12===t.length||24===t.length&&ne.test(t):t instanceof e||(!(!d(t)||12!==t.length)||"object"==typeof t&&"toHexString"in t&&"function"==typeof t.toHexString&&("string"==typeof t.id?12===t.id.length:24===t.toHexString().length&&ne.test(t.id.toString("hex"))))))},e.prototype.toExtendedJSON=function(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}},e.fromExtendedJSON=function(t){return new e(t.$oid)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e.prototype.inspect=function(){return'new ObjectId("'+this.toHexString()+'")'},e.index=Math.floor(16777215*Math.random()),e}();Object.defineProperty(oe.prototype,"generate",{value:w((function(e){return oe.generate(e)}),"Please use the static `ObjectId.generate(time)` instead")}),Object.defineProperty(oe.prototype,"getInc",{value:w((function(){return oe.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(oe.prototype,"get_inc",{value:w((function(){return oe.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(oe,"get_inc",{value:w((function(){return oe.getInc()}),"Please use the static `ObjectId.getInc()` instead")}),Object.defineProperty(oe.prototype,"_bsontype",{value:"ObjectID"});var se=function(){function e(t,n){if(!(this instanceof e))return new e(t,n);if(this.pattern=t,this.options=(null!=n?n:"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new s("BSON Regex patterns cannot contain null bytes, found: "+JSON.stringify(this.pattern));if(-1!==this.options.indexOf("\0"))throw new s("BSON Regex options cannot contain null bytes, found: "+JSON.stringify(this.options));for(var r=0;r<this.options.length;r++)if("i"!==this.options[r]&&"m"!==this.options[r]&&"x"!==this.options[r]&&"l"!==this.options[r]&&"s"!==this.options[r]&&"u"!==this.options[r])throw new s("The regular expression option ["+this.options[r]+"] is not supported")}return e.parseOptions=function(e){return e?e.split("").sort().join(""):""},e.prototype.toExtendedJSON=function(e){return(e=e||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}},e.fromExtendedJSON=function(t){if("$regex"in t){if("string"==typeof t.$regex)return new e(t.$regex,e.parseOptions(t.$options));if("BSONRegExp"===t.$regex._bsontype)return t}if("$regularExpression"in t)return new e(t.$regularExpression.pattern,e.parseOptions(t.$regularExpression.options));throw new u("Unexpected BSONRegExp EJSON object form: "+JSON.stringify(t))},e}();Object.defineProperty(se.prototype,"_bsontype",{value:"BSONRegExp"});var ue=function(){function e(t){if(!(this instanceof e))return new e(t);this.value=t}return e.prototype.valueOf=function(){return this.value},e.prototype.toString=function(){return this.value},e.prototype.inspect=function(){return'new BSONSymbol("'+this.value+'")'},e.prototype.toJSON=function(){return this.value},e.prototype.toExtendedJSON=function(){return{$symbol:this.value}},e.fromExtendedJSON=function(t){return new e(t.$symbol)},e.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},e}();Object.defineProperty(ue.prototype,"_bsontype",{value:"Symbol"});var fe=$,ae=function(e){function t(n,r){var i=this;return i instanceof t?(i=$.isLong(n)?e.call(this,n.low,n.high,!0)||this:v(n)&&void 0!==n.t&&void 0!==n.i?e.call(this,n.i,n.t,!0)||this:e.call(this,n,r,!0)||this,Object.defineProperty(i,"_bsontype",{value:"Timestamp",writable:!1,configurable:!1,enumerable:!1}),i):new t(n,r)}return o(t,e),t.prototype.toJSON=function(){return{$timestamp:this.toString()}},t.fromInt=function(e){return new t($.fromInt(e,!0))},t.fromNumber=function(e){return new t($.fromNumber(e,!0))},t.fromBits=function(e,n){return new t(e,n)},t.fromString=function(e,n){return new t($.fromString(e,!0,n))},t.prototype.toExtendedJSON=function(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}},t.fromExtendedJSON=function(e){return new t(e.$timestamp)},t.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return this.inspect()},t.prototype.inspect=function(){return"new Timestamp({ t: "+this.getHighBits()+", i: "+this.getLowBits()+" })"},t.MAX_VALUE=$.MAX_UNSIGNED_VALUE,t}(fe);function le(e){return v(e)&&Reflect.has(e,"_bsontype")&&"string"==typeof e._bsontype}var ce=2147483647,he=-2147483648,pe=0x8000000000000000,de=-0x8000000000000000,ge={$oid:oe,$binary:j,$uuid:j,$symbol:ue,$numberInt:Q,$numberDecimal:X,$numberDouble:G,$numberLong:$,$minKey:te,$maxKey:ee,$regex:se,$regularExpression:se,$timestamp:ae};function ye(e,t){if(void 0===t&&(t={}),"number"==typeof e){if(t.relaxed||t.legacy)return e;if(Math.floor(e)===e){if(e>=he&&e<=ce)return new Q(e);if(e>=de&&e<=pe)return $.fromNumber(e)}return new G(e)}if(null==e||"object"!=typeof e)return e;if(e.$undefined)return null;for(var n=Object.keys(e).filter((function(t){return t.startsWith("$")&&null!=e[t]})),r=0;r<n.length;r++){var i=ge[n[r]];if(i)return i.fromExtendedJSON(e,t)}if(null!=e.$date){var o=e.$date,s=new Date;return t.legacy?"number"==typeof o?s.setTime(o):"string"==typeof o&&s.setTime(Date.parse(o)):"string"==typeof o?s.setTime(Date.parse(o)):$.isLong(o)?s.setTime(o.toNumber()):"number"==typeof o&&t.relaxed&&s.setTime(o),s}if(null!=e.$code){var u=Object.assign({},e);return e.$scope&&(u.$scope=ye(e.$scope)),I.fromExtendedJSON(e)}if(A(e)||e.$dbPointer){var f=e.$ref?e:e.$dbPointer;if(f instanceof L)return f;var a=Object.keys(f).filter((function(e){return e.startsWith("$")})),l=!0;if(a.forEach((function(e){-1===["$ref","$id","$db"].indexOf(e)&&(l=!1)})),l)return L.fromExtendedJSON(f)}return e}function be(e){var t=e.toISOString();return 0!==e.getUTCMilliseconds()?t:t.slice(0,-5)+"Z"}function me(e,t){if(("object"==typeof e||"function"==typeof e)&&null!==e){var n=t.seenObjects.findIndex((function(t){return t.obj===e}));if(-1!==n){var r=t.seenObjects.map((function(e){return e.propertyName})),i=r.slice(0,n).map((function(e){return e+" -> "})).join(""),o=r[n],f=" -> "+r.slice(n+1,r.length-1).map((function(e){return e+" -> "})).join(""),a=r[r.length-1],l=" ".repeat(i.length+o.length/2),c="-".repeat(f.length+(o.length+a.length)/2-1);throw new u("Converting circular structure to EJSON:\n "+i+o+f+a+"\n "+l+"\\"+c+"/")}t.seenObjects[t.seenObjects.length-1].obj=e}if(Array.isArray(e))return function(e,t){return e.map((function(e,n){t.seenObjects.push({propertyName:"index "+n,obj:null});try{return me(e,t)}finally{t.seenObjects.pop()}}))}(e,t);if(void 0===e)return null;if(e instanceof Date||m(e)){var h=e.getTime(),p=h>-1&&h<2534023188e5;return t.legacy?t.relaxed&&p?{$date:e.getTime()}:{$date:be(e)}:t.relaxed&&p?{$date:be(e)}:{$date:{$numberLong:e.getTime().toString()}}}if(!("number"!=typeof e||t.relaxed&&isFinite(e))){if(Math.floor(e)===e){var d=e>=de&&e<=pe;if(e>=he&&e<=ce)return{$numberInt:e.toString()};if(d)return{$numberLong:e.toString()}}return{$numberDouble:e.toString()}}if(e instanceof RegExp||b(e)){var g=e.flags;if(void 0===g){var y=e.toString().match(/[gimuy]*$/);y&&(g=y[0])}return new se(e.source,g).toExtendedJSON(t)}return null!=e&&"object"==typeof e?function(e,t){if(null==e||"object"!=typeof e)throw new s("not an object instance");var n=e._bsontype;if(void 0===n){var r={};for(var i in e){t.seenObjects.push({propertyName:i,obj:null});try{r[i]=me(e[i],t)}finally{t.seenObjects.pop()}}return r}if(le(e)){var o=e;if("function"!=typeof o.toExtendedJSON){var f=_e[e._bsontype];if(!f)throw new u("Unrecognized or invalid _bsontype: "+e._bsontype);o=f(o)}return"Code"===n&&o.scope?o=new I(o.code,me(o.scope,t)):"DBRef"===n&&o.oid&&(o=new L(me(o.collection,t),me(o.oid,t),me(o.db,t),me(o.fields,t))),o.toExtendedJSON(t)}throw new s("_bsontype must be a string, but was: "+typeof n)}(e,t):e}var ve,we,_e={Binary:function(e){return new j(e.value(),e.sub_type)},Code:function(e){return new I(e.code,e.scope)},DBRef:function(e){return new L(e.collection||e.namespace,e.oid,e.db,e.fields)},Decimal128:function(e){return new X(e.bytes)},Double:function(e){return new G(e.value)},Int32:function(e){return new Q(e.value)},Long:function(e){return $.fromBits(null!=e.low?e.low:e.low_,null!=e.low?e.high:e.high_,null!=e.low?e.unsigned:e.unsigned_)},MaxKey:function(){return new ee},MinKey:function(){return new te},ObjectID:function(e){return new oe(e)},ObjectId:function(e){return new oe(e)},BSONRegExp:function(e){return new se(e.pattern,e.options)},Symbol:function(e){return new ue(e.value)},Timestamp:function(e){return ae.fromBits(e.low,e.high)}};!function(e){function t(e,t){var n=Object.assign({},{relaxed:!0,legacy:!1},t);return"boolean"==typeof n.relaxed&&(n.strict=!n.relaxed),"boolean"==typeof n.strict&&(n.relaxed=!n.strict),JSON.parse(e,(function(e,t){if(-1!==e.indexOf("\0"))throw new s("BSON Document field names cannot contain null bytes, found: "+JSON.stringify(e));return ye(t,n)}))}function n(e,t,n,r){null!=n&&"object"==typeof n&&(r=n,n=0),null==t||"object"!=typeof t||Array.isArray(t)||(r=t,t=void 0,n=0);var i=me(e,Object.assign({relaxed:!0,legacy:!1},r,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(i,t,n)}e.parse=t,e.stringify=n,e.serialize=function(e,t){return t=t||{},JSON.parse(n(e,t))},e.deserialize=function(e,n){return n=n||{},t(JSON.stringify(e),n)}}(ve||(ve={}));var Se=a();we=Se.Map?Se.Map:function(){function e(e){void 0===e&&(e=[]),this._keys=[],this._values={};for(var t=0;t<e.length;t++)if(null!=e[t]){var n=e[t],r=n[0],i=n[1];this._keys.push(r),this._values[r]={v:i,i:this._keys.length-1}}}return e.prototype.clear=function(){this._keys=[],this._values={}},e.prototype.delete=function(e){var t=this._values[e];return null!=t&&(delete this._values[e],this._keys.splice(t.i,1),!0)},e.prototype.entries=function(){var e=this,t=0;return{next:function(){var n=e._keys[t++];return{value:void 0!==n?[n,e._values[n].v]:void 0,done:void 0===n}}}},e.prototype.forEach=function(e,t){t=t||this;for(var n=0;n<this._keys.length;n++){var r=this._keys[n];e.call(t,this._values[r].v,r,t)}},e.prototype.get=function(e){return this._values[e]?this._values[e].v:void 0},e.prototype.has=function(e){return null!=this._values[e]},e.prototype.keys=function(){var e=this,t=0;return{next:function(){var n=e._keys[t++];return{value:void 0!==n?n:void 0,done:void 0===n}}}},e.prototype.set=function(e,t){return this._values[e]?(this._values[e].v=t,this):(this._keys.push(e),this._values[e]={v:t,i:this._keys.length-1},this)},e.prototype.values=function(){var e=this,t=0;return{next:function(){var n=e._keys[t++];return{value:void 0!==n?e._values[n].v:void 0,done:void 0===n}}}},Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!1,configurable:!0}),e}();var Oe=2147483647,xe=-2147483648,Be=Math.pow(2,63)-1,Ne=-Math.pow(2,63),Ee=Math.pow(2,53),je=-Math.pow(2,53),Ie=1,Ae=2,Le=3,Pe=4,Ue=5,Re=6,Te=7,Me=8,De=9,$e=10,ze=11,Ce=12,ke=13,Je=14,Ye=15,Ve=16,qe=17,Fe=18,He=19,Ze=255,Ke=127,We=0,Xe=1,Ge=2,Qe=3,et=4,tt=5,nt=6,rt=7,it=128;function ot(e,t,n){var r=5;if(Array.isArray(e))for(var i=0;i<e.length;i++)r+=st(i.toString(),e[i],t,!0,n);else for(var o in e.toBSON&&(e=e.toBSON()),e)r+=st(o,e[o],t,!1,n);return r}function st(e,t,n,i,o){switch(void 0===n&&(n=!1),void 0===i&&(i=!1),void 0===o&&(o=!1),t&&t.toBSON&&(t=t.toBSON()),typeof t){case"string":return 1+r.Buffer.byteLength(e,"utf8")+1+4+r.Buffer.byteLength(t,"utf8")+1;case"number":return Math.floor(t)===t&&t>=je&&t<=Ee&&t>=xe&&t<=Oe?(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+5:(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+9;case"undefined":return i||!o?(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+1:0;case"boolean":return(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+2;case"object":if(null==t||"MinKey"===t._bsontype||"MaxKey"===t._bsontype)return(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+1;if("ObjectId"===t._bsontype||"ObjectID"===t._bsontype)return(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+13;if(t instanceof Date||m(t))return(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+9;if(ArrayBuffer.isView(t)||t instanceof ArrayBuffer||p(t))return(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+6+t.byteLength;if("Long"===t._bsontype||"Double"===t._bsontype||"Timestamp"===t._bsontype)return(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+9;if("Decimal128"===t._bsontype)return(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+17;if("Code"===t._bsontype)return null!=t.scope&&Object.keys(t.scope).length>0?(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+1+4+4+r.Buffer.byteLength(t.code.toString(),"utf8")+1+ot(t.scope,n,o):(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+1+4+r.Buffer.byteLength(t.code.toString(),"utf8")+1;if("Binary"===t._bsontype)return t.sub_type===j.SUBTYPE_BYTE_ARRAY?(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+(t.position+1+4+1+4):(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+(t.position+1+4+1);if("Symbol"===t._bsontype)return(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+r.Buffer.byteLength(t.value,"utf8")+4+1+1;if("DBRef"===t._bsontype){var s=Object.assign({$ref:t.collection,$id:t.oid},t.fields);return null!=t.db&&(s.$db=t.db),(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+1+ot(s,n,o)}return t instanceof RegExp||b(t)?(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+1+r.Buffer.byteLength(t.source,"utf8")+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1:"BSONRegExp"===t._bsontype?(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+1+r.Buffer.byteLength(t.pattern,"utf8")+1+r.Buffer.byteLength(t.options,"utf8")+1:(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+ot(t,n,o)+1;case"function":if(t instanceof RegExp||b(t)||"[object RegExp]"===String.call(t))return(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+1+r.Buffer.byteLength(t.source,"utf8")+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1;if(n&&null!=t.scope&&Object.keys(t.scope).length>0)return(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+1+4+4+r.Buffer.byteLength(l(t),"utf8")+1+ot(t.scope,n,o);if(n)return(null!=e?r.Buffer.byteLength(e,"utf8")+1:0)+1+4+r.Buffer.byteLength(l(t),"utf8")+1}return 0}function ut(e,t,n){for(var r=0,i=t;i<n;i+=1){var o=e[i];if(r){if(128!=(192&o))return!1;r-=1}else if(128&o)if(192==(224&o))r=1;else if(224==(240&o))r=2;else{if(240!=(248&o))return!1;r=3}}return!r}var ft=$.fromNumber(Ee),at=$.fromNumber(je),lt={};function ct(e,t,n){var r=(t=null==t?{}:t)&&t.index?t.index:0,i=e[r]|e[r+1]<<8|e[r+2]<<16|e[r+3]<<24;if(i<5)throw new s("bson size must be >= 5, is "+i);if(t.allowObjectSmallerThanBufferSize&&e.length<i)throw new s("buffer length "+e.length+" must be >= bson size "+i);if(!t.allowObjectSmallerThanBufferSize&&e.length!==i)throw new s("buffer length "+e.length+" must === bson size "+i);if(i+r>e.byteLength)throw new s("(bson size "+i+" + options.index "+r+" must be <= buffer length "+e.byteLength+")");if(0!==e[r+i-1])throw new s("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return pt(e,r,t,n)}var ht=/^\$ref$|^\$id$|^\$db$/;function pt(e,t,n,i){void 0===i&&(i=!1);var o=null!=n.evalFunctions&&n.evalFunctions,u=null!=n.cacheFunctions&&n.cacheFunctions,f=null==n.fieldsAsRaw?null:n.fieldsAsRaw,a=null!=n.raw&&n.raw,l="boolean"==typeof n.bsonRegExp&&n.bsonRegExp,c=null!=n.promoteBuffers&&n.promoteBuffers,h=null==n.promoteLongs||n.promoteLongs,p=null==n.promoteValues||n.promoteValues,d=t;if(e.length<5)throw new s("corrupt bson message < 5 bytes long");var g=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(g<5||g>e.length)throw new s("corrupt bson message");for(var y=i?[]:{},b=0,m=!i&&null;;){var v=e[t++];if(0===v)break;for(var w=t;0!==e[w]&&w<e.length;)w++;if(w>=e.byteLength)throw new s("Bad BSON Document: illegal CString");var _=i?b++:e.toString("utf8",t,w);!1!==m&&"$"===_[0]&&(m=ht.test(_));var S=void 0;if(t=w+1,v===Ae){if((W=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<=0||W>e.length-t||0!==e[t+W-1])throw new s("bad string length in bson");S=gt(e,t,t+W-1),t+=W}else if(v===Te){var O=r.Buffer.alloc(12);e.copy(O,0,t,t+12),S=new oe(O),t+=12}else if(v===Ve&&!1===p)S=new Q(e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24);else if(v===Ve)S=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;else if(v===Ie&&!1===p)S=new G(e.readDoubleLE(t)),t+=8;else if(v===Ie)S=e.readDoubleLE(t),t+=8;else if(v===De){var x=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,B=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;S=new Date(new $(x,B).toNumber())}else if(v===Me){if(0!==e[t]&&1!==e[t])throw new s("illegal boolean type value");S=1===e[t++]}else if(v===Le){var N=t;if((Z=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)<=0||Z>e.length-t)throw new s("bad embedded document length in bson");S=a?e.slice(t,t+Z):pt(e,N,n,!1),t+=Z}else if(v===Pe){N=t;var E=n,P=t+(Z=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24);if(f&&f[_]){for(var U in E={},n)E[U]=n[U];E.raw=!0}if(S=pt(e,N,E,!0),0!==e[(t+=Z)-1])throw new s("invalid array terminator byte");if(t!==P)throw new s("corrupted array bson")}else if(v===Re)S=void 0;else if(v===$e)S=null;else if(v===Fe){x=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,B=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;var R=new $(x,B);S=h&&!0===p&&R.lessThanOrEqual(ft)&&R.greaterThanOrEqual(at)?R.toNumber():R}else if(v===He){var T=r.Buffer.alloc(16);e.copy(T,0,t,t+16),t+=16;var M=new X(T);S="toObject"in M&&"function"==typeof M.toObject?M.toObject():M}else if(v===Ue){var D=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,z=D,C=e[t++];if(D<0)throw new s("Negative binary type element size found");if(D>e.byteLength)throw new s("Binary type size larger than document size");if(null!=e.slice){if(C===j.SUBTYPE_BYTE_ARRAY){if((D=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<0)throw new s("Negative binary type element size found for subtype 0x02");if(D>z-4)throw new s("Binary type with subtype 0x02 contains too long binary size");if(D<z-4)throw new s("Binary type with subtype 0x02 contains too short binary size")}S=c&&p?e.slice(t,t+D):new j(e.slice(t,t+D),C)}else{var k=r.Buffer.alloc(D);if(C===j.SUBTYPE_BYTE_ARRAY){if((D=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<0)throw new s("Negative binary type element size found for subtype 0x02");if(D>z-4)throw new s("Binary type with subtype 0x02 contains too long binary size");if(D<z-4)throw new s("Binary type with subtype 0x02 contains too short binary size")}for(w=0;w<D;w++)k[w]=e[t+w];S=c&&p?k:new j(k,C)}t+=D}else if(v===ze&&!1===l){for(w=t;0!==e[w]&&w<e.length;)w++;if(w>=e.length)throw new s("Bad BSON Document: illegal CString");var J=e.toString("utf8",t,w);for(w=t=w+1;0!==e[w]&&w<e.length;)w++;if(w>=e.length)throw new s("Bad BSON Document: illegal CString");var Y=e.toString("utf8",t,w);t=w+1;var V=new Array(Y.length);for(w=0;w<Y.length;w++)switch(Y[w]){case"m":V[w]="m";break;case"s":V[w]="g";break;case"i":V[w]="i"}S=new RegExp(J,V.join(""))}else if(v===ze&&!0===l){for(w=t;0!==e[w]&&w<e.length;)w++;if(w>=e.length)throw new s("Bad BSON Document: illegal CString");J=e.toString("utf8",t,w);for(w=t=w+1;0!==e[w]&&w<e.length;)w++;if(w>=e.length)throw new s("Bad BSON Document: illegal CString");Y=e.toString("utf8",t,w);t=w+1,S=new se(J,Y)}else if(v===Je){if((W=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<=0||W>e.length-t||0!==e[t+W-1])throw new s("bad string length in bson");var q=gt(e,t,t+W-1);S=p?q:new ue(q),t+=W}else if(v===qe){x=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,B=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;S=new ae(x,B)}else if(v===Ze)S=new te;else if(v===Ke)S=new ee;else if(v===ke){if((W=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<=0||W>e.length-t||0!==e[t+W-1])throw new s("bad string length in bson");var F=gt(e,t,t+W-1);S=o?u?dt(F,lt,y):dt(F):new I(F),t+=W}else if(v===Ye){var H=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(H<13)throw new s("code_w_scope total size shorter minimum expected length");if((W=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<=0||W>e.length-t||0!==e[t+W-1])throw new s("bad string length in bson");F=gt(e,t,t+W-1),N=t+=W;var Z=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,K=pt(e,N,n,!1);if(t+=Z,H<8+Z+W)throw new s("code_w_scope total size is too short, truncating scope");if(H>8+Z+W)throw new s("code_w_scope total size is too long, clips outer document");o?(S=u?dt(F,lt,y):dt(F)).scope=K:S=new I(F,K)}else{if(v!==Ce)throw new s("Detected unknown BSON type "+v.toString(16)+' for fieldname "'+_+'"');var W;if((W=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<=0||W>e.length-t||0!==e[t+W-1])throw new s("bad string length in bson");if(!ut(e,t,t+W-1))throw new s("Invalid UTF-8 string in BSON document");var ne=e.toString("utf8",t,t+W-1);t+=W;var re=r.Buffer.alloc(12);e.copy(re,0,t,t+12);O=new oe(re);t+=12,S=new L(ne,O)}"__proto__"===_?Object.defineProperty(y,_,{value:S,writable:!0,enumerable:!0,configurable:!0}):y[_]=S}if(g!==t-d){if(i)throw new s("corrupt array bson");throw new s("corrupt object bson")}if(!m)return y;if(A(y)){var ie=Object.assign({},y);return delete ie.$ref,delete ie.$id,delete ie.$db,new L(y.$ref,y.$id,y.$db,ie)}return y}function dt(e,t,n){return t?(null==t[e]&&(t[e]=new Function(e)),t[e].bind(n)):new Function(e)}function gt(e,t,n){for(var r=e.toString("utf8",t,n),i=0;i<r.length;i++)if(65533===r.charCodeAt(i)){if(!ut(e,t,n))throw new s("Invalid UTF-8 string in BSON document");break}return r}function yt(e,t,n,r,i,o){var s,u,f,a="big"===r,l=8*o-i-1,c=(1<<l)-1,h=c>>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=a?o-1:0,g=a?-1:1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-s))<1&&(s--,f*=2),(t+=s+h>=1?p/f:p*Math.pow(2,1-h))*f>=2&&(s++,f/=2),s+h>=c?(u=0,s=c):s+h>=1?(u=(t*f-1)*Math.pow(2,i),s+=h):(u=t*Math.pow(2,h-1)*Math.pow(2,i),s=0)),isNaN(t)&&(u=0);i>=8;)e[n+d]=255&u,d+=g,u/=256,i-=8;for(s=s<<i|u,isNaN(t)&&(s+=8),l+=i;l>0;)e[n+d]=255&s,d+=g,s/=256,l-=8;e[n+d-g]|=128*y}var bt=/\x00/,mt=new Set(["$db","$ref","$id","$clusterTime"]);function vt(e,t,n,r,i){e[r++]=Ae;var o=i?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8");e[(r=r+o+1)-1]=0;var s=e.write(n,r+4,void 0,"utf8");return e[r+3]=s+1>>24&255,e[r+2]=s+1>>16&255,e[r+1]=s+1>>8&255,e[r]=s+1&255,r=r+4+s,e[r++]=0,r}function wt(e,t,n,r,i){Number.isInteger(n)&&n>=xe&&n<=Oe?(e[r++]=Ve,r+=i?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,e[r++]=255&n,e[r++]=n>>8&255,e[r++]=n>>16&255,e[r++]=n>>24&255):(e[r++]=Ie,r+=i?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,yt(e,n,r,"little",52,8),r+=8);return r}function _t(e,t,n,r,i){return e[r++]=$e,r+=i?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,r}function St(e,t,n,r,i){return e[r++]=Me,r+=i?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,e[r++]=n?1:0,r}function Ot(e,t,n,r,i){e[r++]=De,r+=i?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;var o=$.fromNumber(n.getTime()),s=o.getLowBits(),u=o.getHighBits();return e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255,e[r++]=255&u,e[r++]=u>>8&255,e[r++]=u>>16&255,e[r++]=u>>24&255,r}function xt(e,t,n,r,i){if(e[r++]=ze,r+=i?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,n.source&&null!=n.source.match(bt))throw Error("value "+n.source+" must not contain null bytes");return r+=e.write(n.source,r,void 0,"utf8"),e[r++]=0,n.ignoreCase&&(e[r++]=105),n.global&&(e[r++]=115),n.multiline&&(e[r++]=109),e[r++]=0,r}function Bt(e,t,n,r,i){if(e[r++]=ze,r+=i?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,null!=n.pattern.match(bt))throw Error("pattern "+n.pattern+" must not contain null bytes");return r+=e.write(n.pattern,r,void 0,"utf8"),e[r++]=0,r+=e.write(n.options.split("").sort().join(""),r,void 0,"utf8"),e[r++]=0,r}function Nt(e,t,n,r,i){return null===n?e[r++]=$e:"MinKey"===n._bsontype?e[r++]=Ze:e[r++]=Ke,r+=i?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,r}function Et(e,t,n,r,i){if(e[r++]=Te,r+=i?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,"string"==typeof n.id)e.write(n.id,r,void 0,"binary");else{if(!d(n.id))throw new u("object ["+JSON.stringify(n)+"] is not a valid ObjectId");e.set(n.id.subarray(0,12),r)}return r+12}function jt(e,t,n,r,i){e[r++]=Ue,r+=i?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;var o=n.length;return e[r++]=255&o,e[r++]=o>>8&255,e[r++]=o>>16&255,e[r++]=o>>24&255,e[r++]=We,e.set(_(n),r),r+=o}function It(e,t,n,r,i,o,u,f,a,l){void 0===i&&(i=!1),void 0===o&&(o=0),void 0===u&&(u=!1),void 0===f&&(f=!0),void 0===a&&(a=!1),void 0===l&&(l=[]);for(var c=0;c<l.length;c++)if(l[c]===n)throw new s("cyclic dependency detected");l.push(n),e[r++]=Array.isArray(n)?Pe:Le,r+=a?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;var h=zt(e,n,i,r,o+1,u,f,l);return l.pop(),h}function At(e,t,n,r,i){return e[r++]=He,r+=i?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,e.set(n.bytes.subarray(0,16),r),r+16}function Lt(e,t,n,r,i){e[r++]="Long"===n._bsontype?Fe:qe,r+=i?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;var o=n.getLowBits(),s=n.getHighBits();return e[r++]=255&o,e[r++]=o>>8&255,e[r++]=o>>16&255,e[r++]=o>>24&255,e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255,r}function Pt(e,t,n,r,i){return n=n.valueOf(),e[r++]=Ve,r+=i?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,e[r++]=255&n,e[r++]=n>>8&255,e[r++]=n>>16&255,e[r++]=n>>24&255,r}function Ut(e,t,n,r,i){return e[r++]=Ie,r+=i?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0,yt(e,n.value,r,"little",52,8),r+=8}function Rt(e,t,n,r,i,o,s){e[r++]=ke,r+=s?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;var u=l(n),f=e.write(u,r+4,void 0,"utf8")+1;return e[r]=255&f,e[r+1]=f>>8&255,e[r+2]=f>>16&255,e[r+3]=f>>24&255,r=r+4+f-1,e[r++]=0,r}function Tt(e,t,n,r,i,o,s,u,f){if(void 0===i&&(i=!1),void 0===o&&(o=0),void 0===s&&(s=!1),void 0===u&&(u=!0),void 0===f&&(f=!1),n.scope&&"object"==typeof n.scope){e[r++]=Ye,r+=f?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;var a=r,l="string"==typeof n.code?n.code:n.code.toString();r+=4;var c=e.write(l,r+4,void 0,"utf8")+1;e[r]=255&c,e[r+1]=c>>8&255,e[r+2]=c>>16&255,e[r+3]=c>>24&255,e[r+4+c-1]=0,r=r+c+4;var h=zt(e,n.scope,i,r,o+1,s,u);r=h-1;var p=h-a;e[a++]=255&p,e[a++]=p>>8&255,e[a++]=p>>16&255,e[a++]=p>>24&255,e[r++]=0}else{e[r++]=ke,r+=f?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;l=n.code.toString();var d=e.write(l,r+4,void 0,"utf8")+1;e[r]=255&d,e[r+1]=d>>8&255,e[r+2]=d>>16&255,e[r+3]=d>>24&255,r=r+4+d-1,e[r++]=0}return r}function Mt(e,t,n,r,i){e[r++]=Ue,r+=i?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;var o=n.value(!0),s=n.position;return n.sub_type===j.SUBTYPE_BYTE_ARRAY&&(s+=4),e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255,e[r++]=n.sub_type,n.sub_type===j.SUBTYPE_BYTE_ARRAY&&(s-=4,e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255),e.set(o,r),r+=n.position}function Dt(e,t,n,r,i){e[r++]=Je,r+=i?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;var o=e.write(n.value,r+4,void 0,"utf8")+1;return e[r]=255&o,e[r+1]=o>>8&255,e[r+2]=o>>16&255,e[r+3]=o>>24&255,r=r+4+o-1,e[r++]=0,r}function $t(e,t,n,r,i,o,s){e[r++]=Le,r+=s?e.write(t,r,void 0,"ascii"):e.write(t,r,void 0,"utf8"),e[r++]=0;var u=r,f={$ref:n.collection||n.namespace,$id:n.oid};null!=n.db&&(f.$db=n.db);var a=zt(e,f=Object.assign(f,n.fields),!1,r,i+1,o),l=a-u;return e[u++]=255&l,e[u++]=l>>8&255,e[u++]=l>>16&255,e[u++]=l>>24&255,a}function zt(e,t,n,r,i,o,s,f){void 0===n&&(n=!1),void 0===r&&(r=0),void 0===i&&(i=0),void 0===o&&(o=!1),void 0===s&&(s=!0),void 0===f&&(f=[]),r=r||0,(f=f||[]).push(t);var a,l=r+4;if(Array.isArray(t))for(var c=0;c<t.length;c++){var h=""+c;if((S=t[c])&&S.toBSON){if("function"!=typeof S.toBSON)throw new u("toBSON is not a function");S=S.toBSON()}if("string"==typeof S)l=vt(e,h,S,l,!0);else if("number"==typeof S)l=wt(e,h,S,l,!0);else{if("bigint"==typeof S)throw new u("Unsupported type BigInt, please use Decimal128");if("boolean"==typeof S)l=St(e,h,S,l,!0);else if(S instanceof Date||m(S))l=Ot(e,h,S,l,!0);else if(void 0===S)l=_t(e,h,0,l,!0);else if(null===S)l=_t(e,h,0,l,!0);else if("ObjectId"===S._bsontype||"ObjectID"===S._bsontype)l=Et(e,h,S,l,!0);else if(d(S))l=jt(e,h,S,l,!0);else if(S instanceof RegExp||b(S))l=xt(e,h,S,l,!0);else if("object"==typeof S&&null==S._bsontype)l=It(e,h,S,l,n,i,o,s,!0,f);else if("object"==typeof S&&le(S)&&"Decimal128"===S._bsontype)l=At(e,h,S,l,!0);else if("Long"===S._bsontype||"Timestamp"===S._bsontype)l=Lt(e,h,S,l,!0);else if("Double"===S._bsontype)l=Ut(e,h,S,l,!0);else if("function"==typeof S&&o)l=Rt(e,h,S,l,0,0,!0);else if("Code"===S._bsontype)l=Tt(e,h,S,l,n,i,o,s,!0);else if("Binary"===S._bsontype)l=Mt(e,h,S,l,!0);else if("Symbol"===S._bsontype)l=Dt(e,h,S,l,!0);else if("DBRef"===S._bsontype)l=$t(e,h,S,l,i,o,!0);else if("BSONRegExp"===S._bsontype)l=Bt(e,h,S,l,!0);else if("Int32"===S._bsontype)l=Pt(e,h,S,l,!0);else if("MinKey"===S._bsontype||"MaxKey"===S._bsontype)l=Nt(e,h,S,l,!0);else if(void 0!==S._bsontype)throw new u("Unrecognized or invalid _bsontype: "+S._bsontype)}}else if(t instanceof we||(a=t,"[object Map]"===Object.prototype.toString.call(a)))for(var p=t.entries(),v=!1;!v;){var w=p.next();if(!(v=!!w.done)){h=w.value[0];var _=typeof(S=w.value[1]);if("string"==typeof h&&!mt.has(h)){if(null!=h.match(bt))throw Error("key "+h+" must not contain null bytes");if(n){if("$"===h[0])throw Error("key "+h+" must not start with '$'");if(~h.indexOf("."))throw Error("key "+h+" must not contain '.'")}}if("string"===_)l=vt(e,h,S,l);else if("number"===_)l=wt(e,h,S,l);else{if("bigint"===_||g(S)||y(S))throw new u("Unsupported type BigInt, please use Decimal128");if("boolean"===_)l=St(e,h,S,l);else if(S instanceof Date||m(S))l=Ot(e,h,S,l);else if(null===S||void 0===S&&!1===s)l=_t(e,h,0,l);else if("ObjectId"===S._bsontype||"ObjectID"===S._bsontype)l=Et(e,h,S,l);else if(d(S))l=jt(e,h,S,l);else if(S instanceof RegExp||b(S))l=xt(e,h,S,l);else if("object"===_&&null==S._bsontype)l=It(e,h,S,l,n,i,o,s,!1,f);else if("object"===_&&"Decimal128"===S._bsontype)l=At(e,h,S,l);else if("Long"===S._bsontype||"Timestamp"===S._bsontype)l=Lt(e,h,S,l);else if("Double"===S._bsontype)l=Ut(e,h,S,l);else if("Code"===S._bsontype)l=Tt(e,h,S,l,n,i,o,s);else if("function"==typeof S&&o)l=Rt(e,h,S,l,0,0,o);else if("Binary"===S._bsontype)l=Mt(e,h,S,l);else if("Symbol"===S._bsontype)l=Dt(e,h,S,l);else if("DBRef"===S._bsontype)l=$t(e,h,S,l,i,o);else if("BSONRegExp"===S._bsontype)l=Bt(e,h,S,l);else if("Int32"===S._bsontype)l=Pt(e,h,S,l);else if("MinKey"===S._bsontype||"MaxKey"===S._bsontype)l=Nt(e,h,S,l);else if(void 0!==S._bsontype)throw new u("Unrecognized or invalid _bsontype: "+S._bsontype)}}}else{if(t.toBSON){if("function"!=typeof t.toBSON)throw new u("toBSON is not a function");if(null!=(t=t.toBSON())&&"object"!=typeof t)throw new u("toBSON function did not return an object")}for(var h in t){var S;if((S=t[h])&&S.toBSON){if("function"!=typeof S.toBSON)throw new u("toBSON is not a function");S=S.toBSON()}_=typeof S;if("string"==typeof h&&!mt.has(h)){if(null!=h.match(bt))throw Error("key "+h+" must not contain null bytes");if(n){if("$"===h[0])throw Error("key "+h+" must not start with '$'");if(~h.indexOf("."))throw Error("key "+h+" must not contain '.'")}}if("string"===_)l=vt(e,h,S,l);else if("number"===_)l=wt(e,h,S,l);else{if("bigint"===_)throw new u("Unsupported type BigInt, please use Decimal128");if("boolean"===_)l=St(e,h,S,l);else if(S instanceof Date||m(S))l=Ot(e,h,S,l);else if(void 0===S)!1===s&&(l=_t(e,h,0,l));else if(null===S)l=_t(e,h,0,l);else if("ObjectId"===S._bsontype||"ObjectID"===S._bsontype)l=Et(e,h,S,l);else if(d(S))l=jt(e,h,S,l);else if(S instanceof RegExp||b(S))l=xt(e,h,S,l);else if("object"===_&&null==S._bsontype)l=It(e,h,S,l,n,i,o,s,!1,f);else if("object"===_&&"Decimal128"===S._bsontype)l=At(e,h,S,l);else if("Long"===S._bsontype||"Timestamp"===S._bsontype)l=Lt(e,h,S,l);else if("Double"===S._bsontype)l=Ut(e,h,S,l);else if("Code"===S._bsontype)l=Tt(e,h,S,l,n,i,o,s);else if("function"==typeof S&&o)l=Rt(e,h,S,l,0,0,o);else if("Binary"===S._bsontype)l=Mt(e,h,S,l);else if("Symbol"===S._bsontype)l=Dt(e,h,S,l);else if("DBRef"===S._bsontype)l=$t(e,h,S,l,i,o);else if("BSONRegExp"===S._bsontype)l=Bt(e,h,S,l);else if("Int32"===S._bsontype)l=Pt(e,h,S,l);else if("MinKey"===S._bsontype||"MaxKey"===S._bsontype)l=Nt(e,h,S,l);else if(void 0!==S._bsontype)throw new u("Unrecognized or invalid _bsontype: "+S._bsontype)}}}f.pop(),e[l++]=0;var O=l-r;return e[r++]=255&O,e[r++]=O>>8&255,e[r++]=O>>16&255,e[r++]=O>>24&255,l}var Ct=17825792,kt=r.Buffer.alloc(Ct);function Jt(e){kt.length<e&&(kt=r.Buffer.alloc(e))}function Yt(e,t){void 0===t&&(t={});var n="boolean"==typeof t.checkKeys&&t.checkKeys,i="boolean"==typeof t.serializeFunctions&&t.serializeFunctions,o="boolean"!=typeof t.ignoreUndefined||t.ignoreUndefined,s="number"==typeof t.minInternalBufferSize?t.minInternalBufferSize:Ct;kt.length<s&&(kt=r.Buffer.alloc(s));var u=zt(kt,e,n,0,0,i,o,[]),f=r.Buffer.alloc(u);return kt.copy(f,0,0,f.length),f}function Vt(e,t,n){void 0===n&&(n={});var r="boolean"==typeof n.checkKeys&&n.checkKeys,i="boolean"==typeof n.serializeFunctions&&n.serializeFunctions,o="boolean"!=typeof n.ignoreUndefined||n.ignoreUndefined,s="number"==typeof n.index?n.index:0,u=zt(kt,e,r,0,0,i,o);return kt.copy(t,s,0,u),s+u-1}function qt(e,t){return void 0===t&&(t={}),ct(e instanceof r.Buffer?e:_(e),t)}function Ft(e,t){return void 0===t&&(t={}),ot(e,"boolean"==typeof(t=t||{}).serializeFunctions&&t.serializeFunctions,"boolean"!=typeof t.ignoreUndefined||t.ignoreUndefined)}function Ht(e,t,n,r,i,o){for(var s=Object.assign({allowObjectSmallerThanBufferSize:!0,index:0},o),u=_(e),f=t,a=0;a<n;a++){var l=u[f]|u[f+1]<<8|u[f+2]<<16|u[f+3]<<24;s.index=f,r[i+a]=ct(u,s),f+=l}return f}var Zt={Binary:j,Code:I,DBRef:L,Decimal128:X,Double:G,Int32:Q,Long:$,UUID:E,Map:we,MaxKey:ee,MinKey:te,ObjectId:oe,ObjectID:oe,BSONRegExp:se,BSONSymbol:ue,Timestamp:ae,EJSON:ve,setInternalBufferSize:Jt,serialize:Yt,serializeWithBufferAndIndex:Vt,deserialize:qt,calculateObjectSize:Ft,deserializeStream:Ht,BSONError:s,BSONTypeError:u};t.default=Zt},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChildProcessEvaluationListener=void 0;const r=n(2);t.ChildProcessEvaluationListener=class ChildProcessEvaluationListener{constructor(e,t){this.exposedListener=r.exposeAll({onPrompt(t,n){var r,i,o;return null!==(o=null===(i=null===(r=e.evaluationListener)||void 0===r?void 0:r.onPrompt)||void 0===i?void 0:i.call(r,t,n))&&void 0!==o?o:""},onPrint(t){var n,r;return null===(r=null===(n=e.evaluationListener)||void 0===n?void 0:n.onPrint)||void 0===r?void 0:r.call(n,t)},setConfig(t,n){var r,i,o;return null!==(o=null===(i=null===(r=e.evaluationListener)||void 0===r?void 0:r.setConfig)||void 0===i?void 0:i.call(r,t,n))&&void 0!==o?o:Promise.resolve("ignored")},validateConfig(t,n){var r,i,o;return null!==(o=null===(i=null===(r=e.evaluationListener)||void 0===r?void 0:r.validateConfig)||void 0===i?void 0:i.call(r,t,n))&&void 0!==o?o:Promise.resolve(null)},getConfig(t){var n,r;return null===(r=null===(n=e.evaluationListener)||void 0===n?void 0:n.getConfig)||void 0===r?void 0:r.call(n,t)},listConfigOptions(){var t,n;return null===(n=null===(t=e.evaluationListener)||void 0===t?void 0:t.listConfigOptions)||void 0===n?void 0:n.call(t)},onClearCommand(){var t,n;return null===(n=null===(t=e.evaluationListener)||void 0===t?void 0:t.onClearCommand)||void 0===n?void 0:n.call(t)},onExit(t){var n,r,i;return null!==(i=null===(r=null===(n=e.evaluationListener)||void 0===n?void 0:n.onExit)||void 0===r?void 0:r.call(n,t))&&void 0!==i?i:Promise.resolve()}},t)}terminate(){this.exposedListener[r.close]()}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ChildProcessMongoshBus=void 0;const r=n(2);t.ChildProcessMongoshBus=class ChildProcessMongoshBus{constructor(e,t){const n=r.exposeAll({emit(...t){e.emit(...t)},on(){throw new Error("Can't use `on` method on ChildProcessMongoshBus")},once(){throw new Error("Can't use `once` method on ChildProcessMongoshBus")}},t);this.exposedEmitter=n}terminate(){this.exposedEmitter[r.close]()}}}])}));
|