mqtt-plus 0.9.18 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
  ChangeLog
3
3
  =========
4
4
 
5
+ 1.0.0 (2026-01-25)
6
+ ------------------
7
+
8
+ - CLEANUP: various code cleanups
9
+
5
10
  0.9.18 (2026-01-25)
6
11
  -------------------
7
12
 
@@ -35,7 +35,7 @@ export class BaseTrait extends MsgTrait {
35
35
  if (prop === "isFakeProxy")
36
36
  return true;
37
37
  else
38
- return (...args) => { };
38
+ return () => { };
39
39
  }
40
40
  });
41
41
  /* store MQTT client */
@@ -86,9 +86,7 @@ export default class Codec {
86
86
  }
87
87
  decode(data) {
88
88
  let result;
89
- if (this.type === "cbor"
90
- && typeof data === "object"
91
- && data instanceof Uint8Array) {
89
+ if (this.type === "cbor" && data instanceof Uint8Array) {
92
90
  try {
93
91
  result = CBOR.decode(data, { tags: this.tags });
94
92
  }
@@ -1,11 +1,12 @@
1
1
  import { APISchema } from "./mqtt-plus-api";
2
2
  import { CodecTrait } from "./mqtt-plus-codec";
3
+ type MessageType = "event-emission" | "service-call-request" | "service-call-response" | "resource-transfer-request" | "resource-transfer-response";
3
4
  declare class Base {
4
- type: string;
5
+ type: MessageType;
5
6
  id: string;
6
7
  sender?: string | undefined;
7
8
  receiver?: string | undefined;
8
- constructor(type: string, id: string, sender?: string | undefined, receiver?: string | undefined);
9
+ constructor(type: MessageType, id: string, sender?: string | undefined, receiver?: string | undefined);
9
10
  }
10
11
  export declare class EventEmission extends Base {
11
12
  event: string;
@@ -153,7 +153,7 @@ class Msg {
153
153
  else if (obj.type === "resource-transfer-response") {
154
154
  if (obj.resource !== undefined && typeof obj.resource !== "string")
155
155
  throw new Error("invalid ResourceTransferResponse object: \"resource\" field must be a string");
156
- if (obj.chunk !== undefined && typeof obj.chunk !== "object")
156
+ if (obj.chunk !== undefined && (obj.chunk === null || typeof obj.chunk !== "object"))
157
157
  throw new Error("invalid ResourceTransferResponse object: \"chunk\" field must be an object");
158
158
  if (obj.meta !== undefined && (typeof obj.meta !== "object" || obj.meta === null || Array.isArray(obj.meta)))
159
159
  throw new Error("invalid ResourceTransferResponse object: \"meta\" field must be an object");
@@ -195,8 +195,7 @@ export class ResourceTrait extends ServiceTrait {
195
195
  };
196
196
  /* start timeout handler */
197
197
  timer = setTimeout(() => {
198
- cleanup();
199
- metaResolve?.(undefined);
198
+ cleanup(true);
200
199
  stream.destroy(new Error("communication timeout"));
201
200
  }, this.options.timeout);
202
201
  /* register stream handler to collect chunks */
@@ -204,12 +203,13 @@ export class ResourceTrait extends ServiceTrait {
204
203
  this.callbacks.set(requestId, {
205
204
  resource,
206
205
  callback: (error, chunk, meta, final) => {
206
+ const wasFirstChunk = firstChunk;
207
207
  if (firstChunk) {
208
208
  firstChunk = false;
209
209
  metaResolve?.(meta);
210
210
  }
211
211
  if (error !== undefined) {
212
- cleanup(true);
212
+ cleanup(!wasFirstChunk);
213
213
  stream.destroy(error);
214
214
  }
215
215
  else {
@@ -271,7 +271,7 @@ export class ResourceTrait extends ServiceTrait {
271
271
  if (info.stream instanceof Readable)
272
272
  sendStreamAsChunks(info.stream, this.options.chunkSize, sendChunk, () => { }, (err) => sendChunk(undefined, err.message, true));
273
273
  /* handle Buffer result */
274
- else if (info.buffer !== undefined && typeof info.buffer.then === "function")
274
+ else if (info.buffer instanceof Promise)
275
275
  sendBufferAsChunks(await info.buffer, this.options.chunkSize, sendChunk);
276
276
  /* fail */
277
277
  else
@@ -161,7 +161,7 @@ class Codec {
161
161
  }
162
162
  decode(data) {
163
163
  let result;
164
- if (this.type === "cbor" && typeof data === "object" && data instanceof Uint8Array) {
164
+ if (this.type === "cbor" && data instanceof Uint8Array) {
165
165
  try {
166
166
  result = CBOR__namespace.decode(data, { tags: this.tags });
167
167
  } catch (_ex) {
@@ -298,7 +298,7 @@ class Msg {
298
298
  } else if (obj.type === "resource-transfer-response") {
299
299
  if (obj.resource !== void 0 && typeof obj.resource !== "string")
300
300
  throw new Error('invalid ResourceTransferResponse object: "resource" field must be a string');
301
- if (obj.chunk !== void 0 && typeof obj.chunk !== "object")
301
+ if (obj.chunk !== void 0 && (obj.chunk === null || typeof obj.chunk !== "object"))
302
302
  throw new Error('invalid ResourceTransferResponse object: "chunk" field must be an object');
303
303
  if (obj.meta !== void 0 && (typeof obj.meta !== "object" || obj.meta === null || Array.isArray(obj.meta)))
304
304
  throw new Error('invalid ResourceTransferResponse object: "meta" field must be an object');
@@ -342,7 +342,7 @@ class BaseTrait extends MsgTrait {
342
342
  if (prop === "isFakeProxy")
343
343
  return true;
344
344
  else
345
- return (...args) => {
345
+ return () => {
346
346
  };
347
347
  }
348
348
  });
@@ -822,20 +822,20 @@ class ResourceTrait extends ServiceTrait {
822
822
  metaResolve?.(void 0);
823
823
  };
824
824
  timer = setTimeout(() => {
825
- cleanup();
826
- metaResolve?.(void 0);
825
+ cleanup(true);
827
826
  stream.destroy(new Error("communication timeout"));
828
827
  }, this.options.timeout);
829
828
  let firstChunk = true;
830
829
  this.callbacks.set(requestId, {
831
830
  resource,
832
831
  callback: (error, chunk, meta2, final) => {
832
+ const wasFirstChunk = firstChunk;
833
833
  if (firstChunk) {
834
834
  firstChunk = false;
835
835
  metaResolve?.(meta2);
836
836
  }
837
837
  if (error !== void 0) {
838
- cleanup(true);
838
+ cleanup(!wasFirstChunk);
839
839
  stream.destroy(error);
840
840
  } else {
841
841
  if (chunk !== void 0)
@@ -882,7 +882,7 @@ class ResourceTrait extends ServiceTrait {
882
882
  if (info.stream instanceof node_stream.Readable)
883
883
  sendStreamAsChunks(info.stream, this.options.chunkSize, sendChunk, () => {
884
884
  }, (err) => sendChunk(void 0, err.message, true));
885
- else if (info.buffer !== void 0 && typeof info.buffer.then === "function")
885
+ else if (info.buffer instanceof Promise)
886
886
  sendBufferAsChunks(await info.buffer, this.options.chunkSize, sendChunk);
887
887
  else
888
888
  throw new Error("handler did not provide data via info.stream or info.buffer field");
@@ -143,7 +143,7 @@ class Codec {
143
143
  }
144
144
  decode(data) {
145
145
  let result;
146
- if (this.type === "cbor" && typeof data === "object" && data instanceof Uint8Array) {
146
+ if (this.type === "cbor" && data instanceof Uint8Array) {
147
147
  try {
148
148
  result = CBOR.decode(data, { tags: this.tags });
149
149
  } catch (_ex) {
@@ -280,7 +280,7 @@ class Msg {
280
280
  } else if (obj.type === "resource-transfer-response") {
281
281
  if (obj.resource !== void 0 && typeof obj.resource !== "string")
282
282
  throw new Error('invalid ResourceTransferResponse object: "resource" field must be a string');
283
- if (obj.chunk !== void 0 && typeof obj.chunk !== "object")
283
+ if (obj.chunk !== void 0 && (obj.chunk === null || typeof obj.chunk !== "object"))
284
284
  throw new Error('invalid ResourceTransferResponse object: "chunk" field must be an object');
285
285
  if (obj.meta !== void 0 && (typeof obj.meta !== "object" || obj.meta === null || Array.isArray(obj.meta)))
286
286
  throw new Error('invalid ResourceTransferResponse object: "meta" field must be an object');
@@ -324,7 +324,7 @@ class BaseTrait extends MsgTrait {
324
324
  if (prop === "isFakeProxy")
325
325
  return true;
326
326
  else
327
- return (...args) => {
327
+ return () => {
328
328
  };
329
329
  }
330
330
  });
@@ -804,20 +804,20 @@ class ResourceTrait extends ServiceTrait {
804
804
  metaResolve?.(void 0);
805
805
  };
806
806
  timer = setTimeout(() => {
807
- cleanup();
808
- metaResolve?.(void 0);
807
+ cleanup(true);
809
808
  stream.destroy(new Error("communication timeout"));
810
809
  }, this.options.timeout);
811
810
  let firstChunk = true;
812
811
  this.callbacks.set(requestId, {
813
812
  resource,
814
813
  callback: (error, chunk, meta2, final) => {
814
+ const wasFirstChunk = firstChunk;
815
815
  if (firstChunk) {
816
816
  firstChunk = false;
817
817
  metaResolve?.(meta2);
818
818
  }
819
819
  if (error !== void 0) {
820
- cleanup(true);
820
+ cleanup(!wasFirstChunk);
821
821
  stream.destroy(error);
822
822
  } else {
823
823
  if (chunk !== void 0)
@@ -864,7 +864,7 @@ class ResourceTrait extends ServiceTrait {
864
864
  if (info.stream instanceof Readable)
865
865
  sendStreamAsChunks(info.stream, this.options.chunkSize, sendChunk, () => {
866
866
  }, (err) => sendChunk(void 0, err.message, true));
867
- else if (info.buffer !== void 0 && typeof info.buffer.then === "function")
867
+ else if (info.buffer instanceof Promise)
868
868
  sendBufferAsChunks(await info.buffer, this.options.chunkSize, sendChunk);
869
869
  else
870
870
  throw new Error("handler did not provide data via info.stream or info.buffer field");
@@ -1,4 +1,4 @@
1
- (function(ut,Qe){typeof exports=="object"&&typeof module<"u"?module.exports=Qe():typeof define=="function"&&define.amd?define(Qe):(ut=typeof globalThis<"u"?globalThis:ut||self,ut.MQTTp=Qe())})(this,(function(){"use strict";var ut={},Qe={};Qe.byteLength=pi,Qe.toByteArray=gi,Qe.fromByteArray=mi;for(var $e=[],Le=[],hi=typeof Uint8Array<"u"?Uint8Array:Array,Qt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",dt=0,di=Qt.length;dt<di;++dt)$e[dt]=Qt[dt],Le[Qt.charCodeAt(dt)]=dt;Le[45]=62,Le[95]=63;function Pr(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var o=r===e?0:4-r%4;return[r,o]}function pi(t){var e=Pr(t),r=e[0],o=e[1];return(r+o)*3/4-o}function yi(t,e,r){return(e+r)*3/4-r}function gi(t){var e,r=Pr(t),o=r[0],f=r[1],u=new hi(yi(t,o,f)),c=0,p=f>0?o-4:o,y;for(y=0;y<p;y+=4)e=Le[t.charCodeAt(y)]<<18|Le[t.charCodeAt(y+1)]<<12|Le[t.charCodeAt(y+2)]<<6|Le[t.charCodeAt(y+3)],u[c++]=e>>16&255,u[c++]=e>>8&255,u[c++]=e&255;return f===2&&(e=Le[t.charCodeAt(y)]<<2|Le[t.charCodeAt(y+1)]>>4,u[c++]=e&255),f===1&&(e=Le[t.charCodeAt(y)]<<10|Le[t.charCodeAt(y+1)]<<4|Le[t.charCodeAt(y+2)]>>2,u[c++]=e>>8&255,u[c++]=e&255),u}function wi(t){return $e[t>>18&63]+$e[t>>12&63]+$e[t>>6&63]+$e[t&63]}function Ei(t,e,r){for(var o,f=[],u=e;u<r;u+=3)o=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(t[u+2]&255),f.push(wi(o));return f.join("")}function mi(t){for(var e,r=t.length,o=r%3,f=[],u=16383,c=0,p=r-o;c<p;c+=u)f.push(Ei(t,c,c+u>p?p:c+u));return o===1?(e=t[r-1],f.push($e[e>>2]+$e[e<<4&63]+"==")):o===2&&(e=(t[r-2]<<8)+t[r-1],f.push($e[e>>10]+$e[e>>4&63]+$e[e<<2&63]+"=")),f.join("")}var er={};er.read=function(t,e,r,o,f){var u,c,p=f*8-o-1,y=(1<<p)-1,b=y>>1,d=-7,I=r?f-1:0,B=r?-1:1,q=t[e+I];for(I+=B,u=q&(1<<-d)-1,q>>=-d,d+=p;d>0;u=u*256+t[e+I],I+=B,d-=8);for(c=u&(1<<-d)-1,u>>=-d,d+=o;d>0;c=c*256+t[e+I],I+=B,d-=8);if(u===0)u=1-b;else{if(u===y)return c?NaN:(q?-1:1)*(1/0);c=c+Math.pow(2,o),u=u-b}return(q?-1:1)*c*Math.pow(2,u-o)},er.write=function(t,e,r,o,f,u){var c,p,y,b=u*8-f-1,d=(1<<b)-1,I=d>>1,B=f===23?Math.pow(2,-24)-Math.pow(2,-77):0,q=o?0:u-1,P=o?1:-1,W=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(p=isNaN(e)?1:0,c=d):(c=Math.floor(Math.log(e)/Math.LN2),e*(y=Math.pow(2,-c))<1&&(c--,y*=2),c+I>=1?e+=B/y:e+=B*Math.pow(2,1-I),e*y>=2&&(c++,y/=2),c+I>=d?(p=0,c=d):c+I>=1?(p=(e*y-1)*Math.pow(2,f),c=c+I):(p=e*Math.pow(2,I-1)*Math.pow(2,f),c=0));f>=8;t[r+q]=p&255,q+=P,p/=256,f-=8);for(c=c<<f|p,b+=f;b>0;t[r+q]=c&255,q+=P,c/=256,b-=8);t[r+q-P]|=W*128};(function(t){const e=Qe,r=er,o=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=d,t.SlowBuffer=v,t.INSPECT_MAX_BYTES=50;const f=2147483647;t.kMaxLength=f;const{Uint8Array:u,ArrayBuffer:c,SharedArrayBuffer:p}=globalThis;d.TYPED_ARRAY_SUPPORT=y(),!d.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function y(){try{const l=new u(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,u.prototype),Object.setPrototypeOf(l,n),l.foo()===42}catch{return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}}),Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function b(l){if(l>f)throw new RangeError('The value "'+l+'" is invalid for option "size"');const n=new u(l);return Object.setPrototypeOf(n,d.prototype),n}function d(l,n,s){if(typeof l=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return P(l)}return I(l,n,s)}d.poolSize=8192;function I(l,n,s){if(typeof l=="string")return W(l,n);if(c.isView(l))return x(l);if(l==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof l);if(Re(l,c)||l&&Re(l.buffer,c)||typeof p<"u"&&(Re(l,p)||l&&Re(l.buffer,p)))return R(l,n,s);if(typeof l=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const g=l.valueOf&&l.valueOf();if(g!=null&&g!==l)return d.from(g,n,s);const T=A(l);if(T)return T;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof l[Symbol.toPrimitive]=="function")return d.from(l[Symbol.toPrimitive]("string"),n,s);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof l)}d.from=function(l,n,s){return I(l,n,s)},Object.setPrototypeOf(d.prototype,u.prototype),Object.setPrototypeOf(d,u);function B(l){if(typeof l!="number")throw new TypeError('"size" argument must be of type number');if(l<0)throw new RangeError('The value "'+l+'" is invalid for option "size"')}function q(l,n,s){return B(l),l<=0?b(l):n!==void 0?typeof s=="string"?b(l).fill(n,s):b(l).fill(n):b(l)}d.alloc=function(l,n,s){return q(l,n,s)};function P(l){return B(l),b(l<0?0:_(l)|0)}d.allocUnsafe=function(l){return P(l)},d.allocUnsafeSlow=function(l){return P(l)};function W(l,n){if((typeof n!="string"||n==="")&&(n="utf8"),!d.isEncoding(n))throw new TypeError("Unknown encoding: "+n);const s=U(l,n)|0;let g=b(s);const T=g.write(l,n);return T!==s&&(g=g.slice(0,T)),g}function j(l){const n=l.length<0?0:_(l.length)|0,s=b(n);for(let g=0;g<n;g+=1)s[g]=l[g]&255;return s}function x(l){if(Re(l,u)){const n=new u(l);return R(n.buffer,n.byteOffset,n.byteLength)}return j(l)}function R(l,n,s){if(n<0||l.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(l.byteLength<n+(s||0))throw new RangeError('"length" is outside of buffer bounds');let g;return n===void 0&&s===void 0?g=new u(l):s===void 0?g=new u(l,n):g=new u(l,n,s),Object.setPrototypeOf(g,d.prototype),g}function A(l){if(d.isBuffer(l)){const n=_(l.length)|0,s=b(n);return s.length===0||l.copy(s,0,0,n),s}if(l.length!==void 0)return typeof l.length!="number"||Oe(l.length)?b(0):j(l);if(l.type==="Buffer"&&Array.isArray(l.data))return j(l.data)}function _(l){if(l>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return l|0}function v(l){return+l!=l&&(l=0),d.alloc(+l)}d.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==d.prototype},d.compare=function(n,s){if(Re(n,u)&&(n=d.from(n,n.offset,n.byteLength)),Re(s,u)&&(s=d.from(s,s.offset,s.byteLength)),!d.isBuffer(n)||!d.isBuffer(s))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===s)return 0;let g=n.length,T=s.length;for(let M=0,C=Math.min(g,T);M<C;++M)if(n[M]!==s[M]){g=n[M],T=s[M];break}return g<T?-1:T<g?1:0},d.isEncoding=function(n){switch(String(n).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},d.concat=function(n,s){if(!Array.isArray(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return d.alloc(0);let g;if(s===void 0)for(s=0,g=0;g<n.length;++g)s+=n[g].length;const T=d.allocUnsafe(s);let M=0;for(g=0;g<n.length;++g){let C=n[g];if(Re(C,u))M+C.length>T.length?(d.isBuffer(C)||(C=d.from(C)),C.copy(T,M)):u.prototype.set.call(T,C,M);else if(d.isBuffer(C))C.copy(T,M);else throw new TypeError('"list" argument must be an Array of Buffers');M+=C.length}return T};function U(l,n){if(d.isBuffer(l))return l.length;if(c.isView(l)||Re(l,c))return l.byteLength;if(typeof l!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof l);const s=l.length,g=arguments.length>2&&arguments[2]===!0;if(!g&&s===0)return 0;let T=!1;for(;;)switch(n){case"ascii":case"latin1":case"binary":return s;case"utf8":case"utf-8":return ot(l).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s*2;case"hex":return s>>>1;case"base64":return _e(l).length;default:if(T)return g?-1:ot(l).length;n=(""+n).toLowerCase(),T=!0}}d.byteLength=U;function k(l,n,s){let g=!1;if((n===void 0||n<0)&&(n=0),n>this.length||((s===void 0||s>this.length)&&(s=this.length),s<=0)||(s>>>=0,n>>>=0,s<=n))return"";for(l||(l="utf8");;)switch(l){case"hex":return Ke(this,n,s);case"utf8":case"utf-8":return Ae(this,n,s);case"ascii":return He(this,n,s);case"latin1":case"binary":return ht(this,n,s);case"base64":return Ue(this,n,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ke(this,n,s);default:if(g)throw new TypeError("Unknown encoding: "+l);l=(l+"").toLowerCase(),g=!0}}d.prototype._isBuffer=!0;function D(l,n,s){const g=l[n];l[n]=l[s],l[s]=g}d.prototype.swap16=function(){const n=this.length;if(n%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let s=0;s<n;s+=2)D(this,s,s+1);return this},d.prototype.swap32=function(){const n=this.length;if(n%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let s=0;s<n;s+=4)D(this,s,s+3),D(this,s+1,s+2);return this},d.prototype.swap64=function(){const n=this.length;if(n%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let s=0;s<n;s+=8)D(this,s,s+7),D(this,s+1,s+6),D(this,s+2,s+5),D(this,s+3,s+4);return this},d.prototype.toString=function(){const n=this.length;return n===0?"":arguments.length===0?Ae(this,0,n):k.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function(n){if(!d.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:d.compare(this,n)===0},d.prototype.inspect=function(){let n="";const s=t.INSPECT_MAX_BYTES;return n=this.toString("hex",0,s).replace(/(.{2})/g,"$1 ").trim(),this.length>s&&(n+=" ... "),"<Buffer "+n+">"},o&&(d.prototype[o]=d.prototype.inspect),d.prototype.compare=function(n,s,g,T,M){if(Re(n,u)&&(n=d.from(n,n.offset,n.byteLength)),!d.isBuffer(n))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof n);if(s===void 0&&(s=0),g===void 0&&(g=n?n.length:0),T===void 0&&(T=0),M===void 0&&(M=this.length),s<0||g>n.length||T<0||M>this.length)throw new RangeError("out of range index");if(T>=M&&s>=g)return 0;if(T>=M)return-1;if(s>=g)return 1;if(s>>>=0,g>>>=0,T>>>=0,M>>>=0,this===n)return 0;let C=M-T,te=g-s;const le=Math.min(C,te),he=this.slice(T,M),pe=n.slice(s,g);for(let se=0;se<le;++se)if(he[se]!==pe[se]){C=he[se],te=pe[se];break}return C<te?-1:te<C?1:0};function H(l,n,s,g,T){if(l.length===0)return-1;if(typeof s=="string"?(g=s,s=0):s>2147483647?s=2147483647:s<-2147483648&&(s=-2147483648),s=+s,Oe(s)&&(s=T?0:l.length-1),s<0&&(s=l.length+s),s>=l.length){if(T)return-1;s=l.length-1}else if(s<0)if(T)s=0;else return-1;if(typeof n=="string"&&(n=d.from(n,g)),d.isBuffer(n))return n.length===0?-1:z(l,n,s,g,T);if(typeof n=="number")return n=n&255,typeof u.prototype.indexOf=="function"?T?u.prototype.indexOf.call(l,n,s):u.prototype.lastIndexOf.call(l,n,s):z(l,[n],s,g,T);throw new TypeError("val must be string, number or Buffer")}function z(l,n,s,g,T){let M=1,C=l.length,te=n.length;if(g!==void 0&&(g=String(g).toLowerCase(),g==="ucs2"||g==="ucs-2"||g==="utf16le"||g==="utf-16le")){if(l.length<2||n.length<2)return-1;M=2,C/=2,te/=2,s/=2}function le(pe,se){return M===1?pe[se]:pe.readUInt16BE(se*M)}let he;if(T){let pe=-1;for(he=s;he<C;he++)if(le(l,he)===le(n,pe===-1?0:he-pe)){if(pe===-1&&(pe=he),he-pe+1===te)return pe*M}else pe!==-1&&(he-=he-pe),pe=-1}else for(s+te>C&&(s=C-te),he=s;he>=0;he--){let pe=!0;for(let se=0;se<te;se++)if(le(l,he+se)!==le(n,se)){pe=!1;break}if(pe)return he}return-1}d.prototype.includes=function(n,s,g){return this.indexOf(n,s,g)!==-1},d.prototype.indexOf=function(n,s,g){return H(this,n,s,g,!0)},d.prototype.lastIndexOf=function(n,s,g){return H(this,n,s,g,!1)};function re(l,n,s,g){s=Number(s)||0;const T=l.length-s;g?(g=Number(g),g>T&&(g=T)):g=T;const M=n.length;g>M/2&&(g=M/2);let C;for(C=0;C<g;++C){const te=parseInt(n.substr(C*2,2),16);if(Oe(te))return C;l[s+C]=te}return C}function N(l,n,s,g){return Pe(ot(n,l.length-s),l,s,g)}function ae(l,n,s,g){return Pe(Nt(n),l,s,g)}function ve(l,n,s,g){return Pe(_e(n),l,s,g)}function xe(l,n,s,g){return Pe(ge(n,l.length-s),l,s,g)}d.prototype.write=function(n,s,g,T){if(s===void 0)T="utf8",g=this.length,s=0;else if(g===void 0&&typeof s=="string")T=s,g=this.length,s=0;else if(isFinite(s))s=s>>>0,isFinite(g)?(g=g>>>0,T===void 0&&(T="utf8")):(T=g,g=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const M=this.length-s;if((g===void 0||g>M)&&(g=M),n.length>0&&(g<0||s<0)||s>this.length)throw new RangeError("Attempt to write outside buffer bounds");T||(T="utf8");let C=!1;for(;;)switch(T){case"hex":return re(this,n,s,g);case"utf8":case"utf-8":return N(this,n,s,g);case"ascii":case"latin1":case"binary":return ae(this,n,s,g);case"base64":return ve(this,n,s,g);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xe(this,n,s,g);default:if(C)throw new TypeError("Unknown encoding: "+T);T=(""+T).toLowerCase(),C=!0}},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ue(l,n,s){return n===0&&s===l.length?e.fromByteArray(l):e.fromByteArray(l.slice(n,s))}function Ae(l,n,s){s=Math.min(l.length,s);const g=[];let T=n;for(;T<s;){const M=l[T];let C=null,te=M>239?4:M>223?3:M>191?2:1;if(T+te<=s){let le,he,pe,se;switch(te){case 1:M<128&&(C=M);break;case 2:le=l[T+1],(le&192)===128&&(se=(M&31)<<6|le&63,se>127&&(C=se));break;case 3:le=l[T+1],he=l[T+2],(le&192)===128&&(he&192)===128&&(se=(M&15)<<12|(le&63)<<6|he&63,se>2047&&(se<55296||se>57343)&&(C=se));break;case 4:le=l[T+1],he=l[T+2],pe=l[T+3],(le&192)===128&&(he&192)===128&&(pe&192)===128&&(se=(M&15)<<18|(le&63)<<12|(he&63)<<6|pe&63,se>65535&&se<1114112&&(C=se))}}C===null?(C=65533,te=1):C>65535&&(C-=65536,g.push(C>>>10&1023|55296),C=56320|C&1023),g.push(C),T+=te}return We(g)}const De=4096;function We(l){const n=l.length;if(n<=De)return String.fromCharCode.apply(String,l);let s="",g=0;for(;g<n;)s+=String.fromCharCode.apply(String,l.slice(g,g+=De));return s}function He(l,n,s){let g="";s=Math.min(l.length,s);for(let T=n;T<s;++T)g+=String.fromCharCode(l[T]&127);return g}function ht(l,n,s){let g="";s=Math.min(l.length,s);for(let T=n;T<s;++T)g+=String.fromCharCode(l[T]);return g}function Ke(l,n,s){const g=l.length;(!n||n<0)&&(n=0),(!s||s<0||s>g)&&(s=g);let T="";for(let M=n;M<s;++M)T+=Ce[l[M]];return T}function ke(l,n,s){const g=l.slice(n,s);let T="";for(let M=0;M<g.length-1;M+=2)T+=String.fromCharCode(g[M]+g[M+1]*256);return T}d.prototype.slice=function(n,s){const g=this.length;n=~~n,s=s===void 0?g:~~s,n<0?(n+=g,n<0&&(n=0)):n>g&&(n=g),s<0?(s+=g,s<0&&(s=0)):s>g&&(s=g),s<n&&(s=n);const T=this.subarray(n,s);return Object.setPrototypeOf(T,d.prototype),T};function de(l,n,s){if(l%1!==0||l<0)throw new RangeError("offset is not uint");if(l+n>s)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(n,s,g){n=n>>>0,s=s>>>0,g||de(n,s,this.length);let T=this[n],M=1,C=0;for(;++C<s&&(M*=256);)T+=this[n+C]*M;return T},d.prototype.readUintBE=d.prototype.readUIntBE=function(n,s,g){n=n>>>0,s=s>>>0,g||de(n,s,this.length);let T=this[n+--s],M=1;for(;s>0&&(M*=256);)T+=this[n+--s]*M;return T},d.prototype.readUint8=d.prototype.readUInt8=function(n,s){return n=n>>>0,s||de(n,1,this.length),this[n]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(n,s){return n=n>>>0,s||de(n,2,this.length),this[n]|this[n+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(n,s){return n=n>>>0,s||de(n,2,this.length),this[n]<<8|this[n+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(n,s){return n=n>>>0,s||de(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},d.prototype.readUint32BE=d.prototype.readUInt32BE=function(n,s){return n=n>>>0,s||de(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},d.prototype.readBigUInt64LE=Se(function(n){n=n>>>0,J(n,"offset");const s=this[n],g=this[n+7];(s===void 0||g===void 0)&&oe(n,this.length-8);const T=s+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24,M=this[++n]+this[++n]*2**8+this[++n]*2**16+g*2**24;return BigInt(T)+(BigInt(M)<<BigInt(32))}),d.prototype.readBigUInt64BE=Se(function(n){n=n>>>0,J(n,"offset");const s=this[n],g=this[n+7];(s===void 0||g===void 0)&&oe(n,this.length-8);const T=s*2**24+this[++n]*2**16+this[++n]*2**8+this[++n],M=this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+g;return(BigInt(T)<<BigInt(32))+BigInt(M)}),d.prototype.readIntLE=function(n,s,g){n=n>>>0,s=s>>>0,g||de(n,s,this.length);let T=this[n],M=1,C=0;for(;++C<s&&(M*=256);)T+=this[n+C]*M;return M*=128,T>=M&&(T-=Math.pow(2,8*s)),T},d.prototype.readIntBE=function(n,s,g){n=n>>>0,s=s>>>0,g||de(n,s,this.length);let T=s,M=1,C=this[n+--T];for(;T>0&&(M*=256);)C+=this[n+--T]*M;return M*=128,C>=M&&(C-=Math.pow(2,8*s)),C},d.prototype.readInt8=function(n,s){return n=n>>>0,s||de(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},d.prototype.readInt16LE=function(n,s){n=n>>>0,s||de(n,2,this.length);const g=this[n]|this[n+1]<<8;return g&32768?g|4294901760:g},d.prototype.readInt16BE=function(n,s){n=n>>>0,s||de(n,2,this.length);const g=this[n+1]|this[n]<<8;return g&32768?g|4294901760:g},d.prototype.readInt32LE=function(n,s){return n=n>>>0,s||de(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},d.prototype.readInt32BE=function(n,s){return n=n>>>0,s||de(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},d.prototype.readBigInt64LE=Se(function(n){n=n>>>0,J(n,"offset");const s=this[n],g=this[n+7];(s===void 0||g===void 0)&&oe(n,this.length-8);const T=this[n+4]+this[n+5]*2**8+this[n+6]*2**16+(g<<24);return(BigInt(T)<<BigInt(32))+BigInt(s+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24)}),d.prototype.readBigInt64BE=Se(function(n){n=n>>>0,J(n,"offset");const s=this[n],g=this[n+7];(s===void 0||g===void 0)&&oe(n,this.length-8);const T=(s<<24)+this[++n]*2**16+this[++n]*2**8+this[++n];return(BigInt(T)<<BigInt(32))+BigInt(this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+g)}),d.prototype.readFloatLE=function(n,s){return n=n>>>0,s||de(n,4,this.length),r.read(this,n,!0,23,4)},d.prototype.readFloatBE=function(n,s){return n=n>>>0,s||de(n,4,this.length),r.read(this,n,!1,23,4)},d.prototype.readDoubleLE=function(n,s){return n=n>>>0,s||de(n,8,this.length),r.read(this,n,!0,52,8)},d.prototype.readDoubleBE=function(n,s){return n=n>>>0,s||de(n,8,this.length),r.read(this,n,!1,52,8)};function Te(l,n,s,g,T,M){if(!d.isBuffer(l))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>T||n<M)throw new RangeError('"value" argument is out of bounds');if(s+g>l.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(n,s,g,T){if(n=+n,s=s>>>0,g=g>>>0,!T){const te=Math.pow(2,8*g)-1;Te(this,n,s,g,te,0)}let M=1,C=0;for(this[s]=n&255;++C<g&&(M*=256);)this[s+C]=n/M&255;return s+g},d.prototype.writeUintBE=d.prototype.writeUIntBE=function(n,s,g,T){if(n=+n,s=s>>>0,g=g>>>0,!T){const te=Math.pow(2,8*g)-1;Te(this,n,s,g,te,0)}let M=g-1,C=1;for(this[s+M]=n&255;--M>=0&&(C*=256);)this[s+M]=n/C&255;return s+g},d.prototype.writeUint8=d.prototype.writeUInt8=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,1,255,0),this[s]=n&255,s+1},d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,2,65535,0),this[s]=n&255,this[s+1]=n>>>8,s+2},d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,2,65535,0),this[s]=n>>>8,this[s+1]=n&255,s+2},d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,4,4294967295,0),this[s+3]=n>>>24,this[s+2]=n>>>16,this[s+1]=n>>>8,this[s]=n&255,s+4},d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,4,4294967295,0),this[s]=n>>>24,this[s+1]=n>>>16,this[s+2]=n>>>8,this[s+3]=n&255,s+4};function L(l,n,s,g,T){ue(n,g,T,l,s,7);let M=Number(n&BigInt(4294967295));l[s++]=M,M=M>>8,l[s++]=M,M=M>>8,l[s++]=M,M=M>>8,l[s++]=M;let C=Number(n>>BigInt(32)&BigInt(4294967295));return l[s++]=C,C=C>>8,l[s++]=C,C=C>>8,l[s++]=C,C=C>>8,l[s++]=C,s}function F(l,n,s,g,T){ue(n,g,T,l,s,7);let M=Number(n&BigInt(4294967295));l[s+7]=M,M=M>>8,l[s+6]=M,M=M>>8,l[s+5]=M,M=M>>8,l[s+4]=M;let C=Number(n>>BigInt(32)&BigInt(4294967295));return l[s+3]=C,C=C>>8,l[s+2]=C,C=C>>8,l[s+1]=C,C=C>>8,l[s]=C,s+8}d.prototype.writeBigUInt64LE=Se(function(n,s=0){return L(this,n,s,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeBigUInt64BE=Se(function(n,s=0){return F(this,n,s,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeIntLE=function(n,s,g,T){if(n=+n,s=s>>>0,!T){const le=Math.pow(2,8*g-1);Te(this,n,s,g,le-1,-le)}let M=0,C=1,te=0;for(this[s]=n&255;++M<g&&(C*=256);)n<0&&te===0&&this[s+M-1]!==0&&(te=1),this[s+M]=(n/C>>0)-te&255;return s+g},d.prototype.writeIntBE=function(n,s,g,T){if(n=+n,s=s>>>0,!T){const le=Math.pow(2,8*g-1);Te(this,n,s,g,le-1,-le)}let M=g-1,C=1,te=0;for(this[s+M]=n&255;--M>=0&&(C*=256);)n<0&&te===0&&this[s+M+1]!==0&&(te=1),this[s+M]=(n/C>>0)-te&255;return s+g},d.prototype.writeInt8=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,1,127,-128),n<0&&(n=255+n+1),this[s]=n&255,s+1},d.prototype.writeInt16LE=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,2,32767,-32768),this[s]=n&255,this[s+1]=n>>>8,s+2},d.prototype.writeInt16BE=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,2,32767,-32768),this[s]=n>>>8,this[s+1]=n&255,s+2},d.prototype.writeInt32LE=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,4,2147483647,-2147483648),this[s]=n&255,this[s+1]=n>>>8,this[s+2]=n>>>16,this[s+3]=n>>>24,s+4},d.prototype.writeInt32BE=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),this[s]=n>>>24,this[s+1]=n>>>16,this[s+2]=n>>>8,this[s+3]=n&255,s+4},d.prototype.writeBigInt64LE=Se(function(n,s=0){return L(this,n,s,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),d.prototype.writeBigInt64BE=Se(function(n,s=0){return F(this,n,s,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function K(l,n,s,g,T,M){if(s+g>l.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("Index out of range")}function X(l,n,s,g,T){return n=+n,s=s>>>0,T||K(l,n,s,4),r.write(l,n,s,g,23,4),s+4}d.prototype.writeFloatLE=function(n,s,g){return X(this,n,s,!0,g)},d.prototype.writeFloatBE=function(n,s,g){return X(this,n,s,!1,g)};function ee(l,n,s,g,T){return n=+n,s=s>>>0,T||K(l,n,s,8),r.write(l,n,s,g,52,8),s+8}d.prototype.writeDoubleLE=function(n,s,g){return ee(this,n,s,!0,g)},d.prototype.writeDoubleBE=function(n,s,g){return ee(this,n,s,!1,g)},d.prototype.copy=function(n,s,g,T){if(!d.isBuffer(n))throw new TypeError("argument should be a Buffer");if(g||(g=0),!T&&T!==0&&(T=this.length),s>=n.length&&(s=n.length),s||(s=0),T>0&&T<g&&(T=g),T===g||n.length===0||this.length===0)return 0;if(s<0)throw new RangeError("targetStart out of bounds");if(g<0||g>=this.length)throw new RangeError("Index out of range");if(T<0)throw new RangeError("sourceEnd out of bounds");T>this.length&&(T=this.length),n.length-s<T-g&&(T=n.length-s+g);const M=T-g;return this===n&&typeof u.prototype.copyWithin=="function"?this.copyWithin(s,g,T):u.prototype.set.call(n,this.subarray(g,T),s),M},d.prototype.fill=function(n,s,g,T){if(typeof n=="string"){if(typeof s=="string"?(T=s,s=0,g=this.length):typeof g=="string"&&(T=g,g=this.length),T!==void 0&&typeof T!="string")throw new TypeError("encoding must be a string");if(typeof T=="string"&&!d.isEncoding(T))throw new TypeError("Unknown encoding: "+T);if(n.length===1){const C=n.charCodeAt(0);(T==="utf8"&&C<128||T==="latin1")&&(n=C)}}else typeof n=="number"?n=n&255:typeof n=="boolean"&&(n=Number(n));if(s<0||this.length<s||this.length<g)throw new RangeError("Out of range index");if(g<=s)return this;s=s>>>0,g=g===void 0?this.length:g>>>0,n||(n=0);let M;if(typeof n=="number")for(M=s;M<g;++M)this[M]=n;else{const C=d.isBuffer(n)?n:d.from(n,T),te=C.length;if(te===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(M=0;M<g-s;++M)this[M+s]=C[M%te]}return this};const E={};function m(l,n,s){E[l]=class extends s{constructor(){super(),Object.defineProperty(this,"message",{value:n.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${l}]`,this.stack,delete this.name}get code(){return l}set code(T){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:T,writable:!0})}toString(){return`${this.name} [${l}]: ${this.message}`}}}m("ERR_BUFFER_OUT_OF_BOUNDS",function(l){return l?`${l} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),m("ERR_INVALID_ARG_TYPE",function(l,n){return`The "${l}" argument must be of type number. Received type ${typeof n}`},TypeError),m("ERR_OUT_OF_RANGE",function(l,n,s){let g=`The value of "${l}" is out of range.`,T=s;return Number.isInteger(s)&&Math.abs(s)>2**32?T=G(String(s)):typeof s=="bigint"&&(T=String(s),(s>BigInt(2)**BigInt(32)||s<-(BigInt(2)**BigInt(32)))&&(T=G(T)),T+="n"),g+=` It must be ${n}. Received ${T}`,g},RangeError);function G(l){let n="",s=l.length;const g=l[0]==="-"?1:0;for(;s>=g+4;s-=3)n=`_${l.slice(s-3,s)}${n}`;return`${l.slice(0,s)}${n}`}function V(l,n,s){J(n,"offset"),(l[n]===void 0||l[n+s]===void 0)&&oe(n,l.length-(s+1))}function ue(l,n,s,g,T,M){if(l>s||l<n){const C=typeof n=="bigint"?"n":"";let te;throw n===0||n===BigInt(0)?te=`>= 0${C} and < 2${C} ** ${(M+1)*8}${C}`:te=`>= -(2${C} ** ${(M+1)*8-1}${C}) and < 2 ** ${(M+1)*8-1}${C}`,new E.ERR_OUT_OF_RANGE("value",te,l)}V(g,T,M)}function J(l,n){if(typeof l!="number")throw new E.ERR_INVALID_ARG_TYPE(n,"number",l)}function oe(l,n,s){throw Math.floor(l)!==l?(J(l,s),new E.ERR_OUT_OF_RANGE("offset","an integer",l)):n<0?new E.ERR_BUFFER_OUT_OF_BOUNDS:new E.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${n}`,l)}const Ye=/[^+/0-9A-Za-z-_]/g;function it(l){if(l=l.split("=")[0],l=l.trim().replace(Ye,""),l.length<2)return"";for(;l.length%4!==0;)l=l+"=";return l}function ot(l,n){n=n||1/0;let s;const g=l.length;let T=null;const M=[];for(let C=0;C<g;++C){if(s=l.charCodeAt(C),s>55295&&s<57344){if(!T){if(s>56319){(n-=3)>-1&&M.push(239,191,189);continue}else if(C+1===g){(n-=3)>-1&&M.push(239,191,189);continue}T=s;continue}if(s<56320){(n-=3)>-1&&M.push(239,191,189),T=s;continue}s=(T-55296<<10|s-56320)+65536}else T&&(n-=3)>-1&&M.push(239,191,189);if(T=null,s<128){if((n-=1)<0)break;M.push(s)}else if(s<2048){if((n-=2)<0)break;M.push(s>>6|192,s&63|128)}else if(s<65536){if((n-=3)<0)break;M.push(s>>12|224,s>>6&63|128,s&63|128)}else if(s<1114112){if((n-=4)<0)break;M.push(s>>18|240,s>>12&63|128,s>>6&63|128,s&63|128)}else throw new Error("Invalid code point")}return M}function Nt(l){const n=[];for(let s=0;s<l.length;++s)n.push(l.charCodeAt(s)&255);return n}function ge(l,n){let s,g,T;const M=[];for(let C=0;C<l.length&&!((n-=2)<0);++C)s=l.charCodeAt(C),g=s>>8,T=s%256,M.push(T),M.push(g);return M}function _e(l){return e.toByteArray(it(l))}function Pe(l,n,s,g){let T;for(T=0;T<g&&!(T+s>=n.length||T>=l.length);++T)n[T+s]=l[T];return T}function Re(l,n){return l instanceof n||l!=null&&l.constructor!=null&&l.constructor.name!=null&&l.constructor.name===n.name}function Oe(l){return l!==l}const Ce=(function(){const l="0123456789abcdef",n=new Array(256);for(let s=0;s<16;++s){const g=s*16;for(let T=0;T<16;++T)n[g+T]=l[s]+l[T]}return n})();function Se(l){return typeof BigInt>"u"?st:l}function st(){throw new Error("BigInt not supported")}})(ut);const tr=ut.Buffer,ft=ut.Buffer;var pt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bi(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var r=function o(){var f=!1;try{f=this instanceof o}catch{}return f?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(o){var f=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r,o,f.get?f:{enumerable:!0,get:function(){return t[o]}})}),r}var Ft={exports:{}},Cr;function rr(){if(Cr)return Ft.exports;Cr=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(v,U,k){return Function.prototype.apply.call(v,U,k)},r;t&&typeof t.ownKeys=="function"?r=t.ownKeys:Object.getOwnPropertySymbols?r=function(v){return Object.getOwnPropertyNames(v).concat(Object.getOwnPropertySymbols(v))}:r=function(v){return Object.getOwnPropertyNames(v)};function o(_){console&&console.warn&&console.warn(_)}var f=Number.isNaN||function(v){return v!==v};function u(){u.init.call(this)}Ft.exports=u,Ft.exports.once=x,u.EventEmitter=u,u.prototype._events=void 0,u.prototype._eventsCount=0,u.prototype._maxListeners=void 0;var c=10;function p(_){if(typeof _!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof _)}Object.defineProperty(u,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(_){if(typeof _!="number"||_<0||f(_))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+_+".");c=_}}),u.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},u.prototype.setMaxListeners=function(v){if(typeof v!="number"||v<0||f(v))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+v+".");return this._maxListeners=v,this};function y(_){return _._maxListeners===void 0?u.defaultMaxListeners:_._maxListeners}u.prototype.getMaxListeners=function(){return y(this)},u.prototype.emit=function(v){for(var U=[],k=1;k<arguments.length;k++)U.push(arguments[k]);var D=v==="error",H=this._events;if(H!==void 0)D=D&&H.error===void 0;else if(!D)return!1;if(D){var z;if(U.length>0&&(z=U[0]),z instanceof Error)throw z;var re=new Error("Unhandled error."+(z?" ("+z.message+")":""));throw re.context=z,re}var N=H[v];if(N===void 0)return!1;if(typeof N=="function")e(N,this,U);else for(var ae=N.length,ve=P(N,ae),k=0;k<ae;++k)e(ve[k],this,U);return!0};function b(_,v,U,k){var D,H,z;if(p(U),H=_._events,H===void 0?(H=_._events=Object.create(null),_._eventsCount=0):(H.newListener!==void 0&&(_.emit("newListener",v,U.listener?U.listener:U),H=_._events),z=H[v]),z===void 0)z=H[v]=U,++_._eventsCount;else if(typeof z=="function"?z=H[v]=k?[U,z]:[z,U]:k?z.unshift(U):z.push(U),D=y(_),D>0&&z.length>D&&!z.warned){z.warned=!0;var re=new Error("Possible EventEmitter memory leak detected. "+z.length+" "+String(v)+" listeners added. Use emitter.setMaxListeners() to increase limit");re.name="MaxListenersExceededWarning",re.emitter=_,re.type=v,re.count=z.length,o(re)}return _}u.prototype.addListener=function(v,U){return b(this,v,U,!1)},u.prototype.on=u.prototype.addListener,u.prototype.prependListener=function(v,U){return b(this,v,U,!0)};function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function I(_,v,U){var k={fired:!1,wrapFn:void 0,target:_,type:v,listener:U},D=d.bind(k);return D.listener=U,k.wrapFn=D,D}u.prototype.once=function(v,U){return p(U),this.on(v,I(this,v,U)),this},u.prototype.prependOnceListener=function(v,U){return p(U),this.prependListener(v,I(this,v,U)),this},u.prototype.removeListener=function(v,U){var k,D,H,z,re;if(p(U),D=this._events,D===void 0)return this;if(k=D[v],k===void 0)return this;if(k===U||k.listener===U)--this._eventsCount===0?this._events=Object.create(null):(delete D[v],D.removeListener&&this.emit("removeListener",v,k.listener||U));else if(typeof k!="function"){for(H=-1,z=k.length-1;z>=0;z--)if(k[z]===U||k[z].listener===U){re=k[z].listener,H=z;break}if(H<0)return this;H===0?k.shift():W(k,H),k.length===1&&(D[v]=k[0]),D.removeListener!==void 0&&this.emit("removeListener",v,re||U)}return this},u.prototype.off=u.prototype.removeListener,u.prototype.removeAllListeners=function(v){var U,k,D;if(k=this._events,k===void 0)return this;if(k.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):k[v]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete k[v]),this;if(arguments.length===0){var H=Object.keys(k),z;for(D=0;D<H.length;++D)z=H[D],z!=="removeListener"&&this.removeAllListeners(z);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(U=k[v],typeof U=="function")this.removeListener(v,U);else if(U!==void 0)for(D=U.length-1;D>=0;D--)this.removeListener(v,U[D]);return this};function B(_,v,U){var k=_._events;if(k===void 0)return[];var D=k[v];return D===void 0?[]:typeof D=="function"?U?[D.listener||D]:[D]:U?j(D):P(D,D.length)}u.prototype.listeners=function(v){return B(this,v,!0)},u.prototype.rawListeners=function(v){return B(this,v,!1)},u.listenerCount=function(_,v){return typeof _.listenerCount=="function"?_.listenerCount(v):q.call(_,v)},u.prototype.listenerCount=q;function q(_){var v=this._events;if(v!==void 0){var U=v[_];if(typeof U=="function")return 1;if(U!==void 0)return U.length}return 0}u.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]};function P(_,v){for(var U=new Array(v),k=0;k<v;++k)U[k]=_[k];return U}function W(_,v){for(;v+1<_.length;v++)_[v]=_[v+1];_.pop()}function j(_){for(var v=new Array(_.length),U=0;U<v.length;++U)v[U]=_[U].listener||_[U];return v}function x(_,v){return new Promise(function(U,k){function D(z){_.removeListener(v,H),k(z)}function H(){typeof _.removeListener=="function"&&_.removeListener("error",D),U([].slice.call(arguments))}A(_,v,H,{once:!0}),v!=="error"&&R(_,D,{once:!0})})}function R(_,v,U){typeof _.on=="function"&&A(_,"error",v,U)}function A(_,v,U,k){if(typeof _.on=="function")k.once?_.once(v,U):_.on(v,U);else if(typeof _.addEventListener=="function")_.addEventListener(v,function D(H){k.once&&_.removeEventListener(v,D),U(H)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof _)}return Ft.exports}var Ut={exports:{}},$r;function yt(){return $r||($r=1,typeof Object.create=="function"?Ut.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Ut.exports=function(e,r){if(r){e.super_=r;var o=function(){};o.prototype=r.prototype,e.prototype=new o,e.prototype.constructor=e}}),Ut.exports}function _i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var qr={exports:{}},be=qr.exports={},qe,je;function nr(){throw new Error("setTimeout has not been defined")}function ir(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?qe=setTimeout:qe=nr}catch{qe=nr}try{typeof clearTimeout=="function"?je=clearTimeout:je=ir}catch{je=ir}})();function jr(t){if(qe===setTimeout)return setTimeout(t,0);if((qe===nr||!qe)&&setTimeout)return qe=setTimeout,setTimeout(t,0);try{return qe(t,0)}catch{try{return qe.call(null,t,0)}catch{return qe.call(this,t,0)}}}function Ti(t){if(je===clearTimeout)return clearTimeout(t);if((je===ir||!je)&&clearTimeout)return je=clearTimeout,clearTimeout(t);try{return je(t)}catch{try{return je.call(null,t)}catch{return je.call(this,t)}}}var Ve=[],gt=!1,ct,Lt=-1;function xi(){!gt||!ct||(gt=!1,ct.length?Ve=ct.concat(Ve):Lt=-1,Ve.length&&Gr())}function Gr(){if(!gt){var t=jr(xi);gt=!0;for(var e=Ve.length;e;){for(ct=Ve,Ve=[];++Lt<e;)ct&&ct[Lt].run();Lt=-1,e=Ve.length}ct=null,gt=!1,Ti(t)}}be.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];Ve.push(new Wr(t,e)),Ve.length===1&&!gt&&jr(Gr)};function Wr(t,e){this.fun=t,this.array=e}Wr.prototype.run=function(){this.fun.apply(null,this.array)},be.title="browser",be.browser=!0,be.env={},be.argv=[],be.version="",be.versions={};function Xe(){}be.on=Xe,be.addListener=Xe,be.once=Xe,be.off=Xe,be.removeListener=Xe,be.removeAllListeners=Xe,be.emit=Xe,be.prependListener=Xe,be.prependOnceListener=Xe,be.listeners=function(t){return[]},be.binding=function(t){throw new Error("process.binding is not supported")},be.cwd=function(){return"/"},be.chdir=function(t){throw new Error("process.chdir is not supported")},be.umask=function(){return 0};var Si=qr.exports;const fe=_i(Si);var or,Hr;function Kr(){return Hr||(Hr=1,or=rr().EventEmitter),or}var sr={},Yr;function Mt(){return Yr||(Yr=1,(function(t){Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e={},r={};r.byteLength=d,r.toByteArray=B,r.fromByteArray=W;for(var o=[],f=[],u=typeof Uint8Array<"u"?Uint8Array:Array,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,y=c.length;p<y;++p)o[p]=c[p],f[c.charCodeAt(p)]=p;f[45]=62,f[95]=63;function b(R){var A=R.length;if(A%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var _=R.indexOf("=");_===-1&&(_=A);var v=_===A?0:4-_%4;return[_,v]}function d(R){var A=b(R),_=A[0],v=A[1];return(_+v)*3/4-v}function I(R,A,_){return(A+_)*3/4-_}function B(R){var A,_=b(R),v=_[0],U=_[1],k=new u(I(R,v,U)),D=0,H=U>0?v-4:v,z;for(z=0;z<H;z+=4)A=f[R.charCodeAt(z)]<<18|f[R.charCodeAt(z+1)]<<12|f[R.charCodeAt(z+2)]<<6|f[R.charCodeAt(z+3)],k[D++]=A>>16&255,k[D++]=A>>8&255,k[D++]=A&255;return U===2&&(A=f[R.charCodeAt(z)]<<2|f[R.charCodeAt(z+1)]>>4,k[D++]=A&255),U===1&&(A=f[R.charCodeAt(z)]<<10|f[R.charCodeAt(z+1)]<<4|f[R.charCodeAt(z+2)]>>2,k[D++]=A>>8&255,k[D++]=A&255),k}function q(R){return o[R>>18&63]+o[R>>12&63]+o[R>>6&63]+o[R&63]}function P(R,A,_){for(var v,U=[],k=A;k<_;k+=3)v=(R[k]<<16&16711680)+(R[k+1]<<8&65280)+(R[k+2]&255),U.push(q(v));return U.join("")}function W(R){for(var A,_=R.length,v=_%3,U=[],k=16383,D=0,H=_-v;D<H;D+=k)U.push(P(R,D,D+k>H?H:D+k));return v===1?(A=R[_-1],U.push(o[A>>2]+o[A<<4&63]+"==")):v===2&&(A=(R[_-2]<<8)+R[_-1],U.push(o[A>>10]+o[A>>4&63]+o[A<<2&63]+"=")),U.join("")}var j={};j.read=function(R,A,_,v,U){var k,D,H=U*8-v-1,z=(1<<H)-1,re=z>>1,N=-7,ae=_?U-1:0,ve=_?-1:1,xe=R[A+ae];for(ae+=ve,k=xe&(1<<-N)-1,xe>>=-N,N+=H;N>0;k=k*256+R[A+ae],ae+=ve,N-=8);for(D=k&(1<<-N)-1,k>>=-N,N+=v;N>0;D=D*256+R[A+ae],ae+=ve,N-=8);if(k===0)k=1-re;else{if(k===z)return D?NaN:(xe?-1:1)*(1/0);D=D+Math.pow(2,v),k=k-re}return(xe?-1:1)*D*Math.pow(2,k-v)},j.write=function(R,A,_,v,U,k){var D,H,z,re=k*8-U-1,N=(1<<re)-1,ae=N>>1,ve=U===23?Math.pow(2,-24)-Math.pow(2,-77):0,xe=v?0:k-1,Ue=v?1:-1,Ae=A<0||A===0&&1/A<0?1:0;for(A=Math.abs(A),isNaN(A)||A===1/0?(H=isNaN(A)?1:0,D=N):(D=Math.floor(Math.log(A)/Math.LN2),A*(z=Math.pow(2,-D))<1&&(D--,z*=2),D+ae>=1?A+=ve/z:A+=ve*Math.pow(2,1-ae),A*z>=2&&(D++,z/=2),D+ae>=N?(H=0,D=N):D+ae>=1?(H=(A*z-1)*Math.pow(2,U),D=D+ae):(H=A*Math.pow(2,ae-1)*Math.pow(2,U),D=0));U>=8;R[_+xe]=H&255,xe+=Ue,H/=256,U-=8);for(D=D<<U|H,re+=U;re>0;R[_+xe]=D&255,xe+=Ue,D/=256,re-=8);R[_+xe-Ue]|=Ae*128};(function(R){const A=r,_=j,v=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;R.Buffer=N,R.SlowBuffer=ke,R.INSPECT_MAX_BYTES=50;const U=2147483647;R.kMaxLength=U;const{Uint8Array:k,ArrayBuffer:D,SharedArrayBuffer:H}=globalThis;N.TYPED_ARRAY_SUPPORT=z(),!N.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function z(){try{const h=new k(1),i={foo:function(){return 42}};return Object.setPrototypeOf(i,k.prototype),Object.setPrototypeOf(h,i),h.foo()===42}catch{return!1}}Object.defineProperty(N.prototype,"parent",{enumerable:!0,get:function(){if(N.isBuffer(this))return this.buffer}}),Object.defineProperty(N.prototype,"offset",{enumerable:!0,get:function(){if(N.isBuffer(this))return this.byteOffset}});function re(h){if(h>U)throw new RangeError('The value "'+h+'" is invalid for option "size"');const i=new k(h);return Object.setPrototypeOf(i,N.prototype),i}function N(h,i,a){if(typeof h=="number"){if(typeof i=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Ue(h)}return ae(h,i,a)}N.poolSize=8192;function ae(h,i,a){if(typeof h=="string")return Ae(h,i);if(D.isView(h))return We(h);if(h==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h);if(ze(h,D)||h&&ze(h.buffer,D)||typeof H<"u"&&(ze(h,H)||h&&ze(h.buffer,H)))return He(h,i,a);if(typeof h=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const w=h.valueOf&&h.valueOf();if(w!=null&&w!==h)return N.from(w,i,a);const S=ht(h);if(S)return S;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof h[Symbol.toPrimitive]=="function")return N.from(h[Symbol.toPrimitive]("string"),i,a);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h)}N.from=function(h,i,a){return ae(h,i,a)},Object.setPrototypeOf(N.prototype,k.prototype),Object.setPrototypeOf(N,k);function ve(h){if(typeof h!="number")throw new TypeError('"size" argument must be of type number');if(h<0)throw new RangeError('The value "'+h+'" is invalid for option "size"')}function xe(h,i,a){return ve(h),h<=0?re(h):i!==void 0?typeof a=="string"?re(h).fill(i,a):re(h).fill(i):re(h)}N.alloc=function(h,i,a){return xe(h,i,a)};function Ue(h){return ve(h),re(h<0?0:Ke(h)|0)}N.allocUnsafe=function(h){return Ue(h)},N.allocUnsafeSlow=function(h){return Ue(h)};function Ae(h,i){if((typeof i!="string"||i==="")&&(i="utf8"),!N.isEncoding(i))throw new TypeError("Unknown encoding: "+i);const a=de(h,i)|0;let w=re(a);const S=w.write(h,i);return S!==a&&(w=w.slice(0,S)),w}function De(h){const i=h.length<0?0:Ke(h.length)|0,a=re(i);for(let w=0;w<i;w+=1)a[w]=h[w]&255;return a}function We(h){if(ze(h,k)){const i=new k(h);return He(i.buffer,i.byteOffset,i.byteLength)}return De(h)}function He(h,i,a){if(i<0||h.byteLength<i)throw new RangeError('"offset" is outside of buffer bounds');if(h.byteLength<i+(a||0))throw new RangeError('"length" is outside of buffer bounds');let w;return i===void 0&&a===void 0?w=new k(h):a===void 0?w=new k(h,i):w=new k(h,i,a),Object.setPrototypeOf(w,N.prototype),w}function ht(h){if(N.isBuffer(h)){const i=Ke(h.length)|0,a=re(i);return a.length===0||h.copy(a,0,0,i),a}if(h.length!==void 0)return typeof h.length!="number"||kr(h.length)?re(0):De(h);if(h.type==="Buffer"&&Array.isArray(h.data))return De(h.data)}function Ke(h){if(h>=U)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+U.toString(16)+" bytes");return h|0}function ke(h){return+h!=h&&(h=0),N.alloc(+h)}N.isBuffer=function(i){return i!=null&&i._isBuffer===!0&&i!==N.prototype},N.compare=function(i,a){if(ze(i,k)&&(i=N.from(i,i.offset,i.byteLength)),ze(a,k)&&(a=N.from(a,a.offset,a.byteLength)),!N.isBuffer(i)||!N.isBuffer(a))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(i===a)return 0;let w=i.length,S=a.length;for(let O=0,$=Math.min(w,S);O<$;++O)if(i[O]!==a[O]){w=i[O],S=a[O];break}return w<S?-1:S<w?1:0},N.isEncoding=function(i){switch(String(i).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},N.concat=function(i,a){if(!Array.isArray(i))throw new TypeError('"list" argument must be an Array of Buffers');if(i.length===0)return N.alloc(0);let w;if(a===void 0)for(a=0,w=0;w<i.length;++w)a+=i[w].length;const S=N.allocUnsafe(a);let O=0;for(w=0;w<i.length;++w){let $=i[w];if(ze($,k))O+$.length>S.length?(N.isBuffer($)||($=N.from($)),$.copy(S,O)):k.prototype.set.call(S,$,O);else if(N.isBuffer($))$.copy(S,O);else throw new TypeError('"list" argument must be an Array of Buffers');O+=$.length}return S};function de(h,i){if(N.isBuffer(h))return h.length;if(D.isView(h)||ze(h,D))return h.byteLength;if(typeof h!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof h);const a=h.length,w=arguments.length>2&&arguments[2]===!0;if(!w&&a===0)return 0;let S=!1;for(;;)switch(i){case"ascii":case"latin1":case"binary":return a;case"utf8":case"utf-8":return le(h).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a*2;case"hex":return a>>>1;case"base64":return se(h).length;default:if(S)return w?-1:le(h).length;i=(""+i).toLowerCase(),S=!0}}N.byteLength=de;function Te(h,i,a){let w=!1;if((i===void 0||i<0)&&(i=0),i>this.length||((a===void 0||a>this.length)&&(a=this.length),a<=0)||(a>>>=0,i>>>=0,a<=i))return"";for(h||(h="utf8");;)switch(h){case"hex":return ot(this,i,a);case"utf8":case"utf-8":return ue(this,i,a);case"ascii":return Ye(this,i,a);case"latin1":case"binary":return it(this,i,a);case"base64":return V(this,i,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Nt(this,i,a);default:if(w)throw new TypeError("Unknown encoding: "+h);h=(h+"").toLowerCase(),w=!0}}N.prototype._isBuffer=!0;function L(h,i,a){const w=h[i];h[i]=h[a],h[a]=w}N.prototype.swap16=function(){const i=this.length;if(i%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let a=0;a<i;a+=2)L(this,a,a+1);return this},N.prototype.swap32=function(){const i=this.length;if(i%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let a=0;a<i;a+=4)L(this,a,a+3),L(this,a+1,a+2);return this},N.prototype.swap64=function(){const i=this.length;if(i%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let a=0;a<i;a+=8)L(this,a,a+7),L(this,a+1,a+6),L(this,a+2,a+5),L(this,a+3,a+4);return this},N.prototype.toString=function(){const i=this.length;return i===0?"":arguments.length===0?ue(this,0,i):Te.apply(this,arguments)},N.prototype.toLocaleString=N.prototype.toString,N.prototype.equals=function(i){if(!N.isBuffer(i))throw new TypeError("Argument must be a Buffer");return this===i?!0:N.compare(this,i)===0},N.prototype.inspect=function(){let i="";const a=R.INSPECT_MAX_BYTES;return i=this.toString("hex",0,a).replace(/(.{2})/g,"$1 ").trim(),this.length>a&&(i+=" ... "),"<Buffer "+i+">"},v&&(N.prototype[v]=N.prototype.inspect),N.prototype.compare=function(i,a,w,S,O){if(ze(i,k)&&(i=N.from(i,i.offset,i.byteLength)),!N.isBuffer(i))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof i);if(a===void 0&&(a=0),w===void 0&&(w=i?i.length:0),S===void 0&&(S=0),O===void 0&&(O=this.length),a<0||w>i.length||S<0||O>this.length)throw new RangeError("out of range index");if(S>=O&&a>=w)return 0;if(S>=O)return-1;if(a>=w)return 1;if(a>>>=0,w>>>=0,S>>>=0,O>>>=0,this===i)return 0;let $=O-S,ne=w-a;const Ee=Math.min($,ne),ye=this.slice(S,O),me=i.slice(a,w);for(let ce=0;ce<Ee;++ce)if(ye[ce]!==me[ce]){$=ye[ce],ne=me[ce];break}return $<ne?-1:ne<$?1:0};function F(h,i,a,w,S){if(h.length===0)return-1;if(typeof a=="string"?(w=a,a=0):a>2147483647?a=2147483647:a<-2147483648&&(a=-2147483648),a=+a,kr(a)&&(a=S?0:h.length-1),a<0&&(a=h.length+a),a>=h.length){if(S)return-1;a=h.length-1}else if(a<0)if(S)a=0;else return-1;if(typeof i=="string"&&(i=N.from(i,w)),N.isBuffer(i))return i.length===0?-1:K(h,i,a,w,S);if(typeof i=="number")return i=i&255,typeof k.prototype.indexOf=="function"?S?k.prototype.indexOf.call(h,i,a):k.prototype.lastIndexOf.call(h,i,a):K(h,[i],a,w,S);throw new TypeError("val must be string, number or Buffer")}function K(h,i,a,w,S){let O=1,$=h.length,ne=i.length;if(w!==void 0&&(w=String(w).toLowerCase(),w==="ucs2"||w==="ucs-2"||w==="utf16le"||w==="utf-16le")){if(h.length<2||i.length<2)return-1;O=2,$/=2,ne/=2,a/=2}function Ee(me,ce){return O===1?me[ce]:me.readUInt16BE(ce*O)}let ye;if(S){let me=-1;for(ye=a;ye<$;ye++)if(Ee(h,ye)===Ee(i,me===-1?0:ye-me)){if(me===-1&&(me=ye),ye-me+1===ne)return me*O}else me!==-1&&(ye-=ye-me),me=-1}else for(a+ne>$&&(a=$-ne),ye=a;ye>=0;ye--){let me=!0;for(let ce=0;ce<ne;ce++)if(Ee(h,ye+ce)!==Ee(i,ce)){me=!1;break}if(me)return ye}return-1}N.prototype.includes=function(i,a,w){return this.indexOf(i,a,w)!==-1},N.prototype.indexOf=function(i,a,w){return F(this,i,a,w,!0)},N.prototype.lastIndexOf=function(i,a,w){return F(this,i,a,w,!1)};function X(h,i,a,w){a=Number(a)||0;const S=h.length-a;w?(w=Number(w),w>S&&(w=S)):w=S;const O=i.length;w>O/2&&(w=O/2);let $;for($=0;$<w;++$){const ne=parseInt(i.substr($*2,2),16);if(kr(ne))return $;h[a+$]=ne}return $}function ee(h,i,a,w){return Jt(le(i,h.length-a),h,a,w)}function E(h,i,a,w){return Jt(he(i),h,a,w)}function m(h,i,a,w){return Jt(se(i),h,a,w)}function G(h,i,a,w){return Jt(pe(i,h.length-a),h,a,w)}N.prototype.write=function(i,a,w,S){if(a===void 0)S="utf8",w=this.length,a=0;else if(w===void 0&&typeof a=="string")S=a,w=this.length,a=0;else if(isFinite(a))a=a>>>0,isFinite(w)?(w=w>>>0,S===void 0&&(S="utf8")):(S=w,w=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const O=this.length-a;if((w===void 0||w>O)&&(w=O),i.length>0&&(w<0||a<0)||a>this.length)throw new RangeError("Attempt to write outside buffer bounds");S||(S="utf8");let $=!1;for(;;)switch(S){case"hex":return X(this,i,a,w);case"utf8":case"utf-8":return ee(this,i,a,w);case"ascii":case"latin1":case"binary":return E(this,i,a,w);case"base64":return m(this,i,a,w);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return G(this,i,a,w);default:if($)throw new TypeError("Unknown encoding: "+S);S=(""+S).toLowerCase(),$=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function V(h,i,a){return i===0&&a===h.length?A.fromByteArray(h):A.fromByteArray(h.slice(i,a))}function ue(h,i,a){a=Math.min(h.length,a);const w=[];let S=i;for(;S<a;){const O=h[S];let $=null,ne=O>239?4:O>223?3:O>191?2:1;if(S+ne<=a){let Ee,ye,me,ce;switch(ne){case 1:O<128&&($=O);break;case 2:Ee=h[S+1],(Ee&192)===128&&(ce=(O&31)<<6|Ee&63,ce>127&&($=ce));break;case 3:Ee=h[S+1],ye=h[S+2],(Ee&192)===128&&(ye&192)===128&&(ce=(O&15)<<12|(Ee&63)<<6|ye&63,ce>2047&&(ce<55296||ce>57343)&&($=ce));break;case 4:Ee=h[S+1],ye=h[S+2],me=h[S+3],(Ee&192)===128&&(ye&192)===128&&(me&192)===128&&(ce=(O&15)<<18|(Ee&63)<<12|(ye&63)<<6|me&63,ce>65535&&ce<1114112&&($=ce))}}$===null?($=65533,ne=1):$>65535&&($-=65536,w.push($>>>10&1023|55296),$=56320|$&1023),w.push($),S+=ne}return oe(w)}const J=4096;function oe(h){const i=h.length;if(i<=J)return String.fromCharCode.apply(String,h);let a="",w=0;for(;w<i;)a+=String.fromCharCode.apply(String,h.slice(w,w+=J));return a}function Ye(h,i,a){let w="";a=Math.min(h.length,a);for(let S=i;S<a;++S)w+=String.fromCharCode(h[S]&127);return w}function it(h,i,a){let w="";a=Math.min(h.length,a);for(let S=i;S<a;++S)w+=String.fromCharCode(h[S]);return w}function ot(h,i,a){const w=h.length;(!i||i<0)&&(i=0),(!a||a<0||a>w)&&(a=w);let S="";for(let O=i;O<a;++O)S+=Co[h[O]];return S}function Nt(h,i,a){const w=h.slice(i,a);let S="";for(let O=0;O<w.length-1;O+=2)S+=String.fromCharCode(w[O]+w[O+1]*256);return S}N.prototype.slice=function(i,a){const w=this.length;i=~~i,a=a===void 0?w:~~a,i<0?(i+=w,i<0&&(i=0)):i>w&&(i=w),a<0?(a+=w,a<0&&(a=0)):a>w&&(a=w),a<i&&(a=i);const S=this.subarray(i,a);return Object.setPrototypeOf(S,N.prototype),S};function ge(h,i,a){if(h%1!==0||h<0)throw new RangeError("offset is not uint");if(h+i>a)throw new RangeError("Trying to access beyond buffer length")}N.prototype.readUintLE=N.prototype.readUIntLE=function(i,a,w){i=i>>>0,a=a>>>0,w||ge(i,a,this.length);let S=this[i],O=1,$=0;for(;++$<a&&(O*=256);)S+=this[i+$]*O;return S},N.prototype.readUintBE=N.prototype.readUIntBE=function(i,a,w){i=i>>>0,a=a>>>0,w||ge(i,a,this.length);let S=this[i+--a],O=1;for(;a>0&&(O*=256);)S+=this[i+--a]*O;return S},N.prototype.readUint8=N.prototype.readUInt8=function(i,a){return i=i>>>0,a||ge(i,1,this.length),this[i]},N.prototype.readUint16LE=N.prototype.readUInt16LE=function(i,a){return i=i>>>0,a||ge(i,2,this.length),this[i]|this[i+1]<<8},N.prototype.readUint16BE=N.prototype.readUInt16BE=function(i,a){return i=i>>>0,a||ge(i,2,this.length),this[i]<<8|this[i+1]},N.prototype.readUint32LE=N.prototype.readUInt32LE=function(i,a){return i=i>>>0,a||ge(i,4,this.length),(this[i]|this[i+1]<<8|this[i+2]<<16)+this[i+3]*16777216},N.prototype.readUint32BE=N.prototype.readUInt32BE=function(i,a){return i=i>>>0,a||ge(i,4,this.length),this[i]*16777216+(this[i+1]<<16|this[i+2]<<8|this[i+3])},N.prototype.readBigUInt64LE=at(function(i){i=i>>>0,T(i,"offset");const a=this[i],w=this[i+7];(a===void 0||w===void 0)&&M(i,this.length-8);const S=a+this[++i]*2**8+this[++i]*2**16+this[++i]*2**24,O=this[++i]+this[++i]*2**8+this[++i]*2**16+w*2**24;return BigInt(S)+(BigInt(O)<<BigInt(32))}),N.prototype.readBigUInt64BE=at(function(i){i=i>>>0,T(i,"offset");const a=this[i],w=this[i+7];(a===void 0||w===void 0)&&M(i,this.length-8);const S=a*2**24+this[++i]*2**16+this[++i]*2**8+this[++i],O=this[++i]*2**24+this[++i]*2**16+this[++i]*2**8+w;return(BigInt(S)<<BigInt(32))+BigInt(O)}),N.prototype.readIntLE=function(i,a,w){i=i>>>0,a=a>>>0,w||ge(i,a,this.length);let S=this[i],O=1,$=0;for(;++$<a&&(O*=256);)S+=this[i+$]*O;return O*=128,S>=O&&(S-=Math.pow(2,8*a)),S},N.prototype.readIntBE=function(i,a,w){i=i>>>0,a=a>>>0,w||ge(i,a,this.length);let S=a,O=1,$=this[i+--S];for(;S>0&&(O*=256);)$+=this[i+--S]*O;return O*=128,$>=O&&($-=Math.pow(2,8*a)),$},N.prototype.readInt8=function(i,a){return i=i>>>0,a||ge(i,1,this.length),this[i]&128?(255-this[i]+1)*-1:this[i]},N.prototype.readInt16LE=function(i,a){i=i>>>0,a||ge(i,2,this.length);const w=this[i]|this[i+1]<<8;return w&32768?w|4294901760:w},N.prototype.readInt16BE=function(i,a){i=i>>>0,a||ge(i,2,this.length);const w=this[i+1]|this[i]<<8;return w&32768?w|4294901760:w},N.prototype.readInt32LE=function(i,a){return i=i>>>0,a||ge(i,4,this.length),this[i]|this[i+1]<<8|this[i+2]<<16|this[i+3]<<24},N.prototype.readInt32BE=function(i,a){return i=i>>>0,a||ge(i,4,this.length),this[i]<<24|this[i+1]<<16|this[i+2]<<8|this[i+3]},N.prototype.readBigInt64LE=at(function(i){i=i>>>0,T(i,"offset");const a=this[i],w=this[i+7];(a===void 0||w===void 0)&&M(i,this.length-8);const S=this[i+4]+this[i+5]*2**8+this[i+6]*2**16+(w<<24);return(BigInt(S)<<BigInt(32))+BigInt(a+this[++i]*2**8+this[++i]*2**16+this[++i]*2**24)}),N.prototype.readBigInt64BE=at(function(i){i=i>>>0,T(i,"offset");const a=this[i],w=this[i+7];(a===void 0||w===void 0)&&M(i,this.length-8);const S=(a<<24)+this[++i]*2**16+this[++i]*2**8+this[++i];return(BigInt(S)<<BigInt(32))+BigInt(this[++i]*2**24+this[++i]*2**16+this[++i]*2**8+w)}),N.prototype.readFloatLE=function(i,a){return i=i>>>0,a||ge(i,4,this.length),_.read(this,i,!0,23,4)},N.prototype.readFloatBE=function(i,a){return i=i>>>0,a||ge(i,4,this.length),_.read(this,i,!1,23,4)},N.prototype.readDoubleLE=function(i,a){return i=i>>>0,a||ge(i,8,this.length),_.read(this,i,!0,52,8)},N.prototype.readDoubleBE=function(i,a){return i=i>>>0,a||ge(i,8,this.length),_.read(this,i,!1,52,8)};function _e(h,i,a,w,S,O){if(!N.isBuffer(h))throw new TypeError('"buffer" argument must be a Buffer instance');if(i>S||i<O)throw new RangeError('"value" argument is out of bounds');if(a+w>h.length)throw new RangeError("Index out of range")}N.prototype.writeUintLE=N.prototype.writeUIntLE=function(i,a,w,S){if(i=+i,a=a>>>0,w=w>>>0,!S){const ne=Math.pow(2,8*w)-1;_e(this,i,a,w,ne,0)}let O=1,$=0;for(this[a]=i&255;++$<w&&(O*=256);)this[a+$]=i/O&255;return a+w},N.prototype.writeUintBE=N.prototype.writeUIntBE=function(i,a,w,S){if(i=+i,a=a>>>0,w=w>>>0,!S){const ne=Math.pow(2,8*w)-1;_e(this,i,a,w,ne,0)}let O=w-1,$=1;for(this[a+O]=i&255;--O>=0&&($*=256);)this[a+O]=i/$&255;return a+w},N.prototype.writeUint8=N.prototype.writeUInt8=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,1,255,0),this[a]=i&255,a+1},N.prototype.writeUint16LE=N.prototype.writeUInt16LE=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,2,65535,0),this[a]=i&255,this[a+1]=i>>>8,a+2},N.prototype.writeUint16BE=N.prototype.writeUInt16BE=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,2,65535,0),this[a]=i>>>8,this[a+1]=i&255,a+2},N.prototype.writeUint32LE=N.prototype.writeUInt32LE=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,4,4294967295,0),this[a+3]=i>>>24,this[a+2]=i>>>16,this[a+1]=i>>>8,this[a]=i&255,a+4},N.prototype.writeUint32BE=N.prototype.writeUInt32BE=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,4,4294967295,0),this[a]=i>>>24,this[a+1]=i>>>16,this[a+2]=i>>>8,this[a+3]=i&255,a+4};function Pe(h,i,a,w,S){g(i,w,S,h,a,7);let O=Number(i&BigInt(4294967295));h[a++]=O,O=O>>8,h[a++]=O,O=O>>8,h[a++]=O,O=O>>8,h[a++]=O;let $=Number(i>>BigInt(32)&BigInt(4294967295));return h[a++]=$,$=$>>8,h[a++]=$,$=$>>8,h[a++]=$,$=$>>8,h[a++]=$,a}function Re(h,i,a,w,S){g(i,w,S,h,a,7);let O=Number(i&BigInt(4294967295));h[a+7]=O,O=O>>8,h[a+6]=O,O=O>>8,h[a+5]=O,O=O>>8,h[a+4]=O;let $=Number(i>>BigInt(32)&BigInt(4294967295));return h[a+3]=$,$=$>>8,h[a+2]=$,$=$>>8,h[a+1]=$,$=$>>8,h[a]=$,a+8}N.prototype.writeBigUInt64LE=at(function(i,a=0){return Pe(this,i,a,BigInt(0),BigInt("0xffffffffffffffff"))}),N.prototype.writeBigUInt64BE=at(function(i,a=0){return Re(this,i,a,BigInt(0),BigInt("0xffffffffffffffff"))}),N.prototype.writeIntLE=function(i,a,w,S){if(i=+i,a=a>>>0,!S){const Ee=Math.pow(2,8*w-1);_e(this,i,a,w,Ee-1,-Ee)}let O=0,$=1,ne=0;for(this[a]=i&255;++O<w&&($*=256);)i<0&&ne===0&&this[a+O-1]!==0&&(ne=1),this[a+O]=(i/$>>0)-ne&255;return a+w},N.prototype.writeIntBE=function(i,a,w,S){if(i=+i,a=a>>>0,!S){const Ee=Math.pow(2,8*w-1);_e(this,i,a,w,Ee-1,-Ee)}let O=w-1,$=1,ne=0;for(this[a+O]=i&255;--O>=0&&($*=256);)i<0&&ne===0&&this[a+O+1]!==0&&(ne=1),this[a+O]=(i/$>>0)-ne&255;return a+w},N.prototype.writeInt8=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,1,127,-128),i<0&&(i=255+i+1),this[a]=i&255,a+1},N.prototype.writeInt16LE=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,2,32767,-32768),this[a]=i&255,this[a+1]=i>>>8,a+2},N.prototype.writeInt16BE=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,2,32767,-32768),this[a]=i>>>8,this[a+1]=i&255,a+2},N.prototype.writeInt32LE=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,4,2147483647,-2147483648),this[a]=i&255,this[a+1]=i>>>8,this[a+2]=i>>>16,this[a+3]=i>>>24,a+4},N.prototype.writeInt32BE=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,4,2147483647,-2147483648),i<0&&(i=4294967295+i+1),this[a]=i>>>24,this[a+1]=i>>>16,this[a+2]=i>>>8,this[a+3]=i&255,a+4},N.prototype.writeBigInt64LE=at(function(i,a=0){return Pe(this,i,a,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),N.prototype.writeBigInt64BE=at(function(i,a=0){return Re(this,i,a,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Oe(h,i,a,w,S,O){if(a+w>h.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("Index out of range")}function Ce(h,i,a,w,S){return i=+i,a=a>>>0,S||Oe(h,i,a,4),_.write(h,i,a,w,23,4),a+4}N.prototype.writeFloatLE=function(i,a,w){return Ce(this,i,a,!0,w)},N.prototype.writeFloatBE=function(i,a,w){return Ce(this,i,a,!1,w)};function Se(h,i,a,w,S){return i=+i,a=a>>>0,S||Oe(h,i,a,8),_.write(h,i,a,w,52,8),a+8}N.prototype.writeDoubleLE=function(i,a,w){return Se(this,i,a,!0,w)},N.prototype.writeDoubleBE=function(i,a,w){return Se(this,i,a,!1,w)},N.prototype.copy=function(i,a,w,S){if(!N.isBuffer(i))throw new TypeError("argument should be a Buffer");if(w||(w=0),!S&&S!==0&&(S=this.length),a>=i.length&&(a=i.length),a||(a=0),S>0&&S<w&&(S=w),S===w||i.length===0||this.length===0)return 0;if(a<0)throw new RangeError("targetStart out of bounds");if(w<0||w>=this.length)throw new RangeError("Index out of range");if(S<0)throw new RangeError("sourceEnd out of bounds");S>this.length&&(S=this.length),i.length-a<S-w&&(S=i.length-a+w);const O=S-w;return this===i&&typeof k.prototype.copyWithin=="function"?this.copyWithin(a,w,S):k.prototype.set.call(i,this.subarray(w,S),a),O},N.prototype.fill=function(i,a,w,S){if(typeof i=="string"){if(typeof a=="string"?(S=a,a=0,w=this.length):typeof w=="string"&&(S=w,w=this.length),S!==void 0&&typeof S!="string")throw new TypeError("encoding must be a string");if(typeof S=="string"&&!N.isEncoding(S))throw new TypeError("Unknown encoding: "+S);if(i.length===1){const $=i.charCodeAt(0);(S==="utf8"&&$<128||S==="latin1")&&(i=$)}}else typeof i=="number"?i=i&255:typeof i=="boolean"&&(i=Number(i));if(a<0||this.length<a||this.length<w)throw new RangeError("Out of range index");if(w<=a)return this;a=a>>>0,w=w===void 0?this.length:w>>>0,i||(i=0);let O;if(typeof i=="number")for(O=a;O<w;++O)this[O]=i;else{const $=N.isBuffer(i)?i:N.from(i,S),ne=$.length;if(ne===0)throw new TypeError('The value "'+i+'" is invalid for argument "value"');for(O=0;O<w-a;++O)this[O+a]=$[O%ne]}return this};const st={};function l(h,i,a){st[h]=class extends a{constructor(){super(),Object.defineProperty(this,"message",{value:i.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${h}]`,this.stack,delete this.name}get code(){return h}set code(S){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:S,writable:!0})}toString(){return`${this.name} [${h}]: ${this.message}`}}}l("ERR_BUFFER_OUT_OF_BOUNDS",function(h){return h?`${h} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),l("ERR_INVALID_ARG_TYPE",function(h,i){return`The "${h}" argument must be of type number. Received type ${typeof i}`},TypeError),l("ERR_OUT_OF_RANGE",function(h,i,a){let w=`The value of "${h}" is out of range.`,S=a;return Number.isInteger(a)&&Math.abs(a)>2**32?S=n(String(a)):typeof a=="bigint"&&(S=String(a),(a>BigInt(2)**BigInt(32)||a<-(BigInt(2)**BigInt(32)))&&(S=n(S)),S+="n"),w+=` It must be ${i}. Received ${S}`,w},RangeError);function n(h){let i="",a=h.length;const w=h[0]==="-"?1:0;for(;a>=w+4;a-=3)i=`_${h.slice(a-3,a)}${i}`;return`${h.slice(0,a)}${i}`}function s(h,i,a){T(i,"offset"),(h[i]===void 0||h[i+a]===void 0)&&M(i,h.length-(a+1))}function g(h,i,a,w,S,O){if(h>a||h<i){const $=typeof i=="bigint"?"n":"";let ne;throw i===0||i===BigInt(0)?ne=`>= 0${$} and < 2${$} ** ${(O+1)*8}${$}`:ne=`>= -(2${$} ** ${(O+1)*8-1}${$}) and < 2 ** ${(O+1)*8-1}${$}`,new st.ERR_OUT_OF_RANGE("value",ne,h)}s(w,S,O)}function T(h,i){if(typeof h!="number")throw new st.ERR_INVALID_ARG_TYPE(i,"number",h)}function M(h,i,a){throw Math.floor(h)!==h?(T(h,a),new st.ERR_OUT_OF_RANGE("offset","an integer",h)):i<0?new st.ERR_BUFFER_OUT_OF_BOUNDS:new st.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${i}`,h)}const C=/[^+/0-9A-Za-z-_]/g;function te(h){if(h=h.split("=")[0],h=h.trim().replace(C,""),h.length<2)return"";for(;h.length%4!==0;)h=h+"=";return h}function le(h,i){i=i||1/0;let a;const w=h.length;let S=null;const O=[];for(let $=0;$<w;++$){if(a=h.charCodeAt($),a>55295&&a<57344){if(!S){if(a>56319){(i-=3)>-1&&O.push(239,191,189);continue}else if($+1===w){(i-=3)>-1&&O.push(239,191,189);continue}S=a;continue}if(a<56320){(i-=3)>-1&&O.push(239,191,189),S=a;continue}a=(S-55296<<10|a-56320)+65536}else S&&(i-=3)>-1&&O.push(239,191,189);if(S=null,a<128){if((i-=1)<0)break;O.push(a)}else if(a<2048){if((i-=2)<0)break;O.push(a>>6|192,a&63|128)}else if(a<65536){if((i-=3)<0)break;O.push(a>>12|224,a>>6&63|128,a&63|128)}else if(a<1114112){if((i-=4)<0)break;O.push(a>>18|240,a>>12&63|128,a>>6&63|128,a&63|128)}else throw new Error("Invalid code point")}return O}function he(h){const i=[];for(let a=0;a<h.length;++a)i.push(h.charCodeAt(a)&255);return i}function pe(h,i){let a,w,S;const O=[];for(let $=0;$<h.length&&!((i-=2)<0);++$)a=h.charCodeAt($),w=a>>8,S=a%256,O.push(S),O.push(w);return O}function se(h){return A.toByteArray(te(h))}function Jt(h,i,a,w){let S;for(S=0;S<w&&!(S+a>=i.length||S>=h.length);++S)i[S+a]=h[S];return S}function ze(h,i){return h instanceof i||h!=null&&h.constructor!=null&&h.constructor.name!=null&&h.constructor.name===i.name}function kr(h){return h!==h}const Co=(function(){const h="0123456789abcdef",i=new Array(256);for(let a=0;a<16;++a){const w=a*16;for(let S=0;S<16;++S)i[w+S]=h[a]+h[S]}return i})();function at(h){return typeof BigInt>"u"?$o:h}function $o(){throw new Error("BigInt not supported")}})(e);const x=e.Buffer;t.Blob=e.Blob,t.BlobOptions=e.BlobOptions,t.Buffer=e.Buffer,t.File=e.File,t.FileOptions=e.FileOptions,t.INSPECT_MAX_BYTES=e.INSPECT_MAX_BYTES,t.SlowBuffer=e.SlowBuffer,t.TranscodeEncoding=e.TranscodeEncoding,t.atob=e.atob,t.btoa=e.btoa,t.constants=e.constants,t.default=x,t.isAscii=e.isAscii,t.isUtf8=e.isUtf8,t.kMaxLength=e.kMaxLength,t.kStringMaxLength=e.kStringMaxLength,t.resolveObjectURL=e.resolveObjectURL,t.transcode=e.transcode})(sr)),sr}const zr=bi(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ar,Vr;function vi(){if(Vr)return ar;Vr=1;function t(P,W){var j=Object.keys(P);if(Object.getOwnPropertySymbols){var x=Object.getOwnPropertySymbols(P);W&&(x=x.filter(function(R){return Object.getOwnPropertyDescriptor(P,R).enumerable})),j.push.apply(j,x)}return j}function e(P){for(var W=1;W<arguments.length;W++){var j=arguments[W]!=null?arguments[W]:{};W%2?t(Object(j),!0).forEach(function(x){r(P,x,j[x])}):Object.getOwnPropertyDescriptors?Object.defineProperties(P,Object.getOwnPropertyDescriptors(j)):t(Object(j)).forEach(function(x){Object.defineProperty(P,x,Object.getOwnPropertyDescriptor(j,x))})}return P}function r(P,W,j){return W=c(W),W in P?Object.defineProperty(P,W,{value:j,enumerable:!0,configurable:!0,writable:!0}):P[W]=j,P}function o(P,W){if(!(P instanceof W))throw new TypeError("Cannot call a class as a function")}function f(P,W){for(var j=0;j<W.length;j++){var x=W[j];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(P,c(x.key),x)}}function u(P,W,j){return W&&f(P.prototype,W),Object.defineProperty(P,"prototype",{writable:!1}),P}function c(P){var W=p(P,"string");return typeof W=="symbol"?W:String(W)}function p(P,W){if(typeof P!="object"||P===null)return P;var j=P[Symbol.toPrimitive];if(j!==void 0){var x=j.call(P,W);if(typeof x!="object")return x;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(P)}var y=Mt(),b=y.Buffer,d=zr,I=d.inspect,B=I&&I.custom||"inspect";function q(P,W,j){b.prototype.copy.call(P,W,j)}return ar=(function(){function P(){o(this,P),this.head=null,this.tail=null,this.length=0}return u(P,[{key:"push",value:function(j){var x={data:j,next:null};this.length>0?this.tail.next=x:this.head=x,this.tail=x,++this.length}},{key:"unshift",value:function(j){var x={data:j,next:this.head};this.length===0&&(this.tail=x),this.head=x,++this.length}},{key:"shift",value:function(){if(this.length!==0){var j=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,j}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(j){if(this.length===0)return"";for(var x=this.head,R=""+x.data;x=x.next;)R+=j+x.data;return R}},{key:"concat",value:function(j){if(this.length===0)return b.alloc(0);for(var x=b.allocUnsafe(j>>>0),R=this.head,A=0;R;)q(R.data,x,A),A+=R.data.length,R=R.next;return x}},{key:"consume",value:function(j,x){var R;return j<this.head.data.length?(R=this.head.data.slice(0,j),this.head.data=this.head.data.slice(j)):j===this.head.data.length?R=this.shift():R=x?this._getString(j):this._getBuffer(j),R}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(j){var x=this.head,R=1,A=x.data;for(j-=A.length;x=x.next;){var _=x.data,v=j>_.length?_.length:j;if(v===_.length?A+=_:A+=_.slice(0,j),j-=v,j===0){v===_.length?(++R,x.next?this.head=x.next:this.head=this.tail=null):(this.head=x,x.data=_.slice(v));break}++R}return this.length-=R,A}},{key:"_getBuffer",value:function(j){var x=b.allocUnsafe(j),R=this.head,A=1;for(R.data.copy(x),j-=R.data.length;R=R.next;){var _=R.data,v=j>_.length?_.length:j;if(_.copy(x,x.length-j,0,v),j-=v,j===0){v===_.length?(++A,R.next?this.head=R.next:this.head=this.tail=null):(this.head=R,R.data=_.slice(v));break}++A}return this.length-=A,x}},{key:B,value:function(j,x){return I(this,e(e({},x),{},{depth:0,customInspect:!1}))}}]),P})(),ar}var ur,Xr;function Jr(){if(Xr)return ur;Xr=1;function t(c,p){var y=this,b=this._readableState&&this._readableState.destroyed,d=this._writableState&&this._writableState.destroyed;return b||d?(p?p(c):c&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,fe.nextTick(f,this,c)):fe.nextTick(f,this,c)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(c||null,function(I){!p&&I?y._writableState?y._writableState.errorEmitted?fe.nextTick(r,y):(y._writableState.errorEmitted=!0,fe.nextTick(e,y,I)):fe.nextTick(e,y,I):p?(fe.nextTick(r,y),p(I)):fe.nextTick(r,y)}),this)}function e(c,p){f(c,p),r(c)}function r(c){c._writableState&&!c._writableState.emitClose||c._readableState&&!c._readableState.emitClose||c.emit("close")}function o(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function f(c,p){c.emit("error",p)}function u(c,p){var y=c._readableState,b=c._writableState;y&&y.autoDestroy||b&&b.autoDestroy?c.destroy(p):c.emit("error",p)}return ur={destroy:t,undestroy:o,errorOrDestroy:u},ur}var fr={},Zr;function wt(){if(Zr)return fr;Zr=1;function t(p,y){p.prototype=Object.create(y.prototype),p.prototype.constructor=p,p.__proto__=y}var e={};function r(p,y,b){b||(b=Error);function d(B,q,P){return typeof y=="string"?y:y(B,q,P)}var I=(function(B){t(q,B);function q(P,W,j){return B.call(this,d(P,W,j))||this}return q})(b);I.prototype.name=b.name,I.prototype.code=p,e[p]=I}function o(p,y){if(Array.isArray(p)){var b=p.length;return p=p.map(function(d){return String(d)}),b>2?"one of ".concat(y," ").concat(p.slice(0,b-1).join(", "),", or ")+p[b-1]:b===2?"one of ".concat(y," ").concat(p[0]," or ").concat(p[1]):"of ".concat(y," ").concat(p[0])}else return"of ".concat(y," ").concat(String(p))}function f(p,y,b){return p.substr(0,y.length)===y}function u(p,y,b){return(b===void 0||b>p.length)&&(b=p.length),p.substring(b-y.length,b)===y}function c(p,y,b){return typeof b!="number"&&(b=0),b+y.length>p.length?!1:p.indexOf(y,b)!==-1}return r("ERR_INVALID_OPT_VALUE",function(p,y){return'The value "'+y+'" is invalid for option "'+p+'"'},TypeError),r("ERR_INVALID_ARG_TYPE",function(p,y,b){var d;typeof y=="string"&&f(y,"not ")?(d="must not be",y=y.replace(/^not /,"")):d="must be";var I;if(u(p," argument"))I="The ".concat(p," ").concat(d," ").concat(o(y,"type"));else{var B=c(p,".")?"property":"argument";I='The "'.concat(p,'" ').concat(B," ").concat(d," ").concat(o(y,"type"))}return I+=". Received type ".concat(typeof b),I},TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",function(p){return"The "+p+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(p){return"Cannot call "+p+" after a stream was destroyed"}),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",function(p){return"Unknown encoding: "+p},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),fr.codes=e,fr}var cr,Qr;function en(){if(Qr)return cr;Qr=1;var t=wt().codes.ERR_INVALID_OPT_VALUE;function e(o,f,u){return o.highWaterMark!=null?o.highWaterMark:f?o[u]:null}function r(o,f,u,c){var p=e(f,c,u);if(p!=null){if(!(isFinite(p)&&Math.floor(p)===p)||p<0){var y=c?u:"highWaterMark";throw new t(y,p)}return Math.floor(p)}return o.objectMode?16:16*1024}return cr={getHighWaterMark:r},cr}var lr,tn;function Ri(){if(tn)return lr;tn=1,lr=t;function t(r,o){if(e("noDeprecation"))return r;var f=!1;function u(){if(!f){if(e("throwDeprecation"))throw new Error(o);e("traceDeprecation")?console.trace(o):console.warn(o),f=!0}return r.apply(this,arguments)}return u}function e(r){try{if(!pt.localStorage)return!1}catch{return!1}var o=pt.localStorage[r];return o==null?!1:String(o).toLowerCase()==="true"}return lr}var hr,rn;function nn(){if(rn)return hr;rn=1,hr=D;function t(L){var F=this;this.next=null,this.entry=null,this.finish=function(){Te(F,L)}}var e;D.WritableState=U;var r={deprecate:Ri()},o=Kr(),f=Mt().Buffer,u=(typeof pt<"u"?pt:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function c(L){return f.from(L)}function p(L){return f.isBuffer(L)||L instanceof u}var y=Jr(),b=en(),d=b.getHighWaterMark,I=wt().codes,B=I.ERR_INVALID_ARG_TYPE,q=I.ERR_METHOD_NOT_IMPLEMENTED,P=I.ERR_MULTIPLE_CALLBACK,W=I.ERR_STREAM_CANNOT_PIPE,j=I.ERR_STREAM_DESTROYED,x=I.ERR_STREAM_NULL_VALUES,R=I.ERR_STREAM_WRITE_AFTER_END,A=I.ERR_UNKNOWN_ENCODING,_=y.errorOrDestroy;yt()(D,o);function v(){}function U(L,F,K){e=e||Et(),L=L||{},typeof K!="boolean"&&(K=F instanceof e),this.objectMode=!!L.objectMode,K&&(this.objectMode=this.objectMode||!!L.writableObjectMode),this.highWaterMark=d(this,L,"writableHighWaterMark",K),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var X=L.decodeStrings===!1;this.decodeStrings=!X,this.defaultEncoding=L.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(ee){Ue(F,ee)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=L.emitClose!==!1,this.autoDestroy=!!L.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}U.prototype.getBuffer=function(){for(var F=this.bufferedRequest,K=[];F;)K.push(F),F=F.next;return K},(function(){try{Object.defineProperty(U.prototype,"buffer",{get:r.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var k;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(k=Function.prototype[Symbol.hasInstance],Object.defineProperty(D,Symbol.hasInstance,{value:function(F){return k.call(this,F)?!0:this!==D?!1:F&&F._writableState instanceof U}})):k=function(F){return F instanceof this};function D(L){e=e||Et();var F=this instanceof e;if(!F&&!k.call(D,this))return new D(L);this._writableState=new U(L,this,F),this.writable=!0,L&&(typeof L.write=="function"&&(this._write=L.write),typeof L.writev=="function"&&(this._writev=L.writev),typeof L.destroy=="function"&&(this._destroy=L.destroy),typeof L.final=="function"&&(this._final=L.final)),o.call(this)}D.prototype.pipe=function(){_(this,new W)};function H(L,F){var K=new R;_(L,K),fe.nextTick(F,K)}function z(L,F,K,X){var ee;return K===null?ee=new x:typeof K!="string"&&!F.objectMode&&(ee=new B("chunk",["string","Buffer"],K)),ee?(_(L,ee),fe.nextTick(X,ee),!1):!0}D.prototype.write=function(L,F,K){var X=this._writableState,ee=!1,E=!X.objectMode&&p(L);return E&&!f.isBuffer(L)&&(L=c(L)),typeof F=="function"&&(K=F,F=null),E?F="buffer":F||(F=X.defaultEncoding),typeof K!="function"&&(K=v),X.ending?H(this,K):(E||z(this,X,L,K))&&(X.pendingcb++,ee=N(this,X,E,L,F,K)),ee},D.prototype.cork=function(){this._writableState.corked++},D.prototype.uncork=function(){var L=this._writableState;L.corked&&(L.corked--,!L.writing&&!L.corked&&!L.bufferProcessing&&L.bufferedRequest&&We(this,L))},D.prototype.setDefaultEncoding=function(F){if(typeof F=="string"&&(F=F.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((F+"").toLowerCase())>-1))throw new A(F);return this._writableState.defaultEncoding=F,this},Object.defineProperty(D.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function re(L,F,K){return!L.objectMode&&L.decodeStrings!==!1&&typeof F=="string"&&(F=f.from(F,K)),F}Object.defineProperty(D.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function N(L,F,K,X,ee,E){if(!K){var m=re(F,X,ee);X!==m&&(K=!0,ee="buffer",X=m)}var G=F.objectMode?1:X.length;F.length+=G;var V=F.length<F.highWaterMark;if(V||(F.needDrain=!0),F.writing||F.corked){var ue=F.lastBufferedRequest;F.lastBufferedRequest={chunk:X,encoding:ee,isBuf:K,callback:E,next:null},ue?ue.next=F.lastBufferedRequest:F.bufferedRequest=F.lastBufferedRequest,F.bufferedRequestCount+=1}else ae(L,F,!1,G,X,ee,E);return V}function ae(L,F,K,X,ee,E,m){F.writelen=X,F.writecb=m,F.writing=!0,F.sync=!0,F.destroyed?F.onwrite(new j("write")):K?L._writev(ee,F.onwrite):L._write(ee,E,F.onwrite),F.sync=!1}function ve(L,F,K,X,ee){--F.pendingcb,K?(fe.nextTick(ee,X),fe.nextTick(ke,L,F),L._writableState.errorEmitted=!0,_(L,X)):(ee(X),L._writableState.errorEmitted=!0,_(L,X),ke(L,F))}function xe(L){L.writing=!1,L.writecb=null,L.length-=L.writelen,L.writelen=0}function Ue(L,F){var K=L._writableState,X=K.sync,ee=K.writecb;if(typeof ee!="function")throw new P;if(xe(K),F)ve(L,K,X,F,ee);else{var E=He(K)||L.destroyed;!E&&!K.corked&&!K.bufferProcessing&&K.bufferedRequest&&We(L,K),X?fe.nextTick(Ae,L,K,E,ee):Ae(L,K,E,ee)}}function Ae(L,F,K,X){K||De(L,F),F.pendingcb--,X(),ke(L,F)}function De(L,F){F.length===0&&F.needDrain&&(F.needDrain=!1,L.emit("drain"))}function We(L,F){F.bufferProcessing=!0;var K=F.bufferedRequest;if(L._writev&&K&&K.next){var X=F.bufferedRequestCount,ee=new Array(X),E=F.corkedRequestsFree;E.entry=K;for(var m=0,G=!0;K;)ee[m]=K,K.isBuf||(G=!1),K=K.next,m+=1;ee.allBuffers=G,ae(L,F,!0,F.length,ee,"",E.finish),F.pendingcb++,F.lastBufferedRequest=null,E.next?(F.corkedRequestsFree=E.next,E.next=null):F.corkedRequestsFree=new t(F),F.bufferedRequestCount=0}else{for(;K;){var V=K.chunk,ue=K.encoding,J=K.callback,oe=F.objectMode?1:V.length;if(ae(L,F,!1,oe,V,ue,J),K=K.next,F.bufferedRequestCount--,F.writing)break}K===null&&(F.lastBufferedRequest=null)}F.bufferedRequest=K,F.bufferProcessing=!1}D.prototype._write=function(L,F,K){K(new q("_write()"))},D.prototype._writev=null,D.prototype.end=function(L,F,K){var X=this._writableState;return typeof L=="function"?(K=L,L=null,F=null):typeof F=="function"&&(K=F,F=null),L!=null&&this.write(L,F),X.corked&&(X.corked=1,this.uncork()),X.ending||de(this,X,K),this},Object.defineProperty(D.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function He(L){return L.ending&&L.length===0&&L.bufferedRequest===null&&!L.finished&&!L.writing}function ht(L,F){L._final(function(K){F.pendingcb--,K&&_(L,K),F.prefinished=!0,L.emit("prefinish"),ke(L,F)})}function Ke(L,F){!F.prefinished&&!F.finalCalled&&(typeof L._final=="function"&&!F.destroyed?(F.pendingcb++,F.finalCalled=!0,fe.nextTick(ht,L,F)):(F.prefinished=!0,L.emit("prefinish")))}function ke(L,F){var K=He(F);if(K&&(Ke(L,F),F.pendingcb===0&&(F.finished=!0,L.emit("finish"),F.autoDestroy))){var X=L._readableState;(!X||X.autoDestroy&&X.endEmitted)&&L.destroy()}return K}function de(L,F,K){F.ending=!0,ke(L,F),K&&(F.finished?fe.nextTick(K):L.once("finish",K)),F.ended=!0,L.writable=!1}function Te(L,F,K){var X=L.entry;for(L.entry=null;X;){var ee=X.callback;F.pendingcb--,ee(K),X=X.next}F.corkedRequestsFree.next=L}return Object.defineProperty(D.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(F){this._writableState&&(this._writableState.destroyed=F)}}),D.prototype.destroy=y.destroy,D.prototype._undestroy=y.undestroy,D.prototype._destroy=function(L,F){F(L)},hr}var dr,on;function Et(){if(on)return dr;on=1;var t=Object.keys||function(b){var d=[];for(var I in b)d.push(I);return d};dr=c;var e=dn(),r=nn();yt()(c,e);for(var o=t(r.prototype),f=0;f<o.length;f++){var u=o[f];c.prototype[u]||(c.prototype[u]=r.prototype[u])}function c(b){if(!(this instanceof c))return new c(b);e.call(this,b),r.call(this,b),this.allowHalfOpen=!0,b&&(b.readable===!1&&(this.readable=!1),b.writable===!1&&(this.writable=!1),b.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",p)))}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function p(){this._writableState.ended||fe.nextTick(y,this)}function y(b){b.end()}return Object.defineProperty(c.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(d){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=d,this._writableState.destroyed=d)}}),dr}var pr={},Ot={exports:{}};var sn;function Ii(){return sn||(sn=1,(function(t,e){var r=Mt(),o=r.Buffer;function f(c,p){for(var y in c)p[y]=c[y]}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?t.exports=r:(f(r,e),e.Buffer=u);function u(c,p,y){return o(c,p,y)}u.prototype=Object.create(o.prototype),f(o,u),u.from=function(c,p,y){if(typeof c=="number")throw new TypeError("Argument must not be a number");return o(c,p,y)},u.alloc=function(c,p,y){if(typeof c!="number")throw new TypeError("Argument must be a number");var b=o(c);return p!==void 0?typeof y=="string"?b.fill(p,y):b.fill(p):b.fill(0),b},u.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return o(c)},u.allocUnsafeSlow=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(c)}})(Ot,Ot.exports)),Ot.exports}var an;function un(){if(an)return pr;an=1;var t=Ii().Buffer,e=t.isEncoding||function(x){switch(x=""+x,x&&x.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(x){if(!x)return"utf8";for(var R;;)switch(x){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return x;default:if(R)return;x=(""+x).toLowerCase(),R=!0}}function o(x){var R=r(x);if(typeof R!="string"&&(t.isEncoding===e||!e(x)))throw new Error("Unknown encoding: "+x);return R||x}pr.StringDecoder=f;function f(x){this.encoding=o(x);var R;switch(this.encoding){case"utf16le":this.text=I,this.end=B,R=4;break;case"utf8":this.fillLast=y,R=4;break;case"base64":this.text=q,this.end=P,R=3;break;default:this.write=W,this.end=j;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=t.allocUnsafe(R)}f.prototype.write=function(x){if(x.length===0)return"";var R,A;if(this.lastNeed){if(R=this.fillLast(x),R===void 0)return"";A=this.lastNeed,this.lastNeed=0}else A=0;return A<x.length?R?R+this.text(x,A):this.text(x,A):R||""},f.prototype.end=d,f.prototype.text=b,f.prototype.fillLast=function(x){if(this.lastNeed<=x.length)return x.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);x.copy(this.lastChar,this.lastTotal-this.lastNeed,0,x.length),this.lastNeed-=x.length};function u(x){return x<=127?0:x>>5===6?2:x>>4===14?3:x>>3===30?4:x>>6===2?-1:-2}function c(x,R,A){var _=R.length-1;if(_<A)return 0;var v=u(R[_]);return v>=0?(v>0&&(x.lastNeed=v-1),v):--_<A||v===-2?0:(v=u(R[_]),v>=0?(v>0&&(x.lastNeed=v-2),v):--_<A||v===-2?0:(v=u(R[_]),v>=0?(v>0&&(v===2?v=0:x.lastNeed=v-3),v):0))}function p(x,R,A){if((R[0]&192)!==128)return x.lastNeed=0,"�";if(x.lastNeed>1&&R.length>1){if((R[1]&192)!==128)return x.lastNeed=1,"�";if(x.lastNeed>2&&R.length>2&&(R[2]&192)!==128)return x.lastNeed=2,"�"}}function y(x){var R=this.lastTotal-this.lastNeed,A=p(this,x);if(A!==void 0)return A;if(this.lastNeed<=x.length)return x.copy(this.lastChar,R,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);x.copy(this.lastChar,R,0,x.length),this.lastNeed-=x.length}function b(x,R){var A=c(this,x,R);if(!this.lastNeed)return x.toString("utf8",R);this.lastTotal=A;var _=x.length-(A-this.lastNeed);return x.copy(this.lastChar,0,_),x.toString("utf8",R,_)}function d(x){var R=x&&x.length?this.write(x):"";return this.lastNeed?R+"�":R}function I(x,R){if((x.length-R)%2===0){var A=x.toString("utf16le",R);if(A){var _=A.charCodeAt(A.length-1);if(_>=55296&&_<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=x[x.length-2],this.lastChar[1]=x[x.length-1],A.slice(0,-1)}return A}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=x[x.length-1],x.toString("utf16le",R,x.length-1)}function B(x){var R=x&&x.length?this.write(x):"";if(this.lastNeed){var A=this.lastTotal-this.lastNeed;return R+this.lastChar.toString("utf16le",0,A)}return R}function q(x,R){var A=(x.length-R)%3;return A===0?x.toString("base64",R):(this.lastNeed=3-A,this.lastTotal=3,A===1?this.lastChar[0]=x[x.length-1]:(this.lastChar[0]=x[x.length-2],this.lastChar[1]=x[x.length-1]),x.toString("base64",R,x.length-A))}function P(x){var R=x&&x.length?this.write(x):"";return this.lastNeed?R+this.lastChar.toString("base64",0,3-this.lastNeed):R}function W(x){return x.toString(this.encoding)}function j(x){return x&&x.length?this.write(x):""}return pr}var yr,fn;function gr(){if(fn)return yr;fn=1;var t=wt().codes.ERR_STREAM_PREMATURE_CLOSE;function e(u){var c=!1;return function(){if(!c){c=!0;for(var p=arguments.length,y=new Array(p),b=0;b<p;b++)y[b]=arguments[b];u.apply(this,y)}}}function r(){}function o(u){return u.setHeader&&typeof u.abort=="function"}function f(u,c,p){if(typeof c=="function")return f(u,null,c);c||(c={}),p=e(p||r);var y=c.readable||c.readable!==!1&&u.readable,b=c.writable||c.writable!==!1&&u.writable,d=function(){u.writable||B()},I=u._writableState&&u._writableState.finished,B=function(){b=!1,I=!0,y||p.call(u)},q=u._readableState&&u._readableState.endEmitted,P=function(){y=!1,q=!0,b||p.call(u)},W=function(A){p.call(u,A)},j=function(){var A;if(y&&!q)return(!u._readableState||!u._readableState.ended)&&(A=new t),p.call(u,A);if(b&&!I)return(!u._writableState||!u._writableState.ended)&&(A=new t),p.call(u,A)},x=function(){u.req.on("finish",B)};return o(u)?(u.on("complete",B),u.on("abort",j),u.req?x():u.on("request",x)):b&&!u._writableState&&(u.on("end",d),u.on("close",d)),u.on("end",P),u.on("finish",B),c.error!==!1&&u.on("error",W),u.on("close",j),function(){u.removeListener("complete",B),u.removeListener("abort",j),u.removeListener("request",x),u.req&&u.req.removeListener("finish",B),u.removeListener("end",d),u.removeListener("close",d),u.removeListener("finish",B),u.removeListener("end",P),u.removeListener("error",W),u.removeListener("close",j)}}return yr=f,yr}var wr,cn;function Bi(){if(cn)return wr;cn=1;var t;function e(A,_,v){return _=r(_),_ in A?Object.defineProperty(A,_,{value:v,enumerable:!0,configurable:!0,writable:!0}):A[_]=v,A}function r(A){var _=o(A,"string");return typeof _=="symbol"?_:String(_)}function o(A,_){if(typeof A!="object"||A===null)return A;var v=A[Symbol.toPrimitive];if(v!==void 0){var U=v.call(A,_);if(typeof U!="object")return U;throw new TypeError("@@toPrimitive must return a primitive value.")}return(_==="string"?String:Number)(A)}var f=gr(),u=Symbol("lastResolve"),c=Symbol("lastReject"),p=Symbol("error"),y=Symbol("ended"),b=Symbol("lastPromise"),d=Symbol("handlePromise"),I=Symbol("stream");function B(A,_){return{value:A,done:_}}function q(A){var _=A[u];if(_!==null){var v=A[I].read();v!==null&&(A[b]=null,A[u]=null,A[c]=null,_(B(v,!1)))}}function P(A){fe.nextTick(q,A)}function W(A,_){return function(v,U){A.then(function(){if(_[y]){v(B(void 0,!0));return}_[d](v,U)},U)}}var j=Object.getPrototypeOf(function(){}),x=Object.setPrototypeOf((t={get stream(){return this[I]},next:function(){var _=this,v=this[p];if(v!==null)return Promise.reject(v);if(this[y])return Promise.resolve(B(void 0,!0));if(this[I].destroyed)return new Promise(function(H,z){fe.nextTick(function(){_[p]?z(_[p]):H(B(void 0,!0))})});var U=this[b],k;if(U)k=new Promise(W(U,this));else{var D=this[I].read();if(D!==null)return Promise.resolve(B(D,!1));k=new Promise(this[d])}return this[b]=k,k}},e(t,Symbol.asyncIterator,function(){return this}),e(t,"return",function(){var _=this;return new Promise(function(v,U){_[I].destroy(null,function(k){if(k){U(k);return}v(B(void 0,!0))})})}),t),j),R=function(_){var v,U=Object.create(x,(v={},e(v,I,{value:_,writable:!0}),e(v,u,{value:null,writable:!0}),e(v,c,{value:null,writable:!0}),e(v,p,{value:null,writable:!0}),e(v,y,{value:_._readableState.endEmitted,writable:!0}),e(v,d,{value:function(D,H){var z=U[I].read();z?(U[b]=null,U[u]=null,U[c]=null,D(B(z,!1))):(U[u]=D,U[c]=H)},writable:!0}),v));return U[b]=null,f(_,function(k){if(k&&k.code!=="ERR_STREAM_PREMATURE_CLOSE"){var D=U[c];D!==null&&(U[b]=null,U[u]=null,U[c]=null,D(k)),U[p]=k;return}var H=U[u];H!==null&&(U[b]=null,U[u]=null,U[c]=null,H(B(void 0,!0))),U[y]=!0}),_.on("readable",P.bind(null,U)),U};return wr=R,wr}var Er,ln;function Ai(){return ln||(ln=1,Er=function(){throw new Error("Readable.from is not available in the browser")}),Er}var mr,hn;function dn(){if(hn)return mr;hn=1,mr=H;var t;H.ReadableState=D,rr().EventEmitter;var e=function(m,G){return m.listeners(G).length},r=Kr(),o=Mt().Buffer,f=(typeof pt<"u"?pt:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function u(E){return o.from(E)}function c(E){return o.isBuffer(E)||E instanceof f}var p=zr,y;p&&p.debuglog?y=p.debuglog("stream"):y=function(){};var b=vi(),d=Jr(),I=en(),B=I.getHighWaterMark,q=wt().codes,P=q.ERR_INVALID_ARG_TYPE,W=q.ERR_STREAM_PUSH_AFTER_EOF,j=q.ERR_METHOD_NOT_IMPLEMENTED,x=q.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,R,A,_;yt()(H,r);var v=d.errorOrDestroy,U=["error","close","destroy","pause","resume"];function k(E,m,G){if(typeof E.prependListener=="function")return E.prependListener(m,G);!E._events||!E._events[m]?E.on(m,G):Array.isArray(E._events[m])?E._events[m].unshift(G):E._events[m]=[G,E._events[m]]}function D(E,m,G){t=t||Et(),E=E||{},typeof G!="boolean"&&(G=m instanceof t),this.objectMode=!!E.objectMode,G&&(this.objectMode=this.objectMode||!!E.readableObjectMode),this.highWaterMark=B(this,E,"readableHighWaterMark",G),this.buffer=new b,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=E.emitClose!==!1,this.autoDestroy=!!E.autoDestroy,this.destroyed=!1,this.defaultEncoding=E.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,E.encoding&&(R||(R=un().StringDecoder),this.decoder=new R(E.encoding),this.encoding=E.encoding)}function H(E){if(t=t||Et(),!(this instanceof H))return new H(E);var m=this instanceof t;this._readableState=new D(E,this,m),this.readable=!0,E&&(typeof E.read=="function"&&(this._read=E.read),typeof E.destroy=="function"&&(this._destroy=E.destroy)),r.call(this)}Object.defineProperty(H.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(m){this._readableState&&(this._readableState.destroyed=m)}}),H.prototype.destroy=d.destroy,H.prototype._undestroy=d.undestroy,H.prototype._destroy=function(E,m){m(E)},H.prototype.push=function(E,m){var G=this._readableState,V;return G.objectMode?V=!0:typeof E=="string"&&(m=m||G.defaultEncoding,m!==G.encoding&&(E=o.from(E,m),m=""),V=!0),z(this,E,m,!1,V)},H.prototype.unshift=function(E){return z(this,E,null,!0,!1)};function z(E,m,G,V,ue){y("readableAddChunk",m);var J=E._readableState;if(m===null)J.reading=!1,Ue(E,J);else{var oe;if(ue||(oe=N(J,m)),oe)v(E,oe);else if(J.objectMode||m&&m.length>0)if(typeof m!="string"&&!J.objectMode&&Object.getPrototypeOf(m)!==o.prototype&&(m=u(m)),V)J.endEmitted?v(E,new x):re(E,J,m,!0);else if(J.ended)v(E,new W);else{if(J.destroyed)return!1;J.reading=!1,J.decoder&&!G?(m=J.decoder.write(m),J.objectMode||m.length!==0?re(E,J,m,!1):We(E,J)):re(E,J,m,!1)}else V||(J.reading=!1,We(E,J))}return!J.ended&&(J.length<J.highWaterMark||J.length===0)}function re(E,m,G,V){m.flowing&&m.length===0&&!m.sync?(m.awaitDrain=0,E.emit("data",G)):(m.length+=m.objectMode?1:G.length,V?m.buffer.unshift(G):m.buffer.push(G),m.needReadable&&Ae(E)),We(E,m)}function N(E,m){var G;return!c(m)&&typeof m!="string"&&m!==void 0&&!E.objectMode&&(G=new P("chunk",["string","Buffer","Uint8Array"],m)),G}H.prototype.isPaused=function(){return this._readableState.flowing===!1},H.prototype.setEncoding=function(E){R||(R=un().StringDecoder);var m=new R(E);this._readableState.decoder=m,this._readableState.encoding=this._readableState.decoder.encoding;for(var G=this._readableState.buffer.head,V="";G!==null;)V+=m.write(G.data),G=G.next;return this._readableState.buffer.clear(),V!==""&&this._readableState.buffer.push(V),this._readableState.length=V.length,this};var ae=1073741824;function ve(E){return E>=ae?E=ae:(E--,E|=E>>>1,E|=E>>>2,E|=E>>>4,E|=E>>>8,E|=E>>>16,E++),E}function xe(E,m){return E<=0||m.length===0&&m.ended?0:m.objectMode?1:E!==E?m.flowing&&m.length?m.buffer.head.data.length:m.length:(E>m.highWaterMark&&(m.highWaterMark=ve(E)),E<=m.length?E:m.ended?m.length:(m.needReadable=!0,0))}H.prototype.read=function(E){y("read",E),E=parseInt(E,10);var m=this._readableState,G=E;if(E!==0&&(m.emittedReadable=!1),E===0&&m.needReadable&&((m.highWaterMark!==0?m.length>=m.highWaterMark:m.length>0)||m.ended))return y("read: emitReadable",m.length,m.ended),m.length===0&&m.ended?K(this):Ae(this),null;if(E=xe(E,m),E===0&&m.ended)return m.length===0&&K(this),null;var V=m.needReadable;y("need readable",V),(m.length===0||m.length-E<m.highWaterMark)&&(V=!0,y("length less than watermark",V)),m.ended||m.reading?(V=!1,y("reading or ended",V)):V&&(y("do read"),m.reading=!0,m.sync=!0,m.length===0&&(m.needReadable=!0),this._read(m.highWaterMark),m.sync=!1,m.reading||(E=xe(G,m)));var ue;return E>0?ue=F(E,m):ue=null,ue===null?(m.needReadable=m.length<=m.highWaterMark,E=0):(m.length-=E,m.awaitDrain=0),m.length===0&&(m.ended||(m.needReadable=!0),G!==E&&m.ended&&K(this)),ue!==null&&this.emit("data",ue),ue};function Ue(E,m){if(y("onEofChunk"),!m.ended){if(m.decoder){var G=m.decoder.end();G&&G.length&&(m.buffer.push(G),m.length+=m.objectMode?1:G.length)}m.ended=!0,m.sync?Ae(E):(m.needReadable=!1,m.emittedReadable||(m.emittedReadable=!0,De(E)))}}function Ae(E){var m=E._readableState;y("emitReadable",m.needReadable,m.emittedReadable),m.needReadable=!1,m.emittedReadable||(y("emitReadable",m.flowing),m.emittedReadable=!0,fe.nextTick(De,E))}function De(E){var m=E._readableState;y("emitReadable_",m.destroyed,m.length,m.ended),!m.destroyed&&(m.length||m.ended)&&(E.emit("readable"),m.emittedReadable=!1),m.needReadable=!m.flowing&&!m.ended&&m.length<=m.highWaterMark,L(E)}function We(E,m){m.readingMore||(m.readingMore=!0,fe.nextTick(He,E,m))}function He(E,m){for(;!m.reading&&!m.ended&&(m.length<m.highWaterMark||m.flowing&&m.length===0);){var G=m.length;if(y("maybeReadMore read 0"),E.read(0),G===m.length)break}m.readingMore=!1}H.prototype._read=function(E){v(this,new j("_read()"))},H.prototype.pipe=function(E,m){var G=this,V=this._readableState;switch(V.pipesCount){case 0:V.pipes=E;break;case 1:V.pipes=[V.pipes,E];break;default:V.pipes.push(E);break}V.pipesCount+=1,y("pipe count=%d opts=%j",V.pipesCount,m);var ue=(!m||m.end!==!1)&&E!==fe.stdout&&E!==fe.stderr,J=ue?Ye:Oe;V.endEmitted?fe.nextTick(J):G.once("end",J),E.on("unpipe",oe);function oe(Ce,Se){y("onunpipe"),Ce===G&&Se&&Se.hasUnpiped===!1&&(Se.hasUnpiped=!0,Nt())}function Ye(){y("onend"),E.end()}var it=ht(G);E.on("drain",it);var ot=!1;function Nt(){y("cleanup"),E.removeListener("close",Pe),E.removeListener("finish",Re),E.removeListener("drain",it),E.removeListener("error",_e),E.removeListener("unpipe",oe),G.removeListener("end",Ye),G.removeListener("end",Oe),G.removeListener("data",ge),ot=!0,V.awaitDrain&&(!E._writableState||E._writableState.needDrain)&&it()}G.on("data",ge);function ge(Ce){y("ondata");var Se=E.write(Ce);y("dest.write",Se),Se===!1&&((V.pipesCount===1&&V.pipes===E||V.pipesCount>1&&ee(V.pipes,E)!==-1)&&!ot&&(y("false write response, pause",V.awaitDrain),V.awaitDrain++),G.pause())}function _e(Ce){y("onerror",Ce),Oe(),E.removeListener("error",_e),e(E,"error")===0&&v(E,Ce)}k(E,"error",_e);function Pe(){E.removeListener("finish",Re),Oe()}E.once("close",Pe);function Re(){y("onfinish"),E.removeListener("close",Pe),Oe()}E.once("finish",Re);function Oe(){y("unpipe"),G.unpipe(E)}return E.emit("pipe",G),V.flowing||(y("pipe resume"),G.resume()),E};function ht(E){return function(){var G=E._readableState;y("pipeOnDrain",G.awaitDrain),G.awaitDrain&&G.awaitDrain--,G.awaitDrain===0&&e(E,"data")&&(G.flowing=!0,L(E))}}H.prototype.unpipe=function(E){var m=this._readableState,G={hasUnpiped:!1};if(m.pipesCount===0)return this;if(m.pipesCount===1)return E&&E!==m.pipes?this:(E||(E=m.pipes),m.pipes=null,m.pipesCount=0,m.flowing=!1,E&&E.emit("unpipe",this,G),this);if(!E){var V=m.pipes,ue=m.pipesCount;m.pipes=null,m.pipesCount=0,m.flowing=!1;for(var J=0;J<ue;J++)V[J].emit("unpipe",this,{hasUnpiped:!1});return this}var oe=ee(m.pipes,E);return oe===-1?this:(m.pipes.splice(oe,1),m.pipesCount-=1,m.pipesCount===1&&(m.pipes=m.pipes[0]),E.emit("unpipe",this,G),this)},H.prototype.on=function(E,m){var G=r.prototype.on.call(this,E,m),V=this._readableState;return E==="data"?(V.readableListening=this.listenerCount("readable")>0,V.flowing!==!1&&this.resume()):E==="readable"&&!V.endEmitted&&!V.readableListening&&(V.readableListening=V.needReadable=!0,V.flowing=!1,V.emittedReadable=!1,y("on readable",V.length,V.reading),V.length?Ae(this):V.reading||fe.nextTick(ke,this)),G},H.prototype.addListener=H.prototype.on,H.prototype.removeListener=function(E,m){var G=r.prototype.removeListener.call(this,E,m);return E==="readable"&&fe.nextTick(Ke,this),G},H.prototype.removeAllListeners=function(E){var m=r.prototype.removeAllListeners.apply(this,arguments);return(E==="readable"||E===void 0)&&fe.nextTick(Ke,this),m};function Ke(E){var m=E._readableState;m.readableListening=E.listenerCount("readable")>0,m.resumeScheduled&&!m.paused?m.flowing=!0:E.listenerCount("data")>0&&E.resume()}function ke(E){y("readable nexttick read 0"),E.read(0)}H.prototype.resume=function(){var E=this._readableState;return E.flowing||(y("resume"),E.flowing=!E.readableListening,de(this,E)),E.paused=!1,this};function de(E,m){m.resumeScheduled||(m.resumeScheduled=!0,fe.nextTick(Te,E,m))}function Te(E,m){y("resume",m.reading),m.reading||E.read(0),m.resumeScheduled=!1,E.emit("resume"),L(E),m.flowing&&!m.reading&&E.read(0)}H.prototype.pause=function(){return y("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(y("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function L(E){var m=E._readableState;for(y("flow",m.flowing);m.flowing&&E.read()!==null;);}H.prototype.wrap=function(E){var m=this,G=this._readableState,V=!1;E.on("end",function(){if(y("wrapped end"),G.decoder&&!G.ended){var oe=G.decoder.end();oe&&oe.length&&m.push(oe)}m.push(null)}),E.on("data",function(oe){if(y("wrapped data"),G.decoder&&(oe=G.decoder.write(oe)),!(G.objectMode&&oe==null)&&!(!G.objectMode&&(!oe||!oe.length))){var Ye=m.push(oe);Ye||(V=!0,E.pause())}});for(var ue in E)this[ue]===void 0&&typeof E[ue]=="function"&&(this[ue]=(function(Ye){return function(){return E[Ye].apply(E,arguments)}})(ue));for(var J=0;J<U.length;J++)E.on(U[J],this.emit.bind(this,U[J]));return this._read=function(oe){y("wrapped _read",oe),V&&(V=!1,E.resume())},this},typeof Symbol=="function"&&(H.prototype[Symbol.asyncIterator]=function(){return A===void 0&&(A=Bi()),A(this)}),Object.defineProperty(H.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(H.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(H.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(m){this._readableState&&(this._readableState.flowing=m)}}),H._fromList=F,Object.defineProperty(H.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function F(E,m){if(m.length===0)return null;var G;return m.objectMode?G=m.buffer.shift():!E||E>=m.length?(m.decoder?G=m.buffer.join(""):m.buffer.length===1?G=m.buffer.first():G=m.buffer.concat(m.length),m.buffer.clear()):G=m.buffer.consume(E,m.decoder),G}function K(E){var m=E._readableState;y("endReadable",m.endEmitted),m.endEmitted||(m.ended=!0,fe.nextTick(X,m,E))}function X(E,m){if(y("endReadableNT",E.endEmitted,E.length),!E.endEmitted&&E.length===0&&(E.endEmitted=!0,m.readable=!1,m.emit("end"),E.autoDestroy)){var G=m._writableState;(!G||G.autoDestroy&&G.finished)&&m.destroy()}}typeof Symbol=="function"&&(H.from=function(E,m){return _===void 0&&(_=Ai()),_(H,E,m)});function ee(E,m){for(var G=0,V=E.length;G<V;G++)if(E[G]===m)return G;return-1}return mr}var br,pn;function yn(){if(pn)return br;pn=1,br=p;var t=wt().codes,e=t.ERR_METHOD_NOT_IMPLEMENTED,r=t.ERR_MULTIPLE_CALLBACK,o=t.ERR_TRANSFORM_ALREADY_TRANSFORMING,f=t.ERR_TRANSFORM_WITH_LENGTH_0,u=Et();yt()(p,u);function c(d,I){var B=this._transformState;B.transforming=!1;var q=B.writecb;if(q===null)return this.emit("error",new r);B.writechunk=null,B.writecb=null,I!=null&&this.push(I),q(d);var P=this._readableState;P.reading=!1,(P.needReadable||P.length<P.highWaterMark)&&this._read(P.highWaterMark)}function p(d){if(!(this instanceof p))return new p(d);u.call(this,d),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,d&&(typeof d.transform=="function"&&(this._transform=d.transform),typeof d.flush=="function"&&(this._flush=d.flush)),this.on("prefinish",y)}function y(){var d=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(I,B){b(d,I,B)}):b(this,null,null)}p.prototype.push=function(d,I){return this._transformState.needTransform=!1,u.prototype.push.call(this,d,I)},p.prototype._transform=function(d,I,B){B(new e("_transform()"))},p.prototype._write=function(d,I,B){var q=this._transformState;if(q.writecb=B,q.writechunk=d,q.writeencoding=I,!q.transforming){var P=this._readableState;(q.needTransform||P.needReadable||P.length<P.highWaterMark)&&this._read(P.highWaterMark)}},p.prototype._read=function(d){var I=this._transformState;I.writechunk!==null&&!I.transforming?(I.transforming=!0,this._transform(I.writechunk,I.writeencoding,I.afterTransform)):I.needTransform=!0},p.prototype._destroy=function(d,I){u.prototype._destroy.call(this,d,function(B){I(B)})};function b(d,I,B){if(I)return d.emit("error",I);if(B!=null&&d.push(B),d._writableState.length)throw new f;if(d._transformState.transforming)throw new o;return d.push(null)}return br}var _r,gn;function Ni(){if(gn)return _r;gn=1,_r=e;var t=yn();yt()(e,t);function e(r){if(!(this instanceof e))return new e(r);t.call(this,r)}return e.prototype._transform=function(r,o,f){f(null,r)},_r}var Tr,wn;function Fi(){if(wn)return Tr;wn=1;var t;function e(B){var q=!1;return function(){q||(q=!0,B.apply(void 0,arguments))}}var r=wt().codes,o=r.ERR_MISSING_ARGS,f=r.ERR_STREAM_DESTROYED;function u(B){if(B)throw B}function c(B){return B.setHeader&&typeof B.abort=="function"}function p(B,q,P,W){W=e(W);var j=!1;B.on("close",function(){j=!0}),t===void 0&&(t=gr()),t(B,{readable:q,writable:P},function(R){if(R)return W(R);j=!0,W()});var x=!1;return function(R){if(!j&&!x){if(x=!0,c(B))return B.abort();if(typeof B.destroy=="function")return B.destroy();W(R||new f("pipe"))}}}function y(B){B()}function b(B,q){return B.pipe(q)}function d(B){return!B.length||typeof B[B.length-1]!="function"?u:B.pop()}function I(){for(var B=arguments.length,q=new Array(B),P=0;P<B;P++)q[P]=arguments[P];var W=d(q);if(Array.isArray(q[0])&&(q=q[0]),q.length<2)throw new o("streams");var j,x=q.map(function(R,A){var _=A<q.length-1,v=A>0;return p(R,_,v,function(U){j||(j=U),U&&x.forEach(y),!_&&(x.forEach(y),W(j))})});return q.reduce(b)}return Tr=I,Tr}var xr,En;function Ui(){if(En)return xr;En=1,xr=r;var t=rr().EventEmitter,e=yt();e(r,t),r.Readable=dn(),r.Writable=nn(),r.Duplex=Et(),r.Transform=yn(),r.PassThrough=Ni(),r.finished=gr(),r.pipeline=Fi(),r.Stream=r;function r(){t.call(this)}return r.prototype.pipe=function(o,f){var u=this;function c(q){o.writable&&o.write(q)===!1&&u.pause&&u.pause()}u.on("data",c);function p(){u.readable&&u.resume&&u.resume()}o.on("drain",p),!o._isStdio&&(!f||f.end!==!1)&&(u.on("end",b),u.on("close",d));var y=!1;function b(){y||(y=!0,o.end())}function d(){y||(y=!0,typeof o.destroy=="function"&&o.destroy())}function I(q){if(B(),t.listenerCount(this,"error")===0)throw q}u.on("error",I),o.on("error",I);function B(){u.removeListener("data",c),o.removeListener("drain",p),u.removeListener("end",b),u.removeListener("close",d),u.removeListener("error",I),o.removeListener("error",I),u.removeListener("end",B),u.removeListener("close",B),o.removeListener("close",B)}return u.on("end",B),u.on("close",B),o.on("close",B),o.emit("pipe",u),o},xr}var Dt=Ui();const Li="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let bt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=Li[r[t]&63];return e};class _t extends Promise{#e;#t;constructor(e){super(r=>{r()}),this.#e=e}static from(e){return new _t(r=>{r(e())})}static resolve(e){return new _t(r=>{r(e)})}static reject(e){return new _t((r,o)=>{o(e)})}then(e,r){return this.#t??=new Promise(this.#e),this.#t.then(e,r)}catch(e){return this.#t??=new Promise(this.#e),this.#t.catch(e)}finally(e){return this.#t??=new Promise(this.#e),this.#t.finally(e)}}function Mi(t){const e=t.reduce((f,u)=>f+u.length,0),r=new Uint8Array(e);let o=0;for(const f of t)r.set(f,o),o+=f.length;return r}function mn(t){return new _t((e,r)=>{const o=[];t.on("data",f=>{const u=bn(f);o.push(u)}),t.on("end",()=>{e(Mi(o))}),t.on("error",f=>{r(f)})})}function bn(t){let e;return t instanceof tr?e=new Uint8Array(t.buffer,t.byteOffset,t.length):t instanceof Uint8Array?e=t:typeof t=="string"?e=new TextEncoder().encode(t):e=new TextEncoder().encode(String(t)),e}function _n(t,e,r){if(t.byteLength===0)r(void 0,void 0,!0);else for(let o=0;o<t.byteLength;o+=e){const f=Math.min(t.byteLength-o,e),u=t.subarray(o,o+f),c=o+f>=t.byteLength;r(u,void 0,c)}}function Tn(t,e,r,o,f){t.on("readable",()=>{let u;for(;(u=t.read(e))!==null;){const c=bn(u);r(c,void 0,!1)}}),t.on("end",()=>{r(void 0,void 0,!0),o()}),t.on("error",u=>{r(void 0,u.message,!0),f(u)})}const Y={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},ie={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,CBOR:24,URI:32,BASE64URL:33,BASE64:34,DATE_EPOCH_DAYS:100,SET:258,JSON:262,WTF8:273,DATE_FULL:1004,REGEXP:21066,SELF_DESCRIBED:55799,INVALID_16:65535,INVALID_32:4294967295,INVALID_64:0xffffffffffffffffn},Q={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},et={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};let Ie=class{static BREAK=Symbol.for("github.com/hildjj/cbor2/break");static ENCODED=Symbol.for("github.com/hildjj/cbor2/cbor-encoded");static LENGTH=Symbol.for("github.com/hildjj/cbor2/length")};const kt={MIN:-(2n**63n),MAX:2n**64n-1n};let Z=class Zt{static#e=new Map;tag;contents;constructor(e,r=void 0){this.tag=e,this.contents=r}get noChildren(){return!!Zt.#e.get(this.tag)?.noChildren}static registerDecoder(e,r,o){const f=this.#e.get(e);return this.#e.set(e,r),f&&("comment"in r||(r.comment=f.comment),"noChildren"in r||(r.noChildren=f.noChildren)),o&&!r.comment&&(r.comment=()=>`(${o})`),f}static clearDecoder(e){const r=this.#e.get(e);return this.#e.delete(e),r}static getDecoder(e){return this.#e.get(e)}static getAllDecoders(){return new Map(this.#e)}*[Symbol.iterator](){yield this.contents}push(e){return this.contents=e,1}decode(e){const r=e?.tags?.get(this.tag)??(e?.ignoreGlobalTags?void 0:Zt.#e.get(this.tag));return r?r(this,e):this}comment(e,r){const o=e?.tags?.get(this.tag)??(e?.ignoreGlobalTags?void 0:Zt.#e.get(this.tag));if(o?.comment)return o.comment(this,e,r)}toCBOR(){return[this.tag,this.contents]}[Symbol.for("nodejs.util.inspect.custom")](e,r,o){return`${this.tag}(${o(this.contents,r)})`}};function Pt(t){if(t!=null&&typeof t=="object")return t[Ie.ENCODED]}function Oi(t){if(t!=null&&typeof t=="object")return t[Ie.LENGTH]}function Tt(t,e){Object.defineProperty(t,Ie.ENCODED,{configurable:!0,enumerable:!1,value:e})}function xt(t,e){const r=Object(t);return Tt(r,e),r}const Sr=Symbol("CBOR_RANGES");function xn(t,e){Object.defineProperty(t,Sr,{configurable:!1,enumerable:!1,writable:!1,value:e})}function Ct(t){return t[Sr]}function Di(t){return Ct(t)!==void 0}function vr(t,e=0,r=t.length-1){const o=t.subarray(e,r),f=Ct(t);if(f){const u=[];for(const c of f)if(c[0]>=e&&c[0]+c[1]<=r){const p=[...c];p[0]-=e,u.push(p)}u.length&&xn(o,u)}return o}function Sn(t){let e=Math.ceil(t.length/2);const r=new Uint8Array(e);e--;for(let o=t.length,f=o-2;o>=0;o=f,f-=2,e--)r[e]=parseInt(t.substring(f,o),16);return r}function Ne(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function ki(t){const e=t.reduce((c,p)=>c+p.length,0),r=t.some(c=>Di(c)),o=[],f=new Uint8Array(e);let u=0;for(const c of t){if(!(c instanceof Uint8Array))throw new TypeError(`Invalid array: ${c}`);if(f.set(c,u),r){const p=c[Sr]??[[0,c.length]];for(const y of p)y[0]+=u;o.push(...p)}u+=c.length}return r&&xn(f,o),f}function Rr(t){const e=atob(t);return Uint8Array.from(e,r=>r.codePointAt(0))}const Pi={"-":"+",_:"/"};function Ci(t){const e=t.replace(/[_-]/g,r=>Pi[r]);return Rr(e.padEnd(Math.ceil(e.length/4)*4,"="))}function $i(){const t=new Uint8Array(4),e=new Uint32Array(t.buffer);return!((e[0]=1)&t[0])}function vn(t){let e="";for(const r of t){const o=r.codePointAt(0)?.toString(16).padStart(4,"0");e&&(e+=", "),e+=`U+${o}`}return e}class Rn{#e=new Map;registerEncoder(e,r){const o=this.#e.get(e);return this.#e.set(e,r),o}get(e){return this.#e.get(e)}delete(e){return this.#e.delete(e)}clear(){this.#e.clear()}}function In(t,e){const[r,o,f]=t,[u,c,p]=e,y=Math.min(f.length,p.length);for(let b=0;b<y;b++){const d=f[b]-p[b];if(d!==0)return d}return 0}class $t{static defaultOptions={chunkSize:4096};#e;#t=[];#r=null;#n=0;#i=0;constructor(e={}){if(this.#e={...$t.defaultOptions,...e},this.#e.chunkSize<8)throw new RangeError(`Expected size >= 8, got ${this.#e.chunkSize}`);this.#o()}get length(){return this.#i}read(){this.#u();const e=new Uint8Array(this.#i);let r=0;for(const o of this.#t)e.set(o,r),r+=o.length;return this.#o(),e}write(e){const r=e.length;r>this.#f()?(this.#u(),r>this.#e.chunkSize?(this.#t.push(e),this.#o()):(this.#o(),this.#t[this.#t.length-1].set(e),this.#n=r)):(this.#t[this.#t.length-1].set(e,this.#n),this.#n+=r),this.#i+=r}writeUint8(e){this.#s(1),this.#r.setUint8(this.#n,e),this.#a(1)}writeUint16(e,r=!1){this.#s(2),this.#r.setUint16(this.#n,e,r),this.#a(2)}writeUint32(e,r=!1){this.#s(4),this.#r.setUint32(this.#n,e,r),this.#a(4)}writeBigUint64(e,r=!1){this.#s(8),this.#r.setBigUint64(this.#n,e,r),this.#a(8)}writeInt16(e,r=!1){this.#s(2),this.#r.setInt16(this.#n,e,r),this.#a(2)}writeInt32(e,r=!1){this.#s(4),this.#r.setInt32(this.#n,e,r),this.#a(4)}writeBigInt64(e,r=!1){this.#s(8),this.#r.setBigInt64(this.#n,e,r),this.#a(8)}writeFloat32(e,r=!1){this.#s(4),this.#r.setFloat32(this.#n,e,r),this.#a(4)}writeFloat64(e,r=!1){this.#s(8),this.#r.setFloat64(this.#n,e,r),this.#a(8)}clear(){this.#i=0,this.#t=[],this.#o()}#o(){const e=new Uint8Array(this.#e.chunkSize);this.#t.push(e),this.#n=0,this.#r=new DataView(e.buffer,e.byteOffset,e.byteLength)}#u(){if(this.#n===0){this.#t.pop();return}const e=this.#t.length-1;this.#t[e]=this.#t[e].subarray(0,this.#n),this.#n=0,this.#r=null}#f(){const e=this.#t.length-1;return this.#t[e].length-this.#n}#s(e){this.#f()<e&&(this.#u(),this.#o())}#a(e){this.#n+=e,this.#i+=e}}const Ir=1n<<15n,St=0b11111n<<10n,Bn=1n<<9n,An=Bn-1n,Nn=Bn|An,Br=1n<<31n,vt=0b11111111n<<23n,Fn=1n<<22n,Un=Fn-1n,Ln=Fn|Un,qt=1n<<63n,Je=0b11111111111n<<52n,Rt=1n<<51n,jt=Rt-1n,Mn=Rt|jt,On=jt-(An<<42n),Dn=jt-(Un<<29n),qi={2:"0b",8:"0o",16:"0x"};var ji=(t=>(t[t.NATURAL=-2]="NATURAL",t[t.UNKNOWN=-1]="UNKNOWN",t[t.F16=2]="F16",t[t.F32=4]="F32",t[t.F64=8]="F64",t))(ji||{});function kn(t,e,r,o){let f="nan'";return t.quiet||(f+="!"),t.sign===-1&&(f+="-"),f+=o(Math.abs(t.payload),r),f+="'",f+=t.encodingIndicator,f}let Gi=class extends Number{#e;#t=-1;constructor(e,r=!0,o=-1){super(NaN);const f=e;if(typeof e=="number"){if(!Number.isSafeInteger(e))throw new Error(`Invalid NAN payload: ${e}`);e=BigInt(e);let u=0n;if(e<0&&(u=qt,e=-e),e>=Rt)throw new Error(`Payload too large: ${f}`);const c=r?Rt:0n;switch(this.#e=u|Je|c|e,o){case-2:throw new Error("NAN_SIZE.NATURAL only valid for bigint constructor");case-1:o=this.preferredSize;break;case 2:if(this.#e&On)throw new Error("Invalid size for payload");break;case 4:if(this.#e&Dn)throw new Error("Invalid size for payload");break;case 8:break;default:throw new Error(`Invalid size: ${o}`)}this.#t=o}else if(typeof e=="bigint"){let u=-1;if((e&Je)===Je)this.#e=e,u=8;else if((e&vt)===vt){const c=(e&Br)<<32n;this.#e=c|Je|(e&Ln)<<29n,u=4}else if((e&St)===St){const c=(e&Ir)<<48n;this.#e=c|Je|(e&Nn)<<42n,u=2}else throw new Error(`Invalid raw NaN value: ${e}`);if(o===-1)this.#t=this.preferredSize;else if(o===-2)this.#t=u;else{if(o<u)throw new Error("Invalid bigint NaN size");this.#t=o}}else{const u=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.length){case 3:{if(e[0]!==249)throw new Error("Invalid CBOR encoding for half float");const c=BigInt(u.getUint16(1,!1));if((c&St)!==St)throw new Error("Not a NaN");const p=(c&Ir)<<48n;this.#e=p|Je|(c&Nn)<<42n,this.#t=2;break}case 5:{if(e[0]!==250)throw new Error("Invalid CBOR encoding for single float");const c=BigInt(u.getUint32(1,!1));if((c&vt)!==vt)throw new Error("Not a NaN");const p=(c&Br)<<32n;this.#e=p|Je|(c&Ln)<<29n,this.#t=4;break}case 9:{if(e[0]!==251)throw new Error("Invalid CBOR encoding for double float");if(this.#e=u.getBigUint64(1,!1),(this.#e&Je)!==Je)throw new Error("Not a NaN (NaNaN)");this.#t=8;break}default:throw new RangeError(`Invalid NAN size (should be 2, 4, or 8): ${e.length-1}`)}}if(!this.payload&&!this.quiet)throw new Error("Signalling NaN with zero payload")}get bytes(){const e=new ArrayBuffer(this.#t+1),r=new DataView(e);switch(this.#t){case 2:{r.setUint8(0,249);const o=(this.#e&qt?Ir:0n)|St|(this.#e&Mn)>>42n;r.setUint16(1,Number(o),!1);break}case 4:{r.setUint8(0,250);const o=(this.#e&qt?Br:0n)|vt|(this.#e&Mn)>>29n;r.setUint32(1,Number(o),!1);break}case 8:r.setUint8(0,251),r.setBigUint64(1,this.#e);break}return new Uint8Array(e)}get quiet(){return!!(this.#e&Rt)}get sign(){return this.#e&qt?-1:1}get payload(){return Number(this.#e&jt)*this.sign}get raw(){return this.#e}get encodingIndicator(){switch(this.#t){case 2:return"_1";case 4:return"_2"}return"_3"}get size(){return this.#t}get preferredSize(){return(this.#e&On)===0n?2:(this.#e&Dn)===0n?4:8}get isShortestEncoding(){return this.preferredSize===this.#t}toCBOR(e){e.write(this.bytes)}toString(e=10){return kn(this,1,{},r=>(qi[e]??"")+r.toString(e))}[Symbol.for("nodejs.util.inspect.custom")](e,r,o){return kn(this,e,r,o)}};function Pn(t,e=0,r=!1){const o=t[e]&128?-1:1,f=(t[e]&124)>>2,u=(t[e]&3)<<8|t[e+1];if(f===0){if(r&&u!==0)throw new Error(`Unwanted subnormal: ${o*5960464477539063e-23*u}`);return o*5960464477539063e-23*u}else if(f===31)return u?NaN:o*(1/0);return o*2**(f-25)*(1024+u)}function Cn(t){const e=new DataView(new ArrayBuffer(4));e.setFloat32(0,t,!1);const r=e.getUint32(0,!1);if((r&8191)!==0)return null;let o=r>>16&32768;const f=r>>23&255,u=r&8388607;if(!(f===0&&u===0))if(f>=113&&f<=142)o+=(f-112<<10)+(u>>13);else if(f>=103&&f<113){if(u&(1<<126-f)-1)return null;o+=u+8388608>>126-f}else if(f===255)o|=31744,o|=u>>13;else return null;return o}function Wi(t){if(t!==0){const e=new ArrayBuffer(8),r=new DataView(e);r.setFloat64(0,t,!1);const o=r.getBigUint64(0,!1);if((o&0x7ff0000000000000n)===0n)return o&0x8000000000000000n?-0:0}return t}function Hi(t){switch(t.length){case 2:Pn(t,0,!0);break;case 4:{const e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=e.getUint32(0,!1);if((r&2139095040)===0&&r&8388607)throw new Error(`Unwanted subnormal: ${e.getFloat32(0,!1)}`);break}case 8:{const e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=e.getBigUint64(0,!1);if((r&0x7ff0000000000000n)===0n&&r&0x000fffffffffffn)throw new Error(`Unwanted subnormal: ${e.getFloat64(0,!1)}`);break}default:throw new TypeError(`Bad input to isSubnormal: ${t}`)}}class Ki extends TypeError{code="ERR_ENCODING_INVALID_ENCODED_DATA";constructor(){super("The encoded data was not valid for encoding wtf-8")}}class Yi extends RangeError{code="ERR_ENCODING_NOT_SUPPORTED";constructor(e){super(`Invalid encoding: "${e}"`)}}const zi=65279,$n=new Uint8Array(0),Vi=55296,Xi=56320,Ji=65533,qn="wtf-8";function Zi(t){return t&&!(t instanceof ArrayBuffer)&&t.buffer instanceof ArrayBuffer}function Qi(t){return t?t instanceof Uint8Array?t:Zi(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t):$n}const eo=[0,0,0,0,0,0,0,0,-1,-1,-1,-1,1,1,2,3];class Gt{static DEFAULT_BUFFERSIZE=4096;encoding=qn;fatal;ignoreBOM;bufferSize;#e=0;#t=0;#r=0;#n=!0;#i;constructor(e="wtf8",r=void 0){if(e.toLowerCase().replace("-","")!=="wtf8")throw new Yi(e);if(this.fatal=!!r?.fatal,this.ignoreBOM=!!r?.ignoreBOM,this.bufferSize=Math.floor(r?.bufferSize??Gt.DEFAULT_BUFFERSIZE),isNaN(this.bufferSize)||this.bufferSize<1)throw new RangeError(`Invalid buffer size: ${r?.bufferSize}`);this.#i=new Uint16Array(this.bufferSize)}decode(e,r){const o=!!r?.stream,f=Qi(e),u=[],c=this.#i,p=this.bufferSize-3;let y=0;const b=()=>{if(this.#t=0,this.#e=0,this.#r=0,this.fatal)throw new Ki;c[y++]=Ji},d=()=>{const B=this.#r;for(let q=0;q<B;q++)b()},I=B=>{if(this.#e===0)switch(eo[B>>4]){case-1:b();break;case 0:c[y++]=B;break;case 1:this.#t=B&31,(this.#t&30)===0?b():(this.#e=1,this.#r=1);break;case 2:this.#t=B&15,this.#e=2,this.#r=1;break;case 3:B&8?b():(this.#t=B&7,this.#e=3,this.#r=1);break}else{if((B&192)!==128||this.#r===1&&this.#e===2&&this.#t===0&&(B&32)===0||this.#e===3&&this.#t===0&&(B&48)===0)return d(),I(B);if(this.#t=this.#t<<6|B&63,this.#r++,--this.#e===0){if(this.ignoreBOM||!this.#n||this.#t!==zi)if(this.#t<65536)c[y++]=this.#t;else{const q=this.#t-65536;c[y++]=q>>>10&1023|Vi,c[y++]=q&1023|Xi}this.#t=0,this.#r=0,this.#n=!1}}};for(const B of f)y>=p&&(u.push(String.fromCharCode.apply(null,c.subarray(0,y))),y=0),I(B);return o||(this.#n=!0,(this.#t||this.#e)&&d()),y>0&&u.push(String.fromCharCode.apply(null,c.subarray(0,y))),u.join("")}}function to(t){let e=0;for(const r of t){const o=r.codePointAt(0);o<128?e++:o<2048?e+=2:o<65536?e+=3:e+=4}return e}class ro{encoding=qn;encode(e){if(!e)return $n;const r=new Uint8Array(to(String(e)));return this.encodeInto(e,r),r}encodeInto(e,r){const o=String(e),f=o.length,u=r.length;let c=0,p=0;for(p=0;p<f;p++){const y=o.codePointAt(p);if(y<128){if(c>=u)break;r[c++]=y}else if(y<2048){if(c>=u-1)break;r[c++]=192|y>>6,r[c++]=128|y&63}else if(y<65536){if(c>=u-2)break;r[c++]=224|y>>12,r[c++]=128|y>>6&63,r[c++]=128|y&63}else{if(c>=u-3)break;r[c++]=240|y>>18,r[c++]=128|y>>12&63,r[c++]=128|y>>6&63,r[c++]=128|y&63,p++}}return{read:p,written:c}}}const jn=Y.SIMPLE_FLOAT<<5|Q.TWO,no=Y.SIMPLE_FLOAT<<5|Q.FOUR,io=Y.SIMPLE_FLOAT<<5|Q.EIGHT,oo=Y.SIMPLE_FLOAT<<5|et.TRUE,so=Y.SIMPLE_FLOAT<<5|et.FALSE,ao=Y.SIMPLE_FLOAT<<5|et.UNDEFINED,uo=Y.SIMPLE_FLOAT<<5|et.NULL,fo=new TextEncoder,co=new ro,Gn={...$t.defaultOptions,avoidInts:!1,cde:!1,collapseBigInts:!0,dateTag:ie.DATE_EPOCH,dcbor:!1,float64:!1,flushToZero:!1,forceEndian:null,ignoreOriginalEncoding:!1,largeNegativeAsBigInt:!1,reduceUnsafeNumbers:!1,rejectBigInts:!1,rejectCustomSimples:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectUndefined:!1,simplifyNegativeZero:!1,sortKeys:null,stringNormalization:null,types:null,wtf8:!1,ignoreGlobalTags:!1},Wn={cde:!0,ignoreOriginalEncoding:!0,sortKeys:In},lo={...Wn,dcbor:!0,largeNegativeAsBigInt:!0,reduceUnsafeNumbers:!0,rejectCustomSimples:!0,rejectDuplicateKeys:!0,rejectUndefined:!0,simplifyNegativeZero:!0,stringNormalization:"NFC"};function Hn(t){const e=t<0;return typeof t=="bigint"?[e?-t-1n:t,e]:[e?-t-1:t,e]}function Ar(t,e,r){if(r.rejectFloats)throw new Error(`Attempt to encode an unwanted floating point number: ${t}`);if(isNaN(t))e.writeUint8(jn),e.writeUint16(32256);else if(!r.float64&&Math.fround(t)===t){const o=Cn(t);o===null?(e.writeUint8(no),e.writeFloat32(t)):(e.writeUint8(jn),e.writeUint16(o))}else e.writeUint8(io),e.writeFloat64(t)}function Me(t,e,r){const[o,f]=Hn(t);if(f&&r)throw new TypeError(`Negative size: ${t}`);r??=f?Y.NEG_INT:Y.POS_INT,r<<=5,o<24?e.writeUint8(r|o):o<=255?(e.writeUint8(r|Q.ONE),e.writeUint8(o)):o<=65535?(e.writeUint8(r|Q.TWO),e.writeUint16(o)):o<=4294967295?(e.writeUint8(r|Q.FOUR),e.writeUint32(o)):(e.writeUint8(r|Q.EIGHT),e.writeBigUint64(BigInt(o)))}function It(t,e,r){typeof t=="number"?Me(t,e,Y.TAG):typeof t=="object"&&!r.ignoreOriginalEncoding&&Ie.ENCODED in t?e.write(t[Ie.ENCODED]):t<=Number.MAX_SAFE_INTEGER?Me(Number(t),e,Y.TAG):(e.writeUint8(Y.TAG<<5|Q.EIGHT),e.writeBigUint64(BigInt(t)))}function Kn(t,e,r){const[o,f]=Hn(t);if(r.collapseBigInts&&(!r.largeNegativeAsBigInt||t>=-0x8000000000000000n)){if(o<=0xffffffffn){Me(Number(t),e);return}if(o<=0xffffffffffffffffn){const b=(f?Y.NEG_INT:Y.POS_INT)<<5;e.writeUint8(b|Q.EIGHT),e.writeBigUint64(o);return}}if(r.rejectBigInts)throw new Error(`Attempt to encode unwanted bigint: ${t}`);const u=f?ie.NEG_BIGINT:ie.POS_BIGINT,c=o.toString(16),p=c.length%2?"0":"";It(u,e,r);const y=Sn(p+c);Me(y.length,e,Y.BYTE_STRING),e.write(y)}function ho(t,e,r){r.flushToZero&&(t=Wi(t)),Object.is(t,-0)?r.simplifyNegativeZero?r.avoidInts?Ar(0,e,r):Me(0,e):Ar(t,e,r):!r.avoidInts&&Number.isSafeInteger(t)?Me(t,e):r.reduceUnsafeNumbers&&Math.floor(t)===t&&t>=kt.MIN&&t<=kt.MAX?Kn(BigInt(t),e,r):Ar(t,e,r)}function po(t,e,r){const o=r.stringNormalization?t.normalize(r.stringNormalization):t;if(r.wtf8&&!t.isWellFormed()){const f=co.encode(o);It(ie.WTF8,e,r),Me(f.length,e,Y.BYTE_STRING),e.write(f)}else{const f=fo.encode(o);Me(f.length,e,Y.UTF8_STRING),e.write(f)}}function yo(t,e,r){const o=t;Nr(o,o.length,Y.ARRAY,e,r);for(const f of o)lt(f,e,r)}function go(t,e){Me(t.length,e,Y.BYTE_STRING),e.write(t)}const Wt=new Rn;Wt.registerEncoder(Array,yo),Wt.registerEncoder(Uint8Array,go);function we(t,e){return Wt.registerEncoder(t,e)}function Nr(t,e,r,o,f){const u=Oi(t);u&&!f.ignoreOriginalEncoding?o.write(u):Me(e,o,r)}function wo(t,e,r){if(t===null){e.writeUint8(uo);return}if(!r.ignoreOriginalEncoding&&Ie.ENCODED in t){e.write(t[Ie.ENCODED]);return}const o=t.constructor;if(o){const u=r.types?.get(o)??(r.ignoreGlobalTags?void 0:Wt.get(o));if(u){const c=u(t,e,r);if(c!==void 0){if(!Array.isArray(c)||c.length!==2)throw new Error("Invalid encoder return value");(typeof c[0]=="bigint"||isFinite(Number(c[0])))&&It(c[0],e,r),lt(c[1],e,r)}return}}if(typeof t.toCBOR=="function"){const u=t.toCBOR(e,r);u&&((typeof u[0]=="bigint"||isFinite(Number(u[0])))&&It(u[0],e,r),lt(u[1],e,r));return}if(typeof t.toJSON=="function"){lt(t.toJSON(),e,r);return}const f=Object.entries(t).map(u=>[u[0],u[1],mt(u[0],r)]);r.sortKeys&&f.sort(r.sortKeys),Nr(t,f.length,Y.MAP,e,r);for(const[u,c,p]of f)e.write(p),lt(c,e,r)}function lt(t,e,r){switch(typeof t){case"number":ho(t,e,r);break;case"bigint":Kn(t,e,r);break;case"string":po(t,e,r);break;case"boolean":e.writeUint8(t?oo:so);break;case"undefined":if(r.rejectUndefined)throw new Error("Attempt to encode unwanted undefined.");e.writeUint8(ao);break;case"object":wo(t,e,r);break;case"symbol":throw new TypeError(`Unknown symbol: ${t.toString()}`);default:throw new TypeError(`Unknown type: ${typeof t}, ${String(t)}`)}}function mt(t,e={}){const r={...Gn};e.dcbor?Object.assign(r,lo):e.cde&&Object.assign(r,Wn),Object.assign(r,e);const o=new $t(r);return lt(t,o,r),o.read()}var Ht=(t=>(t[t.NEVER=-1]="NEVER",t[t.PREFERRED=0]="PREFERRED",t[t.ALWAYS=1]="ALWAYS",t))(Ht||{});class Ge{static KnownSimple=new Map([[et.FALSE,!1],[et.TRUE,!0],[et.NULL,null],[et.UNDEFINED,void 0]]);value;constructor(e){this.value=e}static create(e){return Ge.KnownSimple.has(e)?Ge.KnownSimple.get(e):new Ge(e)}toCBOR(e,r){if(r.rejectCustomSimples)throw new Error(`Cannot encode non-standard Simple value: ${this.value}`);Me(this.value,e,Y.SIMPLE_FLOAT)}toString(){return`simple(${this.value})`}decode(){return Ge.KnownSimple.has(this.value)?Ge.KnownSimple.get(this.value):this}[Symbol.for("nodejs.util.inspect.custom")](e,r,o){return`simple(${o(this.value,r)})`}}const Eo=new TextDecoder("utf8",{fatal:!0,ignoreBOM:!0});let Kt=class ci{static defaultOptions={maxDepth:1024,encoding:"hex",requirePreferred:!1};#e;#t;#r=0;#n;constructor(e,r){if(this.#n={...ci.defaultOptions,...r},typeof e=="string")switch(this.#n.encoding){case"hex":this.#e=Sn(e);break;case"base64":this.#e=Rr(e);break;default:throw new TypeError(`Encoding not implemented: "${this.#n.encoding}"`)}else this.#e=e;this.#t=new DataView(this.#e.buffer,this.#e.byteOffset,this.#e.byteLength)}toHere(e){return vr(this.#e,e,this.#r)}*[Symbol.iterator](){if(yield*this.#i(0),this.#r!==this.#e.length)throw new Error("Extra data in input")}*seq(){for(;this.#r<this.#e.length;)yield*this.#i(0)}*#i(e){if(e++>this.#n.maxDepth)throw new Error(`Maximum depth ${this.#n.maxDepth} exceeded`);const r=this.#r,o=this.#t.getUint8(this.#r++),f=o>>5,u=o&31;let c=u,p=!1,y=0;switch(u){case Q.ONE:if(y=1,c=this.#t.getUint8(this.#r),f===Y.SIMPLE_FLOAT){if(c<32)throw new Error(`Invalid simple encoding in extra byte: ${c}`);p=!0}else if(this.#n.requirePreferred&&c<24)throw new Error(`Unexpectedly long integer encoding (1) for ${c}`);break;case Q.TWO:if(y=2,f===Y.SIMPLE_FLOAT)c=Pn(this.#e,this.#r);else if(c=this.#t.getUint16(this.#r,!1),this.#n.requirePreferred&&c<=255)throw new Error(`Unexpectedly long integer encoding (2) for ${c}`);break;case Q.FOUR:if(y=4,f===Y.SIMPLE_FLOAT)c=this.#t.getFloat32(this.#r,!1);else if(c=this.#t.getUint32(this.#r,!1),this.#n.requirePreferred&&c<=65535)throw new Error(`Unexpectedly long integer encoding (4) for ${c}`);break;case Q.EIGHT:{if(y=8,f===Y.SIMPLE_FLOAT)c=this.#t.getFloat64(this.#r,!1);else if(c=this.#t.getBigUint64(this.#r,!1),c<=Number.MAX_SAFE_INTEGER&&(c=Number(c)),this.#n.requirePreferred&&c<=4294967295)throw new Error(`Unexpectedly long integer encoding (8) for ${c}`);break}case 28:case 29:case 30:throw new Error(`Additional info not implemented: ${u}`);case Q.INDEFINITE:switch(f){case Y.POS_INT:case Y.NEG_INT:case Y.TAG:throw new Error(`Invalid indefinite encoding for MT ${f}`);case Y.SIMPLE_FLOAT:yield[f,u,Ie.BREAK,r,0];return}c=1/0;break;default:p=!0}switch(this.#r+=y,f){case Y.POS_INT:yield[f,u,c,r,y];break;case Y.NEG_INT:yield[f,u,typeof c=="bigint"?-1n-c:-1-Number(c),r,y];break;case Y.BYTE_STRING:c===1/0?yield*this.#u(f,e,r):yield[f,u,this.#o(c),r,c];break;case Y.UTF8_STRING:c===1/0?yield*this.#u(f,e,r):yield[f,u,Eo.decode(this.#o(c)),r,c];break;case Y.ARRAY:if(c===1/0)yield*this.#u(f,e,r,!1);else{const b=Number(c);yield[f,u,b,r,y];for(let d=0;d<b;d++)yield*this.#i(e+1)}break;case Y.MAP:if(c===1/0)yield*this.#u(f,e,r,!1);else{const b=Number(c);yield[f,u,b,r,y];for(let d=0;d<b;d++)yield*this.#i(e),yield*this.#i(e)}break;case Y.TAG:yield[f,u,c,r,y],yield*this.#i(e);break;case Y.SIMPLE_FLOAT:{const b=c;p&&(c=Ge.create(Number(c))),yield[f,u,c,r,b];break}}}#o(e){const r=vr(this.#e,this.#r,this.#r+=e);if(r.length!==e)throw new Error(`Unexpected end of stream reading ${e} bytes, got ${r.length}`);return r}*#u(e,r,o,f=!0){for(yield[e,Q.INDEFINITE,1/0,o,1/0];;){const u=this.#i(r),c=u.next(),[p,y,b]=c.value;if(b===Ie.BREAK){yield c.value,u.next();return}if(f){if(p!==e)throw new Error(`Unmatched major type. Expected ${e}, got ${p}.`);if(y===Q.INDEFINITE)throw new Error("New stream started in typed stream")}yield c.value,yield*u}}};const mo=new Map([[Q.ZERO,1],[Q.ONE,2],[Q.TWO,3],[Q.FOUR,5],[Q.EIGHT,9]]),bo=new Uint8Array(0);function _o(t,e){return!e.boxed&&!e.preferMap&&t.every(([r])=>typeof r=="string")?Object.fromEntries(t):new Map(t)}let Fe=class li{static defaultDecodeOptions={...Kt.defaultOptions,ParentType:li,boxed:!1,cde:!1,dcbor:!1,diagnosticSizes:Ht.PREFERRED,collapseBigInts:!1,convertUnsafeIntsToFloat:!1,createObject:_o,keepNanPayloads:!1,pretty:!1,preferBigInt:!1,preferMap:!1,rejectLargeNegatives:!1,rejectBigInts:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectInts:!1,rejectLongLoundNaN:!1,rejectLongFloats:!1,rejectNegativeZero:!1,rejectSimple:!1,rejectStreaming:!1,rejectStringsNotNormalizedAs:null,rejectSubnormals:!1,rejectUndefined:!1,rejectUnsafeFloatInts:!1,saveOriginal:!1,sortKeys:null,tags:null,ignoreGlobalTags:!1};static cdeDecodeOptions={cde:!0,rejectStreaming:!0,requirePreferred:!0,sortKeys:In};static dcborDecodeOptions={...this.cdeDecodeOptions,dcbor:!0,convertUnsafeIntsToFloat:!0,rejectDuplicateKeys:!0,rejectLargeNegatives:!0,rejectLongLoundNaN:!0,rejectLongFloats:!0,rejectNegativeZero:!0,rejectSimple:!0,rejectUndefined:!0,rejectUnsafeFloatInts:!0,rejectStringsNotNormalizedAs:"NFC"};parent;mt;ai;left;offset;count=0;children=[];depth=0;#e;#t=null;constructor(e,r,o,f){if([this.mt,this.ai,,this.offset]=e,this.left=r,this.parent=o,this.#e=f,o&&(this.depth=o.depth+1),this.mt===Y.MAP&&(this.#e.sortKeys||this.#e.rejectDuplicateKeys)&&(this.#t=[]),this.#e.rejectStreaming&&this.ai===Q.INDEFINITE)throw new Error("Streaming not supported")}get isStreaming(){return this.left===1/0}get done(){return this.left===0}static create(e,r,o,f){const[u,c,p,y]=e;switch(u){case Y.POS_INT:case Y.NEG_INT:{if(o.rejectInts)throw new Error(`Unexpected integer: ${p}`);if(o.rejectLargeNegatives&&p<-0x8000000000000000n)throw new Error(`Invalid 65bit negative number: ${p}`);let b=p;return o.preferBigInt?b=BigInt(b):o.convertUnsafeIntsToFloat&&b>=kt.MIN&&b<=kt.MAX&&(b=Number(p)),o.boxed?xt(b,f.toHere(y)):b}case Y.SIMPLE_FLOAT:if(c>Q.ONE){if(typeof p=="symbol")return p;if(o.rejectFloats)throw new Error(`Decoding unwanted floating point number: ${p}`);if(o.rejectNegativeZero&&Object.is(p,-0))throw new Error("Decoding negative zero");if(isNaN(p)){const b=f.toHere(y),d=new Gi(b);if(o.rejectLongLoundNaN){if(d.payload||b.length>3)throw new Error(`Invalid NaN encoding: "${Ne(b)}"`)}else if(o.keepNanPayloads&&d.payload){if(o.rejectLongFloats&&!d.isShortestEncoding)throw new Error(`NaN should have been encoded shorter: ${p}`);return d}}if(o.rejectSubnormals&&Hi(f.toHere(y+1)),o.rejectLongFloats){const b=mt(p,{chunkSize:9,reduceUnsafeNumbers:o.rejectUnsafeFloatInts});if(b[0]>>5!==u)throw new Error(`Should have been encoded as int, not float: ${p}`);if(b.length<mo.get(c))throw new Error(`Number should have been encoded shorter: ${p}`)}if(typeof p=="number"&&o.boxed)return xt(p,f.toHere(y))}else{if(o.rejectSimple&&p instanceof Ge)throw new Error(`Invalid simple value: ${p}`);if(o.rejectUndefined&&p===void 0)throw new Error("Unexpected undefined")}return p;case Y.BYTE_STRING:case Y.UTF8_STRING:if(p===1/0)return new o.ParentType(e,1/0,r,o);if(o.rejectStringsNotNormalizedAs&&typeof p=="string"){const b=p.normalize(o.rejectStringsNotNormalizedAs);if(p!==b)throw new Error(`String not normalized as "${o.rejectStringsNotNormalizedAs}", got [${vn(p)}] instead of [${vn(b)}]`)}return o.boxed?xt(p,f.toHere(y)):p;case Y.ARRAY:return new o.ParentType(e,p,r,o);case Y.MAP:return new o.ParentType(e,p*2,r,o);case Y.TAG:{const b=new o.ParentType(e,1,r,o);return b.children=new Z(p),b}}throw new TypeError(`Invalid major type: ${u}`)}static decodeToEncodeOpts(e){return{...Gn,avoidInts:e.rejectInts,float64:!e.rejectLongFloats,flushToZero:e.rejectSubnormals,largeNegativeAsBigInt:e.rejectLargeNegatives,sortKeys:e.sortKeys}}push(e,r,o){if(this.children.push(e),this.#t){const f=Pt(e)||r.toHere(o);this.#t.push(f)}return--this.left}replaceLast(e,r,o){let f,u=-1/0;if(this.children instanceof Z?(u=0,f=this.children.contents,this.children.contents=e):(u=this.children.length-1,f=this.children[u],this.children[u]=e),this.#t){const c=Pt(e)||o.toHere(r.offset);this.#t[u]=c}return f}convert(e){let r;switch(this.mt){case Y.ARRAY:r=this.children;break;case Y.MAP:{const o=this.#r();if(this.#e.sortKeys){let f;for(const u of o){if(f&&this.#e.sortKeys(f,u)>=0)throw new Error(`Duplicate or out of order key: "0x${u[2]}"`);f=u}}else if(this.#e.rejectDuplicateKeys){const f=new Set;for(const[u,c,p]of o){const y=Ne(p);if(f.has(y))throw new Error(`Duplicate key: "0x${y}"`);f.add(y)}}r=this.#e.createObject(o,this.#e);break}case Y.BYTE_STRING:return ki(this.children);case Y.UTF8_STRING:{const o=this.children.join("");r=this.#e.boxed?xt(o,e.toHere(this.offset)):o;break}case Y.TAG:r=this.children.decode(this.#e);break;default:throw new TypeError(`Invalid mt on convert: ${this.mt}`)}return this.#e.saveOriginal&&r&&typeof r=="object"&&Tt(r,e.toHere(this.offset)),r}#r(){const e=this.children,r=e.length;if(r%2)throw new Error("Missing map value");const o=new Array(r/2);if(this.#t)for(let f=0;f<r;f+=2)o[f>>1]=[e[f],e[f+1],this.#t[f]];else for(let f=0;f<r;f+=2)o[f>>1]=[e[f],e[f+1],bo];return o}};const Fr=" ",To=new TextEncoder;class Yn extends Fe{close="";quote='"';get isEmptyStream(){return(this.mt===Y.UTF8_STRING||this.mt===Y.BYTE_STRING)&&this.count===0}}function tt(t,e,r,o){let f="";if(e===Q.INDEFINITE)f+="_";else{if(o.diagnosticSizes===Ht.NEVER)return"";{let u=o.diagnosticSizes===Ht.ALWAYS;if(!u){let c=Q.ZERO;if(Object.is(r,-0))c=Q.TWO;else if(t===Y.POS_INT||t===Y.NEG_INT){const p=r<0,y=typeof r=="bigint"?1n:1,b=p?-r-y:r;b<=23?c=Number(b):b<=255?c=Q.ONE:b<=65535?c=Q.TWO:b<=4294967295?c=Q.FOUR:c=Q.EIGHT}else isFinite(r)?Math.fround(r)===r?Cn(r)==null?c=Q.FOUR:c=Q.TWO:c=Q.EIGHT:c=Q.TWO;u=c!==e}u&&(f+="_",e<Q.ONE?f+="i":f+=String(e-24))}}return f}function xo(t,e){const r={...Fe.defaultDecodeOptions,...e,ParentType:Yn},o=new Kt(t,r);let f,u,c="";for(const p of o){const[y,b,d]=p;switch(f&&(f.count>0&&d!==Ie.BREAK&&(f.mt===Y.MAP&&f.count%2?c+=": ":(c+=",",r.pretty||(c+=" "))),r.pretty&&(f.mt!==Y.MAP||f.count%2===0)&&(c+=`
1
+ (function(ut,Qe){typeof exports=="object"&&typeof module<"u"?module.exports=Qe():typeof define=="function"&&define.amd?define(Qe):(ut=typeof globalThis<"u"?globalThis:ut||self,ut.MQTTp=Qe())})(this,(function(){"use strict";var ut={},Qe={};Qe.byteLength=pi,Qe.toByteArray=gi,Qe.fromByteArray=mi;for(var $e=[],Le=[],hi=typeof Uint8Array<"u"?Uint8Array:Array,Qt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",dt=0,di=Qt.length;dt<di;++dt)$e[dt]=Qt[dt],Le[Qt.charCodeAt(dt)]=dt;Le[45]=62,Le[95]=63;function Pr(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var o=r===e?0:4-r%4;return[r,o]}function pi(t){var e=Pr(t),r=e[0],o=e[1];return(r+o)*3/4-o}function yi(t,e,r){return(e+r)*3/4-r}function gi(t){var e,r=Pr(t),o=r[0],f=r[1],u=new hi(yi(t,o,f)),c=0,p=f>0?o-4:o,y;for(y=0;y<p;y+=4)e=Le[t.charCodeAt(y)]<<18|Le[t.charCodeAt(y+1)]<<12|Le[t.charCodeAt(y+2)]<<6|Le[t.charCodeAt(y+3)],u[c++]=e>>16&255,u[c++]=e>>8&255,u[c++]=e&255;return f===2&&(e=Le[t.charCodeAt(y)]<<2|Le[t.charCodeAt(y+1)]>>4,u[c++]=e&255),f===1&&(e=Le[t.charCodeAt(y)]<<10|Le[t.charCodeAt(y+1)]<<4|Le[t.charCodeAt(y+2)]>>2,u[c++]=e>>8&255,u[c++]=e&255),u}function wi(t){return $e[t>>18&63]+$e[t>>12&63]+$e[t>>6&63]+$e[t&63]}function Ei(t,e,r){for(var o,f=[],u=e;u<r;u+=3)o=(t[u]<<16&16711680)+(t[u+1]<<8&65280)+(t[u+2]&255),f.push(wi(o));return f.join("")}function mi(t){for(var e,r=t.length,o=r%3,f=[],u=16383,c=0,p=r-o;c<p;c+=u)f.push(Ei(t,c,c+u>p?p:c+u));return o===1?(e=t[r-1],f.push($e[e>>2]+$e[e<<4&63]+"==")):o===2&&(e=(t[r-2]<<8)+t[r-1],f.push($e[e>>10]+$e[e>>4&63]+$e[e<<2&63]+"=")),f.join("")}var er={};er.read=function(t,e,r,o,f){var u,c,p=f*8-o-1,y=(1<<p)-1,b=y>>1,d=-7,I=r?f-1:0,B=r?-1:1,q=t[e+I];for(I+=B,u=q&(1<<-d)-1,q>>=-d,d+=p;d>0;u=u*256+t[e+I],I+=B,d-=8);for(c=u&(1<<-d)-1,u>>=-d,d+=o;d>0;c=c*256+t[e+I],I+=B,d-=8);if(u===0)u=1-b;else{if(u===y)return c?NaN:(q?-1:1)*(1/0);c=c+Math.pow(2,o),u=u-b}return(q?-1:1)*c*Math.pow(2,u-o)},er.write=function(t,e,r,o,f,u){var c,p,y,b=u*8-f-1,d=(1<<b)-1,I=d>>1,B=f===23?Math.pow(2,-24)-Math.pow(2,-77):0,q=o?0:u-1,P=o?1:-1,W=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(p=isNaN(e)?1:0,c=d):(c=Math.floor(Math.log(e)/Math.LN2),e*(y=Math.pow(2,-c))<1&&(c--,y*=2),c+I>=1?e+=B/y:e+=B*Math.pow(2,1-I),e*y>=2&&(c++,y/=2),c+I>=d?(p=0,c=d):c+I>=1?(p=(e*y-1)*Math.pow(2,f),c=c+I):(p=e*Math.pow(2,I-1)*Math.pow(2,f),c=0));f>=8;t[r+q]=p&255,q+=P,p/=256,f-=8);for(c=c<<f|p,b+=f;b>0;t[r+q]=c&255,q+=P,c/=256,b-=8);t[r+q-P]|=W*128};(function(t){const e=Qe,r=er,o=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=d,t.SlowBuffer=v,t.INSPECT_MAX_BYTES=50;const f=2147483647;t.kMaxLength=f;const{Uint8Array:u,ArrayBuffer:c,SharedArrayBuffer:p}=globalThis;d.TYPED_ARRAY_SUPPORT=y(),!d.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function y(){try{const l=new u(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,u.prototype),Object.setPrototypeOf(l,n),l.foo()===42}catch{return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}}),Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function b(l){if(l>f)throw new RangeError('The value "'+l+'" is invalid for option "size"');const n=new u(l);return Object.setPrototypeOf(n,d.prototype),n}function d(l,n,s){if(typeof l=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return P(l)}return I(l,n,s)}d.poolSize=8192;function I(l,n,s){if(typeof l=="string")return W(l,n);if(c.isView(l))return x(l);if(l==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof l);if(Re(l,c)||l&&Re(l.buffer,c)||typeof p<"u"&&(Re(l,p)||l&&Re(l.buffer,p)))return R(l,n,s);if(typeof l=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const g=l.valueOf&&l.valueOf();if(g!=null&&g!==l)return d.from(g,n,s);const T=A(l);if(T)return T;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof l[Symbol.toPrimitive]=="function")return d.from(l[Symbol.toPrimitive]("string"),n,s);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof l)}d.from=function(l,n,s){return I(l,n,s)},Object.setPrototypeOf(d.prototype,u.prototype),Object.setPrototypeOf(d,u);function B(l){if(typeof l!="number")throw new TypeError('"size" argument must be of type number');if(l<0)throw new RangeError('The value "'+l+'" is invalid for option "size"')}function q(l,n,s){return B(l),l<=0?b(l):n!==void 0?typeof s=="string"?b(l).fill(n,s):b(l).fill(n):b(l)}d.alloc=function(l,n,s){return q(l,n,s)};function P(l){return B(l),b(l<0?0:_(l)|0)}d.allocUnsafe=function(l){return P(l)},d.allocUnsafeSlow=function(l){return P(l)};function W(l,n){if((typeof n!="string"||n==="")&&(n="utf8"),!d.isEncoding(n))throw new TypeError("Unknown encoding: "+n);const s=U(l,n)|0;let g=b(s);const T=g.write(l,n);return T!==s&&(g=g.slice(0,T)),g}function j(l){const n=l.length<0?0:_(l.length)|0,s=b(n);for(let g=0;g<n;g+=1)s[g]=l[g]&255;return s}function x(l){if(Re(l,u)){const n=new u(l);return R(n.buffer,n.byteOffset,n.byteLength)}return j(l)}function R(l,n,s){if(n<0||l.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(l.byteLength<n+(s||0))throw new RangeError('"length" is outside of buffer bounds');let g;return n===void 0&&s===void 0?g=new u(l):s===void 0?g=new u(l,n):g=new u(l,n,s),Object.setPrototypeOf(g,d.prototype),g}function A(l){if(d.isBuffer(l)){const n=_(l.length)|0,s=b(n);return s.length===0||l.copy(s,0,0,n),s}if(l.length!==void 0)return typeof l.length!="number"||Oe(l.length)?b(0):j(l);if(l.type==="Buffer"&&Array.isArray(l.data))return j(l.data)}function _(l){if(l>=f)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+f.toString(16)+" bytes");return l|0}function v(l){return+l!=l&&(l=0),d.alloc(+l)}d.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==d.prototype},d.compare=function(n,s){if(Re(n,u)&&(n=d.from(n,n.offset,n.byteLength)),Re(s,u)&&(s=d.from(s,s.offset,s.byteLength)),!d.isBuffer(n)||!d.isBuffer(s))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===s)return 0;let g=n.length,T=s.length;for(let M=0,C=Math.min(g,T);M<C;++M)if(n[M]!==s[M]){g=n[M],T=s[M];break}return g<T?-1:T<g?1:0},d.isEncoding=function(n){switch(String(n).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},d.concat=function(n,s){if(!Array.isArray(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return d.alloc(0);let g;if(s===void 0)for(s=0,g=0;g<n.length;++g)s+=n[g].length;const T=d.allocUnsafe(s);let M=0;for(g=0;g<n.length;++g){let C=n[g];if(Re(C,u))M+C.length>T.length?(d.isBuffer(C)||(C=d.from(C)),C.copy(T,M)):u.prototype.set.call(T,C,M);else if(d.isBuffer(C))C.copy(T,M);else throw new TypeError('"list" argument must be an Array of Buffers');M+=C.length}return T};function U(l,n){if(d.isBuffer(l))return l.length;if(c.isView(l)||Re(l,c))return l.byteLength;if(typeof l!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof l);const s=l.length,g=arguments.length>2&&arguments[2]===!0;if(!g&&s===0)return 0;let T=!1;for(;;)switch(n){case"ascii":case"latin1":case"binary":return s;case"utf8":case"utf-8":return ot(l).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return s*2;case"hex":return s>>>1;case"base64":return _e(l).length;default:if(T)return g?-1:ot(l).length;n=(""+n).toLowerCase(),T=!0}}d.byteLength=U;function D(l,n,s){let g=!1;if((n===void 0||n<0)&&(n=0),n>this.length||((s===void 0||s>this.length)&&(s=this.length),s<=0)||(s>>>=0,n>>>=0,s<=n))return"";for(l||(l="utf8");;)switch(l){case"hex":return Ke(this,n,s);case"utf8":case"utf-8":return Ae(this,n,s);case"ascii":return He(this,n,s);case"latin1":case"binary":return ht(this,n,s);case"base64":return Ue(this,n,s);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ke(this,n,s);default:if(g)throw new TypeError("Unknown encoding: "+l);l=(l+"").toLowerCase(),g=!0}}d.prototype._isBuffer=!0;function k(l,n,s){const g=l[n];l[n]=l[s],l[s]=g}d.prototype.swap16=function(){const n=this.length;if(n%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let s=0;s<n;s+=2)k(this,s,s+1);return this},d.prototype.swap32=function(){const n=this.length;if(n%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let s=0;s<n;s+=4)k(this,s,s+3),k(this,s+1,s+2);return this},d.prototype.swap64=function(){const n=this.length;if(n%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let s=0;s<n;s+=8)k(this,s,s+7),k(this,s+1,s+6),k(this,s+2,s+5),k(this,s+3,s+4);return this},d.prototype.toString=function(){const n=this.length;return n===0?"":arguments.length===0?Ae(this,0,n):D.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function(n){if(!d.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:d.compare(this,n)===0},d.prototype.inspect=function(){let n="";const s=t.INSPECT_MAX_BYTES;return n=this.toString("hex",0,s).replace(/(.{2})/g,"$1 ").trim(),this.length>s&&(n+=" ... "),"<Buffer "+n+">"},o&&(d.prototype[o]=d.prototype.inspect),d.prototype.compare=function(n,s,g,T,M){if(Re(n,u)&&(n=d.from(n,n.offset,n.byteLength)),!d.isBuffer(n))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof n);if(s===void 0&&(s=0),g===void 0&&(g=n?n.length:0),T===void 0&&(T=0),M===void 0&&(M=this.length),s<0||g>n.length||T<0||M>this.length)throw new RangeError("out of range index");if(T>=M&&s>=g)return 0;if(T>=M)return-1;if(s>=g)return 1;if(s>>>=0,g>>>=0,T>>>=0,M>>>=0,this===n)return 0;let C=M-T,te=g-s;const le=Math.min(C,te),he=this.slice(T,M),pe=n.slice(s,g);for(let se=0;se<le;++se)if(he[se]!==pe[se]){C=he[se],te=pe[se];break}return C<te?-1:te<C?1:0};function H(l,n,s,g,T){if(l.length===0)return-1;if(typeof s=="string"?(g=s,s=0):s>2147483647?s=2147483647:s<-2147483648&&(s=-2147483648),s=+s,Oe(s)&&(s=T?0:l.length-1),s<0&&(s=l.length+s),s>=l.length){if(T)return-1;s=l.length-1}else if(s<0)if(T)s=0;else return-1;if(typeof n=="string"&&(n=d.from(n,g)),d.isBuffer(n))return n.length===0?-1:z(l,n,s,g,T);if(typeof n=="number")return n=n&255,typeof u.prototype.indexOf=="function"?T?u.prototype.indexOf.call(l,n,s):u.prototype.lastIndexOf.call(l,n,s):z(l,[n],s,g,T);throw new TypeError("val must be string, number or Buffer")}function z(l,n,s,g,T){let M=1,C=l.length,te=n.length;if(g!==void 0&&(g=String(g).toLowerCase(),g==="ucs2"||g==="ucs-2"||g==="utf16le"||g==="utf-16le")){if(l.length<2||n.length<2)return-1;M=2,C/=2,te/=2,s/=2}function le(pe,se){return M===1?pe[se]:pe.readUInt16BE(se*M)}let he;if(T){let pe=-1;for(he=s;he<C;he++)if(le(l,he)===le(n,pe===-1?0:he-pe)){if(pe===-1&&(pe=he),he-pe+1===te)return pe*M}else pe!==-1&&(he-=he-pe),pe=-1}else for(s+te>C&&(s=C-te),he=s;he>=0;he--){let pe=!0;for(let se=0;se<te;se++)if(le(l,he+se)!==le(n,se)){pe=!1;break}if(pe)return he}return-1}d.prototype.includes=function(n,s,g){return this.indexOf(n,s,g)!==-1},d.prototype.indexOf=function(n,s,g){return H(this,n,s,g,!0)},d.prototype.lastIndexOf=function(n,s,g){return H(this,n,s,g,!1)};function re(l,n,s,g){s=Number(s)||0;const T=l.length-s;g?(g=Number(g),g>T&&(g=T)):g=T;const M=n.length;g>M/2&&(g=M/2);let C;for(C=0;C<g;++C){const te=parseInt(n.substr(C*2,2),16);if(Oe(te))return C;l[s+C]=te}return C}function N(l,n,s,g){return Pe(ot(n,l.length-s),l,s,g)}function ae(l,n,s,g){return Pe(Nt(n),l,s,g)}function ve(l,n,s,g){return Pe(_e(n),l,s,g)}function xe(l,n,s,g){return Pe(ge(n,l.length-s),l,s,g)}d.prototype.write=function(n,s,g,T){if(s===void 0)T="utf8",g=this.length,s=0;else if(g===void 0&&typeof s=="string")T=s,g=this.length,s=0;else if(isFinite(s))s=s>>>0,isFinite(g)?(g=g>>>0,T===void 0&&(T="utf8")):(T=g,g=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const M=this.length-s;if((g===void 0||g>M)&&(g=M),n.length>0&&(g<0||s<0)||s>this.length)throw new RangeError("Attempt to write outside buffer bounds");T||(T="utf8");let C=!1;for(;;)switch(T){case"hex":return re(this,n,s,g);case"utf8":case"utf-8":return N(this,n,s,g);case"ascii":case"latin1":case"binary":return ae(this,n,s,g);case"base64":return ve(this,n,s,g);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xe(this,n,s,g);default:if(C)throw new TypeError("Unknown encoding: "+T);T=(""+T).toLowerCase(),C=!0}},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ue(l,n,s){return n===0&&s===l.length?e.fromByteArray(l):e.fromByteArray(l.slice(n,s))}function Ae(l,n,s){s=Math.min(l.length,s);const g=[];let T=n;for(;T<s;){const M=l[T];let C=null,te=M>239?4:M>223?3:M>191?2:1;if(T+te<=s){let le,he,pe,se;switch(te){case 1:M<128&&(C=M);break;case 2:le=l[T+1],(le&192)===128&&(se=(M&31)<<6|le&63,se>127&&(C=se));break;case 3:le=l[T+1],he=l[T+2],(le&192)===128&&(he&192)===128&&(se=(M&15)<<12|(le&63)<<6|he&63,se>2047&&(se<55296||se>57343)&&(C=se));break;case 4:le=l[T+1],he=l[T+2],pe=l[T+3],(le&192)===128&&(he&192)===128&&(pe&192)===128&&(se=(M&15)<<18|(le&63)<<12|(he&63)<<6|pe&63,se>65535&&se<1114112&&(C=se))}}C===null?(C=65533,te=1):C>65535&&(C-=65536,g.push(C>>>10&1023|55296),C=56320|C&1023),g.push(C),T+=te}return We(g)}const De=4096;function We(l){const n=l.length;if(n<=De)return String.fromCharCode.apply(String,l);let s="",g=0;for(;g<n;)s+=String.fromCharCode.apply(String,l.slice(g,g+=De));return s}function He(l,n,s){let g="";s=Math.min(l.length,s);for(let T=n;T<s;++T)g+=String.fromCharCode(l[T]&127);return g}function ht(l,n,s){let g="";s=Math.min(l.length,s);for(let T=n;T<s;++T)g+=String.fromCharCode(l[T]);return g}function Ke(l,n,s){const g=l.length;(!n||n<0)&&(n=0),(!s||s<0||s>g)&&(s=g);let T="";for(let M=n;M<s;++M)T+=Ce[l[M]];return T}function ke(l,n,s){const g=l.slice(n,s);let T="";for(let M=0;M<g.length-1;M+=2)T+=String.fromCharCode(g[M]+g[M+1]*256);return T}d.prototype.slice=function(n,s){const g=this.length;n=~~n,s=s===void 0?g:~~s,n<0?(n+=g,n<0&&(n=0)):n>g&&(n=g),s<0?(s+=g,s<0&&(s=0)):s>g&&(s=g),s<n&&(s=n);const T=this.subarray(n,s);return Object.setPrototypeOf(T,d.prototype),T};function de(l,n,s){if(l%1!==0||l<0)throw new RangeError("offset is not uint");if(l+n>s)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(n,s,g){n=n>>>0,s=s>>>0,g||de(n,s,this.length);let T=this[n],M=1,C=0;for(;++C<s&&(M*=256);)T+=this[n+C]*M;return T},d.prototype.readUintBE=d.prototype.readUIntBE=function(n,s,g){n=n>>>0,s=s>>>0,g||de(n,s,this.length);let T=this[n+--s],M=1;for(;s>0&&(M*=256);)T+=this[n+--s]*M;return T},d.prototype.readUint8=d.prototype.readUInt8=function(n,s){return n=n>>>0,s||de(n,1,this.length),this[n]},d.prototype.readUint16LE=d.prototype.readUInt16LE=function(n,s){return n=n>>>0,s||de(n,2,this.length),this[n]|this[n+1]<<8},d.prototype.readUint16BE=d.prototype.readUInt16BE=function(n,s){return n=n>>>0,s||de(n,2,this.length),this[n]<<8|this[n+1]},d.prototype.readUint32LE=d.prototype.readUInt32LE=function(n,s){return n=n>>>0,s||de(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},d.prototype.readUint32BE=d.prototype.readUInt32BE=function(n,s){return n=n>>>0,s||de(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},d.prototype.readBigUInt64LE=Se(function(n){n=n>>>0,J(n,"offset");const s=this[n],g=this[n+7];(s===void 0||g===void 0)&&oe(n,this.length-8);const T=s+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24,M=this[++n]+this[++n]*2**8+this[++n]*2**16+g*2**24;return BigInt(T)+(BigInt(M)<<BigInt(32))}),d.prototype.readBigUInt64BE=Se(function(n){n=n>>>0,J(n,"offset");const s=this[n],g=this[n+7];(s===void 0||g===void 0)&&oe(n,this.length-8);const T=s*2**24+this[++n]*2**16+this[++n]*2**8+this[++n],M=this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+g;return(BigInt(T)<<BigInt(32))+BigInt(M)}),d.prototype.readIntLE=function(n,s,g){n=n>>>0,s=s>>>0,g||de(n,s,this.length);let T=this[n],M=1,C=0;for(;++C<s&&(M*=256);)T+=this[n+C]*M;return M*=128,T>=M&&(T-=Math.pow(2,8*s)),T},d.prototype.readIntBE=function(n,s,g){n=n>>>0,s=s>>>0,g||de(n,s,this.length);let T=s,M=1,C=this[n+--T];for(;T>0&&(M*=256);)C+=this[n+--T]*M;return M*=128,C>=M&&(C-=Math.pow(2,8*s)),C},d.prototype.readInt8=function(n,s){return n=n>>>0,s||de(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},d.prototype.readInt16LE=function(n,s){n=n>>>0,s||de(n,2,this.length);const g=this[n]|this[n+1]<<8;return g&32768?g|4294901760:g},d.prototype.readInt16BE=function(n,s){n=n>>>0,s||de(n,2,this.length);const g=this[n+1]|this[n]<<8;return g&32768?g|4294901760:g},d.prototype.readInt32LE=function(n,s){return n=n>>>0,s||de(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},d.prototype.readInt32BE=function(n,s){return n=n>>>0,s||de(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},d.prototype.readBigInt64LE=Se(function(n){n=n>>>0,J(n,"offset");const s=this[n],g=this[n+7];(s===void 0||g===void 0)&&oe(n,this.length-8);const T=this[n+4]+this[n+5]*2**8+this[n+6]*2**16+(g<<24);return(BigInt(T)<<BigInt(32))+BigInt(s+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24)}),d.prototype.readBigInt64BE=Se(function(n){n=n>>>0,J(n,"offset");const s=this[n],g=this[n+7];(s===void 0||g===void 0)&&oe(n,this.length-8);const T=(s<<24)+this[++n]*2**16+this[++n]*2**8+this[++n];return(BigInt(T)<<BigInt(32))+BigInt(this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+g)}),d.prototype.readFloatLE=function(n,s){return n=n>>>0,s||de(n,4,this.length),r.read(this,n,!0,23,4)},d.prototype.readFloatBE=function(n,s){return n=n>>>0,s||de(n,4,this.length),r.read(this,n,!1,23,4)},d.prototype.readDoubleLE=function(n,s){return n=n>>>0,s||de(n,8,this.length),r.read(this,n,!0,52,8)},d.prototype.readDoubleBE=function(n,s){return n=n>>>0,s||de(n,8,this.length),r.read(this,n,!1,52,8)};function Te(l,n,s,g,T,M){if(!d.isBuffer(l))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>T||n<M)throw new RangeError('"value" argument is out of bounds');if(s+g>l.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(n,s,g,T){if(n=+n,s=s>>>0,g=g>>>0,!T){const te=Math.pow(2,8*g)-1;Te(this,n,s,g,te,0)}let M=1,C=0;for(this[s]=n&255;++C<g&&(M*=256);)this[s+C]=n/M&255;return s+g},d.prototype.writeUintBE=d.prototype.writeUIntBE=function(n,s,g,T){if(n=+n,s=s>>>0,g=g>>>0,!T){const te=Math.pow(2,8*g)-1;Te(this,n,s,g,te,0)}let M=g-1,C=1;for(this[s+M]=n&255;--M>=0&&(C*=256);)this[s+M]=n/C&255;return s+g},d.prototype.writeUint8=d.prototype.writeUInt8=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,1,255,0),this[s]=n&255,s+1},d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,2,65535,0),this[s]=n&255,this[s+1]=n>>>8,s+2},d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,2,65535,0),this[s]=n>>>8,this[s+1]=n&255,s+2},d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,4,4294967295,0),this[s+3]=n>>>24,this[s+2]=n>>>16,this[s+1]=n>>>8,this[s]=n&255,s+4},d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,4,4294967295,0),this[s]=n>>>24,this[s+1]=n>>>16,this[s+2]=n>>>8,this[s+3]=n&255,s+4};function L(l,n,s,g,T){ue(n,g,T,l,s,7);let M=Number(n&BigInt(4294967295));l[s++]=M,M=M>>8,l[s++]=M,M=M>>8,l[s++]=M,M=M>>8,l[s++]=M;let C=Number(n>>BigInt(32)&BigInt(4294967295));return l[s++]=C,C=C>>8,l[s++]=C,C=C>>8,l[s++]=C,C=C>>8,l[s++]=C,s}function F(l,n,s,g,T){ue(n,g,T,l,s,7);let M=Number(n&BigInt(4294967295));l[s+7]=M,M=M>>8,l[s+6]=M,M=M>>8,l[s+5]=M,M=M>>8,l[s+4]=M;let C=Number(n>>BigInt(32)&BigInt(4294967295));return l[s+3]=C,C=C>>8,l[s+2]=C,C=C>>8,l[s+1]=C,C=C>>8,l[s]=C,s+8}d.prototype.writeBigUInt64LE=Se(function(n,s=0){return L(this,n,s,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeBigUInt64BE=Se(function(n,s=0){return F(this,n,s,BigInt(0),BigInt("0xffffffffffffffff"))}),d.prototype.writeIntLE=function(n,s,g,T){if(n=+n,s=s>>>0,!T){const le=Math.pow(2,8*g-1);Te(this,n,s,g,le-1,-le)}let M=0,C=1,te=0;for(this[s]=n&255;++M<g&&(C*=256);)n<0&&te===0&&this[s+M-1]!==0&&(te=1),this[s+M]=(n/C>>0)-te&255;return s+g},d.prototype.writeIntBE=function(n,s,g,T){if(n=+n,s=s>>>0,!T){const le=Math.pow(2,8*g-1);Te(this,n,s,g,le-1,-le)}let M=g-1,C=1,te=0;for(this[s+M]=n&255;--M>=0&&(C*=256);)n<0&&te===0&&this[s+M+1]!==0&&(te=1),this[s+M]=(n/C>>0)-te&255;return s+g},d.prototype.writeInt8=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,1,127,-128),n<0&&(n=255+n+1),this[s]=n&255,s+1},d.prototype.writeInt16LE=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,2,32767,-32768),this[s]=n&255,this[s+1]=n>>>8,s+2},d.prototype.writeInt16BE=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,2,32767,-32768),this[s]=n>>>8,this[s+1]=n&255,s+2},d.prototype.writeInt32LE=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,4,2147483647,-2147483648),this[s]=n&255,this[s+1]=n>>>8,this[s+2]=n>>>16,this[s+3]=n>>>24,s+4},d.prototype.writeInt32BE=function(n,s,g){return n=+n,s=s>>>0,g||Te(this,n,s,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),this[s]=n>>>24,this[s+1]=n>>>16,this[s+2]=n>>>8,this[s+3]=n&255,s+4},d.prototype.writeBigInt64LE=Se(function(n,s=0){return L(this,n,s,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),d.prototype.writeBigInt64BE=Se(function(n,s=0){return F(this,n,s,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function K(l,n,s,g,T,M){if(s+g>l.length)throw new RangeError("Index out of range");if(s<0)throw new RangeError("Index out of range")}function X(l,n,s,g,T){return n=+n,s=s>>>0,T||K(l,n,s,4),r.write(l,n,s,g,23,4),s+4}d.prototype.writeFloatLE=function(n,s,g){return X(this,n,s,!0,g)},d.prototype.writeFloatBE=function(n,s,g){return X(this,n,s,!1,g)};function ee(l,n,s,g,T){return n=+n,s=s>>>0,T||K(l,n,s,8),r.write(l,n,s,g,52,8),s+8}d.prototype.writeDoubleLE=function(n,s,g){return ee(this,n,s,!0,g)},d.prototype.writeDoubleBE=function(n,s,g){return ee(this,n,s,!1,g)},d.prototype.copy=function(n,s,g,T){if(!d.isBuffer(n))throw new TypeError("argument should be a Buffer");if(g||(g=0),!T&&T!==0&&(T=this.length),s>=n.length&&(s=n.length),s||(s=0),T>0&&T<g&&(T=g),T===g||n.length===0||this.length===0)return 0;if(s<0)throw new RangeError("targetStart out of bounds");if(g<0||g>=this.length)throw new RangeError("Index out of range");if(T<0)throw new RangeError("sourceEnd out of bounds");T>this.length&&(T=this.length),n.length-s<T-g&&(T=n.length-s+g);const M=T-g;return this===n&&typeof u.prototype.copyWithin=="function"?this.copyWithin(s,g,T):u.prototype.set.call(n,this.subarray(g,T),s),M},d.prototype.fill=function(n,s,g,T){if(typeof n=="string"){if(typeof s=="string"?(T=s,s=0,g=this.length):typeof g=="string"&&(T=g,g=this.length),T!==void 0&&typeof T!="string")throw new TypeError("encoding must be a string");if(typeof T=="string"&&!d.isEncoding(T))throw new TypeError("Unknown encoding: "+T);if(n.length===1){const C=n.charCodeAt(0);(T==="utf8"&&C<128||T==="latin1")&&(n=C)}}else typeof n=="number"?n=n&255:typeof n=="boolean"&&(n=Number(n));if(s<0||this.length<s||this.length<g)throw new RangeError("Out of range index");if(g<=s)return this;s=s>>>0,g=g===void 0?this.length:g>>>0,n||(n=0);let M;if(typeof n=="number")for(M=s;M<g;++M)this[M]=n;else{const C=d.isBuffer(n)?n:d.from(n,T),te=C.length;if(te===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(M=0;M<g-s;++M)this[M+s]=C[M%te]}return this};const E={};function m(l,n,s){E[l]=class extends s{constructor(){super(),Object.defineProperty(this,"message",{value:n.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${l}]`,this.stack,delete this.name}get code(){return l}set code(T){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:T,writable:!0})}toString(){return`${this.name} [${l}]: ${this.message}`}}}m("ERR_BUFFER_OUT_OF_BOUNDS",function(l){return l?`${l} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),m("ERR_INVALID_ARG_TYPE",function(l,n){return`The "${l}" argument must be of type number. Received type ${typeof n}`},TypeError),m("ERR_OUT_OF_RANGE",function(l,n,s){let g=`The value of "${l}" is out of range.`,T=s;return Number.isInteger(s)&&Math.abs(s)>2**32?T=G(String(s)):typeof s=="bigint"&&(T=String(s),(s>BigInt(2)**BigInt(32)||s<-(BigInt(2)**BigInt(32)))&&(T=G(T)),T+="n"),g+=` It must be ${n}. Received ${T}`,g},RangeError);function G(l){let n="",s=l.length;const g=l[0]==="-"?1:0;for(;s>=g+4;s-=3)n=`_${l.slice(s-3,s)}${n}`;return`${l.slice(0,s)}${n}`}function V(l,n,s){J(n,"offset"),(l[n]===void 0||l[n+s]===void 0)&&oe(n,l.length-(s+1))}function ue(l,n,s,g,T,M){if(l>s||l<n){const C=typeof n=="bigint"?"n":"";let te;throw n===0||n===BigInt(0)?te=`>= 0${C} and < 2${C} ** ${(M+1)*8}${C}`:te=`>= -(2${C} ** ${(M+1)*8-1}${C}) and < 2 ** ${(M+1)*8-1}${C}`,new E.ERR_OUT_OF_RANGE("value",te,l)}V(g,T,M)}function J(l,n){if(typeof l!="number")throw new E.ERR_INVALID_ARG_TYPE(n,"number",l)}function oe(l,n,s){throw Math.floor(l)!==l?(J(l,s),new E.ERR_OUT_OF_RANGE("offset","an integer",l)):n<0?new E.ERR_BUFFER_OUT_OF_BOUNDS:new E.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${n}`,l)}const Ye=/[^+/0-9A-Za-z-_]/g;function it(l){if(l=l.split("=")[0],l=l.trim().replace(Ye,""),l.length<2)return"";for(;l.length%4!==0;)l=l+"=";return l}function ot(l,n){n=n||1/0;let s;const g=l.length;let T=null;const M=[];for(let C=0;C<g;++C){if(s=l.charCodeAt(C),s>55295&&s<57344){if(!T){if(s>56319){(n-=3)>-1&&M.push(239,191,189);continue}else if(C+1===g){(n-=3)>-1&&M.push(239,191,189);continue}T=s;continue}if(s<56320){(n-=3)>-1&&M.push(239,191,189),T=s;continue}s=(T-55296<<10|s-56320)+65536}else T&&(n-=3)>-1&&M.push(239,191,189);if(T=null,s<128){if((n-=1)<0)break;M.push(s)}else if(s<2048){if((n-=2)<0)break;M.push(s>>6|192,s&63|128)}else if(s<65536){if((n-=3)<0)break;M.push(s>>12|224,s>>6&63|128,s&63|128)}else if(s<1114112){if((n-=4)<0)break;M.push(s>>18|240,s>>12&63|128,s>>6&63|128,s&63|128)}else throw new Error("Invalid code point")}return M}function Nt(l){const n=[];for(let s=0;s<l.length;++s)n.push(l.charCodeAt(s)&255);return n}function ge(l,n){let s,g,T;const M=[];for(let C=0;C<l.length&&!((n-=2)<0);++C)s=l.charCodeAt(C),g=s>>8,T=s%256,M.push(T),M.push(g);return M}function _e(l){return e.toByteArray(it(l))}function Pe(l,n,s,g){let T;for(T=0;T<g&&!(T+s>=n.length||T>=l.length);++T)n[T+s]=l[T];return T}function Re(l,n){return l instanceof n||l!=null&&l.constructor!=null&&l.constructor.name!=null&&l.constructor.name===n.name}function Oe(l){return l!==l}const Ce=(function(){const l="0123456789abcdef",n=new Array(256);for(let s=0;s<16;++s){const g=s*16;for(let T=0;T<16;++T)n[g+T]=l[s]+l[T]}return n})();function Se(l){return typeof BigInt>"u"?st:l}function st(){throw new Error("BigInt not supported")}})(ut);const tr=ut.Buffer,ft=ut.Buffer;var pt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bi(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var r=function o(){var f=!1;try{f=this instanceof o}catch{}return f?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(o){var f=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r,o,f.get?f:{enumerable:!0,get:function(){return t[o]}})}),r}var Ft={exports:{}},Cr;function rr(){if(Cr)return Ft.exports;Cr=1;var t=typeof Reflect=="object"?Reflect:null,e=t&&typeof t.apply=="function"?t.apply:function(v,U,D){return Function.prototype.apply.call(v,U,D)},r;t&&typeof t.ownKeys=="function"?r=t.ownKeys:Object.getOwnPropertySymbols?r=function(v){return Object.getOwnPropertyNames(v).concat(Object.getOwnPropertySymbols(v))}:r=function(v){return Object.getOwnPropertyNames(v)};function o(_){console&&console.warn&&console.warn(_)}var f=Number.isNaN||function(v){return v!==v};function u(){u.init.call(this)}Ft.exports=u,Ft.exports.once=x,u.EventEmitter=u,u.prototype._events=void 0,u.prototype._eventsCount=0,u.prototype._maxListeners=void 0;var c=10;function p(_){if(typeof _!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof _)}Object.defineProperty(u,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(_){if(typeof _!="number"||_<0||f(_))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+_+".");c=_}}),u.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},u.prototype.setMaxListeners=function(v){if(typeof v!="number"||v<0||f(v))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+v+".");return this._maxListeners=v,this};function y(_){return _._maxListeners===void 0?u.defaultMaxListeners:_._maxListeners}u.prototype.getMaxListeners=function(){return y(this)},u.prototype.emit=function(v){for(var U=[],D=1;D<arguments.length;D++)U.push(arguments[D]);var k=v==="error",H=this._events;if(H!==void 0)k=k&&H.error===void 0;else if(!k)return!1;if(k){var z;if(U.length>0&&(z=U[0]),z instanceof Error)throw z;var re=new Error("Unhandled error."+(z?" ("+z.message+")":""));throw re.context=z,re}var N=H[v];if(N===void 0)return!1;if(typeof N=="function")e(N,this,U);else for(var ae=N.length,ve=P(N,ae),D=0;D<ae;++D)e(ve[D],this,U);return!0};function b(_,v,U,D){var k,H,z;if(p(U),H=_._events,H===void 0?(H=_._events=Object.create(null),_._eventsCount=0):(H.newListener!==void 0&&(_.emit("newListener",v,U.listener?U.listener:U),H=_._events),z=H[v]),z===void 0)z=H[v]=U,++_._eventsCount;else if(typeof z=="function"?z=H[v]=D?[U,z]:[z,U]:D?z.unshift(U):z.push(U),k=y(_),k>0&&z.length>k&&!z.warned){z.warned=!0;var re=new Error("Possible EventEmitter memory leak detected. "+z.length+" "+String(v)+" listeners added. Use emitter.setMaxListeners() to increase limit");re.name="MaxListenersExceededWarning",re.emitter=_,re.type=v,re.count=z.length,o(re)}return _}u.prototype.addListener=function(v,U){return b(this,v,U,!1)},u.prototype.on=u.prototype.addListener,u.prototype.prependListener=function(v,U){return b(this,v,U,!0)};function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function I(_,v,U){var D={fired:!1,wrapFn:void 0,target:_,type:v,listener:U},k=d.bind(D);return k.listener=U,D.wrapFn=k,k}u.prototype.once=function(v,U){return p(U),this.on(v,I(this,v,U)),this},u.prototype.prependOnceListener=function(v,U){return p(U),this.prependListener(v,I(this,v,U)),this},u.prototype.removeListener=function(v,U){var D,k,H,z,re;if(p(U),k=this._events,k===void 0)return this;if(D=k[v],D===void 0)return this;if(D===U||D.listener===U)--this._eventsCount===0?this._events=Object.create(null):(delete k[v],k.removeListener&&this.emit("removeListener",v,D.listener||U));else if(typeof D!="function"){for(H=-1,z=D.length-1;z>=0;z--)if(D[z]===U||D[z].listener===U){re=D[z].listener,H=z;break}if(H<0)return this;H===0?D.shift():W(D,H),D.length===1&&(k[v]=D[0]),k.removeListener!==void 0&&this.emit("removeListener",v,re||U)}return this},u.prototype.off=u.prototype.removeListener,u.prototype.removeAllListeners=function(v){var U,D,k;if(D=this._events,D===void 0)return this;if(D.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):D[v]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete D[v]),this;if(arguments.length===0){var H=Object.keys(D),z;for(k=0;k<H.length;++k)z=H[k],z!=="removeListener"&&this.removeAllListeners(z);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(U=D[v],typeof U=="function")this.removeListener(v,U);else if(U!==void 0)for(k=U.length-1;k>=0;k--)this.removeListener(v,U[k]);return this};function B(_,v,U){var D=_._events;if(D===void 0)return[];var k=D[v];return k===void 0?[]:typeof k=="function"?U?[k.listener||k]:[k]:U?j(k):P(k,k.length)}u.prototype.listeners=function(v){return B(this,v,!0)},u.prototype.rawListeners=function(v){return B(this,v,!1)},u.listenerCount=function(_,v){return typeof _.listenerCount=="function"?_.listenerCount(v):q.call(_,v)},u.prototype.listenerCount=q;function q(_){var v=this._events;if(v!==void 0){var U=v[_];if(typeof U=="function")return 1;if(U!==void 0)return U.length}return 0}u.prototype.eventNames=function(){return this._eventsCount>0?r(this._events):[]};function P(_,v){for(var U=new Array(v),D=0;D<v;++D)U[D]=_[D];return U}function W(_,v){for(;v+1<_.length;v++)_[v]=_[v+1];_.pop()}function j(_){for(var v=new Array(_.length),U=0;U<v.length;++U)v[U]=_[U].listener||_[U];return v}function x(_,v){return new Promise(function(U,D){function k(z){_.removeListener(v,H),D(z)}function H(){typeof _.removeListener=="function"&&_.removeListener("error",k),U([].slice.call(arguments))}A(_,v,H,{once:!0}),v!=="error"&&R(_,k,{once:!0})})}function R(_,v,U){typeof _.on=="function"&&A(_,"error",v,U)}function A(_,v,U,D){if(typeof _.on=="function")D.once?_.once(v,U):_.on(v,U);else if(typeof _.addEventListener=="function")_.addEventListener(v,function k(H){D.once&&_.removeEventListener(v,k),U(H)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof _)}return Ft.exports}var Ut={exports:{}},$r;function yt(){return $r||($r=1,typeof Object.create=="function"?Ut.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Ut.exports=function(e,r){if(r){e.super_=r;var o=function(){};o.prototype=r.prototype,e.prototype=new o,e.prototype.constructor=e}}),Ut.exports}function _i(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var qr={exports:{}},be=qr.exports={},qe,je;function nr(){throw new Error("setTimeout has not been defined")}function ir(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?qe=setTimeout:qe=nr}catch{qe=nr}try{typeof clearTimeout=="function"?je=clearTimeout:je=ir}catch{je=ir}})();function jr(t){if(qe===setTimeout)return setTimeout(t,0);if((qe===nr||!qe)&&setTimeout)return qe=setTimeout,setTimeout(t,0);try{return qe(t,0)}catch{try{return qe.call(null,t,0)}catch{return qe.call(this,t,0)}}}function Ti(t){if(je===clearTimeout)return clearTimeout(t);if((je===ir||!je)&&clearTimeout)return je=clearTimeout,clearTimeout(t);try{return je(t)}catch{try{return je.call(null,t)}catch{return je.call(this,t)}}}var Ve=[],gt=!1,ct,Lt=-1;function xi(){!gt||!ct||(gt=!1,ct.length?Ve=ct.concat(Ve):Lt=-1,Ve.length&&Gr())}function Gr(){if(!gt){var t=jr(xi);gt=!0;for(var e=Ve.length;e;){for(ct=Ve,Ve=[];++Lt<e;)ct&&ct[Lt].run();Lt=-1,e=Ve.length}ct=null,gt=!1,Ti(t)}}be.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];Ve.push(new Wr(t,e)),Ve.length===1&&!gt&&jr(Gr)};function Wr(t,e){this.fun=t,this.array=e}Wr.prototype.run=function(){this.fun.apply(null,this.array)},be.title="browser",be.browser=!0,be.env={},be.argv=[],be.version="",be.versions={};function Xe(){}be.on=Xe,be.addListener=Xe,be.once=Xe,be.off=Xe,be.removeListener=Xe,be.removeAllListeners=Xe,be.emit=Xe,be.prependListener=Xe,be.prependOnceListener=Xe,be.listeners=function(t){return[]},be.binding=function(t){throw new Error("process.binding is not supported")},be.cwd=function(){return"/"},be.chdir=function(t){throw new Error("process.chdir is not supported")},be.umask=function(){return 0};var Si=qr.exports;const fe=_i(Si);var or,Hr;function Kr(){return Hr||(Hr=1,or=rr().EventEmitter),or}var sr={},Yr;function Mt(){return Yr||(Yr=1,(function(t){Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e={},r={};r.byteLength=d,r.toByteArray=B,r.fromByteArray=W;for(var o=[],f=[],u=typeof Uint8Array<"u"?Uint8Array:Array,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,y=c.length;p<y;++p)o[p]=c[p],f[c.charCodeAt(p)]=p;f[45]=62,f[95]=63;function b(R){var A=R.length;if(A%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var _=R.indexOf("=");_===-1&&(_=A);var v=_===A?0:4-_%4;return[_,v]}function d(R){var A=b(R),_=A[0],v=A[1];return(_+v)*3/4-v}function I(R,A,_){return(A+_)*3/4-_}function B(R){var A,_=b(R),v=_[0],U=_[1],D=new u(I(R,v,U)),k=0,H=U>0?v-4:v,z;for(z=0;z<H;z+=4)A=f[R.charCodeAt(z)]<<18|f[R.charCodeAt(z+1)]<<12|f[R.charCodeAt(z+2)]<<6|f[R.charCodeAt(z+3)],D[k++]=A>>16&255,D[k++]=A>>8&255,D[k++]=A&255;return U===2&&(A=f[R.charCodeAt(z)]<<2|f[R.charCodeAt(z+1)]>>4,D[k++]=A&255),U===1&&(A=f[R.charCodeAt(z)]<<10|f[R.charCodeAt(z+1)]<<4|f[R.charCodeAt(z+2)]>>2,D[k++]=A>>8&255,D[k++]=A&255),D}function q(R){return o[R>>18&63]+o[R>>12&63]+o[R>>6&63]+o[R&63]}function P(R,A,_){for(var v,U=[],D=A;D<_;D+=3)v=(R[D]<<16&16711680)+(R[D+1]<<8&65280)+(R[D+2]&255),U.push(q(v));return U.join("")}function W(R){for(var A,_=R.length,v=_%3,U=[],D=16383,k=0,H=_-v;k<H;k+=D)U.push(P(R,k,k+D>H?H:k+D));return v===1?(A=R[_-1],U.push(o[A>>2]+o[A<<4&63]+"==")):v===2&&(A=(R[_-2]<<8)+R[_-1],U.push(o[A>>10]+o[A>>4&63]+o[A<<2&63]+"=")),U.join("")}var j={};j.read=function(R,A,_,v,U){var D,k,H=U*8-v-1,z=(1<<H)-1,re=z>>1,N=-7,ae=_?U-1:0,ve=_?-1:1,xe=R[A+ae];for(ae+=ve,D=xe&(1<<-N)-1,xe>>=-N,N+=H;N>0;D=D*256+R[A+ae],ae+=ve,N-=8);for(k=D&(1<<-N)-1,D>>=-N,N+=v;N>0;k=k*256+R[A+ae],ae+=ve,N-=8);if(D===0)D=1-re;else{if(D===z)return k?NaN:(xe?-1:1)*(1/0);k=k+Math.pow(2,v),D=D-re}return(xe?-1:1)*k*Math.pow(2,D-v)},j.write=function(R,A,_,v,U,D){var k,H,z,re=D*8-U-1,N=(1<<re)-1,ae=N>>1,ve=U===23?Math.pow(2,-24)-Math.pow(2,-77):0,xe=v?0:D-1,Ue=v?1:-1,Ae=A<0||A===0&&1/A<0?1:0;for(A=Math.abs(A),isNaN(A)||A===1/0?(H=isNaN(A)?1:0,k=N):(k=Math.floor(Math.log(A)/Math.LN2),A*(z=Math.pow(2,-k))<1&&(k--,z*=2),k+ae>=1?A+=ve/z:A+=ve*Math.pow(2,1-ae),A*z>=2&&(k++,z/=2),k+ae>=N?(H=0,k=N):k+ae>=1?(H=(A*z-1)*Math.pow(2,U),k=k+ae):(H=A*Math.pow(2,ae-1)*Math.pow(2,U),k=0));U>=8;R[_+xe]=H&255,xe+=Ue,H/=256,U-=8);for(k=k<<U|H,re+=U;re>0;R[_+xe]=k&255,xe+=Ue,k/=256,re-=8);R[_+xe-Ue]|=Ae*128};(function(R){const A=r,_=j,v=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;R.Buffer=N,R.SlowBuffer=ke,R.INSPECT_MAX_BYTES=50;const U=2147483647;R.kMaxLength=U;const{Uint8Array:D,ArrayBuffer:k,SharedArrayBuffer:H}=globalThis;N.TYPED_ARRAY_SUPPORT=z(),!N.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function z(){try{const h=new D(1),i={foo:function(){return 42}};return Object.setPrototypeOf(i,D.prototype),Object.setPrototypeOf(h,i),h.foo()===42}catch{return!1}}Object.defineProperty(N.prototype,"parent",{enumerable:!0,get:function(){if(N.isBuffer(this))return this.buffer}}),Object.defineProperty(N.prototype,"offset",{enumerable:!0,get:function(){if(N.isBuffer(this))return this.byteOffset}});function re(h){if(h>U)throw new RangeError('The value "'+h+'" is invalid for option "size"');const i=new D(h);return Object.setPrototypeOf(i,N.prototype),i}function N(h,i,a){if(typeof h=="number"){if(typeof i=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Ue(h)}return ae(h,i,a)}N.poolSize=8192;function ae(h,i,a){if(typeof h=="string")return Ae(h,i);if(k.isView(h))return We(h);if(h==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h);if(ze(h,k)||h&&ze(h.buffer,k)||typeof H<"u"&&(ze(h,H)||h&&ze(h.buffer,H)))return He(h,i,a);if(typeof h=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const w=h.valueOf&&h.valueOf();if(w!=null&&w!==h)return N.from(w,i,a);const S=ht(h);if(S)return S;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof h[Symbol.toPrimitive]=="function")return N.from(h[Symbol.toPrimitive]("string"),i,a);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h)}N.from=function(h,i,a){return ae(h,i,a)},Object.setPrototypeOf(N.prototype,D.prototype),Object.setPrototypeOf(N,D);function ve(h){if(typeof h!="number")throw new TypeError('"size" argument must be of type number');if(h<0)throw new RangeError('The value "'+h+'" is invalid for option "size"')}function xe(h,i,a){return ve(h),h<=0?re(h):i!==void 0?typeof a=="string"?re(h).fill(i,a):re(h).fill(i):re(h)}N.alloc=function(h,i,a){return xe(h,i,a)};function Ue(h){return ve(h),re(h<0?0:Ke(h)|0)}N.allocUnsafe=function(h){return Ue(h)},N.allocUnsafeSlow=function(h){return Ue(h)};function Ae(h,i){if((typeof i!="string"||i==="")&&(i="utf8"),!N.isEncoding(i))throw new TypeError("Unknown encoding: "+i);const a=de(h,i)|0;let w=re(a);const S=w.write(h,i);return S!==a&&(w=w.slice(0,S)),w}function De(h){const i=h.length<0?0:Ke(h.length)|0,a=re(i);for(let w=0;w<i;w+=1)a[w]=h[w]&255;return a}function We(h){if(ze(h,D)){const i=new D(h);return He(i.buffer,i.byteOffset,i.byteLength)}return De(h)}function He(h,i,a){if(i<0||h.byteLength<i)throw new RangeError('"offset" is outside of buffer bounds');if(h.byteLength<i+(a||0))throw new RangeError('"length" is outside of buffer bounds');let w;return i===void 0&&a===void 0?w=new D(h):a===void 0?w=new D(h,i):w=new D(h,i,a),Object.setPrototypeOf(w,N.prototype),w}function ht(h){if(N.isBuffer(h)){const i=Ke(h.length)|0,a=re(i);return a.length===0||h.copy(a,0,0,i),a}if(h.length!==void 0)return typeof h.length!="number"||kr(h.length)?re(0):De(h);if(h.type==="Buffer"&&Array.isArray(h.data))return De(h.data)}function Ke(h){if(h>=U)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+U.toString(16)+" bytes");return h|0}function ke(h){return+h!=h&&(h=0),N.alloc(+h)}N.isBuffer=function(i){return i!=null&&i._isBuffer===!0&&i!==N.prototype},N.compare=function(i,a){if(ze(i,D)&&(i=N.from(i,i.offset,i.byteLength)),ze(a,D)&&(a=N.from(a,a.offset,a.byteLength)),!N.isBuffer(i)||!N.isBuffer(a))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(i===a)return 0;let w=i.length,S=a.length;for(let O=0,$=Math.min(w,S);O<$;++O)if(i[O]!==a[O]){w=i[O],S=a[O];break}return w<S?-1:S<w?1:0},N.isEncoding=function(i){switch(String(i).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},N.concat=function(i,a){if(!Array.isArray(i))throw new TypeError('"list" argument must be an Array of Buffers');if(i.length===0)return N.alloc(0);let w;if(a===void 0)for(a=0,w=0;w<i.length;++w)a+=i[w].length;const S=N.allocUnsafe(a);let O=0;for(w=0;w<i.length;++w){let $=i[w];if(ze($,D))O+$.length>S.length?(N.isBuffer($)||($=N.from($)),$.copy(S,O)):D.prototype.set.call(S,$,O);else if(N.isBuffer($))$.copy(S,O);else throw new TypeError('"list" argument must be an Array of Buffers');O+=$.length}return S};function de(h,i){if(N.isBuffer(h))return h.length;if(k.isView(h)||ze(h,k))return h.byteLength;if(typeof h!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof h);const a=h.length,w=arguments.length>2&&arguments[2]===!0;if(!w&&a===0)return 0;let S=!1;for(;;)switch(i){case"ascii":case"latin1":case"binary":return a;case"utf8":case"utf-8":return le(h).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a*2;case"hex":return a>>>1;case"base64":return se(h).length;default:if(S)return w?-1:le(h).length;i=(""+i).toLowerCase(),S=!0}}N.byteLength=de;function Te(h,i,a){let w=!1;if((i===void 0||i<0)&&(i=0),i>this.length||((a===void 0||a>this.length)&&(a=this.length),a<=0)||(a>>>=0,i>>>=0,a<=i))return"";for(h||(h="utf8");;)switch(h){case"hex":return ot(this,i,a);case"utf8":case"utf-8":return ue(this,i,a);case"ascii":return Ye(this,i,a);case"latin1":case"binary":return it(this,i,a);case"base64":return V(this,i,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Nt(this,i,a);default:if(w)throw new TypeError("Unknown encoding: "+h);h=(h+"").toLowerCase(),w=!0}}N.prototype._isBuffer=!0;function L(h,i,a){const w=h[i];h[i]=h[a],h[a]=w}N.prototype.swap16=function(){const i=this.length;if(i%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let a=0;a<i;a+=2)L(this,a,a+1);return this},N.prototype.swap32=function(){const i=this.length;if(i%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let a=0;a<i;a+=4)L(this,a,a+3),L(this,a+1,a+2);return this},N.prototype.swap64=function(){const i=this.length;if(i%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let a=0;a<i;a+=8)L(this,a,a+7),L(this,a+1,a+6),L(this,a+2,a+5),L(this,a+3,a+4);return this},N.prototype.toString=function(){const i=this.length;return i===0?"":arguments.length===0?ue(this,0,i):Te.apply(this,arguments)},N.prototype.toLocaleString=N.prototype.toString,N.prototype.equals=function(i){if(!N.isBuffer(i))throw new TypeError("Argument must be a Buffer");return this===i?!0:N.compare(this,i)===0},N.prototype.inspect=function(){let i="";const a=R.INSPECT_MAX_BYTES;return i=this.toString("hex",0,a).replace(/(.{2})/g,"$1 ").trim(),this.length>a&&(i+=" ... "),"<Buffer "+i+">"},v&&(N.prototype[v]=N.prototype.inspect),N.prototype.compare=function(i,a,w,S,O){if(ze(i,D)&&(i=N.from(i,i.offset,i.byteLength)),!N.isBuffer(i))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof i);if(a===void 0&&(a=0),w===void 0&&(w=i?i.length:0),S===void 0&&(S=0),O===void 0&&(O=this.length),a<0||w>i.length||S<0||O>this.length)throw new RangeError("out of range index");if(S>=O&&a>=w)return 0;if(S>=O)return-1;if(a>=w)return 1;if(a>>>=0,w>>>=0,S>>>=0,O>>>=0,this===i)return 0;let $=O-S,ne=w-a;const Ee=Math.min($,ne),ye=this.slice(S,O),me=i.slice(a,w);for(let ce=0;ce<Ee;++ce)if(ye[ce]!==me[ce]){$=ye[ce],ne=me[ce];break}return $<ne?-1:ne<$?1:0};function F(h,i,a,w,S){if(h.length===0)return-1;if(typeof a=="string"?(w=a,a=0):a>2147483647?a=2147483647:a<-2147483648&&(a=-2147483648),a=+a,kr(a)&&(a=S?0:h.length-1),a<0&&(a=h.length+a),a>=h.length){if(S)return-1;a=h.length-1}else if(a<0)if(S)a=0;else return-1;if(typeof i=="string"&&(i=N.from(i,w)),N.isBuffer(i))return i.length===0?-1:K(h,i,a,w,S);if(typeof i=="number")return i=i&255,typeof D.prototype.indexOf=="function"?S?D.prototype.indexOf.call(h,i,a):D.prototype.lastIndexOf.call(h,i,a):K(h,[i],a,w,S);throw new TypeError("val must be string, number or Buffer")}function K(h,i,a,w,S){let O=1,$=h.length,ne=i.length;if(w!==void 0&&(w=String(w).toLowerCase(),w==="ucs2"||w==="ucs-2"||w==="utf16le"||w==="utf-16le")){if(h.length<2||i.length<2)return-1;O=2,$/=2,ne/=2,a/=2}function Ee(me,ce){return O===1?me[ce]:me.readUInt16BE(ce*O)}let ye;if(S){let me=-1;for(ye=a;ye<$;ye++)if(Ee(h,ye)===Ee(i,me===-1?0:ye-me)){if(me===-1&&(me=ye),ye-me+1===ne)return me*O}else me!==-1&&(ye-=ye-me),me=-1}else for(a+ne>$&&(a=$-ne),ye=a;ye>=0;ye--){let me=!0;for(let ce=0;ce<ne;ce++)if(Ee(h,ye+ce)!==Ee(i,ce)){me=!1;break}if(me)return ye}return-1}N.prototype.includes=function(i,a,w){return this.indexOf(i,a,w)!==-1},N.prototype.indexOf=function(i,a,w){return F(this,i,a,w,!0)},N.prototype.lastIndexOf=function(i,a,w){return F(this,i,a,w,!1)};function X(h,i,a,w){a=Number(a)||0;const S=h.length-a;w?(w=Number(w),w>S&&(w=S)):w=S;const O=i.length;w>O/2&&(w=O/2);let $;for($=0;$<w;++$){const ne=parseInt(i.substr($*2,2),16);if(kr(ne))return $;h[a+$]=ne}return $}function ee(h,i,a,w){return Jt(le(i,h.length-a),h,a,w)}function E(h,i,a,w){return Jt(he(i),h,a,w)}function m(h,i,a,w){return Jt(se(i),h,a,w)}function G(h,i,a,w){return Jt(pe(i,h.length-a),h,a,w)}N.prototype.write=function(i,a,w,S){if(a===void 0)S="utf8",w=this.length,a=0;else if(w===void 0&&typeof a=="string")S=a,w=this.length,a=0;else if(isFinite(a))a=a>>>0,isFinite(w)?(w=w>>>0,S===void 0&&(S="utf8")):(S=w,w=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const O=this.length-a;if((w===void 0||w>O)&&(w=O),i.length>0&&(w<0||a<0)||a>this.length)throw new RangeError("Attempt to write outside buffer bounds");S||(S="utf8");let $=!1;for(;;)switch(S){case"hex":return X(this,i,a,w);case"utf8":case"utf-8":return ee(this,i,a,w);case"ascii":case"latin1":case"binary":return E(this,i,a,w);case"base64":return m(this,i,a,w);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return G(this,i,a,w);default:if($)throw new TypeError("Unknown encoding: "+S);S=(""+S).toLowerCase(),$=!0}},N.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function V(h,i,a){return i===0&&a===h.length?A.fromByteArray(h):A.fromByteArray(h.slice(i,a))}function ue(h,i,a){a=Math.min(h.length,a);const w=[];let S=i;for(;S<a;){const O=h[S];let $=null,ne=O>239?4:O>223?3:O>191?2:1;if(S+ne<=a){let Ee,ye,me,ce;switch(ne){case 1:O<128&&($=O);break;case 2:Ee=h[S+1],(Ee&192)===128&&(ce=(O&31)<<6|Ee&63,ce>127&&($=ce));break;case 3:Ee=h[S+1],ye=h[S+2],(Ee&192)===128&&(ye&192)===128&&(ce=(O&15)<<12|(Ee&63)<<6|ye&63,ce>2047&&(ce<55296||ce>57343)&&($=ce));break;case 4:Ee=h[S+1],ye=h[S+2],me=h[S+3],(Ee&192)===128&&(ye&192)===128&&(me&192)===128&&(ce=(O&15)<<18|(Ee&63)<<12|(ye&63)<<6|me&63,ce>65535&&ce<1114112&&($=ce))}}$===null?($=65533,ne=1):$>65535&&($-=65536,w.push($>>>10&1023|55296),$=56320|$&1023),w.push($),S+=ne}return oe(w)}const J=4096;function oe(h){const i=h.length;if(i<=J)return String.fromCharCode.apply(String,h);let a="",w=0;for(;w<i;)a+=String.fromCharCode.apply(String,h.slice(w,w+=J));return a}function Ye(h,i,a){let w="";a=Math.min(h.length,a);for(let S=i;S<a;++S)w+=String.fromCharCode(h[S]&127);return w}function it(h,i,a){let w="";a=Math.min(h.length,a);for(let S=i;S<a;++S)w+=String.fromCharCode(h[S]);return w}function ot(h,i,a){const w=h.length;(!i||i<0)&&(i=0),(!a||a<0||a>w)&&(a=w);let S="";for(let O=i;O<a;++O)S+=Co[h[O]];return S}function Nt(h,i,a){const w=h.slice(i,a);let S="";for(let O=0;O<w.length-1;O+=2)S+=String.fromCharCode(w[O]+w[O+1]*256);return S}N.prototype.slice=function(i,a){const w=this.length;i=~~i,a=a===void 0?w:~~a,i<0?(i+=w,i<0&&(i=0)):i>w&&(i=w),a<0?(a+=w,a<0&&(a=0)):a>w&&(a=w),a<i&&(a=i);const S=this.subarray(i,a);return Object.setPrototypeOf(S,N.prototype),S};function ge(h,i,a){if(h%1!==0||h<0)throw new RangeError("offset is not uint");if(h+i>a)throw new RangeError("Trying to access beyond buffer length")}N.prototype.readUintLE=N.prototype.readUIntLE=function(i,a,w){i=i>>>0,a=a>>>0,w||ge(i,a,this.length);let S=this[i],O=1,$=0;for(;++$<a&&(O*=256);)S+=this[i+$]*O;return S},N.prototype.readUintBE=N.prototype.readUIntBE=function(i,a,w){i=i>>>0,a=a>>>0,w||ge(i,a,this.length);let S=this[i+--a],O=1;for(;a>0&&(O*=256);)S+=this[i+--a]*O;return S},N.prototype.readUint8=N.prototype.readUInt8=function(i,a){return i=i>>>0,a||ge(i,1,this.length),this[i]},N.prototype.readUint16LE=N.prototype.readUInt16LE=function(i,a){return i=i>>>0,a||ge(i,2,this.length),this[i]|this[i+1]<<8},N.prototype.readUint16BE=N.prototype.readUInt16BE=function(i,a){return i=i>>>0,a||ge(i,2,this.length),this[i]<<8|this[i+1]},N.prototype.readUint32LE=N.prototype.readUInt32LE=function(i,a){return i=i>>>0,a||ge(i,4,this.length),(this[i]|this[i+1]<<8|this[i+2]<<16)+this[i+3]*16777216},N.prototype.readUint32BE=N.prototype.readUInt32BE=function(i,a){return i=i>>>0,a||ge(i,4,this.length),this[i]*16777216+(this[i+1]<<16|this[i+2]<<8|this[i+3])},N.prototype.readBigUInt64LE=at(function(i){i=i>>>0,T(i,"offset");const a=this[i],w=this[i+7];(a===void 0||w===void 0)&&M(i,this.length-8);const S=a+this[++i]*2**8+this[++i]*2**16+this[++i]*2**24,O=this[++i]+this[++i]*2**8+this[++i]*2**16+w*2**24;return BigInt(S)+(BigInt(O)<<BigInt(32))}),N.prototype.readBigUInt64BE=at(function(i){i=i>>>0,T(i,"offset");const a=this[i],w=this[i+7];(a===void 0||w===void 0)&&M(i,this.length-8);const S=a*2**24+this[++i]*2**16+this[++i]*2**8+this[++i],O=this[++i]*2**24+this[++i]*2**16+this[++i]*2**8+w;return(BigInt(S)<<BigInt(32))+BigInt(O)}),N.prototype.readIntLE=function(i,a,w){i=i>>>0,a=a>>>0,w||ge(i,a,this.length);let S=this[i],O=1,$=0;for(;++$<a&&(O*=256);)S+=this[i+$]*O;return O*=128,S>=O&&(S-=Math.pow(2,8*a)),S},N.prototype.readIntBE=function(i,a,w){i=i>>>0,a=a>>>0,w||ge(i,a,this.length);let S=a,O=1,$=this[i+--S];for(;S>0&&(O*=256);)$+=this[i+--S]*O;return O*=128,$>=O&&($-=Math.pow(2,8*a)),$},N.prototype.readInt8=function(i,a){return i=i>>>0,a||ge(i,1,this.length),this[i]&128?(255-this[i]+1)*-1:this[i]},N.prototype.readInt16LE=function(i,a){i=i>>>0,a||ge(i,2,this.length);const w=this[i]|this[i+1]<<8;return w&32768?w|4294901760:w},N.prototype.readInt16BE=function(i,a){i=i>>>0,a||ge(i,2,this.length);const w=this[i+1]|this[i]<<8;return w&32768?w|4294901760:w},N.prototype.readInt32LE=function(i,a){return i=i>>>0,a||ge(i,4,this.length),this[i]|this[i+1]<<8|this[i+2]<<16|this[i+3]<<24},N.prototype.readInt32BE=function(i,a){return i=i>>>0,a||ge(i,4,this.length),this[i]<<24|this[i+1]<<16|this[i+2]<<8|this[i+3]},N.prototype.readBigInt64LE=at(function(i){i=i>>>0,T(i,"offset");const a=this[i],w=this[i+7];(a===void 0||w===void 0)&&M(i,this.length-8);const S=this[i+4]+this[i+5]*2**8+this[i+6]*2**16+(w<<24);return(BigInt(S)<<BigInt(32))+BigInt(a+this[++i]*2**8+this[++i]*2**16+this[++i]*2**24)}),N.prototype.readBigInt64BE=at(function(i){i=i>>>0,T(i,"offset");const a=this[i],w=this[i+7];(a===void 0||w===void 0)&&M(i,this.length-8);const S=(a<<24)+this[++i]*2**16+this[++i]*2**8+this[++i];return(BigInt(S)<<BigInt(32))+BigInt(this[++i]*2**24+this[++i]*2**16+this[++i]*2**8+w)}),N.prototype.readFloatLE=function(i,a){return i=i>>>0,a||ge(i,4,this.length),_.read(this,i,!0,23,4)},N.prototype.readFloatBE=function(i,a){return i=i>>>0,a||ge(i,4,this.length),_.read(this,i,!1,23,4)},N.prototype.readDoubleLE=function(i,a){return i=i>>>0,a||ge(i,8,this.length),_.read(this,i,!0,52,8)},N.prototype.readDoubleBE=function(i,a){return i=i>>>0,a||ge(i,8,this.length),_.read(this,i,!1,52,8)};function _e(h,i,a,w,S,O){if(!N.isBuffer(h))throw new TypeError('"buffer" argument must be a Buffer instance');if(i>S||i<O)throw new RangeError('"value" argument is out of bounds');if(a+w>h.length)throw new RangeError("Index out of range")}N.prototype.writeUintLE=N.prototype.writeUIntLE=function(i,a,w,S){if(i=+i,a=a>>>0,w=w>>>0,!S){const ne=Math.pow(2,8*w)-1;_e(this,i,a,w,ne,0)}let O=1,$=0;for(this[a]=i&255;++$<w&&(O*=256);)this[a+$]=i/O&255;return a+w},N.prototype.writeUintBE=N.prototype.writeUIntBE=function(i,a,w,S){if(i=+i,a=a>>>0,w=w>>>0,!S){const ne=Math.pow(2,8*w)-1;_e(this,i,a,w,ne,0)}let O=w-1,$=1;for(this[a+O]=i&255;--O>=0&&($*=256);)this[a+O]=i/$&255;return a+w},N.prototype.writeUint8=N.prototype.writeUInt8=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,1,255,0),this[a]=i&255,a+1},N.prototype.writeUint16LE=N.prototype.writeUInt16LE=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,2,65535,0),this[a]=i&255,this[a+1]=i>>>8,a+2},N.prototype.writeUint16BE=N.prototype.writeUInt16BE=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,2,65535,0),this[a]=i>>>8,this[a+1]=i&255,a+2},N.prototype.writeUint32LE=N.prototype.writeUInt32LE=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,4,4294967295,0),this[a+3]=i>>>24,this[a+2]=i>>>16,this[a+1]=i>>>8,this[a]=i&255,a+4},N.prototype.writeUint32BE=N.prototype.writeUInt32BE=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,4,4294967295,0),this[a]=i>>>24,this[a+1]=i>>>16,this[a+2]=i>>>8,this[a+3]=i&255,a+4};function Pe(h,i,a,w,S){g(i,w,S,h,a,7);let O=Number(i&BigInt(4294967295));h[a++]=O,O=O>>8,h[a++]=O,O=O>>8,h[a++]=O,O=O>>8,h[a++]=O;let $=Number(i>>BigInt(32)&BigInt(4294967295));return h[a++]=$,$=$>>8,h[a++]=$,$=$>>8,h[a++]=$,$=$>>8,h[a++]=$,a}function Re(h,i,a,w,S){g(i,w,S,h,a,7);let O=Number(i&BigInt(4294967295));h[a+7]=O,O=O>>8,h[a+6]=O,O=O>>8,h[a+5]=O,O=O>>8,h[a+4]=O;let $=Number(i>>BigInt(32)&BigInt(4294967295));return h[a+3]=$,$=$>>8,h[a+2]=$,$=$>>8,h[a+1]=$,$=$>>8,h[a]=$,a+8}N.prototype.writeBigUInt64LE=at(function(i,a=0){return Pe(this,i,a,BigInt(0),BigInt("0xffffffffffffffff"))}),N.prototype.writeBigUInt64BE=at(function(i,a=0){return Re(this,i,a,BigInt(0),BigInt("0xffffffffffffffff"))}),N.prototype.writeIntLE=function(i,a,w,S){if(i=+i,a=a>>>0,!S){const Ee=Math.pow(2,8*w-1);_e(this,i,a,w,Ee-1,-Ee)}let O=0,$=1,ne=0;for(this[a]=i&255;++O<w&&($*=256);)i<0&&ne===0&&this[a+O-1]!==0&&(ne=1),this[a+O]=(i/$>>0)-ne&255;return a+w},N.prototype.writeIntBE=function(i,a,w,S){if(i=+i,a=a>>>0,!S){const Ee=Math.pow(2,8*w-1);_e(this,i,a,w,Ee-1,-Ee)}let O=w-1,$=1,ne=0;for(this[a+O]=i&255;--O>=0&&($*=256);)i<0&&ne===0&&this[a+O+1]!==0&&(ne=1),this[a+O]=(i/$>>0)-ne&255;return a+w},N.prototype.writeInt8=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,1,127,-128),i<0&&(i=255+i+1),this[a]=i&255,a+1},N.prototype.writeInt16LE=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,2,32767,-32768),this[a]=i&255,this[a+1]=i>>>8,a+2},N.prototype.writeInt16BE=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,2,32767,-32768),this[a]=i>>>8,this[a+1]=i&255,a+2},N.prototype.writeInt32LE=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,4,2147483647,-2147483648),this[a]=i&255,this[a+1]=i>>>8,this[a+2]=i>>>16,this[a+3]=i>>>24,a+4},N.prototype.writeInt32BE=function(i,a,w){return i=+i,a=a>>>0,w||_e(this,i,a,4,2147483647,-2147483648),i<0&&(i=4294967295+i+1),this[a]=i>>>24,this[a+1]=i>>>16,this[a+2]=i>>>8,this[a+3]=i&255,a+4},N.prototype.writeBigInt64LE=at(function(i,a=0){return Pe(this,i,a,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),N.prototype.writeBigInt64BE=at(function(i,a=0){return Re(this,i,a,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Oe(h,i,a,w,S,O){if(a+w>h.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("Index out of range")}function Ce(h,i,a,w,S){return i=+i,a=a>>>0,S||Oe(h,i,a,4),_.write(h,i,a,w,23,4),a+4}N.prototype.writeFloatLE=function(i,a,w){return Ce(this,i,a,!0,w)},N.prototype.writeFloatBE=function(i,a,w){return Ce(this,i,a,!1,w)};function Se(h,i,a,w,S){return i=+i,a=a>>>0,S||Oe(h,i,a,8),_.write(h,i,a,w,52,8),a+8}N.prototype.writeDoubleLE=function(i,a,w){return Se(this,i,a,!0,w)},N.prototype.writeDoubleBE=function(i,a,w){return Se(this,i,a,!1,w)},N.prototype.copy=function(i,a,w,S){if(!N.isBuffer(i))throw new TypeError("argument should be a Buffer");if(w||(w=0),!S&&S!==0&&(S=this.length),a>=i.length&&(a=i.length),a||(a=0),S>0&&S<w&&(S=w),S===w||i.length===0||this.length===0)return 0;if(a<0)throw new RangeError("targetStart out of bounds");if(w<0||w>=this.length)throw new RangeError("Index out of range");if(S<0)throw new RangeError("sourceEnd out of bounds");S>this.length&&(S=this.length),i.length-a<S-w&&(S=i.length-a+w);const O=S-w;return this===i&&typeof D.prototype.copyWithin=="function"?this.copyWithin(a,w,S):D.prototype.set.call(i,this.subarray(w,S),a),O},N.prototype.fill=function(i,a,w,S){if(typeof i=="string"){if(typeof a=="string"?(S=a,a=0,w=this.length):typeof w=="string"&&(S=w,w=this.length),S!==void 0&&typeof S!="string")throw new TypeError("encoding must be a string");if(typeof S=="string"&&!N.isEncoding(S))throw new TypeError("Unknown encoding: "+S);if(i.length===1){const $=i.charCodeAt(0);(S==="utf8"&&$<128||S==="latin1")&&(i=$)}}else typeof i=="number"?i=i&255:typeof i=="boolean"&&(i=Number(i));if(a<0||this.length<a||this.length<w)throw new RangeError("Out of range index");if(w<=a)return this;a=a>>>0,w=w===void 0?this.length:w>>>0,i||(i=0);let O;if(typeof i=="number")for(O=a;O<w;++O)this[O]=i;else{const $=N.isBuffer(i)?i:N.from(i,S),ne=$.length;if(ne===0)throw new TypeError('The value "'+i+'" is invalid for argument "value"');for(O=0;O<w-a;++O)this[O+a]=$[O%ne]}return this};const st={};function l(h,i,a){st[h]=class extends a{constructor(){super(),Object.defineProperty(this,"message",{value:i.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${h}]`,this.stack,delete this.name}get code(){return h}set code(S){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:S,writable:!0})}toString(){return`${this.name} [${h}]: ${this.message}`}}}l("ERR_BUFFER_OUT_OF_BOUNDS",function(h){return h?`${h} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),l("ERR_INVALID_ARG_TYPE",function(h,i){return`The "${h}" argument must be of type number. Received type ${typeof i}`},TypeError),l("ERR_OUT_OF_RANGE",function(h,i,a){let w=`The value of "${h}" is out of range.`,S=a;return Number.isInteger(a)&&Math.abs(a)>2**32?S=n(String(a)):typeof a=="bigint"&&(S=String(a),(a>BigInt(2)**BigInt(32)||a<-(BigInt(2)**BigInt(32)))&&(S=n(S)),S+="n"),w+=` It must be ${i}. Received ${S}`,w},RangeError);function n(h){let i="",a=h.length;const w=h[0]==="-"?1:0;for(;a>=w+4;a-=3)i=`_${h.slice(a-3,a)}${i}`;return`${h.slice(0,a)}${i}`}function s(h,i,a){T(i,"offset"),(h[i]===void 0||h[i+a]===void 0)&&M(i,h.length-(a+1))}function g(h,i,a,w,S,O){if(h>a||h<i){const $=typeof i=="bigint"?"n":"";let ne;throw i===0||i===BigInt(0)?ne=`>= 0${$} and < 2${$} ** ${(O+1)*8}${$}`:ne=`>= -(2${$} ** ${(O+1)*8-1}${$}) and < 2 ** ${(O+1)*8-1}${$}`,new st.ERR_OUT_OF_RANGE("value",ne,h)}s(w,S,O)}function T(h,i){if(typeof h!="number")throw new st.ERR_INVALID_ARG_TYPE(i,"number",h)}function M(h,i,a){throw Math.floor(h)!==h?(T(h,a),new st.ERR_OUT_OF_RANGE("offset","an integer",h)):i<0?new st.ERR_BUFFER_OUT_OF_BOUNDS:new st.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${i}`,h)}const C=/[^+/0-9A-Za-z-_]/g;function te(h){if(h=h.split("=")[0],h=h.trim().replace(C,""),h.length<2)return"";for(;h.length%4!==0;)h=h+"=";return h}function le(h,i){i=i||1/0;let a;const w=h.length;let S=null;const O=[];for(let $=0;$<w;++$){if(a=h.charCodeAt($),a>55295&&a<57344){if(!S){if(a>56319){(i-=3)>-1&&O.push(239,191,189);continue}else if($+1===w){(i-=3)>-1&&O.push(239,191,189);continue}S=a;continue}if(a<56320){(i-=3)>-1&&O.push(239,191,189),S=a;continue}a=(S-55296<<10|a-56320)+65536}else S&&(i-=3)>-1&&O.push(239,191,189);if(S=null,a<128){if((i-=1)<0)break;O.push(a)}else if(a<2048){if((i-=2)<0)break;O.push(a>>6|192,a&63|128)}else if(a<65536){if((i-=3)<0)break;O.push(a>>12|224,a>>6&63|128,a&63|128)}else if(a<1114112){if((i-=4)<0)break;O.push(a>>18|240,a>>12&63|128,a>>6&63|128,a&63|128)}else throw new Error("Invalid code point")}return O}function he(h){const i=[];for(let a=0;a<h.length;++a)i.push(h.charCodeAt(a)&255);return i}function pe(h,i){let a,w,S;const O=[];for(let $=0;$<h.length&&!((i-=2)<0);++$)a=h.charCodeAt($),w=a>>8,S=a%256,O.push(S),O.push(w);return O}function se(h){return A.toByteArray(te(h))}function Jt(h,i,a,w){let S;for(S=0;S<w&&!(S+a>=i.length||S>=h.length);++S)i[S+a]=h[S];return S}function ze(h,i){return h instanceof i||h!=null&&h.constructor!=null&&h.constructor.name!=null&&h.constructor.name===i.name}function kr(h){return h!==h}const Co=(function(){const h="0123456789abcdef",i=new Array(256);for(let a=0;a<16;++a){const w=a*16;for(let S=0;S<16;++S)i[w+S]=h[a]+h[S]}return i})();function at(h){return typeof BigInt>"u"?$o:h}function $o(){throw new Error("BigInt not supported")}})(e);const x=e.Buffer;t.Blob=e.Blob,t.BlobOptions=e.BlobOptions,t.Buffer=e.Buffer,t.File=e.File,t.FileOptions=e.FileOptions,t.INSPECT_MAX_BYTES=e.INSPECT_MAX_BYTES,t.SlowBuffer=e.SlowBuffer,t.TranscodeEncoding=e.TranscodeEncoding,t.atob=e.atob,t.btoa=e.btoa,t.constants=e.constants,t.default=x,t.isAscii=e.isAscii,t.isUtf8=e.isUtf8,t.kMaxLength=e.kMaxLength,t.kStringMaxLength=e.kStringMaxLength,t.resolveObjectURL=e.resolveObjectURL,t.transcode=e.transcode})(sr)),sr}const zr=bi(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var ar,Vr;function vi(){if(Vr)return ar;Vr=1;function t(P,W){var j=Object.keys(P);if(Object.getOwnPropertySymbols){var x=Object.getOwnPropertySymbols(P);W&&(x=x.filter(function(R){return Object.getOwnPropertyDescriptor(P,R).enumerable})),j.push.apply(j,x)}return j}function e(P){for(var W=1;W<arguments.length;W++){var j=arguments[W]!=null?arguments[W]:{};W%2?t(Object(j),!0).forEach(function(x){r(P,x,j[x])}):Object.getOwnPropertyDescriptors?Object.defineProperties(P,Object.getOwnPropertyDescriptors(j)):t(Object(j)).forEach(function(x){Object.defineProperty(P,x,Object.getOwnPropertyDescriptor(j,x))})}return P}function r(P,W,j){return W=c(W),W in P?Object.defineProperty(P,W,{value:j,enumerable:!0,configurable:!0,writable:!0}):P[W]=j,P}function o(P,W){if(!(P instanceof W))throw new TypeError("Cannot call a class as a function")}function f(P,W){for(var j=0;j<W.length;j++){var x=W[j];x.enumerable=x.enumerable||!1,x.configurable=!0,"value"in x&&(x.writable=!0),Object.defineProperty(P,c(x.key),x)}}function u(P,W,j){return W&&f(P.prototype,W),Object.defineProperty(P,"prototype",{writable:!1}),P}function c(P){var W=p(P,"string");return typeof W=="symbol"?W:String(W)}function p(P,W){if(typeof P!="object"||P===null)return P;var j=P[Symbol.toPrimitive];if(j!==void 0){var x=j.call(P,W);if(typeof x!="object")return x;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(P)}var y=Mt(),b=y.Buffer,d=zr,I=d.inspect,B=I&&I.custom||"inspect";function q(P,W,j){b.prototype.copy.call(P,W,j)}return ar=(function(){function P(){o(this,P),this.head=null,this.tail=null,this.length=0}return u(P,[{key:"push",value:function(j){var x={data:j,next:null};this.length>0?this.tail.next=x:this.head=x,this.tail=x,++this.length}},{key:"unshift",value:function(j){var x={data:j,next:this.head};this.length===0&&(this.tail=x),this.head=x,++this.length}},{key:"shift",value:function(){if(this.length!==0){var j=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,j}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(j){if(this.length===0)return"";for(var x=this.head,R=""+x.data;x=x.next;)R+=j+x.data;return R}},{key:"concat",value:function(j){if(this.length===0)return b.alloc(0);for(var x=b.allocUnsafe(j>>>0),R=this.head,A=0;R;)q(R.data,x,A),A+=R.data.length,R=R.next;return x}},{key:"consume",value:function(j,x){var R;return j<this.head.data.length?(R=this.head.data.slice(0,j),this.head.data=this.head.data.slice(j)):j===this.head.data.length?R=this.shift():R=x?this._getString(j):this._getBuffer(j),R}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(j){var x=this.head,R=1,A=x.data;for(j-=A.length;x=x.next;){var _=x.data,v=j>_.length?_.length:j;if(v===_.length?A+=_:A+=_.slice(0,j),j-=v,j===0){v===_.length?(++R,x.next?this.head=x.next:this.head=this.tail=null):(this.head=x,x.data=_.slice(v));break}++R}return this.length-=R,A}},{key:"_getBuffer",value:function(j){var x=b.allocUnsafe(j),R=this.head,A=1;for(R.data.copy(x),j-=R.data.length;R=R.next;){var _=R.data,v=j>_.length?_.length:j;if(_.copy(x,x.length-j,0,v),j-=v,j===0){v===_.length?(++A,R.next?this.head=R.next:this.head=this.tail=null):(this.head=R,R.data=_.slice(v));break}++A}return this.length-=A,x}},{key:B,value:function(j,x){return I(this,e(e({},x),{},{depth:0,customInspect:!1}))}}]),P})(),ar}var ur,Xr;function Jr(){if(Xr)return ur;Xr=1;function t(c,p){var y=this,b=this._readableState&&this._readableState.destroyed,d=this._writableState&&this._writableState.destroyed;return b||d?(p?p(c):c&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,fe.nextTick(f,this,c)):fe.nextTick(f,this,c)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(c||null,function(I){!p&&I?y._writableState?y._writableState.errorEmitted?fe.nextTick(r,y):(y._writableState.errorEmitted=!0,fe.nextTick(e,y,I)):fe.nextTick(e,y,I):p?(fe.nextTick(r,y),p(I)):fe.nextTick(r,y)}),this)}function e(c,p){f(c,p),r(c)}function r(c){c._writableState&&!c._writableState.emitClose||c._readableState&&!c._readableState.emitClose||c.emit("close")}function o(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function f(c,p){c.emit("error",p)}function u(c,p){var y=c._readableState,b=c._writableState;y&&y.autoDestroy||b&&b.autoDestroy?c.destroy(p):c.emit("error",p)}return ur={destroy:t,undestroy:o,errorOrDestroy:u},ur}var fr={},Zr;function wt(){if(Zr)return fr;Zr=1;function t(p,y){p.prototype=Object.create(y.prototype),p.prototype.constructor=p,p.__proto__=y}var e={};function r(p,y,b){b||(b=Error);function d(B,q,P){return typeof y=="string"?y:y(B,q,P)}var I=(function(B){t(q,B);function q(P,W,j){return B.call(this,d(P,W,j))||this}return q})(b);I.prototype.name=b.name,I.prototype.code=p,e[p]=I}function o(p,y){if(Array.isArray(p)){var b=p.length;return p=p.map(function(d){return String(d)}),b>2?"one of ".concat(y," ").concat(p.slice(0,b-1).join(", "),", or ")+p[b-1]:b===2?"one of ".concat(y," ").concat(p[0]," or ").concat(p[1]):"of ".concat(y," ").concat(p[0])}else return"of ".concat(y," ").concat(String(p))}function f(p,y,b){return p.substr(0,y.length)===y}function u(p,y,b){return(b===void 0||b>p.length)&&(b=p.length),p.substring(b-y.length,b)===y}function c(p,y,b){return typeof b!="number"&&(b=0),b+y.length>p.length?!1:p.indexOf(y,b)!==-1}return r("ERR_INVALID_OPT_VALUE",function(p,y){return'The value "'+y+'" is invalid for option "'+p+'"'},TypeError),r("ERR_INVALID_ARG_TYPE",function(p,y,b){var d;typeof y=="string"&&f(y,"not ")?(d="must not be",y=y.replace(/^not /,"")):d="must be";var I;if(u(p," argument"))I="The ".concat(p," ").concat(d," ").concat(o(y,"type"));else{var B=c(p,".")?"property":"argument";I='The "'.concat(p,'" ').concat(B," ").concat(d," ").concat(o(y,"type"))}return I+=". Received type ".concat(typeof b),I},TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",function(p){return"The "+p+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(p){return"Cannot call "+p+" after a stream was destroyed"}),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",function(p){return"Unknown encoding: "+p},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),fr.codes=e,fr}var cr,Qr;function en(){if(Qr)return cr;Qr=1;var t=wt().codes.ERR_INVALID_OPT_VALUE;function e(o,f,u){return o.highWaterMark!=null?o.highWaterMark:f?o[u]:null}function r(o,f,u,c){var p=e(f,c,u);if(p!=null){if(!(isFinite(p)&&Math.floor(p)===p)||p<0){var y=c?u:"highWaterMark";throw new t(y,p)}return Math.floor(p)}return o.objectMode?16:16*1024}return cr={getHighWaterMark:r},cr}var lr,tn;function Ri(){if(tn)return lr;tn=1,lr=t;function t(r,o){if(e("noDeprecation"))return r;var f=!1;function u(){if(!f){if(e("throwDeprecation"))throw new Error(o);e("traceDeprecation")?console.trace(o):console.warn(o),f=!0}return r.apply(this,arguments)}return u}function e(r){try{if(!pt.localStorage)return!1}catch{return!1}var o=pt.localStorage[r];return o==null?!1:String(o).toLowerCase()==="true"}return lr}var hr,rn;function nn(){if(rn)return hr;rn=1,hr=k;function t(L){var F=this;this.next=null,this.entry=null,this.finish=function(){Te(F,L)}}var e;k.WritableState=U;var r={deprecate:Ri()},o=Kr(),f=Mt().Buffer,u=(typeof pt<"u"?pt:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function c(L){return f.from(L)}function p(L){return f.isBuffer(L)||L instanceof u}var y=Jr(),b=en(),d=b.getHighWaterMark,I=wt().codes,B=I.ERR_INVALID_ARG_TYPE,q=I.ERR_METHOD_NOT_IMPLEMENTED,P=I.ERR_MULTIPLE_CALLBACK,W=I.ERR_STREAM_CANNOT_PIPE,j=I.ERR_STREAM_DESTROYED,x=I.ERR_STREAM_NULL_VALUES,R=I.ERR_STREAM_WRITE_AFTER_END,A=I.ERR_UNKNOWN_ENCODING,_=y.errorOrDestroy;yt()(k,o);function v(){}function U(L,F,K){e=e||Et(),L=L||{},typeof K!="boolean"&&(K=F instanceof e),this.objectMode=!!L.objectMode,K&&(this.objectMode=this.objectMode||!!L.writableObjectMode),this.highWaterMark=d(this,L,"writableHighWaterMark",K),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var X=L.decodeStrings===!1;this.decodeStrings=!X,this.defaultEncoding=L.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(ee){Ue(F,ee)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=L.emitClose!==!1,this.autoDestroy=!!L.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}U.prototype.getBuffer=function(){for(var F=this.bufferedRequest,K=[];F;)K.push(F),F=F.next;return K},(function(){try{Object.defineProperty(U.prototype,"buffer",{get:r.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var D;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(D=Function.prototype[Symbol.hasInstance],Object.defineProperty(k,Symbol.hasInstance,{value:function(F){return D.call(this,F)?!0:this!==k?!1:F&&F._writableState instanceof U}})):D=function(F){return F instanceof this};function k(L){e=e||Et();var F=this instanceof e;if(!F&&!D.call(k,this))return new k(L);this._writableState=new U(L,this,F),this.writable=!0,L&&(typeof L.write=="function"&&(this._write=L.write),typeof L.writev=="function"&&(this._writev=L.writev),typeof L.destroy=="function"&&(this._destroy=L.destroy),typeof L.final=="function"&&(this._final=L.final)),o.call(this)}k.prototype.pipe=function(){_(this,new W)};function H(L,F){var K=new R;_(L,K),fe.nextTick(F,K)}function z(L,F,K,X){var ee;return K===null?ee=new x:typeof K!="string"&&!F.objectMode&&(ee=new B("chunk",["string","Buffer"],K)),ee?(_(L,ee),fe.nextTick(X,ee),!1):!0}k.prototype.write=function(L,F,K){var X=this._writableState,ee=!1,E=!X.objectMode&&p(L);return E&&!f.isBuffer(L)&&(L=c(L)),typeof F=="function"&&(K=F,F=null),E?F="buffer":F||(F=X.defaultEncoding),typeof K!="function"&&(K=v),X.ending?H(this,K):(E||z(this,X,L,K))&&(X.pendingcb++,ee=N(this,X,E,L,F,K)),ee},k.prototype.cork=function(){this._writableState.corked++},k.prototype.uncork=function(){var L=this._writableState;L.corked&&(L.corked--,!L.writing&&!L.corked&&!L.bufferProcessing&&L.bufferedRequest&&We(this,L))},k.prototype.setDefaultEncoding=function(F){if(typeof F=="string"&&(F=F.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((F+"").toLowerCase())>-1))throw new A(F);return this._writableState.defaultEncoding=F,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function re(L,F,K){return!L.objectMode&&L.decodeStrings!==!1&&typeof F=="string"&&(F=f.from(F,K)),F}Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function N(L,F,K,X,ee,E){if(!K){var m=re(F,X,ee);X!==m&&(K=!0,ee="buffer",X=m)}var G=F.objectMode?1:X.length;F.length+=G;var V=F.length<F.highWaterMark;if(V||(F.needDrain=!0),F.writing||F.corked){var ue=F.lastBufferedRequest;F.lastBufferedRequest={chunk:X,encoding:ee,isBuf:K,callback:E,next:null},ue?ue.next=F.lastBufferedRequest:F.bufferedRequest=F.lastBufferedRequest,F.bufferedRequestCount+=1}else ae(L,F,!1,G,X,ee,E);return V}function ae(L,F,K,X,ee,E,m){F.writelen=X,F.writecb=m,F.writing=!0,F.sync=!0,F.destroyed?F.onwrite(new j("write")):K?L._writev(ee,F.onwrite):L._write(ee,E,F.onwrite),F.sync=!1}function ve(L,F,K,X,ee){--F.pendingcb,K?(fe.nextTick(ee,X),fe.nextTick(ke,L,F),L._writableState.errorEmitted=!0,_(L,X)):(ee(X),L._writableState.errorEmitted=!0,_(L,X),ke(L,F))}function xe(L){L.writing=!1,L.writecb=null,L.length-=L.writelen,L.writelen=0}function Ue(L,F){var K=L._writableState,X=K.sync,ee=K.writecb;if(typeof ee!="function")throw new P;if(xe(K),F)ve(L,K,X,F,ee);else{var E=He(K)||L.destroyed;!E&&!K.corked&&!K.bufferProcessing&&K.bufferedRequest&&We(L,K),X?fe.nextTick(Ae,L,K,E,ee):Ae(L,K,E,ee)}}function Ae(L,F,K,X){K||De(L,F),F.pendingcb--,X(),ke(L,F)}function De(L,F){F.length===0&&F.needDrain&&(F.needDrain=!1,L.emit("drain"))}function We(L,F){F.bufferProcessing=!0;var K=F.bufferedRequest;if(L._writev&&K&&K.next){var X=F.bufferedRequestCount,ee=new Array(X),E=F.corkedRequestsFree;E.entry=K;for(var m=0,G=!0;K;)ee[m]=K,K.isBuf||(G=!1),K=K.next,m+=1;ee.allBuffers=G,ae(L,F,!0,F.length,ee,"",E.finish),F.pendingcb++,F.lastBufferedRequest=null,E.next?(F.corkedRequestsFree=E.next,E.next=null):F.corkedRequestsFree=new t(F),F.bufferedRequestCount=0}else{for(;K;){var V=K.chunk,ue=K.encoding,J=K.callback,oe=F.objectMode?1:V.length;if(ae(L,F,!1,oe,V,ue,J),K=K.next,F.bufferedRequestCount--,F.writing)break}K===null&&(F.lastBufferedRequest=null)}F.bufferedRequest=K,F.bufferProcessing=!1}k.prototype._write=function(L,F,K){K(new q("_write()"))},k.prototype._writev=null,k.prototype.end=function(L,F,K){var X=this._writableState;return typeof L=="function"?(K=L,L=null,F=null):typeof F=="function"&&(K=F,F=null),L!=null&&this.write(L,F),X.corked&&(X.corked=1,this.uncork()),X.ending||de(this,X,K),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function He(L){return L.ending&&L.length===0&&L.bufferedRequest===null&&!L.finished&&!L.writing}function ht(L,F){L._final(function(K){F.pendingcb--,K&&_(L,K),F.prefinished=!0,L.emit("prefinish"),ke(L,F)})}function Ke(L,F){!F.prefinished&&!F.finalCalled&&(typeof L._final=="function"&&!F.destroyed?(F.pendingcb++,F.finalCalled=!0,fe.nextTick(ht,L,F)):(F.prefinished=!0,L.emit("prefinish")))}function ke(L,F){var K=He(F);if(K&&(Ke(L,F),F.pendingcb===0&&(F.finished=!0,L.emit("finish"),F.autoDestroy))){var X=L._readableState;(!X||X.autoDestroy&&X.endEmitted)&&L.destroy()}return K}function de(L,F,K){F.ending=!0,ke(L,F),K&&(F.finished?fe.nextTick(K):L.once("finish",K)),F.ended=!0,L.writable=!1}function Te(L,F,K){var X=L.entry;for(L.entry=null;X;){var ee=X.callback;F.pendingcb--,ee(K),X=X.next}F.corkedRequestsFree.next=L}return Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(F){this._writableState&&(this._writableState.destroyed=F)}}),k.prototype.destroy=y.destroy,k.prototype._undestroy=y.undestroy,k.prototype._destroy=function(L,F){F(L)},hr}var dr,on;function Et(){if(on)return dr;on=1;var t=Object.keys||function(b){var d=[];for(var I in b)d.push(I);return d};dr=c;var e=dn(),r=nn();yt()(c,e);for(var o=t(r.prototype),f=0;f<o.length;f++){var u=o[f];c.prototype[u]||(c.prototype[u]=r.prototype[u])}function c(b){if(!(this instanceof c))return new c(b);e.call(this,b),r.call(this,b),this.allowHalfOpen=!0,b&&(b.readable===!1&&(this.readable=!1),b.writable===!1&&(this.writable=!1),b.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",p)))}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function p(){this._writableState.ended||fe.nextTick(y,this)}function y(b){b.end()}return Object.defineProperty(c.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(d){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=d,this._writableState.destroyed=d)}}),dr}var pr={},Ot={exports:{}};var sn;function Ii(){return sn||(sn=1,(function(t,e){var r=Mt(),o=r.Buffer;function f(c,p){for(var y in c)p[y]=c[y]}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?t.exports=r:(f(r,e),e.Buffer=u);function u(c,p,y){return o(c,p,y)}u.prototype=Object.create(o.prototype),f(o,u),u.from=function(c,p,y){if(typeof c=="number")throw new TypeError("Argument must not be a number");return o(c,p,y)},u.alloc=function(c,p,y){if(typeof c!="number")throw new TypeError("Argument must be a number");var b=o(c);return p!==void 0?typeof y=="string"?b.fill(p,y):b.fill(p):b.fill(0),b},u.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return o(c)},u.allocUnsafeSlow=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(c)}})(Ot,Ot.exports)),Ot.exports}var an;function un(){if(an)return pr;an=1;var t=Ii().Buffer,e=t.isEncoding||function(x){switch(x=""+x,x&&x.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(x){if(!x)return"utf8";for(var R;;)switch(x){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return x;default:if(R)return;x=(""+x).toLowerCase(),R=!0}}function o(x){var R=r(x);if(typeof R!="string"&&(t.isEncoding===e||!e(x)))throw new Error("Unknown encoding: "+x);return R||x}pr.StringDecoder=f;function f(x){this.encoding=o(x);var R;switch(this.encoding){case"utf16le":this.text=I,this.end=B,R=4;break;case"utf8":this.fillLast=y,R=4;break;case"base64":this.text=q,this.end=P,R=3;break;default:this.write=W,this.end=j;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=t.allocUnsafe(R)}f.prototype.write=function(x){if(x.length===0)return"";var R,A;if(this.lastNeed){if(R=this.fillLast(x),R===void 0)return"";A=this.lastNeed,this.lastNeed=0}else A=0;return A<x.length?R?R+this.text(x,A):this.text(x,A):R||""},f.prototype.end=d,f.prototype.text=b,f.prototype.fillLast=function(x){if(this.lastNeed<=x.length)return x.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);x.copy(this.lastChar,this.lastTotal-this.lastNeed,0,x.length),this.lastNeed-=x.length};function u(x){return x<=127?0:x>>5===6?2:x>>4===14?3:x>>3===30?4:x>>6===2?-1:-2}function c(x,R,A){var _=R.length-1;if(_<A)return 0;var v=u(R[_]);return v>=0?(v>0&&(x.lastNeed=v-1),v):--_<A||v===-2?0:(v=u(R[_]),v>=0?(v>0&&(x.lastNeed=v-2),v):--_<A||v===-2?0:(v=u(R[_]),v>=0?(v>0&&(v===2?v=0:x.lastNeed=v-3),v):0))}function p(x,R,A){if((R[0]&192)!==128)return x.lastNeed=0,"�";if(x.lastNeed>1&&R.length>1){if((R[1]&192)!==128)return x.lastNeed=1,"�";if(x.lastNeed>2&&R.length>2&&(R[2]&192)!==128)return x.lastNeed=2,"�"}}function y(x){var R=this.lastTotal-this.lastNeed,A=p(this,x);if(A!==void 0)return A;if(this.lastNeed<=x.length)return x.copy(this.lastChar,R,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);x.copy(this.lastChar,R,0,x.length),this.lastNeed-=x.length}function b(x,R){var A=c(this,x,R);if(!this.lastNeed)return x.toString("utf8",R);this.lastTotal=A;var _=x.length-(A-this.lastNeed);return x.copy(this.lastChar,0,_),x.toString("utf8",R,_)}function d(x){var R=x&&x.length?this.write(x):"";return this.lastNeed?R+"�":R}function I(x,R){if((x.length-R)%2===0){var A=x.toString("utf16le",R);if(A){var _=A.charCodeAt(A.length-1);if(_>=55296&&_<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=x[x.length-2],this.lastChar[1]=x[x.length-1],A.slice(0,-1)}return A}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=x[x.length-1],x.toString("utf16le",R,x.length-1)}function B(x){var R=x&&x.length?this.write(x):"";if(this.lastNeed){var A=this.lastTotal-this.lastNeed;return R+this.lastChar.toString("utf16le",0,A)}return R}function q(x,R){var A=(x.length-R)%3;return A===0?x.toString("base64",R):(this.lastNeed=3-A,this.lastTotal=3,A===1?this.lastChar[0]=x[x.length-1]:(this.lastChar[0]=x[x.length-2],this.lastChar[1]=x[x.length-1]),x.toString("base64",R,x.length-A))}function P(x){var R=x&&x.length?this.write(x):"";return this.lastNeed?R+this.lastChar.toString("base64",0,3-this.lastNeed):R}function W(x){return x.toString(this.encoding)}function j(x){return x&&x.length?this.write(x):""}return pr}var yr,fn;function gr(){if(fn)return yr;fn=1;var t=wt().codes.ERR_STREAM_PREMATURE_CLOSE;function e(u){var c=!1;return function(){if(!c){c=!0;for(var p=arguments.length,y=new Array(p),b=0;b<p;b++)y[b]=arguments[b];u.apply(this,y)}}}function r(){}function o(u){return u.setHeader&&typeof u.abort=="function"}function f(u,c,p){if(typeof c=="function")return f(u,null,c);c||(c={}),p=e(p||r);var y=c.readable||c.readable!==!1&&u.readable,b=c.writable||c.writable!==!1&&u.writable,d=function(){u.writable||B()},I=u._writableState&&u._writableState.finished,B=function(){b=!1,I=!0,y||p.call(u)},q=u._readableState&&u._readableState.endEmitted,P=function(){y=!1,q=!0,b||p.call(u)},W=function(A){p.call(u,A)},j=function(){var A;if(y&&!q)return(!u._readableState||!u._readableState.ended)&&(A=new t),p.call(u,A);if(b&&!I)return(!u._writableState||!u._writableState.ended)&&(A=new t),p.call(u,A)},x=function(){u.req.on("finish",B)};return o(u)?(u.on("complete",B),u.on("abort",j),u.req?x():u.on("request",x)):b&&!u._writableState&&(u.on("end",d),u.on("close",d)),u.on("end",P),u.on("finish",B),c.error!==!1&&u.on("error",W),u.on("close",j),function(){u.removeListener("complete",B),u.removeListener("abort",j),u.removeListener("request",x),u.req&&u.req.removeListener("finish",B),u.removeListener("end",d),u.removeListener("close",d),u.removeListener("finish",B),u.removeListener("end",P),u.removeListener("error",W),u.removeListener("close",j)}}return yr=f,yr}var wr,cn;function Bi(){if(cn)return wr;cn=1;var t;function e(A,_,v){return _=r(_),_ in A?Object.defineProperty(A,_,{value:v,enumerable:!0,configurable:!0,writable:!0}):A[_]=v,A}function r(A){var _=o(A,"string");return typeof _=="symbol"?_:String(_)}function o(A,_){if(typeof A!="object"||A===null)return A;var v=A[Symbol.toPrimitive];if(v!==void 0){var U=v.call(A,_);if(typeof U!="object")return U;throw new TypeError("@@toPrimitive must return a primitive value.")}return(_==="string"?String:Number)(A)}var f=gr(),u=Symbol("lastResolve"),c=Symbol("lastReject"),p=Symbol("error"),y=Symbol("ended"),b=Symbol("lastPromise"),d=Symbol("handlePromise"),I=Symbol("stream");function B(A,_){return{value:A,done:_}}function q(A){var _=A[u];if(_!==null){var v=A[I].read();v!==null&&(A[b]=null,A[u]=null,A[c]=null,_(B(v,!1)))}}function P(A){fe.nextTick(q,A)}function W(A,_){return function(v,U){A.then(function(){if(_[y]){v(B(void 0,!0));return}_[d](v,U)},U)}}var j=Object.getPrototypeOf(function(){}),x=Object.setPrototypeOf((t={get stream(){return this[I]},next:function(){var _=this,v=this[p];if(v!==null)return Promise.reject(v);if(this[y])return Promise.resolve(B(void 0,!0));if(this[I].destroyed)return new Promise(function(H,z){fe.nextTick(function(){_[p]?z(_[p]):H(B(void 0,!0))})});var U=this[b],D;if(U)D=new Promise(W(U,this));else{var k=this[I].read();if(k!==null)return Promise.resolve(B(k,!1));D=new Promise(this[d])}return this[b]=D,D}},e(t,Symbol.asyncIterator,function(){return this}),e(t,"return",function(){var _=this;return new Promise(function(v,U){_[I].destroy(null,function(D){if(D){U(D);return}v(B(void 0,!0))})})}),t),j),R=function(_){var v,U=Object.create(x,(v={},e(v,I,{value:_,writable:!0}),e(v,u,{value:null,writable:!0}),e(v,c,{value:null,writable:!0}),e(v,p,{value:null,writable:!0}),e(v,y,{value:_._readableState.endEmitted,writable:!0}),e(v,d,{value:function(k,H){var z=U[I].read();z?(U[b]=null,U[u]=null,U[c]=null,k(B(z,!1))):(U[u]=k,U[c]=H)},writable:!0}),v));return U[b]=null,f(_,function(D){if(D&&D.code!=="ERR_STREAM_PREMATURE_CLOSE"){var k=U[c];k!==null&&(U[b]=null,U[u]=null,U[c]=null,k(D)),U[p]=D;return}var H=U[u];H!==null&&(U[b]=null,U[u]=null,U[c]=null,H(B(void 0,!0))),U[y]=!0}),_.on("readable",P.bind(null,U)),U};return wr=R,wr}var Er,ln;function Ai(){return ln||(ln=1,Er=function(){throw new Error("Readable.from is not available in the browser")}),Er}var mr,hn;function dn(){if(hn)return mr;hn=1,mr=H;var t;H.ReadableState=k,rr().EventEmitter;var e=function(m,G){return m.listeners(G).length},r=Kr(),o=Mt().Buffer,f=(typeof pt<"u"?pt:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function u(E){return o.from(E)}function c(E){return o.isBuffer(E)||E instanceof f}var p=zr,y;p&&p.debuglog?y=p.debuglog("stream"):y=function(){};var b=vi(),d=Jr(),I=en(),B=I.getHighWaterMark,q=wt().codes,P=q.ERR_INVALID_ARG_TYPE,W=q.ERR_STREAM_PUSH_AFTER_EOF,j=q.ERR_METHOD_NOT_IMPLEMENTED,x=q.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,R,A,_;yt()(H,r);var v=d.errorOrDestroy,U=["error","close","destroy","pause","resume"];function D(E,m,G){if(typeof E.prependListener=="function")return E.prependListener(m,G);!E._events||!E._events[m]?E.on(m,G):Array.isArray(E._events[m])?E._events[m].unshift(G):E._events[m]=[G,E._events[m]]}function k(E,m,G){t=t||Et(),E=E||{},typeof G!="boolean"&&(G=m instanceof t),this.objectMode=!!E.objectMode,G&&(this.objectMode=this.objectMode||!!E.readableObjectMode),this.highWaterMark=B(this,E,"readableHighWaterMark",G),this.buffer=new b,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=E.emitClose!==!1,this.autoDestroy=!!E.autoDestroy,this.destroyed=!1,this.defaultEncoding=E.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,E.encoding&&(R||(R=un().StringDecoder),this.decoder=new R(E.encoding),this.encoding=E.encoding)}function H(E){if(t=t||Et(),!(this instanceof H))return new H(E);var m=this instanceof t;this._readableState=new k(E,this,m),this.readable=!0,E&&(typeof E.read=="function"&&(this._read=E.read),typeof E.destroy=="function"&&(this._destroy=E.destroy)),r.call(this)}Object.defineProperty(H.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(m){this._readableState&&(this._readableState.destroyed=m)}}),H.prototype.destroy=d.destroy,H.prototype._undestroy=d.undestroy,H.prototype._destroy=function(E,m){m(E)},H.prototype.push=function(E,m){var G=this._readableState,V;return G.objectMode?V=!0:typeof E=="string"&&(m=m||G.defaultEncoding,m!==G.encoding&&(E=o.from(E,m),m=""),V=!0),z(this,E,m,!1,V)},H.prototype.unshift=function(E){return z(this,E,null,!0,!1)};function z(E,m,G,V,ue){y("readableAddChunk",m);var J=E._readableState;if(m===null)J.reading=!1,Ue(E,J);else{var oe;if(ue||(oe=N(J,m)),oe)v(E,oe);else if(J.objectMode||m&&m.length>0)if(typeof m!="string"&&!J.objectMode&&Object.getPrototypeOf(m)!==o.prototype&&(m=u(m)),V)J.endEmitted?v(E,new x):re(E,J,m,!0);else if(J.ended)v(E,new W);else{if(J.destroyed)return!1;J.reading=!1,J.decoder&&!G?(m=J.decoder.write(m),J.objectMode||m.length!==0?re(E,J,m,!1):We(E,J)):re(E,J,m,!1)}else V||(J.reading=!1,We(E,J))}return!J.ended&&(J.length<J.highWaterMark||J.length===0)}function re(E,m,G,V){m.flowing&&m.length===0&&!m.sync?(m.awaitDrain=0,E.emit("data",G)):(m.length+=m.objectMode?1:G.length,V?m.buffer.unshift(G):m.buffer.push(G),m.needReadable&&Ae(E)),We(E,m)}function N(E,m){var G;return!c(m)&&typeof m!="string"&&m!==void 0&&!E.objectMode&&(G=new P("chunk",["string","Buffer","Uint8Array"],m)),G}H.prototype.isPaused=function(){return this._readableState.flowing===!1},H.prototype.setEncoding=function(E){R||(R=un().StringDecoder);var m=new R(E);this._readableState.decoder=m,this._readableState.encoding=this._readableState.decoder.encoding;for(var G=this._readableState.buffer.head,V="";G!==null;)V+=m.write(G.data),G=G.next;return this._readableState.buffer.clear(),V!==""&&this._readableState.buffer.push(V),this._readableState.length=V.length,this};var ae=1073741824;function ve(E){return E>=ae?E=ae:(E--,E|=E>>>1,E|=E>>>2,E|=E>>>4,E|=E>>>8,E|=E>>>16,E++),E}function xe(E,m){return E<=0||m.length===0&&m.ended?0:m.objectMode?1:E!==E?m.flowing&&m.length?m.buffer.head.data.length:m.length:(E>m.highWaterMark&&(m.highWaterMark=ve(E)),E<=m.length?E:m.ended?m.length:(m.needReadable=!0,0))}H.prototype.read=function(E){y("read",E),E=parseInt(E,10);var m=this._readableState,G=E;if(E!==0&&(m.emittedReadable=!1),E===0&&m.needReadable&&((m.highWaterMark!==0?m.length>=m.highWaterMark:m.length>0)||m.ended))return y("read: emitReadable",m.length,m.ended),m.length===0&&m.ended?K(this):Ae(this),null;if(E=xe(E,m),E===0&&m.ended)return m.length===0&&K(this),null;var V=m.needReadable;y("need readable",V),(m.length===0||m.length-E<m.highWaterMark)&&(V=!0,y("length less than watermark",V)),m.ended||m.reading?(V=!1,y("reading or ended",V)):V&&(y("do read"),m.reading=!0,m.sync=!0,m.length===0&&(m.needReadable=!0),this._read(m.highWaterMark),m.sync=!1,m.reading||(E=xe(G,m)));var ue;return E>0?ue=F(E,m):ue=null,ue===null?(m.needReadable=m.length<=m.highWaterMark,E=0):(m.length-=E,m.awaitDrain=0),m.length===0&&(m.ended||(m.needReadable=!0),G!==E&&m.ended&&K(this)),ue!==null&&this.emit("data",ue),ue};function Ue(E,m){if(y("onEofChunk"),!m.ended){if(m.decoder){var G=m.decoder.end();G&&G.length&&(m.buffer.push(G),m.length+=m.objectMode?1:G.length)}m.ended=!0,m.sync?Ae(E):(m.needReadable=!1,m.emittedReadable||(m.emittedReadable=!0,De(E)))}}function Ae(E){var m=E._readableState;y("emitReadable",m.needReadable,m.emittedReadable),m.needReadable=!1,m.emittedReadable||(y("emitReadable",m.flowing),m.emittedReadable=!0,fe.nextTick(De,E))}function De(E){var m=E._readableState;y("emitReadable_",m.destroyed,m.length,m.ended),!m.destroyed&&(m.length||m.ended)&&(E.emit("readable"),m.emittedReadable=!1),m.needReadable=!m.flowing&&!m.ended&&m.length<=m.highWaterMark,L(E)}function We(E,m){m.readingMore||(m.readingMore=!0,fe.nextTick(He,E,m))}function He(E,m){for(;!m.reading&&!m.ended&&(m.length<m.highWaterMark||m.flowing&&m.length===0);){var G=m.length;if(y("maybeReadMore read 0"),E.read(0),G===m.length)break}m.readingMore=!1}H.prototype._read=function(E){v(this,new j("_read()"))},H.prototype.pipe=function(E,m){var G=this,V=this._readableState;switch(V.pipesCount){case 0:V.pipes=E;break;case 1:V.pipes=[V.pipes,E];break;default:V.pipes.push(E);break}V.pipesCount+=1,y("pipe count=%d opts=%j",V.pipesCount,m);var ue=(!m||m.end!==!1)&&E!==fe.stdout&&E!==fe.stderr,J=ue?Ye:Oe;V.endEmitted?fe.nextTick(J):G.once("end",J),E.on("unpipe",oe);function oe(Ce,Se){y("onunpipe"),Ce===G&&Se&&Se.hasUnpiped===!1&&(Se.hasUnpiped=!0,Nt())}function Ye(){y("onend"),E.end()}var it=ht(G);E.on("drain",it);var ot=!1;function Nt(){y("cleanup"),E.removeListener("close",Pe),E.removeListener("finish",Re),E.removeListener("drain",it),E.removeListener("error",_e),E.removeListener("unpipe",oe),G.removeListener("end",Ye),G.removeListener("end",Oe),G.removeListener("data",ge),ot=!0,V.awaitDrain&&(!E._writableState||E._writableState.needDrain)&&it()}G.on("data",ge);function ge(Ce){y("ondata");var Se=E.write(Ce);y("dest.write",Se),Se===!1&&((V.pipesCount===1&&V.pipes===E||V.pipesCount>1&&ee(V.pipes,E)!==-1)&&!ot&&(y("false write response, pause",V.awaitDrain),V.awaitDrain++),G.pause())}function _e(Ce){y("onerror",Ce),Oe(),E.removeListener("error",_e),e(E,"error")===0&&v(E,Ce)}D(E,"error",_e);function Pe(){E.removeListener("finish",Re),Oe()}E.once("close",Pe);function Re(){y("onfinish"),E.removeListener("close",Pe),Oe()}E.once("finish",Re);function Oe(){y("unpipe"),G.unpipe(E)}return E.emit("pipe",G),V.flowing||(y("pipe resume"),G.resume()),E};function ht(E){return function(){var G=E._readableState;y("pipeOnDrain",G.awaitDrain),G.awaitDrain&&G.awaitDrain--,G.awaitDrain===0&&e(E,"data")&&(G.flowing=!0,L(E))}}H.prototype.unpipe=function(E){var m=this._readableState,G={hasUnpiped:!1};if(m.pipesCount===0)return this;if(m.pipesCount===1)return E&&E!==m.pipes?this:(E||(E=m.pipes),m.pipes=null,m.pipesCount=0,m.flowing=!1,E&&E.emit("unpipe",this,G),this);if(!E){var V=m.pipes,ue=m.pipesCount;m.pipes=null,m.pipesCount=0,m.flowing=!1;for(var J=0;J<ue;J++)V[J].emit("unpipe",this,{hasUnpiped:!1});return this}var oe=ee(m.pipes,E);return oe===-1?this:(m.pipes.splice(oe,1),m.pipesCount-=1,m.pipesCount===1&&(m.pipes=m.pipes[0]),E.emit("unpipe",this,G),this)},H.prototype.on=function(E,m){var G=r.prototype.on.call(this,E,m),V=this._readableState;return E==="data"?(V.readableListening=this.listenerCount("readable")>0,V.flowing!==!1&&this.resume()):E==="readable"&&!V.endEmitted&&!V.readableListening&&(V.readableListening=V.needReadable=!0,V.flowing=!1,V.emittedReadable=!1,y("on readable",V.length,V.reading),V.length?Ae(this):V.reading||fe.nextTick(ke,this)),G},H.prototype.addListener=H.prototype.on,H.prototype.removeListener=function(E,m){var G=r.prototype.removeListener.call(this,E,m);return E==="readable"&&fe.nextTick(Ke,this),G},H.prototype.removeAllListeners=function(E){var m=r.prototype.removeAllListeners.apply(this,arguments);return(E==="readable"||E===void 0)&&fe.nextTick(Ke,this),m};function Ke(E){var m=E._readableState;m.readableListening=E.listenerCount("readable")>0,m.resumeScheduled&&!m.paused?m.flowing=!0:E.listenerCount("data")>0&&E.resume()}function ke(E){y("readable nexttick read 0"),E.read(0)}H.prototype.resume=function(){var E=this._readableState;return E.flowing||(y("resume"),E.flowing=!E.readableListening,de(this,E)),E.paused=!1,this};function de(E,m){m.resumeScheduled||(m.resumeScheduled=!0,fe.nextTick(Te,E,m))}function Te(E,m){y("resume",m.reading),m.reading||E.read(0),m.resumeScheduled=!1,E.emit("resume"),L(E),m.flowing&&!m.reading&&E.read(0)}H.prototype.pause=function(){return y("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(y("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function L(E){var m=E._readableState;for(y("flow",m.flowing);m.flowing&&E.read()!==null;);}H.prototype.wrap=function(E){var m=this,G=this._readableState,V=!1;E.on("end",function(){if(y("wrapped end"),G.decoder&&!G.ended){var oe=G.decoder.end();oe&&oe.length&&m.push(oe)}m.push(null)}),E.on("data",function(oe){if(y("wrapped data"),G.decoder&&(oe=G.decoder.write(oe)),!(G.objectMode&&oe==null)&&!(!G.objectMode&&(!oe||!oe.length))){var Ye=m.push(oe);Ye||(V=!0,E.pause())}});for(var ue in E)this[ue]===void 0&&typeof E[ue]=="function"&&(this[ue]=(function(Ye){return function(){return E[Ye].apply(E,arguments)}})(ue));for(var J=0;J<U.length;J++)E.on(U[J],this.emit.bind(this,U[J]));return this._read=function(oe){y("wrapped _read",oe),V&&(V=!1,E.resume())},this},typeof Symbol=="function"&&(H.prototype[Symbol.asyncIterator]=function(){return A===void 0&&(A=Bi()),A(this)}),Object.defineProperty(H.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(H.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(H.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(m){this._readableState&&(this._readableState.flowing=m)}}),H._fromList=F,Object.defineProperty(H.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function F(E,m){if(m.length===0)return null;var G;return m.objectMode?G=m.buffer.shift():!E||E>=m.length?(m.decoder?G=m.buffer.join(""):m.buffer.length===1?G=m.buffer.first():G=m.buffer.concat(m.length),m.buffer.clear()):G=m.buffer.consume(E,m.decoder),G}function K(E){var m=E._readableState;y("endReadable",m.endEmitted),m.endEmitted||(m.ended=!0,fe.nextTick(X,m,E))}function X(E,m){if(y("endReadableNT",E.endEmitted,E.length),!E.endEmitted&&E.length===0&&(E.endEmitted=!0,m.readable=!1,m.emit("end"),E.autoDestroy)){var G=m._writableState;(!G||G.autoDestroy&&G.finished)&&m.destroy()}}typeof Symbol=="function"&&(H.from=function(E,m){return _===void 0&&(_=Ai()),_(H,E,m)});function ee(E,m){for(var G=0,V=E.length;G<V;G++)if(E[G]===m)return G;return-1}return mr}var br,pn;function yn(){if(pn)return br;pn=1,br=p;var t=wt().codes,e=t.ERR_METHOD_NOT_IMPLEMENTED,r=t.ERR_MULTIPLE_CALLBACK,o=t.ERR_TRANSFORM_ALREADY_TRANSFORMING,f=t.ERR_TRANSFORM_WITH_LENGTH_0,u=Et();yt()(p,u);function c(d,I){var B=this._transformState;B.transforming=!1;var q=B.writecb;if(q===null)return this.emit("error",new r);B.writechunk=null,B.writecb=null,I!=null&&this.push(I),q(d);var P=this._readableState;P.reading=!1,(P.needReadable||P.length<P.highWaterMark)&&this._read(P.highWaterMark)}function p(d){if(!(this instanceof p))return new p(d);u.call(this,d),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,d&&(typeof d.transform=="function"&&(this._transform=d.transform),typeof d.flush=="function"&&(this._flush=d.flush)),this.on("prefinish",y)}function y(){var d=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(I,B){b(d,I,B)}):b(this,null,null)}p.prototype.push=function(d,I){return this._transformState.needTransform=!1,u.prototype.push.call(this,d,I)},p.prototype._transform=function(d,I,B){B(new e("_transform()"))},p.prototype._write=function(d,I,B){var q=this._transformState;if(q.writecb=B,q.writechunk=d,q.writeencoding=I,!q.transforming){var P=this._readableState;(q.needTransform||P.needReadable||P.length<P.highWaterMark)&&this._read(P.highWaterMark)}},p.prototype._read=function(d){var I=this._transformState;I.writechunk!==null&&!I.transforming?(I.transforming=!0,this._transform(I.writechunk,I.writeencoding,I.afterTransform)):I.needTransform=!0},p.prototype._destroy=function(d,I){u.prototype._destroy.call(this,d,function(B){I(B)})};function b(d,I,B){if(I)return d.emit("error",I);if(B!=null&&d.push(B),d._writableState.length)throw new f;if(d._transformState.transforming)throw new o;return d.push(null)}return br}var _r,gn;function Ni(){if(gn)return _r;gn=1,_r=e;var t=yn();yt()(e,t);function e(r){if(!(this instanceof e))return new e(r);t.call(this,r)}return e.prototype._transform=function(r,o,f){f(null,r)},_r}var Tr,wn;function Fi(){if(wn)return Tr;wn=1;var t;function e(B){var q=!1;return function(){q||(q=!0,B.apply(void 0,arguments))}}var r=wt().codes,o=r.ERR_MISSING_ARGS,f=r.ERR_STREAM_DESTROYED;function u(B){if(B)throw B}function c(B){return B.setHeader&&typeof B.abort=="function"}function p(B,q,P,W){W=e(W);var j=!1;B.on("close",function(){j=!0}),t===void 0&&(t=gr()),t(B,{readable:q,writable:P},function(R){if(R)return W(R);j=!0,W()});var x=!1;return function(R){if(!j&&!x){if(x=!0,c(B))return B.abort();if(typeof B.destroy=="function")return B.destroy();W(R||new f("pipe"))}}}function y(B){B()}function b(B,q){return B.pipe(q)}function d(B){return!B.length||typeof B[B.length-1]!="function"?u:B.pop()}function I(){for(var B=arguments.length,q=new Array(B),P=0;P<B;P++)q[P]=arguments[P];var W=d(q);if(Array.isArray(q[0])&&(q=q[0]),q.length<2)throw new o("streams");var j,x=q.map(function(R,A){var _=A<q.length-1,v=A>0;return p(R,_,v,function(U){j||(j=U),U&&x.forEach(y),!_&&(x.forEach(y),W(j))})});return q.reduce(b)}return Tr=I,Tr}var xr,En;function Ui(){if(En)return xr;En=1,xr=r;var t=rr().EventEmitter,e=yt();e(r,t),r.Readable=dn(),r.Writable=nn(),r.Duplex=Et(),r.Transform=yn(),r.PassThrough=Ni(),r.finished=gr(),r.pipeline=Fi(),r.Stream=r;function r(){t.call(this)}return r.prototype.pipe=function(o,f){var u=this;function c(q){o.writable&&o.write(q)===!1&&u.pause&&u.pause()}u.on("data",c);function p(){u.readable&&u.resume&&u.resume()}o.on("drain",p),!o._isStdio&&(!f||f.end!==!1)&&(u.on("end",b),u.on("close",d));var y=!1;function b(){y||(y=!0,o.end())}function d(){y||(y=!0,typeof o.destroy=="function"&&o.destroy())}function I(q){if(B(),t.listenerCount(this,"error")===0)throw q}u.on("error",I),o.on("error",I);function B(){u.removeListener("data",c),o.removeListener("drain",p),u.removeListener("end",b),u.removeListener("close",d),u.removeListener("error",I),o.removeListener("error",I),u.removeListener("end",B),u.removeListener("close",B),o.removeListener("close",B)}return u.on("end",B),u.on("close",B),o.on("close",B),o.emit("pipe",u),o},xr}var Dt=Ui();const Li="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let bt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=Li[r[t]&63];return e};class _t extends Promise{#e;#t;constructor(e){super(r=>{r()}),this.#e=e}static from(e){return new _t(r=>{r(e())})}static resolve(e){return new _t(r=>{r(e)})}static reject(e){return new _t((r,o)=>{o(e)})}then(e,r){return this.#t??=new Promise(this.#e),this.#t.then(e,r)}catch(e){return this.#t??=new Promise(this.#e),this.#t.catch(e)}finally(e){return this.#t??=new Promise(this.#e),this.#t.finally(e)}}function Mi(t){const e=t.reduce((f,u)=>f+u.length,0),r=new Uint8Array(e);let o=0;for(const f of t)r.set(f,o),o+=f.length;return r}function mn(t){return new _t((e,r)=>{const o=[];t.on("data",f=>{const u=bn(f);o.push(u)}),t.on("end",()=>{e(Mi(o))}),t.on("error",f=>{r(f)})})}function bn(t){let e;return t instanceof tr?e=new Uint8Array(t.buffer,t.byteOffset,t.length):t instanceof Uint8Array?e=t:typeof t=="string"?e=new TextEncoder().encode(t):e=new TextEncoder().encode(String(t)),e}function _n(t,e,r){if(t.byteLength===0)r(void 0,void 0,!0);else for(let o=0;o<t.byteLength;o+=e){const f=Math.min(t.byteLength-o,e),u=t.subarray(o,o+f),c=o+f>=t.byteLength;r(u,void 0,c)}}function Tn(t,e,r,o,f){t.on("readable",()=>{let u;for(;(u=t.read(e))!==null;){const c=bn(u);r(c,void 0,!1)}}),t.on("end",()=>{r(void 0,void 0,!0),o()}),t.on("error",u=>{r(void 0,u.message,!0),f(u)})}const Y={POS_INT:0,NEG_INT:1,BYTE_STRING:2,UTF8_STRING:3,ARRAY:4,MAP:5,TAG:6,SIMPLE_FLOAT:7},ie={DATE_STRING:0,DATE_EPOCH:1,POS_BIGINT:2,NEG_BIGINT:3,CBOR:24,URI:32,BASE64URL:33,BASE64:34,DATE_EPOCH_DAYS:100,SET:258,JSON:262,WTF8:273,DATE_FULL:1004,REGEXP:21066,SELF_DESCRIBED:55799,INVALID_16:65535,INVALID_32:4294967295,INVALID_64:0xffffffffffffffffn},Q={ZERO:0,ONE:24,TWO:25,FOUR:26,EIGHT:27,INDEFINITE:31},et={FALSE:20,TRUE:21,NULL:22,UNDEFINED:23};let Ie=class{static BREAK=Symbol.for("github.com/hildjj/cbor2/break");static ENCODED=Symbol.for("github.com/hildjj/cbor2/cbor-encoded");static LENGTH=Symbol.for("github.com/hildjj/cbor2/length")};const kt={MIN:-(2n**63n),MAX:2n**64n-1n};let Z=class Zt{static#e=new Map;tag;contents;constructor(e,r=void 0){this.tag=e,this.contents=r}get noChildren(){return!!Zt.#e.get(this.tag)?.noChildren}static registerDecoder(e,r,o){const f=this.#e.get(e);return this.#e.set(e,r),f&&("comment"in r||(r.comment=f.comment),"noChildren"in r||(r.noChildren=f.noChildren)),o&&!r.comment&&(r.comment=()=>`(${o})`),f}static clearDecoder(e){const r=this.#e.get(e);return this.#e.delete(e),r}static getDecoder(e){return this.#e.get(e)}static getAllDecoders(){return new Map(this.#e)}*[Symbol.iterator](){yield this.contents}push(e){return this.contents=e,1}decode(e){const r=e?.tags?.get(this.tag)??(e?.ignoreGlobalTags?void 0:Zt.#e.get(this.tag));return r?r(this,e):this}comment(e,r){const o=e?.tags?.get(this.tag)??(e?.ignoreGlobalTags?void 0:Zt.#e.get(this.tag));if(o?.comment)return o.comment(this,e,r)}toCBOR(){return[this.tag,this.contents]}[Symbol.for("nodejs.util.inspect.custom")](e,r,o){return`${this.tag}(${o(this.contents,r)})`}};function Pt(t){if(t!=null&&typeof t=="object")return t[Ie.ENCODED]}function Oi(t){if(t!=null&&typeof t=="object")return t[Ie.LENGTH]}function Tt(t,e){Object.defineProperty(t,Ie.ENCODED,{configurable:!0,enumerable:!1,value:e})}function xt(t,e){const r=Object(t);return Tt(r,e),r}const Sr=Symbol("CBOR_RANGES");function xn(t,e){Object.defineProperty(t,Sr,{configurable:!1,enumerable:!1,writable:!1,value:e})}function Ct(t){return t[Sr]}function Di(t){return Ct(t)!==void 0}function vr(t,e=0,r=t.length-1){const o=t.subarray(e,r),f=Ct(t);if(f){const u=[];for(const c of f)if(c[0]>=e&&c[0]+c[1]<=r){const p=[...c];p[0]-=e,u.push(p)}u.length&&xn(o,u)}return o}function Sn(t){let e=Math.ceil(t.length/2);const r=new Uint8Array(e);e--;for(let o=t.length,f=o-2;o>=0;o=f,f-=2,e--)r[e]=parseInt(t.substring(f,o),16);return r}function Ne(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"")}function ki(t){const e=t.reduce((c,p)=>c+p.length,0),r=t.some(c=>Di(c)),o=[],f=new Uint8Array(e);let u=0;for(const c of t){if(!(c instanceof Uint8Array))throw new TypeError(`Invalid array: ${c}`);if(f.set(c,u),r){const p=c[Sr]??[[0,c.length]];for(const y of p)y[0]+=u;o.push(...p)}u+=c.length}return r&&xn(f,o),f}function Rr(t){const e=atob(t);return Uint8Array.from(e,r=>r.codePointAt(0))}const Pi={"-":"+",_:"/"};function Ci(t){const e=t.replace(/[_-]/g,r=>Pi[r]);return Rr(e.padEnd(Math.ceil(e.length/4)*4,"="))}function $i(){const t=new Uint8Array(4),e=new Uint32Array(t.buffer);return!((e[0]=1)&t[0])}function vn(t){let e="";for(const r of t){const o=r.codePointAt(0)?.toString(16).padStart(4,"0");e&&(e+=", "),e+=`U+${o}`}return e}class Rn{#e=new Map;registerEncoder(e,r){const o=this.#e.get(e);return this.#e.set(e,r),o}get(e){return this.#e.get(e)}delete(e){return this.#e.delete(e)}clear(){this.#e.clear()}}function In(t,e){const[r,o,f]=t,[u,c,p]=e,y=Math.min(f.length,p.length);for(let b=0;b<y;b++){const d=f[b]-p[b];if(d!==0)return d}return 0}class $t{static defaultOptions={chunkSize:4096};#e;#t=[];#r=null;#n=0;#i=0;constructor(e={}){if(this.#e={...$t.defaultOptions,...e},this.#e.chunkSize<8)throw new RangeError(`Expected size >= 8, got ${this.#e.chunkSize}`);this.#o()}get length(){return this.#i}read(){this.#u();const e=new Uint8Array(this.#i);let r=0;for(const o of this.#t)e.set(o,r),r+=o.length;return this.#o(),e}write(e){const r=e.length;r>this.#f()?(this.#u(),r>this.#e.chunkSize?(this.#t.push(e),this.#o()):(this.#o(),this.#t[this.#t.length-1].set(e),this.#n=r)):(this.#t[this.#t.length-1].set(e,this.#n),this.#n+=r),this.#i+=r}writeUint8(e){this.#s(1),this.#r.setUint8(this.#n,e),this.#a(1)}writeUint16(e,r=!1){this.#s(2),this.#r.setUint16(this.#n,e,r),this.#a(2)}writeUint32(e,r=!1){this.#s(4),this.#r.setUint32(this.#n,e,r),this.#a(4)}writeBigUint64(e,r=!1){this.#s(8),this.#r.setBigUint64(this.#n,e,r),this.#a(8)}writeInt16(e,r=!1){this.#s(2),this.#r.setInt16(this.#n,e,r),this.#a(2)}writeInt32(e,r=!1){this.#s(4),this.#r.setInt32(this.#n,e,r),this.#a(4)}writeBigInt64(e,r=!1){this.#s(8),this.#r.setBigInt64(this.#n,e,r),this.#a(8)}writeFloat32(e,r=!1){this.#s(4),this.#r.setFloat32(this.#n,e,r),this.#a(4)}writeFloat64(e,r=!1){this.#s(8),this.#r.setFloat64(this.#n,e,r),this.#a(8)}clear(){this.#i=0,this.#t=[],this.#o()}#o(){const e=new Uint8Array(this.#e.chunkSize);this.#t.push(e),this.#n=0,this.#r=new DataView(e.buffer,e.byteOffset,e.byteLength)}#u(){if(this.#n===0){this.#t.pop();return}const e=this.#t.length-1;this.#t[e]=this.#t[e].subarray(0,this.#n),this.#n=0,this.#r=null}#f(){const e=this.#t.length-1;return this.#t[e].length-this.#n}#s(e){this.#f()<e&&(this.#u(),this.#o())}#a(e){this.#n+=e,this.#i+=e}}const Ir=1n<<15n,St=0b11111n<<10n,Bn=1n<<9n,An=Bn-1n,Nn=Bn|An,Br=1n<<31n,vt=0b11111111n<<23n,Fn=1n<<22n,Un=Fn-1n,Ln=Fn|Un,qt=1n<<63n,Je=0b11111111111n<<52n,Rt=1n<<51n,jt=Rt-1n,Mn=Rt|jt,On=jt-(An<<42n),Dn=jt-(Un<<29n),qi={2:"0b",8:"0o",16:"0x"};var ji=(t=>(t[t.NATURAL=-2]="NATURAL",t[t.UNKNOWN=-1]="UNKNOWN",t[t.F16=2]="F16",t[t.F32=4]="F32",t[t.F64=8]="F64",t))(ji||{});function kn(t,e,r,o){let f="nan'";return t.quiet||(f+="!"),t.sign===-1&&(f+="-"),f+=o(Math.abs(t.payload),r),f+="'",f+=t.encodingIndicator,f}let Gi=class extends Number{#e;#t=-1;constructor(e,r=!0,o=-1){super(NaN);const f=e;if(typeof e=="number"){if(!Number.isSafeInteger(e))throw new Error(`Invalid NAN payload: ${e}`);e=BigInt(e);let u=0n;if(e<0&&(u=qt,e=-e),e>=Rt)throw new Error(`Payload too large: ${f}`);const c=r?Rt:0n;switch(this.#e=u|Je|c|e,o){case-2:throw new Error("NAN_SIZE.NATURAL only valid for bigint constructor");case-1:o=this.preferredSize;break;case 2:if(this.#e&On)throw new Error("Invalid size for payload");break;case 4:if(this.#e&Dn)throw new Error("Invalid size for payload");break;case 8:break;default:throw new Error(`Invalid size: ${o}`)}this.#t=o}else if(typeof e=="bigint"){let u=-1;if((e&Je)===Je)this.#e=e,u=8;else if((e&vt)===vt){const c=(e&Br)<<32n;this.#e=c|Je|(e&Ln)<<29n,u=4}else if((e&St)===St){const c=(e&Ir)<<48n;this.#e=c|Je|(e&Nn)<<42n,u=2}else throw new Error(`Invalid raw NaN value: ${e}`);if(o===-1)this.#t=this.preferredSize;else if(o===-2)this.#t=u;else{if(o<u)throw new Error("Invalid bigint NaN size");this.#t=o}}else{const u=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.length){case 3:{if(e[0]!==249)throw new Error("Invalid CBOR encoding for half float");const c=BigInt(u.getUint16(1,!1));if((c&St)!==St)throw new Error("Not a NaN");const p=(c&Ir)<<48n;this.#e=p|Je|(c&Nn)<<42n,this.#t=2;break}case 5:{if(e[0]!==250)throw new Error("Invalid CBOR encoding for single float");const c=BigInt(u.getUint32(1,!1));if((c&vt)!==vt)throw new Error("Not a NaN");const p=(c&Br)<<32n;this.#e=p|Je|(c&Ln)<<29n,this.#t=4;break}case 9:{if(e[0]!==251)throw new Error("Invalid CBOR encoding for double float");if(this.#e=u.getBigUint64(1,!1),(this.#e&Je)!==Je)throw new Error("Not a NaN (NaNaN)");this.#t=8;break}default:throw new RangeError(`Invalid NAN size (should be 2, 4, or 8): ${e.length-1}`)}}if(!this.payload&&!this.quiet)throw new Error("Signalling NaN with zero payload")}get bytes(){const e=new ArrayBuffer(this.#t+1),r=new DataView(e);switch(this.#t){case 2:{r.setUint8(0,249);const o=(this.#e&qt?Ir:0n)|St|(this.#e&Mn)>>42n;r.setUint16(1,Number(o),!1);break}case 4:{r.setUint8(0,250);const o=(this.#e&qt?Br:0n)|vt|(this.#e&Mn)>>29n;r.setUint32(1,Number(o),!1);break}case 8:r.setUint8(0,251),r.setBigUint64(1,this.#e);break}return new Uint8Array(e)}get quiet(){return!!(this.#e&Rt)}get sign(){return this.#e&qt?-1:1}get payload(){return Number(this.#e&jt)*this.sign}get raw(){return this.#e}get encodingIndicator(){switch(this.#t){case 2:return"_1";case 4:return"_2"}return"_3"}get size(){return this.#t}get preferredSize(){return(this.#e&On)===0n?2:(this.#e&Dn)===0n?4:8}get isShortestEncoding(){return this.preferredSize===this.#t}toCBOR(e){e.write(this.bytes)}toString(e=10){return kn(this,1,{},r=>(qi[e]??"")+r.toString(e))}[Symbol.for("nodejs.util.inspect.custom")](e,r,o){return kn(this,e,r,o)}};function Pn(t,e=0,r=!1){const o=t[e]&128?-1:1,f=(t[e]&124)>>2,u=(t[e]&3)<<8|t[e+1];if(f===0){if(r&&u!==0)throw new Error(`Unwanted subnormal: ${o*5960464477539063e-23*u}`);return o*5960464477539063e-23*u}else if(f===31)return u?NaN:o*(1/0);return o*2**(f-25)*(1024+u)}function Cn(t){const e=new DataView(new ArrayBuffer(4));e.setFloat32(0,t,!1);const r=e.getUint32(0,!1);if((r&8191)!==0)return null;let o=r>>16&32768;const f=r>>23&255,u=r&8388607;if(!(f===0&&u===0))if(f>=113&&f<=142)o+=(f-112<<10)+(u>>13);else if(f>=103&&f<113){if(u&(1<<126-f)-1)return null;o+=u+8388608>>126-f}else if(f===255)o|=31744,o|=u>>13;else return null;return o}function Wi(t){if(t!==0){const e=new ArrayBuffer(8),r=new DataView(e);r.setFloat64(0,t,!1);const o=r.getBigUint64(0,!1);if((o&0x7ff0000000000000n)===0n)return o&0x8000000000000000n?-0:0}return t}function Hi(t){switch(t.length){case 2:Pn(t,0,!0);break;case 4:{const e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=e.getUint32(0,!1);if((r&2139095040)===0&&r&8388607)throw new Error(`Unwanted subnormal: ${e.getFloat32(0,!1)}`);break}case 8:{const e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=e.getBigUint64(0,!1);if((r&0x7ff0000000000000n)===0n&&r&0x000fffffffffffn)throw new Error(`Unwanted subnormal: ${e.getFloat64(0,!1)}`);break}default:throw new TypeError(`Bad input to isSubnormal: ${t}`)}}class Ki extends TypeError{code="ERR_ENCODING_INVALID_ENCODED_DATA";constructor(){super("The encoded data was not valid for encoding wtf-8")}}class Yi extends RangeError{code="ERR_ENCODING_NOT_SUPPORTED";constructor(e){super(`Invalid encoding: "${e}"`)}}const zi=65279,$n=new Uint8Array(0),Vi=55296,Xi=56320,Ji=65533,qn="wtf-8";function Zi(t){return t&&!(t instanceof ArrayBuffer)&&t.buffer instanceof ArrayBuffer}function Qi(t){return t?t instanceof Uint8Array?t:Zi(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t):$n}const eo=[0,0,0,0,0,0,0,0,-1,-1,-1,-1,1,1,2,3];class Gt{static DEFAULT_BUFFERSIZE=4096;encoding=qn;fatal;ignoreBOM;bufferSize;#e=0;#t=0;#r=0;#n=!0;#i;constructor(e="wtf8",r=void 0){if(e.toLowerCase().replace("-","")!=="wtf8")throw new Yi(e);if(this.fatal=!!r?.fatal,this.ignoreBOM=!!r?.ignoreBOM,this.bufferSize=Math.floor(r?.bufferSize??Gt.DEFAULT_BUFFERSIZE),isNaN(this.bufferSize)||this.bufferSize<1)throw new RangeError(`Invalid buffer size: ${r?.bufferSize}`);this.#i=new Uint16Array(this.bufferSize)}decode(e,r){const o=!!r?.stream,f=Qi(e),u=[],c=this.#i,p=this.bufferSize-3;let y=0;const b=()=>{if(this.#t=0,this.#e=0,this.#r=0,this.fatal)throw new Ki;c[y++]=Ji},d=()=>{const B=this.#r;for(let q=0;q<B;q++)b()},I=B=>{if(this.#e===0)switch(eo[B>>4]){case-1:b();break;case 0:c[y++]=B;break;case 1:this.#t=B&31,(this.#t&30)===0?b():(this.#e=1,this.#r=1);break;case 2:this.#t=B&15,this.#e=2,this.#r=1;break;case 3:B&8?b():(this.#t=B&7,this.#e=3,this.#r=1);break}else{if((B&192)!==128||this.#r===1&&this.#e===2&&this.#t===0&&(B&32)===0||this.#e===3&&this.#t===0&&(B&48)===0)return d(),I(B);if(this.#t=this.#t<<6|B&63,this.#r++,--this.#e===0){if(this.ignoreBOM||!this.#n||this.#t!==zi)if(this.#t<65536)c[y++]=this.#t;else{const q=this.#t-65536;c[y++]=q>>>10&1023|Vi,c[y++]=q&1023|Xi}this.#t=0,this.#r=0,this.#n=!1}}};for(const B of f)y>=p&&(u.push(String.fromCharCode.apply(null,c.subarray(0,y))),y=0),I(B);return o||(this.#n=!0,(this.#t||this.#e)&&d()),y>0&&u.push(String.fromCharCode.apply(null,c.subarray(0,y))),u.join("")}}function to(t){let e=0;for(const r of t){const o=r.codePointAt(0);o<128?e++:o<2048?e+=2:o<65536?e+=3:e+=4}return e}class ro{encoding=qn;encode(e){if(!e)return $n;const r=new Uint8Array(to(String(e)));return this.encodeInto(e,r),r}encodeInto(e,r){const o=String(e),f=o.length,u=r.length;let c=0,p=0;for(p=0;p<f;p++){const y=o.codePointAt(p);if(y<128){if(c>=u)break;r[c++]=y}else if(y<2048){if(c>=u-1)break;r[c++]=192|y>>6,r[c++]=128|y&63}else if(y<65536){if(c>=u-2)break;r[c++]=224|y>>12,r[c++]=128|y>>6&63,r[c++]=128|y&63}else{if(c>=u-3)break;r[c++]=240|y>>18,r[c++]=128|y>>12&63,r[c++]=128|y>>6&63,r[c++]=128|y&63,p++}}return{read:p,written:c}}}const jn=Y.SIMPLE_FLOAT<<5|Q.TWO,no=Y.SIMPLE_FLOAT<<5|Q.FOUR,io=Y.SIMPLE_FLOAT<<5|Q.EIGHT,oo=Y.SIMPLE_FLOAT<<5|et.TRUE,so=Y.SIMPLE_FLOAT<<5|et.FALSE,ao=Y.SIMPLE_FLOAT<<5|et.UNDEFINED,uo=Y.SIMPLE_FLOAT<<5|et.NULL,fo=new TextEncoder,co=new ro,Gn={...$t.defaultOptions,avoidInts:!1,cde:!1,collapseBigInts:!0,dateTag:ie.DATE_EPOCH,dcbor:!1,float64:!1,flushToZero:!1,forceEndian:null,ignoreOriginalEncoding:!1,largeNegativeAsBigInt:!1,reduceUnsafeNumbers:!1,rejectBigInts:!1,rejectCustomSimples:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectUndefined:!1,simplifyNegativeZero:!1,sortKeys:null,stringNormalization:null,types:null,wtf8:!1,ignoreGlobalTags:!1},Wn={cde:!0,ignoreOriginalEncoding:!0,sortKeys:In},lo={...Wn,dcbor:!0,largeNegativeAsBigInt:!0,reduceUnsafeNumbers:!0,rejectCustomSimples:!0,rejectDuplicateKeys:!0,rejectUndefined:!0,simplifyNegativeZero:!0,stringNormalization:"NFC"};function Hn(t){const e=t<0;return typeof t=="bigint"?[e?-t-1n:t,e]:[e?-t-1:t,e]}function Ar(t,e,r){if(r.rejectFloats)throw new Error(`Attempt to encode an unwanted floating point number: ${t}`);if(isNaN(t))e.writeUint8(jn),e.writeUint16(32256);else if(!r.float64&&Math.fround(t)===t){const o=Cn(t);o===null?(e.writeUint8(no),e.writeFloat32(t)):(e.writeUint8(jn),e.writeUint16(o))}else e.writeUint8(io),e.writeFloat64(t)}function Me(t,e,r){const[o,f]=Hn(t);if(f&&r)throw new TypeError(`Negative size: ${t}`);r??=f?Y.NEG_INT:Y.POS_INT,r<<=5,o<24?e.writeUint8(r|o):o<=255?(e.writeUint8(r|Q.ONE),e.writeUint8(o)):o<=65535?(e.writeUint8(r|Q.TWO),e.writeUint16(o)):o<=4294967295?(e.writeUint8(r|Q.FOUR),e.writeUint32(o)):(e.writeUint8(r|Q.EIGHT),e.writeBigUint64(BigInt(o)))}function It(t,e,r){typeof t=="number"?Me(t,e,Y.TAG):typeof t=="object"&&!r.ignoreOriginalEncoding&&Ie.ENCODED in t?e.write(t[Ie.ENCODED]):t<=Number.MAX_SAFE_INTEGER?Me(Number(t),e,Y.TAG):(e.writeUint8(Y.TAG<<5|Q.EIGHT),e.writeBigUint64(BigInt(t)))}function Kn(t,e,r){const[o,f]=Hn(t);if(r.collapseBigInts&&(!r.largeNegativeAsBigInt||t>=-0x8000000000000000n)){if(o<=0xffffffffn){Me(Number(t),e);return}if(o<=0xffffffffffffffffn){const b=(f?Y.NEG_INT:Y.POS_INT)<<5;e.writeUint8(b|Q.EIGHT),e.writeBigUint64(o);return}}if(r.rejectBigInts)throw new Error(`Attempt to encode unwanted bigint: ${t}`);const u=f?ie.NEG_BIGINT:ie.POS_BIGINT,c=o.toString(16),p=c.length%2?"0":"";It(u,e,r);const y=Sn(p+c);Me(y.length,e,Y.BYTE_STRING),e.write(y)}function ho(t,e,r){r.flushToZero&&(t=Wi(t)),Object.is(t,-0)?r.simplifyNegativeZero?r.avoidInts?Ar(0,e,r):Me(0,e):Ar(t,e,r):!r.avoidInts&&Number.isSafeInteger(t)?Me(t,e):r.reduceUnsafeNumbers&&Math.floor(t)===t&&t>=kt.MIN&&t<=kt.MAX?Kn(BigInt(t),e,r):Ar(t,e,r)}function po(t,e,r){const o=r.stringNormalization?t.normalize(r.stringNormalization):t;if(r.wtf8&&!t.isWellFormed()){const f=co.encode(o);It(ie.WTF8,e,r),Me(f.length,e,Y.BYTE_STRING),e.write(f)}else{const f=fo.encode(o);Me(f.length,e,Y.UTF8_STRING),e.write(f)}}function yo(t,e,r){const o=t;Nr(o,o.length,Y.ARRAY,e,r);for(const f of o)lt(f,e,r)}function go(t,e){Me(t.length,e,Y.BYTE_STRING),e.write(t)}const Wt=new Rn;Wt.registerEncoder(Array,yo),Wt.registerEncoder(Uint8Array,go);function we(t,e){return Wt.registerEncoder(t,e)}function Nr(t,e,r,o,f){const u=Oi(t);u&&!f.ignoreOriginalEncoding?o.write(u):Me(e,o,r)}function wo(t,e,r){if(t===null){e.writeUint8(uo);return}if(!r.ignoreOriginalEncoding&&Ie.ENCODED in t){e.write(t[Ie.ENCODED]);return}const o=t.constructor;if(o){const u=r.types?.get(o)??(r.ignoreGlobalTags?void 0:Wt.get(o));if(u){const c=u(t,e,r);if(c!==void 0){if(!Array.isArray(c)||c.length!==2)throw new Error("Invalid encoder return value");(typeof c[0]=="bigint"||isFinite(Number(c[0])))&&It(c[0],e,r),lt(c[1],e,r)}return}}if(typeof t.toCBOR=="function"){const u=t.toCBOR(e,r);u&&((typeof u[0]=="bigint"||isFinite(Number(u[0])))&&It(u[0],e,r),lt(u[1],e,r));return}if(typeof t.toJSON=="function"){lt(t.toJSON(),e,r);return}const f=Object.entries(t).map(u=>[u[0],u[1],mt(u[0],r)]);r.sortKeys&&f.sort(r.sortKeys),Nr(t,f.length,Y.MAP,e,r);for(const[u,c,p]of f)e.write(p),lt(c,e,r)}function lt(t,e,r){switch(typeof t){case"number":ho(t,e,r);break;case"bigint":Kn(t,e,r);break;case"string":po(t,e,r);break;case"boolean":e.writeUint8(t?oo:so);break;case"undefined":if(r.rejectUndefined)throw new Error("Attempt to encode unwanted undefined.");e.writeUint8(ao);break;case"object":wo(t,e,r);break;case"symbol":throw new TypeError(`Unknown symbol: ${t.toString()}`);default:throw new TypeError(`Unknown type: ${typeof t}, ${String(t)}`)}}function mt(t,e={}){const r={...Gn};e.dcbor?Object.assign(r,lo):e.cde&&Object.assign(r,Wn),Object.assign(r,e);const o=new $t(r);return lt(t,o,r),o.read()}var Ht=(t=>(t[t.NEVER=-1]="NEVER",t[t.PREFERRED=0]="PREFERRED",t[t.ALWAYS=1]="ALWAYS",t))(Ht||{});class Ge{static KnownSimple=new Map([[et.FALSE,!1],[et.TRUE,!0],[et.NULL,null],[et.UNDEFINED,void 0]]);value;constructor(e){this.value=e}static create(e){return Ge.KnownSimple.has(e)?Ge.KnownSimple.get(e):new Ge(e)}toCBOR(e,r){if(r.rejectCustomSimples)throw new Error(`Cannot encode non-standard Simple value: ${this.value}`);Me(this.value,e,Y.SIMPLE_FLOAT)}toString(){return`simple(${this.value})`}decode(){return Ge.KnownSimple.has(this.value)?Ge.KnownSimple.get(this.value):this}[Symbol.for("nodejs.util.inspect.custom")](e,r,o){return`simple(${o(this.value,r)})`}}const Eo=new TextDecoder("utf8",{fatal:!0,ignoreBOM:!0});let Kt=class ci{static defaultOptions={maxDepth:1024,encoding:"hex",requirePreferred:!1};#e;#t;#r=0;#n;constructor(e,r){if(this.#n={...ci.defaultOptions,...r},typeof e=="string")switch(this.#n.encoding){case"hex":this.#e=Sn(e);break;case"base64":this.#e=Rr(e);break;default:throw new TypeError(`Encoding not implemented: "${this.#n.encoding}"`)}else this.#e=e;this.#t=new DataView(this.#e.buffer,this.#e.byteOffset,this.#e.byteLength)}toHere(e){return vr(this.#e,e,this.#r)}*[Symbol.iterator](){if(yield*this.#i(0),this.#r!==this.#e.length)throw new Error("Extra data in input")}*seq(){for(;this.#r<this.#e.length;)yield*this.#i(0)}*#i(e){if(e++>this.#n.maxDepth)throw new Error(`Maximum depth ${this.#n.maxDepth} exceeded`);const r=this.#r,o=this.#t.getUint8(this.#r++),f=o>>5,u=o&31;let c=u,p=!1,y=0;switch(u){case Q.ONE:if(y=1,c=this.#t.getUint8(this.#r),f===Y.SIMPLE_FLOAT){if(c<32)throw new Error(`Invalid simple encoding in extra byte: ${c}`);p=!0}else if(this.#n.requirePreferred&&c<24)throw new Error(`Unexpectedly long integer encoding (1) for ${c}`);break;case Q.TWO:if(y=2,f===Y.SIMPLE_FLOAT)c=Pn(this.#e,this.#r);else if(c=this.#t.getUint16(this.#r,!1),this.#n.requirePreferred&&c<=255)throw new Error(`Unexpectedly long integer encoding (2) for ${c}`);break;case Q.FOUR:if(y=4,f===Y.SIMPLE_FLOAT)c=this.#t.getFloat32(this.#r,!1);else if(c=this.#t.getUint32(this.#r,!1),this.#n.requirePreferred&&c<=65535)throw new Error(`Unexpectedly long integer encoding (4) for ${c}`);break;case Q.EIGHT:{if(y=8,f===Y.SIMPLE_FLOAT)c=this.#t.getFloat64(this.#r,!1);else if(c=this.#t.getBigUint64(this.#r,!1),c<=Number.MAX_SAFE_INTEGER&&(c=Number(c)),this.#n.requirePreferred&&c<=4294967295)throw new Error(`Unexpectedly long integer encoding (8) for ${c}`);break}case 28:case 29:case 30:throw new Error(`Additional info not implemented: ${u}`);case Q.INDEFINITE:switch(f){case Y.POS_INT:case Y.NEG_INT:case Y.TAG:throw new Error(`Invalid indefinite encoding for MT ${f}`);case Y.SIMPLE_FLOAT:yield[f,u,Ie.BREAK,r,0];return}c=1/0;break;default:p=!0}switch(this.#r+=y,f){case Y.POS_INT:yield[f,u,c,r,y];break;case Y.NEG_INT:yield[f,u,typeof c=="bigint"?-1n-c:-1-Number(c),r,y];break;case Y.BYTE_STRING:c===1/0?yield*this.#u(f,e,r):yield[f,u,this.#o(c),r,c];break;case Y.UTF8_STRING:c===1/0?yield*this.#u(f,e,r):yield[f,u,Eo.decode(this.#o(c)),r,c];break;case Y.ARRAY:if(c===1/0)yield*this.#u(f,e,r,!1);else{const b=Number(c);yield[f,u,b,r,y];for(let d=0;d<b;d++)yield*this.#i(e+1)}break;case Y.MAP:if(c===1/0)yield*this.#u(f,e,r,!1);else{const b=Number(c);yield[f,u,b,r,y];for(let d=0;d<b;d++)yield*this.#i(e),yield*this.#i(e)}break;case Y.TAG:yield[f,u,c,r,y],yield*this.#i(e);break;case Y.SIMPLE_FLOAT:{const b=c;p&&(c=Ge.create(Number(c))),yield[f,u,c,r,b];break}}}#o(e){const r=vr(this.#e,this.#r,this.#r+=e);if(r.length!==e)throw new Error(`Unexpected end of stream reading ${e} bytes, got ${r.length}`);return r}*#u(e,r,o,f=!0){for(yield[e,Q.INDEFINITE,1/0,o,1/0];;){const u=this.#i(r),c=u.next(),[p,y,b]=c.value;if(b===Ie.BREAK){yield c.value,u.next();return}if(f){if(p!==e)throw new Error(`Unmatched major type. Expected ${e}, got ${p}.`);if(y===Q.INDEFINITE)throw new Error("New stream started in typed stream")}yield c.value,yield*u}}};const mo=new Map([[Q.ZERO,1],[Q.ONE,2],[Q.TWO,3],[Q.FOUR,5],[Q.EIGHT,9]]),bo=new Uint8Array(0);function _o(t,e){return!e.boxed&&!e.preferMap&&t.every(([r])=>typeof r=="string")?Object.fromEntries(t):new Map(t)}let Fe=class li{static defaultDecodeOptions={...Kt.defaultOptions,ParentType:li,boxed:!1,cde:!1,dcbor:!1,diagnosticSizes:Ht.PREFERRED,collapseBigInts:!1,convertUnsafeIntsToFloat:!1,createObject:_o,keepNanPayloads:!1,pretty:!1,preferBigInt:!1,preferMap:!1,rejectLargeNegatives:!1,rejectBigInts:!1,rejectDuplicateKeys:!1,rejectFloats:!1,rejectInts:!1,rejectLongLoundNaN:!1,rejectLongFloats:!1,rejectNegativeZero:!1,rejectSimple:!1,rejectStreaming:!1,rejectStringsNotNormalizedAs:null,rejectSubnormals:!1,rejectUndefined:!1,rejectUnsafeFloatInts:!1,saveOriginal:!1,sortKeys:null,tags:null,ignoreGlobalTags:!1};static cdeDecodeOptions={cde:!0,rejectStreaming:!0,requirePreferred:!0,sortKeys:In};static dcborDecodeOptions={...this.cdeDecodeOptions,dcbor:!0,convertUnsafeIntsToFloat:!0,rejectDuplicateKeys:!0,rejectLargeNegatives:!0,rejectLongLoundNaN:!0,rejectLongFloats:!0,rejectNegativeZero:!0,rejectSimple:!0,rejectUndefined:!0,rejectUnsafeFloatInts:!0,rejectStringsNotNormalizedAs:"NFC"};parent;mt;ai;left;offset;count=0;children=[];depth=0;#e;#t=null;constructor(e,r,o,f){if([this.mt,this.ai,,this.offset]=e,this.left=r,this.parent=o,this.#e=f,o&&(this.depth=o.depth+1),this.mt===Y.MAP&&(this.#e.sortKeys||this.#e.rejectDuplicateKeys)&&(this.#t=[]),this.#e.rejectStreaming&&this.ai===Q.INDEFINITE)throw new Error("Streaming not supported")}get isStreaming(){return this.left===1/0}get done(){return this.left===0}static create(e,r,o,f){const[u,c,p,y]=e;switch(u){case Y.POS_INT:case Y.NEG_INT:{if(o.rejectInts)throw new Error(`Unexpected integer: ${p}`);if(o.rejectLargeNegatives&&p<-0x8000000000000000n)throw new Error(`Invalid 65bit negative number: ${p}`);let b=p;return o.preferBigInt?b=BigInt(b):o.convertUnsafeIntsToFloat&&b>=kt.MIN&&b<=kt.MAX&&(b=Number(p)),o.boxed?xt(b,f.toHere(y)):b}case Y.SIMPLE_FLOAT:if(c>Q.ONE){if(typeof p=="symbol")return p;if(o.rejectFloats)throw new Error(`Decoding unwanted floating point number: ${p}`);if(o.rejectNegativeZero&&Object.is(p,-0))throw new Error("Decoding negative zero");if(isNaN(p)){const b=f.toHere(y),d=new Gi(b);if(o.rejectLongLoundNaN){if(d.payload||b.length>3)throw new Error(`Invalid NaN encoding: "${Ne(b)}"`)}else if(o.keepNanPayloads&&d.payload){if(o.rejectLongFloats&&!d.isShortestEncoding)throw new Error(`NaN should have been encoded shorter: ${p}`);return d}}if(o.rejectSubnormals&&Hi(f.toHere(y+1)),o.rejectLongFloats){const b=mt(p,{chunkSize:9,reduceUnsafeNumbers:o.rejectUnsafeFloatInts});if(b[0]>>5!==u)throw new Error(`Should have been encoded as int, not float: ${p}`);if(b.length<mo.get(c))throw new Error(`Number should have been encoded shorter: ${p}`)}if(typeof p=="number"&&o.boxed)return xt(p,f.toHere(y))}else{if(o.rejectSimple&&p instanceof Ge)throw new Error(`Invalid simple value: ${p}`);if(o.rejectUndefined&&p===void 0)throw new Error("Unexpected undefined")}return p;case Y.BYTE_STRING:case Y.UTF8_STRING:if(p===1/0)return new o.ParentType(e,1/0,r,o);if(o.rejectStringsNotNormalizedAs&&typeof p=="string"){const b=p.normalize(o.rejectStringsNotNormalizedAs);if(p!==b)throw new Error(`String not normalized as "${o.rejectStringsNotNormalizedAs}", got [${vn(p)}] instead of [${vn(b)}]`)}return o.boxed?xt(p,f.toHere(y)):p;case Y.ARRAY:return new o.ParentType(e,p,r,o);case Y.MAP:return new o.ParentType(e,p*2,r,o);case Y.TAG:{const b=new o.ParentType(e,1,r,o);return b.children=new Z(p),b}}throw new TypeError(`Invalid major type: ${u}`)}static decodeToEncodeOpts(e){return{...Gn,avoidInts:e.rejectInts,float64:!e.rejectLongFloats,flushToZero:e.rejectSubnormals,largeNegativeAsBigInt:e.rejectLargeNegatives,sortKeys:e.sortKeys}}push(e,r,o){if(this.children.push(e),this.#t){const f=Pt(e)||r.toHere(o);this.#t.push(f)}return--this.left}replaceLast(e,r,o){let f,u=-1/0;if(this.children instanceof Z?(u=0,f=this.children.contents,this.children.contents=e):(u=this.children.length-1,f=this.children[u],this.children[u]=e),this.#t){const c=Pt(e)||o.toHere(r.offset);this.#t[u]=c}return f}convert(e){let r;switch(this.mt){case Y.ARRAY:r=this.children;break;case Y.MAP:{const o=this.#r();if(this.#e.sortKeys){let f;for(const u of o){if(f&&this.#e.sortKeys(f,u)>=0)throw new Error(`Duplicate or out of order key: "0x${u[2]}"`);f=u}}else if(this.#e.rejectDuplicateKeys){const f=new Set;for(const[u,c,p]of o){const y=Ne(p);if(f.has(y))throw new Error(`Duplicate key: "0x${y}"`);f.add(y)}}r=this.#e.createObject(o,this.#e);break}case Y.BYTE_STRING:return ki(this.children);case Y.UTF8_STRING:{const o=this.children.join("");r=this.#e.boxed?xt(o,e.toHere(this.offset)):o;break}case Y.TAG:r=this.children.decode(this.#e);break;default:throw new TypeError(`Invalid mt on convert: ${this.mt}`)}return this.#e.saveOriginal&&r&&typeof r=="object"&&Tt(r,e.toHere(this.offset)),r}#r(){const e=this.children,r=e.length;if(r%2)throw new Error("Missing map value");const o=new Array(r/2);if(this.#t)for(let f=0;f<r;f+=2)o[f>>1]=[e[f],e[f+1],this.#t[f]];else for(let f=0;f<r;f+=2)o[f>>1]=[e[f],e[f+1],bo];return o}};const Fr=" ",To=new TextEncoder;class Yn extends Fe{close="";quote='"';get isEmptyStream(){return(this.mt===Y.UTF8_STRING||this.mt===Y.BYTE_STRING)&&this.count===0}}function tt(t,e,r,o){let f="";if(e===Q.INDEFINITE)f+="_";else{if(o.diagnosticSizes===Ht.NEVER)return"";{let u=o.diagnosticSizes===Ht.ALWAYS;if(!u){let c=Q.ZERO;if(Object.is(r,-0))c=Q.TWO;else if(t===Y.POS_INT||t===Y.NEG_INT){const p=r<0,y=typeof r=="bigint"?1n:1,b=p?-r-y:r;b<=23?c=Number(b):b<=255?c=Q.ONE:b<=65535?c=Q.TWO:b<=4294967295?c=Q.FOUR:c=Q.EIGHT}else isFinite(r)?Math.fround(r)===r?Cn(r)==null?c=Q.FOUR:c=Q.TWO:c=Q.EIGHT:c=Q.TWO;u=c!==e}u&&(f+="_",e<Q.ONE?f+="i":f+=String(e-24))}}return f}function xo(t,e){const r={...Fe.defaultDecodeOptions,...e,ParentType:Yn},o=new Kt(t,r);let f,u,c="";for(const p of o){const[y,b,d]=p;switch(f&&(f.count>0&&d!==Ie.BREAK&&(f.mt===Y.MAP&&f.count%2?c+=": ":(c+=",",r.pretty||(c+=" "))),r.pretty&&(f.mt!==Y.MAP||f.count%2===0)&&(c+=`
2
2
  ${Fr.repeat(f.depth+1)}`)),u=Fe.create(p,f,r,o),y){case Y.POS_INT:case Y.NEG_INT:c+=String(d),c+=tt(y,b,d,r);break;case Y.SIMPLE_FLOAT:if(d!==Ie.BREAK)if(typeof d=="number"){const I=Object.is(d,-0)?"-0.0":String(d);c+=I,isFinite(d)&&!/[.e]/.test(I)&&(c+=".0"),c+=tt(y,b,d,r)}else d instanceof Ge?(c+="simple(",c+=String(d.value),c+=tt(Y.POS_INT,b,d.value,r),c+=")"):c+=String(d);break;case Y.BYTE_STRING:d===1/0?(c+="(_ ",u.close=")",u.quote="'"):(c+="h'",c+=Ne(d),c+="'",c+=tt(Y.POS_INT,b,d.length,r));break;case Y.UTF8_STRING:d===1/0?(c+="(_ ",u.close=")"):(c+=JSON.stringify(d),c+=tt(Y.POS_INT,b,To.encode(d).length,r));break;case Y.ARRAY:{c+="[";const I=tt(Y.POS_INT,b,d,r);c+=I,I&&(c+=" "),r.pretty&&d?u.close=`
3
3
  ${Fr.repeat(u.depth)}]`:u.close="]";break}case Y.MAP:{c+="{";const I=tt(Y.POS_INT,b,d,r);c+=I,I&&(c+=" "),r.pretty&&d?u.close=`
4
4
  ${Fr.repeat(u.depth)}}`:u.close="}";break}case Y.TAG:c+=String(d),c+=tt(Y.POS_INT,b,d,r),c+="(",u.close=")";break}if(u===Ie.BREAK)if(f?.isStreaming)f.left=0;else throw new Error("Unexpected BREAK");else f&&(f.count++,f.left--);for(u instanceof Yn&&(f=u);f?.done;){if(f.isEmptyStream)c=c.slice(0,-3),c+=`${f.quote}${f.quote}_`;else{if(f.mt===Y.MAP&&f.count%2!==0)throw new Error(`Odd streaming map size: ${f.count}`);c+=f.close}f=f.parent}}return c}const So=new TextDecoder;class Ur extends Fe{depth=0;leaf=!1;value;length;[Ie.ENCODED];constructor(e,r,o,f){super(e,r,o,f),this.parent?this.depth=this.parent.depth+1:this.depth=f.initialDepth,[,,this.value,,this.length]=e}numBytes(){switch(this.ai){case Q.ONE:return 1;case Q.TWO:return 2;case Q.FOUR:return 4;case Q.EIGHT:return 8}return 0}}function zn(t){return t instanceof Ur}function Yt(t,e){return t===1/0?"Indefinite":e?`${t} ${e}${t!==1&&t!==1n?"s":""}`:String(t)}function Bt(t){return"".padStart(t," ")}function Vn(t,e,r){let o="";o+=Bt(t.depth*2);const f=Pt(t);o+=Ne(f.subarray(0,1));const u=t.numBytes();u&&(o+=" ",o+=Ne(f.subarray(1,u+1))),o=o.padEnd(e.minCol+1," "),o+="-- ",r!==void 0&&(o+=Bt(t.depth*2),r!==""&&(o+=`[${r}] `));let c=!1;const[p]=t.children;switch(t.mt){case Y.POS_INT:o+=`Unsigned: ${p}`,typeof p=="bigint"&&(o+="n");break;case Y.NEG_INT:o+=`Negative: ${p}`,typeof p=="bigint"&&(o+="n");break;case Y.BYTE_STRING:o+=`Bytes (Length: ${Yt(t.length)})`;break;case Y.UTF8_STRING:o+=`UTF8 (Length: ${Yt(t.length)})`,t.length!==1/0&&(o+=`: ${JSON.stringify(p)}`);break;case Y.ARRAY:o+=`Array (Length: ${Yt(t.value,"item")})`;break;case Y.MAP:o+=`Map (Length: ${Yt(t.value,"pair")})`;break;case Y.TAG:{o+=`Tag #${t.value}`;const y=t.children,[b]=y.contents.children,d=new Z(y.tag,b);Tt(d,f);const I=d.comment(e,t.depth);I&&(o+=": ",o+=I),c||=d.noChildren;break}case Y.SIMPLE_FLOAT:p===Ie.BREAK?o+="BREAK":t.ai>Q.ONE?Object.is(p,-0)?o+="Float: -0":o+=`Float: ${p}`:(o+="Simple: ",p instanceof Ge?o+=p.value:o+=p);break}if(!c)if(t.leaf){if(o+=`
@@ -10,4 +10,4 @@ ${Fr.repeat(u.depth)}}`:u.close="}";break}case Y.TAG:c+=String(d),c+=tt(Y.POS_IN
10
10
  `;let y=0;for(const b of t.children){if(zn(b)){let d=String(y);t.mt===Y.MAP?d=y%2?`val ${(y-1)/2}`:`key ${y/2}`:t.mt===Y.TAG&&(d=""),o+=Vn(b,e,d)}y++}}return o}const vo={...Fe.defaultDecodeOptions,initialDepth:0,noPrefixHex:!1,minCol:0};function Xn(t,e){const r={...vo,...e,ParentType:Ur,saveOriginal:!0},o=new Kt(t,r);let f,u;for(const p of o){if(u=Fe.create(p,f,r,o),p[2]===Ie.BREAK)if(f?.isStreaming)f.left=1;else throw new Error("Unexpected BREAK");if(!zn(u)){const d=new Ur(p,0,f,r);d.leaf=!0,d.children.push(u),Tt(d,o.toHere(p[3])),u=d}let y=(u.depth+1)*2;const b=u.numBytes();for(b&&(y+=1,y+=b*2),r.minCol=Math.max(r.minCol,y),f&&f.push(u,o,p[3]),f=u;f?.done;)u=f,u.leaf||Tt(u,o.toHere(u.offset)),{parent:f}=f}e&&(e.minCol=r.minCol);let c=r.noPrefixHex?"":`0x${Ne(o.toHere(0))}
11
11
  `;return c+=Vn(u,r),c}const Jn=!$i();function zt(t){if(typeof t=="object"&&t){if(t.constructor!==Number)throw new Error(`Expected number: ${t}`)}else if(typeof t!="number")throw new Error(`Expected number: ${t}`)}function rt(t){if(typeof t=="object"&&t){if(t.constructor!==String)throw new Error(`Expected string: ${t}`)}else if(typeof t!="string")throw new Error(`Expected string: ${t}`)}function Ze(t){if(!(t instanceof Uint8Array))throw new Error(`Expected Uint8Array: ${t}`)}function Zn(t){if(!Array.isArray(t))throw new Error(`Expected Array: ${t}`)}we(Map,(t,e,r)=>{const o=[...t.entries()].map(f=>[f[0],f[1],mt(f[0],r)]);if(r.rejectDuplicateKeys){const f=new Set;for(const[u,c,p]of o){const y=Ne(p);if(f.has(y))throw new Error(`Duplicate map key: 0x${y}`);f.add(y)}}r.sortKeys&&o.sort(r.sortKeys),Nr(t,t.size,Y.MAP,e,r);for(const[f,u,c]of o)e.write(c),lt(u,e,r)});function Lr(t){return rt(t.contents),new Date(t.contents)}Lr.comment=t=>{rt(t.contents);const e=new Date(t.contents);return`(String ${t.tag===ie.DATE_FULL?"Full ":""}Date) ${e.toISOString()}`},Z.registerDecoder(ie.DATE_STRING,Lr),Z.registerDecoder(ie.DATE_FULL,Lr);function Qn(t){return zt(t.contents),new Date(t.contents*1e3)}Qn.comment=t=>(zt(t.contents),`(Epoch Date) ${new Date(t.contents*1e3).toISOString()}`),Z.registerDecoder(ie.DATE_EPOCH,Qn);const Mr=1e3*60*60*24;function ei(t){return zt(t.contents),new Date(t.contents*Mr)}ei.comment=t=>(zt(t.contents),`(Epoch Date) ${new Date(t.contents*Mr).toISOString()}`),Z.registerDecoder(ie.DATE_EPOCH_DAYS,ei),we(Date,(t,e,r)=>{switch(r.dateTag){case ie.DATE_EPOCH:return[r.dateTag,t.valueOf()/1e3];case ie.DATE_STRING:return[r.dateTag,t.toISOString().replace(/\.000Z$/,"Z")];case ie.DATE_EPOCH_DAYS:return[r.dateTag,Math.floor(t.valueOf()/Mr)];case ie.DATE_FULL:return[r.dateTag,t.toISOString().split("T")[0]];default:throw new Error(`Unsupported date tag: ${r.dateTag}`)}});function Vt(t,e,r){if(Ze(e.contents),r.rejectBigInts)throw new Error(`Decoding unwanted big integer: ${e}(h'${Ne(e.contents)}')`);if(r.requirePreferred&&e.contents[0]===0)throw new Error(`Decoding overly-large bigint: ${e.tag}(h'${Ne(e.contents)})`);let o=e.contents.reduce((u,c)=>u<<8n|BigInt(c),0n);t&&(o=-1n-o);const f=o>=Number.MIN_SAFE_INTEGER&&o<=Number.MAX_SAFE_INTEGER;if(r.requirePreferred&&f)throw new Error(`Decoding bigint that could have been int: ${o}n`);return r.collapseBigInts&&f&&(o=Number(o)),r.boxed?xt(o,e.contents):o}const ti=Vt.bind(null,!1),ri=Vt.bind(null,!0);ti.comment=(t,e)=>`(Positive BigInt) ${Vt(!1,t,e)}n`,ri.comment=(t,e)=>`(Negative BigInt) ${Vt(!0,t,e)}n`,Z.registerDecoder(ie.POS_BIGINT,ti),Z.registerDecoder(ie.NEG_BIGINT,ri);function Or(t,e){return Ze(t.contents),t}Or.comment=(t,e,r)=>{Ze(t.contents);const o={...e,initialDepth:r+2,noPrefixHex:!0},f=Pt(t);let u=2**((f[0]&31)-24)+1;const c=f[u]&31;let p=Ne(f.subarray(u,++u));c>=24&&(p+=" ",p+=Ne(f.subarray(u,u+2**(c-24)))),o.minCol=Math.max(o.minCol,(r+1)*2+p.length);const y=Xn(t.contents,o);let b=`Embedded CBOR
12
12
  `;return b+=`${"".padStart((r+1)*2," ")}${p}`.padEnd(o.minCol+1," "),b+=`-- Bytes (Length: ${t.contents.length})
13
- `,b+=y,b},Or.noChildren=!0,Z.registerDecoder(ie.CBOR,Or),Z.registerDecoder(ie.URI,t=>(rt(t.contents),new URL(t.contents)),"URI"),we(URL,t=>[ie.URI,t.toString()]),Z.registerDecoder(ie.BASE64URL,t=>(rt(t.contents),Ci(t.contents)),"Base64url-encoded"),Z.registerDecoder(ie.BASE64,t=>(rt(t.contents),Rr(t.contents)),"Base64-encoded"),Z.registerDecoder(35,t=>(rt(t.contents),new RegExp(t.contents)),"RegExp"),Z.registerDecoder(21065,t=>{rt(t.contents);const e=`^(?:${t.contents})$`;return new RegExp(e,"u")},"I-RegExp"),Z.registerDecoder(ie.REGEXP,t=>{if(Zn(t.contents),t.contents.length<1||t.contents.length>2)throw new Error(`Invalid RegExp Array: ${t.contents}`);return new RegExp(t.contents[0],t.contents[1])},"RegExp"),we(RegExp,t=>[ie.REGEXP,[t.source,t.flags]]),Z.registerDecoder(64,t=>(Ze(t.contents),t.contents),"uint8 Typed Array");function Be(t,e,r){Ze(t.contents);let o=t.contents.length;if(o%e.BYTES_PER_ELEMENT!==0)throw new Error(`Number of bytes must be divisible by ${e.BYTES_PER_ELEMENT}, got: ${o}`);o/=e.BYTES_PER_ELEMENT;const f=new e(o),u=new DataView(t.contents.buffer,t.contents.byteOffset,t.contents.byteLength),c=u[`get${e.name.replace(/Array/,"")}`].bind(u);for(let p=0;p<o;p++)f[p]=c(p*e.BYTES_PER_ELEMENT,r);return f}function nt(t,e,r,o,f){const u=f.forceEndian??Jn;if(It(u?e:r,t,f),Me(o.byteLength,t,Y.BYTE_STRING),Jn===u)t.write(new Uint8Array(o.buffer,o.byteOffset,o.byteLength));else{const c=`write${o.constructor.name.replace(/Array/,"")}`,p=t[c].bind(t);for(const y of o)p(y,u)}}Z.registerDecoder(65,t=>Be(t,Uint16Array,!1),"uint16, big endian, Typed Array"),Z.registerDecoder(66,t=>Be(t,Uint32Array,!1),"uint32, big endian, Typed Array"),Z.registerDecoder(67,t=>Be(t,BigUint64Array,!1),"uint64, big endian, Typed Array"),Z.registerDecoder(68,t=>(Ze(t.contents),new Uint8ClampedArray(t.contents)),"uint8 Typed Array, clamped arithmetic"),we(Uint8ClampedArray,t=>[68,new Uint8Array(t.buffer,t.byteOffset,t.byteLength)]),Z.registerDecoder(69,t=>Be(t,Uint16Array,!0),"uint16, little endian, Typed Array"),we(Uint16Array,(t,e,r)=>nt(e,69,65,t,r)),Z.registerDecoder(70,t=>Be(t,Uint32Array,!0),"uint32, little endian, Typed Array"),we(Uint32Array,(t,e,r)=>nt(e,70,66,t,r)),Z.registerDecoder(71,t=>Be(t,BigUint64Array,!0),"uint64, little endian, Typed Array"),we(BigUint64Array,(t,e,r)=>nt(e,71,67,t,r)),Z.registerDecoder(72,t=>(Ze(t.contents),new Int8Array(t.contents)),"sint8 Typed Array"),we(Int8Array,t=>[72,new Uint8Array(t.buffer,t.byteOffset,t.byteLength)]),Z.registerDecoder(73,t=>Be(t,Int16Array,!1),"sint16, big endian, Typed Array"),Z.registerDecoder(74,t=>Be(t,Int32Array,!1),"sint32, big endian, Typed Array"),Z.registerDecoder(75,t=>Be(t,BigInt64Array,!1),"sint64, big endian, Typed Array"),Z.registerDecoder(77,t=>Be(t,Int16Array,!0),"sint16, little endian, Typed Array"),we(Int16Array,(t,e,r)=>nt(e,77,73,t,r)),Z.registerDecoder(78,t=>Be(t,Int32Array,!0),"sint32, little endian, Typed Array"),we(Int32Array,(t,e,r)=>nt(e,78,74,t,r)),Z.registerDecoder(79,t=>Be(t,BigInt64Array,!0),"sint64, little endian, Typed Array"),we(BigInt64Array,(t,e,r)=>nt(e,79,75,t,r)),Z.registerDecoder(81,t=>Be(t,Float32Array,!1),"IEEE 754 binary32, big endian, Typed Array"),Z.registerDecoder(82,t=>Be(t,Float64Array,!1),"IEEE 754 binary64, big endian, Typed Array"),Z.registerDecoder(85,t=>Be(t,Float32Array,!0),"IEEE 754 binary32, little endian, Typed Array"),we(Float32Array,(t,e,r)=>nt(e,85,81,t,r)),Z.registerDecoder(86,t=>Be(t,Float64Array,!0),"IEEE 754 binary64, big endian, Typed Array"),we(Float64Array,(t,e,r)=>nt(e,86,82,t,r)),Z.registerDecoder(ie.SET,(t,e)=>{if(Zn(t.contents),e.sortKeys){const r=Fe.decodeToEncodeOpts(e);let o=null;for(const f of t.contents){const u=[f,void 0,mt(f,r)];if(o&&e.sortKeys(o,u)>=0)throw new Error(`Set items out of order in tag #${ie.SET}`);o=u}}return new Set(t.contents)},"Set"),we(Set,(t,e,r)=>{let o=[...t];if(r.sortKeys){const f=o.map(u=>[u,void 0,mt(u,r)]);f.sort(r.sortKeys),o=f.map(([u])=>u)}return[ie.SET,o]}),Z.registerDecoder(ie.JSON,t=>(rt(t.contents),JSON.parse(t.contents)),"JSON-encoded");function ni(t){return Ze(t.contents),new Gt().decode(t.contents)}ni.comment=t=>{Ze(t.contents);const e=new Gt;return`(WTF8 string): ${JSON.stringify(e.decode(t.contents))}`},Z.registerDecoder(ie.WTF8,ni),Z.registerDecoder(ie.SELF_DESCRIBED,t=>t.contents,"Self-Described"),Z.registerDecoder(ie.INVALID_16,()=>{throw new Error(`Tag always invalid: ${ie.INVALID_16}`)},"Invalid"),Z.registerDecoder(ie.INVALID_32,()=>{throw new Error(`Tag always invalid: ${ie.INVALID_32}`)},"Invalid"),Z.registerDecoder(ie.INVALID_64,()=>{throw new Error(`Tag always invalid: ${ie.INVALID_64}`)},"Invalid");function Dr(t){throw new Error(`Encoding ${t.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}we(ArrayBuffer,Dr),we(DataView,Dr),typeof SharedArrayBuffer<"u"&&we(SharedArrayBuffer,Dr);function Xt(t){return[NaN,t.valueOf()]}we(Boolean,Xt),we(Number,Xt),we(String,Xt),we(BigInt,Xt);function Ro(t){const e={...Fe.defaultDecodeOptions};if(t.dcbor?Object.assign(e,Fe.dcborDecodeOptions):t.cde&&Object.assign(e,Fe.cdeDecodeOptions),Object.assign(e,t),Object.hasOwn(e,"rejectLongNumbers"))throw new TypeError("rejectLongNumbers has changed to requirePreferred");return e.boxed&&(e.saveOriginal=!0),e}let Io=class{parent=void 0;ret=void 0;step(e,r,o){if(this.ret=Fe.create(e,this.parent,r,o),e[2]===Ie.BREAK)if(this.parent?.isStreaming)this.parent.left=0;else throw new Error("Unexpected BREAK");else this.parent&&this.parent.push(this.ret,o,e[3]);for(this.ret instanceof Fe&&(this.parent=this.ret);this.parent?.done;){this.ret=this.parent.convert(o);const f=this.parent.parent;f?.replaceLast(this.ret,this.parent,o),this.parent=f}}};function Bo(t,e={}){const r=Ro(e),o=new Kt(t,r),f=new Io;for(const u of o)f.step(u,r,o);return f.ret}const{cdeDecodeOptions:Go,dcborDecodeOptions:Wo,defaultDecodeOptions:Ho}=Fe;class Ao{constructor(e={}){this.options={id:bt(),codec:"cbor",timeout:10*1e3,chunkSize:16*1024,topicMake:(r,o,f)=>`${r}/${o}/${f??"any"}`,topicMatch:r=>{const o=r.match(/^(.+)\/([^/]+)\/([^/]+)$/);return o?{name:o[1],operation:o[2],peerId:o[3]==="any"?void 0:o[3]}:null},...e}}}class ii{static uint8ArrayToBase64(e){return btoa(String.fromCharCode(...e))}static base64ToUint8Array(e){const r=atob(e),o=new Uint8Array(r.length);for(let f=0;f<r.length;f++)o[f]=r.charCodeAt(f);return o}static stringify(e){return JSON.stringify(e,(r,o)=>o instanceof Uint8Array?{__Uint8Array:this.uint8ArrayToBase64(o)}:o)}static parse(e){return JSON.parse(e,(r,o)=>typeof o?.__Uint8Array=="string"?this.base64ToUint8Array(o.__Uint8Array):o)}}class No{constructor(e){this.type=e,this.types=new Rn,this.tags=new Map;const r=64e3;this.types.registerEncoder(tr,o=>[r,new Uint8Array(o.buffer,o.byteOffset,o.byteLength)]),this.tags.set(r,o=>tr.from(o.contents))}encode(e){let r;if(this.type==="cbor")try{r=mt(e,{types:this.types})}catch{throw new Error("failed to encode CBOR format")}else if(this.type==="json")try{r=ii.stringify(e)}catch{throw new Error("failed to encode JSON format")}else throw new Error("invalid format");return r}decode(e){let r;if(this.type==="cbor"&&typeof e=="object"&&e instanceof Uint8Array)try{r=Bo(e,{tags:this.tags})}catch{throw new Error("failed to decode CBOR format")}else if(this.type==="json"&&typeof e=="string")try{r=ii.parse(e)}catch{throw new Error("failed to decode JSON format")}else throw new Error("invalid format or wrong data type");return r}}class Fo extends Ao{constructor(e={}){super(e),this.codec=new No(this.options.codec)}}class At{constructor(e,r,o,f){this.type=e,this.id=r,this.sender=o,this.receiver=f}}class oi extends At{constructor(e,r,o,f,u){super("event-emission",e,f,u),this.event=r,this.params=o}}class si extends At{constructor(e,r,o,f,u){super("service-call-request",e,f,u),this.service=r,this.params=o}}class ai extends At{constructor(e,r,o,f,u){super("service-call-response",e,f,u),this.result=r,this.error=o}}class ui extends At{constructor(e,r,o,f,u){super("resource-transfer-request",e,f,u),this.resource=r,this.params=o}}class fi extends At{constructor(e,r,o,f,u,c,p,y,b){super("resource-transfer-response",e,y,b),this.resource=r,this.params=o,this.chunk=f,this.meta=u,this.error=c,this.final=p}}class Uo{makeEventEmission(e,r,o,f,u){return new oi(e,r,o,f,u)}makeServiceCallRequest(e,r,o,f,u){return new si(e,r,o,f,u)}makeServiceCallResponse(e,r,o,f,u){return new ai(e,r,o,f,u)}makeResourceTransferRequest(e,r,o,f,u){return new ui(e,r,o,f,u)}makeResourceTransferResponse(e,r,o,f,u,c,p,y,b){return new fi(e,r,o,f,u,c,p,y,b)}parse(e){if(typeof e!="object"||e===null)throw new Error("invalid argument: not an object");if(!("type"in e)||typeof e.type!="string")throw new Error('invalid object: missing or invalid "type" field');if(!("id"in e)||typeof e.id!="string")throw new Error('invalid object: missing or invalid "id" field');if("sender"in e&&e.sender!==void 0&&typeof e.sender!="string")throw new Error('invalid object: invalid "sender" field');if("receiver"in e&&e.receiver!==void 0&&typeof e.receiver!="string")throw new Error('invalid object: invalid "receiver" field');const r=(f,u)=>Object.keys(f).some(c=>!u.includes(c)),o=f=>f.params===void 0||typeof f.params=="object"&&Array.isArray(f.params);if(e.type==="event-emission"){if(typeof e.event!="string")throw new Error('invalid EventEmission object: "event" field must be a string');if(r(e,["type","id","event","params","sender","receiver"]))throw new Error("invalid EventEmission object: contains unknown fields");if(!o(e))throw new Error('invalid EventEmission object: "params" field must be an array');return this.makeEventEmission(e.id,e.event,e.params,e.sender,e.receiver)}else if(e.type==="service-call-request"){if(typeof e.service!="string")throw new Error('invalid ServiceCallRequest object: "service" field must be a string');if(r(e,["type","id","service","params","sender","receiver"]))throw new Error("invalid ServiceCallRequest object: contains unknown fields");if(!o(e))throw new Error('invalid ServiceCallRequest object: "params" field must be an array');return this.makeServiceCallRequest(e.id,e.service,e.params,e.sender,e.receiver)}else if(e.type==="service-call-response"){if(r(e,["type","id","result","error","sender","receiver"]))throw new Error("invalid ServiceCallResponse object: contains unknown fields");return this.makeServiceCallResponse(e.id,e.result,e.error,e.sender,e.receiver)}else if(e.type==="resource-transfer-request"){if(typeof e.resource!="string")throw new Error('invalid ResourceTransferRequest object: "resource" field must be a string');if(r(e,["type","id","resource","params","sender","receiver"]))throw new Error("invalid ResourceTransferRequest object: contains unknown fields");if(!o(e))throw new Error('invalid ResourceTransferRequest object: "params" field must be an array');return this.makeResourceTransferRequest(e.id,e.resource,e.params,e.sender,e.receiver)}else if(e.type==="resource-transfer-response"){if(e.resource!==void 0&&typeof e.resource!="string")throw new Error('invalid ResourceTransferResponse object: "resource" field must be a string');if(e.chunk!==void 0&&typeof e.chunk!="object")throw new Error('invalid ResourceTransferResponse object: "chunk" field must be an object');if(e.meta!==void 0&&(typeof e.meta!="object"||e.meta===null||Array.isArray(e.meta)))throw new Error('invalid ResourceTransferResponse object: "meta" field must be an object');if(e.error!==void 0&&typeof e.error!="string")throw new Error('invalid ResourceTransferResponse object: "error" field must be a string');if(e.final!==void 0&&typeof e.final!="boolean")throw new Error('invalid ResourceTransferResponse object: "final" field must be a boolean');if(!o(e))throw new Error('invalid ResourceTransferResponse object: "params" field must be an array');if(r(e,["type","id","resource","params","chunk","meta","error","final","sender","receiver"]))throw new Error("invalid ResourceTransferResponse object: contains unknown fields");return this.makeResourceTransferResponse(e.id,e.resource,e.params,e.chunk,e.meta,e.error,e.final,e.sender,e.receiver)}else throw new Error("invalid object: not of any known type")}}class Lo extends Fo{constructor(){super(...arguments),this.msg=new Uo}}class Mo extends Lo{constructor(e,r={}){super(r),e===null&&(e=new Proxy({},{get(o,f,u){return f==="isFakeProxy"?!0:(...c)=>{}}})),this.mqtt=e,this._messageHandler=(o,f,u)=>{this._onMessage(o,f,u)},this.mqtt.on("message",this._messageHandler)}destroy(){this.mqtt.off("message",this._messageHandler)}async _subscribeTopic(e,r={}){return new Promise((o,f)=>{this.mqtt.subscribe(e,{qos:2,...r},(u,c)=>{u?f(u):o()})})}async _unsubscribeTopic(e){return new Promise((r,o)=>{this.mqtt.unsubscribe(e,(f,u)=>{f?o(f):r()})})}_onMessage(e,r,o){let f;try{let u=r;this.options.codec==="json"&&(u=r.toString());const c=this.codec.decode(u);f=this.msg.parse(c)}catch(u){const c=u instanceof Error?new Error(`failed to parse message: ${u.message}`):new Error("failed to parse message");this.mqtt.emit("error",c);return}this._dispatchMessage(e,f)}_dispatchMessage(e,r){}}class Oo extends Mo{constructor(){super(...arguments),this.subscriptions=new Map}async subscribe(e,...r){let o,f,u={},c;if(typeof e=="object"&&e!==null?(o=e.event,f=e.callback,u=e.options??{},c=e.share):(o=e,f=r[0]),this.subscriptions.has(o))throw new Error(`subscribe: event "${o}" already subscribed`);const p=c?`$share/${c}/${o}`:o,y=this.options.topicMake(p,"event-emission"),b=this.options.topicMake(p,"event-emission",this.options.id);await Promise.all([this._subscribeTopic(y,{qos:0,...u}),this._subscribeTopic(b,{qos:0,...u})]).catch(B=>{throw this._unsubscribeTopic(y).catch(()=>{}),this._unsubscribeTopic(b).catch(()=>{}),B}),this.subscriptions.set(o,f);const d=this;return{async unsubscribe(){if(!d.subscriptions.has(o))throw new Error(`unsubscribe: event "${o}" not subscribed`);return d.subscriptions.delete(o),Promise.all([d._unsubscribeTopic(y),d._unsubscribeTopic(b)]).then(()=>{})}}}emit(e,...r){let o,f,u,c={},p;typeof e=="object"&&e!==null?(o=e.event,f=e.params,u=e.receiver,c=e.options??{},p=e.dry):(o=e,f=r);const y=bt(),b=this.msg.makeEventEmission(y,o,f,this.options.id,u),d=this.codec.encode(b),I=this.options.topicMake(o,"event-emission",u);if(p)return{topic:I,payload:ft.from(d),options:{qos:0,...c}};this.mqtt.publish(I,ft.from(d),{qos:0,...c})}_dispatchMessage(e,r){super._dispatchMessage(e,r);const o=this.options.topicMatch(e);if(o!==null&&o.operation==="event-emission"&&r instanceof oi){const f=r.event,u=this.subscriptions.get(f),c=r.params??[],p={sender:r.sender??""};r.receiver&&(p.receiver=r.receiver),Promise.resolve().then(()=>u?.(...c,p)).catch(y=>{this.mqtt.emit("error",y)})}}}class Do extends Oo{constructor(){super(...arguments),this.registrations=new Map,this.responseCallback=new Map,this.responseSubscriptions=new Map}async register(e,...r){let o,f,u={},c;if(typeof e=="object"&&e!==null?(o=e.service,f=e.callback,u=e.options??{},c=e.share):(o=e,f=r[0]),this.registrations.has(o))throw new Error(`register: service "${o}" already registered`);const p=c?`$share/${c}/${o}`:o,y=this.options.topicMake(p,"service-call-request"),b=this.options.topicMake(p,"service-call-request",this.options.id);await Promise.all([this._subscribeTopic(y,{qos:2,...u}),this._subscribeTopic(b,{qos:2,...u})]).catch(B=>{throw this._unsubscribeTopic(y).catch(()=>{}),this._unsubscribeTopic(b).catch(()=>{}),B}),this.registrations.set(o,f);const d=this;return{async unregister(){if(!d.registrations.has(o))throw new Error(`unregister: service "${o}" not registered`);return d.registrations.delete(o),Promise.all([d._unsubscribeTopic(y),d._unsubscribeTopic(b)]).then(()=>{})}}}call(e,...r){let o,f,u,c={};typeof e=="object"&&e!==null?(o=e.service,f=e.params,u=e.receiver,c=e.options??{}):(o=e,f=r);const p=bt();this._responseSubscribe(o,{qos:c.qos??2});const y=new Promise((B,q)=>{let P=setTimeout(()=>{this.responseCallback.delete(p),this._responseUnsubscribe(o),P=null,q(new Error("communication timeout"))},this.options.timeout);this.responseCallback.set(p,{service:o,callback:(W,j)=>{P!==null&&(clearTimeout(P),P=null),W?q(W):B(j)}})}),b=this.msg.makeServiceCallRequest(p,o,f,this.options.id,u),d=this.codec.encode(b),I=this.options.topicMake(o,"service-call-request",u);return this.mqtt.publish(I,ft.from(d),{qos:2,...c},B=>{if(B){const q=this.responseCallback.get(p);q!==void 0&&(this.responseCallback.delete(p),this._responseUnsubscribe(o),q.callback(B,void 0))}}),y}_responseSubscribe(e,r={qos:2}){const o=this.options.topicMake(e,"service-call-response",this.options.id);this.responseSubscriptions.has(o)||(this.responseSubscriptions.set(o,0),this.mqtt.subscribe(o,r,u=>{if(u){const c=this.responseSubscriptions.get(o)??0;c>1?this.responseSubscriptions.set(o,c-1):this.responseSubscriptions.delete(o),this.mqtt.emit("error",u)}}));const f=this.responseSubscriptions.get(o)??0;this.responseSubscriptions.set(o,f+1)}_responseUnsubscribe(e){const r=this.options.topicMake(e,"service-call-response",this.options.id);if(!this.responseSubscriptions.has(r))return;const o=this.responseSubscriptions.get(r)??0;o>1?this.responseSubscriptions.set(r,o-1):(this.responseSubscriptions.delete(r),this.mqtt.unsubscribe(r,f=>{f&&this.mqtt.emit("error",f)}))}_dispatchMessage(e,r){super._dispatchMessage(e,r);const o=this.options.topicMatch(e);if(o!==null&&o.operation==="service-call-request"&&r instanceof si){const f=r.id,u=r.service,c=this.registrations.get(u);let p;if(c!==void 0){const y=r.params??[],b={sender:r.sender??""};r.receiver&&(b.receiver=r.receiver),p=Promise.resolve().then(()=>c(...y,b))}else p=Promise.reject(new Error(`method not found: ${u}`));p.then(y=>this.msg.makeServiceCallResponse(f,y,void 0,this.options.id,r.sender),y=>{let b;return y==null?b="undefined error":typeof y=="string"?b=y:y instanceof Error?b=y.message:b=String(y),this.msg.makeServiceCallResponse(f,void 0,b,this.options.id,r.sender)}).then(y=>{const b=r.sender;if(b===void 0)throw new Error("invalid request: missing sender");const d=this.codec.encode(y),I=this.options.topicMake(u,"service-call-response",b);this.mqtt.publish(I,ft.from(d),{qos:2})}).catch(y=>{this.mqtt.emit("error",y)})}else if(o!==null&&o.operation==="service-call-response"&&o.peerId===this.options.id&&r instanceof ai){const f=r.id,u=this.responseCallback.get(f);u!==void 0&&(r.error!==void 0?u.callback(new Error(r.error),void 0):u.callback(void 0,r.result),this.responseCallback.delete(f),this._responseUnsubscribe(u.service))}}}class ko extends Do{constructor(){super(...arguments),this.provisionings=new Map,this.callbacks=new Map,this.pushStreams=new Map,this.pushTimers=new Map}async provision(e,...r){let o,f,u={},c;if(typeof e=="object"&&e!==null?(o=e.resource,f=e.callback,u=e.options??{},c=e.share):(o=e,f=r[0]),this.provisionings.has(o))throw new Error(`provision: resource "${o}" already provisioned`);const p=c?`$share/${c}/${o}`:o,y=this.options.topicMake(p,"resource-transfer-request"),b=this.options.topicMake(p,"resource-transfer-request",this.options.id),d=this.options.topicMake(p,"resource-transfer-response"),I=this.options.topicMake(p,"resource-transfer-response",this.options.id);await Promise.all([this._subscribeTopic(y,{qos:2,...u}),this._subscribeTopic(b,{qos:2,...u}),this._subscribeTopic(d,{qos:2,...u}),this._subscribeTopic(I,{qos:2,...u})]).catch(P=>{throw this._unsubscribeTopic(y).catch(()=>{}),this._unsubscribeTopic(b).catch(()=>{}),this._unsubscribeTopic(d).catch(()=>{}),this._unsubscribeTopic(I).catch(()=>{}),P}),this.provisionings.set(o,f);const B=this;return{async unprovision(){if(!B.provisionings.has(o))throw new Error(`unprovision: resource "${o}" not provisioned`);return B.provisionings.delete(o),Promise.all([B._unsubscribeTopic(y),B._unsubscribeTopic(b),B._unsubscribeTopic(d),B._unsubscribeTopic(I)]).then(()=>{})}}}push(e,...r){let o,f,u,c,p,y={};typeof e=="object"&&e!==null?(o=e.resource,f=e.data,u=e.params,c=e.meta,p=e.receiver,y=e.options??{}):(o=e,f=r[0],u=r.slice(1));const b=bt(),d=this.options.topicMake(o,"resource-transfer-response",p);let I=!0;const B=(q,P,W)=>{const j=I?c:void 0;I=!1;const x=this.msg.makeResourceTransferResponse(b,o,u,q,j,P,W,this.options.id,p),R=this.codec.encode(x);this.mqtt.publish(d,ft.from(R),{qos:2,...y})};return new Promise((q,P)=>{f instanceof Dt.Readable?Tn(f,this.options.chunkSize,B,()=>q(),W=>P(W)):f instanceof Uint8Array&&(_n(f,this.options.chunkSize,B),q())})}async fetch(e,...r){let o,f,u={},c;typeof e=="object"&&e!==null?(o=e.resource,c=e.params,f=e.receiver,u=e.options??{}):(o=e,c=r);const p=bt(),y=this.options.topicMake(o,"resource-transfer-response",this.options.id);await this._subscribeTopic(y,{qos:2});const b=new Dt.Readable({read(A){}}),d=mn(b);let I;const B=new Promise(A=>{I=A});let q=null;const P=(A=!1)=>{q!==null&&(clearTimeout(q),q=null),this._unsubscribeTopic(y).catch(()=>{}),this.callbacks.delete(p),A&&I?.(void 0)};q=setTimeout(()=>{P(),I?.(void 0),b.destroy(new Error("communication timeout"))},this.options.timeout);let W=!0;this.callbacks.set(p,{resource:o,callback:(A,_,v,U)=>{W&&(W=!1,I?.(v)),A!==void 0?(P(!0),b.destroy(A)):(_!==void 0&&b.push(_),U&&(P(),b.push(null)))}});const j=this.msg.makeResourceTransferRequest(p,o,c,this.options.id,f),x=this.codec.encode(j),R=this.options.topicMake(o,"resource-transfer-request",f);return this.mqtt.publish(R,ft.from(x),{qos:2,...u}),{stream:b,buffer:d,meta:B}}_dispatchMessage(e,r){super._dispatchMessage(e,r);const o=this.options.topicMatch(e);if(o!==null&&o.operation==="resource-transfer-request"&&r instanceof ui){const f=r.resource,u=this.provisionings.get(f);if(u!==void 0){const c=r.id,p=r.resource,y=r.params??[],b=r.sender??"",d=r.receiver,I={sender:b};d&&(I.receiver=d);const B=this.options.topicMake(p,"resource-transfer-response",b);let q=!0;const P=(W,j,x)=>{const R=q?I.meta:void 0;q=!1;const A=this.msg.makeResourceTransferResponse(c,p,void 0,W,R,j,x,this.options.id,b),_=ft.from(this.codec.encode(A));this.mqtt.publish(B,_,{qos:2})};Promise.resolve().then(()=>u(...y,I)).then(async()=>{if(I.stream instanceof Dt.Readable)Tn(I.stream,this.options.chunkSize,P,()=>{},W=>P(void 0,W.message,!0));else if(I.buffer!==void 0&&typeof I.buffer.then=="function")_n(await I.buffer,this.options.chunkSize,P);else throw new Error("handler did not provide data via info.stream or info.buffer field")}).catch(W=>{P(void 0,W.message,!0)})}}else if(o!==null&&o.operation==="resource-transfer-response"&&r instanceof fi){const f=r.id,u=r.error,c=r.meta,p=r.final,y=r.chunk!==void 0&&!(r.chunk instanceof Uint8Array)?Uint8Array.from(r.chunk):r.chunk,b=this.callbacks.get(f);if(b!==void 0)b.callback(u?new Error(u):void 0,y,c,p);else if(r.resource!==void 0){const d=r.resource,I=this.provisionings.get(d);if(I!==void 0){let B=this.pushStreams.get(f);if(B===void 0){B=new Dt.Readable({read(R){}}),this.pushStreams.set(f,B);const P=setTimeout(()=>{const R=this.pushStreams.get(f);R!==void 0&&(R.destroy(new Error("push stream timeout")),this.pushStreams.delete(f),this.pushTimers.delete(f))},this.options.timeout);this.pushTimers.set(f,P);const W=mn(B),j=r.params??[],x={sender:r.sender??""};r.receiver&&(x.receiver=r.receiver),r.meta&&(x.meta=c),x.stream=B,x.buffer=W,Promise.resolve().then(()=>I(...j,x)).catch(R=>{this.mqtt.emit("error",R)})}const q=()=>{const P=this.pushTimers.get(f);P!==void 0&&(clearTimeout(P),this.pushTimers.delete(f))};u!==void 0?(q(),B.destroy(new Error(u)),this.pushStreams.delete(f)):(y!==void 0&&B.push(y),p&&(q(),B.push(null),this.pushStreams.delete(f)))}}}}}class Po extends ko{}return Po}));
13
+ `,b+=y,b},Or.noChildren=!0,Z.registerDecoder(ie.CBOR,Or),Z.registerDecoder(ie.URI,t=>(rt(t.contents),new URL(t.contents)),"URI"),we(URL,t=>[ie.URI,t.toString()]),Z.registerDecoder(ie.BASE64URL,t=>(rt(t.contents),Ci(t.contents)),"Base64url-encoded"),Z.registerDecoder(ie.BASE64,t=>(rt(t.contents),Rr(t.contents)),"Base64-encoded"),Z.registerDecoder(35,t=>(rt(t.contents),new RegExp(t.contents)),"RegExp"),Z.registerDecoder(21065,t=>{rt(t.contents);const e=`^(?:${t.contents})$`;return new RegExp(e,"u")},"I-RegExp"),Z.registerDecoder(ie.REGEXP,t=>{if(Zn(t.contents),t.contents.length<1||t.contents.length>2)throw new Error(`Invalid RegExp Array: ${t.contents}`);return new RegExp(t.contents[0],t.contents[1])},"RegExp"),we(RegExp,t=>[ie.REGEXP,[t.source,t.flags]]),Z.registerDecoder(64,t=>(Ze(t.contents),t.contents),"uint8 Typed Array");function Be(t,e,r){Ze(t.contents);let o=t.contents.length;if(o%e.BYTES_PER_ELEMENT!==0)throw new Error(`Number of bytes must be divisible by ${e.BYTES_PER_ELEMENT}, got: ${o}`);o/=e.BYTES_PER_ELEMENT;const f=new e(o),u=new DataView(t.contents.buffer,t.contents.byteOffset,t.contents.byteLength),c=u[`get${e.name.replace(/Array/,"")}`].bind(u);for(let p=0;p<o;p++)f[p]=c(p*e.BYTES_PER_ELEMENT,r);return f}function nt(t,e,r,o,f){const u=f.forceEndian??Jn;if(It(u?e:r,t,f),Me(o.byteLength,t,Y.BYTE_STRING),Jn===u)t.write(new Uint8Array(o.buffer,o.byteOffset,o.byteLength));else{const c=`write${o.constructor.name.replace(/Array/,"")}`,p=t[c].bind(t);for(const y of o)p(y,u)}}Z.registerDecoder(65,t=>Be(t,Uint16Array,!1),"uint16, big endian, Typed Array"),Z.registerDecoder(66,t=>Be(t,Uint32Array,!1),"uint32, big endian, Typed Array"),Z.registerDecoder(67,t=>Be(t,BigUint64Array,!1),"uint64, big endian, Typed Array"),Z.registerDecoder(68,t=>(Ze(t.contents),new Uint8ClampedArray(t.contents)),"uint8 Typed Array, clamped arithmetic"),we(Uint8ClampedArray,t=>[68,new Uint8Array(t.buffer,t.byteOffset,t.byteLength)]),Z.registerDecoder(69,t=>Be(t,Uint16Array,!0),"uint16, little endian, Typed Array"),we(Uint16Array,(t,e,r)=>nt(e,69,65,t,r)),Z.registerDecoder(70,t=>Be(t,Uint32Array,!0),"uint32, little endian, Typed Array"),we(Uint32Array,(t,e,r)=>nt(e,70,66,t,r)),Z.registerDecoder(71,t=>Be(t,BigUint64Array,!0),"uint64, little endian, Typed Array"),we(BigUint64Array,(t,e,r)=>nt(e,71,67,t,r)),Z.registerDecoder(72,t=>(Ze(t.contents),new Int8Array(t.contents)),"sint8 Typed Array"),we(Int8Array,t=>[72,new Uint8Array(t.buffer,t.byteOffset,t.byteLength)]),Z.registerDecoder(73,t=>Be(t,Int16Array,!1),"sint16, big endian, Typed Array"),Z.registerDecoder(74,t=>Be(t,Int32Array,!1),"sint32, big endian, Typed Array"),Z.registerDecoder(75,t=>Be(t,BigInt64Array,!1),"sint64, big endian, Typed Array"),Z.registerDecoder(77,t=>Be(t,Int16Array,!0),"sint16, little endian, Typed Array"),we(Int16Array,(t,e,r)=>nt(e,77,73,t,r)),Z.registerDecoder(78,t=>Be(t,Int32Array,!0),"sint32, little endian, Typed Array"),we(Int32Array,(t,e,r)=>nt(e,78,74,t,r)),Z.registerDecoder(79,t=>Be(t,BigInt64Array,!0),"sint64, little endian, Typed Array"),we(BigInt64Array,(t,e,r)=>nt(e,79,75,t,r)),Z.registerDecoder(81,t=>Be(t,Float32Array,!1),"IEEE 754 binary32, big endian, Typed Array"),Z.registerDecoder(82,t=>Be(t,Float64Array,!1),"IEEE 754 binary64, big endian, Typed Array"),Z.registerDecoder(85,t=>Be(t,Float32Array,!0),"IEEE 754 binary32, little endian, Typed Array"),we(Float32Array,(t,e,r)=>nt(e,85,81,t,r)),Z.registerDecoder(86,t=>Be(t,Float64Array,!0),"IEEE 754 binary64, big endian, Typed Array"),we(Float64Array,(t,e,r)=>nt(e,86,82,t,r)),Z.registerDecoder(ie.SET,(t,e)=>{if(Zn(t.contents),e.sortKeys){const r=Fe.decodeToEncodeOpts(e);let o=null;for(const f of t.contents){const u=[f,void 0,mt(f,r)];if(o&&e.sortKeys(o,u)>=0)throw new Error(`Set items out of order in tag #${ie.SET}`);o=u}}return new Set(t.contents)},"Set"),we(Set,(t,e,r)=>{let o=[...t];if(r.sortKeys){const f=o.map(u=>[u,void 0,mt(u,r)]);f.sort(r.sortKeys),o=f.map(([u])=>u)}return[ie.SET,o]}),Z.registerDecoder(ie.JSON,t=>(rt(t.contents),JSON.parse(t.contents)),"JSON-encoded");function ni(t){return Ze(t.contents),new Gt().decode(t.contents)}ni.comment=t=>{Ze(t.contents);const e=new Gt;return`(WTF8 string): ${JSON.stringify(e.decode(t.contents))}`},Z.registerDecoder(ie.WTF8,ni),Z.registerDecoder(ie.SELF_DESCRIBED,t=>t.contents,"Self-Described"),Z.registerDecoder(ie.INVALID_16,()=>{throw new Error(`Tag always invalid: ${ie.INVALID_16}`)},"Invalid"),Z.registerDecoder(ie.INVALID_32,()=>{throw new Error(`Tag always invalid: ${ie.INVALID_32}`)},"Invalid"),Z.registerDecoder(ie.INVALID_64,()=>{throw new Error(`Tag always invalid: ${ie.INVALID_64}`)},"Invalid");function Dr(t){throw new Error(`Encoding ${t.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`)}we(ArrayBuffer,Dr),we(DataView,Dr),typeof SharedArrayBuffer<"u"&&we(SharedArrayBuffer,Dr);function Xt(t){return[NaN,t.valueOf()]}we(Boolean,Xt),we(Number,Xt),we(String,Xt),we(BigInt,Xt);function Ro(t){const e={...Fe.defaultDecodeOptions};if(t.dcbor?Object.assign(e,Fe.dcborDecodeOptions):t.cde&&Object.assign(e,Fe.cdeDecodeOptions),Object.assign(e,t),Object.hasOwn(e,"rejectLongNumbers"))throw new TypeError("rejectLongNumbers has changed to requirePreferred");return e.boxed&&(e.saveOriginal=!0),e}let Io=class{parent=void 0;ret=void 0;step(e,r,o){if(this.ret=Fe.create(e,this.parent,r,o),e[2]===Ie.BREAK)if(this.parent?.isStreaming)this.parent.left=0;else throw new Error("Unexpected BREAK");else this.parent&&this.parent.push(this.ret,o,e[3]);for(this.ret instanceof Fe&&(this.parent=this.ret);this.parent?.done;){this.ret=this.parent.convert(o);const f=this.parent.parent;f?.replaceLast(this.ret,this.parent,o),this.parent=f}}};function Bo(t,e={}){const r=Ro(e),o=new Kt(t,r),f=new Io;for(const u of o)f.step(u,r,o);return f.ret}const{cdeDecodeOptions:Go,dcborDecodeOptions:Wo,defaultDecodeOptions:Ho}=Fe;class Ao{constructor(e={}){this.options={id:bt(),codec:"cbor",timeout:10*1e3,chunkSize:16*1024,topicMake:(r,o,f)=>`${r}/${o}/${f??"any"}`,topicMatch:r=>{const o=r.match(/^(.+)\/([^/]+)\/([^/]+)$/);return o?{name:o[1],operation:o[2],peerId:o[3]==="any"?void 0:o[3]}:null},...e}}}class ii{static uint8ArrayToBase64(e){return btoa(String.fromCharCode(...e))}static base64ToUint8Array(e){const r=atob(e),o=new Uint8Array(r.length);for(let f=0;f<r.length;f++)o[f]=r.charCodeAt(f);return o}static stringify(e){return JSON.stringify(e,(r,o)=>o instanceof Uint8Array?{__Uint8Array:this.uint8ArrayToBase64(o)}:o)}static parse(e){return JSON.parse(e,(r,o)=>typeof o?.__Uint8Array=="string"?this.base64ToUint8Array(o.__Uint8Array):o)}}class No{constructor(e){this.type=e,this.types=new Rn,this.tags=new Map;const r=64e3;this.types.registerEncoder(tr,o=>[r,new Uint8Array(o.buffer,o.byteOffset,o.byteLength)]),this.tags.set(r,o=>tr.from(o.contents))}encode(e){let r;if(this.type==="cbor")try{r=mt(e,{types:this.types})}catch{throw new Error("failed to encode CBOR format")}else if(this.type==="json")try{r=ii.stringify(e)}catch{throw new Error("failed to encode JSON format")}else throw new Error("invalid format");return r}decode(e){let r;if(this.type==="cbor"&&e instanceof Uint8Array)try{r=Bo(e,{tags:this.tags})}catch{throw new Error("failed to decode CBOR format")}else if(this.type==="json"&&typeof e=="string")try{r=ii.parse(e)}catch{throw new Error("failed to decode JSON format")}else throw new Error("invalid format or wrong data type");return r}}class Fo extends Ao{constructor(e={}){super(e),this.codec=new No(this.options.codec)}}class At{constructor(e,r,o,f){this.type=e,this.id=r,this.sender=o,this.receiver=f}}class oi extends At{constructor(e,r,o,f,u){super("event-emission",e,f,u),this.event=r,this.params=o}}class si extends At{constructor(e,r,o,f,u){super("service-call-request",e,f,u),this.service=r,this.params=o}}class ai extends At{constructor(e,r,o,f,u){super("service-call-response",e,f,u),this.result=r,this.error=o}}class ui extends At{constructor(e,r,o,f,u){super("resource-transfer-request",e,f,u),this.resource=r,this.params=o}}class fi extends At{constructor(e,r,o,f,u,c,p,y,b){super("resource-transfer-response",e,y,b),this.resource=r,this.params=o,this.chunk=f,this.meta=u,this.error=c,this.final=p}}class Uo{makeEventEmission(e,r,o,f,u){return new oi(e,r,o,f,u)}makeServiceCallRequest(e,r,o,f,u){return new si(e,r,o,f,u)}makeServiceCallResponse(e,r,o,f,u){return new ai(e,r,o,f,u)}makeResourceTransferRequest(e,r,o,f,u){return new ui(e,r,o,f,u)}makeResourceTransferResponse(e,r,o,f,u,c,p,y,b){return new fi(e,r,o,f,u,c,p,y,b)}parse(e){if(typeof e!="object"||e===null)throw new Error("invalid argument: not an object");if(!("type"in e)||typeof e.type!="string")throw new Error('invalid object: missing or invalid "type" field');if(!("id"in e)||typeof e.id!="string")throw new Error('invalid object: missing or invalid "id" field');if("sender"in e&&e.sender!==void 0&&typeof e.sender!="string")throw new Error('invalid object: invalid "sender" field');if("receiver"in e&&e.receiver!==void 0&&typeof e.receiver!="string")throw new Error('invalid object: invalid "receiver" field');const r=(f,u)=>Object.keys(f).some(c=>!u.includes(c)),o=f=>f.params===void 0||typeof f.params=="object"&&Array.isArray(f.params);if(e.type==="event-emission"){if(typeof e.event!="string")throw new Error('invalid EventEmission object: "event" field must be a string');if(r(e,["type","id","event","params","sender","receiver"]))throw new Error("invalid EventEmission object: contains unknown fields");if(!o(e))throw new Error('invalid EventEmission object: "params" field must be an array');return this.makeEventEmission(e.id,e.event,e.params,e.sender,e.receiver)}else if(e.type==="service-call-request"){if(typeof e.service!="string")throw new Error('invalid ServiceCallRequest object: "service" field must be a string');if(r(e,["type","id","service","params","sender","receiver"]))throw new Error("invalid ServiceCallRequest object: contains unknown fields");if(!o(e))throw new Error('invalid ServiceCallRequest object: "params" field must be an array');return this.makeServiceCallRequest(e.id,e.service,e.params,e.sender,e.receiver)}else if(e.type==="service-call-response"){if(r(e,["type","id","result","error","sender","receiver"]))throw new Error("invalid ServiceCallResponse object: contains unknown fields");return this.makeServiceCallResponse(e.id,e.result,e.error,e.sender,e.receiver)}else if(e.type==="resource-transfer-request"){if(typeof e.resource!="string")throw new Error('invalid ResourceTransferRequest object: "resource" field must be a string');if(r(e,["type","id","resource","params","sender","receiver"]))throw new Error("invalid ResourceTransferRequest object: contains unknown fields");if(!o(e))throw new Error('invalid ResourceTransferRequest object: "params" field must be an array');return this.makeResourceTransferRequest(e.id,e.resource,e.params,e.sender,e.receiver)}else if(e.type==="resource-transfer-response"){if(e.resource!==void 0&&typeof e.resource!="string")throw new Error('invalid ResourceTransferResponse object: "resource" field must be a string');if(e.chunk!==void 0&&(e.chunk===null||typeof e.chunk!="object"))throw new Error('invalid ResourceTransferResponse object: "chunk" field must be an object');if(e.meta!==void 0&&(typeof e.meta!="object"||e.meta===null||Array.isArray(e.meta)))throw new Error('invalid ResourceTransferResponse object: "meta" field must be an object');if(e.error!==void 0&&typeof e.error!="string")throw new Error('invalid ResourceTransferResponse object: "error" field must be a string');if(e.final!==void 0&&typeof e.final!="boolean")throw new Error('invalid ResourceTransferResponse object: "final" field must be a boolean');if(!o(e))throw new Error('invalid ResourceTransferResponse object: "params" field must be an array');if(r(e,["type","id","resource","params","chunk","meta","error","final","sender","receiver"]))throw new Error("invalid ResourceTransferResponse object: contains unknown fields");return this.makeResourceTransferResponse(e.id,e.resource,e.params,e.chunk,e.meta,e.error,e.final,e.sender,e.receiver)}else throw new Error("invalid object: not of any known type")}}class Lo extends Fo{constructor(){super(...arguments),this.msg=new Uo}}class Mo extends Lo{constructor(e,r={}){super(r),e===null&&(e=new Proxy({},{get(o,f,u){return f==="isFakeProxy"?!0:()=>{}}})),this.mqtt=e,this._messageHandler=(o,f,u)=>{this._onMessage(o,f,u)},this.mqtt.on("message",this._messageHandler)}destroy(){this.mqtt.off("message",this._messageHandler)}async _subscribeTopic(e,r={}){return new Promise((o,f)=>{this.mqtt.subscribe(e,{qos:2,...r},(u,c)=>{u?f(u):o()})})}async _unsubscribeTopic(e){return new Promise((r,o)=>{this.mqtt.unsubscribe(e,(f,u)=>{f?o(f):r()})})}_onMessage(e,r,o){let f;try{let u=r;this.options.codec==="json"&&(u=r.toString());const c=this.codec.decode(u);f=this.msg.parse(c)}catch(u){const c=u instanceof Error?new Error(`failed to parse message: ${u.message}`):new Error("failed to parse message");this.mqtt.emit("error",c);return}this._dispatchMessage(e,f)}_dispatchMessage(e,r){}}class Oo extends Mo{constructor(){super(...arguments),this.subscriptions=new Map}async subscribe(e,...r){let o,f,u={},c;if(typeof e=="object"&&e!==null?(o=e.event,f=e.callback,u=e.options??{},c=e.share):(o=e,f=r[0]),this.subscriptions.has(o))throw new Error(`subscribe: event "${o}" already subscribed`);const p=c?`$share/${c}/${o}`:o,y=this.options.topicMake(p,"event-emission"),b=this.options.topicMake(p,"event-emission",this.options.id);await Promise.all([this._subscribeTopic(y,{qos:0,...u}),this._subscribeTopic(b,{qos:0,...u})]).catch(B=>{throw this._unsubscribeTopic(y).catch(()=>{}),this._unsubscribeTopic(b).catch(()=>{}),B}),this.subscriptions.set(o,f);const d=this;return{async unsubscribe(){if(!d.subscriptions.has(o))throw new Error(`unsubscribe: event "${o}" not subscribed`);return d.subscriptions.delete(o),Promise.all([d._unsubscribeTopic(y),d._unsubscribeTopic(b)]).then(()=>{})}}}emit(e,...r){let o,f,u,c={},p;typeof e=="object"&&e!==null?(o=e.event,f=e.params,u=e.receiver,c=e.options??{},p=e.dry):(o=e,f=r);const y=bt(),b=this.msg.makeEventEmission(y,o,f,this.options.id,u),d=this.codec.encode(b),I=this.options.topicMake(o,"event-emission",u);if(p)return{topic:I,payload:ft.from(d),options:{qos:0,...c}};this.mqtt.publish(I,ft.from(d),{qos:0,...c})}_dispatchMessage(e,r){super._dispatchMessage(e,r);const o=this.options.topicMatch(e);if(o!==null&&o.operation==="event-emission"&&r instanceof oi){const f=r.event,u=this.subscriptions.get(f),c=r.params??[],p={sender:r.sender??""};r.receiver&&(p.receiver=r.receiver),Promise.resolve().then(()=>u?.(...c,p)).catch(y=>{this.mqtt.emit("error",y)})}}}class Do extends Oo{constructor(){super(...arguments),this.registrations=new Map,this.responseCallback=new Map,this.responseSubscriptions=new Map}async register(e,...r){let o,f,u={},c;if(typeof e=="object"&&e!==null?(o=e.service,f=e.callback,u=e.options??{},c=e.share):(o=e,f=r[0]),this.registrations.has(o))throw new Error(`register: service "${o}" already registered`);const p=c?`$share/${c}/${o}`:o,y=this.options.topicMake(p,"service-call-request"),b=this.options.topicMake(p,"service-call-request",this.options.id);await Promise.all([this._subscribeTopic(y,{qos:2,...u}),this._subscribeTopic(b,{qos:2,...u})]).catch(B=>{throw this._unsubscribeTopic(y).catch(()=>{}),this._unsubscribeTopic(b).catch(()=>{}),B}),this.registrations.set(o,f);const d=this;return{async unregister(){if(!d.registrations.has(o))throw new Error(`unregister: service "${o}" not registered`);return d.registrations.delete(o),Promise.all([d._unsubscribeTopic(y),d._unsubscribeTopic(b)]).then(()=>{})}}}call(e,...r){let o,f,u,c={};typeof e=="object"&&e!==null?(o=e.service,f=e.params,u=e.receiver,c=e.options??{}):(o=e,f=r);const p=bt();this._responseSubscribe(o,{qos:c.qos??2});const y=new Promise((B,q)=>{let P=setTimeout(()=>{this.responseCallback.delete(p),this._responseUnsubscribe(o),P=null,q(new Error("communication timeout"))},this.options.timeout);this.responseCallback.set(p,{service:o,callback:(W,j)=>{P!==null&&(clearTimeout(P),P=null),W?q(W):B(j)}})}),b=this.msg.makeServiceCallRequest(p,o,f,this.options.id,u),d=this.codec.encode(b),I=this.options.topicMake(o,"service-call-request",u);return this.mqtt.publish(I,ft.from(d),{qos:2,...c},B=>{if(B){const q=this.responseCallback.get(p);q!==void 0&&(this.responseCallback.delete(p),this._responseUnsubscribe(o),q.callback(B,void 0))}}),y}_responseSubscribe(e,r={qos:2}){const o=this.options.topicMake(e,"service-call-response",this.options.id);this.responseSubscriptions.has(o)||(this.responseSubscriptions.set(o,0),this.mqtt.subscribe(o,r,u=>{if(u){const c=this.responseSubscriptions.get(o)??0;c>1?this.responseSubscriptions.set(o,c-1):this.responseSubscriptions.delete(o),this.mqtt.emit("error",u)}}));const f=this.responseSubscriptions.get(o)??0;this.responseSubscriptions.set(o,f+1)}_responseUnsubscribe(e){const r=this.options.topicMake(e,"service-call-response",this.options.id);if(!this.responseSubscriptions.has(r))return;const o=this.responseSubscriptions.get(r)??0;o>1?this.responseSubscriptions.set(r,o-1):(this.responseSubscriptions.delete(r),this.mqtt.unsubscribe(r,f=>{f&&this.mqtt.emit("error",f)}))}_dispatchMessage(e,r){super._dispatchMessage(e,r);const o=this.options.topicMatch(e);if(o!==null&&o.operation==="service-call-request"&&r instanceof si){const f=r.id,u=r.service,c=this.registrations.get(u);let p;if(c!==void 0){const y=r.params??[],b={sender:r.sender??""};r.receiver&&(b.receiver=r.receiver),p=Promise.resolve().then(()=>c(...y,b))}else p=Promise.reject(new Error(`method not found: ${u}`));p.then(y=>this.msg.makeServiceCallResponse(f,y,void 0,this.options.id,r.sender),y=>{let b;return y==null?b="undefined error":typeof y=="string"?b=y:y instanceof Error?b=y.message:b=String(y),this.msg.makeServiceCallResponse(f,void 0,b,this.options.id,r.sender)}).then(y=>{const b=r.sender;if(b===void 0)throw new Error("invalid request: missing sender");const d=this.codec.encode(y),I=this.options.topicMake(u,"service-call-response",b);this.mqtt.publish(I,ft.from(d),{qos:2})}).catch(y=>{this.mqtt.emit("error",y)})}else if(o!==null&&o.operation==="service-call-response"&&o.peerId===this.options.id&&r instanceof ai){const f=r.id,u=this.responseCallback.get(f);u!==void 0&&(r.error!==void 0?u.callback(new Error(r.error),void 0):u.callback(void 0,r.result),this.responseCallback.delete(f),this._responseUnsubscribe(u.service))}}}class ko extends Do{constructor(){super(...arguments),this.provisionings=new Map,this.callbacks=new Map,this.pushStreams=new Map,this.pushTimers=new Map}async provision(e,...r){let o,f,u={},c;if(typeof e=="object"&&e!==null?(o=e.resource,f=e.callback,u=e.options??{},c=e.share):(o=e,f=r[0]),this.provisionings.has(o))throw new Error(`provision: resource "${o}" already provisioned`);const p=c?`$share/${c}/${o}`:o,y=this.options.topicMake(p,"resource-transfer-request"),b=this.options.topicMake(p,"resource-transfer-request",this.options.id),d=this.options.topicMake(p,"resource-transfer-response"),I=this.options.topicMake(p,"resource-transfer-response",this.options.id);await Promise.all([this._subscribeTopic(y,{qos:2,...u}),this._subscribeTopic(b,{qos:2,...u}),this._subscribeTopic(d,{qos:2,...u}),this._subscribeTopic(I,{qos:2,...u})]).catch(P=>{throw this._unsubscribeTopic(y).catch(()=>{}),this._unsubscribeTopic(b).catch(()=>{}),this._unsubscribeTopic(d).catch(()=>{}),this._unsubscribeTopic(I).catch(()=>{}),P}),this.provisionings.set(o,f);const B=this;return{async unprovision(){if(!B.provisionings.has(o))throw new Error(`unprovision: resource "${o}" not provisioned`);return B.provisionings.delete(o),Promise.all([B._unsubscribeTopic(y),B._unsubscribeTopic(b),B._unsubscribeTopic(d),B._unsubscribeTopic(I)]).then(()=>{})}}}push(e,...r){let o,f,u,c,p,y={};typeof e=="object"&&e!==null?(o=e.resource,f=e.data,u=e.params,c=e.meta,p=e.receiver,y=e.options??{}):(o=e,f=r[0],u=r.slice(1));const b=bt(),d=this.options.topicMake(o,"resource-transfer-response",p);let I=!0;const B=(q,P,W)=>{const j=I?c:void 0;I=!1;const x=this.msg.makeResourceTransferResponse(b,o,u,q,j,P,W,this.options.id,p),R=this.codec.encode(x);this.mqtt.publish(d,ft.from(R),{qos:2,...y})};return new Promise((q,P)=>{f instanceof Dt.Readable?Tn(f,this.options.chunkSize,B,()=>q(),W=>P(W)):f instanceof Uint8Array&&(_n(f,this.options.chunkSize,B),q())})}async fetch(e,...r){let o,f,u={},c;typeof e=="object"&&e!==null?(o=e.resource,c=e.params,f=e.receiver,u=e.options??{}):(o=e,c=r);const p=bt(),y=this.options.topicMake(o,"resource-transfer-response",this.options.id);await this._subscribeTopic(y,{qos:2});const b=new Dt.Readable({read(A){}}),d=mn(b);let I;const B=new Promise(A=>{I=A});let q=null;const P=(A=!1)=>{q!==null&&(clearTimeout(q),q=null),this._unsubscribeTopic(y).catch(()=>{}),this.callbacks.delete(p),A&&I?.(void 0)};q=setTimeout(()=>{P(!0),b.destroy(new Error("communication timeout"))},this.options.timeout);let W=!0;this.callbacks.set(p,{resource:o,callback:(A,_,v,U)=>{const D=W;W&&(W=!1,I?.(v)),A!==void 0?(P(!D),b.destroy(A)):(_!==void 0&&b.push(_),U&&(P(),b.push(null)))}});const j=this.msg.makeResourceTransferRequest(p,o,c,this.options.id,f),x=this.codec.encode(j),R=this.options.topicMake(o,"resource-transfer-request",f);return this.mqtt.publish(R,ft.from(x),{qos:2,...u}),{stream:b,buffer:d,meta:B}}_dispatchMessage(e,r){super._dispatchMessage(e,r);const o=this.options.topicMatch(e);if(o!==null&&o.operation==="resource-transfer-request"&&r instanceof ui){const f=r.resource,u=this.provisionings.get(f);if(u!==void 0){const c=r.id,p=r.resource,y=r.params??[],b=r.sender??"",d=r.receiver,I={sender:b};d&&(I.receiver=d);const B=this.options.topicMake(p,"resource-transfer-response",b);let q=!0;const P=(W,j,x)=>{const R=q?I.meta:void 0;q=!1;const A=this.msg.makeResourceTransferResponse(c,p,void 0,W,R,j,x,this.options.id,b),_=ft.from(this.codec.encode(A));this.mqtt.publish(B,_,{qos:2})};Promise.resolve().then(()=>u(...y,I)).then(async()=>{if(I.stream instanceof Dt.Readable)Tn(I.stream,this.options.chunkSize,P,()=>{},W=>P(void 0,W.message,!0));else if(I.buffer instanceof Promise)_n(await I.buffer,this.options.chunkSize,P);else throw new Error("handler did not provide data via info.stream or info.buffer field")}).catch(W=>{P(void 0,W.message,!0)})}}else if(o!==null&&o.operation==="resource-transfer-response"&&r instanceof fi){const f=r.id,u=r.error,c=r.meta,p=r.final,y=r.chunk!==void 0&&!(r.chunk instanceof Uint8Array)?Uint8Array.from(r.chunk):r.chunk,b=this.callbacks.get(f);if(b!==void 0)b.callback(u?new Error(u):void 0,y,c,p);else if(r.resource!==void 0){const d=r.resource,I=this.provisionings.get(d);if(I!==void 0){let B=this.pushStreams.get(f);if(B===void 0){B=new Dt.Readable({read(R){}}),this.pushStreams.set(f,B);const P=setTimeout(()=>{const R=this.pushStreams.get(f);R!==void 0&&(R.destroy(new Error("push stream timeout")),this.pushStreams.delete(f),this.pushTimers.delete(f))},this.options.timeout);this.pushTimers.set(f,P);const W=mn(B),j=r.params??[],x={sender:r.sender??""};r.receiver&&(x.receiver=r.receiver),r.meta&&(x.meta=c),x.stream=B,x.buffer=W,Promise.resolve().then(()=>I(...j,x)).catch(R=>{this.mqtt.emit("error",R)})}const q=()=>{const P=this.pushTimers.get(f);P!==void 0&&(clearTimeout(P),this.pushTimers.delete(f))};u!==void 0?(q(),B.destroy(new Error(u)),this.pushStreams.delete(f)):(y!==void 0&&B.push(y),p&&(q(),B.push(null),this.pushStreams.delete(f)))}}}}}class Po extends ko{}return Po}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mqtt-plus",
3
- "version": "0.9.18",
3
+ "version": "1.0.0",
4
4
  "description": "MQTT Communication Patterns",
5
5
  "keywords": [ "mqtt",
6
6
  "event", "emit",
@@ -57,7 +57,7 @@ export class BaseTrait<T extends APISchema = APISchema> extends MsgTrait<T> {
57
57
  if (prop === "isFakeProxy")
58
58
  return true
59
59
  else
60
- return (...args: any[]) => {}
60
+ return () => {}
61
61
  }
62
62
  })
63
63
 
@@ -89,9 +89,7 @@ export default class Codec {
89
89
  }
90
90
  decode (data: Uint8Array | string): unknown {
91
91
  let result: unknown
92
- if (this.type === "cbor"
93
- && typeof data === "object"
94
- && data instanceof Uint8Array) {
92
+ if (this.type === "cbor" && data instanceof Uint8Array) {
95
93
  try { result = CBOR.decode(data, { tags: this.tags }) }
96
94
  catch (_ex) { throw new Error("failed to decode CBOR format") }
97
95
  }
@@ -26,10 +26,18 @@
26
26
  import { APISchema } from "./mqtt-plus-api"
27
27
  import { CodecTrait } from "./mqtt-plus-codec"
28
28
 
29
+ /* message types */
30
+ type MessageType =
31
+ | "event-emission"
32
+ | "service-call-request"
33
+ | "service-call-response"
34
+ | "resource-transfer-request"
35
+ | "resource-transfer-response"
36
+
29
37
  /* base class */
30
38
  class Base {
31
39
  constructor (
32
- public type: string,
40
+ public type: MessageType,
33
41
  public id: string,
34
42
  public sender?: string,
35
43
  public receiver?: string
@@ -222,7 +230,7 @@ class Msg {
222
230
  else if (obj.type === "resource-transfer-response") {
223
231
  if (obj.resource !== undefined && typeof obj.resource !== "string")
224
232
  throw new Error("invalid ResourceTransferResponse object: \"resource\" field must be a string")
225
- if (obj.chunk !== undefined && typeof obj.chunk !== "object")
233
+ if (obj.chunk !== undefined && (obj.chunk === null || typeof obj.chunk !== "object"))
226
234
  throw new Error("invalid ResourceTransferResponse object: \"chunk\" field must be an object")
227
235
  if (obj.meta !== undefined && (typeof obj.meta !== "object" || obj.meta === null || Array.isArray(obj.meta)))
228
236
  throw new Error("invalid ResourceTransferResponse object: \"meta\" field must be an object")
@@ -319,8 +319,7 @@ export class ResourceTrait<T extends APISchema = APISchema> extends ServiceTrait
319
319
 
320
320
  /* start timeout handler */
321
321
  timer = setTimeout(() => {
322
- cleanup()
323
- metaResolve?.(undefined)
322
+ cleanup(true)
324
323
  stream.destroy(new Error("communication timeout"))
325
324
  }, this.options.timeout)
326
325
 
@@ -334,12 +333,13 @@ export class ResourceTrait<T extends APISchema = APISchema> extends ServiceTrait
334
333
  meta: Record<string, any> | undefined,
335
334
  final: boolean | undefined
336
335
  ) => {
336
+ const wasFirstChunk = firstChunk
337
337
  if (firstChunk) {
338
338
  firstChunk = false
339
339
  metaResolve?.(meta)
340
340
  }
341
341
  if (error !== undefined) {
342
- cleanup(true)
342
+ cleanup(!wasFirstChunk)
343
343
  stream.destroy(error)
344
344
  }
345
345
  else {
@@ -414,7 +414,7 @@ export class ResourceTrait<T extends APISchema = APISchema> extends ServiceTrait
414
414
  () => {}, (err) => sendChunk(undefined, err.message, true))
415
415
 
416
416
  /* handle Buffer result */
417
- else if (info.buffer !== undefined && typeof info.buffer.then === "function")
417
+ else if (info.buffer instanceof Promise)
418
418
  sendBufferAsChunks(await info.buffer, this.options.chunkSize, sendChunk)
419
419
 
420
420
  /* fail */