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