@mongosh/node-runtime-worker-thread 2.3.0 → 2.3.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.
Files changed (58) hide show
  1. package/AUTHORS +1 -0
  2. package/dist/153.js +1 -0
  3. package/dist/41.js +1 -0
  4. package/dist/502.js +1 -0
  5. package/dist/{578.js → 503.js} +1 -1
  6. package/dist/{43.js → 527.js} +1 -1
  7. package/dist/534.js +1 -0
  8. package/dist/711.js +1 -0
  9. package/dist/739.js +1 -0
  10. package/dist/index.d.ts +6 -8
  11. package/dist/index.js +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/report.html +2 -2
  14. package/dist/rpc.d.ts +6 -15
  15. package/dist/rpc.js +7 -71
  16. package/dist/rpc.js.map +1 -1
  17. package/dist/worker-process-mongosh-bus.d.ts +7 -0
  18. package/dist/{child-process-mongosh-bus.js → worker-process-mongosh-bus.js} +8 -8
  19. package/dist/worker-process-mongosh-bus.js.map +1 -0
  20. package/dist/worker-runtime.js +16 -16
  21. package/dist/worker-runtime.js.map +1 -1
  22. package/dist/{child-process-evaluation-listener.d.ts → worker-thread-evaluation-listener.d.ts} +2 -4
  23. package/dist/{child-process-evaluation-listener.js → worker-thread-evaluation-listener.js} +6 -6
  24. package/dist/worker-thread-evaluation-listener.js.map +1 -0
  25. package/package.json +13 -12
  26. package/src/index.spec.ts +148 -147
  27. package/src/index.ts +98 -120
  28. package/src/lock.spec.ts +1 -1
  29. package/src/rpc.spec.ts +24 -90
  30. package/src/rpc.ts +17 -98
  31. package/src/{child-process-mongosh-bus.ts → worker-process-mongosh-bus.ts} +5 -6
  32. package/src/worker-runtime.spec.ts +19 -29
  33. package/src/worker-runtime.ts +15 -22
  34. package/src/{child-process-evaluation-listener.ts → worker-thread-evaluation-listener.ts} +3 -4
  35. package/tests/register-worker.js +1 -0
  36. package/tsconfig.json +2 -1
  37. package/webpack.config.js +4 -6
  38. package/__fixtures__/script-that-throws.js +0 -1
  39. package/dist/354.js +0 -1
  40. package/dist/528.js +0 -1
  41. package/dist/650.js +0 -1
  42. package/dist/722.js +0 -1
  43. package/dist/777.js +0 -1
  44. package/dist/942.js +0 -1
  45. package/dist/child-process-evaluation-listener.js.map +0 -1
  46. package/dist/child-process-mongosh-bus.d.ts +0 -9
  47. package/dist/child-process-mongosh-bus.js.map +0 -1
  48. package/dist/child-process-proxy.d.ts +0 -1
  49. package/dist/child-process-proxy.js +0 -1
  50. package/dist/child-process-proxy.js.map +0 -1
  51. package/dist/spawn-child-from-source.d.ts +0 -5
  52. package/dist/spawn-child-from-source.js +0 -74
  53. package/dist/spawn-child-from-source.js.map +0 -1
  54. package/src/child-process-proxy.spec.ts +0 -84
  55. package/src/child-process-proxy.ts +0 -124
  56. package/src/spawn-child-from-source.spec.ts +0 -90
  57. package/src/spawn-child-from-source.ts +0 -102
  58. package/tsconfig.test.json +0 -11
package/dist/722.js DELETED
@@ -1 +0,0 @@
1
- "use strict";exports.id=722,exports.ids=[722],exports.modules={74658:(e,t,r)=>{r.d(t,{H:()=>s});let n=!1;const s=e=>{e&&!n&&parseInt(e.substring(1,e.indexOf(".")))<18&&(n=!0,process.emitWarning("NodeDeprecationWarning: The AWS SDK for JavaScript (v3) will\nno longer support Node.js 16.x on January 6, 2025.\n\nTo continue receiving updates to AWS services, bug fixes, and security\nupdates please upgrade to a supported Node.js LTS version.\n\nMore information can be found at: https://a.co/74kJMmI"))}},234:(e,t,r)=>{r.d(t,{V:()=>AwsSdkSigV4Signer});var n=r(25640);const s=e=>new Date(Date.now()+e),i=e=>n.Zn.isInstance(e)?e.headers?.date??e.headers?.Date:void 0,a=(e,t)=>{const r=Date.parse(e);return((e,t)=>Math.abs(s(t).getTime()-e)>=3e5)(r,t)?r-Date.now():t},o=(e,t)=>{if(!t)throw new Error(`Property \`${e}\` is not resolved for AWS SDK SigV4Auth`);return t};class AwsSdkSigV4Signer{async sign(e,t,r){if(!n.aW.isInstance(e))throw new Error("The request is not an instance of `HttpRequest` and cannot be signed");const{config:i,signer:a,signingRegion:c,signingName:u}=await(async e=>{const t=o("context",e.context),r=o("config",e.config),n=t.endpointV2?.properties?.authSchemes?.[0],s=o("signer",r.signer),i=await s(n),a=e?.signingRegion,c=e?.signingName;return{config:r,signer:i,signingRegion:a,signingName:c}})(r);return await a.sign(e,{signingDate:s(i.systemClockOffset),signingRegion:c,signingService:u})}errorHandler(e){return t=>{const r=t.ServerTime??i(t.$response);if(r){const n=o("config",e.config),s=n.systemClockOffset;n.systemClockOffset=a(r,n.systemClockOffset);n.systemClockOffset!==s&&t.$metadata&&(t.$metadata.clockSkewCorrected=!0)}throw t}}successHandler(e,t){const r=i(e);if(r){const e=o("config",t.config);e.systemClockOffset=a(r,e.systemClockOffset)}}}},35413:(e,t,r)=>{r.d(t,{K:()=>_});var n=r(71818),s=r(63202),i=r(95773),a=r(16969),o=r(7242);const c="X-Amz-Date",u="X-Amz-Signature",d="X-Amz-Security-Token",l="authorization",g=c.toLowerCase(),p=[l,g,"date"],h=u.toLowerCase(),f="x-amz-content-sha256",m=d.toLowerCase(),y={authorization:!0,"cache-control":!0,connection:!0,expect:!0,from:!0,"keep-alive":!0,"max-forwards":!0,pragma:!0,referer:!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0,"user-agent":!0,"x-amzn-trace-id":!0},w=/^proxy-/,S=/^sec-/,v="AWS4-HMAC-SHA256",b="AWS4-HMAC-SHA256-PAYLOAD",R="aws4_request",E={},A=[],T=(e,t,r)=>`${e}/${t}/${r}/${R}`,$=(e,t,r)=>{const n=new e(t);return n.update((0,o._f)(r)),n.digest()},C=({headers:e},t,r)=>{const n={};for(const s of Object.keys(e).sort()){if(null==e[s])continue;const i=s.toLowerCase();(i in y||t?.has(i)||w.test(i)||S.test(i))&&(!r||r&&!r.has(i))||(n[i]=e[s].trim().replace(/\s+/g," "))}return n};var P=r(15730);const I=async({headers:e,body:t},r)=>{for(const t of Object.keys(e))if(t.toLowerCase()===f)return e[t];if(null==t)return"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";if("string"==typeof t||ArrayBuffer.isView(t)||(0,P.e)(t)){const e=new r;return e.update((0,o._f)(t)),(0,s.N)(await e.digest())}return"UNSIGNED-PAYLOAD"};class HeaderFormatter{format(e){const t=[];for(const r of Object.keys(e)){const n=(0,o.$x)(r);t.push(Uint8Array.from([n.byteLength]),n,this.formatHeaderValue(e[r]))}const r=new Uint8Array(t.reduce(((e,t)=>e+t.byteLength),0));let n=0;for(const e of t)r.set(e,n),n+=e.byteLength;return r}formatHeaderValue(e){switch(e.type){case"boolean":return Uint8Array.from([e.value?0:1]);case"byte":return Uint8Array.from([2,e.value]);case"short":const t=new DataView(new ArrayBuffer(3));return t.setUint8(0,3),t.setInt16(1,e.value,!1),new Uint8Array(t.buffer);case"integer":const r=new DataView(new ArrayBuffer(5));return r.setUint8(0,4),r.setInt32(1,e.value,!1),new Uint8Array(r.buffer);case"long":const n=new Uint8Array(9);return n[0]=5,n.set(e.value.bytes,1),n;case"binary":const i=new DataView(new ArrayBuffer(3+e.value.byteLength));i.setUint8(0,6),i.setUint16(1,e.value.byteLength,!1);const a=new Uint8Array(i.buffer);return a.set(e.value,3),a;case"string":const c=(0,o.$x)(e.value),u=new DataView(new ArrayBuffer(3+c.byteLength));u.setUint8(0,7),u.setUint16(1,c.byteLength,!1);const d=new Uint8Array(u.buffer);return d.set(c,3),d;case"timestamp":const l=new Uint8Array(9);return l[0]=8,l.set(Int64.fromNumber(e.value.valueOf()).bytes,1),l;case"uuid":if(!N.test(e.value))throw new Error(`Invalid UUID received: ${e.value}`);const g=new Uint8Array(17);return g[0]=9,g.set((0,s.H)(e.value.replace(/\-/g,"")),1),g}}}var k;!function(e){e[e.boolTrue=0]="boolTrue",e[e.boolFalse=1]="boolFalse",e[e.byte=2]="byte",e[e.short=3]="short",e[e.integer=4]="integer",e[e.long=5]="long",e[e.byteArray=6]="byteArray",e[e.string=7]="string",e[e.timestamp=8]="timestamp",e[e.uuid=9]="uuid"}(k||(k={}));const N=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;class Int64{constructor(e){if(this.bytes=e,8!==e.byteLength)throw new Error("Int64 buffers must be exactly 8 bytes")}static fromNumber(e){if(e>0x8000000000000000||e<-0x8000000000000000)throw new Error(`${e} is too large (or, if negative, too small) to represent as an Int64`);const t=new Uint8Array(8);for(let r=7,n=Math.abs(Math.round(e));r>-1&&n>0;r--,n/=256)t[r]=n;return e<0&&D(t),new Int64(t)}valueOf(){const e=this.bytes.slice(0),t=128&e[0];return t&&D(e),parseInt((0,s.N)(e),16)*(t?-1:1)}toString(){return String(this.valueOf())}}function D(e){for(let t=0;t<8;t++)e[t]^=255;for(let t=7;t>-1&&(e[t]++,0===e[t]);t--);}var x=r(25640);const O=e=>{e=x.aW.clone(e);for(const t of Object.keys(e.headers))p.indexOf(t.toLowerCase())>-1&&delete e.headers[t];return e},U=e=>"number"==typeof e?new Date(1e3*e):"string"==typeof e?Number(e)?new Date(1e3*Number(e)):new Date(e):e;class SignatureV4{constructor({applyChecksum:e,credentials:t,region:r,service:n,sha256:s,uriEscapePath:a=!0}){this.headerFormatter=new HeaderFormatter,this.service=n,this.sha256=s,this.uriEscapePath=a,this.applyChecksum="boolean"!=typeof e||e,this.regionProvider=(0,i.$)(r),this.credentialProvider=(0,i.$)(t)}async presign(e,t={}){const{signingDate:r=new Date,expiresIn:n=3600,unsignableHeaders:s,unhoistableHeaders:i,signableHeaders:a,signingRegion:o,signingService:l}=t,g=await this.credentialProvider();this.validateResolvedCredentials(g);const p=o??await this.regionProvider(),{longDate:h,shortDate:f}=L(r);if(n>604800)return Promise.reject("Signature version 4 presigned URLs must have an expiration date less than one week in the future");const m=T(f,p,l??this.service),y=((e,t={})=>{const{headers:r,query:n={}}=x.aW.clone(e);for(const e of Object.keys(r)){const s=e.toLowerCase();"x-amz-"!==s.slice(0,6)||t.unhoistableHeaders?.has(s)||(n[e]=r[e],delete r[e])}return{...e,headers:r,query:n}})(O(e),{unhoistableHeaders:i});g.sessionToken&&(y.query[d]=g.sessionToken),y.query["X-Amz-Algorithm"]=v,y.query["X-Amz-Credential"]=`${g.accessKeyId}/${m}`,y.query[c]=h,y.query["X-Amz-Expires"]=n.toString(10);const w=C(y,s,a);return y.query["X-Amz-SignedHeaders"]=M(w),y.query[u]=await this.getSignature(h,m,this.getSigningKey(g,p,f,l),this.createCanonicalRequest(y,w,await I(e,this.sha256))),y}async sign(e,t){return"string"==typeof e?this.signString(e,t):e.headers&&e.payload?this.signEvent(e,t):e.message?this.signMessage(e,t):this.signRequest(e,t)}async signEvent({headers:e,payload:t},{signingDate:r=new Date,priorSignature:n,signingRegion:i,signingService:a}){const o=i??await this.regionProvider(),{shortDate:c,longDate:u}=L(r),d=T(c,o,a??this.service),l=await I({headers:{},body:t},this.sha256),g=new this.sha256;g.update(e);const p=(0,s.N)(await g.digest()),h=[b,u,d,n,p,l].join("\n");return this.signString(h,{signingDate:r,signingRegion:o,signingService:a})}async signMessage(e,{signingDate:t=new Date,signingRegion:r,signingService:n}){return this.signEvent({headers:this.headerFormatter.format(e.message.headers),payload:e.message.body},{signingDate:t,signingRegion:r,signingService:n,priorSignature:e.priorSignature}).then((t=>({message:e.message,signature:t})))}async signString(e,{signingDate:t=new Date,signingRegion:r,signingService:n}={}){const i=await this.credentialProvider();this.validateResolvedCredentials(i);const a=r??await this.regionProvider(),{shortDate:c}=L(t),u=new this.sha256(await this.getSigningKey(i,a,c,n));return u.update((0,o._f)(e)),(0,s.N)(await u.digest())}async signRequest(e,{signingDate:t=new Date,signableHeaders:r,unsignableHeaders:n,signingRegion:s,signingService:i}={}){const a=await this.credentialProvider();this.validateResolvedCredentials(a);const o=s??await this.regionProvider(),c=O(e),{longDate:u,shortDate:d}=L(t),p=T(d,o,i??this.service);c.headers[g]=u,a.sessionToken&&(c.headers[m]=a.sessionToken);const h=await I(c,this.sha256);!((e,t)=>{e=e.toLowerCase();for(const r of Object.keys(t))if(e===r.toLowerCase())return!0;return!1})(f,c.headers)&&this.applyChecksum&&(c.headers[f]=h);const y=C(c,n,r),w=await this.getSignature(u,p,this.getSigningKey(a,o,d,i),this.createCanonicalRequest(c,y,h));return c.headers[l]=`${v} Credential=${a.accessKeyId}/${p}, SignedHeaders=${M(y)}, Signature=${w}`,c}createCanonicalRequest(e,t,r){const n=Object.keys(t).sort();return`${e.method}\n${this.getCanonicalPath(e)}\n${(({query:e={}})=>{const t=[],r={};for(const n of Object.keys(e).sort()){if(n.toLowerCase()===h)continue;t.push(n);const s=e[n];"string"==typeof s?r[n]=`${(0,a.i)(n)}=${(0,a.i)(s)}`:Array.isArray(s)&&(r[n]=s.slice(0).reduce(((e,t)=>e.concat([`${(0,a.i)(n)}=${(0,a.i)(t)}`])),[]).sort().join("&"))}return t.map((e=>r[e])).filter((e=>e)).join("&")})(e)}\n${n.map((e=>`${e}:${t[e]}`)).join("\n")}\n\n${n.join(";")}\n${r}`}async createStringToSign(e,t,r){const n=new this.sha256;n.update((0,o._f)(r));const i=await n.digest();return`${v}\n${e}\n${t}\n${(0,s.N)(i)}`}getCanonicalPath({path:e}){if(this.uriEscapePath){const t=[];for(const r of e.split("/"))0!==r?.length&&"."!==r&&(".."===r?t.pop():t.push(r));const r=`${e?.startsWith("/")?"/":""}${t.join("/")}${t.length>0&&e?.endsWith("/")?"/":""}`;return(0,a.i)(r).replace(/%2F/g,"/")}return e}async getSignature(e,t,r,n){const i=await this.createStringToSign(e,t,n),a=new this.sha256(await r);return a.update((0,o._f)(i)),(0,s.N)(await a.digest())}getSigningKey(e,t,r,n){return(async(e,t,r,n,i)=>{const a=await $(e,t.secretAccessKey,t.accessKeyId),o=`${r}:${n}:${i}:${(0,s.N)(a)}:${t.sessionToken}`;if(o in E)return E[o];for(A.push(o);A.length>50;)delete E[A.shift()];let c=`AWS4${t.secretAccessKey}`;for(const t of[r,n,i,R])c=await $(e,c,t);return E[o]=c})(this.sha256,e,r,t,n||this.service)}validateResolvedCredentials(e){if("object"!=typeof e||"string"!=typeof e.accessKeyId||"string"!=typeof e.secretAccessKey)throw new Error("Resolved credential object is not valid")}}const L=e=>{const t=(r=e,U(r).toISOString().replace(/\.\d{3}Z$/,"Z")).replace(/[\-:]/g,"");var r;return{longDate:t,shortDate:t.slice(0,8)}},M=e=>Object.keys(e).sort().join(";"),_=e=>{let t;e.credentials&&(t=(0,n.CU)(e.credentials,n.BP,n.zV)),t||(t=e.credentialDefaultProvider?(0,n.$E)(e.credentialDefaultProvider(Object.assign({},e,{parentClientConfig:e}))):async()=>{throw new Error("`credentials` is missing")});const{signingEscapePath:r=!0,systemClockOffset:s=e.systemClockOffset||0,sha256:i}=e;let a;return a=e.signer?(0,n.$E)(e.signer):e.regionInfoProvider?()=>(0,n.$E)(e.region)().then((async t=>[await e.regionInfoProvider(t,{useFipsEndpoint:await e.useFipsEndpoint(),useDualstackEndpoint:await e.useDualstackEndpoint()})||{},t])).then((([n,s])=>{const{signingRegion:a,signingService:o}=n;e.signingRegion=e.signingRegion||a||s,e.signingName=e.signingName||o||e.serviceId;const c={...e,credentials:t,region:e.signingRegion,service:e.signingName,sha256:i,uriEscapePath:r};return new(e.signerConstructor||SignatureV4)(c)})):async s=>{const a=(s=Object.assign({},{name:"sigv4",signingName:e.signingName||e.defaultSigningName,signingRegion:await(0,n.$E)(e.region)(),properties:{}},s)).signingRegion,o=s.signingName;e.signingRegion=e.signingRegion||a,e.signingName=e.signingName||o||e.serviceId;const c={...e,credentials:t,region:e.signingRegion,service:e.signingName,sha256:i,uriEscapePath:r};return new(e.signerConstructor||SignatureV4)(c)},{...e,systemClockOffset:s,signingEscapePath:r,credentials:t,signer:a}}},29311:(e,t,r)=>{r.d(t,{J:()=>s});var n=r(51630);const s=(e,t)=>(0,n.Wg)(e,t).then((e=>t.utf8Encoder(e)))},37493:(e,t,r)=>{r.d(t,{G2:()=>a,S8:()=>s});var n=r(25640);function s(e){return e}const i={name:"hostHeaderMiddleware",step:"build",priority:"low",tags:["HOST"],override:!0},a=e=>({applyToStack:t=>{t.add((e=>t=>async r=>{if(!n.aW.isInstance(r.request))return t(r);const{request:s}=r,{handlerProtocol:i=""}=e.requestHandler.metadata||{};if(i.indexOf("h2")>=0&&!s.headers[":authority"])delete s.headers.host,s.headers[":authority"]=s.hostname+(s.port?":"+s.port:"");else if(!s.headers.host){let e=s.hostname;null!=s.port&&(e+=`:${s.port}`),s.headers.host=e}return t(r)})(e),i)}})},70183:(e,t,r)=>{r.d(t,{cV:()=>s});const n={name:"loggerMiddleware",tags:["LOGGER"],step:"initialize",override:!0},s=e=>({applyToStack:e=>{e.add(((e,t)=>async r=>{try{const n=await e(r),{clientName:s,commandName:i,logger:a,dynamoDbDocumentClientOptions:o={}}=t,{overrideInputFilterSensitiveLog:c,overrideOutputFilterSensitiveLog:u}=o,d=c??t.inputFilterSensitiveLog,l=u??t.outputFilterSensitiveLog,{$metadata:g,...p}=n.output;return a?.info?.({clientName:s,commandName:i,input:d(r.input),output:l(p),metadata:g}),n}catch(e){const{clientName:n,commandName:s,logger:i,dynamoDbDocumentClientOptions:a={}}=t,{overrideInputFilterSensitiveLog:o}=a,c=o??t.inputFilterSensitiveLog;throw i?.error?.({clientName:n,commandName:s,input:c(r.input),error:e,metadata:e.$metadata}),e}}),n)}})},23703:(e,t,r)=>{r.d(t,{eV:()=>a});var n=r(25640);const s="X-Amzn-Trace-Id",i={step:"build",tags:["RECURSION_DETECTION"],name:"recursionDetectionMiddleware",override:!0,priority:"low"},a=e=>({applyToStack:t=>{t.add((e=>t=>async r=>{const{request:i}=r;if(!n.aW.isInstance(i)||"node"!==e.runtime||i.headers.hasOwnProperty(s))return t(r);const a=process.env.AWS_LAMBDA_FUNCTION_NAME,o=process.env._X_AMZN_TRACE_ID,c=e=>"string"==typeof e&&e.length>0;return c(a)&&c(o)&&(i.headers[s]=o),t({...r,request:i})})(e),i)}})},88610:(e,t,r)=>{function n(e){return{...e,customUserAgent:"string"==typeof e.customUserAgent?[[e.customUserAgent]]:e.customUserAgent}}r.d(t,{XJ:()=>g,er:()=>n});var s=r(99558),i=r(25640);const a="user-agent",o="x-amz-user-agent",c=/[^\!\$\%\&\'\*\+\-\.\^\_\`\|\~\d\w]/g,u=/[^\!\$\%\&\'\*\+\-\.\^\_\`\|\~\d\w\#]/g,d=e=>{const t=e[0].split("/").map((e=>e.replace(c,"-"))).join("/"),r=e[1]?.replace(u,"-"),n=t.indexOf("/"),s=t.substring(0,n);let i=t.substring(n+1);return"api"===s&&(i=i.toLowerCase()),[s,i,r].filter((e=>e&&e.length>0)).reduce(((e,t,r)=>{switch(r){case 0:return t;case 1:return`${e}/${t}`;default:return`${e}#${t}`}}),"")},l={name:"getUserAgentMiddleware",step:"build",priority:"low",tags:["SET_USER_AGENT","USER_AGENT"],override:!0},g=e=>({applyToStack:t=>{var r;t.add((r=e,(e,t)=>async n=>{const{request:c}=n;if(!i.aW.isInstance(c))return e(n);const{headers:u}=c,l=t?.userAgent?.map(d)||[],g=(await r.defaultUserAgentProvider()).map(d),p=r?.customUserAgent?.map(d)||[],h=(0,s.Qj)(),f=(h?[h]:[]).concat([...g,...l,...p]).join(" "),m=[...g.filter((e=>e.startsWith("aws-sdk-"))),...p].join(" ");return"browser"!==r.runtime?(m&&(u[o]=u[o]?`${u[a]} ${m}`:m),u[a]=f):u[o]=f,e({...n,request:c})}),l)}})},31716:(e,t,r)=>{r.d(t,{GW:()=>n,A1:()=>s});const n=e=>{let t=async()=>{if(void 0===e.region)throw new Error("Region is missing from runtimeConfig");const t=e.region;return"string"==typeof t?t:t()};return{setRegion(e){t=e},region:()=>t}},s=e=>({region:e.region()})},99558:(e,t,r)=>{r.d(t,{Iu:()=>c,Qj:()=>o});var n=r(92718);const s=(e,t=!1)=>{if(t){for(const t of e.split("."))if(!s(t))return!1;return!0}return!!(0,n.IA)(e)&&(!(e.length<3||e.length>63)&&(e===e.toLowerCase()&&!(0,n.dY)(e)))};let i=JSON.parse('{"partitions":[{"id":"aws","outputs":{"dnsSuffix":"amazonaws.com","dualStackDnsSuffix":"api.aws","implicitGlobalRegion":"us-east-1","name":"aws","supportsDualStack":true,"supportsFIPS":true},"regionRegex":"^(us|eu|ap|sa|ca|me|af|il)\\\\-\\\\w+\\\\-\\\\d+$","regions":{"af-south-1":{"description":"Africa (Cape Town)"},"ap-east-1":{"description":"Asia Pacific (Hong Kong)"},"ap-northeast-1":{"description":"Asia Pacific (Tokyo)"},"ap-northeast-2":{"description":"Asia Pacific (Seoul)"},"ap-northeast-3":{"description":"Asia Pacific (Osaka)"},"ap-south-1":{"description":"Asia Pacific (Mumbai)"},"ap-south-2":{"description":"Asia Pacific (Hyderabad)"},"ap-southeast-1":{"description":"Asia Pacific (Singapore)"},"ap-southeast-2":{"description":"Asia Pacific (Sydney)"},"ap-southeast-3":{"description":"Asia Pacific (Jakarta)"},"ap-southeast-4":{"description":"Asia Pacific (Melbourne)"},"aws-global":{"description":"AWS Standard global region"},"ca-central-1":{"description":"Canada (Central)"},"ca-west-1":{"description":"Canada West (Calgary)"},"eu-central-1":{"description":"Europe (Frankfurt)"},"eu-central-2":{"description":"Europe (Zurich)"},"eu-north-1":{"description":"Europe (Stockholm)"},"eu-south-1":{"description":"Europe (Milan)"},"eu-south-2":{"description":"Europe (Spain)"},"eu-west-1":{"description":"Europe (Ireland)"},"eu-west-2":{"description":"Europe (London)"},"eu-west-3":{"description":"Europe (Paris)"},"il-central-1":{"description":"Israel (Tel Aviv)"},"me-central-1":{"description":"Middle East (UAE)"},"me-south-1":{"description":"Middle East (Bahrain)"},"sa-east-1":{"description":"South America (Sao Paulo)"},"us-east-1":{"description":"US East (N. Virginia)"},"us-east-2":{"description":"US East (Ohio)"},"us-west-1":{"description":"US West (N. California)"},"us-west-2":{"description":"US West (Oregon)"}}},{"id":"aws-cn","outputs":{"dnsSuffix":"amazonaws.com.cn","dualStackDnsSuffix":"api.amazonwebservices.com.cn","implicitGlobalRegion":"cn-northwest-1","name":"aws-cn","supportsDualStack":true,"supportsFIPS":true},"regionRegex":"^cn\\\\-\\\\w+\\\\-\\\\d+$","regions":{"aws-cn-global":{"description":"AWS China global region"},"cn-north-1":{"description":"China (Beijing)"},"cn-northwest-1":{"description":"China (Ningxia)"}}},{"id":"aws-us-gov","outputs":{"dnsSuffix":"amazonaws.com","dualStackDnsSuffix":"api.aws","implicitGlobalRegion":"us-gov-west-1","name":"aws-us-gov","supportsDualStack":true,"supportsFIPS":true},"regionRegex":"^us\\\\-gov\\\\-\\\\w+\\\\-\\\\d+$","regions":{"aws-us-gov-global":{"description":"AWS GovCloud (US) global region"},"us-gov-east-1":{"description":"AWS GovCloud (US-East)"},"us-gov-west-1":{"description":"AWS GovCloud (US-West)"}}},{"id":"aws-iso","outputs":{"dnsSuffix":"c2s.ic.gov","dualStackDnsSuffix":"c2s.ic.gov","implicitGlobalRegion":"us-iso-east-1","name":"aws-iso","supportsDualStack":false,"supportsFIPS":true},"regionRegex":"^us\\\\-iso\\\\-\\\\w+\\\\-\\\\d+$","regions":{"aws-iso-global":{"description":"AWS ISO (US) global region"},"us-iso-east-1":{"description":"US ISO East"},"us-iso-west-1":{"description":"US ISO WEST"}}},{"id":"aws-iso-b","outputs":{"dnsSuffix":"sc2s.sgov.gov","dualStackDnsSuffix":"sc2s.sgov.gov","implicitGlobalRegion":"us-isob-east-1","name":"aws-iso-b","supportsDualStack":false,"supportsFIPS":true},"regionRegex":"^us\\\\-isob\\\\-\\\\w+\\\\-\\\\d+$","regions":{"aws-iso-b-global":{"description":"AWS ISOB (US) global region"},"us-isob-east-1":{"description":"US ISOB East (Ohio)"}}},{"id":"aws-iso-e","outputs":{"dnsSuffix":"cloud.adc-e.uk","dualStackDnsSuffix":"cloud.adc-e.uk","implicitGlobalRegion":"eu-isoe-west-1","name":"aws-iso-e","supportsDualStack":false,"supportsFIPS":true},"regionRegex":"^eu\\\\-isoe\\\\-\\\\w+\\\\-\\\\d+$","regions":{"eu-isoe-west-1":{"description":"EU ISOE West"}}},{"id":"aws-iso-f","outputs":{"dnsSuffix":"csp.hci.ic.gov","dualStackDnsSuffix":"csp.hci.ic.gov","implicitGlobalRegion":"us-isof-south-1","name":"aws-iso-f","supportsDualStack":false,"supportsFIPS":true},"regionRegex":"^us\\\\-isof\\\\-\\\\w+\\\\-\\\\d+$","regions":{}}],"version":"1.1"}'),a="";const o=()=>a,c={isVirtualHostableS3Bucket:s,parseArn:e=>{const t=e.split(":");if(t.length<6)return null;const[r,n,s,i,a,...o]=t;return"arn"!==r||""===n||""===s||""===o[0]?null:{partition:n,service:s,region:i,accountId:a,resourceId:o[0].includes("/")?o[0].split("/"):o}},partition:e=>{const{partitions:t}=i;for(const r of t){const{regions:t,outputs:n}=r;for(const[r,s]of Object.entries(t))if(r===e)return{...n,...s}}for(const r of t){const{regionRegex:t,outputs:n}=r;if(new RegExp(t).test(e))return{...n}}const r=t.find((e=>"aws"===e.id));if(!r)throw new Error("Provided region was not found in the partition array or regex, and default partition with id 'aws' doesn't exist.");return{...r.outputs}}};n.DY.aws=c},95640:(e,t,r)=>{r.d(t,{fV:()=>o});var n=r(88320),s=r(22037),i=r(77282);const a=!1,o=({serviceId:e,clientVersion:t})=>{const r=[["aws-sdk-js",t],["ua","2.0"],[`os/${(0,s.platform)()}`,(0,s.release)()],["lang/js"],["md/nodejs",`${i.versions.node}`]],o=a?["md/crt-avail"]:null;o&&r.push(o),e&&r.push([`api/${e}`,t]),i.env.AWS_EXECUTION_ENV&&r.push([`exec-env/${i.env.AWS_EXECUTION_ENV}`]);const c=(0,n.M)({environmentVariableSelector:e=>e.AWS_SDK_UA_APP_ID,configFileSelector:e=>e["sdk-ua-app-id"],default:void 0})();let u;return async()=>{if(!u){const e=await c;u=e?[...r,[`app/${e}`]]:[...r]}return u}}},22144:(e,t,r)=>{r.d(t,{zb:()=>c,_c:()=>o,G7:()=>i,NL:()=>a,Xb:()=>l});const n=(e,t,r)=>{if(t in e){if("true"===e[t])return!0;if("false"===e[t])return!1;throw new Error(`Cannot load ${r} "${t}". Expected "true" or "false", got ${e[t]}.`)}};var s;!function(e){e.ENV="env",e.CONFIG="shared config entry"}(s||(s={}));const i={environmentVariableSelector:e=>n(e,"AWS_USE_DUALSTACK_ENDPOINT",s.ENV),configFileSelector:e=>n(e,"use_dualstack_endpoint",s.CONFIG),default:!1},a={environmentVariableSelector:e=>n(e,"AWS_USE_FIPS_ENDPOINT",s.ENV),configFileSelector:e=>n(e,"use_fips_endpoint",s.CONFIG),default:!1};r(95773);const o={environmentVariableSelector:e=>e.AWS_REGION,configFileSelector:e=>e.region,default:()=>{throw new Error("Region is missing")}},c={preferredFile:"credentials"},u=e=>"string"==typeof e&&(e.startsWith("fips-")||e.endsWith("-fips")),d=e=>u(e)?["fips-aws-global","aws-fips"].includes(e)?"us-east-1":e.replace(/fips-(dkr-|prod-)?|-fips/,""):e,l=e=>{const{region:t,useFipsEndpoint:r}=e;if(!t)throw new Error("Region is missing");return{...e,region:async()=>{if("string"==typeof t)return d(t);const e=await t();return d(e)},useFipsEndpoint:async()=>{const e="string"==typeof t?t:await t();return!!u(e)||("function"!=typeof r?Promise.resolve(!!r):r())}}}},71818:(e,t,r)=>{r.d(t,{K5:()=>DefaultIdentityProviderConfig,oH:()=>NoAuthSigner,zV:()=>h,tZ:()=>a,aZ:()=>l,BP:()=>g,CU:()=>f,$E:()=>m,cu:()=>w});r(66627);var n=r(95773);const s=(e,t)=>(r,s)=>async i=>{const a=e.httpAuthSchemeProvider(await t.httpAuthSchemeParametersProvider(e,s,i.input)),o=function(e){const t=new Map;for(const r of e)t.set(r.schemeId,r);return t}(e.httpAuthSchemes),c=(0,n.J)(s),u=[];for(const r of a){const n=o.get(r.schemeId);if(!n){u.push(`HttpAuthScheme \`${r.schemeId}\` was not enabled for this service.`);continue}const i=n.identityProvider(await t.identityProviderConfigProvider(e));if(!i){u.push(`HttpAuthScheme \`${r.schemeId}\` did not have an IdentityProvider configured.`);continue}const{identityProperties:a={},signingProperties:d={}}=r.propertiesExtractor?.(e,s)||{};r.identityProperties=Object.assign(r.identityProperties||{},a),r.signingProperties=Object.assign(r.signingProperties||{},d),c.selectedHttpAuthScheme={httpAuthOption:r,identity:await i(r.identityProperties),signer:n.signer};break}if(!c.selectedHttpAuthScheme)throw new Error(u.join("\n"));return r(i)};const i={step:"serialize",tags:["HTTP_AUTH_SCHEME"],name:"httpAuthSchemeMiddleware",override:!0,relation:"before",toMiddleware:r(75795).Q$.name},a=(e,{httpAuthSchemeParametersProvider:t,identityProviderConfigProvider:r})=>({applyToStack:n=>{n.addRelativeTo(s(e,{httpAuthSchemeParametersProvider:t,identityProviderConfigProvider:r}),i)}});r(43080).JK.name;var o=r(25640);const c=e=>e=>{throw e},u=(e,t)=>{};const d={step:"finalizeRequest",tags:["HTTP_SIGNING"],name:"httpSigningMiddleware",aliases:["apiKeyMiddleware","tokenMiddleware","awsAuthMiddleware"],override:!0,relation:"after",toMiddleware:r(48643).yg.name},l=e=>({applyToStack:e=>{e.addRelativeTo(((e,t)=>async r=>{if(!o.aW.isInstance(r.request))return e(r);const s=(0,n.J)(t).selectedHttpAuthScheme;if(!s)throw new Error("No HttpAuthScheme was selected: unable to sign request");const{httpAuthOption:{signingProperties:i={}},identity:a,signer:d}=s,l=await e({...r,request:await d.sign(r.request,a,i)}).catch((d.errorHandler||c)(i));return(d.successHandler||u)(l.response,i),l}),d)}});class DefaultIdentityProviderConfig{constructor(e){this.authSchemes=new Map;for(const[t,r]of Object.entries(e))void 0!==r&&this.authSchemes.set(t,r)}getIdentityProvider(e){return this.authSchemes.get(e)}}class NoAuthSigner{async sign(e,t,r){return e}}const g=(p=3e5,e=>h(e)&&e.expiration.getTime()-Date.now()<p);var p;const h=e=>void 0!==e.expiration,f=(e,t,r)=>{if(void 0===e)return;const n="function"!=typeof e?async()=>Promise.resolve(e):e;let s,i,a,o=!1;const c=async e=>{i||(i=n(e));try{s=await i,a=!0,o=!1}finally{i=void 0}return s};return void 0===t?async e=>(a&&!e?.forceRefresh||(s=await c(e)),s):async e=>(a&&!e?.forceRefresh||(s=await c(e)),o?s:r(s)?t(s)?(await c(e),s):s:(o=!0,s))},m=e=>{if("function"==typeof e)return e;const t=Promise.resolve(e);return()=>t};var y=r(51630);function w(e,t){return new RequestBuilder(e,t)}class RequestBuilder{constructor(e,t){this.input=e,this.context=t,this.query={},this.method="",this.headers={},this.path="",this.body=null,this.hostname="",this.resolvePathStack=[]}async build(){const{hostname:e,protocol:t="https",port:r,path:n}=await this.context.endpoint();this.path=n;for(const e of this.resolvePathStack)e(this.path);return new o.aW({protocol:t,hostname:this.hostname||e,port:r,method:this.method,path:this.path,query:this.query,body:this.body,headers:this.headers})}hn(e){return this.hostname=e,this}bp(e){return this.resolvePathStack.push((t=>{this.path=`${t?.endsWith("/")?t.slice(0,-1):t||""}`+e})),this}p(e,t,r,n){return this.resolvePathStack.push((s=>{this.path=(0,y.Is)(s,this.input,e,t,r,n)})),this}h(e){return this.headers=e,this}q(e){return this.query=e,this}b(e){return this.body=e,this}m(e){return this.method=e,this}}},87954:(e,t,r)=>{r.d(t,{k:()=>Hash});var n=r(52912),s=r(7242),i=r(14300),a=r(6113);class Hash{constructor(e,t){this.algorithmIdentifier=e,this.secret=t,this.reset()}update(e,t){this.hash.update((0,s._f)(o(e,t)))}digest(){return Promise.resolve(this.hash.digest())}reset(){this.hash=this.secret?(0,a.createHmac)(this.algorithmIdentifier,o(this.secret)):(0,a.createHash)(this.algorithmIdentifier)}}function o(e,t){return i.Buffer.isBuffer(e)?e:"string"==typeof e?(0,n.m)(e,t):ArrayBuffer.isView(e)?(0,n.g)(e.buffer,e.byteOffset,e.byteLength):(0,n.g)(e)}},89362:(e,t,r)=>{r.d(t,{VG:()=>a});var n=r(25640);const s="content-length";const i={step:"build",tags:["SET_CONTENT_LENGTH","CONTENT_LENGTH"],name:"contentLengthMiddleware",override:!0},a=e=>({applyToStack:t=>{var r;t.add((r=e.bodyLengthChecker,e=>async t=>{const i=t.request;if(n.aW.isInstance(i)){const{body:e,headers:t}=i;if(e&&-1===Object.keys(t).map((e=>e.toLowerCase())).indexOf(s))try{const t=r(e);i.headers={...i.headers,[s]:String(t)}}catch(e){}}return e({...t,request:i})}),i)}})},75795:(e,t,r)=>{r.d(t,{Q$:()=>S,a3:()=>v,uW:()=>b});const n=/^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$/,s=/(\d+\.){3}\d+/,i=/\.\./,a=e=>n.test(e)&&!s.test(e)&&!i.test(e),o=e=>{const[t,r,n,,,s]=e.split(":"),i="arn"===t&&e.split(":").length>=6,a=Boolean(i&&r&&n&&s);if(i&&!a)throw new Error(`Invalid ARN: ${e} was an invalid ARN.`);return a},c=(e,t,r)=>{const n=async()=>{const n=r[e]??r[t];return"function"==typeof n?n():n};return"credentialScope"===e||"CredentialScope"===t?async()=>{const e="function"==typeof r.credentials?await r.credentials():r.credentials;return e?.credentialScope??e?.CredentialScope}:"accountId"===e||"AccountId"===t?async()=>{const e="function"==typeof r.credentials?await r.credentials():r.credentials;return e?.accountId??e?.AccountId}:"endpoint"===e||"endpoint"===t?async()=>{const e=await n();if(e&&"object"==typeof e){if("url"in e)return e.url.href;if("hostname"in e){const{protocol:t,hostname:r,port:n,path:s}=e;return`${t}//${r}${n?":"+n:""}${s}`}}return e}:n};var u=r(88320),d=r(43598);const l="AWS_ENDPOINT_URL",g="endpoint_url",p=async e=>(0,u.M)((e=>({environmentVariableSelector:t=>{const r=e.split(" ").map((e=>e.toUpperCase())),n=t[[l,...r].join("_")];if(n)return n;return t[l]||void 0},configFileSelector:(t,r)=>{if(r&&t.services){const n=r[["services",t.services].join(d.Ck)];if(n){const t=n[[e.split(" ").map((e=>e.toLowerCase())).join("_"),g].join(d.Ck)];if(t)return t}}const n=t[g];if(n)return n},default:void 0}))(e))();var h=r(53918);const f=e=>"object"==typeof e?"url"in e?(0,h.e)(e.url):e:(0,h.e)(e),m=async(e,t,r)=>{const n={},s=t?.getEndpointParameterInstructions?.()||{};for(const[t,i]of Object.entries(s))switch(i.type){case"staticContextParams":n[t]=i.value;break;case"contextParams":n[t]=e[i.name];break;case"clientContextParams":case"builtInParams":n[t]=await c(i.name,t,r)();break;default:throw new Error("Unrecognized endpoint parameter instruction: "+JSON.stringify(i))}return 0===Object.keys(s).length&&Object.assign(n,r),"s3"===String(r.serviceId).toLowerCase()&&await(async e=>{const t=e?.Bucket||"";if("string"==typeof e.Bucket&&(e.Bucket=t.replace(/#/g,encodeURIComponent("#")).replace(/\?/g,encodeURIComponent("?"))),o(t)){if(!0===e.ForcePathStyle)throw new Error("Path-style addressing cannot be used with ARN buckets")}else(!a(t)||-1!==t.indexOf(".")&&!String(e.Endpoint).startsWith("http:")||t.toLowerCase()!==t||t.length<3)&&(e.ForcePathStyle=!0);return e.DisableMultiRegionAccessPoints&&(e.disableMultiRegionAccessPoints=!0,e.DisableMRAP=!0),e})(n),n};var y=r(95773);const w=({config:e,instructions:t})=>(r,n)=>async s=>{const i=await(async(e,t,r,n)=>{if(!r.endpoint){const e=await p(r.serviceId||"");e&&(r.endpoint=()=>Promise.resolve(f(e)))}const s=await m(e,t,r);if("function"!=typeof r.endpointProvider)throw new Error("config.endpointProvider is not set.");return r.endpointProvider(s,n)})(s.input,{getEndpointParameterInstructions:()=>t},{...e},n);n.endpointV2=i,n.authSchemes=i.properties?.authSchemes;const a=n.authSchemes?.[0];if(a){n.signing_region=a.signingRegion,n.signing_service=a.signingName;const e=(0,y.J)(n),t=e?.selectedHttpAuthScheme?.httpAuthOption;t&&(t.signingProperties=Object.assign(t.signingProperties||{},{signing_region:a.signingRegion,signingRegion:a.signingRegion,signing_service:a.signingName,signingName:a.signingName,signingRegionSet:a.signingRegionSet},a.properties))}return r({...s})};const S={step:"serialize",tags:["ENDPOINT_PARAMETERS","ENDPOINT_V2","ENDPOINT"],name:"endpointV2Middleware",override:!0,relation:"before",toMiddleware:r(43080).JK.name},v=(e,t)=>({applyToStack:r=>{r.addRelativeTo(w({config:e,instructions:t}),S)}}),b=e=>{const t=e.tls??!0,{endpoint:r}=e,n=null!=r?async()=>f(await(0,y.$)(r)()):void 0,s=!!r;return{...e,endpoint:n,tls:t,isCustomEndpoint:s,useDualstackEndpoint:(0,y.$)(e.useDualstackEndpoint??!1),useFipsEndpoint:(0,y.$)(e.useFipsEndpoint??!1)}}},48643:(e,t,r)=>{r.d(t,{Hs:()=>c,aK:()=>d,NQ:()=>P,BC:()=>u,yg:()=>C});var n=r(88383),s=r(25640);var i=r(95773);const a="AWS_MAX_ATTEMPTS",o="max_attempts",c={environmentVariableSelector:e=>{const t=e[a];if(!t)return;const r=parseInt(t);if(Number.isNaN(r))throw new Error(`Environment variable ${a} mast be a number, got "${t}"`);return r},configFileSelector:e=>{const t=e[o];if(!t)return;const r=parseInt(t);if(Number.isNaN(r))throw new Error(`Shared config file entry ${o} mast be a number, got "${t}"`);return r},default:n.J},u=e=>{const{retryStrategy:t}=e,r=(0,i.$)(e.maxAttempts??n.J);return{...e,maxAttempts:r,retryStrategy:async()=>{if(t)return t;return await(0,i.$)(e.retryMode)()===n.Ul.ADAPTIVE?new n.AY(r):new n.Uz(r)}}},d={environmentVariableSelector:e=>e.AWS_RETRY_MODE,configFileSelector:e=>e.retry_mode,default:n.CA};var l=r(68086),g=r(51630),p=r(6113),h=r.n(p);const f={randomUUID:h().randomUUID},m=new Uint8Array(256);let y=m.length;function w(){return y>m.length-16&&(h().randomFillSync(m),y=0),m.slice(y,y+=16)}const S=[];for(let e=0;e<256;++e)S.push((e+256).toString(16).slice(1));function v(e,t=0){return S[e[t+0]]+S[e[t+1]]+S[e[t+2]]+S[e[t+3]]+"-"+S[e[t+4]]+S[e[t+5]]+"-"+S[e[t+6]]+S[e[t+7]]+"-"+S[e[t+8]]+S[e[t+9]]+"-"+S[e[t+10]]+S[e[t+11]]+S[e[t+12]]+S[e[t+13]]+S[e[t+14]]+S[e[t+15]]}const b=function(e,t,r){if(f.randomUUID&&!t&&!e)return f.randomUUID();const n=(e=e||{}).random||(e.rng||w)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=n[e];return t}return v(n)};var R=r(12781);const E=e=>e?.body instanceof R.Readable||"undefined"!=typeof ReadableStream&&e?.body instanceof ReadableStream,A=e=>void 0!==e.acquireInitialRetryToken&&void 0!==e.refreshRetryTokenForRetry&&void 0!==e.recordSuccess,T=e=>{const t={error:e,errorType:$(e)},r=I(e.$response);return r&&(t.retryAfterHint=r),t},$=e=>(0,l.pK)(e)?"THROTTLING":(0,l.iH)(e)?"TRANSIENT":(0,l.o7)(e)?"SERVER_ERROR":"CLIENT_ERROR",C={name:"retryMiddleware",tags:["RETRY"],step:"finalizeRequest",priority:"high",override:!0},P=e=>({applyToStack:t=>{t.add((e=>(t,r)=>async i=>{let a=await e.retryStrategy();const o=await e.maxAttempts();if(!A(a))return a?.mode&&(r.userAgent=[...r.userAgent||[],["cfg/retry-mode",a.mode]]),a.retry(t,i);{let e=await a.acquireInitialRetryToken(r.partition_id),u=new Error,d=0,l=0;const{request:p}=i,h=s.aW.isInstance(p);for(h&&(p.headers[n.lk]=b());;)try{h&&(p.headers[n.r5]=`attempt=${d+1}; max=${o}`);const{response:r,output:s}=await t(i);return a.recordSuccess(e),s.$metadata.attempts=d+1,s.$metadata.totalRetryDelay=l,{response:r,output:s}}catch(t){const n=T(t);if(u=(c=t)instanceof Error?c:c instanceof Object?Object.assign(new Error,c):"string"==typeof c?new Error(c):new Error(`AWS SDK error wrapper for ${c}`),h&&E(p))throw(r.logger instanceof g.vk?console:r.logger)?.warn("An error was encountered in a non-retryable streaming request."),u;try{e=await a.refreshRetryTokenForRetry(e,n)}catch(e){throw u.$metadata||(u.$metadata={}),u.$metadata.attempts=d+1,u.$metadata.totalRetryDelay=l,u}d=e.getRetryCount();const s=e.getRetryDelay();l+=s,await new Promise((e=>setTimeout(e,s)))}}var c})(e),C)}}),I=e=>{if(!s.Zn.isInstance(e))return;const t=Object.keys(e.headers).find((e=>"retry-after"===e.toLowerCase()));if(!t)return;const r=e.headers[t],n=Number(r);if(!Number.isNaN(n))return new Date(1e3*n);return new Date(r)}},43080:(e,t,r)=>{r.d(t,{p2:()=>o,JK:()=>a});const n=(e,t)=>r=>async n=>{const{response:s}=await r(n);try{return{response:s,output:await t(s,e)}}catch(e){if(Object.defineProperty(e,"$response",{value:s}),!("$metadata"in e)){const t="Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.";e.message+="\n "+t,void 0!==e.$responseBodyText&&e.$response&&(e.$response.body=e.$responseBodyText)}throw e}},s=(e,t)=>(r,n)=>async s=>{const i=n.endpointV2?.url&&e.urlParser?async()=>e.urlParser(n.endpointV2.url):e.endpoint;if(!i)throw new Error("No valid endpoint provider available.");const a=await t(s.input,{...e,endpoint:i});return r({...s,request:a})},i={name:"deserializerMiddleware",step:"deserialize",tags:["DESERIALIZER"],override:!0},a={name:"serializerMiddleware",step:"serialize",tags:["SERIALIZER"],override:!0};function o(e,t,r){return{applyToStack:o=>{o.add(n(e,r),i),o.add(s(e,t),a)}}}},68086:(e,t,r)=>{r.d(t,{o7:()=>u,pK:()=>o,iH:()=>c});const n=["BandwidthLimitExceeded","EC2ThrottledException","LimitExceededException","PriorRequestNotComplete","ProvisionedThroughputExceededException","RequestLimitExceeded","RequestThrottled","RequestThrottledException","SlowDown","ThrottledException","Throttling","ThrottlingException","TooManyRequestsException","TransactionInProgressException"],s=["TimeoutError","RequestTimeout","RequestTimeoutException"],i=[500,502,503,504],a=["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT"],o=e=>429===e.$metadata?.httpStatusCode||n.includes(e.name)||1==e.$retryable?.throttling,c=e=>(e=>e.$metadata?.clockSkewCorrected)(e)||s.includes(e.name)||a.includes(e?.code||"")||i.includes(e.$metadata?.httpStatusCode||0),u=e=>{if(void 0!==e.$metadata?.httpStatusCode){const t=e.$metadata.httpStatusCode;return 500<=t&&t<=599&&!c(e)}return!1}},91743:(e,t,r)=>{r.d(t,{W:()=>s});var n=r(57147);const s=e=>{if(!e)return 0;if("string"==typeof e)return Buffer.byteLength(e);if("number"==typeof e.byteLength)return e.byteLength;if("number"==typeof e.size)return e.size;if("number"==typeof e.start&&"number"==typeof e.end)return e.end+1-e.start;if("string"==typeof e.path||Buffer.isBuffer(e.path))return(0,n.lstatSync)(e.path).size;if("number"==typeof e.fd)return(0,n.fstatSync)(e.fd).size;throw new Error(`Body Length computation failed for ${e}`)}},66918:(e,t,r)=>{r.d(t,{j:()=>d});var n=r(22144),s=r(88320),i=r(68924);const a="AWS_REGION",o="AWS_DEFAULT_REGION",c=["in-region","cross-region","mobile","standard","legacy"],u={environmentVariableSelector:e=>e.AWS_DEFAULTS_MODE,configFileSelector:e=>e.defaults_mode,default:"legacy"},d=({region:e=(0,s.M)(n._c),defaultsMode:t=(0,s.M)(u)}={})=>(0,i.HP)((async()=>{const r="function"==typeof t?await t():t;switch(r?.toLowerCase()){case"auto":return l(e);case"in-region":case"cross-region":case"mobile":case"standard":case"legacy":return Promise.resolve(r?.toLocaleLowerCase());case void 0:return Promise.resolve("legacy");default:throw new Error(`Invalid parameter for "defaultsMode", expect ${c.join(", ")}, got ${r}`)}})),l=async e=>{if(e){const t="function"==typeof e?await e():e,r=await g();return r?t===r?"in-region":"cross-region":"standard"}return"standard"},g=async()=>{if(process.env.AWS_EXECUTION_ENV&&(process.env[a]||process.env[o]))return process.env[a]??process.env[o];if(!process.env.AWS_EC2_METADATA_DISABLED)try{const{getInstanceMetadataEndpoint:e,httpRequest:t}=await Promise.resolve().then(r.bind(r,94176)),n=await e();return(await t({...n,path:"/latest/meta-data/placement/region"})).toString()}catch(e){}}},92718:(e,t,r)=>{r.d(t,{DY:()=>o,dY:()=>s,IA:()=>a,B1:()=>C});const n=new RegExp("^(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}$"),s=e=>n.test(e)||e.startsWith("[")&&e.endsWith("]"),i=new RegExp("^(?!.*-$)(?!-)[a-zA-Z0-9-]{1,63}$"),a=(e,t=!1)=>{if(!t)return i.test(e);const r=e.split(".");for(const e of r)if(!a(e))return!1;return!0},o={},c="endpoints";function u(e){return"object"!=typeof e||null==e?e:"ref"in e?`$${u(e.ref)}`:"fn"in e?`${e.fn}(${(e.argv||[]).map(u).join(", ")})`:JSON.stringify(e,null,2)}class EndpointError extends Error{constructor(e){super(e),this.name="EndpointError"}}const d=(e,t)=>(e=>{const t=e.split("."),r=[];for(const n of t){const t=n.indexOf("[");if(-1!==t){if(n.indexOf("]")!==n.length-1)throw new EndpointError(`Path: '${e}' does not end with ']'`);const s=n.slice(t+1,-1);if(Number.isNaN(parseInt(s)))throw new EndpointError(`Invalid array index: '${s}' in path: '${e}'`);0!==t&&r.push(n.slice(0,t)),r.push(s)}else r.push(n)}return r})(t).reduce(((r,n)=>{if("object"!=typeof r)throw new EndpointError(`Index '${n}' in '${t}' not found in '${JSON.stringify(e)}'`);return Array.isArray(r)?r[parseInt(n)]:r[n]}),e);var l=r(66627);const g={[l.cj.HTTP]:80,[l.cj.HTTPS]:443},p={booleanEquals:(e,t)=>e===t,getAttr:d,isSet:e=>null!=e,isValidHostLabel:a,not:e=>!e,parseURL:e=>{const t=(()=>{try{if(e instanceof URL)return e;if("object"==typeof e&&"hostname"in e){const{hostname:t,port:r,protocol:n="",path:s="",query:i={}}=e,a=new URL(`${n}//${t}${r?`:${r}`:""}${s}`);return a.search=Object.entries(i).map((([e,t])=>`${e}=${t}`)).join("&"),a}return new URL(e)}catch(e){return null}})();if(!t)return console.error(`Unable to parse ${JSON.stringify(e)} as a whatwg URL.`),null;const r=t.href,{host:n,hostname:i,pathname:a,protocol:o,search:c}=t;if(c)return null;const u=o.slice(0,-1);if(!Object.values(l.cj).includes(u))return null;const d=s(i);return{scheme:u,authority:`${n}${r.includes(`${n}:${g[u]}`)||"string"==typeof e&&e.includes(`${n}:${g[u]}`)?`:${g[u]}`:""}`,path:a,normalizedPath:a.endsWith("/")?a:`${a}/`,isIp:d}},stringEquals:(e,t)=>e===t,substring:(e,t,r,n)=>t>=r||e.length<r?null:n?e.substring(e.length-r,e.length-t):e.substring(t,r),uriEncode:e=>encodeURIComponent(e).replace(/[!*'()]/g,(e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`))},h=(e,t)=>{const r=[],n={...t.endpointParams,...t.referenceRecord};let s=0;for(;s<e.length;){const t=e.indexOf("{",s);if(-1===t){r.push(e.slice(s));break}r.push(e.slice(s,t));const i=e.indexOf("}",t);if(-1===i){r.push(e.slice(t));break}"{"===e[t+1]&&"}"===e[i+1]&&(r.push(e.slice(t+1,i)),s=i+2);const a=e.substring(t+1,i);if(a.includes("#")){const[e,t]=a.split("#");r.push(d(n[e],t))}else r.push(n[a]);s=i+1}return r.join("")},f=(e,t,r)=>{if("string"==typeof e)return h(e,r);if(e.fn)return m(e,r);if(e.ref)return(({ref:e},t)=>({...t.endpointParams,...t.referenceRecord}[e]))(e,r);throw new EndpointError(`'${t}': ${String(e)} is not a string, function or reference.`)},m=({fn:e,argv:t},r)=>{const n=t.map((e=>["boolean","number"].includes(typeof e)?e:f(e,"arg",r))),s=e.split(".");return s[0]in o&&null!=s[1]?o[s[0]][s[1]](...n):p[e](...n)},y=({assign:e,...t},r)=>{if(e&&e in r.referenceRecord)throw new EndpointError(`'${e}' is already defined in Reference Record.`);const n=m(t,r);return r.logger?.debug?.(`${c} evaluateCondition: ${u(t)} = ${u(n)}`),{result:""===n||!!n,...null!=e&&{toAssign:{name:e,value:n}}}},w=(e=[],t)=>{const r={};for(const n of e){const{result:e,toAssign:s}=y(n,{...t,referenceRecord:{...t.referenceRecord,...r}});if(!e)return{result:e};s&&(r[s.name]=s.value,t.logger?.debug?.(`${c} assign: ${s.name} := ${u(s.value)}`))}return{result:!0,referenceRecord:r}},S=(e,t)=>Object.entries(e).reduce(((e,[r,n])=>({...e,[r]:n.map((e=>{const n=f(e,"Header value entry",t);if("string"!=typeof n)throw new EndpointError(`Header '${r}' value '${n}' is not a string`);return n}))})),{}),v=(e,t)=>{if(Array.isArray(e))return e.map((e=>v(e,t)));switch(typeof e){case"string":return h(e,t);case"object":if(null===e)throw new EndpointError(`Unexpected endpoint property: ${e}`);return b(e,t);case"boolean":return e;default:throw new EndpointError("Unexpected endpoint property type: "+typeof e)}},b=(e,t)=>Object.entries(e).reduce(((e,[r,n])=>({...e,[r]:v(n,t)})),{}),R=(e,t)=>{const r=f(e,"Endpoint URL",t);if("string"==typeof r)try{return new URL(r)}catch(e){throw console.error(`Failed to construct URL with ${r}`,e),e}throw new EndpointError("Endpoint URL must be a string, got "+typeof r)},E=(e,t)=>{const{conditions:r,endpoint:n}=e,{result:s,referenceRecord:i}=w(r,t);if(!s)return;const a={...t,referenceRecord:{...t.referenceRecord,...i}},{url:o,properties:d,headers:l}=n;return t.logger?.debug?.(`${c} Resolving endpoint from template: ${u(n)}`),{...null!=l&&{headers:S(l,a)},...null!=d&&{properties:b(d,a)},url:R(o,a)}},A=(e,t)=>{const{conditions:r,error:n}=e,{result:s,referenceRecord:i}=w(r,t);if(s)throw new EndpointError(f(n,"Error",{...t,referenceRecord:{...t.referenceRecord,...i}}))},T=(e,t)=>{const{conditions:r,rules:n}=e,{result:s,referenceRecord:i}=w(r,t);if(s)return $(n,{...t,referenceRecord:{...t.referenceRecord,...i}})},$=(e,t)=>{for(const r of e)if("endpoint"===r.type){const e=E(r,t);if(e)return e}else if("error"===r.type)A(r,t);else{if("tree"!==r.type)throw new EndpointError(`Unknown endpoint rule: ${r}`);{const e=T(r,t);if(e)return e}}throw new EndpointError("Rules evaluation failed")},C=(e,t)=>{const{endpointParams:r,logger:n}=t,{parameters:s,rules:i}=e;t.logger?.debug?.(`${c} Initial EndpointParams: ${u(r)}`);const a=Object.entries(s).filter((([,e])=>null!=e.default)).map((([e,t])=>[e,t.default]));if(a.length>0)for(const[e,t]of a)r[e]=r[e]??t;const o=Object.entries(s).filter((([,e])=>e.required)).map((([e])=>e));for(const e of o)if(null==r[e])throw new EndpointError(`Missing required parameter: '${e}'`);const d=$(i,{endpointParams:r,logger:n,referenceRecord:{}});if(t.endpointParams?.Endpoint)try{const e=new URL(t.endpointParams.Endpoint),{protocol:r,port:n}=e;d.url.protocol=r,d.url.port=n}catch(e){}return t.logger?.debug?.(`${c} Resolved endpoint: ${u(d)}`),d}},95773:(e,t,r)=>{r.d(t,{J:()=>s,$:()=>i});var n=r(66627);const s=e=>e[n.zK]||(e[n.zK]={}),i=e=>{if("function"==typeof e)return e;const t=Promise.resolve(e);return()=>t}},88383:(e,t,r)=>{var n;r.d(t,{AY:()=>AdaptiveRetryStrategy,J:()=>s,CA:()=>i,lk:()=>o,r5:()=>c,Ul:()=>n,Uz:()=>StandardRetryStrategy_StandardRetryStrategy}),function(e){e.STANDARD="standard",e.ADAPTIVE="adaptive"}(n||(n={}));const s=3,i=n.STANDARD;var a=r(68086);class DefaultRateLimiter{constructor(e){this.currentCapacity=0,this.enabled=!1,this.lastMaxRate=0,this.measuredTxRate=0,this.requestCount=0,this.lastTimestamp=0,this.timeWindow=0,this.beta=e?.beta??.7,this.minCapacity=e?.minCapacity??1,this.minFillRate=e?.minFillRate??.5,this.scaleConstant=e?.scaleConstant??.4,this.smooth=e?.smooth??.8;const t=this.getCurrentTimeInSeconds();this.lastThrottleTime=t,this.lastTxRateBucket=Math.floor(this.getCurrentTimeInSeconds()),this.fillRate=this.minFillRate,this.maxCapacity=this.minCapacity}getCurrentTimeInSeconds(){return Date.now()/1e3}async getSendToken(){return this.acquireTokenBucket(1)}async acquireTokenBucket(e){if(this.enabled){if(this.refillTokenBucket(),e>this.currentCapacity){const t=(e-this.currentCapacity)/this.fillRate*1e3;await new Promise((e=>setTimeout(e,t)))}this.currentCapacity=this.currentCapacity-e}}refillTokenBucket(){const e=this.getCurrentTimeInSeconds();if(!this.lastTimestamp)return void(this.lastTimestamp=e);const t=(e-this.lastTimestamp)*this.fillRate;this.currentCapacity=Math.min(this.maxCapacity,this.currentCapacity+t),this.lastTimestamp=e}updateClientSendingRate(e){let t;if(this.updateMeasuredRate(),(0,a.pK)(e)){const e=this.enabled?Math.min(this.measuredTxRate,this.fillRate):this.measuredTxRate;this.lastMaxRate=e,this.calculateTimeWindow(),this.lastThrottleTime=this.getCurrentTimeInSeconds(),t=this.cubicThrottle(e),this.enableTokenBucket()}else this.calculateTimeWindow(),t=this.cubicSuccess(this.getCurrentTimeInSeconds());const r=Math.min(t,2*this.measuredTxRate);this.updateTokenBucketRate(r)}calculateTimeWindow(){this.timeWindow=this.getPrecise(Math.pow(this.lastMaxRate*(1-this.beta)/this.scaleConstant,1/3))}cubicThrottle(e){return this.getPrecise(e*this.beta)}cubicSuccess(e){return this.getPrecise(this.scaleConstant*Math.pow(e-this.lastThrottleTime-this.timeWindow,3)+this.lastMaxRate)}enableTokenBucket(){this.enabled=!0}updateTokenBucketRate(e){this.refillTokenBucket(),this.fillRate=Math.max(e,this.minFillRate),this.maxCapacity=Math.max(e,this.minCapacity),this.currentCapacity=Math.min(this.currentCapacity,this.maxCapacity)}updateMeasuredRate(){const e=this.getCurrentTimeInSeconds(),t=Math.floor(2*e)/2;if(this.requestCount++,t>this.lastTxRateBucket){const e=this.requestCount/(t-this.lastTxRateBucket);this.measuredTxRate=this.getPrecise(e*this.smooth+this.measuredTxRate*(1-this.smooth)),this.requestCount=0,this.lastTxRateBucket=t}}getPrecise(e){return parseFloat(e.toFixed(8))}}const o="amz-sdk-invocation-id",c="amz-sdk-request",u=({retryDelay:e,retryCount:t,retryCost:r})=>({getRetryCount:()=>t,getRetryDelay:()=>Math.min(2e4,e),getRetryCost:()=>r});class StandardRetryStrategy_StandardRetryStrategy{constructor(e){this.maxAttempts=e,this.mode=n.STANDARD,this.capacity=500,this.retryBackoffStrategy=(()=>{let e=100;return{computeNextBackoffDelay:t=>Math.floor(Math.min(2e4,Math.random()*2**t*e)),setDelayBase:t=>{e=t}}})(),this.maxAttemptsProvider="function"==typeof e?e:async()=>e}async acquireInitialRetryToken(e){return u({retryDelay:100,retryCount:0})}async refreshRetryTokenForRetry(e,t){const r=await this.getMaxAttempts();if(this.shouldRetry(e,t,r)){const r=t.errorType;this.retryBackoffStrategy.setDelayBase("THROTTLING"===r?500:100);const n=this.retryBackoffStrategy.computeNextBackoffDelay(e.getRetryCount()),s=t.retryAfterHint?Math.max(t.retryAfterHint.getTime()-Date.now()||0,n):n,i=this.getCapacityCost(r);return this.capacity-=i,u({retryDelay:s,retryCount:e.getRetryCount()+1,retryCost:i})}throw new Error("No retry token available")}recordSuccess(e){this.capacity=Math.max(500,this.capacity+(e.getRetryCost()??1))}getCapacity(){return this.capacity}async getMaxAttempts(){try{return await this.maxAttemptsProvider()}catch(e){return console.warn(`Max attempts provider could not resolve. Using default of ${s}`),s}}shouldRetry(e,t,r){return e.getRetryCount()+1<r&&this.capacity>=this.getCapacityCost(t.errorType)&&this.isRetryableError(t.errorType)}getCapacityCost(e){return"TRANSIENT"===e?10:5}isRetryableError(e){return"THROTTLING"===e||"TRANSIENT"===e}}class AdaptiveRetryStrategy{constructor(e,t){this.maxAttemptsProvider=e,this.mode=n.ADAPTIVE;const{rateLimiter:r}=t??{};this.rateLimiter=r??new DefaultRateLimiter,this.standardRetryStrategy=new StandardRetryStrategy_StandardRetryStrategy(e)}async acquireInitialRetryToken(e){return await this.rateLimiter.getSendToken(),this.standardRetryStrategy.acquireInitialRetryToken(e)}async refreshRetryTokenForRetry(e,t){return this.rateLimiter.updateClientSendingRate(t),this.standardRetryStrategy.refreshRetryTokenForRetry(e,t)}recordSuccess(e){this.rateLimiter.updateClientSendingRate({}),this.standardRetryStrategy.recordSuccess(e)}}}};
package/dist/777.js DELETED
@@ -1 +0,0 @@
1
- "use strict";exports.id=777,exports.ids=[777],exports.modules={69777:(e,t,r)=>{r.d(t,{CreateTokenCommand:()=>CreateTokenCommand,SSOOIDCClient:()=>SSOOIDCClient});var o=r(37493),n=r(70183),i=r(23703),s=r(88610),a=r(22144),c=r(71818),d=r(89362),p=r(75795),u=r(48643),l=r(51630),h=r(35413),x=r(95773);const m=async(e,t,r)=>({operation:(0,x.J)(t).operation,region:await(0,x.$)(e.region)()||(()=>{throw new Error("expected `region` to be configured for `aws.auth#sigv4`")})()});const y=e=>{const t=[];switch(e.operation){case"CreateToken":case"RegisterClient":case"StartDeviceAuthorization":t.push({schemeId:"smithy.api#noAuth"});break;default:t.push(function(e){return{schemeId:"aws.auth#sigv4",signingProperties:{name:"sso-oauth",region:e.region},propertiesExtractor:(e,t)=>({signingProperties:{config:e,context:t}})}}(e))}return t},E={UseFIPS:{type:"builtInParams",name:"useFipsEndpoint"},Endpoint:{type:"builtInParams",name:"endpoint"},Region:{type:"builtInParams",name:"region"},UseDualStack:{type:"builtInParams",name:"useDualstackEndpoint"}},S="3.621.0";var v=r(74658),I=r(66495),f=r(95640),g=r(87954),w=r(88320),O=r(11728),b=r(91743),C=r(88383),P=r(234),D=r(53918),k=r(76954),_=r(7242),$=r(99558),A=r(92718);const U="required",R="fn",q="argv",z="ref",T="isSet",Y="booleanEquals",j="error",G="endpoint",M="tree",F="PartitionResult",H="getAttr",V={[U]:!1,type:"String"},J={[U]:!0,default:!1,type:"Boolean"},B={[z]:"Endpoint"},N={[R]:Y,[q]:[{[z]:"UseFIPS"},!0]},L={[R]:Y,[q]:[{[z]:"UseDualStack"},!0]},W={},K={[R]:H,[q]:[{[z]:F},"supportsFIPS"]},Z={[z]:F},Q={[R]:Y,[q]:[!0,{[R]:H,[q]:[Z,"supportsDualStack"]}]},X=[N],ee=[L],te=[{[z]:"Region"}],re={version:"1.0",parameters:{Region:V,UseDualStack:J,UseFIPS:J,Endpoint:V},rules:[{conditions:[{[R]:T,[q]:[B]}],rules:[{conditions:X,error:"Invalid Configuration: FIPS and custom endpoint are not supported",type:j},{conditions:ee,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",type:j},{endpoint:{url:B,properties:W,headers:W},type:G}],type:M},{conditions:[{[R]:T,[q]:te}],rules:[{conditions:[{[R]:"aws.partition",[q]:te,assign:F}],rules:[{conditions:[N,L],rules:[{conditions:[{[R]:Y,[q]:[true,K]},Q],rules:[{endpoint:{url:"https://oidc-fips.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:W,headers:W},type:G}],type:M},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",type:j}],type:M},{conditions:X,rules:[{conditions:[{[R]:Y,[q]:[K,true]}],rules:[{conditions:[{[R]:"stringEquals",[q]:[{[R]:H,[q]:[Z,"name"]},"aws-us-gov"]}],endpoint:{url:"https://oidc.{Region}.amazonaws.com",properties:W,headers:W},type:G},{endpoint:{url:"https://oidc-fips.{Region}.{PartitionResult#dnsSuffix}",properties:W,headers:W},type:G}],type:M},{error:"FIPS is enabled but this partition does not support FIPS",type:j}],type:M},{conditions:ee,rules:[{conditions:[Q],rules:[{endpoint:{url:"https://oidc.{Region}.{PartitionResult#dualStackDnsSuffix}",properties:W,headers:W},type:G}],type:M},{error:"DualStack is enabled but this partition does not support DualStack",type:j}],type:M},{endpoint:{url:"https://oidc.{Region}.{PartitionResult#dnsSuffix}",properties:W,headers:W},type:G}],type:M}],type:M},{error:"Invalid Configuration: Missing Region",type:j}]},oe=(e,t={})=>(0,A.B1)(re,{endpointParams:e,logger:t.logger});A.DY.aws=$.Iu;var ne=r(66918);const ie=e=>{(0,l.H_)(process.version);const t=(0,ne.j)(e),r=()=>t().then(l.jv),o=(e=>({apiVersion:"2019-06-10",base64Decoder:e?.base64Decoder??k.G,base64Encoder:e?.base64Encoder??k.s,disableHostPrefix:e?.disableHostPrefix??!1,endpointProvider:e?.endpointProvider??oe,extensions:e?.extensions??[],httpAuthSchemeProvider:e?.httpAuthSchemeProvider??y,httpAuthSchemes:e?.httpAuthSchemes??[{schemeId:"aws.auth#sigv4",identityProvider:e=>e.getIdentityProvider("aws.auth#sigv4"),signer:new P.V},{schemeId:"smithy.api#noAuth",identityProvider:e=>e.getIdentityProvider("smithy.api#noAuth")||(async()=>({})),signer:new c.oH}],logger:e?.logger??new l.vk,serviceId:e?.serviceId??"SSO OIDC",urlParser:e?.urlParser??D.e,utf8Decoder:e?.utf8Decoder??_.$x,utf8Encoder:e?.utf8Encoder??_.GZ}))(e);return(0,v.H)(process.version),{...o,...e,runtime:"node",defaultsMode:t,bodyLengthChecker:e?.bodyLengthChecker??b.W,credentialDefaultProvider:e?.credentialDefaultProvider??I.iw,defaultUserAgentProvider:e?.defaultUserAgentProvider??(0,f.fV)({serviceId:o.serviceId,clientVersion:S}),maxAttempts:e?.maxAttempts??(0,w.M)(u.Hs),region:e?.region??(0,w.M)(a._c,a.zb),requestHandler:O.NA.create(e?.requestHandler??r),retryMode:e?.retryMode??(0,w.M)({...u.aK,default:async()=>(await r()).retryMode||C.CA}),sha256:e?.sha256??g.k.bind(null,"sha256"),streamCollector:e?.streamCollector??O.CF,useDualstackEndpoint:e?.useDualstackEndpoint??(0,w.M)(a.G7),useFipsEndpoint:e?.useFipsEndpoint??(0,w.M)(a.NL)}};var se=r(31716),ae=r(25640);const ce=e=>{const t=e.httpAuthSchemes;let r=e.httpAuthSchemeProvider,o=e.credentials;return{setHttpAuthScheme(e){const r=t.findIndex((t=>t.schemeId===e.schemeId));-1===r?t.push(e):t.splice(r,1,e)},httpAuthSchemes:()=>t,setHttpAuthSchemeProvider(e){r=e},httpAuthSchemeProvider:()=>r,setCredentials(e){o=e},credentials:()=>o}};class SSOOIDCClient extends l.KU{constructor(...[e]){const t=ie(e||{}),r=(x=t,{...x,useDualstackEndpoint:x.useDualstackEndpoint??!1,useFipsEndpoint:x.useFipsEndpoint??!1,defaultSigningName:"sso-oauth"});var x;const m=(0,a.Xb)(r),y=(0,p.uW)(m),E=(0,o.S8)(y),S=(0,s.er)(E),v=(0,u.BC)(S);var I;const f=((e,t)=>{const r={...(0,se.GW)(e),...(0,l.kE)(e),...(0,ae.cA)(e),...ce(e)};return t.forEach((e=>e.configure(r))),{...e,...(0,se.A1)(r),...(0,l.SQ)(r),...(0,ae.AO)(r),...(o=r,{httpAuthSchemes:o.httpAuthSchemes(),httpAuthSchemeProvider:o.httpAuthSchemeProvider(),credentials:o.credentials()})};var o})((I=v,{...(0,h.K)(I)}),e?.extensions||[]);super(f),this.config=f,this.middlewareStack.use((0,o.G2)(this.config)),this.middlewareStack.use((0,n.cV)(this.config)),this.middlewareStack.use((0,i.eV)(this.config)),this.middlewareStack.use((0,s.XJ)(this.config)),this.middlewareStack.use((0,u.NQ)(this.config)),this.middlewareStack.use((0,d.VG)(this.config)),this.middlewareStack.use((0,c.tZ)(this.config,{httpAuthSchemeParametersProvider:this.getDefaultHttpAuthSchemeParametersProvider(),identityProviderConfigProvider:this.getIdentityProviderConfigProvider()})),this.middlewareStack.use((0,c.aZ)(this.config))}destroy(){super.destroy()}getDefaultHttpAuthSchemeParametersProvider(){return m}getIdentityProviderConfigProvider(){return async e=>new c.K5({"aws.auth#sigv4":e.credentials})}}var de=r(43080);class SSOOIDCServiceException extends l.sI{constructor(e){super(e),Object.setPrototypeOf(this,SSOOIDCServiceException.prototype)}}class AccessDeniedException extends SSOOIDCServiceException{constructor(e){super({name:"AccessDeniedException",$fault:"client",...e}),this.name="AccessDeniedException",this.$fault="client",Object.setPrototypeOf(this,AccessDeniedException.prototype),this.error=e.error,this.error_description=e.error_description}}class AuthorizationPendingException extends SSOOIDCServiceException{constructor(e){super({name:"AuthorizationPendingException",$fault:"client",...e}),this.name="AuthorizationPendingException",this.$fault="client",Object.setPrototypeOf(this,AuthorizationPendingException.prototype),this.error=e.error,this.error_description=e.error_description}}class ExpiredTokenException extends SSOOIDCServiceException{constructor(e){super({name:"ExpiredTokenException",$fault:"client",...e}),this.name="ExpiredTokenException",this.$fault="client",Object.setPrototypeOf(this,ExpiredTokenException.prototype),this.error=e.error,this.error_description=e.error_description}}class InternalServerException extends SSOOIDCServiceException{constructor(e){super({name:"InternalServerException",$fault:"server",...e}),this.name="InternalServerException",this.$fault="server",Object.setPrototypeOf(this,InternalServerException.prototype),this.error=e.error,this.error_description=e.error_description}}class InvalidClientException extends SSOOIDCServiceException{constructor(e){super({name:"InvalidClientException",$fault:"client",...e}),this.name="InvalidClientException",this.$fault="client",Object.setPrototypeOf(this,InvalidClientException.prototype),this.error=e.error,this.error_description=e.error_description}}class InvalidGrantException extends SSOOIDCServiceException{constructor(e){super({name:"InvalidGrantException",$fault:"client",...e}),this.name="InvalidGrantException",this.$fault="client",Object.setPrototypeOf(this,InvalidGrantException.prototype),this.error=e.error,this.error_description=e.error_description}}class InvalidRequestException extends SSOOIDCServiceException{constructor(e){super({name:"InvalidRequestException",$fault:"client",...e}),this.name="InvalidRequestException",this.$fault="client",Object.setPrototypeOf(this,InvalidRequestException.prototype),this.error=e.error,this.error_description=e.error_description}}class InvalidScopeException extends SSOOIDCServiceException{constructor(e){super({name:"InvalidScopeException",$fault:"client",...e}),this.name="InvalidScopeException",this.$fault="client",Object.setPrototypeOf(this,InvalidScopeException.prototype),this.error=e.error,this.error_description=e.error_description}}class SlowDownException extends SSOOIDCServiceException{constructor(e){super({name:"SlowDownException",$fault:"client",...e}),this.name="SlowDownException",this.$fault="client",Object.setPrototypeOf(this,SlowDownException.prototype),this.error=e.error,this.error_description=e.error_description}}class UnauthorizedClientException extends SSOOIDCServiceException{constructor(e){super({name:"UnauthorizedClientException",$fault:"client",...e}),this.name="UnauthorizedClientException",this.$fault="client",Object.setPrototypeOf(this,UnauthorizedClientException.prototype),this.error=e.error,this.error_description=e.error_description}}class UnsupportedGrantTypeException extends SSOOIDCServiceException{constructor(e){super({name:"UnsupportedGrantTypeException",$fault:"client",...e}),this.name="UnsupportedGrantTypeException",this.$fault="client",Object.setPrototypeOf(this,UnsupportedGrantTypeException.prototype),this.error=e.error,this.error_description=e.error_description}}class InvalidRequestRegionException extends SSOOIDCServiceException{constructor(e){super({name:"InvalidRequestRegionException",$fault:"client",...e}),this.name="InvalidRequestRegionException",this.$fault="client",Object.setPrototypeOf(this,InvalidRequestRegionException.prototype),this.error=e.error,this.error_description=e.error_description,this.endpoint=e.endpoint,this.region=e.region}}class InvalidClientMetadataException extends SSOOIDCServiceException{constructor(e){super({name:"InvalidClientMetadataException",$fault:"client",...e}),this.name="InvalidClientMetadataException",this.$fault="client",Object.setPrototypeOf(this,InvalidClientMetadataException.prototype),this.error=e.error,this.error_description=e.error_description}}class InvalidRedirectUriException extends SSOOIDCServiceException{constructor(e){super({name:"InvalidRedirectUriException",$fault:"client",...e}),this.name="InvalidRedirectUriException",this.$fault="client",Object.setPrototypeOf(this,InvalidRedirectUriException.prototype),this.error=e.error,this.error_description=e.error_description}}const pe=e=>({...e,...e.clientSecret&&{clientSecret:l.oc},...e.refreshToken&&{refreshToken:l.oc},...e.codeVerifier&&{codeVerifier:l.oc}}),ue=e=>({...e,...e.accessToken&&{accessToken:l.oc},...e.refreshToken&&{refreshToken:l.oc},...e.idToken&&{idToken:l.oc}});var le=r(10247);const he=async(e,t)=>{const r=(0,c.cu)(e,t);let o;return r.bp("/token"),o=JSON.stringify((0,l.qn)(e,{clientId:[],clientSecret:[],code:[],codeVerifier:[],deviceCode:[],grantType:[],redirectUri:[],refreshToken:[],scope:e=>(0,l.F3)(e)})),r.m("POST").h({"content-type":"application/json"}).b(o),r.build()},xe=async(e,t)=>{if(200!==e.statusCode&&e.statusCode>=300)return me(e,t);const r=(0,l.UI)({$metadata:$e(e)}),o=(0,l.CE)((0,l.Wh)(await(0,le.e1)(e.body,t)),"body"),n=(0,l.qn)(o,{accessToken:l.pY,expiresIn:l.u$,idToken:l.pY,refreshToken:l.pY,tokenType:l.pY});return Object.assign(r,n),r},me=async(e,t)=>{const r={...e,body:await(0,le.fk)(e.body,t)},o=(0,le.mJ)(e,r.body);switch(o){case"AccessDeniedException":case"com.amazonaws.ssooidc#AccessDeniedException":throw await Ee(r,t);case"AuthorizationPendingException":case"com.amazonaws.ssooidc#AuthorizationPendingException":throw await Se(r,t);case"ExpiredTokenException":case"com.amazonaws.ssooidc#ExpiredTokenException":throw await ve(r,t);case"InternalServerException":case"com.amazonaws.ssooidc#InternalServerException":throw await Ie(r,t);case"InvalidClientException":case"com.amazonaws.ssooidc#InvalidClientException":throw await fe(r,t);case"InvalidGrantException":case"com.amazonaws.ssooidc#InvalidGrantException":throw await we(r,t);case"InvalidRequestException":case"com.amazonaws.ssooidc#InvalidRequestException":throw await be(r,t);case"InvalidScopeException":case"com.amazonaws.ssooidc#InvalidScopeException":throw await Pe(r,t);case"SlowDownException":case"com.amazonaws.ssooidc#SlowDownException":throw await De(r,t);case"UnauthorizedClientException":case"com.amazonaws.ssooidc#UnauthorizedClientException":throw await ke(r,t);case"UnsupportedGrantTypeException":case"com.amazonaws.ssooidc#UnsupportedGrantTypeException":throw await _e(r,t);case"InvalidRequestRegionException":case"com.amazonaws.ssooidc#InvalidRequestRegionException":throw await Ce(r,t);case"InvalidClientMetadataException":case"com.amazonaws.ssooidc#InvalidClientMetadataException":throw await ge(r,t);case"InvalidRedirectUriException":case"com.amazonaws.ssooidc#InvalidRedirectUriException":throw await Oe(r,t);default:const n=r.body;return ye({output:e,parsedBody:n,errorCode:o})}},ye=(0,l.PC)(SSOOIDCServiceException),Ee=async(e,t)=>{const r=(0,l.UI)({}),o=e.body,n=(0,l.qn)(o,{error:l.pY,error_description:l.pY});Object.assign(r,n);const i=new AccessDeniedException({$metadata:$e(e),...r});return(0,l.to)(i,e.body)},Se=async(e,t)=>{const r=(0,l.UI)({}),o=e.body,n=(0,l.qn)(o,{error:l.pY,error_description:l.pY});Object.assign(r,n);const i=new AuthorizationPendingException({$metadata:$e(e),...r});return(0,l.to)(i,e.body)},ve=async(e,t)=>{const r=(0,l.UI)({}),o=e.body,n=(0,l.qn)(o,{error:l.pY,error_description:l.pY});Object.assign(r,n);const i=new ExpiredTokenException({$metadata:$e(e),...r});return(0,l.to)(i,e.body)},Ie=async(e,t)=>{const r=(0,l.UI)({}),o=e.body,n=(0,l.qn)(o,{error:l.pY,error_description:l.pY});Object.assign(r,n);const i=new InternalServerException({$metadata:$e(e),...r});return(0,l.to)(i,e.body)},fe=async(e,t)=>{const r=(0,l.UI)({}),o=e.body,n=(0,l.qn)(o,{error:l.pY,error_description:l.pY});Object.assign(r,n);const i=new InvalidClientException({$metadata:$e(e),...r});return(0,l.to)(i,e.body)},ge=async(e,t)=>{const r=(0,l.UI)({}),o=e.body,n=(0,l.qn)(o,{error:l.pY,error_description:l.pY});Object.assign(r,n);const i=new InvalidClientMetadataException({$metadata:$e(e),...r});return(0,l.to)(i,e.body)},we=async(e,t)=>{const r=(0,l.UI)({}),o=e.body,n=(0,l.qn)(o,{error:l.pY,error_description:l.pY});Object.assign(r,n);const i=new InvalidGrantException({$metadata:$e(e),...r});return(0,l.to)(i,e.body)},Oe=async(e,t)=>{const r=(0,l.UI)({}),o=e.body,n=(0,l.qn)(o,{error:l.pY,error_description:l.pY});Object.assign(r,n);const i=new InvalidRedirectUriException({$metadata:$e(e),...r});return(0,l.to)(i,e.body)},be=async(e,t)=>{const r=(0,l.UI)({}),o=e.body,n=(0,l.qn)(o,{error:l.pY,error_description:l.pY});Object.assign(r,n);const i=new InvalidRequestException({$metadata:$e(e),...r});return(0,l.to)(i,e.body)},Ce=async(e,t)=>{const r=(0,l.UI)({}),o=e.body,n=(0,l.qn)(o,{endpoint:l.pY,error:l.pY,error_description:l.pY,region:l.pY});Object.assign(r,n);const i=new InvalidRequestRegionException({$metadata:$e(e),...r});return(0,l.to)(i,e.body)},Pe=async(e,t)=>{const r=(0,l.UI)({}),o=e.body,n=(0,l.qn)(o,{error:l.pY,error_description:l.pY});Object.assign(r,n);const i=new InvalidScopeException({$metadata:$e(e),...r});return(0,l.to)(i,e.body)},De=async(e,t)=>{const r=(0,l.UI)({}),o=e.body,n=(0,l.qn)(o,{error:l.pY,error_description:l.pY});Object.assign(r,n);const i=new SlowDownException({$metadata:$e(e),...r});return(0,l.to)(i,e.body)},ke=async(e,t)=>{const r=(0,l.UI)({}),o=e.body,n=(0,l.qn)(o,{error:l.pY,error_description:l.pY});Object.assign(r,n);const i=new UnauthorizedClientException({$metadata:$e(e),...r});return(0,l.to)(i,e.body)},_e=async(e,t)=>{const r=(0,l.UI)({}),o=e.body,n=(0,l.qn)(o,{error:l.pY,error_description:l.pY});Object.assign(r,n);const i=new UnsupportedGrantTypeException({$metadata:$e(e),...r});return(0,l.to)(i,e.body)},$e=e=>({httpStatusCode:e.statusCode,requestId:e.headers["x-amzn-requestid"]??e.headers["x-amzn-request-id"]??e.headers["x-amz-request-id"],extendedRequestId:e.headers["x-amz-id-2"],cfId:e.headers["x-amz-cf-id"]});class CreateTokenCommand extends(l.mY.classBuilder().ep({...E}).m((function(e,t,r,o){return[(0,de.p2)(r,this.serialize,this.deserialize),(0,p.a3)(r,e.getEndpointParameterInstructions())]})).s("AWSSSOOIDCService","CreateToken",{}).n("SSOOIDCClient","CreateTokenCommand").f(pe,ue).ser(he).de(xe).build()){}},10247:(e,t,r)=>{r.d(t,{e1:()=>n,fk:()=>i,mJ:()=>s});var o=r(29311);const n=(e,t)=>(0,o.J)(e,t).then((e=>{if(e.length)try{return JSON.parse(e)}catch(t){throw"SyntaxError"===t?.name&&Object.defineProperty(t,"$responseBodyText",{value:e}),t}return{}})),i=async(e,t)=>{const r=await n(e,t);return r.message=r.message??r.Message,r},s=(e,t)=>{const r=e=>{let t=e;return"number"==typeof t&&(t=t.toString()),t.indexOf(",")>=0&&(t=t.split(",")[0]),t.indexOf(":")>=0&&(t=t.split(":")[0]),t.indexOf("#")>=0&&(t=t.split("#")[1]),t},o=(n=e.headers,i="x-amzn-errortype",Object.keys(n).find((e=>e.toLowerCase()===i.toLowerCase())));var n,i;return void 0!==o?r(e.headers[o]):void 0!==t.code?r(t.code):void 0!==t.__type?r(t.__type):void 0}}};
package/dist/942.js DELETED
@@ -1 +0,0 @@
1
- "use strict";exports.id=942,exports.ids=[942],exports.modules={64942:(s,e,o)=>{o.d(e,{AssumeRoleCommand:()=>t.x,STSClient:()=>d.X});var t=o(31388),d=o(58292)}};
@@ -1 +0,0 @@
1
- {"version":3,"file":"child-process-evaluation-listener.js","sourceRoot":"","sources":["../src/child-process-evaluation-listener.ts"],"names":[],"mappings":";;;AAEA,+BAAyC;AAEzC,6CAA2D;AAG3D,MAAa,8BAA8B;IAOzC,YAAY,aAA4B,EAAE,YAA0B;QAClE,IAAI,CAAC,eAAe,GAAG,IAAA,eAAS,EAC9B;YACE,QAAQ,CAAC,QAAQ,EAAE,IAAI;;gBACrB,OAAO,CACL,MAAA,MAAA,MAAA,aAAa,CAAC,kBAAkB,0CAAE,QAAQ,mDAAG,QAAQ,EAAE,IAAI,CAAC,mCAAI,EAAE,CACnE,CAAC;YACJ,CAAC;YACD,OAAO,CAAC,MAAM;;gBACZ,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,wCAA2B,CAAC,CAAC;gBACjD,OAAO,MAAA,MAAA,aAAa,CAAC,kBAAkB,0CAAE,OAAO,mDAAG,MAAM,CAAC,CAAC;YAC7D,CAAC;YACD,SAAS,CAAC,GAAG,EAAE,KAAK;;gBAClB,OAAO,CACL,MAAA,MAAA,MAAA,aAAa,CAAC,kBAAkB,0CAAE,SAAS,mDAAG,GAAG,EAAE,KAAK,CAAC,mCACzD,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAC3B,CAAC;YACJ,CAAC;YACD,WAAW,CAAC,GAAG;;gBACb,OAAO,CACL,MAAA,MAAA,MAAA,aAAa,CAAC,kBAAkB,0CAAE,WAAW,mDAAG,GAAG,CAAC,mCACpD,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAC3B,CAAC;YACJ,CAAC;YACD,cAAc,CAAC,GAAG,EAAE,KAAK;;gBACvB,OAAO,CACL,MAAA,MAAA,MAAA,aAAa,CAAC,kBAAkB,0CAAE,cAAc,mDAAG,GAAG,EAAE,KAAK,CAAC,mCAC9D,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CACtB,CAAC;YACJ,CAAC;YACD,SAAS,CAAC,GAAG;;gBACX,OAAO,MAAA,MAAA,aAAa,CAAC,kBAAkB,0CAAE,SAAS,mDAAG,GAAG,CAAC,CAAC;YAC5D,CAAC;YACD,iBAAiB;;gBACf,OAAO,MAAA,MAAA,aAAa,CAAC,kBAAkB,0CAAE,iBAAiB,kDAAI,CAAC;YACjE,CAAC;YACD,cAAc;;gBACZ,OAAO,MAAA,MAAA,aAAa,CAAC,kBAAkB,0CAAE,cAAc,kDAAI,CAAC;YAC9D,CAAC;YACD,MAAM,CAAC,QAAQ;;gBACb,OAAO,CACL,MAAA,MAAA,MAAA,aAAa,CAAC,kBAAkB,0CAAE,MAAM,mDAAG,QAAQ,CAAC,mCACnD,OAAO,CAAC,OAAO,EAAqB,CACtC,CAAC;YACJ,CAAC;SACF,EACD,YAAY,CACb,CAAC;IACJ,CAAC;IAED,SAAS;QACP,IAAI,CAAC,eAAe,CAAC,WAAK,CAAC,EAAE,CAAC;IAChC,CAAC;CACF;AA5DD,wEA4DC"}
@@ -1,9 +0,0 @@
1
- /// <reference types="node" />
2
- import type { ChildProcess } from 'child_process';
3
- import type { MongoshBus } from '@mongosh/types';
4
- import type { Exposed } from './rpc';
5
- export declare class ChildProcessMongoshBus {
6
- exposedEmitter: Exposed<MongoshBus>;
7
- constructor(eventEmitter: MongoshBus, childProcess: ChildProcess);
8
- terminate(): void;
9
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"child-process-mongosh-bus.js","sourceRoot":"","sources":["../src/child-process-mongosh-bus.ts"],"names":[],"mappings":";;;AAGA,+BAAyC;AAEzC,MAAa,sBAAsB;IAGjC,YAAY,YAAwB,EAAE,YAA0B;QAC9D,MAAM,cAAc,GAAwB,IAAA,eAAS,EACnD;YACE,IAAI,CAAC,GAAG,IAAI;gBACV,YAAY,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;YAC7B,CAAC;YACD,EAAE;gBACA,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;YACrE,CAAC;YACD,IAAI;gBACF,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;YACvE,CAAC;SACF,EACD,YAAY,CACb,CAAC;QACF,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED,SAAS;QACP,IAAI,CAAC,cAAc,CAAC,WAAK,CAAC,EAAE,CAAC;IAC/B,CAAC;CACF;AAxBD,wDAwBC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
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 r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(global,(()=>{return e={558:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=s,t.call=function(e){return s(e).apply(null,[].slice.call(arguments,1))};var n,o=r(130),i=(n=o)&&n.__esModule?n:{default:n};function s(e,t){var r=(t=t||{}).addListener||window.addEventListener,n=t.removeListener||window.removeEventListener,o=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,i.default)(),func:e,args:Array.from(arguments)},a=void 0,f=new Promise((function(i,f){var l=function r(){var o=u.apply(null,arguments);if(o&&"postmsg-rpc/server"===o.sender&&o.id===t.id){if(n("message",r),o.err){var s=new Error("Unexpected error calling "+e);return Object.assign(s,o.err),f(s)}i(o.res)}};a=function(){n("message",l);var t=new Error("Canceled call to "+e);t.isCanceled=!0,f(t)},r("message",l),o(t,s)}));return f.cancel=function(){return a()},f}}},246:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(558);Object.defineProperty(t,"caller",{enumerable:!0,get:function(){return i(n).default}}),Object.defineProperty(t,"call",{enumerable:!0,get:function(){return n.call}});var o=r(624);function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"expose",{enumerable:!0,get:function(){return i(o).default}})},624:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){var n=(r=r||{}).addListener||window.addEventListener,o=r.removeListener||window.removeEventListener,i=r.postMessage||window.postMessage,s=r.targetOrigin||"*",u=r.getMessageData||function(e){return e.data},a=r.isCallback||!1,f=function(){var r=u.apply(null,arguments);if(r&&"postmsg-rpc/client"===r.sender&&r.func===e){var n={sender:"postmsg-rpc/server",id:r.id},o=function(e){n.res=e,i(n,s)},f=function(e){n.err=Object.assign({message:e.message},e.output&&e.output.payload),i(n,s)};if(a)t.apply(null,r.args.concat((function(e,t){if(e)return f(e);o(t)})));else{var l=t.apply(null,r.args);Promise.resolve(l).then(o).catch(f)}}};return n("message",f),{close:function(){return o("message",f)}}}},130:(e,t,r)=>{"use strict";e.exports=r(252)},173:(e,t,r)=>{"use strict";var n,o,i,s=r(514),u="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";function a(){i=!1}function f(e){if(e){if(e!==n){if(e.length!==u.length)throw new Error("Custom alphabet for shortid must be "+u.length+" unique characters. You submitted "+e.length+" characters: "+e);var t=e.split("").filter((function(e,t,r){return t!==r.lastIndexOf(e)}));if(t.length)throw new Error("Custom alphabet for shortid must be "+u.length+" unique characters. These characters were not unique: "+t.join(", "));n=e,a()}}else n!==u&&(n=u,a())}function l(){return i||(i=function(){n||f(u);for(var e,t=n.split(""),r=[],o=s.nextValue();t.length>0;)o=s.nextValue(),e=Math.floor(o*t.length),r.push(t.splice(e,1)[0]);return r.join("")}())}e.exports={get:function(){return n||u},characters:function(e){return f(e),n},seed:function(e){s.seed(e),o!==e&&(a(),o=e)},lookup:function(e){return l()[e]},shuffled:l}},89:(e,t,r)=>{"use strict";var n,o,i=r(943);r(173),e.exports=function(e){var t="",r=Math.floor(.001*(Date.now()-1567752802062));return r===o?n++:(n=0,o=r),t+=i(7),t+=i(e),n>0&&(t+=i(n)),t+=i(r)}},943:(e,t,r)=>{"use strict";var n=r(173),o=r(908),i=r(137);e.exports=function(e){for(var t,r=0,s="";!t;)s+=i(o,n.get(),1),t=e<Math.pow(16,r+1),r++;return s}},252:(e,t,r)=>{"use strict";var n=r(173),o=r(89),i=r(56),s=r(696)||0;function u(){return o(s)}e.exports=u,e.exports.generate=u,e.exports.seed=function(t){return n.seed(t),e.exports},e.exports.worker=function(t){return s=t,e.exports},e.exports.characters=function(e){return void 0!==e&&n.characters(e),n.shuffled()},e.exports.isValid=i},56:(e,t,r)=>{"use strict";var n=r(173);e.exports=function(e){return!(!e||"string"!=typeof e||e.length<6||new RegExp("[^"+n.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]").test(e))}},908:(e,t,r)=>{e.exports=r(701)},514:e=>{"use strict";var t=1;e.exports={nextValue:function(){return(t=(9301*t+49297)%233280)/233280},seed:function(e){t=e}}},696:(e,t,r)=>{"use strict";var n=r(1),o=0;!n.isMaster&&n.worker&&(o=n.worker.id),e.exports=parseInt(process.env.NODE_UNIQUE_ID||o,10)},137:e=>{e.exports=function(e,t,r){for(var n=(2<<31-Math.clz32(t.length-1|1))-1,o=Math.ceil(1.6*n*r/t.length),i="";;)for(var s=e(o),u=o;u--;)if((i+=t[s[u]&n]||"").length===+r)return i}},701:(e,t,r)=>{var n=r(113);if(n.randomFillSync){var o={};e.exports=function(e){var t=o[e];return t||(t=Buffer.allocUnsafe(e),e<=255&&(o[e]=t)),n.randomFillSync(t)}}else e.exports=n.randomBytes},754:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const o=r(361),i=r(267),s=n(r(17)),u=r(369),a=r(59),f=process.env.WORKER_RUNTIME_SRC_PATH_DO_NOT_USE_THIS_EXCEPT_FOR_TESTING||s.default.resolve(__dirname,"worker-runtime.js"),l=new i.Worker(f,{env:i.SHARE_ENV}),c=(async()=>{await Promise.race([(async()=>{let e;for(;[e]=await(0,o.once)(l,"message");)if("ready"===e)return})(),(async()=>{const[e]=await(0,o.once)(l,"error");if(e)throw e.message=`Worker thread failed to start with the following error: ${e.message}`,e})()])})();process.setMaxListeners(25),l.setMaxListeners(25);let g=null;const{interrupt:h}=(0,u.createCaller)(["interrupt"],l),p=Object.assign((0,u.createCaller)(["init","evaluate","getCompletions","getShellPrompt"],l),{interrupt:()=>g?((0,a.interrupt)(g),!0):h()});Object.keys(p).forEach((e=>{var t;p[e]=(t=p[e],new Proxy(t,{apply:async(e,t,r)=>(await c,e.call(t,...Array.from(r)))}))})),(0,u.exposeAll)(p,process);const d=Object.assign((0,u.createCaller)(["onPrint","onPrompt","getConfig","setConfig","resetConfig","validateConfig","listConfigOptions","onClearCommand","onExit"],process),{onRunInterruptible(e){g=e}});(0,u.exposeAll)(d,l);const b=(0,u.createCaller)(["emit","on"],process);(0,u.exposeAll)(b,l),process.once("disconnect",(()=>process.exit())),process.nextTick((()=>{var e;null===(e=process.send)||void 0===e||e.call(process,"ready")}))},369:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.createCaller=t.exposeAll=t.cancel=t.close=t.removeTrailingUndefined=t.deserialize=t.serialize=void 0;const o=n(r(655)),i=r(246),s=r(568);function u(e){return`data:;base64,${o.default.serialize(e).toString("base64")}`}function a(e){return/^data:;base64,.+/.test(e)?o.default.deserialize(Buffer.from(e.replace("data:;base64,",""),"base64")):e}var f;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 g(e){return l(e)&&"postmsg-rpc/client"===e.sender}function h(e){if(Array.isArray(e))for(e=[...e];e.length>0&&void 0===e[e.length-1];)e.pop();return e}function p(e){return{addListener:e.on.bind(e),removeListener:e.off.bind(e),postMessage(t){if(g(t)&&Array.isArray(t.args)&&(t.args=u(h(t.args))),c(t))try{t.res=u(t.res)}catch(e){t.res=u({type:f.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=>(g(e)&&e.args&&"string"==typeof e.args&&(e.args=a(e.args)),c(e)&&"string"==typeof e.res&&(e.res=a(e.res)),e)}}t.serialize=u,t.deserialize=a,function(e){e[e.Message=0]="Message",e[e.Error=1]="Error"}(f||(f={})),t.removeTrailingUndefined=h,t.close=Symbol("@@rpc.close"),t.cancel=Symbol("@@rpc.cancel"),t.exposeAll=function(e,r){return Object.entries(e).forEach((([e,t])=>{const{close:n}=(0,i.expose)(e,(async(...e)=>{try{return{type:f.Message,payload:await t(...e)}}catch(e){return{type:f.Error,payload:(0,s.serializeError)(e)}}}),p(r));t.close=n})),Object.defineProperty(e,t.close,{enumerable:!1,value(){Object.values(e).forEach((e=>{e.close()}))}}),e},t.createCaller=function(e,r,n={}){const o={},u=new Set;return e.forEach((e=>{const t=(0,i.caller)(e,p(r));o[e]=async(...r)=>{var o;const i="function"==typeof n[e]?null===(o=n[e])||void 0===o?void 0:o.call(n,...r):r,a=t(...i);u.add(a);const l=await a;if(u.delete(a),(c=l)&&"object"==typeof c&&c.type===f.Error)throw(0,s.deserializeError)(l.payload);var c;return l.payload}})),Object.defineProperty(o,t.cancel,{enumerable:!1,value(){for(const e of u)e.cancel(),u.delete(e)}}),o}},568:(e,t,r)=>{"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 n=r(837),o=r(429);function i(e){var t;return(t=e,Object.getOwnPropertyNames(t)).concat("name").filter((t=>"function"!=typeof e[t])).reduce(((t,r)=>(t[r]=e[r],t)),{})}function s(e){return Object.assign(new Error,e)}var u;t.serializeError=i,t.deserializeError=s,function(e){e.SerializedErrorResult="SerializedErrorResult",e.InspectResult="InspectResult",e.SerializedShellApiResult="SerializedShellApiResult"}(u||(t.SerializedResultTypes=u={})),t.serializeEvaluationResult=function({type:e,printable:t,source:r}){return"object"!=typeof(s=t)&&"function"!=typeof s||null===s?{type:e,printable:t,source:r}:function(e){return e&&e.name&&e.message&&e.stack}(t)?{type:u.SerializedErrorResult,printable:i(t),source:r}:null===e?{type:u.InspectResult,printable:(0,n.inspect)(t),source:r}:{type:u.SerializedShellApiResult,printable:{origType:e,serializedValue:o.EJSON.serialize(t)}};var s},t.deserializeEvaluationResult=function({type:e,printable:t,source:r}){return e===u.SerializedErrorResult?{type:e,printable:s(t),source:r}:e===u.SerializedShellApiResult?{type:t.origType,printable:o.EJSON.deserialize(t.serializedValue),source:r}:{type:e,printable:t,source:r}};const a=["schemaMap","encryptedFieldsMap"];t.serializeConnectOptions=function(e){var t;const r={...e};for(const e of a)(null===(t=r.autoEncryption)||void 0===t?void 0:t[e])&&(r.autoEncryption={...r.autoEncryption,[e]:o.EJSON.serialize(r.autoEncryption[e],{relaxed:!1})});return r},t.deserializeConnectOptions=function(e){var t;const r={...e};for(const e of a)(null===(t=r.autoEncryption)||void 0===t?void 0:t[e])&&(r.autoEncryption={...r.autoEncryption,[e]:o.EJSON.deserialize(r.autoEncryption[e],{relaxed:!1})});return r}},59:e=>{"use strict";e.exports=require("interruptor")},1:e=>{"use strict";e.exports=require("cluster")},113:e=>{"use strict";e.exports=require("crypto")},361:e=>{"use strict";e.exports=require("events")},17:e=>{"use strict";e.exports=require("path")},837:e=>{"use strict";e.exports=require("util")},655:e=>{"use strict";e.exports=require("v8")},267:e=>{"use strict";e.exports=require("worker_threads")},429:(e,t,r)=>{"use strict";function n(e){return["[object ArrayBuffer]","[object SharedArrayBuffer]"].includes(Object.prototype.toString.call(e))}function o(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)}function i(e){return"[object RegExp]"===Object.prototype.toString.call(e)}function s(e){return"[object Map]"===Object.prototype.toString.call(e)}function u(e){return"[object Date]"===Object.prototype.toString.call(e)}function a(e,t){return JSON.stringify(e,((e,t)=>"bigint"==typeof t?{$numberLong:`${t}`}:s(t)?Object.fromEntries(t):t))}const f=6,l=2147483647,c=-2147483648,g=Math.pow(2,63)-1,h=-Math.pow(2,63),p=Math.pow(2,53),d=-Math.pow(2,53),b=1,y=2,m=3,w=4,B=5,S=6,O=7,N=8,E=9,L=10,x=11,I=12,_=13,v=14,U=15,$=16,T=17,j=18,D=19,R=255,A=127,M=0,z=4,F=Object.freeze({double:1,string:2,object:3,array:4,binData:5,undefined:6,objectId:7,bool:8,date:9,null:10,regex:11,dbPointer:12,javascript:13,symbol:14,javascriptWithScope:15,int:16,timestamp:17,long:18,decimal:19,minKey:-1,maxKey:127});class BSONError extends Error{get bsonError(){return!0}get name(){return"BSONError"}constructor(e,t){super(e,t)}static isBSONError(e){return null!=e&&"object"==typeof e&&"bsonError"in e&&!0===e.bsonError&&"name"in e&&"message"in e&&"stack"in e}}class BSONVersionError extends BSONError{get name(){return"BSONVersionError"}constructor(){super(`Unsupported BSON version, bson types must be from bson ${f}.x.x`)}}class BSONRuntimeError extends BSONError{get name(){return"BSONRuntimeError"}constructor(e){super(e)}}class BSONOffsetError extends BSONError{get name(){return"BSONOffsetError"}constructor(e,t,r){super(`${e}. offset: ${t}`,r),this.offset=t}}let V,C;function J(e,t,r,n){if(n){V??=new TextDecoder("utf8",{fatal:!0});try{return V.decode(e.subarray(t,r))}catch(e){throw new BSONError("Invalid UTF-8 string in BSON document",{cause:e})}}return C??=new TextDecoder("utf8",{fatal:!1}),C.decode(e.subarray(t,r))}function q(e,t,r){if(0===e.length)return"";const n=r-t;if(0===n)return"";if(n>20)return null;if(1===n&&e[t]<128)return String.fromCharCode(e[t]);if(2===n&&e[t]<128&&e[t+1]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1]);if(3===n&&e[t]<128&&e[t+1]<128&&e[t+2]<128)return String.fromCharCode(e[t])+String.fromCharCode(e[t+1])+String.fromCharCode(e[t+2]);const o=[];for(let n=t;n<r;n++){const t=e[n];if(t>127)return null;o.push(t)}return String.fromCharCode(...o)}function P(e){return k.fromNumberArray(Array.from({length:e},(()=>Math.floor(256*Math.random()))))}const k={toLocalBufferType(e){if(Buffer.isBuffer(e))return e;if(ArrayBuffer.isView(e))return Buffer.from(e.buffer,e.byteOffset,e.byteLength);const t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if("ArrayBuffer"===t||"SharedArrayBuffer"===t||"[object ArrayBuffer]"===t||"[object SharedArrayBuffer]"===t)return Buffer.from(e);throw new BSONError(`Cannot create Buffer from ${String(e)}`)},allocate:e=>Buffer.alloc(e),allocateUnsafe:e=>Buffer.allocUnsafe(e),equals:(e,t)=>k.toLocalBufferType(e).equals(t),fromNumberArray:e=>Buffer.from(e),fromBase64:e=>Buffer.from(e,"base64"),toBase64:e=>k.toLocalBufferType(e).toString("base64"),fromISO88591:e=>Buffer.from(e,"binary"),toISO88591:e=>k.toLocalBufferType(e).toString("binary"),fromHex:e=>Buffer.from(e,"hex"),toHex:e=>k.toLocalBufferType(e).toString("hex"),toUTF8(e,t,r,n){const o=r-t<=20?q(e,t,r):null;if(null!=o)return o;const i=k.toLocalBufferType(e).toString("utf8",t,r);if(n)for(let n=0;n<i.length;n++)if(65533===i.charCodeAt(n)){J(e,t,r,!0);break}return i},utf8ByteLength:e=>Buffer.byteLength(e,"utf8"),encodeUTF8Into(e,t,r){const n=function(e,t,r){if(0===t.length)return 0;if(t.length>25)return null;if(e.length-r<t.length)return null;for(let n=0,o=r;n<t.length;n++,o++){const r=t.charCodeAt(n);if(r>127)return null;e[o]=r}return t.length}(e,t,r);return null!=n?n:k.toLocalBufferType(e).write(t,r,void 0,"utf8")},randomBytes:(()=>{try{return r(113).randomBytes}catch{return P}})()};function H(e){if(e<0)throw new RangeError(`The argument 'byteLength' is invalid. Received ${e}`);return Z.fromNumberArray(Array.from({length:e},(()=>Math.floor(256*Math.random()))))}const K=(()=>{const{crypto:e}=globalThis;if(null!=e&&"function"==typeof e.getRandomValues)return t=>e.getRandomValues(Z.allocate(t));if(function(){const{navigator:e}=globalThis;return"object"==typeof e&&"ReactNative"===e.product}()){const{console:e}=globalThis;e?.warn?.("BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.")}return H})(),Y=/(\d|[a-f])/i,Z={toLocalBufferType(e){const t=e?.[Symbol.toStringTag]??Object.prototype.toString.call(e);if("Uint8Array"===t)return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength));if("ArrayBuffer"===t||"SharedArrayBuffer"===t||"[object ArrayBuffer]"===t||"[object SharedArrayBuffer]"===t)return new Uint8Array(e);throw new BSONError(`Cannot make a Uint8Array from ${String(e)}`)},allocate(e){if("number"!=typeof e)throw new TypeError(`The "size" argument must be of type number. Received ${String(e)}`);return new Uint8Array(e)},allocateUnsafe:e=>Z.allocate(e),equals(e,t){if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0},fromNumberArray:e=>Uint8Array.from(e),fromBase64:e=>Uint8Array.from(atob(e),(e=>e.charCodeAt(0))),toBase64:e=>btoa(Z.toISO88591(e)),fromISO88591:e=>Uint8Array.from(e,(e=>255&e.charCodeAt(0))),toISO88591:e=>Array.from(Uint16Array.from(e),(e=>String.fromCharCode(e))).join(""),fromHex(e){const t=e.length%2==0?e:e.slice(0,e.length-1),r=[];for(let e=0;e<t.length;e+=2){const n=t[e],o=t[e+1];if(!Y.test(n))break;if(!Y.test(o))break;const i=Number.parseInt(`${n}${o}`,16);r.push(i)}return Uint8Array.from(r)},toHex:e=>Array.from(e,(e=>e.toString(16).padStart(2,"0"))).join(""),toUTF8(e,t,r,n){const o=r-t<=20?q(e,t,r):null;return null!=o?o:J(e,t,r,n)},utf8ByteLength:e=>(new TextEncoder).encode(e).byteLength,encodeUTF8Into(e,t,r){const n=(new TextEncoder).encode(t);return e.set(n,r),n.byteLength},randomBytes:K},W="function"==typeof Buffer&&!0!==Buffer.prototype?._isBuffer?k:Z;class BSONValue{get[Symbol.for("@@mdb.bson.version")](){return f}[Symbol.for("nodejs.util.inspect.custom")](e,t,r){return this.inspect(e,t,r)}}class Binary extends BSONValue{get _bsontype(){return"Binary"}constructor(e,t){if(super(),null!=e&&"string"==typeof e&&!ArrayBuffer.isView(e)&&!n(e)&&!Array.isArray(e))throw new BSONError("Binary can only be constructed from Uint8Array or number[]");this.sub_type=t??Binary.BSON_BINARY_SUBTYPE_DEFAULT,null==e?(this.buffer=W.allocate(Binary.BUFFER_SIZE),this.position=0):(this.buffer=Array.isArray(e)?W.fromNumberArray(e):W.toLocalBufferType(e),this.position=this.buffer.byteLength)}put(e){if("string"==typeof e&&1!==e.length)throw new BSONError("only accepts single character String");if("number"!=typeof e&&1!==e.length)throw new BSONError("only accepts single character Uint8Array or Array");let t;if(t="string"==typeof e?e.charCodeAt(0):"number"==typeof e?e:e[0],t<0||t>255)throw new BSONError("only accepts number in a valid unsigned byte range 0-255");if(this.buffer.byteLength>this.position)this.buffer[this.position++]=t;else{const e=W.allocate(Binary.BUFFER_SIZE+this.buffer.length);e.set(this.buffer,0),this.buffer=e,this.buffer[this.position++]=t}}write(e,t){if(t="number"==typeof t?t:this.position,this.buffer.byteLength<t+e.length){const t=W.allocate(this.buffer.byteLength+e.length);t.set(this.buffer,0),this.buffer=t}if(ArrayBuffer.isView(e))this.buffer.set(W.toLocalBufferType(e),t),this.position=t+e.byteLength>this.position?t+e.length:this.position;else if("string"==typeof e)throw new BSONError("input cannot be string")}read(e,t){return t=t&&t>0?t:this.position,this.buffer.slice(e,e+t)}value(){return this.buffer.length===this.position?this.buffer:this.buffer.subarray(0,this.position)}length(){return this.position}toJSON(){return W.toBase64(this.buffer.subarray(0,this.position))}toString(e){return"hex"===e?W.toHex(this.buffer.subarray(0,this.position)):"base64"===e?W.toBase64(this.buffer.subarray(0,this.position)):W.toUTF8(this.buffer,0,this.position,!1)}toExtendedJSON(e){e=e||{};const t=W.toBase64(this.buffer),r=Number(this.sub_type).toString(16);return e.legacy?{$binary:t,$type:1===r.length?"0"+r:r}:{$binary:{base64:t,subType:1===r.length?"0"+r:r}}}toUUID(){if(this.sub_type===Binary.SUBTYPE_UUID)return new UUID(this.buffer.slice(0,this.position));throw new BSONError(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${Binary.SUBTYPE_UUID}" is currently supported.`)}static createFromHexString(e,t){return new Binary(W.fromHex(e),t)}static createFromBase64(e,t){return new Binary(W.fromBase64(e),t)}static fromExtendedJSON(e,t){let r,n;if(t=t||{},"$binary"in e?t.legacy&&"string"==typeof e.$binary&&"$type"in e?(n=e.$type?parseInt(e.$type,16):0,r=W.fromBase64(e.$binary)):"string"!=typeof e.$binary&&(n=e.$binary.subType?parseInt(e.$binary.subType,16):0,r=W.fromBase64(e.$binary.base64)):"$uuid"in e&&(n=4,r=UUID.bytesFromString(e.$uuid)),!r)throw new BSONError(`Unexpected Binary Extended JSON format ${JSON.stringify(e)}`);return n===z?new UUID(r):new Binary(r,n)}inspect(e,t,r){return r??=a,`Binary.createFromBase64(${r(W.toBase64(this.buffer.subarray(0,this.position)),t)}, ${r(this.sub_type,t)})`}}Binary.BSON_BINARY_SUBTYPE_DEFAULT=0,Binary.BUFFER_SIZE=256,Binary.SUBTYPE_DEFAULT=0,Binary.SUBTYPE_FUNCTION=1,Binary.SUBTYPE_BYTE_ARRAY=2,Binary.SUBTYPE_UUID_OLD=3,Binary.SUBTYPE_UUID=4,Binary.SUBTYPE_MD5=5,Binary.SUBTYPE_ENCRYPTED=6,Binary.SUBTYPE_COLUMN=7,Binary.SUBTYPE_SENSITIVE=8,Binary.SUBTYPE_USER_DEFINED=128;const G=/^[0-9A-F]{32}$/i,X=/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i;class UUID extends Binary{constructor(e){let t;if(null==e)t=UUID.generate();else if(e instanceof UUID)t=W.toLocalBufferType(new Uint8Array(e.buffer));else if(ArrayBuffer.isView(e)&&16===e.byteLength)t=W.toLocalBufferType(e);else{if("string"!=typeof e)throw new BSONError("Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");t=UUID.bytesFromString(e)}super(t,z)}get id(){return this.buffer}set id(e){this.buffer=e}toHexString(e=!0){return e?[W.toHex(this.buffer.subarray(0,4)),W.toHex(this.buffer.subarray(4,6)),W.toHex(this.buffer.subarray(6,8)),W.toHex(this.buffer.subarray(8,10)),W.toHex(this.buffer.subarray(10,16))].join("-"):W.toHex(this.buffer)}toString(e){return"hex"===e?W.toHex(this.id):"base64"===e?W.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}equals(e){if(!e)return!1;if(e instanceof UUID)return W.equals(e.id,this.id);try{return W.equals(new UUID(e).id,this.id)}catch{return!1}}toBinary(){return new Binary(this.id,Binary.SUBTYPE_UUID)}static generate(){const e=W.randomBytes(16);return e[6]=15&e[6]|64,e[8]=63&e[8]|128,e}static isValid(e){return!!e&&("string"==typeof e?UUID.isValidUUIDString(e):o(e)?16===e.byteLength:"Binary"===e._bsontype&&e.sub_type===this.SUBTYPE_UUID&&16===e.buffer.byteLength)}static createFromHexString(e){const t=UUID.bytesFromString(e);return new UUID(t)}static createFromBase64(e){return new UUID(W.fromBase64(e))}static bytesFromString(e){if(!UUID.isValidUUIDString(e))throw new BSONError("UUID string representation must be 32 hex digits or canonical hyphenated representation");return W.fromHex(e.replace(/-/g,""))}static isValidUUIDString(e){return G.test(e)||X.test(e)}inspect(e,t,r){return r??=a,`new UUID(${r(this.toHexString(),t)})`}}class Code extends BSONValue{get _bsontype(){return"Code"}constructor(e,t){super(),this.code=e.toString(),this.scope=t??null}toJSON(){return null!=this.scope?{code:this.code,scope:this.scope}:{code:this.code}}toExtendedJSON(){return this.scope?{$code:this.code,$scope:this.scope}:{$code:this.code}}static fromExtendedJSON(e){return new Code(e.$code,e.$scope)}inspect(e,t,r){r??=a;let n=r(this.code,t);const o=n.includes("\n");return null!=this.scope&&(n+=`,${o?"\n":" "}${r(this.scope,t)}`),`new Code(${o?"\n":""}${n}${o&&null===this.scope?"\n":""})`}}function Q(e){return null!=e&&"object"==typeof e&&"$id"in e&&null!=e.$id&&"$ref"in e&&"string"==typeof e.$ref&&(!("$db"in e)||"$db"in e&&"string"==typeof e.$db)}class DBRef extends BSONValue{get _bsontype(){return"DBRef"}constructor(e,t,r,n){super();const o=e.split(".");2===o.length&&(r=o.shift(),e=o.shift()),this.collection=e,this.oid=t,this.db=r,this.fields=n||{}}get namespace(){return this.collection}set namespace(e){this.collection=e}toJSON(){const e=Object.assign({$ref:this.collection,$id:this.oid},this.fields);return null!=this.db&&(e.$db=this.db),e}toExtendedJSON(e){e=e||{};let t={$ref:this.collection,$id:this.oid};return e.legacy||(this.db&&(t.$db=this.db),t=Object.assign(t,this.fields)),t}static fromExtendedJSON(e){const t=Object.assign({},e);return delete t.$ref,delete t.$id,delete t.$db,new DBRef(e.$ref,e.$id,e.$db,t)}inspect(e,t,r){r??=a;const n=[r(this.namespace,t),r(this.oid,t),...this.db?[r(this.db,t)]:[],...Object.keys(this.fields).length>0?[r(this.fields,t)]:[]];return n[1]=r===a?`new ObjectId(${n[1]})`:n[1],`new DBRef(${n.join(", ")})`}}function ee(e){if(""===e)return e;let t=0;const r="-"===e[t],n="+"===e[t];(n||r)&&(t+=1);let o=!1;for(;t<e.length&&"0"===e[t];++t)o=!0;return o?`${r?"-":""}${e.length===t?"0":e.slice(t)}`:n?e.slice(1):e}let te;try{te=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}const re=4294967296,ne=0x10000000000000000,oe=ne/2,ie={},se={},ue=/^(\+?0|(\+|-)?[1-9][0-9]*)$/;class Long extends BSONValue{get _bsontype(){return"Long"}get __isLong__(){return!0}constructor(e=0,t,r){super(),"bigint"==typeof e?Object.assign(this,Long.fromBigInt(e,!!t)):"string"==typeof e?Object.assign(this,Long.fromString(e,!!t)):(this.low=0|e,this.high=0|t,this.unsigned=!!r)}static fromBits(e,t,r){return new Long(e,t,r)}static fromInt(e,t){let r,n,o;return t?(o=0<=(e>>>=0)&&e<256)&&(n=se[e],n)?n:(r=Long.fromBits(e,(0|e)<0?-1:0,!0),o&&(se[e]=r),r):(o=-128<=(e|=0)&&e<128)&&(n=ie[e],n)?n:(r=Long.fromBits(e,e<0?-1:0,!1),o&&(ie[e]=r),r)}static fromNumber(e,t){if(isNaN(e))return t?Long.UZERO:Long.ZERO;if(t){if(e<0)return Long.UZERO;if(e>=ne)return Long.MAX_UNSIGNED_VALUE}else{if(e<=-oe)return Long.MIN_VALUE;if(e+1>=oe)return Long.MAX_VALUE}return e<0?Long.fromNumber(-e,t).neg():Long.fromBits(e%re|0,e/re|0,t)}static fromBigInt(e,t){return Long.fromString(e.toString(),t)}static _fromString(e,t,r){if(0===e.length)throw new BSONError("empty string");if(r<2||36<r)throw new BSONError("radix");let n;if((n=e.indexOf("-"))>0)throw new BSONError("interior hyphen");if(0===n)return Long._fromString(e.substring(1),t,r).neg();const o=Long.fromNumber(Math.pow(r,8));let i=Long.ZERO;for(let t=0;t<e.length;t+=8){const n=Math.min(8,e.length-t),s=parseInt(e.substring(t,t+n),r);if(n<8){const e=Long.fromNumber(Math.pow(r,n));i=i.mul(e).add(Long.fromNumber(s))}else i=i.mul(o),i=i.add(Long.fromNumber(s))}return i.unsigned=t,i}static fromStringStrict(e,t,r){let n=!1;if("number"==typeof t?(r=t,t=!1):n=!!t,r??=10,e.trim()!==e)throw new BSONError(`Input: '${e}' contains leading and/or trailing whitespace`);if(!function(e,t){t=t??10;const r="0123456789abcdefghijklmnopqrstuvwxyz".slice(0,t);return!new RegExp(`[^-+${r}]`,"i").test(e)&&e}(e,r))throw new BSONError(`Input: '${e}' contains invalid characters for radix: ${r}`);const o=ee(e),i=Long._fromString(o,n,r);if(i.toString(r).toLowerCase()!==o.toLowerCase())throw new BSONError(`Input: ${e} is not representable as ${i.unsigned?"an unsigned":"a signed"} 64-bit Long ${null!=r?`with radix: ${r}`:""}`);return i}static fromString(e,t,r){let n=!1;return"number"==typeof t?(r=t,t=!1):n=!!t,r??=10,"NaN"===e&&r<24||("Infinity"===e||"+Infinity"===e||"-Infinity"===e)&&r<35?Long.ZERO:Long._fromString(e,n,r)}static fromBytes(e,t,r){return r?Long.fromBytesLE(e,t):Long.fromBytesBE(e,t)}static fromBytesLE(e,t){return new Long(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)}static fromBytesBE(e,t){return new Long(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)}static isLong(e){return null!=e&&"object"==typeof e&&"__isLong__"in e&&!0===e.__isLong__}static fromValue(e,t){return"number"==typeof e?Long.fromNumber(e,t):"string"==typeof e?Long.fromString(e,t):Long.fromBits(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}add(e){Long.isLong(e)||(e=Long.fromValue(e));const t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,i=e.high>>>16,s=65535&e.high,u=e.low>>>16;let a=0,f=0,l=0,c=0;return c+=o+(65535&e.low),l+=c>>>16,c&=65535,l+=n+u,f+=l>>>16,l&=65535,f+=r+s,a+=f>>>16,f&=65535,a+=t+i,a&=65535,Long.fromBits(l<<16|c,a<<16|f,this.unsigned)}and(e){return Long.isLong(e)||(e=Long.fromValue(e)),Long.fromBits(this.low&e.low,this.high&e.high,this.unsigned)}compare(e){if(Long.isLong(e)||(e=Long.fromValue(e)),this.eq(e))return 0;const t=this.isNegative(),r=e.isNegative();return t&&!r?-1:!t&&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}comp(e){return this.compare(e)}divide(e){if(Long.isLong(e)||(e=Long.fromValue(e)),e.isZero())throw new BSONError("division by zero");if(te){if(!this.unsigned&&-2147483648===this.high&&-1===e.low&&-1===e.high)return this;const t=(this.unsigned?te.div_u:te.div_s)(this.low,this.high,e.low,e.high);return Long.fromBits(t,te.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?Long.UZERO:Long.ZERO;let t,r,n;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return Long.UZERO;if(e.gt(this.shru(1)))return Long.UONE;n=Long.UZERO}else{if(this.eq(Long.MIN_VALUE))return e.eq(Long.ONE)||e.eq(Long.NEG_ONE)?Long.MIN_VALUE:e.eq(Long.MIN_VALUE)?Long.ONE:(t=this.shr(1).div(e).shl(1),t.eq(Long.ZERO)?e.isNegative()?Long.ONE:Long.NEG_ONE:(r=this.sub(e.mul(t)),n=t.add(r.div(e)),n));if(e.eq(Long.MIN_VALUE))return this.unsigned?Long.UZERO:Long.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();n=Long.ZERO}for(r=this;r.gte(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));const o=Math.ceil(Math.log(t)/Math.LN2),i=o<=48?1:Math.pow(2,o-48);let s=Long.fromNumber(t),u=s.mul(e);for(;u.isNegative()||u.gt(r);)t-=i,s=Long.fromNumber(t,this.unsigned),u=s.mul(e);s.isZero()&&(s=Long.ONE),n=n.add(s),r=r.sub(u)}return n}div(e){return this.divide(e)}equals(e){return Long.isLong(e)||(e=Long.fromValue(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low}eq(e){return this.equals(e)}getHighBits(){return this.high}getHighBitsUnsigned(){return this.high>>>0}getLowBits(){return this.low}getLowBitsUnsigned(){return this.low>>>0}getNumBitsAbs(){if(this.isNegative())return this.eq(Long.MIN_VALUE)?64:this.neg().getNumBitsAbs();const e=0!==this.high?this.high:this.low;let t;for(t=31;t>0&&0==(e&1<<t);t--);return 0!==this.high?t+33:t+1}greaterThan(e){return this.comp(e)>0}gt(e){return this.greaterThan(e)}greaterThanOrEqual(e){return this.comp(e)>=0}gte(e){return this.greaterThanOrEqual(e)}ge(e){return this.greaterThanOrEqual(e)}isEven(){return 0==(1&this.low)}isNegative(){return!this.unsigned&&this.high<0}isOdd(){return 1==(1&this.low)}isPositive(){return this.unsigned||this.high>=0}isZero(){return 0===this.high&&0===this.low}lessThan(e){return this.comp(e)<0}lt(e){return this.lessThan(e)}lessThanOrEqual(e){return this.comp(e)<=0}lte(e){return this.lessThanOrEqual(e)}modulo(e){if(Long.isLong(e)||(e=Long.fromValue(e)),te){const t=(this.unsigned?te.rem_u:te.rem_s)(this.low,this.high,e.low,e.high);return Long.fromBits(t,te.get_high(),this.unsigned)}return this.sub(this.div(e).mul(e))}mod(e){return this.modulo(e)}rem(e){return this.modulo(e)}multiply(e){if(this.isZero())return Long.ZERO;if(Long.isLong(e)||(e=Long.fromValue(e)),te){const t=te.mul(this.low,this.high,e.low,e.high);return Long.fromBits(t,te.get_high(),this.unsigned)}if(e.isZero())return Long.ZERO;if(this.eq(Long.MIN_VALUE))return e.isOdd()?Long.MIN_VALUE:Long.ZERO;if(e.eq(Long.MIN_VALUE))return this.isOdd()?Long.MIN_VALUE:Long.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(Long.TWO_PWR_24)&&e.lt(Long.TWO_PWR_24))return Long.fromNumber(this.toNumber()*e.toNumber(),this.unsigned);const t=this.high>>>16,r=65535&this.high,n=this.low>>>16,o=65535&this.low,i=e.high>>>16,s=65535&e.high,u=e.low>>>16,a=65535&e.low;let f=0,l=0,c=0,g=0;return g+=o*a,c+=g>>>16,g&=65535,c+=n*a,l+=c>>>16,c&=65535,c+=o*u,l+=c>>>16,c&=65535,l+=r*a,f+=l>>>16,l&=65535,l+=n*u,f+=l>>>16,l&=65535,l+=o*s,f+=l>>>16,l&=65535,f+=t*a+r*u+n*s+o*i,f&=65535,Long.fromBits(c<<16|g,f<<16|l,this.unsigned)}mul(e){return this.multiply(e)}negate(){return!this.unsigned&&this.eq(Long.MIN_VALUE)?Long.MIN_VALUE:this.not().add(Long.ONE)}neg(){return this.negate()}not(){return Long.fromBits(~this.low,~this.high,this.unsigned)}notEquals(e){return!this.equals(e)}neq(e){return this.notEquals(e)}ne(e){return this.notEquals(e)}or(e){return Long.isLong(e)||(e=Long.fromValue(e)),Long.fromBits(this.low|e.low,this.high|e.high,this.unsigned)}shiftLeft(e){return Long.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Long.fromBits(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):Long.fromBits(0,this.low<<e-32,this.unsigned)}shl(e){return this.shiftLeft(e)}shiftRight(e){return Long.isLong(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Long.fromBits(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):Long.fromBits(this.high>>e-32,this.high>=0?0:-1,this.unsigned)}shr(e){return this.shiftRight(e)}shiftRightUnsigned(e){if(Long.isLong(e)&&(e=e.toInt()),0==(e&=63))return this;{const t=this.high;if(e<32){const r=this.low;return Long.fromBits(r>>>e|t<<32-e,t>>>e,this.unsigned)}return 32===e?Long.fromBits(t,0,this.unsigned):Long.fromBits(t>>>e-32,0,this.unsigned)}}shr_u(e){return this.shiftRightUnsigned(e)}shru(e){return this.shiftRightUnsigned(e)}subtract(e){return Long.isLong(e)||(e=Long.fromValue(e)),this.add(e.neg())}sub(e){return this.subtract(e)}toInt(){return this.unsigned?this.low>>>0:this.low}toNumber(){return this.unsigned?(this.high>>>0)*re+(this.low>>>0):this.high*re+(this.low>>>0)}toBigInt(){return BigInt(this.toString())}toBytes(e){return e?this.toBytesLE():this.toBytesBE()}toBytesLE(){const 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]}toBytesBE(){const 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]}toSigned(){return this.unsigned?Long.fromBits(this.low,this.high,!1):this}toString(e){if((e=e||10)<2||36<e)throw new BSONError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(Long.MIN_VALUE)){const t=Long.fromNumber(e),r=this.div(t),n=r.mul(t).sub(this);return r.toString(e)+n.toInt().toString(e)}return"-"+this.neg().toString(e)}const t=Long.fromNumber(Math.pow(e,6),this.unsigned);let r=this,n="";for(;;){const o=r.div(t);let i=(r.sub(o.mul(t)).toInt()>>>0).toString(e);if(r=o,r.isZero())return i+n;for(;i.length<6;)i="0"+i;n=""+i+n}}toUnsigned(){return this.unsigned?this:Long.fromBits(this.low,this.high,!0)}xor(e){return Long.isLong(e)||(e=Long.fromValue(e)),Long.fromBits(this.low^e.low,this.high^e.high,this.unsigned)}eqz(){return this.isZero()}le(e){return this.lessThanOrEqual(e)}toExtendedJSON(e){return e&&e.relaxed?this.toNumber():{$numberLong:this.toString()}}static fromExtendedJSON(e,t){const{useBigInt64:r=!1,relaxed:n=!0}={...t};if(e.$numberLong.length>20)throw new BSONError("$numberLong string is too long");if(!ue.test(e.$numberLong))throw new BSONError(`$numberLong string "${e.$numberLong}" is in an invalid format`);if(r){const t=BigInt(e.$numberLong);return BigInt.asIntN(64,t)}const o=Long.fromString(e.$numberLong);return n?o.toNumber():o}inspect(e,t,r){return r??=a,`new Long(${r(this.toString(),t)}${this.unsigned?`, ${r(this.unsigned,t)}`:""})`}}Long.TWO_PWR_24=Long.fromInt(1<<24),Long.MAX_UNSIGNED_VALUE=Long.fromBits(-1,-1,!0),Long.ZERO=Long.fromInt(0),Long.UZERO=Long.fromInt(0,!0),Long.ONE=Long.fromInt(1),Long.UONE=Long.fromInt(1,!0),Long.NEG_ONE=Long.fromInt(-1),Long.MAX_VALUE=Long.fromBits(-1,2147483647,!1),Long.MIN_VALUE=Long.fromBits(0,-2147483648,!1);const ae=/^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/,fe=/^(\+|-)?(Infinity|inf)$/i,le=/^(\+|-)?NaN$/i,ce=6111,ge=-6176,he=W.fromNumberArray([124,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),pe=W.fromNumberArray([248,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),de=W.fromNumberArray([120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0].reverse()),be=/^([-+])?(\d+)?$/;function ye(e){return!isNaN(parseInt(e,10))}function me(e){const t=Long.fromNumber(1e9);let r=Long.fromNumber(0);if(!(e.parts[0]||e.parts[1]||e.parts[2]||e.parts[3]))return{quotient:e,rem:r};for(let n=0;n<=3;n++)r=r.shiftLeft(32),r=r.add(new Long(e.parts[n],0)),e.parts[n]=r.div(t).low,r=r.modulo(t);return{quotient:e,rem:r}}function we(e,t){throw new BSONError(`"${e}" is not a valid Decimal128 string - ${t}`)}class Decimal128 extends BSONValue{get _bsontype(){return"Decimal128"}constructor(e){if(super(),"string"==typeof e)this.bytes=Decimal128.fromString(e).bytes;else{if(!o(e))throw new BSONError("Decimal128 must take a Buffer or string");if(16!==e.byteLength)throw new BSONError("Decimal128 must take a Buffer of 16 bytes");this.bytes=e}}static fromString(e){return Decimal128._fromString(e,{allowRounding:!1})}static fromStringWithRounding(e){return Decimal128._fromString(e,{allowRounding:!0})}static _fromString(e,t){let r=!1,n=!1,o=!1,i=!1,s=0,u=0,a=0,f=0,l=0;const c=[0];let g=0,h=0,p=0,d=0,b=new Long(0,0),y=new Long(0,0),m=0,w=0;if(e.length>=7e3)throw new BSONError(e+" not a valid Decimal128 string");const B=e.match(ae),S=e.match(fe),O=e.match(le);if(!B&&!S&&!O||0===e.length)throw new BSONError(e+" not a valid Decimal128 string");if(B){const t=B[2],r=B[4],n=B[5],o=B[6];r&&void 0===o&&we(e,"missing exponent power"),r&&void 0===t&&we(e,"missing exponent base"),void 0===r&&(n||o)&&we(e,"missing e before exponent")}if("+"!==e[w]&&"-"!==e[w]||(n=!0,r="-"===e[w++]),!ye(e[w])&&"."!==e[w]){if("i"===e[w]||"I"===e[w])return new Decimal128(r?pe:de);if("N"===e[w])return new Decimal128(he)}for(;ye(e[w])||"."===e[w];)"."!==e[w]?(g<34&&("0"!==e[w]||i)&&(i||(l=u),i=!0,c[h++]=parseInt(e[w],10),g+=1),i&&(a+=1),o&&(f+=1),u+=1,w+=1):(o&&we(e,"contains multiple periods"),o=!0,w+=1);if(o&&!u)throw new BSONError(e+" not a valid Decimal128 string");if("e"===e[w]||"E"===e[w]){const t=e.substr(++w).match(be);if(!t||!t[2])return new Decimal128(he);d=parseInt(t[0],10),w+=t[0].length}if(e[w])return new Decimal128(he);if(g){if(p=g-1,s=a,1!==s)for(;"0"===e[l+s-1+Number(n)+Number(o)];)s-=1}else c[0]=0,a=1,g=1,s=0;for(d<=f&&f>d+16384?d=ge:d-=f;d>ce;){if(p+=1,p>=34){if(0===s){d=ce;break}we(e,"overflow")}d-=1}if(t.allowRounding){for(;d<ge||g<a;){if(0===p&&s<g){d=ge,s=0;break}if(g<a?a-=1:p-=1,d<ce)d+=1;else{if(c.join("").match(/^0+$/)){d=ce;break}we(e,"overflow")}}if(p+1<s){let t=u;o&&(l+=1,t+=1),n&&(l+=1,t+=1);const i=parseInt(e[l+p+1],10);let s=0;if(i>=5&&(s=1,5===i)){s=c[p]%2==1?1:0;for(let r=l+p+2;r<t;r++)if(parseInt(e[r],10)){s=1;break}}if(s){let e=p;for(;e>=0&&++c[e]>9;e--)if(c[e]=0,0===e){if(!(d<ce))return new Decimal128(r?pe:de);d+=1,c[e]=1}}}}else{for(;d<ge||g<a;){if(0===p){if(0===s){d=ge;break}we(e,"exponent underflow")}g<a?("0"!==e[a-1+Number(n)+Number(o)]&&0!==s&&we(e,"inexact rounding"),a-=1):(0!==c[p]&&we(e,"inexact rounding"),p-=1),d<ce?d+=1:we(e,"overflow")}p+1<s&&(o&&(l+=1),n&&(l+=1),0!==parseInt(e[l+p+1],10)&&we(e,"inexact rounding"))}if(b=Long.fromNumber(0),y=Long.fromNumber(0),0===s)b=Long.fromNumber(0),y=Long.fromNumber(0);else if(p<17){let e=0;for(y=Long.fromNumber(c[e++]),b=new Long(0,0);e<=p;e++)y=y.multiply(Long.fromNumber(10)),y=y.add(Long.fromNumber(c[e]))}else{let e=0;for(b=Long.fromNumber(c[e++]);e<=p-17;e++)b=b.multiply(Long.fromNumber(10)),b=b.add(Long.fromNumber(c[e]));for(y=Long.fromNumber(c[e++]);e<=p;e++)y=y.multiply(Long.fromNumber(10)),y=y.add(Long.fromNumber(c[e]))}const N=function(e,t){if(!e&&!t)return{high:Long.fromNumber(0),low:Long.fromNumber(0)};const r=e.shiftRightUnsigned(32),n=new Long(e.getLowBits(),0),o=t.shiftRightUnsigned(32),i=new Long(t.getLowBits(),0);let s=r.multiply(o),u=r.multiply(i);const a=n.multiply(o);let f=n.multiply(i);return s=s.add(u.shiftRightUnsigned(32)),u=new Long(u.getLowBits(),0).add(a).add(f.shiftRightUnsigned(32)),s=s.add(u.shiftRightUnsigned(32)),f=u.shiftLeft(32).add(new Long(f.getLowBits(),0)),{high:s,low:f}}(b,Long.fromString("100000000000000000"));N.low=N.low.add(y),function(e,t){const r=e.high>>>0,n=t.high>>>0;return r<n||r===n&&e.low>>>0<t.low>>>0}(N.low,y)&&(N.high=N.high.add(Long.fromNumber(1))),m=d+6176;const E={low:Long.fromNumber(0),high:Long.fromNumber(0)};N.high.shiftRightUnsigned(49).and(Long.fromNumber(1)).equals(Long.fromNumber(1))?(E.high=E.high.or(Long.fromNumber(3).shiftLeft(61)),E.high=E.high.or(Long.fromNumber(m).and(Long.fromNumber(16383).shiftLeft(47))),E.high=E.high.or(N.high.and(Long.fromNumber(0x7fffffffffff)))):(E.high=E.high.or(Long.fromNumber(16383&m).shiftLeft(49)),E.high=E.high.or(N.high.and(Long.fromNumber(562949953421311)))),E.low=N.low,r&&(E.high=E.high.or(Long.fromString("9223372036854775808")));const L=W.allocateUnsafe(16);return w=0,L[w++]=255&E.low.low,L[w++]=E.low.low>>8&255,L[w++]=E.low.low>>16&255,L[w++]=E.low.low>>24&255,L[w++]=255&E.low.high,L[w++]=E.low.high>>8&255,L[w++]=E.low.high>>16&255,L[w++]=E.low.high>>24&255,L[w++]=255&E.high.low,L[w++]=E.high.low>>8&255,L[w++]=E.high.low>>16&255,L[w++]=E.high.low>>24&255,L[w++]=255&E.high.high,L[w++]=E.high.high>>8&255,L[w++]=E.high.high>>16&255,L[w++]=E.high.high>>24&255,new Decimal128(L)}toString(){let e,t=0;const r=new Array(36);for(let e=0;e<r.length;e++)r[e]=0;let n,o,i,s=0,u=!1,a={parts:[0,0,0,0]};const f=[];s=0;const l=this.bytes,c=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,g=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,h=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24,p=l[s++]|l[s++]<<8|l[s++]<<16|l[s++]<<24;s=0,(new Long(c,g),new Long(h,p)).lessThan(Long.ZERO)&&f.push("-");const d=p>>26&31;if(d>>3==3){if(30===d)return f.join("")+"Infinity";if(31===d)return"NaN";e=p>>15&16383,n=8+(p>>14&1)}else n=p>>14&7,e=p>>17&16383;const b=e-6176;if(a.parts[0]=(16383&p)+((15&n)<<14),a.parts[1]=h,a.parts[2]=g,a.parts[3]=c,0===a.parts[0]&&0===a.parts[1]&&0===a.parts[2]&&0===a.parts[3])u=!0;else for(i=3;i>=0;i--){let e=0;const t=me(a);if(a=t.quotient,e=t.rem.low,e)for(o=8;o>=0;o--)r[9*i+o]=e%10,e=Math.floor(e/10)}if(u)t=1,r[s]=0;else for(t=36;!r[s];)t-=1,s+=1;const y=t-1+b;if(y>=34||y<=-7||b>0){if(t>34)return f.push("0"),b>0?f.push(`E+${b}`):b<0&&f.push(`E${b}`),f.join("");f.push(`${r[s++]}`),t-=1,t&&f.push(".");for(let e=0;e<t;e++)f.push(`${r[s++]}`);f.push("E"),y>0?f.push(`+${y}`):f.push(`${y}`)}else if(b>=0)for(let e=0;e<t;e++)f.push(`${r[s++]}`);else{let e=t+b;if(e>0)for(let t=0;t<e;t++)f.push(`${r[s++]}`);else f.push("0");for(f.push(".");e++<0;)f.push("0");for(let n=0;n<t-Math.max(e-1,0);n++)f.push(`${r[s++]}`)}return f.join("")}toJSON(){return{$numberDecimal:this.toString()}}toExtendedJSON(){return{$numberDecimal:this.toString()}}static fromExtendedJSON(e){return Decimal128.fromString(e.$numberDecimal)}inspect(e,t,r){return r??=a,`new Decimal128(${r(this.toString(),t)})`}}class Double extends BSONValue{get _bsontype(){return"Double"}constructor(e){super(),e instanceof Number&&(e=e.valueOf()),this.value=+e}static fromString(e){const t=Number(e);if("NaN"===e)return new Double(NaN);if("Infinity"===e)return new Double(1/0);if("-Infinity"===e)return new Double(-1/0);if(!Number.isFinite(t))throw new BSONError(`Input: ${e} is not representable as a Double`);if(e.trim()!==e)throw new BSONError(`Input: '${e}' contains whitespace`);if(""===e)throw new BSONError("Input is an empty string");if(/[^-0-9.+eE]/.test(e))throw new BSONError(`Input: '${e}' is not in decimal or exponential notation`);return new Double(t)}valueOf(){return this.value}toJSON(){return this.value}toString(e){return this.value.toString(e)}toExtendedJSON(e){return e&&(e.legacy||e.relaxed&&isFinite(this.value))?this.value:Object.is(Math.sign(this.value),-0)?{$numberDouble:"-0.0"}:{$numberDouble:Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}}static fromExtendedJSON(e,t){const r=parseFloat(e.$numberDouble);return t&&t.relaxed?r:new Double(r)}inspect(e,t,r){return r??=a,`new Double(${r(this.value,t)})`}}class Int32 extends BSONValue{get _bsontype(){return"Int32"}constructor(e){super(),e instanceof Number&&(e=e.valueOf()),this.value=0|+e}static fromString(e){const t=ee(e),r=Number(e);if(l<r)throw new BSONError(`Input: '${e}' is larger than the maximum value for Int32`);if(c>r)throw new BSONError(`Input: '${e}' is smaller than the minimum value for Int32`);if(!Number.isSafeInteger(r))throw new BSONError(`Input: '${e}' is not a safe integer`);if(r.toString()!==t)throw new BSONError(`Input: '${e}' is not a valid Int32 string`);return new Int32(r)}valueOf(){return this.value}toString(e){return this.value.toString(e)}toJSON(){return this.value}toExtendedJSON(e){return e&&(e.relaxed||e.legacy)?this.value:{$numberInt:this.value.toString()}}static fromExtendedJSON(e,t){return t&&t.relaxed?parseInt(e.$numberInt,10):new Int32(e.$numberInt)}inspect(e,t,r){return r??=a,`new Int32(${r(this.value,t)})`}}class MaxKey extends BSONValue{get _bsontype(){return"MaxKey"}toExtendedJSON(){return{$maxKey:1}}static fromExtendedJSON(){return new MaxKey}inspect(){return"new MaxKey()"}}class MinKey extends BSONValue{get _bsontype(){return"MinKey"}toExtendedJSON(){return{$minKey:1}}static fromExtendedJSON(){return new MinKey}inspect(){return"new MinKey()"}}const Be=new Float64Array(1),Se=new Uint8Array(Be.buffer,0,8);Be[0]=-1;const Oe=0===Se[7],Ne={getNonnegativeInt32LE(e,t){if(e[t+3]>127)throw new RangeError(`Size cannot be negative at offset: ${t}`);return e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24},getInt32LE:(e,t)=>e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,getUint32LE:(e,t)=>e[t]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3],getUint32BE:(e,t)=>e[t+3]+256*e[t+2]+65536*e[t+1]+16777216*e[t],getBigInt64LE(e,t){const r=Ne.getUint32LE(e,t),n=Ne.getUint32LE(e,t+4);return(BigInt(n)<<BigInt(32))+BigInt(r)},getFloat64LE:Oe?(e,t)=>(Se[7]=e[t],Se[6]=e[t+1],Se[5]=e[t+2],Se[4]=e[t+3],Se[3]=e[t+4],Se[2]=e[t+5],Se[1]=e[t+6],Se[0]=e[t+7],Be[0]):(e,t)=>(Se[0]=e[t],Se[1]=e[t+1],Se[2]=e[t+2],Se[3]=e[t+3],Se[4]=e[t+4],Se[5]=e[t+5],Se[6]=e[t+6],Se[7]=e[t+7],Be[0]),setInt32BE:(e,t,r)=>(e[t+3]=r,r>>>=8,e[t+2]=r,r>>>=8,e[t+1]=r,r>>>=8,e[t]=r,4),setInt32LE:(e,t,r)=>(e[t]=r,r>>>=8,e[t+1]=r,r>>>=8,e[t+2]=r,r>>>=8,e[t+3]=r,4),setBigInt64LE(e,t,r){const n=BigInt(4294967295);let o=Number(r&n);e[t]=o,o>>=8,e[t+1]=o,o>>=8,e[t+2]=o,o>>=8,e[t+3]=o;let i=Number(r>>BigInt(32)&n);return e[t+4]=i,i>>=8,e[t+5]=i,i>>=8,e[t+6]=i,i>>=8,e[t+7]=i,8},setFloat64LE:Oe?(e,t,r)=>(Be[0]=r,e[t]=Se[7],e[t+1]=Se[6],e[t+2]=Se[5],e[t+3]=Se[4],e[t+4]=Se[3],e[t+5]=Se[2],e[t+6]=Se[1],e[t+7]=Se[0],8):(e,t,r)=>(Be[0]=r,e[t]=Se[0],e[t+1]=Se[1],e[t+2]=Se[2],e[t+3]=Se[3],e[t+4]=Se[4],e[t+5]=Se[5],e[t+6]=Se[6],e[t+7]=Se[7],8)},Ee=new RegExp("^[0-9a-fA-F]{24}$");let Le=null;class ObjectId extends BSONValue{get _bsontype(){return"ObjectId"}constructor(e){let t;if(super(),"object"==typeof e&&e&&"id"in e){if("string"!=typeof e.id&&!ArrayBuffer.isView(e.id))throw new BSONError("Argument passed in must have an id that is of type string or Buffer");t="toHexString"in e&&"function"==typeof e.toHexString?W.fromHex(e.toHexString()):e.id}else t=e;if(null==t||"number"==typeof t)this.buffer=ObjectId.generate("number"==typeof t?t:void 0);else if(ArrayBuffer.isView(t)&&12===t.byteLength)this.buffer=W.toLocalBufferType(t);else{if("string"!=typeof t)throw new BSONError("Argument passed in does not match the accepted types");if(24!==t.length||!Ee.test(t))throw new BSONError("input must be a 24 character hex string, 12 byte Uint8Array, or an integer");this.buffer=W.fromHex(t)}ObjectId.cacheHexString&&(this.__id=W.toHex(this.id))}get id(){return this.buffer}set id(e){this.buffer=e,ObjectId.cacheHexString&&(this.__id=W.toHex(e))}toHexString(){if(ObjectId.cacheHexString&&this.__id)return this.__id;const e=W.toHex(this.id);return ObjectId.cacheHexString&&!this.__id&&(this.__id=e),e}static getInc(){return ObjectId.index=(ObjectId.index+1)%16777215}static generate(e){"number"!=typeof e&&(e=Math.floor(Date.now()/1e3));const t=ObjectId.getInc(),r=W.allocateUnsafe(12);return Ne.setInt32BE(r,0,e),null===Le&&(Le=W.randomBytes(5)),r[4]=Le[0],r[5]=Le[1],r[6]=Le[2],r[7]=Le[3],r[8]=Le[4],r[11]=255&t,r[10]=t>>8&255,r[9]=t>>16&255,r}toString(e){return"base64"===e?W.toBase64(this.id):this.toHexString()}toJSON(){return this.toHexString()}static is(e){return null!=e&&"object"==typeof e&&"_bsontype"in e&&"ObjectId"===e._bsontype}equals(e){if(null==e)return!1;if(ObjectId.is(e))return this.buffer[11]===e.buffer[11]&&W.equals(this.buffer,e.buffer);if("string"==typeof e)return e.toLowerCase()===this.toHexString();if("object"==typeof e&&"function"==typeof e.toHexString){const t=e.toHexString(),r=this.toHexString();return"string"==typeof t&&t.toLowerCase()===r}return!1}getTimestamp(){const e=new Date,t=Ne.getUint32BE(this.buffer,0);return e.setTime(1e3*Math.floor(t)),e}static createPk(){return new ObjectId}serializeInto(e,t){return e[t]=this.buffer[0],e[t+1]=this.buffer[1],e[t+2]=this.buffer[2],e[t+3]=this.buffer[3],e[t+4]=this.buffer[4],e[t+5]=this.buffer[5],e[t+6]=this.buffer[6],e[t+7]=this.buffer[7],e[t+8]=this.buffer[8],e[t+9]=this.buffer[9],e[t+10]=this.buffer[10],e[t+11]=this.buffer[11],12}static createFromTime(e){const t=W.allocate(12);for(let e=11;e>=4;e--)t[e]=0;return Ne.setInt32BE(t,0,e),new ObjectId(t)}static createFromHexString(e){if(24!==e?.length)throw new BSONError("hex string must be 24 characters");return new ObjectId(W.fromHex(e))}static createFromBase64(e){if(16!==e?.length)throw new BSONError("base64 string must be 16 characters");return new ObjectId(W.fromBase64(e))}static isValid(e){if(null==e)return!1;try{return new ObjectId(e),!0}catch{return!1}}toExtendedJSON(){return this.toHexString?{$oid:this.toHexString()}:{$oid:this.toString("hex")}}static fromExtendedJSON(e){return new ObjectId(e.$oid)}inspect(e,t,r){return r??=a,`new ObjectId(${r(this.toHexString(),t)})`}}function xe(e,t,r){let n=5;if(Array.isArray(e))for(let o=0;o<e.length;o++)n+=Ie(o.toString(),e[o],t,!0,r);else{"function"==typeof e?.toBSON&&(e=e.toBSON());for(const o of Object.keys(e))n+=Ie(o,e[o],t,!1,r)}return n}function Ie(e,t,r=!1,o=!1,s=!1){switch("function"==typeof t?.toBSON&&(t=t.toBSON()),typeof t){case"string":return 1+W.utf8ByteLength(e)+1+4+W.utf8ByteLength(t)+1;case"number":return Math.floor(t)===t&&t>=d&&t<=p&&t>=c&&t<=l?(null!=e?W.utf8ByteLength(e)+1:0)+5:(null!=e?W.utf8ByteLength(e)+1:0)+9;case"undefined":return o||!s?(null!=e?W.utf8ByteLength(e)+1:0)+1:0;case"boolean":return(null!=e?W.utf8ByteLength(e)+1:0)+2;case"object":if(null!=t&&"string"==typeof t._bsontype&&t[Symbol.for("@@mdb.bson.version")]!==f)throw new BSONVersionError;if(null==t||"MinKey"===t._bsontype||"MaxKey"===t._bsontype)return(null!=e?W.utf8ByteLength(e)+1:0)+1;if("ObjectId"===t._bsontype)return(null!=e?W.utf8ByteLength(e)+1:0)+13;if(t instanceof Date||u(t))return(null!=e?W.utf8ByteLength(e)+1:0)+9;if(ArrayBuffer.isView(t)||t instanceof ArrayBuffer||n(t))return(null!=e?W.utf8ByteLength(e)+1:0)+6+t.byteLength;if("Long"===t._bsontype||"Double"===t._bsontype||"Timestamp"===t._bsontype)return(null!=e?W.utf8ByteLength(e)+1:0)+9;if("Decimal128"===t._bsontype)return(null!=e?W.utf8ByteLength(e)+1:0)+17;if("Code"===t._bsontype)return null!=t.scope&&Object.keys(t.scope).length>0?(null!=e?W.utf8ByteLength(e)+1:0)+1+4+4+W.utf8ByteLength(t.code.toString())+1+xe(t.scope,r,s):(null!=e?W.utf8ByteLength(e)+1:0)+1+4+W.utf8ByteLength(t.code.toString())+1;if("Binary"===t._bsontype){const r=t;return r.sub_type===Binary.SUBTYPE_BYTE_ARRAY?(null!=e?W.utf8ByteLength(e)+1:0)+(r.position+1+4+1+4):(null!=e?W.utf8ByteLength(e)+1:0)+(r.position+1+4+1)}if("Symbol"===t._bsontype)return(null!=e?W.utf8ByteLength(e)+1:0)+W.utf8ByteLength(t.value)+4+1+1;if("DBRef"===t._bsontype){const n=Object.assign({$ref:t.collection,$id:t.oid},t.fields);return null!=t.db&&(n.$db=t.db),(null!=e?W.utf8ByteLength(e)+1:0)+1+xe(n,r,s)}return t instanceof RegExp||i(t)?(null!=e?W.utf8ByteLength(e)+1:0)+1+W.utf8ByteLength(t.source)+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1:"BSONRegExp"===t._bsontype?(null!=e?W.utf8ByteLength(e)+1:0)+1+W.utf8ByteLength(t.pattern)+1+W.utf8ByteLength(t.options)+1:(null!=e?W.utf8ByteLength(e)+1:0)+xe(t,r,s)+1;case"function":if(r)return(null!=e?W.utf8ByteLength(e)+1:0)+1+4+W.utf8ByteLength(t.toString())+1}return 0}ObjectId.index=Math.floor(16777215*Math.random());class BSONRegExp extends BSONValue{get _bsontype(){return"BSONRegExp"}constructor(e,t){if(super(),this.pattern=e,this.options=(t??"").split("").sort().join(""),-1!==this.pattern.indexOf("\0"))throw new BSONError(`BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}`);if(-1!==this.options.indexOf("\0"))throw new BSONError(`BSON Regex options cannot contain null bytes, found: ${JSON.stringify(this.options)}`);for(let e=0;e<this.options.length;e++)if("i"!==this.options[e]&&"m"!==this.options[e]&&"x"!==this.options[e]&&"l"!==this.options[e]&&"s"!==this.options[e]&&"u"!==this.options[e])throw new BSONError(`The regular expression option [${this.options[e]}] is not supported`)}static parseOptions(e){return e?e.split("").sort().join(""):""}toExtendedJSON(e){return(e=e||{}).legacy?{$regex:this.pattern,$options:this.options}:{$regularExpression:{pattern:this.pattern,options:this.options}}}static fromExtendedJSON(e){if("$regex"in e){if("string"==typeof e.$regex)return new BSONRegExp(e.$regex,BSONRegExp.parseOptions(e.$options));if("BSONRegExp"===e.$regex._bsontype)return e}if("$regularExpression"in e)return new BSONRegExp(e.$regularExpression.pattern,BSONRegExp.parseOptions(e.$regularExpression.options));throw new BSONError(`Unexpected BSONRegExp EJSON object form: ${JSON.stringify(e)}`)}inspect(e,t,r){const n=function(e){if(null!=e&&"object"==typeof e&&"stylize"in e&&"function"==typeof e.stylize)return e.stylize}(t)??(e=>e);return r??=a,`new BSONRegExp(${n(r(this.pattern),"regexp")}, ${n(r(this.options),"regexp")})`}}class BSONSymbol extends BSONValue{get _bsontype(){return"BSONSymbol"}constructor(e){super(),this.value=e}valueOf(){return this.value}toString(){return this.value}toJSON(){return this.value}toExtendedJSON(){return{$symbol:this.value}}static fromExtendedJSON(e){return new BSONSymbol(e.$symbol)}inspect(e,t,r){return r??=a,`new BSONSymbol(${r(this.value,t)})`}}const _e=Long;class Timestamp extends _e{get _bsontype(){return"Timestamp"}constructor(e){if(null==e)super(0,0,!0);else if("bigint"==typeof e)super(e,!0);else if(Long.isLong(e))super(e.low,e.high,!0);else{if("object"!=typeof e||!("t"in e)||!("i"in e))throw new BSONError("A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }");{if("number"!=typeof e.t&&("object"!=typeof e.t||"Int32"!==e.t._bsontype))throw new BSONError("Timestamp constructed from { t, i } must provide t as a number");if("number"!=typeof e.i&&("object"!=typeof e.i||"Int32"!==e.i._bsontype))throw new BSONError("Timestamp constructed from { t, i } must provide i as a number");const t=Number(e.t),r=Number(e.i);if(t<0||Number.isNaN(t))throw new BSONError("Timestamp constructed from { t, i } must provide a positive t");if(r<0||Number.isNaN(r))throw new BSONError("Timestamp constructed from { t, i } must provide a positive i");if(t>4294967295)throw new BSONError("Timestamp constructed from { t, i } must provide t equal or less than uint32 max");if(r>4294967295)throw new BSONError("Timestamp constructed from { t, i } must provide i equal or less than uint32 max");super(r,t,!0)}}}toJSON(){return{$timestamp:this.toString()}}static fromInt(e){return new Timestamp(Long.fromInt(e,!0))}static fromNumber(e){return new Timestamp(Long.fromNumber(e,!0))}static fromBits(e,t){return new Timestamp({i:e,t})}static fromString(e,t){return new Timestamp(Long.fromString(e,!0,t))}toExtendedJSON(){return{$timestamp:{t:this.high>>>0,i:this.low>>>0}}}static fromExtendedJSON(e){const t=Long.isLong(e.$timestamp.i)?e.$timestamp.i.getLowBitsUnsigned():e.$timestamp.i,r=Long.isLong(e.$timestamp.t)?e.$timestamp.t.getLowBitsUnsigned():e.$timestamp.t;return new Timestamp({t:r,i:t})}inspect(e,t,r){return r??=a,`new Timestamp({ t: ${r(this.high>>>0,t)}, i: ${r(this.low>>>0,t)} })`}}Timestamp.MAX_VALUE=Long.MAX_UNSIGNED_VALUE;const ve=Long.fromNumber(p),Ue=Long.fromNumber(d);function $e(e,t,r){const n=(t=null==t?{}:t)&&t.index?t.index:0,o=Ne.getInt32LE(e,n);if(o<5)throw new BSONError(`bson size must be >= 5, is ${o}`);if(t.allowObjectSmallerThanBufferSize&&e.length<o)throw new BSONError(`buffer length ${e.length} must be >= bson size ${o}`);if(!t.allowObjectSmallerThanBufferSize&&e.length!==o)throw new BSONError(`buffer length ${e.length} must === bson size ${o}`);if(o+n>e.byteLength)throw new BSONError(`(bson size ${o} + options.index ${n} must be <= buffer length ${e.byteLength})`);if(0!==e[n+o-1])throw new BSONError("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return je(e,n,t,r)}const Te=/^\$ref$|^\$id$|^\$db$/;function je(e,t,r,n=!1){const o=null==r.fieldsAsRaw?null:r.fieldsAsRaw,i=null!=r.raw&&r.raw,s="boolean"==typeof r.bsonRegExp&&r.bsonRegExp,u=r.promoteBuffers??!1,a=r.promoteLongs??!0,f=r.promoteValues??!0,l=r.useBigInt64??!1;if(l&&!f)throw new BSONError("Must either request bigint or Long for int64 deserialization");if(l&&!a)throw new BSONError("Must either request bigint or Long for int64 deserialization");let c,g,h=!0;const p=(null==r.validation?{utf8:!0}:r.validation).utf8;if("boolean"==typeof p)c=p;else{h=!1;const e=Object.keys(p).map((function(e){return p[e]}));if(0===e.length)throw new BSONError("UTF-8 validation setting cannot be empty");if("boolean"!=typeof e[0])throw new BSONError("Invalid UTF-8 validation option, must specify boolean values");if(c=e[0],!e.every((e=>e===c)))throw new BSONError("Invalid UTF-8 validation option - keys must be all true or all false")}if(!h){g=new Set;for(const e of Object.keys(p))g.add(e)}const d=t;if(e.length<5)throw new BSONError("corrupt bson message < 5 bytes long");const M=Ne.getInt32LE(e,t);if(t+=4,M<5||M>e.length)throw new BSONError("corrupt bson message");const F=n?[]:{};let V=0,C=!n&&null;for(;;){const p=e[t++];if(0===p)break;let d=t;for(;0!==e[d]&&d<e.length;)d++;if(d>=e.byteLength)throw new BSONError("Bad BSON Document: illegal CString");const M=n?V++:W.toUTF8(e,t,d,!1);let J,q=!0;if(q=h||g?.has(M)?c:!c,!1!==C&&"$"===M[0]&&(C=Te.test(M)),t=d+1,p===y){const r=Ne.getInt32LE(e,t);if(t+=4,r<=0||r>e.length-t||0!==e[t+r-1])throw new BSONError("bad string length in bson");J=W.toUTF8(e,t,t+r-1,q),t+=r}else if(p===O){const r=W.allocateUnsafe(12);for(let n=0;n<12;n++)r[n]=e[t+n];J=new ObjectId(r),t+=12}else if(p===$&&!1===f)J=new Int32(Ne.getInt32LE(e,t)),t+=4;else if(p===$)J=Ne.getInt32LE(e,t),t+=4;else if(p===b)J=Ne.getFloat64LE(e,t),t+=8,!1===f&&(J=new Double(J));else if(p===E){const r=Ne.getInt32LE(e,t),n=Ne.getInt32LE(e,t+4);t+=8,J=new Date(new Long(r,n).toNumber())}else if(p===N){if(0!==e[t]&&1!==e[t])throw new BSONError("illegal boolean type value");J=1===e[t++]}else if(p===m){const n=t,o=Ne.getInt32LE(e,t);if(o<=0||o>e.length-t)throw new BSONError("bad embedded document length in bson");if(i)J=e.slice(t,t+o);else{let t=r;h||(t={...r,validation:{utf8:q}}),J=je(e,n,t,!1)}t+=o}else if(p===w){const n=t,i=Ne.getInt32LE(e,t);let s=r;const u=t+i;if(o&&o[M]&&(s={...r,raw:!0}),h||(s={...s,validation:{utf8:q}}),J=je(e,n,s,!0),0!==e[(t+=i)-1])throw new BSONError("invalid array terminator byte");if(t!==u)throw new BSONError("corrupted array bson")}else if(p===S)J=void 0;else if(p===L)J=null;else if(p===j)if(l)J=Ne.getBigInt64LE(e,t),t+=8;else{const r=Ne.getInt32LE(e,t),n=Ne.getInt32LE(e,t+4);t+=8;const o=new Long(r,n);J=a&&!0===f&&o.lessThanOrEqual(ve)&&o.greaterThanOrEqual(Ue)?o.toNumber():o}else if(p===D){const r=W.allocateUnsafe(16);for(let n=0;n<16;n++)r[n]=e[t+n];t+=16,J=new Decimal128(r)}else if(p===B){let r=Ne.getInt32LE(e,t);t+=4;const n=r,o=e[t++];if(r<0)throw new BSONError("Negative binary type element size found");if(r>e.byteLength)throw new BSONError("Binary type size larger than document size");if(null!=e.slice){if(o===Binary.SUBTYPE_BYTE_ARRAY){if(r=Ne.getInt32LE(e,t),t+=4,r<0)throw new BSONError("Negative binary type element size found for subtype 0x02");if(r>n-4)throw new BSONError("Binary type with subtype 0x02 contains too long binary size");if(r<n-4)throw new BSONError("Binary type with subtype 0x02 contains too short binary size")}u&&f?J=W.toLocalBufferType(e.slice(t,t+r)):(J=new Binary(e.slice(t,t+r),o),o===z&&UUID.isValid(J)&&(J=J.toUUID()))}else{if(o===Binary.SUBTYPE_BYTE_ARRAY){if(r=Ne.getInt32LE(e,t),t+=4,r<0)throw new BSONError("Negative binary type element size found for subtype 0x02");if(r>n-4)throw new BSONError("Binary type with subtype 0x02 contains too long binary size");if(r<n-4)throw new BSONError("Binary type with subtype 0x02 contains too short binary size")}if(u&&f)for(J=W.allocateUnsafe(r),d=0;d<r;d++)J[d]=e[t+d];else J=new Binary(e.slice(t,t+r),o),o===z&&UUID.isValid(J)&&(J=J.toUUID())}t+=r}else if(p===x&&!1===s){for(d=t;0!==e[d]&&d<e.length;)d++;if(d>=e.length)throw new BSONError("Bad BSON Document: illegal CString");const r=W.toUTF8(e,t,d,!1);for(d=t=d+1;0!==e[d]&&d<e.length;)d++;if(d>=e.length)throw new BSONError("Bad BSON Document: illegal CString");const n=W.toUTF8(e,t,d,!1);t=d+1;const o=new Array(n.length);for(d=0;d<n.length;d++)switch(n[d]){case"m":o[d]="m";break;case"s":o[d]="g";break;case"i":o[d]="i"}J=new RegExp(r,o.join(""))}else if(p===x&&!0===s){for(d=t;0!==e[d]&&d<e.length;)d++;if(d>=e.length)throw new BSONError("Bad BSON Document: illegal CString");const r=W.toUTF8(e,t,d,!1);for(d=t=d+1;0!==e[d]&&d<e.length;)d++;if(d>=e.length)throw new BSONError("Bad BSON Document: illegal CString");const n=W.toUTF8(e,t,d,!1);t=d+1,J=new BSONRegExp(r,n)}else if(p===v){const r=Ne.getInt32LE(e,t);if(t+=4,r<=0||r>e.length-t||0!==e[t+r-1])throw new BSONError("bad string length in bson");const n=W.toUTF8(e,t,t+r-1,q);J=f?n:new BSONSymbol(n),t+=r}else if(p===T)J=new Timestamp({i:Ne.getUint32LE(e,t),t:Ne.getUint32LE(e,t+4)}),t+=8;else if(p===R)J=new MinKey;else if(p===A)J=new MaxKey;else if(p===_){const r=Ne.getInt32LE(e,t);if(t+=4,r<=0||r>e.length-t||0!==e[t+r-1])throw new BSONError("bad string length in bson");const n=W.toUTF8(e,t,t+r-1,q);J=new Code(n),t+=r}else if(p===U){const n=Ne.getInt32LE(e,t);if(t+=4,n<13)throw new BSONError("code_w_scope total size shorter minimum expected length");const o=Ne.getInt32LE(e,t);if(t+=4,o<=0||o>e.length-t||0!==e[t+o-1])throw new BSONError("bad string length in bson");const i=W.toUTF8(e,t,t+o-1,q),s=t+=o,u=Ne.getInt32LE(e,t),a=je(e,s,r,!1);if(t+=u,n<8+u+o)throw new BSONError("code_w_scope total size is too short, truncating scope");if(n>8+u+o)throw new BSONError("code_w_scope total size is too long, clips outer document");J=new Code(i,a)}else{if(p!==I)throw new BSONError(`Detected unknown BSON type ${p.toString(16)} for fieldname "${M}"`);{const r=Ne.getInt32LE(e,t);if(t+=4,r<=0||r>e.length-t||0!==e[t+r-1])throw new BSONError("bad string length in bson");const n=W.toUTF8(e,t,t+r-1,q);t+=r;const o=W.allocateUnsafe(12);for(let r=0;r<12;r++)o[r]=e[t+r];const i=new ObjectId(o);t+=12,J=new DBRef(n,i)}}"__proto__"===M?Object.defineProperty(F,M,{value:J,writable:!0,enumerable:!0,configurable:!0}):F[M]=J}if(M!==t-d){if(n)throw new BSONError("corrupt array bson");throw new BSONError("corrupt object bson")}if(!C)return F;if(Q(F)){const e=Object.assign({},F);return delete e.$ref,delete e.$id,delete e.$db,new DBRef(F.$ref,F.$id,F.$db,e)}return F}const De=/\x00/,Re=new Set(["$db","$ref","$id","$clusterTime"]);function Ae(e,t,r,n){e[n++]=y,e[(n=n+W.encodeUTF8Into(e,t,n)+1)-1]=0;const o=W.encodeUTF8Into(e,r,n+4);return Ne.setInt32LE(e,n,o+1),n=n+4+o,e[n++]=0,n}function Me(e,t,r,n){const o=!Object.is(r,-0)&&Number.isSafeInteger(r)&&r<=l&&r>=c?$:b;return e[n++]=o,n+=W.encodeUTF8Into(e,t,n),e[n++]=0,n+=o===$?Ne.setInt32LE(e,n,r):Ne.setFloat64LE(e,n,r)}function ze(e,t,r,n){return e[n++]=j,n+=W.encodeUTF8Into(e,t,n),e[n++]=0,n+=Ne.setBigInt64LE(e,n,r)}function Fe(e,t,r,n){return e[n++]=L,n+=W.encodeUTF8Into(e,t,n),e[n++]=0,n}function Ve(e,t,r,n){return e[n++]=N,n+=W.encodeUTF8Into(e,t,n),e[n++]=0,e[n++]=r?1:0,n}function Ce(e,t,r,n){e[n++]=E,n+=W.encodeUTF8Into(e,t,n),e[n++]=0;const o=Long.fromNumber(r.getTime()),i=o.getLowBits(),s=o.getHighBits();return n+=Ne.setInt32LE(e,n,i),n+=Ne.setInt32LE(e,n,s)}function Je(e,t,r,n){if(e[n++]=x,n+=W.encodeUTF8Into(e,t,n),e[n++]=0,r.source&&null!=r.source.match(De))throw new BSONError("value "+r.source+" must not contain null bytes");return n+=W.encodeUTF8Into(e,r.source,n),e[n++]=0,r.ignoreCase&&(e[n++]=105),r.global&&(e[n++]=115),r.multiline&&(e[n++]=109),e[n++]=0,n}function qe(e,t,r,n){if(e[n++]=x,n+=W.encodeUTF8Into(e,t,n),e[n++]=0,null!=r.pattern.match(De))throw new BSONError("pattern "+r.pattern+" must not contain null bytes");n+=W.encodeUTF8Into(e,r.pattern,n),e[n++]=0;const o=r.options.split("").sort().join("");return n+=W.encodeUTF8Into(e,o,n),e[n++]=0,n}function Pe(e,t,r,n){return null===r?e[n++]=L:"MinKey"===r._bsontype?e[n++]=R:e[n++]=A,n+=W.encodeUTF8Into(e,t,n),e[n++]=0,n}function ke(e,t,r,n){return e[n++]=O,n+=W.encodeUTF8Into(e,t,n),e[n++]=0,n+=r.serializeInto(e,n)}function He(e,t,r,n){e[n++]=B,n+=W.encodeUTF8Into(e,t,n),e[n++]=0;const o=r.length;if(n+=Ne.setInt32LE(e,n,o),e[n++]=M,o<=16)for(let t=0;t<o;t++)e[n+t]=r[t];else e.set(r,n);return n+=o}function Ke(e,t,r,n,o,i,s,u,a){if(a.has(r))throw new BSONError("Cannot convert circular structure to BSON");a.add(r),e[n++]=Array.isArray(r)?w:m,n+=W.encodeUTF8Into(e,t,n),e[n++]=0;const f=nt(e,r,o,n,i+1,s,u,a);return a.delete(r),f}function Ye(e,t,r,n){e[n++]=D,n+=W.encodeUTF8Into(e,t,n),e[n++]=0;for(let t=0;t<16;t++)e[n+t]=r.bytes[t];return n+16}function Ze(e,t,r,n){e[n++]="Long"===r._bsontype?j:T,n+=W.encodeUTF8Into(e,t,n),e[n++]=0;const o=r.getLowBits(),i=r.getHighBits();return n+=Ne.setInt32LE(e,n,o),n+=Ne.setInt32LE(e,n,i)}function We(e,t,r,n){return r=r.valueOf(),e[n++]=$,n+=W.encodeUTF8Into(e,t,n),e[n++]=0,n+=Ne.setInt32LE(e,n,r)}function Ge(e,t,r,n){return e[n++]=b,n+=W.encodeUTF8Into(e,t,n),e[n++]=0,n+=Ne.setFloat64LE(e,n,r.value)}function Xe(e,t,r,n){e[n++]=_,n+=W.encodeUTF8Into(e,t,n),e[n++]=0;const o=r.toString(),i=W.encodeUTF8Into(e,o,n+4)+1;return Ne.setInt32LE(e,n,i),n=n+4+i-1,e[n++]=0,n}function Qe(e,t,r,n,o=!1,i=0,s=!1,u=!0,a){if(r.scope&&"object"==typeof r.scope){e[n++]=U,n+=W.encodeUTF8Into(e,t,n),e[n++]=0;let f=n;const l=r.code;n+=4;const c=W.encodeUTF8Into(e,l,n+4)+1;Ne.setInt32LE(e,n,c),e[n+4+c-1]=0,n=n+c+4;const g=nt(e,r.scope,o,n,i+1,s,u,a);n=g-1;const h=g-f;f+=Ne.setInt32LE(e,f,h),e[n++]=0}else{e[n++]=_,n+=W.encodeUTF8Into(e,t,n),e[n++]=0;const o=r.code.toString(),i=W.encodeUTF8Into(e,o,n+4)+1;Ne.setInt32LE(e,n,i),n=n+4+i-1,e[n++]=0}return n}function et(e,t,r,n){e[n++]=B,n+=W.encodeUTF8Into(e,t,n),e[n++]=0;const o=r.buffer;let i=r.position;if(r.sub_type===Binary.SUBTYPE_BYTE_ARRAY&&(i+=4),n+=Ne.setInt32LE(e,n,i),e[n++]=r.sub_type,r.sub_type===Binary.SUBTYPE_BYTE_ARRAY&&(i-=4,n+=Ne.setInt32LE(e,n,i)),i<=16)for(let t=0;t<i;t++)e[n+t]=o[t];else e.set(o,n);return n+=r.position}function tt(e,t,r,n){e[n++]=v,n+=W.encodeUTF8Into(e,t,n),e[n++]=0;const o=W.encodeUTF8Into(e,r.value,n+4)+1;return Ne.setInt32LE(e,n,o),n=n+4+o-1,e[n++]=0,n}function rt(e,t,r,n,o,i,s){e[n++]=m,n+=W.encodeUTF8Into(e,t,n),e[n++]=0;let u=n,a={$ref:r.collection||r.namespace,$id:r.oid};null!=r.db&&(a.$db=r.db),a=Object.assign(a,r.fields);const f=nt(e,a,!1,n,o+1,i,!0,s),l=f-u;return u+=Ne.setInt32LE(e,n,l),f}function nt(e,t,r,a,l,c,g,h){if(null==h){if(null==t)return e[0]=5,e[1]=0,e[2]=0,e[3]=0,e[4]=0,5;if(Array.isArray(t))throw new BSONError("serialize does not support an array as the root input");if("object"!=typeof t)throw new BSONError("serialize does not support non-object as the root input");if("_bsontype"in t&&"string"==typeof t._bsontype)throw new BSONError("BSON types cannot be serialized as a document");if(u(t)||i(t)||o(t)||n(t))throw new BSONError("date, regexp, typedarray, and arraybuffer cannot be BSON documents");h=new Set}h.add(t);let p=a+4;if(Array.isArray(t))for(let n=0;n<t.length;n++){const s=`${n}`;let a=t[n];if("function"==typeof a?.toBSON&&(a=a.toBSON()),"string"==typeof a)p=Ae(e,s,a,p);else if("number"==typeof a)p=Me(e,s,a,p);else if("bigint"==typeof a)p=ze(e,s,a,p);else if("boolean"==typeof a)p=Ve(e,s,a,p);else if(a instanceof Date||u(a))p=Ce(e,s,a,p);else if(void 0===a)p=Fe(e,s,0,p);else if(null===a)p=Fe(e,s,0,p);else if(o(a))p=He(e,s,a,p);else if(a instanceof RegExp||i(a))p=Je(e,s,a,p);else if("object"==typeof a&&null==a._bsontype)p=Ke(e,s,a,p,r,l,c,g,h);else{if("object"==typeof a&&a[Symbol.for("@@mdb.bson.version")]!==f)throw new BSONVersionError;if("ObjectId"===a._bsontype)p=ke(e,s,a,p);else if("Decimal128"===a._bsontype)p=Ye(e,s,a,p);else if("Long"===a._bsontype||"Timestamp"===a._bsontype)p=Ze(e,s,a,p);else if("Double"===a._bsontype)p=Ge(e,s,a,p);else if("function"==typeof a&&c)p=Xe(e,s,a,p);else if("Code"===a._bsontype)p=Qe(e,s,a,p,r,l,c,g,h);else if("Binary"===a._bsontype)p=et(e,s,a,p);else if("BSONSymbol"===a._bsontype)p=tt(e,s,a,p);else if("DBRef"===a._bsontype)p=rt(e,s,a,p,l,c,h);else if("BSONRegExp"===a._bsontype)p=qe(e,s,a,p);else if("Int32"===a._bsontype)p=We(e,s,a,p);else if("MinKey"===a._bsontype||"MaxKey"===a._bsontype)p=Pe(e,s,a,p);else if(void 0!==a._bsontype)throw new BSONError(`Unrecognized or invalid _bsontype: ${String(a._bsontype)}`)}}else if(t instanceof Map||s(t)){const n=t.entries();let s=!1;for(;!s;){const t=n.next();if(s=!!t.done,s)continue;const a=t.value[0];let d=t.value[1];"function"==typeof d?.toBSON&&(d=d.toBSON());const b=typeof d;if("string"==typeof a&&!Re.has(a)){if(null!=a.match(De))throw new BSONError("key "+a+" must not contain null bytes");if(r){if("$"===a[0])throw new BSONError("key "+a+" must not start with '$'");if(a.includes("."))throw new BSONError("key "+a+" must not contain '.'")}}if("string"===b)p=Ae(e,a,d,p);else if("number"===b)p=Me(e,a,d,p);else if("bigint"===b)p=ze(e,a,d,p);else if("boolean"===b)p=Ve(e,a,d,p);else if(d instanceof Date||u(d))p=Ce(e,a,d,p);else if(null===d||void 0===d&&!1===g)p=Fe(e,a,0,p);else if(o(d))p=He(e,a,d,p);else if(d instanceof RegExp||i(d))p=Je(e,a,d,p);else if("object"===b&&null==d._bsontype)p=Ke(e,a,d,p,r,l,c,g,h);else{if("object"==typeof d&&d[Symbol.for("@@mdb.bson.version")]!==f)throw new BSONVersionError;if("ObjectId"===d._bsontype)p=ke(e,a,d,p);else if("object"===b&&"Decimal128"===d._bsontype)p=Ye(e,a,d,p);else if("Long"===d._bsontype||"Timestamp"===d._bsontype)p=Ze(e,a,d,p);else if("Double"===d._bsontype)p=Ge(e,a,d,p);else if("Code"===d._bsontype)p=Qe(e,a,d,p,r,l,c,g,h);else if("function"==typeof d&&c)p=Xe(e,a,d,p);else if("Binary"===d._bsontype)p=et(e,a,d,p);else if("BSONSymbol"===d._bsontype)p=tt(e,a,d,p);else if("DBRef"===d._bsontype)p=rt(e,a,d,p,l,c,h);else if("BSONRegExp"===d._bsontype)p=qe(e,a,d,p);else if("Int32"===d._bsontype)p=We(e,a,d,p);else if("MinKey"===d._bsontype||"MaxKey"===d._bsontype)p=Pe(e,a,d,p);else if(void 0!==d._bsontype)throw new BSONError(`Unrecognized or invalid _bsontype: ${String(d._bsontype)}`)}}}else{if("function"==typeof t?.toBSON&&null!=(t=t.toBSON())&&"object"!=typeof t)throw new BSONError("toBSON function did not return an object");for(const n of Object.keys(t)){let s=t[n];"function"==typeof s?.toBSON&&(s=s.toBSON());const a=typeof s;if("string"==typeof n&&!Re.has(n)){if(null!=n.match(De))throw new BSONError("key "+n+" must not contain null bytes");if(r){if("$"===n[0])throw new BSONError("key "+n+" must not start with '$'");if(n.includes("."))throw new BSONError("key "+n+" must not contain '.'")}}if("string"===a)p=Ae(e,n,s,p);else if("number"===a)p=Me(e,n,s,p);else if("bigint"===a)p=ze(e,n,s,p);else if("boolean"===a)p=Ve(e,n,s,p);else if(s instanceof Date||u(s))p=Ce(e,n,s,p);else if(void 0===s)!1===g&&(p=Fe(e,n,0,p));else if(null===s)p=Fe(e,n,0,p);else if(o(s))p=He(e,n,s,p);else if(s instanceof RegExp||i(s))p=Je(e,n,s,p);else if("object"===a&&null==s._bsontype)p=Ke(e,n,s,p,r,l,c,g,h);else{if("object"==typeof s&&s[Symbol.for("@@mdb.bson.version")]!==f)throw new BSONVersionError;if("ObjectId"===s._bsontype)p=ke(e,n,s,p);else if("object"===a&&"Decimal128"===s._bsontype)p=Ye(e,n,s,p);else if("Long"===s._bsontype||"Timestamp"===s._bsontype)p=Ze(e,n,s,p);else if("Double"===s._bsontype)p=Ge(e,n,s,p);else if("Code"===s._bsontype)p=Qe(e,n,s,p,r,l,c,g,h);else if("function"==typeof s&&c)p=Xe(e,n,s,p);else if("Binary"===s._bsontype)p=et(e,n,s,p);else if("BSONSymbol"===s._bsontype)p=tt(e,n,s,p);else if("DBRef"===s._bsontype)p=rt(e,n,s,p,l,c,h);else if("BSONRegExp"===s._bsontype)p=qe(e,n,s,p);else if("Int32"===s._bsontype)p=We(e,n,s,p);else if("MinKey"===s._bsontype||"MaxKey"===s._bsontype)p=Pe(e,n,s,p);else if(void 0!==s._bsontype)throw new BSONError(`Unrecognized or invalid _bsontype: ${String(s._bsontype)}`)}}}h.delete(t),e[p++]=0;const d=p-a;return a+=Ne.setInt32LE(e,a,d),p}const ot={$oid:ObjectId,$binary:Binary,$uuid:Binary,$symbol:BSONSymbol,$numberInt:Int32,$numberDecimal:Decimal128,$numberDouble:Double,$numberLong:Long,$minKey:MinKey,$maxKey:MaxKey,$regex:BSONRegExp,$regularExpression:BSONRegExp,$timestamp:Timestamp};function it(e,t={}){if("number"==typeof e){const r=e<=l&&e>=c,n=e<=g&&e>=h;if(t.relaxed||t.legacy)return e;if(Number.isInteger(e)&&!Object.is(e,-0)){if(r)return new Int32(e);if(n)return t.useBigInt64?BigInt(e):Long.fromNumber(e)}return new Double(e)}if(null==e||"object"!=typeof e)return e;if(e.$undefined)return null;const r=Object.keys(e).filter((t=>t.startsWith("$")&&null!=e[t]));for(let n=0;n<r.length;n++){const o=ot[r[n]];if(o)return o.fromExtendedJSON(e,t)}if(null!=e.$date){const r=e.$date,n=new Date;if(t.legacy)if("number"==typeof r)n.setTime(r);else if("string"==typeof r)n.setTime(Date.parse(r));else{if("bigint"!=typeof r)throw new BSONRuntimeError("Unrecognized type for EJSON date: "+typeof r);n.setTime(Number(r))}else if("string"==typeof r)n.setTime(Date.parse(r));else if(Long.isLong(r))n.setTime(r.toNumber());else if("number"==typeof r&&t.relaxed)n.setTime(r);else{if("bigint"!=typeof r)throw new BSONRuntimeError("Unrecognized type for EJSON date: "+typeof r);n.setTime(Number(r))}return n}if(null!=e.$code){const t=Object.assign({},e);return e.$scope&&(t.$scope=it(e.$scope)),Code.fromExtendedJSON(e)}if(Q(e)||e.$dbPointer){const t=e.$ref?e:e.$dbPointer;if(t instanceof DBRef)return t;const r=Object.keys(t).filter((e=>e.startsWith("$")));let n=!0;if(r.forEach((e=>{-1===["$ref","$id","$db"].indexOf(e)&&(n=!1)})),n)return DBRef.fromExtendedJSON(t)}return e}function st(e){const t=e.toISOString();return 0!==e.getUTCMilliseconds()?t:t.slice(0,-5)+"Z"}function ut(e,t){if(e instanceof Map||s(e)){const r=Object.create(null);for(const[t,n]of e){if("string"!=typeof t)throw new BSONError("Can only serialize maps with string keys");r[t]=n}return ut(r,t)}if(("object"==typeof e||"function"==typeof e)&&null!==e){const r=t.seenObjects.findIndex((t=>t.obj===e));if(-1!==r){const e=t.seenObjects.map((e=>e.propertyName)),n=e.slice(0,r).map((e=>`${e} -> `)).join(""),o=e[r],i=" -> "+e.slice(r+1,e.length-1).map((e=>`${e} -> `)).join(""),s=e[e.length-1],u=" ".repeat(n.length+o.length/2),a="-".repeat(i.length+(o.length+s.length)/2-1);throw new BSONError(`Converting circular structure to EJSON:\n ${n}${o}${i}${s}\n ${u}\\${a}/`)}t.seenObjects[t.seenObjects.length-1].obj=e}if(Array.isArray(e))return function(e,t){return e.map(((e,r)=>{t.seenObjects.push({propertyName:`index ${r}`,obj:null});try{return ut(e,t)}finally{t.seenObjects.pop()}}))}(e,t);if(void 0===e)return null;if(e instanceof Date||u(e)){const r=e.getTime(),n=r>-1&&r<2534023188e5;return t.legacy?t.relaxed&&n?{$date:e.getTime()}:{$date:st(e)}:t.relaxed&&n?{$date:st(e)}:{$date:{$numberLong:e.getTime().toString()}}}if(!("number"!=typeof e||t.relaxed&&isFinite(e))){if(Number.isInteger(e)&&!Object.is(e,-0)){if(e>=c&&e<=l)return{$numberInt:e.toString()};if(e>=h&&e<=g)return{$numberLong:e.toString()}}return{$numberDouble:Object.is(e,-0)?"-0.0":e.toString()}}if("bigint"==typeof e)return t.relaxed?Number(BigInt.asIntN(64,e)):{$numberLong:BigInt.asIntN(64,e).toString()};if(e instanceof RegExp||i(e)){let r=e.flags;if(void 0===r){const t=e.toString().match(/[gimuy]*$/);t&&(r=t[0])}return new BSONRegExp(e.source,r).toExtendedJSON(t)}return null!=e&&"object"==typeof e?function(e,t){if(null==e||"object"!=typeof e)throw new BSONError("not an object instance");const r=e._bsontype;if(void 0===r){const r={};for(const n of Object.keys(e)){t.seenObjects.push({propertyName:n,obj:null});try{const o=ut(e[n],t);"__proto__"===n?Object.defineProperty(r,n,{value:o,writable:!0,enumerable:!0,configurable:!0}):r[n]=o}finally{t.seenObjects.pop()}}return r}if(null!=e&&"object"==typeof e&&"string"==typeof e._bsontype&&e[Symbol.for("@@mdb.bson.version")]!==f)throw new BSONVersionError;if(function(e){return null!=e&&"object"==typeof e&&"_bsontype"in e&&"string"==typeof e._bsontype}(e)){let n=e;if("function"!=typeof n.toExtendedJSON){const t=at[e._bsontype];if(!t)throw new BSONError("Unrecognized or invalid _bsontype: "+e._bsontype);n=t(n)}return"Code"===r&&n.scope?n=new Code(n.code,ut(n.scope,t)):"DBRef"===r&&n.oid&&(n=new DBRef(ut(n.collection,t),ut(n.oid,t),ut(n.db,t),ut(n.fields,t))),n.toExtendedJSON(t)}throw new BSONError("_bsontype must be a string, but was: "+typeof r)}(e,t):e}const at={Binary:e=>new Binary(e.value(),e.sub_type),Code:e=>new Code(e.code,e.scope),DBRef:e=>new DBRef(e.collection||e.namespace,e.oid,e.db,e.fields),Decimal128:e=>new Decimal128(e.bytes),Double:e=>new Double(e.value),Int32:e=>new Int32(e.value),Long:e=>Long.fromBits(null!=e.low?e.low:e.low_,null!=e.low?e.high:e.high_,null!=e.low?e.unsigned:e.unsigned_),MaxKey:()=>new MaxKey,MinKey:()=>new MinKey,ObjectId:e=>new ObjectId(e),BSONRegExp:e=>new BSONRegExp(e.pattern,e.options),BSONSymbol:e=>new BSONSymbol(e.value),Timestamp:e=>Timestamp.fromBits(e.low,e.high)};function ft(e,t){const r={useBigInt64:t?.useBigInt64??!1,relaxed:t?.relaxed??!0,legacy:t?.legacy??!1};return JSON.parse(e,((e,t)=>{if(-1!==e.indexOf("\0"))throw new BSONError(`BSON Document field names cannot contain null bytes, found: ${JSON.stringify(e)}`);return it(t,r)}))}function lt(e,t,r,n){null!=r&&"object"==typeof r&&(n=r,r=0),null==t||"object"!=typeof t||Array.isArray(t)||(n=t,t=void 0,r=0);const o=ut(e,Object.assign({relaxed:!0,legacy:!1},n,{seenObjects:[{propertyName:"(root)",obj:null}]}));return JSON.stringify(o,t,r)}const ct=Object.create(null);function gt(e,t){try{return Ne.getNonnegativeInt32LE(e,t)}catch(e){throw new BSONOffsetError("BSON size cannot be negative",t,{cause:e})}}function ht(e,t){let r=t;for(;0!==e[r];r++);if(r===e.length-1)throw new BSONOffsetError("Null terminator not found",t);return r}ct.parse=ft,ct.stringify=lt,ct.serialize=function(e,t){return t=t||{},JSON.parse(lt(e,t))},ct.deserialize=function(e,t){return t=t||{},ft(JSON.stringify(e),t)},Object.freeze(ct);const pt=Object.create(null);pt.parseToElements=function(e,t=0){if(t??=0,e.length<5)throw new BSONOffsetError(`Input must be at least 5 bytes, got ${e.length} bytes`,t);const r=gt(e,t);if(r>e.length-t)throw new BSONOffsetError(`Parsed documentSize (${r} bytes) does not match input length (${e.length} bytes)`,t);if(0!==e[t+r-1])throw new BSONOffsetError("BSON documents must end in 0x00",t+r);const n=[];let o=t+4;for(;o<=r+t;){const i=e[o];if(o+=1,0===i){if(o-t!==r)throw new BSONOffsetError("Invalid 0x00 type byte",o);break}const s=o,u=ht(e,o)-s;let a;if(o+=u+1,1===i||18===i||9===i||17===i)a=8;else if(16===i)a=4;else if(7===i)a=12;else if(19===i)a=16;else if(8===i)a=1;else if(10===i||6===i||127===i||255===i)a=0;else if(11===i)a=ht(e,ht(e,o)+1)+1-o;else if(3===i||4===i||15===i)a=gt(e,o);else{if(2!==i&&5!==i&&12!==i&&13!==i&&14!==i)throw new BSONOffsetError(`Invalid 0x${i.toString(16).padStart(2,"0")} type byte`,o);a=gt(e,o)+4,5===i&&(a+=1),12===i&&(a+=12)}if(a>r)throw new BSONOffsetError("value reports length larger than document",o);n.push([i,s,u,o,a]),o+=a}return n},pt.ByteUtils=W,pt.NumberUtils=Ne,Object.freeze(pt);const dt=17825792;let bt=W.allocate(dt);function yt(e){bt.length<e&&(bt=W.allocate(e))}function mt(e,t={}){const r="boolean"==typeof t.checkKeys&&t.checkKeys,n="boolean"==typeof t.serializeFunctions&&t.serializeFunctions,o="boolean"!=typeof t.ignoreUndefined||t.ignoreUndefined,i="number"==typeof t.minInternalBufferSize?t.minInternalBufferSize:dt;bt.length<i&&(bt=W.allocate(i));const s=nt(bt,e,r,0,0,n,o,null),u=W.allocateUnsafe(s);return u.set(bt.subarray(0,s),0),u}function wt(e,t,r={}){const n="boolean"==typeof r.checkKeys&&r.checkKeys,o="boolean"==typeof r.serializeFunctions&&r.serializeFunctions,i="boolean"!=typeof r.ignoreUndefined||r.ignoreUndefined,s="number"==typeof r.index?r.index:0,u=nt(bt,e,n,0,0,o,i,null);return t.set(bt.subarray(0,u),s),s+u-1}function Bt(e,t={}){return $e(W.toLocalBufferType(e),t)}function St(e,t={}){return xe(e,"boolean"==typeof(t=t||{}).serializeFunctions&&t.serializeFunctions,"boolean"!=typeof t.ignoreUndefined||t.ignoreUndefined)}function Ot(e,t,r,n,o,i){const s=Object.assign({allowObjectSmallerThanBufferSize:!0,index:0},i),u=W.toLocalBufferType(e);let a=t;for(let e=0;e<r;e++){const t=Ne.getInt32LE(u,a);s.index=a,n[o+e]=$e(u,s),a+=t}return a}var Nt=Object.freeze({__proto__:null,BSONError,BSONOffsetError,BSONRegExp,BSONRuntimeError,BSONSymbol,BSONType:F,BSONValue,BSONVersionError,Binary,Code,DBRef,Decimal128,Double,EJSON:ct,Int32,Long,MaxKey,MinKey,ObjectId,Timestamp,UUID,calculateObjectSize:St,deserialize:Bt,deserializeStream:Ot,onDemand:pt,serialize:mt,serializeWithBufferAndIndex:wt,setInternalBufferSize:yt});t.BSON=Nt,t.BSONError=BSONError,t.BSONOffsetError=BSONOffsetError,t.BSONRegExp=BSONRegExp,t.BSONRuntimeError=BSONRuntimeError,t.BSONSymbol=BSONSymbol,t.BSONType=F,t.BSONValue=BSONValue,t.BSONVersionError=BSONVersionError,t.Binary=Binary,t.Code=Code,t.DBRef=DBRef,t.Decimal128=Decimal128,t.Double=Double,t.EJSON=ct,t.Int32=Int32,t.Long=Long,t.MaxKey=MaxKey,t.MinKey=MinKey,t.ObjectId=ObjectId,t.Timestamp=Timestamp,t.UUID=UUID,t.calculateObjectSize=St,t.deserialize=Bt,t.deserializeStream=Ot,t.onDemand=pt,t.serialize=mt,t.serializeWithBufferAndIndex=wt,t.setInternalBufferSize=yt}},t={},function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}},s=!0;try{e[n].call(i.exports,i,i.exports,r),s=!1}finally{s&&delete t[n]}return i.exports}(754);var e,t}));
@@ -1 +0,0 @@
1
- {"version":3,"file":"child-process-proxy.js","sourceRoot":"","sources":["../src/child-process-proxy.ts"],"names":[],"mappings":";;;;;AAeA,mCAA8B;AAC9B,mDAAmD;AACnD,gDAAwB;AACxB,+BAAgD;AAEhD,6CAA2D;AAE3D,MAAM,oBAAoB,GACxB,OAAO,CAAC,GAAG,CAAC,0DAA0D;IACtE,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;AAE/C,MAAM,aAAa,GAAG,IAAI,uBAAM,CAAC,oBAAoB,EAAE,EAAE,GAAG,EAAE,0BAAS,EAAE,CAAC,CAAC;AAE3E,MAAM,kBAAkB,GAAkB,CAAC,KAAK,IAAI,EAAE;IACpD,MAAM,mBAAmB,GAAG,KAAK,IAAI,EAAE;QACrC,IAAI,GAAW,CAAC;QAChB,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,IAAA,aAAI,EAAC,aAAa,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC;YACtD,IAAI,GAAG,KAAK,OAAO;gBAAE,OAAO;QAC9B,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,KAAK,IAAI,EAAE;QAC9B,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,IAAA,aAAI,EAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACjD,IAAI,GAAG,EAAE,CAAC;YACR,GAAG,CAAC,OAAO,GAAG,2DAA2D,GAAG,CAAC,OAAO,EAAE,CAAC;YACvF,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,mBAAmB,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC;AAC9D,CAAC,CAAC,EAAE,CAAC;AAML,OAAO,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;AAC5B,aAAa,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;AAElC,IAAI,eAAe,GAA2B,IAAI,CAAC;AAEnD,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,kBAAY,EAAC,CAAC,WAAW,CAAC,EAAE,aAAa,CAAC,CAAC;AAEjE,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAC1B,IAAA,kBAAY,EACV,CAAC,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,EACxD,aAAa,CACd,EACD;IACE,SAAS;QACP,IAAI,eAAe,EAAE,CAAC;YACpB,IAAA,uBAAe,EAAC,eAAe,CAAC,CAAC;YACjC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,SAAS,EAAE,CAAC;IACrB,CAAC;CACF,CACF,CAAC;AAEF,SAAS,uBAAuB,CAAqB,EAAK;IACxD,OAAO,IAAI,KAAK,CAAC,EAAE,EAAE;QACnB,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,aAAa;YACxC,MAAM,kBAAkB,CAAC;YACzB,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;QAC5D,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAIA,MAAM,CAAC,IAAI,CAAC,MAAM,CAA6B,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;IAC/D,MAAM,CAAC,GAAG,CAAC,GAAG,uBAAuB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC;AAEH,IAAA,eAAS,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE3B,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CACtC,IAAA,kBAAY,EACV;IACE,SAAS;IACT,UAAU;IACV,WAAW;IACX,WAAW;IACX,aAAa;IACb,gBAAgB;IAChB,mBAAmB;IACnB,gBAAgB;IAChB,QAAQ;CACT,EACD,OAAO,CACR,EACD;IACE,kBAAkB,CAAC,MAA8B;QAC/C,eAAe,GAAG,MAAM,CAAC;IAC3B,CAAC;CACF,CACF,CAAC;AAEF,IAAA,eAAS,EAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;AAE7C,MAAM,UAAU,GAAG,IAAA,kBAAY,EAAC,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;AAEzD,IAAA,eAAS,EAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AAErC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;AACjD,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE;;IACpB,MAAA,OAAO,CAAC,IAAI,wDAAG,OAAO,CAAC,CAAC;AAC1B,CAAC,CAAC,CAAC"}
@@ -1,5 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import type { ChildProcess, SpawnOptions, StdioNull, StdioPipe } from 'child_process';
4
- export declare function kill(childProcess: ChildProcess, code?: NodeJS.Signals | number): Promise<void>;
5
- export default function spawnChildFromSource(src: string, spawnOptions?: Omit<SpawnOptions, 'stdio'>, timeoutMs?: number, _stdout?: StdioNull | StdioPipe, _stderr?: StdioNull | StdioPipe): Promise<ChildProcess>;
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.kill = void 0;
4
- const child_process_1 = require("child_process");
5
- const events_1 = require("events");
6
- async function kill(childProcess, code = 'SIGTERM') {
7
- childProcess.kill(code);
8
- if (childProcess.exitCode === null && childProcess.signalCode === null) {
9
- await (0, events_1.once)(childProcess, 'exit');
10
- }
11
- }
12
- exports.kill = kill;
13
- function spawnChildFromSource(src, spawnOptions = {}, timeoutMs, _stdout = 'inherit', _stderr = 'inherit') {
14
- return new Promise((resolve, reject) => {
15
- const readyToken = Date.now().toString(32);
16
- const childProcess = (0, child_process_1.spawn)(process.execPath, {
17
- stdio: ['pipe', _stdout, _stderr, 'ipc'],
18
- ...spawnOptions,
19
- });
20
- if (!childProcess.stdin) {
21
- kill(childProcess)
22
- .then(() => {
23
- reject(new Error("Can't write src to the spawned process, missing stdin"));
24
- })
25
- .catch((err) => {
26
- reject(err);
27
- });
28
- return;
29
- }
30
- let timeoutId;
31
- function cleanupListeners() {
32
- if (timeoutId) {
33
- clearTimeout(timeoutId);
34
- }
35
- if (childProcess.stdin) {
36
- childProcess.stdin.off('error', onWriteError);
37
- }
38
- childProcess.off('message', onMessage);
39
- childProcess.off('exit', onExit);
40
- }
41
- function onExit(exitCode) {
42
- if (exitCode && exitCode > 0) {
43
- cleanupListeners();
44
- reject(new Error('Child process exited with error before starting'));
45
- }
46
- }
47
- async function onWriteError(error) {
48
- cleanupListeners();
49
- await kill(childProcess);
50
- reject(error);
51
- }
52
- async function onTimeout() {
53
- cleanupListeners();
54
- await kill(childProcess);
55
- reject(new Error('Timed out while waiting for child process to start'));
56
- }
57
- function onMessage(data) {
58
- if (data === readyToken) {
59
- cleanupListeners();
60
- resolve(childProcess);
61
- }
62
- }
63
- childProcess.on('message', onMessage);
64
- childProcess.on('exit', onExit);
65
- childProcess.stdin.on('error', onWriteError);
66
- childProcess.stdin.write(src);
67
- childProcess.stdin.write(`;process.send(${JSON.stringify(readyToken)})`);
68
- childProcess.stdin.end();
69
- timeoutId =
70
- timeoutMs !== undefined ? setTimeout(onTimeout, timeoutMs) : null;
71
- });
72
- }
73
- exports.default = spawnChildFromSource;
74
- //# sourceMappingURL=spawn-child-from-source.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"spawn-child-from-source.js","sourceRoot":"","sources":["../src/spawn-child-from-source.ts"],"names":[],"mappings":";;;AAOA,iDAAsC;AACtC,mCAA8B;AAEvB,KAAK,UAAU,IAAI,CACxB,YAA0B,EAC1B,OAAgC,SAAS;IAEzC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxB,IAAI,YAAY,CAAC,QAAQ,KAAK,IAAI,IAAI,YAAY,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;QACvE,MAAM,IAAA,aAAI,EAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC;AACH,CAAC;AARD,oBAQC;AAED,SAAwB,oBAAoB,CAC1C,GAAW,EACX,eAA4C,EAAE,EAC9C,SAAkB,EAClB,UAAiC,SAAS,EAC1C,UAAiC,SAAS;IAE1C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAE3C,MAAM,YAAY,GAAG,IAAA,qBAAK,EAAC,OAAO,CAAC,QAAQ,EAAE;YAC3C,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC;YACxC,GAAG,YAAY;SAChB,CAAC,CAAC;QAEH,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;YACxB,IAAI,CAAC,YAAY,CAAC;iBACf,IAAI,CAAC,GAAG,EAAE;gBACT,MAAM,CACJ,IAAI,KAAK,CAAC,uDAAuD,CAAC,CACnE,CAAC;YACJ,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,GAAQ,EAAE,EAAE;gBAClB,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC,CAAC,CAAC;YACL,OAAO;QACT,CAAC;QAGD,IAAI,SAAgC,CAAC;QAErC,SAAS,gBAAgB;YACvB,IAAI,SAAS,EAAE,CAAC;gBACd,YAAY,CAAC,SAAS,CAAC,CAAC;YAC1B,CAAC;YACD,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC;gBACvB,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;YAChD,CAAC;YACD,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YACvC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACnC,CAAC;QAED,SAAS,MAAM,CAAC,QAAuB;YACrC,IAAI,QAAQ,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;gBAC7B,gBAAgB,EAAE,CAAC;gBACnB,MAAM,CAAC,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;QAID,KAAK,UAAU,YAAY,CAAC,KAAY;YACtC,gBAAgB,EAAE,CAAC;YACnB,MAAM,IAAI,CAAC,YAAY,CAAC,CAAC;YACzB,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC;QAED,KAAK,UAAU,SAAS;YACtB,gBAAgB,EAAE,CAAC;YACnB,MAAM,IAAI,CAAC,YAAY,CAAC,CAAC;YACzB,MAAM,CAAC,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC,CAAC;QAC1E,CAAC;QAED,SAAS,SAAS,CAAC,IAAkB;YACnC,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;gBACxB,gBAAgB,EAAE,CAAC;gBACnB,OAAO,CAAC,YAAY,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;QAED,YAAY,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACtC,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAChC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QAE7C,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9B,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACzE,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QAEzB,SAAS;YACP,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC;AAjFD,uCAiFC"}
@@ -1,84 +0,0 @@
1
- import path from 'path';
2
- import type { ChildProcess } from 'child_process';
3
- import { fork, spawn } from 'child_process';
4
- import type { Caller } from './rpc';
5
- import { cancel, createCaller } from './rpc';
6
- import { expect } from 'chai';
7
- import type { WorkerRuntime } from './worker-runtime';
8
- import { once } from 'events';
9
- import { promisify } from 'util';
10
- import { dummyOptions } from './index.spec';
11
-
12
- const childProcessModulePath = path.resolve(
13
- __dirname,
14
- '..',
15
- 'dist',
16
- 'child-process-proxy.js'
17
- );
18
-
19
- describe('child process worker proxy', function () {
20
- let caller: Caller<WorkerRuntime>;
21
- let childProcess: ChildProcess;
22
-
23
- afterEach(function () {
24
- if (caller) {
25
- caller[cancel]();
26
- caller = null;
27
- }
28
-
29
- if (childProcess) {
30
- childProcess.disconnect();
31
- childProcess = null;
32
- }
33
- });
34
-
35
- it('should start worker runtime and proxy calls', async function () {
36
- childProcess = fork(childProcessModulePath);
37
- caller = createCaller(['init', 'evaluate'], childProcess);
38
- await caller.init('mongodb://nodb/', dummyOptions, { nodb: true });
39
- const result = await caller.evaluate('1 + 1');
40
- expect(result.printable).to.equal(2);
41
- });
42
-
43
- it('should exit on its own when the parent process disconnects', async function () {
44
- const intermediateProcess = spawn(
45
- process.execPath,
46
- [
47
- '-e',
48
- `require("child_process")
49
- .fork(${JSON.stringify(childProcessModulePath)})
50
- .on("message", function(m) { console.log("message " + m + " from " + this.pid) })`,
51
- ],
52
- { stdio: ['pipe', 'pipe', 'inherit'] }
53
- );
54
-
55
- // Make sure the outer child process runs and has created the inner child process
56
- const [message] = await once(
57
- intermediateProcess.stdout.setEncoding('utf8'),
58
- 'data'
59
- );
60
- const match = message.trim().match(/^message ready from (?<pid>\d+)$/);
61
- expect(match).to.not.equal(null);
62
-
63
- // Make sure the inner child process runs
64
- const childPid = +match.groups.pid;
65
- process.kill(childPid, 0);
66
-
67
- // Kill the intermediate process and wait for the inner child process to also close
68
- intermediateProcess.kill('SIGTERM');
69
- let innerChildHasStoppedRunning = false;
70
- for (let i = 0; i < 200; i++) {
71
- try {
72
- process.kill(childPid, 0);
73
- } catch (err) {
74
- if (err.code === 'ESRCH') {
75
- innerChildHasStoppedRunning = true;
76
- break;
77
- }
78
- throw err;
79
- }
80
- await promisify(setTimeout)(10);
81
- }
82
- expect(innerChildHasStoppedRunning).to.equal(true);
83
- });
84
- });