"use strict";var Web5Dids=(()=>{var Ox=Object.create;var Cc=Object.defineProperty;var Ux=Object.getOwnPropertyDescriptor;var Cx=Object.getOwnPropertyNames;var Px=Object.getPrototypeOf,kx=Object.prototype.hasOwnProperty;var z=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),us=(t,e)=>{for(var r in e)Cc(t,r,{get:e[r],enumerable:!0})},hp=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Cx(e))!kx.call(t,i)&&i!==r&&Cc(t,i,{get:()=>e[i],enumerable:!(n=Ux(e,i))||n.enumerable});return t};var f=(t,e,r)=>(r=t!=null?Ox(Px(t)):{},hp(e||!t||!t.__esModule?Cc(r,"default",{value:t,enumerable:!0}):r,t)),Kx=t=>hp(Cc({},"__esModule",{value:!0}),t);var mp=z(Pc=>{"use strict";var T6=f(h());Pc.byteLength=Mx;Pc.toByteArray=$x;Pc.fromByteArray=Vx;var xr=[],zt=[],Lx=typeof Uint8Array<"u"?Uint8Array:Array,Qu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(ti=0,pp=Qu.length;ti0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function Mx(t){var e=yp(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Nx(t,e,r){return(e+r)*3/4-r}function $x(t){var e,r=yp(t),n=r[0],i=r[1],o=new Lx(Nx(t,n,i)),s=0,c=i>0?n-4:n,a;for(a=0;a>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=zt[t.charCodeAt(a)]<<2|zt[t.charCodeAt(a+1)]>>4,o[s++]=e&255),i===1&&(e=zt[t.charCodeAt(a)]<<10|zt[t.charCodeAt(a+1)]<<4|zt[t.charCodeAt(a+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function qx(t){return xr[t>>18&63]+xr[t>>12&63]+xr[t>>6&63]+xr[t&63]}function Fx(t,e,r){for(var n,i=[],o=e;oc?c:s+o));return n===1?(e=t[r-1],i.push(xr[e>>2]+xr[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(xr[e>>10]+xr[e>>4&63]+xr[e<<2&63]+"=")),i.join("")}});var gp=z(ed=>{var I6=f(h());ed.read=function(t,e,r,n,i){var o,s,c=i*8-n-1,a=(1<>1,u=-7,l=r?i-1:0,y=r?-1:1,g=t[e+l];for(l+=y,o=g&(1<<-u)-1,g>>=-u,u+=c;u>0;o=o*256+t[e+l],l+=y,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=n;u>0;s=s*256+t[e+l],l+=y,u-=8);if(o===0)o=1-d;else{if(o===a)return s?NaN:(g?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-d}return(g?-1:1)*s*Math.pow(2,o-n)};ed.write=function(t,e,r,n,i,o){var s,c,a,d=o*8-i-1,u=(1<>1,y=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=n?0:o-1,p=n?1:-1,w=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),s+l>=1?e+=y/a:e+=y*Math.pow(2,1-l),e*a>=2&&(s++,a/=2),s+l>=u?(c=0,s=u):s+l>=1?(c=(e*a-1)*Math.pow(2,i),s=s+l):(c=e*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;t[r+g]=c&255,g+=p,c/=256,i-=8);for(s=s<0;t[r+g]=s&255,g+=p,s/=256,d-=8);t[r+g-p]|=w*128}});var At=z(no=>{"use strict";var R6=f(h());var td=mp(),to=gp(),wp=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;no.Buffer=B;no.SlowBuffer=Jx;no.INSPECT_MAX_BYTES=50;var kc=2147483647;no.kMaxLength=kc;B.TYPED_ARRAY_SUPPORT=Hx();!B.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 Hx(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch{return!1}}Object.defineProperty(B.prototype,"parent",{enumerable:!0,get:function(){if(B.isBuffer(this))return this.buffer}});Object.defineProperty(B.prototype,"offset",{enumerable:!0,get:function(){if(B.isBuffer(this))return this.byteOffset}});function zr(t){if(t>kc)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,B.prototype),e}function B(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return od(t)}return vp(t,e,r)}B.poolSize=8192;function vp(t,e,r){if(typeof t=="string")return Wx(t,e);if(ArrayBuffer.isView(t))return zx(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(Er(t,ArrayBuffer)||t&&Er(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Er(t,SharedArrayBuffer)||t&&Er(t.buffer,SharedArrayBuffer)))return nd(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return B.from(n,e,r);let i=Gx(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return B.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}B.from=function(t,e,r){return vp(t,e,r)};Object.setPrototypeOf(B.prototype,Uint8Array.prototype);Object.setPrototypeOf(B,Uint8Array);function Sp(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function jx(t,e,r){return Sp(t),t<=0?zr(t):e!==void 0?typeof r=="string"?zr(t).fill(e,r):zr(t).fill(e):zr(t)}B.alloc=function(t,e,r){return jx(t,e,r)};function od(t){return Sp(t),zr(t<0?0:sd(t)|0)}B.allocUnsafe=function(t){return od(t)};B.allocUnsafeSlow=function(t){return od(t)};function Wx(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!B.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=Ap(t,e)|0,n=zr(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function rd(t){let e=t.length<0?0:sd(t.length)|0,r=zr(e);for(let n=0;n=kc)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kc.toString(16)+" bytes");return t|0}function Jx(t){return+t!=t&&(t=0),B.alloc(+t)}B.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==B.prototype};B.compare=function(e,r){if(Er(e,Uint8Array)&&(e=B.from(e,e.offset,e.byteLength)),Er(r,Uint8Array)&&(r=B.from(r,r.offset,r.byteLength)),!B.isBuffer(e)||!B.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let o=0,s=Math.min(n,i);oi.length?(B.isBuffer(s)||(s=B.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(B.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function Ap(t,e){if(B.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Er(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return id(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Cp(t).length;default:if(i)return n?-1:id(t).length;e=(""+e).toLowerCase(),i=!0}}B.byteLength=Ap;function Yx(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return sE(this,e,r);case"utf8":case"utf-8":return _p(this,e,r);case"ascii":return iE(this,e,r);case"latin1":case"binary":return oE(this,e,r);case"base64":return rE(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return cE(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}B.prototype._isBuffer=!0;function ri(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}B.prototype.swap16=function(){let e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;rr&&(e+=" ... "),""};wp&&(B.prototype[wp]=B.prototype.inspect);B.prototype.compare=function(e,r,n,i,o){if(Er(e,Uint8Array)&&(e=B.from(e,e.offset,e.byteLength)),!B.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let s=o-i,c=n-r,a=Math.min(s,c),d=this.slice(i,o),u=e.slice(r,n);for(let l=0;l2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,ad(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=B.from(e,n)),B.isBuffer(e))return e.length===0?-1:bp(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):bp(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function bp(t,e,r,n,i){let o=1,s=t.length,c=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;o=2,s/=2,c/=2,r/=2}function a(u,l){return o===1?u[l]:u.readUInt16BE(l*o)}let d;if(i){let u=-1;for(d=r;ds&&(r=s-c),d=r;d>=0;d--){let u=!0;for(let l=0;li&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-r;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return Xx(this,e,r,n);case"utf8":case"utf-8":return Zx(this,e,r,n);case"ascii":case"latin1":case"binary":return Qx(this,e,r,n);case"base64":return eE(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return tE(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};B.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function rE(t,e,r){return e===0&&r===t.length?td.fromByteArray(t):td.fromByteArray(t.slice(e,r))}function _p(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i239?4:o>223?3:o>191?2:1;if(i+c<=r){let a,d,u,l;switch(c){case 1:o<128&&(s=o);break;case 2:a=t[i+1],(a&192)===128&&(l=(o&31)<<6|a&63,l>127&&(s=l));break;case 3:a=t[i+1],d=t[i+2],(a&192)===128&&(d&192)===128&&(l=(o&15)<<12|(a&63)<<6|d&63,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:a=t[i+1],d=t[i+2],u=t[i+3],(a&192)===128&&(d&192)===128&&(u&192)===128&&(l=(o&15)<<18|(a&63)<<12|(d&63)<<6|u&63,l>65535&&l<1114112&&(s=l))}}s===null?(s=65533,c=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=c}return nE(n)}var xp=4096;function nE(t){let e=t.length;if(e<=xp)return String.fromCharCode.apply(String,t);let r="",n=0;for(;nn)&&(r=n);let i="";for(let o=e;on&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),rr)throw new RangeError("Trying to access beyond buffer length")}B.prototype.readUintLE=B.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||nt(e,r,this.length);let i=this[e],o=1,s=0;for(;++s>>0,r=r>>>0,n||nt(e,r,this.length);let i=this[e+--r],o=1;for(;r>0&&(o*=256);)i+=this[e+--r]*o;return i};B.prototype.readUint8=B.prototype.readUInt8=function(e,r){return e=e>>>0,r||nt(e,1,this.length),this[e]};B.prototype.readUint16LE=B.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||nt(e,2,this.length),this[e]|this[e+1]<<8};B.prototype.readUint16BE=B.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||nt(e,2,this.length),this[e]<<8|this[e+1]};B.prototype.readUint32LE=B.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||nt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};B.prototype.readUint32BE=B.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||nt(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};B.prototype.readBigUInt64LE=Tn(function(e){e=e>>>0,ro(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ds(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(o)<>>0,ro(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ds(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],o=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<>>0,r=r>>>0,n||nt(e,r,this.length);let i=this[e],o=1,s=0;for(;++s=o&&(i-=Math.pow(2,8*r)),i};B.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||nt(e,r,this.length);let i=r,o=1,s=this[e+--i];for(;i>0&&(o*=256);)s+=this[e+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};B.prototype.readInt8=function(e,r){return e=e>>>0,r||nt(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};B.prototype.readInt16LE=function(e,r){e=e>>>0,r||nt(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};B.prototype.readInt16BE=function(e,r){e=e>>>0,r||nt(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};B.prototype.readInt32LE=function(e,r){return e=e>>>0,r||nt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};B.prototype.readInt32BE=function(e,r){return e=e>>>0,r||nt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};B.prototype.readBigInt64LE=Tn(function(e){e=e>>>0,ro(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ds(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<>>0,ro(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ds(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<>>0,r||nt(e,4,this.length),to.read(this,e,!0,23,4)};B.prototype.readFloatBE=function(e,r){return e=e>>>0,r||nt(e,4,this.length),to.read(this,e,!1,23,4)};B.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||nt(e,8,this.length),to.read(this,e,!0,52,8)};B.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||nt(e,8,this.length),to.read(this,e,!1,52,8)};function St(t,e,r,n,i,o){if(!B.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}B.prototype.writeUintLE=B.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;St(this,e,r,n,c,0)}let o=1,s=0;for(this[r]=e&255;++s>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;St(this,e,r,n,c,0)}let o=n-1,s=1;for(this[r+o]=e&255;--o>=0&&(s*=256);)this[r+o]=e/s&255;return r+n};B.prototype.writeUint8=B.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||St(this,e,r,1,255,0),this[r]=e&255,r+1};B.prototype.writeUint16LE=B.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||St(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};B.prototype.writeUint16BE=B.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||St(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};B.prototype.writeUint32LE=B.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||St(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};B.prototype.writeUint32BE=B.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||St(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function Ip(t,e,r,n,i){Up(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,r}function Bp(t,e,r,n,i){Up(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o=o>>8,t[r+6]=o,o=o>>8,t[r+5]=o,o=o>>8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s=s>>8,t[r+2]=s,s=s>>8,t[r+1]=s,s=s>>8,t[r]=s,r+8}B.prototype.writeBigUInt64LE=Tn(function(e,r=0){return Ip(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});B.prototype.writeBigUInt64BE=Tn(function(e,r=0){return Bp(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});B.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let a=Math.pow(2,8*n-1);St(this,e,r,n,a-1,-a)}let o=0,s=1,c=0;for(this[r]=e&255;++o>0)-c&255;return r+n};B.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let a=Math.pow(2,8*n-1);St(this,e,r,n,a-1,-a)}let o=n-1,s=1,c=0;for(this[r+o]=e&255;--o>=0&&(s*=256);)e<0&&c===0&&this[r+o+1]!==0&&(c=1),this[r+o]=(e/s>>0)-c&255;return r+n};B.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||St(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};B.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||St(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};B.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||St(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};B.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||St(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};B.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||St(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};B.prototype.writeBigInt64LE=Tn(function(e,r=0){return Ip(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});B.prototype.writeBigInt64BE=Tn(function(e,r=0){return Bp(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Dp(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Rp(t,e,r,n,i){return e=+e,r=r>>>0,i||Dp(t,e,r,4,34028234663852886e22,-34028234663852886e22),to.write(t,e,r,n,23,4),r+4}B.prototype.writeFloatLE=function(e,r,n){return Rp(this,e,r,!0,n)};B.prototype.writeFloatBE=function(e,r,n){return Rp(this,e,r,!1,n)};function Op(t,e,r,n,i){return e=+e,r=r>>>0,i||Dp(t,e,r,8,17976931348623157e292,-17976931348623157e292),to.write(t,e,r,n,52,8),r+8}B.prototype.writeDoubleLE=function(e,r,n){return Op(this,e,r,!0,n)};B.prototype.writeDoubleBE=function(e,r,n){return Op(this,e,r,!1,n)};B.prototype.copy=function(e,r,n,i){if(!B.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=r;o2**32?i=Ep(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Ep(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Ep(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function aE(t,e,r){ro(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&ds(e,t.length-(r+1))}function Up(t,e,r,n,i,o){if(t>r||t3?e===0||e===BigInt(0)?c=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:c=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:c=`>= ${e}${s} and <= ${r}${s}`,new eo.ERR_OUT_OF_RANGE("value",c,t)}aE(n,i,o)}function ro(t,e){if(typeof t!="number")throw new eo.ERR_INVALID_ARG_TYPE(e,"number",t)}function ds(t,e,r){throw Math.floor(t)!==t?(ro(t,r),new eo.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new eo.ERR_BUFFER_OUT_OF_BOUNDS:new eo.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var uE=/[^+/0-9A-Za-z-_]/g;function dE(t){if(t=t.split("=")[0],t=t.trim().replace(uE,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function id(t,e){e=e||1/0;let r,n=t.length,i=null,o=[];for(let s=0;s55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function lE(t){let e=[];for(let r=0;r>8,i=r%256,o.push(i),o.push(n);return o}function Cp(t){return td.toByteArray(dE(t))}function Kc(t,e,r,n){let i;for(i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Er(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function ad(t){return t!==t}var hE=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Tn(t){return typeof BigInt>"u"?pE:t}function pE(){throw new Error("BigInt not supported")}});var h=z(()=>{"use strict";var Pp=At().Buffer,{Buffer:yE}=At();Pp.prototype.writeBigUInt64BE=yE.prototype.writeBigUInt64BE;globalThis.Buffer=Pp});var Kp=z((q6,kp)=>{var F6=f(h()),mE=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Lc=()=>mE.now(),gE=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),ud=t=>t===1/0||gE(t),dd=class t{constructor({max:e=1/0,ttl:r,updateAgeOnGet:n=!1,checkAgeOnGet:i=!1,noUpdateTTL:o=!1,dispose:s,noDisposeOnSet:c=!1}={}){if(this.expirations=Object.create(null),this.data=new Map,this.expirationMap=new Map,r!==void 0&&!ud(r))throw new TypeError("ttl must be positive integer or Infinity if set");if(!ud(e))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=r,this.max=e,this.updateAgeOnGet=!!n,this.checkAgeOnGet=!!i,this.noUpdateTTL=!!o,this.noDisposeOnSet=!!c,s!==void 0){if(typeof s!="function")throw new TypeError("dispose must be function if set");this.dispose=s}this.timer=void 0,this.timerExpiration=void 0}setTimer(e,r){if(this.timerExpiration{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let i in this.expirations){this.setTimer(i,i-Lc());break}},r);n.unref&&n.unref(),this.timerExpiration=e,this.timer=n}cancelTimer(){this.timer&&(clearTimeout(this.timer),this.timerExpiration=void 0,this.timer=void 0)}cancelTimers(){return process.emitWarning('TTLCache.cancelTimers has been renamed to TTLCache.cancelTimer (no "s"), and will be removed in the next major version update'),this.cancelTimer()}clear(){let e=this.dispose!==t.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(let[r,n]of e)this.dispose(n,r,"delete")}setTTL(e,r=this.ttl){let n=this.expirationMap.get(e);if(n!==void 0){let i=this.expirations[n];!i||i.length<=1?delete this.expirations[n]:this.expirations[n]=i.filter(o=>o!==e)}if(r!==1/0){let i=Math.floor(Lc()+r);this.expirationMap.set(e,i),this.expirations[i]||(this.expirations[i]=[],this.setTimer(i,r)),this.expirations[i].push(e)}else this.expirationMap.set(e,1/0)}set(e,r,{ttl:n=this.ttl,noUpdateTTL:i=this.noUpdateTTL,noDisposeOnSet:o=this.noDisposeOnSet}={}){if(!ud(n))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(e)){i||this.setTTL(e,n);let s=this.data.get(e);s!==r&&(this.data.set(e,r),o||this.dispose(s,e,"set"))}else this.setTTL(e,n),this.data.set(e,r);for(;this.size>this.max;)this.purgeToCapacity();return this}has(e){return this.data.has(e)}getRemainingTTL(e){let r=this.expirationMap.get(e);return r===1/0?r:r!==void 0?Math.max(0,Math.ceil(r-Lc())):0}get(e,{updateAgeOnGet:r=this.updateAgeOnGet,ttl:n=this.ttl,checkAgeOnGet:i=this.checkAgeOnGet}={}){let o=this.data.get(e);if(i&&this.getRemainingTTL(e)===0){this.delete(e);return}return r&&this.setTTL(e,n),o}dispose(e,r){}delete(e){let r=this.expirationMap.get(e);if(r!==void 0){let n=this.data.get(e);this.data.delete(e),this.expirationMap.delete(e);let i=this.expirations[r];return i&&(i.length<=1?delete this.expirations[r]:this.expirations[r]=i.filter(o=>o!==e)),this.dispose(n,e,"delete"),this.size===0&&this.cancelTimer(),!0}return!1}purgeToCapacity(){for(let e in this.expirations){let r=this.expirations[e];if(this.size-r.length>=this.max){delete this.expirations[e];let n=[];for(let i of r)n.push([i,this.data.get(i)]),this.data.delete(i),this.expirationMap.delete(i);for(let[i,o]of n)this.dispose(o,i,"evict")}else{let n=this.size-this.max,i=[];for(let o of r.splice(0,n))i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"evict");return}}}get size(){return this.data.size}purgeStale(){let e=Math.ceil(Lc());for(let r in this.expirations){if(r==="Infinity"||r>e)return;let n=[...this.expirations[r]||[]],i=[];delete this.expirations[r];for(let o of n)i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"stale")}this.size===0&&this.cancelTimer()}*entries(){for(let e in this.expirations)for(let r of this.expirations[e])yield[r,this.data.get(r)]}*keys(){for(let e in this.expirations)for(let r of this.expirations[e])yield r}*values(){for(let e in this.expirations)for(let r of this.expirations[e])yield this.data.get(r)}[Symbol.iterator](){return this.entries()}};kp.exports=dd});var Qp=z(Zp=>{"use strict";var t8=f(h());Zp.supports=function(...e){let r=e.reduce((n,i)=>Object.assign(n,i),{});return Object.assign(r,{snapshots:r.snapshots||!1,permanence:r.permanence||!1,seek:r.seek||!1,clear:r.clear||!1,getMany:r.getMany||!1,keyIterator:r.keyIterator||!1,valueIterator:r.valueIterator||!1,iteratorNextv:r.iteratorNextv||!1,iteratorAll:r.iteratorAll||!1,status:r.status||!1,createIfMissing:r.createIfMissing||!1,errorIfExists:r.errorIfExists||!1,deferredOpen:r.deferredOpen||!1,promises:r.promises||!1,streams:r.streams||!1,encodings:Object.assign({},r.encodings),events:Object.assign({},r.events),additionalMethods:Object.assign({},r.additionalMethods)})}});var sr=z((n8,ey)=>{"use strict";var i8=f(h());ey.exports=class extends Error{constructor(e,r){super(e||""),typeof r=="object"&&r!==null&&(r.code&&(this.code=String(r.code)),r.expected&&(this.expected=!0),r.transient&&(this.transient=!0),r.cause&&(this.cause=r.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}});var Ad=z((o8,ty)=>{"use strict";var s8=f(h()),Sd=null;ty.exports=function(){return Sd===null&&(Sd={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),Sd}});var Id=z(ry=>{"use strict";var a8=f(h()),Td=sr(),JE=new Set(["buffer","view","utf8"]),_d=class{constructor(e){if(this.encode=e.encode||this.encode,this.decode=e.decode||this.decode,this.name=e.name||this.name,this.format=e.format||this.format,typeof this.encode!="function")throw new TypeError("The 'encode' property must be a function");if(typeof this.decode!="function")throw new TypeError("The 'decode' property must be a function");if(this.encode=this.encode.bind(this),this.decode=this.decode.bind(this),typeof this.name!="string"||this.name==="")throw new TypeError("The 'name' property must be a string");if(typeof this.format!="string"||!JE.has(this.format))throw new TypeError("The 'format' property must be one of 'buffer', 'view', 'utf8'");e.createViewTranscoder&&(this.createViewTranscoder=e.createViewTranscoder),e.createBufferTranscoder&&(this.createBufferTranscoder=e.createBufferTranscoder),e.createUTF8Transcoder&&(this.createUTF8Transcoder=e.createUTF8Transcoder)}get commonName(){return this.name.split("+")[0]}createBufferTranscoder(){throw new Td(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new Td(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new Td(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};ry.Encoding=_d});var Od=z(Nc=>{"use strict";var d8=f(h()),{Buffer:Dd}=At()||{},{Encoding:Rd}=Id(),YE=Ad(),ys=class extends Rd{constructor(e){super({...e,format:"buffer"})}createViewTranscoder(){return new ms({encode:this.encode,decode:e=>this.decode(Dd.from(e.buffer,e.byteOffset,e.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},ms=class extends Rd{constructor(e){super({...e,format:"view"})}createBufferTranscoder(){return new ys({encode:e=>{let r=this.encode(e);return Dd.from(r.buffer,r.byteOffset,r.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},Bd=class extends Rd{constructor(e){super({...e,format:"utf8"})}createBufferTranscoder(){return new ys({encode:e=>Dd.from(this.encode(e),"utf8"),decode:e=>this.decode(e.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:e,textDecoder:r}=YE();return new ms({encode:n=>e.encode(this.encode(n)),decode:n=>this.decode(r.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};Nc.BufferFormat=ys;Nc.ViewFormat=ms;Nc.UTF8Format=Bd});var sy=z(ci=>{"use strict";var f8=f(h()),{Buffer:yt}=At()||{Buffer:{isBuffer:()=>!1}},{textEncoder:iy,textDecoder:ny}=Ad()(),{BufferFormat:gs,ViewFormat:Ud,UTF8Format:oy}=Od(),$c=t=>t;ci.utf8=new oy({encode:function(t){return yt.isBuffer(t)?t.toString("utf8"):ArrayBuffer.isView(t)?ny.decode(t):String(t)},decode:$c,name:"utf8",createViewTranscoder(){return new Ud({encode:function(t){return ArrayBuffer.isView(t)?t:iy.encode(t)},decode:function(t){return ny.decode(t)},name:`${this.name}+view`})},createBufferTranscoder(){return new gs({encode:function(t){return yt.isBuffer(t)?t:ArrayBuffer.isView(t)?yt.from(t.buffer,t.byteOffset,t.byteLength):yt.from(String(t),"utf8")},decode:function(t){return t.toString("utf8")},name:`${this.name}+buffer`})}});ci.json=new oy({encode:JSON.stringify,decode:JSON.parse,name:"json"});ci.buffer=new gs({encode:function(t){return yt.isBuffer(t)?t:ArrayBuffer.isView(t)?yt.from(t.buffer,t.byteOffset,t.byteLength):yt.from(String(t),"utf8")},decode:$c,name:"buffer",createViewTranscoder(){return new Ud({encode:function(t){return ArrayBuffer.isView(t)?t:yt.from(String(t),"utf8")},decode:function(t){return yt.from(t.buffer,t.byteOffset,t.byteLength)},name:`${this.name}+view`})}});ci.view=new Ud({encode:function(t){return ArrayBuffer.isView(t)?t:iy.encode(t)},decode:$c,name:"view",createBufferTranscoder(){return new gs({encode:function(t){return yt.isBuffer(t)?t:ArrayBuffer.isView(t)?yt.from(t.buffer,t.byteOffset,t.byteLength):yt.from(String(t),"utf8")},decode:$c,name:`${this.name}+buffer`})}});ci.hex=new gs({encode:function(t){return yt.isBuffer(t)?t:yt.from(String(t),"hex")},decode:function(t){return t.toString("hex")},name:"hex"});ci.base64=new gs({encode:function(t){return yt.isBuffer(t)?t:yt.from(String(t),"base64")},decode:function(t){return t.toString("base64")},name:"base64"})});var uy=z(ay=>{"use strict";var p8=f(h()),cy=sr(),Fc=sy(),{Encoding:XE}=Id(),{BufferFormat:ZE,ViewFormat:QE,UTF8Format:e1}=Od(),ws=Symbol("formats"),qc=Symbol("encodings"),t1=new Set(["buffer","view","utf8"]),Cd=class{constructor(e){if(Array.isArray(e)){if(!e.every(r=>t1.has(r)))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}else throw new TypeError("The first argument 'formats' must be an array");this[qc]=new Map,this[ws]=new Set(e);for(let r in Fc)try{this.encoding(r)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[qc].values()))}encoding(e){let r=this[qc].get(e);if(r===void 0){if(typeof e=="string"&&e!==""){if(r=o1[e],!r)throw new cy(`Encoding '${e}' is not found`,{code:"LEVEL_ENCODING_NOT_FOUND"})}else{if(typeof e!="object"||e===null)throw new TypeError("First argument 'encoding' must be a string or object");r=r1(e)}let{name:n,format:i}=r;if(!this[ws].has(i))if(this[ws].has("view"))r=r.createViewTranscoder();else if(this[ws].has("buffer"))r=r.createBufferTranscoder();else if(this[ws].has("utf8"))r=r.createUTF8Transcoder();else throw new cy(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[e,n,r.name,r.commonName])this[qc].set(o,r)}return r}};ay.Transcoder=Cd;function r1(t){if(t instanceof XE)return t;let e="type"in t&&typeof t.type=="string"?t.type:void 0,r=t.name||e||`anonymous-${s1++}`;switch(n1(t)){case"view":return new QE({...t,name:r});case"utf8":return new e1({...t,name:r});case"buffer":return new ZE({...t,name:r});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function n1(t){return"format"in t&&t.format!==void 0?t.format:"buffer"in t&&typeof t.buffer=="boolean"?t.buffer?"buffer":"utf8":"code"in t&&Number.isInteger(t.code)?"view":"buffer"}var i1={binary:Fc.buffer,"utf-8":Fc.utf8},o1={...Fc,...i1},s1=0});var bs=z((y8,Pd)=>{"use strict";var m8=f(h()),ao=typeof Reflect=="object"?Reflect:null,dy=ao&&typeof ao.apply=="function"?ao.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Vc;ao&&typeof ao.ownKeys=="function"?Vc=ao.ownKeys:Object.getOwnPropertySymbols?Vc=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Vc=function(e){return Object.getOwnPropertyNames(e)};function c1(t){console&&console.warn&&console.warn(t)}var fy=Number.isNaN||function(e){return e!==e};function Te(){Te.init.call(this)}Pd.exports=Te;Pd.exports.once=l1;Te.EventEmitter=Te;Te.prototype._events=void 0;Te.prototype._eventsCount=0;Te.prototype._maxListeners=void 0;var ly=10;function Hc(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Te,"defaultMaxListeners",{enumerable:!0,get:function(){return ly},set:function(t){if(typeof t!="number"||t<0||fy(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");ly=t}});Te.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};Te.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||fy(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function hy(t){return t._maxListeners===void 0?Te.defaultMaxListeners:t._maxListeners}Te.prototype.getMaxListeners=function(){return hy(this)};Te.prototype.emit=function(e){for(var r=[],n=1;n0&&(s=r[0]),s instanceof Error)throw s;var c=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw c.context=s,c}var a=o[e];if(a===void 0)return!1;if(typeof a=="function")dy(a,this,r);else for(var d=a.length,u=wy(a,d),n=0;n0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=s.length,c1(c)}return t}Te.prototype.addListener=function(e,r){return py(this,e,r,!1)};Te.prototype.on=Te.prototype.addListener;Te.prototype.prependListener=function(e,r){return py(this,e,r,!0)};function a1(){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 yy(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=a1.bind(n);return i.listener=r,n.wrapFn=i,i}Te.prototype.once=function(e,r){return Hc(r),this.on(e,yy(this,e,r)),this};Te.prototype.prependOnceListener=function(e,r){return Hc(r),this.prependListener(e,yy(this,e,r)),this};Te.prototype.removeListener=function(e,r){var n,i,o,s,c;if(Hc(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(o=-1,s=n.length-1;s>=0;s--)if(n[s]===r||n[s].listener===r){c=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():u1(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,c||r)}return this};Te.prototype.off=Te.prototype.removeListener;Te.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var o=Object.keys(n),s;for(i=0;i=0;i--)this.removeListener(e,r[i]);return this};function my(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?d1(i):wy(i,i.length)}Te.prototype.listeners=function(e){return my(this,e,!0)};Te.prototype.rawListeners=function(e){return my(this,e,!1)};Te.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):gy.call(t,e)};Te.prototype.listenerCount=gy;function gy(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}Te.prototype.eventNames=function(){return this._eventsCount>0?Vc(this._events):[]};function wy(t,e){for(var r=new Array(e),n=0;n{var w8=f(h());xy.exports=typeof queueMicrotask=="function"?queueMicrotask:t=>Promise.resolve().then(t)});var xs=z(kd=>{"use strict";var x8=f(h()),vy=Ey();kd.fromCallback=function(t,e){if(t===void 0){var r=new Promise(function(n,i){t=function(o,s){o?i(o):n(s)}});t[e!==void 0?e:"promise"]=r}else if(typeof t!="function")throw new TypeError("Callback must be a function");return t};kd.fromPromise=function(t,e){if(e===void 0)return t;t.then(function(r){vy(()=>e(null,r))}).catch(function(r){vy(()=>e(r))})}});var jc=z(Kd=>{"use strict";var v8=f(h());Kd.getCallback=function(t,e){return typeof t=="function"?t:e};Kd.getOptions=function(t,e){return typeof t=="object"&&t!==null?t:e!==void 0?e:{}}});var On=z(Jc=>{"use strict";var A8=f(h()),{fromCallback:Ld}=xs(),kt=sr(),{getOptions:Md,getCallback:Sy}=jc(),ai=Symbol("promise"),uo=Symbol("callback"),Sr=Symbol("working"),ui=Symbol("handleOne"),Yr=Symbol("handleMany"),Nd=Symbol("autoClose"),Dn=Symbol("finishWork"),Ar=Symbol("returnMany"),_n=Symbol("closing"),Es=Symbol("handleClose"),Wc=Symbol("closed"),vs=Symbol("closeCallbacks"),Bn=Symbol("keyEncoding"),di=Symbol("valueEncoding"),$d=Symbol("abortOnClose"),zc=Symbol("legacy"),qd=Symbol("keys"),Fd=Symbol("values"),In=Symbol("limit"),Gt=Symbol("count"),Gc=Object.freeze({}),h1=()=>{},Ay=!1,Ss=class{constructor(e,r,n){if(typeof e!="object"||e===null){let i=e===null?"null":typeof e;throw new TypeError(`The first argument must be an abstract-level database, received ${i}`)}if(typeof r!="object"||r===null)throw new TypeError("The second argument must be an options object");this[Wc]=!1,this[vs]=[],this[Sr]=!1,this[_n]=!1,this[Nd]=!1,this[uo]=null,this[ui]=this[ui].bind(this),this[Yr]=this[Yr].bind(this),this[Es]=this[Es].bind(this),this[Bn]=r[Bn],this[di]=r[di],this[zc]=n,this[In]=Number.isInteger(r.limit)&&r.limit>=0?r.limit:1/0,this[Gt]=0,this[$d]=!!r.abortOnClose,this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get count(){return this[Gt]}get limit(){return this[In]}next(e){let r;if(e===void 0)r=new Promise((n,i)=>{e=(o,s,c)=>{o?i(o):this[zc]?s===void 0&&c===void 0?n():n([s,c]):n(s)}});else if(typeof e!="function")throw new TypeError("Callback must be a function");return this[_n]?this.nextTick(e,new kt("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Sr]?this.nextTick(e,new kt("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[Sr]=!0,this[uo]=e,this[Gt]>=this[In]?this.nextTick(this[ui],null):this._next(this[ui])),r}_next(e){this.nextTick(e)}nextv(e,r,n){return n=Sy(r,n),n=Ld(n,ai),r=Md(r,Gc),Number.isInteger(e)?(this[_n]?this.nextTick(n,new kt("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Sr]?this.nextTick(n,new kt("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(e<1&&(e=1),this[In]<1/0&&(e=Math.min(e,this[In]-this[Gt])),this[Sr]=!0,this[uo]=n,e<=0?this.nextTick(this[Yr],null,[]):this._nextv(e,r,this[Yr])),n[ai]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[ai])}_nextv(e,r,n){let i=[],o=(s,c,a)=>{if(s)return n(s);if(this[zc]?c===void 0&&a===void 0:c===void 0)return n(null,i);i.push(this[zc]?[c,a]:c),i.length===e?n(null,i):this._next(o)};this._next(o)}all(e,r){return r=Sy(e,r),r=Ld(r,ai),e=Md(e,Gc),this[_n]?this.nextTick(r,new kt("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Sr]?this.nextTick(r,new kt("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[Sr]=!0,this[uo]=r,this[Nd]=!0,this[Gt]>=this[In]?this.nextTick(this[Yr],null,[]):this._all(e,this[Yr])),r[ai]}_all(e,r){let n=this[Gt],i=[],o=()=>{let c=this[In]<1/0?Math.min(1e3,this[In]-n):1e3;c<=0?this.nextTick(r,null,i):this._nextv(c,Gc,s)},s=(c,a)=>{c?r(c):a.length===0?r(null,i):(i.push.apply(i,a),n+=a.length,o())};o()}[Dn](){let e=this[uo];return this[$d]&&e===null?h1:(this[Sr]=!1,this[uo]=null,this[_n]&&this._close(this[Es]),e)}[Ar](e,r,n){this[Nd]?this.close(e.bind(null,r,n)):e(r,n)}seek(e,r){if(r=Md(r,Gc),!this[_n]){if(this[Sr])throw new kt("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let n=this.db.keyEncoding(r.keyEncoding||this[Bn]),i=n.format;r.keyEncoding!==i&&(r={...r,keyEncoding:i});let o=this.db.prefixKey(n.encode(e),i);this._seek(o,r)}}}_seek(e,r){throw new kt("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(e){return e=Ld(e,ai),this[Wc]?this.nextTick(e):this[_n]?this[vs].push(e):(this[_n]=!0,this[vs].push(e),this[Sr]?this[$d]&&this[Dn]()(new kt("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[Es])),e[ai]}_close(e){this.nextTick(e)}[Es](){this[Wc]=!0,this.db.detachResource(this);let e=this[vs];this[vs]=[];for(let r of e)r()}async*[Symbol.asyncIterator](){try{let e;for(;(e=await this.next())!==void 0;)yield e}finally{this[Wc]||await this.close()}}},lo=class extends Ss{constructor(e,r){super(e,r,!0),this[qd]=r.keys!==!1,this[Fd]=r.values!==!1}[ui](e,r,n){let i=this[Dn]();if(e)return i(e);try{r=this[qd]&&r!==void 0?this[Bn].decode(r):void 0,n=this[Fd]&&n!==void 0?this[di].decode(n):void 0}catch(o){return i(new Rn("entry",o))}r===void 0&&n===void 0||this[Gt]++,i(null,r,n)}[Yr](e,r){let n=this[Dn]();if(e)return this[Ar](n,e);try{for(let i of r){let o=i[0],s=i[1];i[0]=this[qd]&&o!==void 0?this[Bn].decode(o):void 0,i[1]=this[Fd]&&s!==void 0?this[di].decode(s):void 0}}catch(i){return this[Ar](n,new Rn("entries",i))}this[Gt]+=r.length,this[Ar](n,null,r)}end(e){return!Ay&&typeof console<"u"&&(Ay=!0,console.warn(new kt("The iterator.end() method was renamed to close() and end() is an alias that will be removed in a future version",{code:"LEVEL_LEGACY"}))),this.close(e)}},Vd=class extends Ss{constructor(e,r){super(e,r,!1)}[ui](e,r){let n=this[Dn]();if(e)return n(e);try{r=r!==void 0?this[Bn].decode(r):void 0}catch(i){return n(new Rn("key",i))}r!==void 0&&this[Gt]++,n(null,r)}[Yr](e,r){let n=this[Dn]();if(e)return this[Ar](n,e);try{for(let i=0;i{"use strict";var _8=f(h()),{AbstractKeyIterator:p1,AbstractValueIterator:y1}=On(),li=Symbol("iterator"),As=Symbol("callback"),fo=Symbol("handleOne"),fi=Symbol("handleMany"),Ts=class extends p1{constructor(e,r){super(e,r),this[li]=e.iterator({...r,keys:!0,values:!1}),this[fo]=this[fo].bind(this),this[fi]=this[fi].bind(this)}},Yc=class extends y1{constructor(e,r){super(e,r),this[li]=e.iterator({...r,keys:!1,values:!0}),this[fo]=this[fo].bind(this),this[fi]=this[fi].bind(this)}};for(let t of[Ts,Yc]){let e=t===Ts,r=e?n=>n[0]:n=>n[1];t.prototype._next=function(n){this[As]=n,this[li].next(this[fo])},t.prototype[fo]=function(n,i,o){let s=this[As];n?s(n):s(null,e?i:o)},t.prototype._nextv=function(n,i,o){this[As]=o,this[li].nextv(n,i,this[fi])},t.prototype._all=function(n,i){this[As]=i,this[li].all(n,this[fi])},t.prototype[fi]=function(n,i){let o=this[As];n?o(n):o(null,i.map(r))},t.prototype._seek=function(n,i){this[li].seek(n,i)},t.prototype._close=function(n){this[li].close(n)}}jd.DefaultKeyIterator=Ts;jd.DefaultValueIterator=Yc});var _y=z(ra=>{"use strict";var B8=f(h()),{AbstractIterator:m1,AbstractKeyIterator:g1,AbstractValueIterator:w1}=On(),Wd=sr(),_t=Symbol("nut"),ea=Symbol("undefer"),ta=Symbol("factory"),Xc=class extends m1{constructor(e,r){super(e,r),this[_t]=null,this[ta]=()=>e.iterator(r),this.db.defer(()=>this[ea]())}},Zc=class extends g1{constructor(e,r){super(e,r),this[_t]=null,this[ta]=()=>e.keys(r),this.db.defer(()=>this[ea]())}},Qc=class extends w1{constructor(e,r){super(e,r),this[_t]=null,this[ta]=()=>e.values(r),this.db.defer(()=>this[ea]())}};for(let t of[Xc,Zc,Qc])t.prototype[ea]=function(){this.db.status==="open"&&(this[_t]=this[ta]())},t.prototype._next=function(e){this[_t]!==null?this[_t].next(e):this.db.status==="opening"?this.db.defer(()=>this._next(e)):this.nextTick(e,new Wd("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._nextv=function(e,r,n){this[_t]!==null?this[_t].nextv(e,r,n):this.db.status==="opening"?this.db.defer(()=>this._nextv(e,r,n)):this.nextTick(n,new Wd("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._all=function(e,r){this[_t]!==null?this[_t].all(r):this.db.status==="opening"?this.db.defer(()=>this._all(e,r)):this.nextTick(r,new Wd("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._seek=function(e,r){this[_t]!==null?this[_t]._seek(e,r):this.db.status==="opening"&&this.db.defer(()=>this._seek(e,r))},t.prototype._close=function(e){this[_t]!==null?this[_t].close(e):this.db.status==="opening"?this.db.defer(()=>this._close(e)):this.nextTick(e)};ra.DeferredIterator=Xc;ra.DeferredKeyIterator=Zc;ra.DeferredValueIterator=Qc});var Gd=z(By=>{"use strict";var R8=f(h()),{fromCallback:Iy}=xs(),na=sr(),{getCallback:b1,getOptions:x1}=jc(),ia=Symbol("promise"),Jt=Symbol("status"),ho=Symbol("operations"),_s=Symbol("finishClose"),po=Symbol("closeCallbacks"),zd=class{constructor(e){if(typeof e!="object"||e===null){let r=e===null?"null":typeof e;throw new TypeError(`The first argument must be an abstract-level database, received ${r}`)}this[ho]=[],this[po]=[],this[Jt]="open",this[_s]=this[_s].bind(this),this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get length(){return this[ho].length}put(e,r,n){if(this[Jt]!=="open")throw new na("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let i=this.db._checkKey(e)||this.db._checkValue(r);if(i)throw i;let o=n&&n.sublevel!=null?n.sublevel:this.db,s=n,c=o.keyEncoding(n&&n.keyEncoding),a=o.valueEncoding(n&&n.valueEncoding),d=c.format;n={...n,keyEncoding:d,valueEncoding:a.format},o!==this.db&&(n.sublevel=null);let u=o.prefixKey(c.encode(e),d),l=a.encode(r);return this._put(u,l,n),this[ho].push({...s,type:"put",key:e,value:r}),this}_put(e,r,n){}del(e,r){if(this[Jt]!=="open")throw new na("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let n=this.db._checkKey(e);if(n)throw n;let i=r&&r.sublevel!=null?r.sublevel:this.db,o=r,s=i.keyEncoding(r&&r.keyEncoding),c=s.format;return r={...r,keyEncoding:c},i!==this.db&&(r.sublevel=null),this._del(i.prefixKey(s.encode(e),c),r),this[ho].push({...o,type:"del",key:e}),this}_del(e,r){}clear(){if(this[Jt]!=="open")throw new na("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[ho]=[],this}_clear(){}write(e,r){return r=b1(e,r),r=Iy(r,ia),e=x1(e),this[Jt]!=="open"?this.nextTick(r,new na("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(r):(this[Jt]="writing",this._write(e,n=>{this[Jt]="closing",this[po].push(()=>r(n)),n||this.db.emit("batch",this[ho]),this._close(this[_s])})),r[ia]}_write(e,r){}close(e){return e=Iy(e,ia),this[Jt]==="closing"?this[po].push(e):this[Jt]==="closed"?this.nextTick(e):(this[po].push(e),this[Jt]!=="writing"&&(this[Jt]="closing",this._close(this[_s]))),e[ia]}_close(e){this.nextTick(e)}[_s](){this[Jt]="closed",this.db.detachResource(this);let e=this[po];this[po]=[];for(let r of e)r()}};By.AbstractChainedBatch=zd});var Ry=z(Dy=>{"use strict";var U8=f(h()),{AbstractChainedBatch:E1}=Gd(),v1=sr(),yo=Symbol("encoded"),Jd=class extends E1{constructor(e){super(e),this[yo]=[]}_put(e,r,n){this[yo].push({...n,type:"put",key:e,value:r})}_del(e,r){this[yo].push({...r,type:"del",key:e})}_clear(){this[yo]=[]}_write(e,r){this.db.status==="opening"?this.db.defer(()=>this._write(e,r)):this.db.status==="open"?this[yo].length===0?this.nextTick(r):this.db._batch(this[yo],e,r):this.nextTick(r,new v1("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};Dy.DefaultChainedBatch=Jd});var Cy=z((C8,Uy)=>{"use strict";var P8=f(h()),Oy=sr(),S1=Object.prototype.hasOwnProperty,A1=new Set(["lt","lte","gt","gte"]);Uy.exports=function(t,e){let r={};for(let n in t)if(S1.call(t,n)&&!(n==="keyEncoding"||n==="valueEncoding")){if(n==="start"||n==="end")throw new Oy(`The legacy range option '${n}' has been removed`,{code:"LEVEL_LEGACY"});if(n==="encoding")throw new Oy("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});A1.has(n)?r[n]=e.encode(t[n]):r[n]=t[n]}return r.reverse=!!r.reverse,r.limit=Number.isInteger(r.limit)&&r.limit>=0?r.limit:-1,r}});var Yd=z((k8,ky)=>{var K8=f(h());var Py;ky.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):t=>(Py||(Py=Promise.resolve())).then(t).catch(e=>setTimeout(()=>{throw e},0))});var My=z((L8,Ly)=>{"use strict";var M8=f(h()),Ky=Yd();Ly.exports=function(t,...e){e.length===0?Ky(t):Ky(()=>t(...e))}});var Ny=z(oa=>{"use strict";var $8=f(h()),{AbstractIterator:T1,AbstractKeyIterator:_1,AbstractValueIterator:I1}=On(),mo=Symbol("unfix"),cr=Symbol("iterator"),hi=Symbol("handleOne"),Un=Symbol("handleMany"),Xr=Symbol("callback"),Is=class extends T1{constructor(e,r,n,i){super(e,r),this[cr]=n,this[mo]=i,this[hi]=this[hi].bind(this),this[Un]=this[Un].bind(this),this[Xr]=null}[hi](e,r,n){let i=this[Xr];if(e)return i(e);r!==void 0&&(r=this[mo](r)),i(e,r,n)}[Un](e,r){let n=this[Xr];if(e)return n(e);for(let i of r){let o=i[0];o!==void 0&&(i[0]=this[mo](o))}n(e,r)}},Bs=class extends _1{constructor(e,r,n,i){super(e,r),this[cr]=n,this[mo]=i,this[hi]=this[hi].bind(this),this[Un]=this[Un].bind(this),this[Xr]=null}[hi](e,r){let n=this[Xr];if(e)return n(e);r!==void 0&&(r=this[mo](r)),n(e,r)}[Un](e,r){let n=this[Xr];if(e)return n(e);for(let i=0;i{"use strict";var F8=f(h()),Xd=sr(),{Buffer:el}=At()||{},{AbstractSublevelIterator:B1,AbstractSublevelKeyIterator:D1,AbstractSublevelValueIterator:R1}=Ny(),Zr=Symbol("prefix"),$y=Symbol("upperBound"),Rs=Symbol("prefixRange"),Kt=Symbol("parent"),Zd=Symbol("unfix"),qy=new TextEncoder,O1={separator:"!"};Fy.exports=function({AbstractLevel:t}){class e extends t{static defaults(n){if(typeof n=="string")throw new Xd("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(n&&n.open)throw new Xd("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return n==null?O1:n.separator?n:{...n,separator:"!"}}constructor(n,i,o){let{separator:s,manifest:c,...a}=e.defaults(o);i=C1(i,s);let d=s.charCodeAt(0)+1,u=n[Kt]||n;if(!qy.encode(i).every(g=>g>d&&g<127))throw new Xd(`Prefix must use bytes > ${d} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(U1(u,c),a);let l=(n.prefix||"")+s+i+s,y=l.slice(0,-1)+String.fromCharCode(d);this[Kt]=u,this[Zr]=new sa(l),this[$y]=new sa(y),this[Zd]=new tl,this.nextTick=u.nextTick}prefixKey(n,i){if(i==="utf8")return this[Zr].utf8+n;if(n.byteLength===0)return this[Zr][i];if(i==="view"){let o=this[Zr].view,s=new Uint8Array(o.byteLength+n.byteLength);return s.set(o,0),s.set(n,o.byteLength),s}else{let o=this[Zr].buffer;return el.concat([o,n],o.byteLength+n.byteLength)}}[Rs](n,i){n.gte!==void 0?n.gte=this.prefixKey(n.gte,i):n.gt!==void 0?n.gt=this.prefixKey(n.gt,i):n.gte=this[Zr][i],n.lte!==void 0?n.lte=this.prefixKey(n.lte,i):n.lt!==void 0?n.lt=this.prefixKey(n.lt,i):n.lte=this[$y][i]}get prefix(){return this[Zr].utf8}get db(){return this[Kt]}_open(n,i){this[Kt].open({passive:!0},i)}_put(n,i,o,s){this[Kt].put(n,i,o,s)}_get(n,i,o){this[Kt].get(n,i,o)}_getMany(n,i,o){this[Kt].getMany(n,i,o)}_del(n,i,o){this[Kt].del(n,i,o)}_batch(n,i,o){this[Kt].batch(n,i,o)}_clear(n,i){this[Rs](n,n.keyEncoding),this[Kt].clear(n,i)}_iterator(n){this[Rs](n,n.keyEncoding);let i=this[Kt].iterator(n),o=this[Zd].get(this[Zr].utf8.length,n.keyEncoding);return new B1(this,n,i,o)}_keys(n){this[Rs](n,n.keyEncoding);let i=this[Kt].keys(n),o=this[Zd].get(this[Zr].utf8.length,n.keyEncoding);return new D1(this,n,i,o)}_values(n){this[Rs](n,n.keyEncoding);let i=this[Kt].values(n);return new R1(this,n,i)}}return{AbstractSublevel:e}};var U1=function(t,e){return{...t.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...e,encodings:{utf8:Qd(t,"utf8"),buffer:Qd(t,"buffer"),view:Qd(t,"view")}}},Qd=function(t,e){return t.supports.encodings[e]?t.keyEncoding(e).name===e:!1},sa=class{constructor(e){this.utf8=e,this.view=qy.encode(e),this.buffer=el?el.from(this.view.buffer,0,this.view.byteLength):{}}},tl=class{constructor(){this.cache=new Map}get(e,r){let n=this.cache.get(r);return n===void 0&&(r==="view"?n=(function(i,o){return o.subarray(i)}).bind(null,e):n=(function(i,o){return o.slice(i)}).bind(null,e),this.cache.set(r,n)),n}},C1=function(t,e){let r=0,n=t.length;for(;rr&&t[n-1]===e;)n--;return t.slice(r,n)}});var sl=z(ol=>{"use strict";var H8=f(h()),{supports:P1}=Qp(),{Transcoder:k1}=uy(),{EventEmitter:K1}=bs(),{fromCallback:Cn}=xs(),ar=sr(),{AbstractIterator:pi}=On(),{DefaultKeyIterator:L1,DefaultValueIterator:M1}=Ty(),{DeferredIterator:N1,DeferredKeyIterator:$1,DeferredValueIterator:q1}=_y(),{DefaultChainedBatch:Hy}=Ry(),{getCallback:yi,getOptions:Pn}=jc(),ca=Cy(),fe=Symbol("promise"),Qr=Symbol("landed"),mi=Symbol("resources"),rl=Symbol("closeResources"),Os=Symbol("operations"),Us=Symbol("undefer"),aa=Symbol("deferOpen"),jy=Symbol("options"),pe=Symbol("status"),gi=Symbol("defaultOptions"),go=Symbol("transcoder"),ua=Symbol("keyEncoding"),nl=Symbol("valueEncoding"),F1=()=>{},Cs=class extends K1{constructor(e,r){if(super(),typeof e!="object"||e===null)throw new TypeError("The first argument 'manifest' must be an object");r=Pn(r);let{keyEncoding:n,valueEncoding:i,passive:o,...s}=r;this[mi]=new Set,this[Os]=[],this[aa]=!0,this[jy]=s,this[pe]="opening",this.supports=P1(e,{status:!0,promises:!0,clear:!0,getMany:!0,deferredOpen:!0,snapshots:e.snapshots!==!1,permanence:e.permanence!==!1,keyIterator:!0,valueIterator:!0,iteratorNextv:!0,iteratorAll:!0,encodings:e.encodings||{},events:Object.assign({},e.events,{opening:!0,open:!0,closing:!0,closed:!0,put:!0,del:!0,batch:!0,clear:!0})}),this[go]=new k1(V1(this)),this[ua]=this[go].encoding(n||"utf8"),this[nl]=this[go].encoding(i||"utf8");for(let c of this[go].encodings())this.supports.encodings[c.commonName]||(this.supports.encodings[c.commonName]=!0);this[gi]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[ua].commonName,valueEncoding:this[nl].commonName}),key:Object.freeze({keyEncoding:this[ua].commonName})},this.nextTick(()=>{this[aa]&&this.open({passive:!1},F1)})}get status(){return this[pe]}keyEncoding(e){return this[go].encoding(e??this[ua])}valueEncoding(e){return this[go].encoding(e??this[nl])}open(e,r){r=yi(e,r),r=Cn(r,fe),e={...this[jy],...Pn(e)},e.createIfMissing=e.createIfMissing!==!1,e.errorIfExists=!!e.errorIfExists;let n=i=>{this[pe]==="closing"||this[pe]==="opening"?this.once(Qr,i?()=>n(i):n):this[pe]!=="open"?r(new ar("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):r()};return e.passive?this[pe]==="opening"?this.once(Qr,n):this.nextTick(n):this[pe]==="closed"||this[aa]?(this[aa]=!1,this[pe]="opening",this.emit("opening"),this._open(e,i=>{if(i){this[pe]="closed",this[rl](()=>{this.emit(Qr),n(i)}),this[Us]();return}this[pe]="open",this[Us](),this.emit(Qr),this[pe]==="open"&&this.emit("open"),this[pe]==="open"&&this.emit("ready"),n()})):this[pe]==="open"?this.nextTick(n):this.once(Qr,()=>this.open(e,r)),r[fe]}_open(e,r){this.nextTick(r)}close(e){e=Cn(e,fe);let r=n=>{this[pe]==="opening"||this[pe]==="closing"?this.once(Qr,n?r(n):r):this[pe]!=="closed"?e(new ar("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):e()};if(this[pe]==="open"){this[pe]="closing",this.emit("closing");let n=i=>{this[pe]="open",this[Us](),this.emit(Qr),r(i)};this[rl](()=>{this._close(i=>{if(i)return n(i);this[pe]="closed",this[Us](),this.emit(Qr),this[pe]==="closed"&&this.emit("closed"),r()})})}else this[pe]==="closed"?this.nextTick(r):this.once(Qr,()=>this.close(e));return e[fe]}[rl](e){if(this[mi].size===0)return this.nextTick(e);let r=this[mi].size,n=!0,i=()=>{--r===0&&(n?this.nextTick(e):e())};for(let o of this[mi])o.close(i);n=!1,this[mi].clear()}_close(e){this.nextTick(e)}get(e,r,n){if(n=yi(r,n),n=Cn(n,fe),r=Pn(r,this[gi].entry),this[pe]==="opening")return this.defer(()=>this.get(e,r,n)),n[fe];if(wo(this,n))return n[fe];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[fe];let o=this.keyEncoding(r.keyEncoding),s=this.valueEncoding(r.valueEncoding),c=o.format,a=s.format;return(r.keyEncoding!==c||r.valueEncoding!==a)&&(r=Object.assign({},r,{keyEncoding:c,valueEncoding:a})),this._get(this.prefixKey(o.encode(e),c),r,(d,u)=>{if(d)return(d.code==="LEVEL_NOT_FOUND"||d.notFound||/NotFound/i.test(d))&&(d.code||(d.code="LEVEL_NOT_FOUND"),d.notFound||(d.notFound=!0),d.status||(d.status=404)),n(d);try{u=s.decode(u)}catch(l){return n(new ar("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:l}))}n(null,u)}),n[fe]}_get(e,r,n){this.nextTick(n,new Error("NotFound"))}getMany(e,r,n){if(n=yi(r,n),n=Cn(n,fe),r=Pn(r,this[gi].entry),this[pe]==="opening")return this.defer(()=>this.getMany(e,r,n)),n[fe];if(wo(this,n))return n[fe];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[fe];if(e.length===0)return this.nextTick(n,null,[]),n[fe];let i=this.keyEncoding(r.keyEncoding),o=this.valueEncoding(r.valueEncoding),s=i.format,c=o.format;(r.keyEncoding!==s||r.valueEncoding!==c)&&(r=Object.assign({},r,{keyEncoding:s,valueEncoding:c}));let a=new Array(e.length);for(let d=0;d{if(d)return n(d);try{for(let l=0;lthis.put(e,r,n,i)),i[fe];if(wo(this,i))return i[fe];let o=this._checkKey(e)||this._checkValue(r);if(o)return this.nextTick(i,o),i[fe];let s=this.keyEncoding(n.keyEncoding),c=this.valueEncoding(n.valueEncoding),a=s.format,d=c.format;(n.keyEncoding!==a||n.valueEncoding!==d)&&(n=Object.assign({},n,{keyEncoding:a,valueEncoding:d}));let u=this.prefixKey(s.encode(e),a),l=c.encode(r);return this._put(u,l,n,y=>{if(y)return i(y);this.emit("put",e,r),i()}),i[fe]}_put(e,r,n,i){this.nextTick(i)}del(e,r,n){if(n=yi(r,n),n=Cn(n,fe),r=Pn(r,this[gi].key),this[pe]==="opening")return this.defer(()=>this.del(e,r,n)),n[fe];if(wo(this,n))return n[fe];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[fe];let o=this.keyEncoding(r.keyEncoding),s=o.format;return r.keyEncoding!==s&&(r=Object.assign({},r,{keyEncoding:s})),this._del(this.prefixKey(o.encode(e),s),r,c=>{if(c)return n(c);this.emit("del",e),n()}),n[fe]}_del(e,r,n){this.nextTick(n)}batch(e,r,n){if(!arguments.length){if(this[pe]==="opening")return new Hy(this);if(this[pe]!=="open")throw new ar("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof e=="function"?n=e:n=yi(r,n),n=Cn(n,fe),r=Pn(r,this[gi].empty),this[pe]==="opening")return this.defer(()=>this.batch(e,r,n)),n[fe];if(wo(this,n))return n[fe];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[fe];if(e.length===0)return this.nextTick(n),n[fe];let i=new Array(e.length),{keyEncoding:o,valueEncoding:s,...c}=r;for(let a=0;a{if(a)return n(a);this.emit("batch",e),n()}),n[fe]}_batch(e,r,n){this.nextTick(n)}sublevel(e,r){return this._sublevel(e,il.defaults(r))}_sublevel(e,r){return new il(this,e,r)}prefixKey(e,r){return e}clear(e,r){if(r=yi(e,r),r=Cn(r,fe),e=Pn(e,this[gi].empty),this[pe]==="opening")return this.defer(()=>this.clear(e,r)),r[fe];if(wo(this,r))return r[fe];let n=e,i=this.keyEncoding(e.keyEncoding);return e=ca(e,i),e.keyEncoding=i.format,e.limit===0?this.nextTick(r):this._clear(e,o=>{if(o)return r(o);this.emit("clear",n),r()}),r[fe]}_clear(e,r){this.nextTick(r)}iterator(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=ca(e,r),e.keys=e.keys!==!1,e.values=e.values!==!1,e[pi.keyEncoding]=r,e[pi.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[pe]==="opening")return new N1(this,e);if(this[pe]!=="open")throw new ar("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(e)}_iterator(e){return new pi(this,e)}keys(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=ca(e,r),e[pi.keyEncoding]=r,e[pi.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[pe]==="opening")return new $1(this,e);if(this[pe]!=="open")throw new ar("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(e)}_keys(e){return new L1(this,e)}values(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=ca(e,r),e[pi.keyEncoding]=r,e[pi.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[pe]==="opening")return new q1(this,e);if(this[pe]!=="open")throw new ar("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(e)}_values(e){return new M1(this,e)}defer(e){if(typeof e!="function")throw new TypeError("The first argument must be a function");this[Os].push(e)}[Us](){if(this[Os].length===0)return;let e=this[Os];this[Os]=[];for(let r of e)r()}attachResource(e){if(typeof e!="object"||e===null||typeof e.close!="function")throw new TypeError("The first argument must be a resource object");this[mi].add(e)}detachResource(e){this[mi].delete(e)}_chainedBatch(){return new Hy(this)}_checkKey(e){if(e==null)return new ar("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(e){if(e==null)return new ar("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};Cs.prototype.nextTick=My();var{AbstractSublevel:il}=Vy()({AbstractLevel:Cs});ol.AbstractLevel=Cs;ol.AbstractSublevel=il;var wo=function(t,e){return t[pe]!=="open"?(t.nextTick(e,new ar("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},V1=function(t){return Object.keys(t.supports.encodings).filter(e=>!!t.supports.encodings[e])}});var cl=z(wi=>{"use strict";var W8=f(h());wi.AbstractLevel=sl().AbstractLevel;wi.AbstractSublevel=sl().AbstractSublevel;wi.AbstractIterator=On().AbstractIterator;wi.AbstractKeyIterator=On().AbstractKeyIterator;wi.AbstractValueIterator=On().AbstractValueIterator;wi.AbstractChainedBatch=Gd().AbstractChainedBatch});var zy=z((z8,Wy)=>{var G8=f(h());Wy.exports=j1;var H1=Yd();function j1(t,e,r){if(typeof e!="number")throw new Error("second argument must be a Number");let n,i,o,s,c,a=!0,d;Array.isArray(t)?(n=[],o=i=t.length):(s=Object.keys(t),n={},o=i=s.length);function u(y){function g(){r&&r(y,n),r=null}a?H1(g):g()}function l(y,g,p){if(n[y]=p,g&&(c=!0),--o===0||g)u(g);else if(!c&&d{"use strict";var Y8=f(h());Gy.exports=function(e){let r=e.gte!==void 0?e.gte:e.gt!==void 0?e.gt:void 0,n=e.lte!==void 0?e.lte:e.lt!==void 0?e.lt:void 0,i=e.gte===void 0,o=e.lte===void 0;return r!==void 0&&n!==void 0?IDBKeyRange.bound(r,n,i,o):r!==void 0?IDBKeyRange.lowerBound(r,i):n!==void 0?IDBKeyRange.upperBound(n,o):null}});var ul=z((X8,Jy)=>{"use strict";var Z8=f(h()),W1=new TextEncoder;Jy.exports=function(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):W1.encode(t)}});var e0=z(Qy=>{"use strict";var eR=f(h()),{AbstractIterator:z1}=cl(),Yy=al(),da=ul(),Tr=Symbol("cache"),en=Symbol("finished"),Lt=Symbol("options"),tn=Symbol("currentOptions"),bi=Symbol("position"),dl=Symbol("location"),bo=Symbol("first"),Xy={},ll=class extends z1{constructor(e,r,n){super(e,n),this[Tr]=[],this[en]=this.limit===0,this[Lt]=n,this[tn]={...n},this[bi]=void 0,this[dl]=r,this[bo]=!0}_nextv(e,r,n){if(this[bo]=!1,this[en])return this.nextTick(n,null,[]);if(this[Tr].length>0)return e=Math.min(e,this[Tr].length),this.nextTick(n,null,this[Tr].splice(0,e));this[bi]!==void 0&&(this[Lt].reverse?(this[tn].lt=this[bi],this[tn].lte=void 0):(this[tn].gt=this[bi],this[tn].gte=void 0));let i;try{i=Yy(this[tn])}catch{return this[en]=!0,this.nextTick(n,null,[])}let o=this.db.db.transaction([this[dl]],"readonly"),s=o.objectStore(this[dl]),c=[];if(this[Lt].reverse){let a=!this[Lt].values&&s.openKeyCursor?"openKeyCursor":"openCursor";s[a](i,"prev").onsuccess=d=>{let u=d.target.result;if(u){let{key:l,value:y}=u;this[bi]=l,c.push([this[Lt].keys&&l!==void 0?da(l):void 0,this[Lt].values&&y!==void 0?da(y):void 0]),c.length{if(a===void 0||d===void 0)return;let l=Math.max(a.length,d.length);l===0||e===1/0?this[en]=!0:this[bi]=a[l-1],c.length=l;for(let y=0;y{a=l.target.result,u()}:(a=[],this.nextTick(u)),this[Lt].values?s.getAll(i,e<1/0?e:void 0).onsuccess=l=>{d=l.target.result,u()}:(d=[],this.nextTick(u))}o.onabort=()=>{n(o.error||new Error("aborted by user")),n=null},o.oncomplete=()=>{n(null,c),n=null}}_next(e){if(this[Tr].length>0){let[r,n]=this[Tr].shift();this.nextTick(e,null,r,n)}else if(this[en])this.nextTick(e);else{let r=Math.min(100,this.limit-this.count);this[bo]&&(this[bo]=!1,r=1),this._nextv(r,Xy,(n,i)=>{if(n)return e(n);this[Tr]=i,this._next(e)})}}_all(e,r){this[bo]=!1;let n=this[Tr].splice(0,this[Tr].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(r,null,n);this._nextv(i,Xy,(o,s)=>{if(o)return r(o);n.length>0&&(s=n.concat(s)),r(null,s)})}_seek(e,r){this[bo]=!0,this[Tr]=[],this[en]=!1,this[bi]=void 0,this[tn]={...this[Lt]};let n;try{n=Yy(this[Lt])}catch{this[en]=!0;return}n!==null&&!n.includes(e)?this[en]=!0:this[Lt].reverse?this[tn].lte=e:this[tn].gte=e}};Qy.Iterator=ll;function Zy(t){typeof t.commit=="function"&&t.commit()}});var r0=z((tR,t0)=>{"use strict";var rR=f(h());t0.exports=function(e,r,n,i,o){if(i.limit===0)return e.nextTick(o);let s=e.db.transaction([r],"readwrite"),c=s.objectStore(r),a=0;s.oncomplete=function(){o()},s.onabort=function(){o(s.error||new Error("aborted by user"))};let d=c.openKeyCursor?"openKeyCursor":"openCursor",u=i.reverse?"prev":"next";c[d](n,u).onsuccess=function(l){let y=l.target.result;y&&(c.delete(y.key).onsuccess=function(){(i.limit<=0||++a{"use strict";var iR=f(h()),{AbstractLevel:G1}=cl(),n0=sr(),J1=zy(),{fromCallback:Y1}=xs(),{Iterator:X1}=e0(),i0=ul(),Z1=r0(),Q1=al(),s0="level-js-",Ps=Symbol("idb"),fl=Symbol("namePrefix"),rn=Symbol("location"),hl=Symbol("version"),xi=Symbol("store"),ks=Symbol("onComplete"),o0=Symbol("promise"),la=class extends G1{constructor(e,r,n){if(typeof r=="function"||typeof n=="function")throw new n0("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});let{prefix:i,version:o,...s}=r||{};if(super({encodings:{view:!0},snapshots:!1,createIfMissing:!1,errorIfExists:!1,seek:!0},s),typeof e!="string")throw new Error("constructor requires a location string argument");this[rn]=e,this[fl]=i??s0,this[hl]=parseInt(o||1,10),this[Ps]=null}get location(){return this[rn]}get namePrefix(){return this[fl]}get version(){return this[hl]}get db(){return this[Ps]}get type(){return"browser-level"}_open(e,r){let n=indexedDB.open(this[fl]+this[rn],this[hl]);n.onerror=function(){r(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[Ps]=n.result,r()},n.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[rn])||o.createObjectStore(this[rn])}}[xi](e){return this[Ps].transaction([this[rn]],e).objectStore(this[rn])}[ks](e,r){let n=e.transaction;n.onabort=function(){r(n.error||new Error("aborted by user"))},n.oncomplete=function(){r(null,e.result)}}_get(e,r,n){let i=this[xi]("readonly"),o;try{o=i.get(e)}catch(s){return this.nextTick(n,s)}this[ks](o,function(s,c){if(s)return n(s);if(c===void 0)return n(new n0("Entry not found",{code:"LEVEL_NOT_FOUND"}));n(null,i0(c))})}_getMany(e,r,n){let i=this[xi]("readonly"),o=e.map(s=>c=>{let a;try{a=i.get(s)}catch(d){return c(d)}a.onsuccess=()=>{let d=a.result;c(null,d===void 0?d:i0(d))},a.onerror=d=>{d.stopPropagation(),c(a.error)}});J1(o,16,n)}_del(e,r,n){let i=this[xi]("readwrite"),o;try{o=i.delete(e)}catch(s){return this.nextTick(n,s)}this[ks](o,n)}_put(e,r,n,i){let o=this[xi]("readwrite"),s;try{s=o.put(r,e)}catch(c){return this.nextTick(i,c)}this[ks](s,i)}_iterator(e){return new X1(this,this[rn],e)}_batch(e,r,n){let i=this[xi]("readwrite"),o=i.transaction,s=0,c;o.onabort=function(){n(c||o.error||new Error("aborted by user"))},o.oncomplete=function(){n()};function a(){let d=e[s++],u=d.key,l;try{l=d.type==="del"?i.delete(u):i.put(d.value,u)}catch(y){c=y,o.abort();return}s=0)return Z1(this,this[rn],n,e,r);try{let o=this[xi]("readwrite");i=n?o.delete(n):o.clear()}catch(o){return this.nextTick(r,o)}this[ks](i,r)}_close(e){this[Ps].close(),this.nextTick(e)}};la.destroy=function(t,e,r){typeof e=="function"&&(r=e,e=s0),r=Y1(r,o0);let n=indexedDB.deleteDatabase(e+t);return n.onsuccess=function(){r()},n.onerror=function(i){r(i)},r[o0]};c0.BrowserLevel=la});var u0=z(a0=>{var sR=f(h());a0.Level=pl().BrowserLevel});var ze=z((fR,d0)=>{"use strict";var hR=f(h());d0.exports={ArrayIsArray(t){return Array.isArray(t)},ArrayPrototypeIncludes(t,e){return t.includes(e)},ArrayPrototypeIndexOf(t,e){return t.indexOf(e)},ArrayPrototypeJoin(t,e){return t.join(e)},ArrayPrototypeMap(t,e){return t.map(e)},ArrayPrototypePop(t,e){return t.pop(e)},ArrayPrototypePush(t,e){return t.push(e)},ArrayPrototypeSlice(t,e,r){return t.slice(e,r)},Error,FunctionPrototypeCall(t,e,...r){return t.call(e,...r)},FunctionPrototypeSymbolHasInstance(t,e){return Function.prototype[Symbol.hasInstance].call(t,e)},MathFloor:Math.floor,Number,NumberIsInteger:Number.isInteger,NumberIsNaN:Number.isNaN,NumberMAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,NumberMIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,NumberParseInt:Number.parseInt,ObjectDefineProperties(t,e){return Object.defineProperties(t,e)},ObjectDefineProperty(t,e,r){return Object.defineProperty(t,e,r)},ObjectGetOwnPropertyDescriptor(t,e){return Object.getOwnPropertyDescriptor(t,e)},ObjectKeys(t){return Object.keys(t)},ObjectSetPrototypeOf(t,e){return Object.setPrototypeOf(t,e)},Promise,PromisePrototypeCatch(t,e){return t.catch(e)},PromisePrototypeThen(t,e,r){return t.then(e,r)},PromiseReject(t){return Promise.reject(t)},ReflectApply:Reflect.apply,RegExpPrototypeTest(t,e){return t.test(e)},SafeSet:Set,String,StringPrototypeSlice(t,e,r){return t.slice(e,r)},StringPrototypeToLowerCase(t){return t.toLowerCase()},StringPrototypeToUpperCase(t){return t.toUpperCase()},StringPrototypeTrim(t){return t.trim()},Symbol,SymbolFor:Symbol.for,SymbolAsyncIterator:Symbol.asyncIterator,SymbolHasInstance:Symbol.hasInstance,SymbolIterator:Symbol.iterator,TypedArrayPrototypeSet(t,e,r){return t.set(e,r)},Uint8Array}});var _r=z((pR,ml)=>{"use strict";var yR=f(h()),tv=At(),rv=Object.getPrototypeOf(async function(){}).constructor,l0=globalThis.Blob||tv.Blob,nv=typeof l0<"u"?function(e){return e instanceof l0}:function(e){return!1},yl=class extends Error{constructor(e){if(!Array.isArray(e))throw new TypeError(`Expected input to be an Array, got ${typeof e}`);let r="";for(let n=0;n{t=n,e=i}),resolve:t,reject:e}},promisify(t){return new Promise((e,r)=>{t((n,...i)=>n?r(n):e(...i))})},debuglog(){return function(){}},format(t,...e){return t.replace(/%([sdifj])/g,function(...[r,n]){let i=e.shift();return n==="f"?i.toFixed(6):n==="j"?JSON.stringify(i):n==="s"&&typeof i=="object"?`${i.constructor!==Object?i.constructor.name:""} {}`.trim():i.toString()})},inspect(t){switch(typeof t){case"string":if(t.includes("'"))if(t.includes('"')){if(!t.includes("`")&&!t.includes("${"))return`\`${t}\``}else return`"${t}"`;return`'${t}'`;case"number":return isNaN(t)?"NaN":Object.is(t,-0)?String(t):t;case"bigint":return`${String(t)}n`;case"boolean":case"undefined":return String(t);case"object":return"{}"}},types:{isAsyncFunction(t){return t instanceof rv},isArrayBufferView(t){return ArrayBuffer.isView(t)}},isBlob:nv};ml.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")});var pa=z((mR,ha)=>{"use strict";var gR=f(h()),{AbortController:f0,AbortSignal:iv}=typeof self<"u"?self:typeof window<"u"?window:void 0;ha.exports=f0;ha.exports.AbortSignal=iv;ha.exports.default=f0});var wt=z((wR,y0)=>{"use strict";var bR=f(h()),{format:ov,inspect:ya,AggregateError:sv}=_r(),cv=globalThis.AggregateError||sv,av=Symbol("kIsNodeError"),uv=["string","function","number","object","Function","Object","boolean","bigint","symbol"],dv=/^([A-Z][a-z0-9]*)+$/,lv="__node_internal_",ma={};function vi(t,e){if(!t)throw new ma.ERR_INTERNAL_ASSERTION(e)}function h0(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function fv(t,e,r){if(typeof e=="function")return vi(e.length<=r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${e.length}).`),e(...r);let n=(e.match(/%[dfijoOs]/g)||[]).length;return vi(n===r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),r.length===0?e:ov(e,...r)}function ct(t,e,r){r||(r=Error);class n extends r{constructor(...o){super(fv(t,e,o))}toString(){return`${this.name} [${t}]: ${this.message}`}}Object.defineProperties(n.prototype,{name:{value:r.name,writable:!0,enumerable:!1,configurable:!0},toString:{value(){return`${this.name} [${t}]: ${this.message}`},writable:!0,enumerable:!1,configurable:!0}}),n.prototype.code=t,n.prototype[av]=!0,ma[t]=n}function p0(t){let e=lv+t.name;return Object.defineProperty(t,"name",{value:e}),t}function hv(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;let r=new cv([e,t],e.message);return r.code=e.code,r}return t||e}var gl=class extends Error{constructor(e="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new ma.ERR_INVALID_ARG_TYPE("options","Object",r);super(e,r),this.code="ABORT_ERR",this.name="AbortError"}};ct("ERR_ASSERTION","%s",Error);ct("ERR_INVALID_ARG_TYPE",(t,e,r)=>{vi(typeof t=="string","'name' must be a string"),Array.isArray(e)||(e=[e]);let n="The ";t.endsWith(" argument")?n+=`${t} `:n+=`"${t}" ${t.includes(".")?"property":"argument"} `,n+="must be ";let i=[],o=[],s=[];for(let a of e)vi(typeof a=="string","All expected entries have to be of type string"),uv.includes(a)?i.push(a.toLowerCase()):dv.test(a)?o.push(a):(vi(a!=="object",'The value "object" should be written as "Object"'),s.push(a));if(o.length>0){let a=i.indexOf("object");a!==-1&&(i.splice(i,a,1),o.push("Object"))}if(i.length>0){switch(i.length){case 1:n+=`of type ${i[0]}`;break;case 2:n+=`one of type ${i[0]} or ${i[1]}`;break;default:{let a=i.pop();n+=`one of type ${i.join(", ")}, or ${a}`}}(o.length>0||s.length>0)&&(n+=" or ")}if(o.length>0){switch(o.length){case 1:n+=`an instance of ${o[0]}`;break;case 2:n+=`an instance of ${o[0]} or ${o[1]}`;break;default:{let a=o.pop();n+=`an instance of ${o.join(", ")}, or ${a}`}}s.length>0&&(n+=" or ")}switch(s.length){case 0:break;case 1:s[0].toLowerCase()!==s[0]&&(n+="an "),n+=`${s[0]}`;break;case 2:n+=`one of ${s[0]} or ${s[1]}`;break;default:{let a=s.pop();n+=`one of ${s.join(", ")}, or ${a}`}}if(r==null)n+=`. Received ${r}`;else if(typeof r=="function"&&r.name)n+=`. Received function ${r.name}`;else if(typeof r=="object"){var c;if((c=r.constructor)!==null&&c!==void 0&&c.name)n+=`. Received an instance of ${r.constructor.name}`;else{let a=ya(r,{depth:-1});n+=`. Received ${a}`}}else{let a=ya(r,{colors:!1});a.length>25&&(a=`${a.slice(0,25)}...`),n+=`. Received type ${typeof r} (${a})`}return n},TypeError);ct("ERR_INVALID_ARG_VALUE",(t,e,r="is invalid")=>{let n=ya(e);return n.length>128&&(n=n.slice(0,128)+"..."),`The ${t.includes(".")?"property":"argument"} '${t}' ${r}. Received ${n}`},TypeError);ct("ERR_INVALID_RETURN_VALUE",(t,e,r)=>{var n;let i=r!=null&&(n=r.constructor)!==null&&n!==void 0&&n.name?`instance of ${r.constructor.name}`:`type ${typeof r}`;return`Expected ${t} to be returned from the "${e}" function but got ${i}.`},TypeError);ct("ERR_MISSING_ARGS",(...t)=>{vi(t.length>0,"At least one arg needs to be specified");let e,r=t.length;switch(t=(Array.isArray(t)?t:[t]).map(n=>`"${n}"`).join(" or "),r){case 1:e+=`The ${t[0]} argument`;break;case 2:e+=`The ${t[0]} and ${t[1]} arguments`;break;default:{let n=t.pop();e+=`The ${t.join(", ")}, and ${n} arguments`}break}return`${e} must be specified`},TypeError);ct("ERR_OUT_OF_RANGE",(t,e,r)=>{vi(e,'Missing "range" argument');let n;return Number.isInteger(r)&&Math.abs(r)>2**32?n=h0(String(r)):typeof r=="bigint"?(n=String(r),(r>2n**32n||r<-(2n**32n))&&(n=h0(n)),n+="n"):n=ya(r),`The value of "${t}" is out of range. It must be ${e}. Received ${n}`},RangeError);ct("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error);ct("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error);ct("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error);ct("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error);ct("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error);ct("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);ct("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error);ct("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error);ct("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error);ct("ERR_STREAM_WRITE_AFTER_END","write after end",Error);ct("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);y0.exports={AbortError:gl,aggregateTwoErrors:p0(hv),hideStackFrames:p0,codes:ma}});var Ks=z((xR,A0)=>{"use strict";var ER=f(h()),{ArrayIsArray:bl,ArrayPrototypeIncludes:b0,ArrayPrototypeJoin:x0,ArrayPrototypeMap:pv,NumberIsInteger:xl,NumberIsNaN:yv,NumberMAX_SAFE_INTEGER:mv,NumberMIN_SAFE_INTEGER:gv,NumberParseInt:wv,ObjectPrototypeHasOwnProperty:bv,RegExpPrototypeExec:E0,String:xv,StringPrototypeToUpperCase:Ev,StringPrototypeTrim:vv}=ze(),{hideStackFrames:Yt,codes:{ERR_SOCKET_BAD_PORT:Sv,ERR_INVALID_ARG_TYPE:bt,ERR_INVALID_ARG_VALUE:xo,ERR_OUT_OF_RANGE:Si,ERR_UNKNOWN_SIGNAL:m0}}=wt(),{normalizeEncoding:Av}=_r(),{isAsyncFunction:Tv,isArrayBufferView:_v}=_r().types,g0={};function Iv(t){return t===(t|0)}function Bv(t){return t===t>>>0}var Dv=/^[0-7]+$/,Rv="must be a 32-bit unsigned integer or an octal string";function Ov(t,e,r){if(typeof t>"u"&&(t=r),typeof t=="string"){if(E0(Dv,t)===null)throw new xo(e,t,Rv);t=wv(t,8)}return v0(t,e),t}var Uv=Yt((t,e,r=gv,n=mv)=>{if(typeof t!="number")throw new bt(e,"number",t);if(!xl(t))throw new Si(e,"an integer",t);if(tn)throw new Si(e,`>= ${r} && <= ${n}`,t)}),Cv=Yt((t,e,r=-2147483648,n=2147483647)=>{if(typeof t!="number")throw new bt(e,"number",t);if(!xl(t))throw new Si(e,"an integer",t);if(tn)throw new Si(e,`>= ${r} && <= ${n}`,t)}),v0=Yt((t,e,r=!1)=>{if(typeof t!="number")throw new bt(e,"number",t);if(!xl(t))throw new Si(e,"an integer",t);let n=r?1:0,i=4294967295;if(ti)throw new Si(e,`>= ${n} && <= ${i}`,t)});function El(t,e){if(typeof t!="string")throw new bt(e,"string",t)}function Pv(t,e,r=void 0,n){if(typeof t!="number")throw new bt(e,"number",t);if(r!=null&&tn||(r!=null||n!=null)&&yv(t))throw new Si(e,`${r!=null?`>= ${r}`:""}${r!=null&&n!=null?" && ":""}${n!=null?`<= ${n}`:""}`,t)}var kv=Yt((t,e,r)=>{if(!b0(r,t)){let i="must be one of: "+x0(pv(r,o=>typeof o=="string"?`'${o}'`:xv(o)),", ");throw new xo(e,t,i)}});function S0(t,e){if(typeof t!="boolean")throw new bt(e,"boolean",t)}function wl(t,e,r){return t==null||!bv(t,e)?r:t[e]}var Kv=Yt((t,e,r=null)=>{let n=wl(r,"allowArray",!1),i=wl(r,"allowFunction",!1);if(!wl(r,"nullable",!1)&&t===null||!n&&bl(t)||typeof t!="object"&&(!i||typeof t!="function"))throw new bt(e,"Object",t)}),Lv=Yt((t,e)=>{if(t!=null&&typeof t!="object"&&typeof t!="function")throw new bt(e,"a dictionary",t)}),vl=Yt((t,e,r=0)=>{if(!bl(t))throw new bt(e,"Array",t);if(t.length{if(!_v(t))throw new bt(e,["Buffer","TypedArray","DataView"],t)});function Fv(t,e){let r=Av(e),n=t.length;if(r==="hex"&&n%2!==0)throw new xo("encoding",e,`is invalid for data of length ${n}`)}function Vv(t,e="Port",r=!0){if(typeof t!="number"&&typeof t!="string"||typeof t=="string"&&vv(t).length===0||+t!==+t>>>0||t>65535||t===0&&!r)throw new Sv(e,t,r);return t|0}var Hv=Yt((t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new bt(e,"AbortSignal",t)}),jv=Yt((t,e)=>{if(typeof t!="function")throw new bt(e,"Function",t)}),Wv=Yt((t,e)=>{if(typeof t!="function"||Tv(t))throw new bt(e,"Function",t)}),zv=Yt((t,e)=>{if(t!==void 0)throw new bt(e,"undefined",t)});function Gv(t,e,r){if(!b0(r,t))throw new bt(e,`('${x0(r,"|")}')`,t)}var Jv=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function w0(t,e){if(typeof t>"u"||!E0(Jv,t))throw new xo(e,t,'must be an array or string of format "; rel=preload; as=style"')}function Yv(t){if(typeof t=="string")return w0(t,"hints"),t;if(bl(t)){let e=t.length,r="";if(e===0)return r;for(let n=0;n; rel=preload; as=style"')}A0.exports={isInt32:Iv,isUint32:Bv,parseFileMode:Ov,validateArray:vl,validateStringArray:Mv,validateBooleanArray:Nv,validateBoolean:S0,validateBuffer:qv,validateDictionary:Lv,validateEncoding:Fv,validateFunction:jv,validateInt32:Cv,validateInteger:Uv,validateNumber:Pv,validateObject:Kv,validateOneOf:kv,validatePlainFunction:Wv,validatePort:Vv,validateSignalName:$v,validateString:El,validateUint32:v0,validateUndefined:zv,validateUnion:Gv,validateAbortSignal:Hv,validateLinkHeaderValue:Yv}});var kn=z((vR,B0)=>{var SR=f(h()),qe=B0.exports={},Ir,Br;function Sl(){throw new Error("setTimeout has not been defined")}function Al(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?Ir=setTimeout:Ir=Sl}catch{Ir=Sl}try{typeof clearTimeout=="function"?Br=clearTimeout:Br=Al}catch{Br=Al}})();function T0(t){if(Ir===setTimeout)return setTimeout(t,0);if((Ir===Sl||!Ir)&&setTimeout)return Ir=setTimeout,setTimeout(t,0);try{return Ir(t,0)}catch{try{return Ir.call(null,t,0)}catch{return Ir.call(this,t,0)}}}function Xv(t){if(Br===clearTimeout)return clearTimeout(t);if((Br===Al||!Br)&&clearTimeout)return Br=clearTimeout,clearTimeout(t);try{return Br(t)}catch{try{return Br.call(null,t)}catch{return Br.call(this,t)}}}var nn=[],Eo=!1,Ai,ga=-1;function Zv(){!Eo||!Ai||(Eo=!1,Ai.length?nn=Ai.concat(nn):ga=-1,nn.length&&_0())}function _0(){if(!Eo){var t=T0(Zv);Eo=!0;for(var e=nn.length;e;){for(Ai=nn,nn=[];++ga1)for(var r=1;r{"use strict";var TR=f(h()),{Symbol:wa,SymbolAsyncIterator:D0,SymbolIterator:R0,SymbolFor:O0}=ze(),U0=wa("kDestroyed"),C0=wa("kIsErrored"),Tl=wa("kIsReadable"),P0=wa("kIsDisturbed"),Qv=O0("nodejs.webstream.isClosedPromise"),e2=O0("nodejs.webstream.controllerErrorFunction");function ba(t,e=!1){var r;return!!(t&&typeof t.pipe=="function"&&typeof t.on=="function"&&(!e||typeof t.pause=="function"&&typeof t.resume=="function")&&(!t._writableState||((r=t._readableState)===null||r===void 0?void 0:r.readable)!==!1)&&(!t._writableState||t._readableState))}function xa(t){var e;return!!(t&&typeof t.write=="function"&&typeof t.on=="function"&&(!t._readableState||((e=t._writableState)===null||e===void 0?void 0:e.writable)!==!1))}function t2(t){return!!(t&&typeof t.pipe=="function"&&t._readableState&&typeof t.on=="function"&&typeof t.write=="function")}function Dr(t){return t&&(t._readableState||t._writableState||typeof t.write=="function"&&typeof t.on=="function"||typeof t.pipe=="function"&&typeof t.on=="function")}function k0(t){return!!(t&&!Dr(t)&&typeof t.pipeThrough=="function"&&typeof t.getReader=="function"&&typeof t.cancel=="function")}function K0(t){return!!(t&&!Dr(t)&&typeof t.getWriter=="function"&&typeof t.abort=="function")}function L0(t){return!!(t&&!Dr(t)&&typeof t.readable=="object"&&typeof t.writable=="object")}function r2(t){return k0(t)||K0(t)||L0(t)}function n2(t,e){return t==null?!1:e===!0?typeof t[D0]=="function":e===!1?typeof t[R0]=="function":typeof t[D0]=="function"||typeof t[R0]=="function"}function Ea(t){if(!Dr(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!!(t.destroyed||t[U0]||n!=null&&n.destroyed)}function M0(t){if(!xa(t))return null;if(t.writableEnded===!0)return!0;let e=t._writableState;return e!=null&&e.errored?!1:typeof e?.ended!="boolean"?null:e.ended}function i2(t,e){if(!xa(t))return null;if(t.writableFinished===!0)return!0;let r=t._writableState;return r!=null&&r.errored?!1:typeof r?.finished!="boolean"?null:!!(r.finished||e===!1&&r.ended===!0&&r.length===0)}function o2(t){if(!ba(t))return null;if(t.readableEnded===!0)return!0;let e=t._readableState;return!e||e.errored?!1:typeof e?.ended!="boolean"?null:e.ended}function N0(t,e){if(!ba(t))return null;let r=t._readableState;return r!=null&&r.errored?!1:typeof r?.endEmitted!="boolean"?null:!!(r.endEmitted||e===!1&&r.ended===!0&&r.length===0)}function $0(t){return t&&t[Tl]!=null?t[Tl]:typeof t?.readable!="boolean"?null:Ea(t)?!1:ba(t)&&t.readable&&!N0(t)}function q0(t){return typeof t?.writable!="boolean"?null:Ea(t)?!1:xa(t)&&t.writable&&!M0(t)}function s2(t,e){return Dr(t)?Ea(t)?!0:!(e?.readable!==!1&&$0(t)||e?.writable!==!1&&q0(t)):null}function c2(t){var e,r;return Dr(t)?t.writableErrored?t.writableErrored:(e=(r=t._writableState)===null||r===void 0?void 0:r.errored)!==null&&e!==void 0?e:null:null}function a2(t){var e,r;return Dr(t)?t.readableErrored?t.readableErrored:(e=(r=t._readableState)===null||r===void 0?void 0:r.errored)!==null&&e!==void 0?e:null:null}function u2(t){if(!Dr(t))return null;if(typeof t.closed=="boolean")return t.closed;let e=t._writableState,r=t._readableState;return typeof e?.closed=="boolean"||typeof r?.closed=="boolean"?e?.closed||r?.closed:typeof t._closed=="boolean"&&F0(t)?t._closed:null}function F0(t){return typeof t._closed=="boolean"&&typeof t._defaultKeepAlive=="boolean"&&typeof t._removedConnection=="boolean"&&typeof t._removedContLen=="boolean"}function V0(t){return typeof t._sent100=="boolean"&&F0(t)}function d2(t){var e;return typeof t._consuming=="boolean"&&typeof t._dumped=="boolean"&&((e=t.req)===null||e===void 0?void 0:e.upgradeOrConnect)===void 0}function l2(t){if(!Dr(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!n&&V0(t)||!!(n&&n.autoDestroy&&n.emitClose&&n.closed===!1)}function f2(t){var e;return!!(t&&((e=t[P0])!==null&&e!==void 0?e:t.readableDidRead||t.readableAborted))}function h2(t){var e,r,n,i,o,s,c,a,d,u;return!!(t&&((e=(r=(n=(i=(o=(s=t[C0])!==null&&s!==void 0?s:t.readableErrored)!==null&&o!==void 0?o:t.writableErrored)!==null&&i!==void 0?i:(c=t._readableState)===null||c===void 0?void 0:c.errorEmitted)!==null&&n!==void 0?n:(a=t._writableState)===null||a===void 0?void 0:a.errorEmitted)!==null&&r!==void 0?r:(d=t._readableState)===null||d===void 0?void 0:d.errored)!==null&&e!==void 0?e:!((u=t._writableState)===null||u===void 0)&&u.errored))}H0.exports={kDestroyed:U0,isDisturbed:f2,kIsDisturbed:P0,isErrored:h2,kIsErrored:C0,isReadable:$0,kIsReadable:Tl,kIsClosedPromise:Qv,kControllerErrorFunction:e2,isClosed:u2,isDestroyed:Ea,isDuplexNodeStream:t2,isFinished:s2,isIterable:n2,isReadableNodeStream:ba,isReadableStream:k0,isReadableEnded:o2,isReadableFinished:N0,isReadableErrored:a2,isNodeStream:Dr,isWebStream:r2,isWritable:q0,isWritableNodeStream:xa,isWritableStream:K0,isWritableEnded:M0,isWritableFinished:i2,isWritableErrored:c2,isServerRequest:d2,isServerResponse:V0,willEmitClose:l2,isTransformStream:L0}});var sn=z((_R,Rl)=>{var IR=f(h()),Kn=kn(),{AbortError:Q0,codes:p2}=wt(),{ERR_INVALID_ARG_TYPE:y2,ERR_STREAM_PREMATURE_CLOSE:j0}=p2,{kEmptyObject:Il,once:Bl}=_r(),{validateAbortSignal:m2,validateFunction:g2,validateObject:w2,validateBoolean:b2}=Ks(),{Promise:x2,PromisePrototypeThen:E2}=ze(),{isClosed:v2,isReadable:W0,isReadableNodeStream:_l,isReadableStream:S2,isReadableFinished:z0,isReadableErrored:G0,isWritable:J0,isWritableNodeStream:Y0,isWritableStream:A2,isWritableFinished:X0,isWritableErrored:Z0,isNodeStream:T2,willEmitClose:_2,kIsClosedPromise:I2}=Rr();function B2(t){return t.setHeader&&typeof t.abort=="function"}var Dl=()=>{};function em(t,e,r){var n,i;if(arguments.length===2?(r=e,e=Il):e==null?e=Il:w2(e,"options"),g2(r,"callback"),m2(e.signal,"options.signal"),r=Bl(r),S2(t)||A2(t))return D2(t,e,r);if(!T2(t))throw new y2("stream",["ReadableStream","WritableStream","Stream"],t);let o=(n=e.readable)!==null&&n!==void 0?n:_l(t),s=(i=e.writable)!==null&&i!==void 0?i:Y0(t),c=t._writableState,a=t._readableState,d=()=>{t.writable||y()},u=_2(t)&&_l(t)===o&&Y0(t)===s,l=X0(t,!1),y=()=>{l=!0,t.destroyed&&(u=!1),!(u&&(!t.readable||o))&&(!o||g)&&r.call(t)},g=z0(t,!1),p=()=>{g=!0,t.destroyed&&(u=!1),!(u&&(!t.writable||s))&&(!s||l)&&r.call(t)},w=D=>{r.call(t,D)},x=v2(t),S=()=>{x=!0;let D=Z0(t)||G0(t);if(D&&typeof D!="boolean")return r.call(t,D);if(o&&!g&&_l(t,!0)&&!z0(t,!1))return r.call(t,new j0);if(s&&!l&&!X0(t,!1))return r.call(t,new j0);r.call(t)},T=()=>{x=!0;let D=Z0(t)||G0(t);if(D&&typeof D!="boolean")return r.call(t,D);r.call(t)},E=()=>{t.req.on("finish",y)};B2(t)?(t.on("complete",y),u||t.on("abort",S),t.req?E():t.on("request",E)):s&&!c&&(t.on("end",d),t.on("close",d)),!u&&typeof t.aborted=="boolean"&&t.on("aborted",S),t.on("end",p),t.on("finish",y),e.error!==!1&&t.on("error",w),t.on("close",S),x?Kn.nextTick(S):c!=null&&c.errorEmitted||a!=null&&a.errorEmitted?u||Kn.nextTick(T):(!o&&(!u||W0(t))&&(l||J0(t)===!1)||!s&&(!u||J0(t))&&(g||W0(t)===!1)||a&&t.req&&t.aborted)&&Kn.nextTick(T);let R=()=>{r=Dl,t.removeListener("aborted",S),t.removeListener("complete",y),t.removeListener("abort",S),t.removeListener("request",E),t.req&&t.req.removeListener("finish",y),t.removeListener("end",d),t.removeListener("close",d),t.removeListener("finish",y),t.removeListener("end",p),t.removeListener("error",w),t.removeListener("close",S)};if(e.signal&&!x){let D=()=>{let O=r;R(),O.call(t,new Q0(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)Kn.nextTick(D);else{let O=r;r=Bl((...k)=>{e.signal.removeEventListener("abort",D),O.apply(t,k)}),e.signal.addEventListener("abort",D)}}return R}function D2(t,e,r){let n=!1,i=Dl;if(e.signal)if(i=()=>{n=!0,r.call(t,new Q0(void 0,{cause:e.signal.reason}))},e.signal.aborted)Kn.nextTick(i);else{let s=r;r=Bl((...c)=>{e.signal.removeEventListener("abort",i),s.apply(t,c)}),e.signal.addEventListener("abort",i)}let o=(...s)=>{n||Kn.nextTick(()=>r.apply(t,s))};return E2(t[I2].promise,o,o),Dl}function R2(t,e){var r;let n=!1;return e===null&&(e=Il),(r=e)!==null&&r!==void 0&&r.cleanup&&(b2(e.cleanup,"cleanup"),n=e.cleanup),new x2((i,o)=>{let s=em(t,e,c=>{n&&s(),c?o(c):i()})})}Rl.exports=em;Rl.exports.finished=R2});var Ti=z((BR,am)=>{"use strict";var DR=f(h()),Or=kn(),{aggregateTwoErrors:O2,codes:{ERR_MULTIPLE_CALLBACK:U2},AbortError:C2}=wt(),{Symbol:nm}=ze(),{kDestroyed:P2,isDestroyed:k2,isFinished:K2,isServerRequest:L2}=Rr(),im=nm("kDestroy"),Ol=nm("kConstruct");function om(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function M2(t,e){let r=this._readableState,n=this._writableState,i=n||r;return n!=null&&n.destroyed||r!=null&&r.destroyed?(typeof e=="function"&&e(),this):(om(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?tm(this,t,e):this.once(im,function(o){tm(this,O2(o,t),e)}),this)}function tm(t,e,r){let n=!1;function i(o){if(n)return;n=!0;let s=t._readableState,c=t._writableState;om(o,c,s),c&&(c.closed=!0),s&&(s.closed=!0),typeof r=="function"&&r(o),o?Or.nextTick(N2,t,o):Or.nextTick(sm,t)}try{t._destroy(e||null,i)}catch(o){i(o)}}function N2(t,e){Ul(t,e),sm(t)}function sm(t){let e=t._readableState,r=t._writableState;r&&(r.closeEmitted=!0),e&&(e.closeEmitted=!0),(r!=null&&r.emitClose||e!=null&&e.emitClose)&&t.emit("close")}function Ul(t,e){let r=t._readableState,n=t._writableState;n!=null&&n.errorEmitted||r!=null&&r.errorEmitted||(n&&(n.errorEmitted=!0),r&&(r.errorEmitted=!0),t.emit("error",e))}function $2(){let t=this._readableState,e=this._writableState;t&&(t.constructed=!0,t.closed=!1,t.closeEmitted=!1,t.destroyed=!1,t.errored=null,t.errorEmitted=!1,t.reading=!1,t.ended=t.readable===!1,t.endEmitted=t.readable===!1),e&&(e.constructed=!0,e.destroyed=!1,e.closed=!1,e.closeEmitted=!1,e.errored=null,e.errorEmitted=!1,e.finalCalled=!1,e.prefinished=!1,e.ended=e.writable===!1,e.ending=e.writable===!1,e.finished=e.writable===!1)}function Cl(t,e,r){let n=t._readableState,i=t._writableState;if(i!=null&&i.destroyed||n!=null&&n.destroyed)return this;n!=null&&n.autoDestroy||i!=null&&i.autoDestroy?t.destroy(e):e&&(e.stack,i&&!i.errored&&(i.errored=e),n&&!n.errored&&(n.errored=e),r?Or.nextTick(Ul,t,e):Ul(t,e))}function q2(t,e){if(typeof t._construct!="function")return;let r=t._readableState,n=t._writableState;r&&(r.constructed=!1),n&&(n.constructed=!1),t.once(Ol,e),!(t.listenerCount(Ol)>1)&&Or.nextTick(F2,t)}function F2(t){let e=!1;function r(n){if(e){Cl(t,n??new U2);return}e=!0;let i=t._readableState,o=t._writableState,s=o||i;i&&(i.constructed=!0),o&&(o.constructed=!0),s.destroyed?t.emit(im,n):n?Cl(t,n,!0):Or.nextTick(V2,t)}try{t._construct(n=>{Or.nextTick(r,n)})}catch(n){Or.nextTick(r,n)}}function V2(t){t.emit(Ol)}function rm(t){return t?.setHeader&&typeof t.abort=="function"}function cm(t){t.emit("close")}function H2(t,e){t.emit("error",e),Or.nextTick(cm,t)}function j2(t,e){!t||k2(t)||(!e&&!K2(t)&&(e=new C2),L2(t)?(t.socket=null,t.destroy(e)):rm(t)?t.abort():rm(t.req)?t.req.abort():typeof t.destroy=="function"?t.destroy(e):typeof t.close=="function"?t.close():e?Or.nextTick(H2,t,e):Or.nextTick(cm,t),t.destroyed||(t[P2]=!0))}am.exports={construct:q2,destroyer:j2,destroy:M2,undestroy:$2,errorOrDestroy:Cl}});var Aa=z((RR,dm)=>{"use strict";var OR=f(h()),{ArrayIsArray:W2,ObjectSetPrototypeOf:um}=ze(),{EventEmitter:va}=bs();function Sa(t){va.call(this,t)}um(Sa.prototype,va.prototype);um(Sa,va);Sa.prototype.pipe=function(t,e){let r=this;function n(u){t.writable&&t.write(u)===!1&&r.pause&&r.pause()}r.on("data",n);function i(){r.readable&&r.resume&&r.resume()}t.on("drain",i),!t._isStdio&&(!e||e.end!==!1)&&(r.on("end",s),r.on("close",c));let o=!1;function s(){o||(o=!0,t.end())}function c(){o||(o=!0,typeof t.destroy=="function"&&t.destroy())}function a(u){d(),va.listenerCount(this,"error")===0&&this.emit("error",u)}Pl(r,"error",a),Pl(t,"error",a);function d(){r.removeListener("data",n),t.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",c),r.removeListener("error",a),t.removeListener("error",a),r.removeListener("end",d),r.removeListener("close",d),t.removeListener("close",d)}return r.on("end",d),r.on("close",d),t.on("close",d),t.emit("pipe",r),t};function Pl(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):W2(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}dm.exports={Stream:Sa,prependListener:Pl}});var Ls=z((UR,Ta)=>{"use strict";var CR=f(h()),{AbortError:lm,codes:z2}=wt(),{isNodeStream:fm,isWebStream:G2,kControllerErrorFunction:J2}=Rr(),Y2=sn(),{ERR_INVALID_ARG_TYPE:hm}=z2,X2=(t,e)=>{if(typeof t!="object"||!("aborted"in t))throw new hm(e,"AbortSignal",t)};Ta.exports.addAbortSignal=function(e,r){if(X2(e,"signal"),!fm(r)&&!G2(r))throw new hm("stream",["ReadableStream","WritableStream","Stream"],r);return Ta.exports.addAbortSignalNoValidate(e,r)};Ta.exports.addAbortSignalNoValidate=function(t,e){if(typeof t!="object"||!("aborted"in t))return e;let r=fm(e)?()=>{e.destroy(new lm(void 0,{cause:t.reason}))}:()=>{e[J2](new lm(void 0,{cause:t.reason}))};return t.aborted?r():(t.addEventListener("abort",r),Y2(e,()=>t.removeEventListener("abort",r))),e}});var mm=z((kR,ym)=>{"use strict";var KR=f(h()),{StringPrototypeSlice:pm,SymbolIterator:Z2,TypedArrayPrototypeSet:_a,Uint8Array:Q2}=ze(),{Buffer:kl}=At(),{inspect:eS}=_r();ym.exports=class{constructor(){this.head=null,this.tail=null,this.length=0}push(e){let r={data:e,next:null};this.length>0?this.tail.next=r:this.head=r,this.tail=r,++this.length}unshift(e){let r={data:e,next:this.head};this.length===0&&(this.tail=r),this.head=r,++this.length}shift(){if(this.length===0)return;let e=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,e}clear(){this.head=this.tail=null,this.length=0}join(e){if(this.length===0)return"";let r=this.head,n=""+r.data;for(;(r=r.next)!==null;)n+=e+r.data;return n}concat(e){if(this.length===0)return kl.alloc(0);let r=kl.allocUnsafe(e>>>0),n=this.head,i=0;for(;n;)_a(r,n.data,i),i+=n.data.length,n=n.next;return r}consume(e,r){let n=this.head.data;if(eo.length)r+=o,e-=o.length;else{e===o.length?(r+=o,++i,n.next?this.head=n.next:this.head=this.tail=null):(r+=pm(o,0,e),this.head=n,n.data=pm(o,e));break}++i}while((n=n.next)!==null);return this.length-=i,r}_getBuffer(e){let r=kl.allocUnsafe(e),n=e,i=this.head,o=0;do{let s=i.data;if(e>s.length)_a(r,s,n-e),e-=s.length;else{e===s.length?(_a(r,s,n-e),++o,i.next?this.head=i.next:this.head=this.tail=null):(_a(r,new Q2(s.buffer,s.byteOffset,e),n-e),this.head=i,i.data=s.slice(e));break}++o}while((i=i.next)!==null);return this.length-=o,r}[Symbol.for("nodejs.util.inspect.custom")](e,r){return eS(this,{...r,depth:0,customInspect:!1})}}});var Ia=z((LR,wm)=>{"use strict";var MR=f(h()),{MathFloor:tS,NumberIsInteger:rS}=ze(),{ERR_INVALID_ARG_VALUE:nS}=wt().codes;function iS(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function gm(t){return t?16:16*1024}function oS(t,e,r,n){let i=iS(e,n,r);if(i!=null){if(!rS(i)||i<0){let o=n?`options.${r}`:"options.highWaterMark";throw new nS(o,i)}return tS(i)}return gm(t.objectMode)}wm.exports={getHighWaterMark:oS,getDefaultHighWaterMark:gm}});var Em=z((Kl,xm)=>{var NR=f(h());var Ba=At(),Ur=Ba.Buffer;function bm(t,e){for(var r in t)e[r]=t[r]}Ur.from&&Ur.alloc&&Ur.allocUnsafe&&Ur.allocUnsafeSlow?xm.exports=Ba:(bm(Ba,Kl),Kl.Buffer=_i);function _i(t,e,r){return Ur(t,e,r)}_i.prototype=Object.create(Ur.prototype);bm(Ur,_i);_i.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return Ur(t,e,r)};_i.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=Ur(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};_i.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Ur(t)};_i.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Ba.SlowBuffer(t)}});var Am=z(Sm=>{"use strict";var qR=f(h()),Ml=Em().Buffer,vm=Ml.isEncoding||function(t){switch(t=""+t,t&&t.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 sS(t){if(!t)return"utf8";for(var e;;)switch(t){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 t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}function cS(t){var e=sS(t);if(typeof e!="string"&&(Ml.isEncoding===vm||!vm(t)))throw new Error("Unknown encoding: "+t);return e||t}Sm.StringDecoder=Ms;function Ms(t){this.encoding=cS(t);var e;switch(this.encoding){case"utf16le":this.text=hS,this.end=pS,e=4;break;case"utf8":this.fillLast=dS,e=4;break;case"base64":this.text=yS,this.end=mS,e=3;break;default:this.write=gS,this.end=wS;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Ml.allocUnsafe(e)}Ms.prototype.write=function(t){if(t.length===0)return"";var e,r;if(this.lastNeed){if(e=this.fillLast(t),e===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function aS(t,e,r){var n=e.length-1;if(n=0?(i>0&&(t.lastNeed=i-1),i):--n=0?(i>0&&(t.lastNeed=i-2),i):--n=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function uS(t,e,r){if((e[0]&192)!==128)return t.lastNeed=0,"\uFFFD";if(t.lastNeed>1&&e.length>1){if((e[1]&192)!==128)return t.lastNeed=1,"\uFFFD";if(t.lastNeed>2&&e.length>2&&(e[2]&192)!==128)return t.lastNeed=2,"\uFFFD"}}function dS(t){var e=this.lastTotal-this.lastNeed,r=uS(this,t,e);if(r!==void 0)return r;if(this.lastNeed<=t.length)return t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,e,0,t.length),this.lastNeed-=t.length}function lS(t,e){var r=aS(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)}function fS(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function hS(t,e){if((t.length-e)%2===0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function pS(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function yS(t,e){var r=(t.length-e)%3;return r===0?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function mS(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function gS(t){return t.toString(this.encoding)}function wS(t){return t&&t.length?this.write(t):""}});var Nl=z((FR,Bm)=>{"use strict";var VR=f(h()),Tm=kn(),{PromisePrototypeThen:bS,SymbolAsyncIterator:_m,SymbolIterator:Im}=ze(),{Buffer:xS}=At(),{ERR_INVALID_ARG_TYPE:ES,ERR_STREAM_NULL_VALUES:vS}=wt().codes;function SS(t,e,r){let n;if(typeof e=="string"||e instanceof xS)return new t({objectMode:!0,...r,read(){this.push(e),this.push(null)}});let i;if(e&&e[_m])i=!0,n=e[_m]();else if(e&&e[Im])i=!1,n=e[Im]();else throw new ES("iterable",["Iterable"],e);let o=new t({objectMode:!0,highWaterMark:1,...r}),s=!1;o._read=function(){s||(s=!0,a())},o._destroy=function(d,u){bS(c(d),()=>Tm.nextTick(u,d),l=>Tm.nextTick(u,l||d))};async function c(d){let u=d!=null,l=typeof n.throw=="function";if(u&&l){let{value:y,done:g}=await n.throw(d);if(await y,g)return}if(typeof n.return=="function"){let{value:y}=await n.return();await y}}async function a(){for(;;){try{let{value:d,done:u}=i?await n.next():n.next();if(u)o.push(null);else{let l=d&&typeof d.then=="function"?await d:d;if(l===null)throw s=!1,new vS;if(o.push(l))continue;s=!1}}catch(d){o.destroy(d)}break}}return o}Bm.exports=SS});var Ns=z((HR,qm)=>{var jR=f(h()),ur=kn(),{ArrayPrototypeIndexOf:AS,NumberIsInteger:TS,NumberIsNaN:_S,NumberParseInt:IS,ObjectDefineProperties:Om,ObjectKeys:BS,ObjectSetPrototypeOf:Um,Promise:DS,SafeSet:RS,SymbolAsyncIterator:OS,Symbol:US}=ze();qm.exports=he;he.ReadableState=jl;var{EventEmitter:CS}=bs(),{Stream:Ln,prependListener:PS}=Aa(),{Buffer:$l}=At(),{addAbortSignal:kS}=Ls(),KS=sn(),ye=_r().debuglog("stream",t=>{ye=t}),LS=mm(),So=Ti(),{getHighWaterMark:MS,getDefaultHighWaterMark:NS}=Ia(),{aggregateTwoErrors:Dm,codes:{ERR_INVALID_ARG_TYPE:$S,ERR_METHOD_NOT_IMPLEMENTED:qS,ERR_OUT_OF_RANGE:FS,ERR_STREAM_PUSH_AFTER_EOF:VS,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:HS}}=wt(),{validateObject:jS}=Ks(),Ii=US("kPaused"),{StringDecoder:Cm}=Am(),WS=Nl();Um(he.prototype,Ln.prototype);Um(he,Ln);var ql=()=>{},{errorOrDestroy:vo}=So;function jl(t,e,r){typeof r!="boolean"&&(r=e instanceof Cr()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.readableObjectMode)),this.highWaterMark=t?MS(this,t,"readableHighWaterMark",r):NS(!1),this.buffer=new LS,this.length=0,this.pipes=[],this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.constructed=!0,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this[Ii]=null,this.errorEmitted=!1,this.emitClose=!t||t.emitClose!==!1,this.autoDestroy=!t||t.autoDestroy!==!1,this.destroyed=!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.awaitDrainWriters=null,this.multiAwaitDrain=!1,this.readingMore=!1,this.dataEmitted=!1,this.decoder=null,this.encoding=null,t&&t.encoding&&(this.decoder=new Cm(t.encoding),this.encoding=t.encoding)}function he(t){if(!(this instanceof he))return new he(t);let e=this instanceof Cr();this._readableState=new jl(t,this,e),t&&(typeof t.read=="function"&&(this._read=t.read),typeof t.destroy=="function"&&(this._destroy=t.destroy),typeof t.construct=="function"&&(this._construct=t.construct),t.signal&&!e&&kS(t.signal,this)),Ln.call(this,t),So.construct(this,()=>{this._readableState.needReadable&&Da(this,this._readableState)})}he.prototype.destroy=So.destroy;he.prototype._undestroy=So.undestroy;he.prototype._destroy=function(t,e){e(t)};he.prototype[CS.captureRejectionSymbol]=function(t){this.destroy(t)};he.prototype.push=function(t,e){return Pm(this,t,e,!1)};he.prototype.unshift=function(t,e){return Pm(this,t,e,!0)};function Pm(t,e,r,n){ye("readableAddChunk",e);let i=t._readableState,o;if(i.objectMode||(typeof e=="string"?(r=r||i.defaultEncoding,i.encoding!==r&&(n&&i.encoding?e=$l.from(e,r).toString(i.encoding):(e=$l.from(e,r),r=""))):e instanceof $l?r="":Ln._isUint8Array(e)?(e=Ln._uint8ArrayToBuffer(e),r=""):e!=null&&(o=new $S("chunk",["string","Buffer","Uint8Array"],e))),o)vo(t,o);else if(e===null)i.reading=!1,JS(t,i);else if(i.objectMode||e&&e.length>0)if(n)if(i.endEmitted)vo(t,new HS);else{if(i.destroyed||i.errored)return!1;Fl(t,i,e,!0)}else if(i.ended)vo(t,new VS);else{if(i.destroyed||i.errored)return!1;i.reading=!1,i.decoder&&!r?(e=i.decoder.write(e),i.objectMode||e.length!==0?Fl(t,i,e,!1):Da(t,i)):Fl(t,i,e,!1)}else n||(i.reading=!1,Da(t,i));return!i.ended&&(i.length0?(e.multiAwaitDrain?e.awaitDrainWriters.clear():e.awaitDrainWriters=null,e.dataEmitted=!0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&Ra(t)),Da(t,e)}he.prototype.isPaused=function(){let t=this._readableState;return t[Ii]===!0||t.flowing===!1};he.prototype.setEncoding=function(t){let e=new Cm(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;let r=this._readableState.buffer,n="";for(let i of r)n+=e.write(i);return r.clear(),n!==""&&r.push(n),this._readableState.length=n.length,this};var zS=1073741824;function GS(t){if(t>zS)throw new FS("size","<= 1GiB",t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++,t}function Rm(t,e){return t<=0||e.length===0&&e.ended?0:e.objectMode?1:_S(t)?e.flowing&&e.length?e.buffer.first().length:e.length:t<=e.length?t:e.ended?e.length:0}he.prototype.read=function(t){ye("read",t),t===void 0?t=NaN:TS(t)||(t=IS(t,10));let e=this._readableState,r=t;if(t>e.highWaterMark&&(e.highWaterMark=GS(t)),t!==0&&(e.emittedReadable=!1),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return ye("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?Vl(this):Ra(this),null;if(t=Rm(t,e),t===0&&e.ended)return e.length===0&&Vl(this),null;let n=e.needReadable;if(ye("need readable",n),(e.length===0||e.length-t0?i=Nm(t,e):i=null,i===null?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.multiAwaitDrain?e.awaitDrainWriters.clear():e.awaitDrainWriters=null),e.length===0&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&Vl(this)),i!==null&&!e.errorEmitted&&!e.closeEmitted&&(e.dataEmitted=!0,this.emit("data",i)),i};function JS(t,e){if(ye("onEofChunk"),!e.ended){if(e.decoder){let r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?Ra(t):(e.needReadable=!1,e.emittedReadable=!0,km(t))}}function Ra(t){let e=t._readableState;ye("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(ye("emitReadable",e.flowing),e.emittedReadable=!0,ur.nextTick(km,t))}function km(t){let e=t._readableState;ye("emitReadable_",e.destroyed,e.length,e.ended),!e.destroyed&&!e.errored&&(e.length||e.ended)&&(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,Lm(t)}function Da(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,ur.nextTick(YS,t,e))}function YS(t,e){for(;!e.reading&&!e.ended&&(e.length1&&n.pipes.includes(t)&&(ye("false write response, pause",n.awaitDrainWriters.size),n.awaitDrainWriters.add(t)),r.pause()),a||(a=XS(r,t),t.on("drain",a))}r.on("data",y);function y(S){ye("ondata");let T=t.write(S);ye("dest.write",T),T===!1&&l()}function g(S){if(ye("onerror",S),x(),t.removeListener("error",g),t.listenerCount("error")===0){let T=t._writableState||t._readableState;T&&!T.errorEmitted?vo(t,S):t.emit("error",S)}}PS(t,"error",g);function p(){t.removeListener("finish",w),x()}t.once("close",p);function w(){ye("onfinish"),t.removeListener("close",p),x()}t.once("finish",w);function x(){ye("unpipe"),r.unpipe(t)}return t.emit("pipe",r),t.writableNeedDrain===!0?n.flowing&&l():n.flowing||(ye("pipe resume"),r.resume()),t};function XS(t,e){return function(){let n=t._readableState;n.awaitDrainWriters===e?(ye("pipeOnDrain",1),n.awaitDrainWriters=null):n.multiAwaitDrain&&(ye("pipeOnDrain",n.awaitDrainWriters.size),n.awaitDrainWriters.delete(e)),(!n.awaitDrainWriters||n.awaitDrainWriters.size===0)&&t.listenerCount("data")&&t.resume()}}he.prototype.unpipe=function(t){let e=this._readableState,r={hasUnpiped:!1};if(e.pipes.length===0)return this;if(!t){let i=e.pipes;e.pipes=[],this.pause();for(let o=0;o0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,ye("on readable",n.length,n.reading),n.length?Ra(this):n.reading||ur.nextTick(ZS,this)),r};he.prototype.addListener=he.prototype.on;he.prototype.removeListener=function(t,e){let r=Ln.prototype.removeListener.call(this,t,e);return t==="readable"&&ur.nextTick(Km,this),r};he.prototype.off=he.prototype.removeListener;he.prototype.removeAllListeners=function(t){let e=Ln.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&ur.nextTick(Km,this),e};function Km(t){let e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&e[Ii]===!1?e.flowing=!0:t.listenerCount("data")>0?t.resume():e.readableListening||(e.flowing=null)}function ZS(t){ye("readable nexttick read 0"),t.read(0)}he.prototype.resume=function(){let t=this._readableState;return t.flowing||(ye("resume"),t.flowing=!t.readableListening,QS(this,t)),t[Ii]=!1,this};function QS(t,e){e.resumeScheduled||(e.resumeScheduled=!0,ur.nextTick(eA,t,e))}function eA(t,e){ye("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),Lm(t),e.flowing&&!e.reading&&t.read(0)}he.prototype.pause=function(){return ye("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(ye("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[Ii]=!0,this};function Lm(t){let e=t._readableState;for(ye("flow",e.flowing);e.flowing&&t.read()!==null;);}he.prototype.wrap=function(t){let e=!1;t.on("data",n=>{!this.push(n)&&t.pause&&(e=!0,t.pause())}),t.on("end",()=>{this.push(null)}),t.on("error",n=>{vo(this,n)}),t.on("close",()=>{this.destroy()}),t.on("destroy",()=>{this.destroy()}),this._read=()=>{e&&t.resume&&(e=!1,t.resume())};let r=BS(t);for(let n=1;n{i=s?Dm(i,s):null,r(),r=ql});try{for(;;){let s=t.destroyed?null:t.read();if(s!==null)yield s;else{if(i)throw i;if(i===null)return;await new DS(n)}}}catch(s){throw i=Dm(i,s),i}finally{(i||e?.destroyOnReturn!==!1)&&(i===void 0||t._readableState.autoDestroy)?So.destroyer(t,null):(t.off("readable",n),o())}}Om(he.prototype,{readable:{__proto__:null,get(){let t=this._readableState;return!!t&&t.readable!==!1&&!t.destroyed&&!t.errorEmitted&&!t.endEmitted},set(t){this._readableState&&(this._readableState.readable=!!t)}},readableDidRead:{__proto__:null,enumerable:!1,get:function(){return this._readableState.dataEmitted}},readableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._readableState.readable!==!1&&(this._readableState.destroyed||this._readableState.errored)&&!this._readableState.endEmitted)}},readableHighWaterMark:{__proto__:null,enumerable:!1,get:function(){return this._readableState.highWaterMark}},readableBuffer:{__proto__:null,enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}},readableFlowing:{__proto__:null,enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}},readableLength:{__proto__:null,enumerable:!1,get(){return this._readableState.length}},readableObjectMode:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.objectMode:!1}},readableEncoding:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.encoding:null}},errored:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.errored:null}},closed:{__proto__:null,get(){return this._readableState?this._readableState.closed:!1}},destroyed:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.destroyed:!1},set(t){this._readableState&&(this._readableState.destroyed=t)}},readableEnded:{__proto__:null,enumerable:!1,get(){return this._readableState?this._readableState.endEmitted:!1}}});Om(jl.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[Ii]!==!1},set(t){this[Ii]=!!t}}});he._fromList=Nm;function Nm(t,e){if(e.length===0)return null;let r;return e.objectMode?r=e.buffer.shift():!t||t>=e.length?(e.decoder?r=e.buffer.join(""):e.buffer.length===1?r=e.buffer.first():r=e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r}function Vl(t){let e=t._readableState;ye("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,ur.nextTick(rA,e,t))}function rA(t,e){if(ye("endReadableNT",t.endEmitted,t.length),!t.errored&&!t.closeEmitted&&!t.endEmitted&&t.length===0){if(t.endEmitted=!0,e.emit("end"),e.writable&&e.allowHalfOpen===!1)ur.nextTick(nA,e);else if(t.autoDestroy){let r=e._writableState;(!r||r.autoDestroy&&(r.finished||r.writable===!1))&&e.destroy()}}}function nA(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}he.from=function(t,e){return WS(he,t,e)};var Hl;function $m(){return Hl===void 0&&(Hl={}),Hl}he.fromWeb=function(t,e){return $m().newStreamReadableFromReadableStream(t,e)};he.toWeb=function(t,e){return $m().newReadableStreamFromStreamReadable(t,e)};he.wrap=function(t,e){var r,n;return new he({objectMode:(r=(n=t.readableObjectMode)!==null&&n!==void 0?n:t.objectMode)!==null&&r!==void 0?r:!0,...e,destroy(i,o){So.destroyer(t,i),o(i)}}).wrap(t)}});var Zl=z((WR,Qm)=>{var zR=f(h()),Bi=kn(),{ArrayPrototypeSlice:Hm,Error:iA,FunctionPrototypeSymbolHasInstance:jm,ObjectDefineProperty:Wm,ObjectDefineProperties:oA,ObjectSetPrototypeOf:zm,StringPrototypeToLowerCase:sA,Symbol:cA,SymbolHasInstance:aA}=ze();Qm.exports=Me;Me.WritableState=Fs;var{EventEmitter:uA}=bs(),$s=Aa().Stream,{Buffer:Oa}=At(),Pa=Ti(),{addAbortSignal:dA}=Ls(),{getHighWaterMark:lA,getDefaultHighWaterMark:fA}=Ia(),{ERR_INVALID_ARG_TYPE:hA,ERR_METHOD_NOT_IMPLEMENTED:pA,ERR_MULTIPLE_CALLBACK:Gm,ERR_STREAM_CANNOT_PIPE:yA,ERR_STREAM_DESTROYED:qs,ERR_STREAM_ALREADY_FINISHED:mA,ERR_STREAM_NULL_VALUES:gA,ERR_STREAM_WRITE_AFTER_END:wA,ERR_UNKNOWN_ENCODING:Jm}=wt().codes,{errorOrDestroy:Ao}=Pa;zm(Me.prototype,$s.prototype);zm(Me,$s);function Gl(){}var To=cA("kOnFinished");function Fs(t,e,r){typeof r!="boolean"&&(r=e instanceof Cr()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.writableObjectMode)),this.highWaterMark=t?lA(this,t,"writableHighWaterMark",r):fA(!1),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;let n=!!(t&&t.decodeStrings===!1);this.decodeStrings=!n,this.defaultEncoding=t&&t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=xA.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,Ca(this),this.pendingcb=0,this.constructed=!0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!t||t.emitClose!==!1,this.autoDestroy=!t||t.autoDestroy!==!1,this.errored=null,this.closed=!1,this.closeEmitted=!1,this[To]=[]}function Ca(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}Fs.prototype.getBuffer=function(){return Hm(this.buffered,this.bufferedIndex)};Wm(Fs.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function Me(t){let e=this instanceof Cr();if(!e&&!jm(Me,this))return new Me(t);this._writableState=new Fs(t,this,e),t&&(typeof t.write=="function"&&(this._write=t.write),typeof t.writev=="function"&&(this._writev=t.writev),typeof t.destroy=="function"&&(this._destroy=t.destroy),typeof t.final=="function"&&(this._final=t.final),typeof t.construct=="function"&&(this._construct=t.construct),t.signal&&dA(t.signal,this)),$s.call(this,t),Pa.construct(this,()=>{let r=this._writableState;r.writing||Yl(this,r),Xl(this,r)})}Wm(Me,aA,{__proto__:null,value:function(t){return jm(this,t)?!0:this!==Me?!1:t&&t._writableState instanceof Fs}});Me.prototype.pipe=function(){Ao(this,new yA)};function Ym(t,e,r,n){let i=t._writableState;if(typeof r=="function")n=r,r=i.defaultEncoding;else{if(!r)r=i.defaultEncoding;else if(r!=="buffer"&&!Oa.isEncoding(r))throw new Jm(r);typeof n!="function"&&(n=Gl)}if(e===null)throw new gA;if(!i.objectMode)if(typeof e=="string")i.decodeStrings!==!1&&(e=Oa.from(e,r),r="buffer");else if(e instanceof Oa)r="buffer";else if($s._isUint8Array(e))e=$s._uint8ArrayToBuffer(e),r="buffer";else throw new hA("chunk",["string","Buffer","Uint8Array"],e);let o;return i.ending?o=new wA:i.destroyed&&(o=new qs("write")),o?(Bi.nextTick(n,o),Ao(t,o,!0),o):(i.pendingcb++,bA(t,i,e,r,n))}Me.prototype.write=function(t,e,r){return Ym(this,t,e,r)===!0};Me.prototype.cork=function(){this._writableState.corked++};Me.prototype.uncork=function(){let t=this._writableState;t.corked&&(t.corked--,t.writing||Yl(this,t))};Me.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=sA(e)),!Oa.isEncoding(e))throw new Jm(e);return this._writableState.defaultEncoding=e,this};function bA(t,e,r,n,i){let o=e.objectMode?1:r.length;e.length+=o;let s=e.lengthr.bufferedIndex&&Yl(t,r),n?r.afterWriteTickInfo!==null&&r.afterWriteTickInfo.cb===i?r.afterWriteTickInfo.count++:(r.afterWriteTickInfo={count:1,cb:i,stream:t,state:r},Bi.nextTick(EA,r.afterWriteTickInfo)):Xm(t,r,1,i))}function EA({stream:t,state:e,count:r,cb:n}){return e.afterWriteTickInfo=null,Xm(t,e,r,n)}function Xm(t,e,r,n){for(!e.ending&&!t.destroyed&&e.length===0&&e.needDrain&&(e.needDrain=!1,t.emit("drain"));r-- >0;)e.pendingcb--,n();e.destroyed&&Jl(e),Xl(t,e)}function Jl(t){if(t.writing)return;for(let i=t.bufferedIndex;i1&&t._writev){e.pendingcb-=o-1;let c=e.allNoop?Gl:d=>{for(let u=s;u256?(r.splice(0,s),e.bufferedIndex=0):e.bufferedIndex=s}e.bufferProcessing=!1}Me.prototype._write=function(t,e,r){if(this._writev)this._writev([{chunk:t,encoding:e}],r);else throw new pA("_write()")};Me.prototype._writev=null;Me.prototype.end=function(t,e,r){let n=this._writableState;typeof t=="function"?(r=t,t=null,e=null):typeof e=="function"&&(r=e,e=null);let i;if(t!=null){let o=Ym(this,t,e);o instanceof iA&&(i=o)}return n.corked&&(n.corked=1,this.uncork()),i||(!n.errored&&!n.ending?(n.ending=!0,Xl(this,n,!0),n.ended=!0):n.finished?i=new mA("end"):n.destroyed&&(i=new qs("end"))),typeof r=="function"&&(i||n.finished?Bi.nextTick(r,i):n[To].push(r)),this};function Ua(t){return t.ending&&!t.destroyed&&t.constructed&&t.length===0&&!t.errored&&t.buffered.length===0&&!t.finished&&!t.writing&&!t.errorEmitted&&!t.closeEmitted}function vA(t,e){let r=!1;function n(i){if(r){Ao(t,i??Gm());return}if(r=!0,e.pendingcb--,i){let o=e[To].splice(0);for(let s=0;s{Ua(i)?zl(n,i):i.pendingcb--},t,e)):Ua(e)&&(e.pendingcb++,zl(t,e))))}function zl(t,e){e.pendingcb--,e.finished=!0;let r=e[To].splice(0);for(let n=0;n{var JR=f(h()),Ql=kn(),TA=At(),{isReadable:_A,isWritable:IA,isIterable:eg,isNodeStream:BA,isReadableNodeStream:tg,isWritableNodeStream:rg,isDuplexNodeStream:DA}=Rr(),ng=sn(),{AbortError:ug,codes:{ERR_INVALID_ARG_TYPE:RA,ERR_INVALID_RETURN_VALUE:ig}}=wt(),{destroyer:_o}=Ti(),OA=Cr(),UA=Ns(),{createDeferredPromise:og}=_r(),sg=Nl(),cg=globalThis.Blob||TA.Blob,CA=typeof cg<"u"?function(e){return e instanceof cg}:function(e){return!1},PA=globalThis.AbortController||pa().AbortController,{FunctionPrototypeCall:ag}=ze(),Di=class extends OA{constructor(e){super(e),e?.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),e?.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)}};dg.exports=function t(e,r){if(DA(e))return e;if(tg(e))return ka({readable:e});if(rg(e))return ka({writable:e});if(BA(e))return ka({writable:!1,readable:!1});if(typeof e=="function"){let{value:i,write:o,final:s,destroy:c}=kA(e);if(eg(i))return sg(Di,i,{objectMode:!0,write:o,final:s,destroy:c});let a=i?.then;if(typeof a=="function"){let d,u=ag(a,i,l=>{if(l!=null)throw new ig("nully","body",l)},l=>{_o(d,l)});return d=new Di({objectMode:!0,readable:!1,write:o,final(l){s(async()=>{try{await u,Ql.nextTick(l,null)}catch(y){Ql.nextTick(l,y)}})},destroy:c})}throw new ig("Iterable, AsyncIterable or AsyncFunction",r,i)}if(CA(e))return t(e.arrayBuffer());if(eg(e))return sg(Di,e,{objectMode:!0,writable:!1});if(typeof e?.writable=="object"||typeof e?.readable=="object"){let i=e!=null&&e.readable?tg(e?.readable)?e?.readable:t(e.readable):void 0,o=e!=null&&e.writable?rg(e?.writable)?e?.writable:t(e.writable):void 0;return ka({readable:i,writable:o})}let n=e?.then;if(typeof n=="function"){let i;return ag(n,e,o=>{o!=null&&i.push(o),i.push(null)},o=>{_o(i,o)}),i=new Di({objectMode:!0,writable:!1,read(){}})}throw new RA(r,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],e)};function kA(t){let{promise:e,resolve:r}=og(),n=new PA,i=n.signal;return{value:t(async function*(){for(;;){let s=e;e=null;let{chunk:c,done:a,cb:d}=await s;if(Ql.nextTick(d),a)return;if(i.aborted)throw new ug(void 0,{cause:i.reason});({promise:e,resolve:r}=og()),yield c}}(),{signal:i}),write(s,c,a){let d=r;r=null,d({chunk:s,done:!1,cb:a})},final(s){let c=r;r=null,c({done:!0,cb:s})},destroy(s,c){n.abort(),c(s)}}}function ka(t){let e=t.readable&&typeof t.readable.read!="function"?UA.wrap(t.readable):t.readable,r=t.writable,n=!!_A(e),i=!!IA(r),o,s,c,a,d;function u(l){let y=a;a=null,y?y(l):l&&d.destroy(l)}return d=new Di({readableObjectMode:!!(e!=null&&e.readableObjectMode),writableObjectMode:!!(r!=null&&r.writableObjectMode),readable:n,writable:i}),i&&(ng(r,l=>{i=!1,l&&_o(e,l),u(l)}),d._write=function(l,y,g){r.write(l,y)?g():o=g},d._final=function(l){r.end(),s=l},r.on("drain",function(){if(o){let l=o;o=null,l()}}),r.on("finish",function(){if(s){let l=s;s=null,l()}})),n&&(ng(e,l=>{n=!1,l&&_o(e,l),u(l)}),e.on("readable",function(){if(c){let l=c;c=null,l()}}),e.on("end",function(){d.push(null)}),d._read=function(){for(;;){let l=e.read();if(l===null){c=d._read;return}if(!d.push(l))return}}),d._destroy=function(l,y){!l&&a!==null&&(l=new ug),c=null,o=null,s=null,a===null?y(l):(a=y,_o(r,l),_o(e,l))},d}});var Cr=z((YR,pg)=>{"use strict";var XR=f(h()),{ObjectDefineProperties:KA,ObjectGetOwnPropertyDescriptor:cn,ObjectKeys:LA,ObjectSetPrototypeOf:fg}=ze();pg.exports=dr;var rf=Ns(),Xt=Zl();fg(dr.prototype,rf.prototype);fg(dr,rf);{let t=LA(Xt.prototype);for(let e=0;e{"use strict";var QR=f(h()),{ObjectSetPrototypeOf:yg,Symbol:MA}=ze();mg.exports=an;var{ERR_METHOD_NOT_IMPLEMENTED:NA}=wt().codes,of=Cr(),{getHighWaterMark:$A}=Ia();yg(an.prototype,of.prototype);yg(an,of);var Vs=MA("kCallback");function an(t){if(!(this instanceof an))return new an(t);let e=t?$A(this,t,"readableHighWaterMark",!0):null;e===0&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),of.call(this,t),this._readableState.sync=!1,this[Vs]=null,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",qA)}function nf(t){typeof this._flush=="function"&&!this.destroyed?this._flush((e,r)=>{if(e){t?t(e):this.destroy(e);return}r!=null&&this.push(r),this.push(null),t&&t()}):(this.push(null),t&&t())}function qA(){this._final!==nf&&nf.call(this)}an.prototype._final=nf;an.prototype._transform=function(t,e,r){throw new NA("_transform()")};an.prototype._write=function(t,e,r){let n=this._readableState,i=this._writableState,o=n.length;this._transform(t,e,(s,c)=>{if(s){r(s);return}c!=null&&this.push(c),i.ended||o===n.length||n.length{"use strict";var t5=f(h()),{ObjectSetPrototypeOf:gg}=ze();wg.exports=Io;var cf=sf();gg(Io.prototype,cf.prototype);gg(Io,cf);function Io(t){if(!(this instanceof Io))return new Io(t);cf.call(this,t)}Io.prototype._transform=function(t,e,r){r(null,t)}});var Na=z((r5,Sg)=>{var n5=f(h()),Hs=kn(),{ArrayIsArray:FA,Promise:VA,SymbolAsyncIterator:HA}=ze(),Ma=sn(),{once:jA}=_r(),WA=Ti(),bg=Cr(),{aggregateTwoErrors:zA,codes:{ERR_INVALID_ARG_TYPE:mf,ERR_INVALID_RETURN_VALUE:uf,ERR_MISSING_ARGS:GA,ERR_STREAM_DESTROYED:JA,ERR_STREAM_PREMATURE_CLOSE:YA},AbortError:XA}=wt(),{validateFunction:ZA,validateAbortSignal:QA}=Ks(),{isIterable:Ri,isReadable:df,isReadableNodeStream:La,isNodeStream:xg,isTransformStream:Bo,isWebStream:eT,isReadableStream:lf,isReadableEnded:tT}=Rr(),rT=globalThis.AbortController||pa().AbortController,ff,hf;function Eg(t,e,r){let n=!1;t.on("close",()=>{n=!0});let i=Ma(t,{readable:e,writable:r},o=>{n=!o});return{destroy:o=>{n||(n=!0,WA.destroyer(t,o||new JA("pipe")))},cleanup:i}}function nT(t){return ZA(t[t.length-1],"streams[stream.length - 1]"),t.pop()}function pf(t){if(Ri(t))return t;if(La(t))return iT(t);throw new mf("val",["Readable","Iterable","AsyncIterable"],t)}async function*iT(t){hf||(hf=Ns()),yield*hf.prototype[HA].call(t)}async function Ka(t,e,r,{end:n}){let i,o=null,s=d=>{if(d&&(i=d),o){let u=o;o=null,u()}},c=()=>new VA((d,u)=>{i?u(i):o=()=>{i?u(i):d()}});e.on("drain",s);let a=Ma(e,{readable:!1},s);try{e.writableNeedDrain&&await c();for await(let d of t)e.write(d)||await c();n&&e.end(),await c(),r()}catch(d){r(i!==d?zA(i,d):d)}finally{a(),e.off("drain",s)}}async function yf(t,e,r,{end:n}){Bo(e)&&(e=e.writable);let i=e.getWriter();try{for await(let o of t)await i.ready,i.write(o).catch(()=>{});await i.ready,n&&await i.close(),r()}catch(o){try{await i.abort(o),r(o)}catch(s){r(s)}}}function oT(...t){return vg(t,jA(nT(t)))}function vg(t,e,r){if(t.length===1&&FA(t[0])&&(t=t[0]),t.length<2)throw new GA("streams");let n=new rT,i=n.signal,o=r?.signal,s=[];QA(o,"options.signal");function c(){g(new XA)}o?.addEventListener("abort",c);let a,d,u=[],l=0;function y(T){g(T,--l===0)}function g(T,E){if(T&&(!a||a.code==="ERR_STREAM_PREMATURE_CLOSE")&&(a=T),!(!a&&!E)){for(;u.length;)u.shift()(a);o?.removeEventListener("abort",c),n.abort(),E&&(a||s.forEach(R=>R()),Hs.nextTick(e,a,d))}}let p;for(let T=0;T0,O=R||r?.end!==!1,k=T===t.length-1;if(xg(E)){let P=function($){$&&$.name!=="AbortError"&&$.code!=="ERR_STREAM_PREMATURE_CLOSE"&&y($)};var S=P;if(O){let{destroy:$,cleanup:N}=Eg(E,R,D);u.push($),df(E)&&k&&s.push(N)}E.on("error",P),df(E)&&k&&s.push(()=>{E.removeListener("error",P)})}if(T===0)if(typeof E=="function"){if(p=E({signal:i}),!Ri(p))throw new uf("Iterable, AsyncIterable or Stream","source",p)}else Ri(E)||La(E)||Bo(E)?p=E:p=bg.from(E);else if(typeof E=="function"){if(Bo(p)){var w;p=pf((w=p)===null||w===void 0?void 0:w.readable)}else p=pf(p);if(p=E(p,{signal:i}),R){if(!Ri(p,!0))throw new uf("AsyncIterable",`transform[${T-1}]`,p)}else{var x;ff||(ff=af());let P=new ff({objectMode:!0}),$=(x=p)===null||x===void 0?void 0:x.then;if(typeof $=="function")l++,$.call(p,V=>{d=V,V!=null&&P.write(V),O&&P.end(),Hs.nextTick(y)},V=>{P.destroy(V),Hs.nextTick(y,V)});else if(Ri(p,!0))l++,Ka(p,P,y,{end:O});else if(lf(p)||Bo(p)){let V=p.readable||p;l++,Ka(V,P,y,{end:O})}else throw new uf("AsyncIterable or Promise","destination",p);p=P;let{destroy:N,cleanup:q}=Eg(p,!1,!0);u.push(N),k&&s.push(q)}}else if(xg(E)){if(La(p)){l+=2;let P=sT(p,E,y,{end:O});df(E)&&k&&s.push(P)}else if(Bo(p)||lf(p)){let P=p.readable||p;l++,Ka(P,E,y,{end:O})}else if(Ri(p))l++,Ka(p,E,y,{end:O});else throw new mf("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],p);p=E}else if(eT(E)){if(La(p))l++,yf(pf(p),E,y,{end:O});else if(lf(p)||Ri(p))l++,yf(p,E,y,{end:O});else if(Bo(p))l++,yf(p.readable,E,y,{end:O});else throw new mf("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],p);p=E}else p=bg.from(E)}return(i!=null&&i.aborted||o!=null&&o.aborted)&&Hs.nextTick(c),p}function sT(t,e,r,{end:n}){let i=!1;if(e.on("close",()=>{i||r(new YA)}),t.pipe(e,{end:!1}),n){let s=function(){i=!0,e.end()};var o=s;tT(t)?Hs.nextTick(s):t.once("end",s)}else r();return Ma(t,{readable:!0,writable:!1},s=>{let c=t._readableState;s&&s.code==="ERR_STREAM_PREMATURE_CLOSE"&&c&&c.ended&&!c.errored&&!c.errorEmitted?t.once("end",r).once("error",r):r(s)}),Ma(e,{readable:!1,writable:!0},r)}Sg.exports={pipelineImpl:vg,pipeline:oT}});var wf=z((i5,Dg)=>{"use strict";var o5=f(h()),{pipeline:cT}=Na(),$a=Cr(),{destroyer:aT}=Ti(),{isNodeStream:qa,isReadable:Ag,isWritable:Tg,isWebStream:gf,isTransformStream:Oi,isWritableStream:_g,isReadableStream:Ig}=Rr(),{AbortError:uT,codes:{ERR_INVALID_ARG_VALUE:Bg,ERR_MISSING_ARGS:dT}}=wt(),lT=sn();Dg.exports=function(...e){if(e.length===0)throw new dT("streams");if(e.length===1)return $a.from(e[0]);let r=[...e];if(typeof e[0]=="function"&&(e[0]=$a.from(e[0])),typeof e[e.length-1]=="function"){let g=e.length-1;e[g]=$a.from(e[g])}for(let g=0;g0&&!(Tg(e[g])||_g(e[g])||Oi(e[g])))throw new Bg(`streams[${g}]`,r[g],"must be writable")}let n,i,o,s,c;function a(g){let p=s;s=null,p?p(g):g?c.destroy(g):!y&&!l&&c.destroy()}let d=e[0],u=cT(e,a),l=!!(Tg(d)||_g(d)||Oi(d)),y=!!(Ag(u)||Ig(u)||Oi(u));if(c=new $a({writableObjectMode:!!(d!=null&&d.writableObjectMode),readableObjectMode:!!(u!=null&&u.writableObjectMode),writable:l,readable:y}),l){if(qa(d))c._write=function(p,w,x){d.write(p,w)?x():n=x},c._final=function(p){d.end(),i=p},d.on("drain",function(){if(n){let p=n;n=null,p()}});else if(gf(d)){let w=(Oi(d)?d.writable:d).getWriter();c._write=async function(x,S,T){try{await w.ready,w.write(x).catch(()=>{}),T()}catch(E){T(E)}},c._final=async function(x){try{await w.ready,w.close().catch(()=>{}),i=x}catch(S){x(S)}}}let g=Oi(u)?u.readable:u;lT(g,()=>{if(i){let p=i;i=null,p()}})}if(y){if(qa(u))u.on("readable",function(){if(o){let g=o;o=null,g()}}),u.on("end",function(){c.push(null)}),c._read=function(){for(;;){let g=u.read();if(g===null){o=c._read;return}if(!c.push(g))return}};else if(gf(u)){let p=(Oi(u)?u.readable:u).getReader();c._read=async function(){for(;;)try{let{value:w,done:x}=await p.read();if(!c.push(w))return;if(x){c.push(null);return}}catch{return}}}}return c._destroy=function(g,p){!g&&s!==null&&(g=new uT),o=null,n=null,i=null,s===null?p(g):(s=p,qa(u)&&aT(u,g))},c}});var Lg=z((s5,Ef)=>{"use strict";var c5=f(h()),Cg=globalThis.AbortController||pa().AbortController,{codes:{ERR_INVALID_ARG_VALUE:fT,ERR_INVALID_ARG_TYPE:js,ERR_MISSING_ARGS:hT,ERR_OUT_OF_RANGE:pT},AbortError:Pr}=wt(),{validateAbortSignal:Ui,validateInteger:yT,validateObject:Ci}=Ks(),mT=ze().Symbol("kWeak"),{finished:gT}=sn(),wT=wf(),{addAbortSignalNoValidate:bT}=Ls(),{isWritable:xT,isNodeStream:ET}=Rr(),{ArrayPrototypePush:vT,MathFloor:ST,Number:AT,NumberIsNaN:TT,Promise:Rg,PromiseReject:Og,PromisePrototypeThen:_T,Symbol:Pg}=ze(),Fa=Pg("kEmpty"),Ug=Pg("kEof");function IT(t,e){if(e!=null&&Ci(e,"options"),e?.signal!=null&&Ui(e.signal,"options.signal"),ET(t)&&!xT(t))throw new fT("stream",t,"must be writable");let r=wT(this,t);return e!=null&&e.signal&&bT(e.signal,r),r}function Va(t,e){if(typeof t!="function")throw new js("fn",["Function","AsyncFunction"],t);e!=null&&Ci(e,"options"),e?.signal!=null&&Ui(e.signal,"options.signal");let r=1;return e?.concurrency!=null&&(r=ST(e.concurrency)),yT(r,"concurrency",1),(async function*(){var i,o;let s=new Cg,c=this,a=[],d=s.signal,u={signal:d},l=()=>s.abort();e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted&&l(),e==null||(o=e.signal)===null||o===void 0||o.addEventListener("abort",l);let y,g,p=!1;function w(){p=!0}async function x(){try{for await(let E of c){var S;if(p)return;if(d.aborted)throw new Pr;try{E=t(E,u)}catch(R){E=Og(R)}E!==Fa&&(typeof((S=E)===null||S===void 0?void 0:S.catch)=="function"&&E.catch(w),a.push(E),y&&(y(),y=null),!p&&a.length&&a.length>=r&&await new Rg(R=>{g=R}))}a.push(Ug)}catch(E){let R=Og(E);_T(R,void 0,w),a.push(R)}finally{var T;p=!0,y&&(y(),y=null),e==null||(T=e.signal)===null||T===void 0||T.removeEventListener("abort",l)}}x();try{for(;;){for(;a.length>0;){let S=await a[0];if(S===Ug)return;if(d.aborted)throw new Pr;S!==Fa&&(yield S),a.shift(),g&&(g(),g=null)}await new Rg(S=>{y=S})}}finally{s.abort(),p=!0,g&&(g(),g=null)}}).call(this)}function BT(t=void 0){return t!=null&&Ci(t,"options"),t?.signal!=null&&Ui(t.signal,"options.signal"),(async function*(){let r=0;for await(let i of this){var n;if(t!=null&&(n=t.signal)!==null&&n!==void 0&&n.aborted)throw new Pr({cause:t.signal.reason});yield[r++,i]}}).call(this)}async function kg(t,e=void 0){for await(let r of xf.call(this,t,e))return!0;return!1}async function DT(t,e=void 0){if(typeof t!="function")throw new js("fn",["Function","AsyncFunction"],t);return!await kg.call(this,async(...r)=>!await t(...r),e)}async function RT(t,e){for await(let r of xf.call(this,t,e))return r}async function OT(t,e){if(typeof t!="function")throw new js("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i),Fa}for await(let n of Va.call(this,r,e));}function xf(t,e){if(typeof t!="function")throw new js("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i)?n:Fa}return Va.call(this,r,e)}var bf=class extends hT{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}};async function UT(t,e,r){var n;if(typeof t!="function")throw new js("reducer",["Function","AsyncFunction"],t);r!=null&&Ci(r,"options"),r?.signal!=null&&Ui(r.signal,"options.signal");let i=arguments.length>1;if(r!=null&&(n=r.signal)!==null&&n!==void 0&&n.aborted){let d=new Pr(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await gT(this.destroy(d)),d}let o=new Cg,s=o.signal;if(r!=null&&r.signal){let d={once:!0,[mT]:this};r.signal.addEventListener("abort",()=>o.abort(),d)}let c=!1;try{for await(let d of this){var a;if(c=!0,r!=null&&(a=r.signal)!==null&&a!==void 0&&a.aborted)throw new Pr;i?e=await t(e,d,{signal:s}):(e=d,i=!0)}if(!c&&!i)throw new bf}finally{o.abort()}return e}async function CT(t){t!=null&&Ci(t,"options"),t?.signal!=null&&Ui(t.signal,"options.signal");let e=[];for await(let n of this){var r;if(t!=null&&(r=t.signal)!==null&&r!==void 0&&r.aborted)throw new Pr(void 0,{cause:t.signal.reason});vT(e,n)}return e}function PT(t,e){let r=Va.call(this,t,e);return(async function*(){for await(let i of r)yield*i}).call(this)}function Kg(t){if(t=AT(t),TT(t))return 0;if(t<0)throw new pT("number",">= 0",t);return t}function kT(t,e=void 0){return e!=null&&Ci(e,"options"),e?.signal!=null&&Ui(e.signal,"options.signal"),t=Kg(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new Pr;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new Pr;t--<=0&&(yield o)}}).call(this)}function KT(t,e=void 0){return e!=null&&Ci(e,"options"),e?.signal!=null&&Ui(e.signal,"options.signal"),t=Kg(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new Pr;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new Pr;if(t-- >0)yield o;else return}}).call(this)}Ef.exports.streamReturningOperators={asIndexedPairs:BT,drop:kT,filter:xf,flatMap:PT,map:Va,take:KT,compose:IT};Ef.exports.promiseReturningOperators={every:DT,forEach:OT,reduce:UT,toArray:CT,some:kg,find:RT}});var vf=z((a5,Mg)=>{"use strict";var u5=f(h()),{ArrayPrototypePop:LT,Promise:MT}=ze(),{isIterable:NT,isNodeStream:$T,isWebStream:qT}=Rr(),{pipelineImpl:FT}=Na(),{finished:VT}=sn();Sf();function HT(...t){return new MT((e,r)=>{let n,i,o=t[t.length-1];if(o&&typeof o=="object"&&!$T(o)&&!NT(o)&&!qT(o)){let s=LT(t);n=s.signal,i=s.end}FT(t,(s,c)=>{s?r(s):e(c)},{signal:n,end:i})})}Mg.exports={finished:VT,pipeline:HT}});var Sf=z((d5,zg)=>{var l5=f(h()),{Buffer:jT}=At(),{ObjectDefineProperty:un,ObjectKeys:qg,ReflectApply:Fg}=ze(),{promisify:{custom:Vg}}=_r(),{streamReturningOperators:Ng,promiseReturningOperators:$g}=Lg(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:Hg}}=wt(),WT=wf(),{pipeline:jg}=Na(),{destroyer:zT}=Ti(),Wg=sn(),Af=vf(),Tf=Rr(),Fe=zg.exports=Aa().Stream;Fe.isDisturbed=Tf.isDisturbed;Fe.isErrored=Tf.isErrored;Fe.isReadable=Tf.isReadable;Fe.Readable=Ns();for(let t of qg(Ng)){let r=function(...n){if(new.target)throw Hg();return Fe.Readable.from(Fg(e,this,n))};_f=r;let e=Ng[t];un(r,"name",{__proto__:null,value:e.name}),un(r,"length",{__proto__:null,value:e.length}),un(Fe.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var _f;for(let t of qg($g)){let r=function(...i){if(new.target)throw Hg();return Fg(e,this,i)};_f=r;let e=$g[t];un(r,"name",{__proto__:null,value:e.name}),un(r,"length",{__proto__:null,value:e.length}),un(Fe.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var _f;Fe.Writable=Zl();Fe.Duplex=Cr();Fe.Transform=sf();Fe.PassThrough=af();Fe.pipeline=jg;var{addAbortSignal:GT}=Ls();Fe.addAbortSignal=GT;Fe.finished=Wg;Fe.destroy=zT;Fe.compose=WT;un(Fe,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return Af}});un(jg,Vg,{__proto__:null,enumerable:!0,get(){return Af.pipeline}});un(Wg,Vg,{__proto__:null,enumerable:!0,get(){return Af.finished}});Fe.Stream=Fe;Fe._isUint8Array=function(e){return e instanceof Uint8Array};Fe._uint8ArrayToBuffer=function(e){return jT.from(e.buffer,e.byteOffset,e.byteLength)}});var If=z((f5,Ve)=>{"use strict";var h5=f(h()),Ye=Sf(),JT=vf(),YT=Ye.Readable.destroy;Ve.exports=Ye.Readable;Ve.exports._uint8ArrayToBuffer=Ye._uint8ArrayToBuffer;Ve.exports._isUint8Array=Ye._isUint8Array;Ve.exports.isDisturbed=Ye.isDisturbed;Ve.exports.isErrored=Ye.isErrored;Ve.exports.isReadable=Ye.isReadable;Ve.exports.Readable=Ye.Readable;Ve.exports.Writable=Ye.Writable;Ve.exports.Duplex=Ye.Duplex;Ve.exports.Transform=Ye.Transform;Ve.exports.PassThrough=Ye.PassThrough;Ve.exports.addAbortSignal=Ye.addAbortSignal;Ve.exports.finished=Ye.finished;Ve.exports.destroy=Ye.destroy;Ve.exports.destroy=YT;Ve.exports.pipeline=Ye.pipeline;Ve.exports.compose=Ye.compose;Object.defineProperty(Ye,"promises",{configurable:!0,enumerable:!0,get(){return JT}});Ve.exports.Stream=Ye.Stream;Ve.exports.default=Ve.exports});var bb=z((Uu,wb)=>{var q3=f(h());(function(t,e){typeof Uu=="object"&&typeof wb<"u"?e(Uu):typeof define=="function"&&define.amd?define(["exports"],e):e(t.URI=t.URI||{})})(Uu,function(t){"use strict";function e(){for(var b=arguments.length,m=Array(b),v=0;v1){m[0]=m[0].slice(0,-1);for(var _=m.length-1,I=1;I<_;++I)m[I]=m[I].slice(1,-1);return m[_]=m[_].slice(1),m.join("")}else return m[0]}function r(b){return"(?:"+b+")"}function n(b){return b===void 0?"undefined":b===null?"null":Object.prototype.toString.call(b).split(" ").pop().split("]").shift().toLowerCase()}function i(b){return b.toUpperCase()}function o(b){return b!=null?b instanceof Array?b:typeof b.length!="number"||b.split||b.setInterval||b.call?[b]:Array.prototype.slice.call(b):[]}function s(b,m){var v=b;if(m)for(var _ in m)v[_]=m[_];return v}function c(b){var m="[A-Za-z]",v="[\\x0D]",_="[0-9]",I="[\\x22]",j=e(_,"[A-Fa-f]"),ue="[\\x0A]",we="[\\x20]",Se=r(r("%[EFef]"+j+"%"+j+j+"%"+j+j)+"|"+r("%[89A-Fa-f]"+j+"%"+j+j)+"|"+r("%"+j+j)),je="[\\:\\/\\?\\#\\[\\]\\@]",me="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",Ke=e(je,me),We=b?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]",Ue=b?"[\\uE000-\\uF8FF]":"[]",be=e(m,_,"[\\-\\.\\_\\~]",We),Le=r(m+e(m,_,"[\\+\\-\\.]")+"*"),Ae=r(r(Se+"|"+e(be,me,"[\\:]"))+"*"),Zn=r(r("25[0-5]")+"|"+r("2[0-4]"+_)+"|"+r("1"+_+_)+"|"+r("[1-9]"+_)+"|"+_),Ct=r(r("25[0-5]")+"|"+r("2[0-4]"+_)+"|"+r("1"+_+_)+"|"+r("0?[1-9]"+_)+"|0?0?"+_),jt=r(Ct+"\\."+Ct+"\\."+Ct+"\\."+Ct),Ie=r(j+"{1,4}"),Pt=r(r(Ie+"\\:"+Ie)+"|"+jt),Wt=r(r(Ie+"\\:")+"{6}"+Pt),br=r("\\:\\:"+r(Ie+"\\:")+"{5}"+Pt),Qn=r(r(Ie)+"?\\:\\:"+r(Ie+"\\:")+"{4}"+Pt),Hr=r(r(r(Ie+"\\:")+"{0,1}"+Ie)+"?\\:\\:"+r(Ie+"\\:")+"{3}"+Pt),is=r(r(r(Ie+"\\:")+"{0,2}"+Ie)+"?\\:\\:"+r(Ie+"\\:")+"{2}"+Pt),Rc=r(r(r(Ie+"\\:")+"{0,3}"+Ie)+"?\\:\\:"+Ie+"\\:"+Pt),Oc=r(r(r(Ie+"\\:")+"{0,4}"+Ie)+"?\\:\\:"+Pt),Gi=r(r(r(Ie+"\\:")+"{0,5}"+Ie)+"?\\:\\:"+Ie),Ji=r(r(r(Ie+"\\:")+"{0,6}"+Ie)+"?\\:\\:"),jr=r([Wt,br,Qn,Hr,is,Rc,Oc,Gi,Ji].join("|")),Yi=r(r(be+"|"+Se)+"+"),Xu=r(jr+"\\%25"+Yi),ei=r(jr+r("\\%25|\\%(?!"+j+"{2})")+Yi),Ax=r("[vV]"+j+"+\\."+e(be,me,"[\\:]")+"+"),Tx=r("\\["+r(ei+"|"+jr+"|"+Ax)+"\\]"),up=r(r(Se+"|"+e(be,me))+"*"),os=r(Tx+"|"+jt+"(?!"+up+")|"+up),ss=r(_+"*"),dp=r(r(Ae+"@")+"?"+os+r("\\:"+ss)+"?"),cs=r(Se+"|"+e(be,me,"[\\:\\@]")),_x=r(cs+"*"),lp=r(cs+"+"),Ix=r(r(Se+"|"+e(be,me,"[\\@]"))+"+"),Wr=r(r("\\/"+_x)+"*"),Xi=r("\\/"+r(lp+Wr)+"?"),Zu=r(Ix+Wr),Uc=r(lp+Wr),Zi="(?!"+cs+")",y6=r(Wr+"|"+Xi+"|"+Zu+"|"+Uc+"|"+Zi),Qi=r(r(cs+"|"+e("[\\/\\?]",Ue))+"*"),as=r(r(cs+"|[\\/\\?]")+"*"),fp=r(r("\\/\\/"+dp+Wr)+"|"+Xi+"|"+Uc+"|"+Zi),Bx=r(Le+"\\:"+fp+r("\\?"+Qi)+"?"+r("\\#"+as)+"?"),Dx=r(r("\\/\\/"+dp+Wr)+"|"+Xi+"|"+Zu+"|"+Zi),Rx=r(Dx+r("\\?"+Qi)+"?"+r("\\#"+as)+"?"),m6=r(Bx+"|"+Rx),g6=r(Le+"\\:"+fp+r("\\?"+Qi)+"?"),w6="^("+Le+")\\:"+r(r("\\/\\/("+r("("+Ae+")@")+"?("+os+")"+r("\\:("+ss+")")+"?)")+"?("+Wr+"|"+Xi+"|"+Uc+"|"+Zi+")")+r("\\?("+Qi+")")+"?"+r("\\#("+as+")")+"?$",b6="^(){0}"+r(r("\\/\\/("+r("("+Ae+")@")+"?("+os+")"+r("\\:("+ss+")")+"?)")+"?("+Wr+"|"+Xi+"|"+Zu+"|"+Zi+")")+r("\\?("+Qi+")")+"?"+r("\\#("+as+")")+"?$",x6="^("+Le+")\\:"+r(r("\\/\\/("+r("("+Ae+")@")+"?("+os+")"+r("\\:("+ss+")")+"?)")+"?("+Wr+"|"+Xi+"|"+Uc+"|"+Zi+")")+r("\\?("+Qi+")")+"?$",E6="^"+r("\\#("+as+")")+"?$",v6="^"+r("("+Ae+")@")+"?("+os+")"+r("\\:("+ss+")")+"?$";return{NOT_SCHEME:new RegExp(e("[^]",m,_,"[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(e("[^\\%\\:]",be,me),"g"),NOT_HOST:new RegExp(e("[^\\%\\[\\]\\:]",be,me),"g"),NOT_PATH:new RegExp(e("[^\\%\\/\\:\\@]",be,me),"g"),NOT_PATH_NOSCHEME:new RegExp(e("[^\\%\\/\\@]",be,me),"g"),NOT_QUERY:new RegExp(e("[^\\%]",be,me,"[\\:\\@\\/\\?]",Ue),"g"),NOT_FRAGMENT:new RegExp(e("[^\\%]",be,me,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(e("[^]",be,me),"g"),UNRESERVED:new RegExp(be,"g"),OTHER_CHARS:new RegExp(e("[^\\%]",be,Ke),"g"),PCT_ENCODED:new RegExp(Se,"g"),IPV4ADDRESS:new RegExp("^("+jt+")$"),IPV6ADDRESS:new RegExp("^\\[?("+jr+")"+r(r("\\%25|\\%(?!"+j+"{2})")+"("+Yi+")")+"?\\]?$")}}var a=c(!1),d=c(!0),u=function(){function b(m,v){var _=[],I=!0,j=!1,ue=void 0;try{for(var we=m[Symbol.iterator](),Se;!(I=(Se=we.next()).done)&&(_.push(Se.value),!(v&&_.length===v));I=!0);}catch(je){j=!0,ue=je}finally{try{!I&&we.return&&we.return()}finally{if(j)throw ue}}return _}return function(m,v){if(Array.isArray(m))return m;if(Symbol.iterator in Object(m))return b(m,v);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),l=function(b){if(Array.isArray(b)){for(var m=0,v=Array(b.length);m= 0x80 (not a basic code point)","invalid-input":"Invalid input"},$=g-p,N=Math.floor,q=String.fromCharCode;function V(b){throw new RangeError(P[b])}function X(b,m){for(var v=[],_=b.length;_--;)v[_]=m(b[_]);return v}function ce(b,m){var v=b.split("@"),_="";v.length>1&&(_=v[0]+"@",b=v[1]),b=b.replace(k,".");var I=b.split("."),j=X(I,m).join(".");return _+j}function U(b){for(var m=[],v=0,_=b.length;v<_;){var I=b.charCodeAt(v++);if(I>=55296&&I<=56319&&v<_){var j=b.charCodeAt(v++);(j&64512)==56320?m.push(((I&1023)<<10)+(j&1023)+65536):(m.push(I),v--)}else m.push(I)}return m}var L=function(m){return String.fromCodePoint.apply(String,l(m))},H=function(m){return m-48<10?m-22:m-65<26?m-65:m-97<26?m-97:g},C=function(m,v){return m+22+75*(m<26)-((v!=0)<<5)},A=function(m,v,_){var I=0;for(m=_?N(m/S):m>>1,m+=N(m/v);m>$*w>>1;I+=g)m=N(m/$);return N(I+($+1)*m/(m+x))},K=function(m){var v=[],_=m.length,I=0,j=E,ue=T,we=m.lastIndexOf(R);we<0&&(we=0);for(var Se=0;Se=128&&V("not-basic"),v.push(m.charCodeAt(Se));for(var je=we>0?we+1:0;je<_;){for(var me=I,Ke=1,We=g;;We+=g){je>=_&&V("invalid-input");var Ue=H(m.charCodeAt(je++));(Ue>=g||Ue>N((y-I)/Ke))&&V("overflow"),I+=Ue*Ke;var be=We<=ue?p:We>=ue+w?w:We-ue;if(UeN(y/Le)&&V("overflow"),Ke*=Le}var Ae=v.length+1;ue=A(I-me,Ae,me==0),N(I/Ae)>y-j&&V("overflow"),j+=N(I/Ae),I%=Ae,v.splice(I++,0,j)}return String.fromCodePoint.apply(String,v)},M=function(m){var v=[];m=U(m);var _=m.length,I=E,j=0,ue=T,we=!0,Se=!1,je=void 0;try{for(var me=m[Symbol.iterator](),Ke;!(we=(Ke=me.next()).done);we=!0){var We=Ke.value;We<128&&v.push(q(We))}}catch(ei){Se=!0,je=ei}finally{try{!we&&me.return&&me.return()}finally{if(Se)throw je}}var Ue=v.length,be=Ue;for(Ue&&v.push(R);be<_;){var Le=y,Ae=!0,Zn=!1,Ct=void 0;try{for(var jt=m[Symbol.iterator](),Ie;!(Ae=(Ie=jt.next()).done);Ae=!0){var Pt=Ie.value;Pt>=I&&PtN((y-j)/Wt)&&V("overflow"),j+=(Le-I)*Wt,I=Le;var br=!0,Qn=!1,Hr=void 0;try{for(var is=m[Symbol.iterator](),Rc;!(br=(Rc=is.next()).done);br=!0){var Oc=Rc.value;if(Ocy&&V("overflow"),Oc==I){for(var Gi=j,Ji=g;;Ji+=g){var jr=Ji<=ue?p:Ji>=ue+w?w:Ji-ue;if(Gi>6|192).toString(16).toUpperCase()+"%"+(m&63|128).toString(16).toUpperCase():v="%"+(m>>12|224).toString(16).toUpperCase()+"%"+(m>>6&63|128).toString(16).toUpperCase()+"%"+(m&63|128).toString(16).toUpperCase(),v}function oe(b){for(var m="",v=0,_=b.length;v<_;){var I=parseInt(b.substr(v+1,2),16);if(I<128)m+=String.fromCharCode(I),v+=3;else if(I>=194&&I<224){if(_-v>=6){var j=parseInt(b.substr(v+4,2),16);m+=String.fromCharCode((I&31)<<6|j&63)}else m+=b.substr(v,6);v+=6}else if(I>=224){if(_-v>=9){var ue=parseInt(b.substr(v+4,2),16),we=parseInt(b.substr(v+7,2),16);m+=String.fromCharCode((I&15)<<12|(ue&63)<<6|we&63)}else m+=b.substr(v,9);v+=9}else m+=b.substr(v,3),v+=3}return m}function xe(b,m){function v(_){var I=oe(_);return I.match(m.UNRESERVED)?I:_}return b.scheme&&(b.scheme=String(b.scheme).replace(m.PCT_ENCODED,v).toLowerCase().replace(m.NOT_SCHEME,"")),b.userinfo!==void 0&&(b.userinfo=String(b.userinfo).replace(m.PCT_ENCODED,v).replace(m.NOT_USERINFO,Q).replace(m.PCT_ENCODED,i)),b.host!==void 0&&(b.host=String(b.host).replace(m.PCT_ENCODED,v).toLowerCase().replace(m.NOT_HOST,Q).replace(m.PCT_ENCODED,i)),b.path!==void 0&&(b.path=String(b.path).replace(m.PCT_ENCODED,v).replace(b.scheme?m.NOT_PATH:m.NOT_PATH_NOSCHEME,Q).replace(m.PCT_ENCODED,i)),b.query!==void 0&&(b.query=String(b.query).replace(m.PCT_ENCODED,v).replace(m.NOT_QUERY,Q).replace(m.PCT_ENCODED,i)),b.fragment!==void 0&&(b.fragment=String(b.fragment).replace(m.PCT_ENCODED,v).replace(m.NOT_FRAGMENT,Q).replace(m.PCT_ENCODED,i)),b}function ge(b){return b.replace(/^0*(.*)/,"$1")||"0"}function Ne(b,m){var v=b.match(m.IPV4ADDRESS)||[],_=u(v,2),I=_[1];return I?I.split(".").map(ge).join("."):b}function He(b,m){var v=b.match(m.IPV6ADDRESS)||[],_=u(v,3),I=_[1],j=_[2];if(I){for(var ue=I.toLowerCase().split("::").reverse(),we=u(ue,2),Se=we[0],je=we[1],me=je?je.split(":").map(ge):[],Ke=Se.split(":").map(ge),We=m.IPV4ADDRESS.test(Ke[Ke.length-1]),Ue=We?7:8,be=Ke.length-Ue,Le=Array(Ue),Ae=0;Ae1){var Ie=Le.slice(0,Ct.index),Pt=Le.slice(Ct.index+Ct.length);jt=Ie.join(":")+"::"+Pt.join(":")}else jt=Le.join(":");return j&&(jt+="%"+j),jt}else return b}var $e=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,rt="".match(/(){0}/)[1]===void 0;function Ge(b){var m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},v={},_=m.iri!==!1?d:a;m.reference==="suffix"&&(b=(m.scheme?m.scheme+":":"")+"//"+b);var I=b.match($e);if(I){rt?(v.scheme=I[1],v.userinfo=I[3],v.host=I[4],v.port=parseInt(I[5],10),v.path=I[6]||"",v.query=I[7],v.fragment=I[8],isNaN(v.port)&&(v.port=I[5])):(v.scheme=I[1]||void 0,v.userinfo=b.indexOf("@")!==-1?I[3]:void 0,v.host=b.indexOf("//")!==-1?I[4]:void 0,v.port=parseInt(I[5],10),v.path=I[6]||"",v.query=b.indexOf("?")!==-1?I[7]:void 0,v.fragment=b.indexOf("#")!==-1?I[8]:void 0,isNaN(v.port)&&(v.port=b.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?I[4]:void 0)),v.host&&(v.host=He(Ne(v.host,_),_)),v.scheme===void 0&&v.userinfo===void 0&&v.host===void 0&&v.port===void 0&&!v.path&&v.query===void 0?v.reference="same-document":v.scheme===void 0?v.reference="relative":v.fragment===void 0?v.reference="absolute":v.reference="uri",m.reference&&m.reference!=="suffix"&&m.reference!==v.reference&&(v.error=v.error||"URI is not a "+m.reference+" reference.");var j=ne[(m.scheme||v.scheme||"").toLowerCase()];if(!m.unicodeSupport&&(!j||!j.unicodeSupport)){if(v.host&&(m.domainHost||j&&j.domainHost))try{v.host=re.toASCII(v.host.replace(_.PCT_ENCODED,oe).toLowerCase())}catch(ue){v.error=v.error||"Host's domain name can not be converted to ASCII via punycode: "+ue}xe(v,a)}else xe(v,_);j&&j.parse&&j.parse(v,m)}else v.error=v.error||"URI can not be parsed.";return v}function Vr(b,m){var v=m.iri!==!1?d:a,_=[];return b.userinfo!==void 0&&(_.push(b.userinfo),_.push("@")),b.host!==void 0&&_.push(He(Ne(String(b.host),v),v).replace(v.IPV6ADDRESS,function(I,j,ue){return"["+j+(ue?"%25"+ue:"")+"]"})),(typeof b.port=="number"||typeof b.port=="string")&&(_.push(":"),_.push(String(b.port))),_.length?_.join(""):void 0}var vn=/^\.\.?\//,es=/^\/\.(\/|$)/,Ac=/^\/\.\.(\/|$)/,Gu=/^\/?(?:.|\n)*?(?=\/|$)/;function Sn(b){for(var m=[];b.length;)if(b.match(vn))b=b.replace(vn,"");else if(b.match(es))b=b.replace(es,"/");else if(b.match(Ac))b=b.replace(Ac,"/"),m.pop();else if(b==="."||b==="..")b="";else{var v=b.match(Gu);if(v){var _=v[0];b=b.slice(_.length),m.push(_)}else throw new Error("Unexpected dot segment condition")}return m.join("")}function Vt(b){var m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},v=m.iri?d:a,_=[],I=ne[(m.scheme||b.scheme||"").toLowerCase()];if(I&&I.serialize&&I.serialize(b,m),b.host&&!v.IPV6ADDRESS.test(b.host)){if(m.domainHost||I&&I.domainHost)try{b.host=m.iri?re.toUnicode(b.host):re.toASCII(b.host.replace(v.PCT_ENCODED,oe).toLowerCase())}catch(we){b.error=b.error||"Host's domain name can not be converted to "+(m.iri?"Unicode":"ASCII")+" via punycode: "+we}}xe(b,v),m.reference!=="suffix"&&b.scheme&&(_.push(b.scheme),_.push(":"));var j=Vr(b,m);if(j!==void 0&&(m.reference!=="suffix"&&_.push("//"),_.push(j),b.path&&b.path.charAt(0)!=="/"&&_.push("/")),b.path!==void 0){var ue=b.path;!m.absolutePath&&(!I||!I.absolutePath)&&(ue=Sn(ue)),j===void 0&&(ue=ue.replace(/^\/\//,"/%2F")),_.push(ue)}return b.query!==void 0&&(_.push("?"),_.push(b.query)),b.fragment!==void 0&&(_.push("#"),_.push(b.fragment)),_.join("")}function ts(b,m){var v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},_=arguments[3],I={};return _||(b=Ge(Vt(b,v),v),m=Ge(Vt(m,v),v)),v=v||{},!v.tolerant&&m.scheme?(I.scheme=m.scheme,I.userinfo=m.userinfo,I.host=m.host,I.port=m.port,I.path=Sn(m.path||""),I.query=m.query):(m.userinfo!==void 0||m.host!==void 0||m.port!==void 0?(I.userinfo=m.userinfo,I.host=m.host,I.port=m.port,I.path=Sn(m.path||""),I.query=m.query):(m.path?(m.path.charAt(0)==="/"?I.path=Sn(m.path):((b.userinfo!==void 0||b.host!==void 0||b.port!==void 0)&&!b.path?I.path="/"+m.path:b.path?I.path=b.path.slice(0,b.path.lastIndexOf("/")+1)+m.path:I.path=m.path,I.path=Sn(I.path)),I.query=m.query):(I.path=b.path,m.query!==void 0?I.query=m.query:I.query=b.query),I.userinfo=b.userinfo,I.host=b.host,I.port=b.port),I.scheme=b.scheme),I.fragment=m.fragment,I}function Tc(b,m,v){var _=s({scheme:"null"},v);return Vt(ts(Ge(b,_),Ge(m,_),_,!0),_)}function rs(b,m){return typeof b=="string"?b=Vt(Ge(b,m),m):n(b)==="object"&&(b=Ge(Vt(b,m),m)),b}function _c(b,m,v){return typeof b=="string"?b=Vt(Ge(b,v),v):n(b)==="object"&&(b=Vt(b,v)),typeof m=="string"?m=Vt(Ge(m,v),v):n(m)==="object"&&(m=Vt(m,v)),b===m}function Ic(b,m){return b&&b.toString().replace(!m||!m.iri?a.ESCAPE:d.ESCAPE,Q)}function Ht(b,m){return b&&b.toString().replace(!m||!m.iri?a.PCT_ENCODED:d.PCT_ENCODED,oe)}var An={scheme:"http",domainHost:!0,parse:function(m,v){return m.host||(m.error=m.error||"HTTP URIs must have a host."),m},serialize:function(m,v){var _=String(m.scheme).toLowerCase()==="https";return(m.port===(_?443:80)||m.port==="")&&(m.port=void 0),m.path||(m.path="/"),m}},ns={scheme:"https",domainHost:An.domainHost,parse:An.parse,serialize:An.serialize};function Bc(b){return typeof b.secure=="boolean"?b.secure:String(b.scheme).toLowerCase()==="wss"}var Xn={scheme:"ws",domainHost:!0,parse:function(m,v){var _=m;return _.secure=Bc(_),_.resourceName=(_.path||"/")+(_.query?"?"+_.query:""),_.path=void 0,_.query=void 0,_},serialize:function(m,v){if((m.port===(Bc(m)?443:80)||m.port==="")&&(m.port=void 0),typeof m.secure=="boolean"&&(m.scheme=m.secure?"wss":"ws",m.secure=void 0),m.resourceName){var _=m.resourceName.split("?"),I=u(_,2),j=I[0],ue=I[1];m.path=j&&j!=="/"?j:void 0,m.query=ue,m.resourceName=void 0}return m.fragment=void 0,m}},Dc={scheme:"wss",domainHost:Xn.domainHost,parse:Xn.parse,serialize:Xn.serialize},Ju={},hx=!0,ip="[A-Za-z0-9\\-\\.\\_\\~"+(hx?"\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF":"")+"]",wr="[0-9A-Fa-f]",px=r(r("%[EFef]"+wr+"%"+wr+wr+"%"+wr+wr)+"|"+r("%[89A-Fa-f]"+wr+"%"+wr+wr)+"|"+r("%"+wr+wr)),yx="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",mx="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",gx=e(mx,'[\\"\\\\]'),wx="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",bx=new RegExp(ip,"g"),zi=new RegExp(px,"g"),xx=new RegExp(e("[^]",yx,"[\\.]",'[\\"]',gx),"g"),op=new RegExp(e("[^]",ip,wx),"g"),Ex=op;function Yu(b){var m=oe(b);return m.match(bx)?m:b}var sp={scheme:"mailto",parse:function(m,v){var _=m,I=_.to=_.path?_.path.split(","):[];if(_.path=void 0,_.query){for(var j=!1,ue={},we=_.query.split("&"),Se=0,je=we.length;Se{"use strict";var Q3=f(h());xb.exports=function t(e){if(typeof e=="number"&&isNaN(e))throw new Error("NaN is not allowed");if(typeof e=="number"&&!isFinite(e))throw new Error("Infinity is not allowed");return e===null||typeof e!="object"?JSON.stringify(e):e.toJSON instanceof Function?t(e.toJSON()):Array.isArray(e)?`[${e.reduce((i,o,s)=>`${i}${s===0?"":","}${t(o===void 0||typeof o=="symbol"?null:o)}`,"")}]`:`{${Object.keys(e).sort().reduce((n,i)=>{if(e[i]===void 0||typeof e[i]=="symbol")return n;let o=n.length===0?"":",";return`${n}${o}${t(i)}:${t(e[i])}`},"")}}`}});var ax=z((a4,cx)=>{var u4=f(h()),Xo=1e3,Zo=Xo*60,Qo=Zo*60,Wi=Qo*24,u6=Wi*7,d6=Wi*365.25;cx.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return l6(t);if(r==="number"&&isFinite(t))return e.long?h6(t):f6(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function l6(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*d6;case"weeks":case"week":case"w":return r*u6;case"days":case"day":case"d":return r*Wi;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Qo;case"minutes":case"minute":case"mins":case"min":case"m":return r*Zo;case"seconds":case"second":case"secs":case"sec":case"s":return r*Xo;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function f6(t){var e=Math.abs(t);return e>=Wi?Math.round(t/Wi)+"d":e>=Qo?Math.round(t/Qo)+"h":e>=Zo?Math.round(t/Zo)+"m":e>=Xo?Math.round(t/Xo)+"s":t+"ms"}function h6(t){var e=Math.abs(t);return e>=Wi?zu(t,e,Wi,"day"):e>=Qo?zu(t,e,Qo,"hour"):e>=Zo?zu(t,e,Zo,"minute"):e>=Xo?zu(t,e,Xo,"second"):t+" ms"}function zu(t,e,r,n){var i=e>=r*1.5;return Math.round(t/r)+" "+n+(i?"s":"")}});var dx=z(ux=>{var l4=f(h());ux.Level=pl().BrowserLevel});var p6={};us(p6,{BearerDid:()=>xt,Did:()=>Pe,DidDht:()=>pc,DidDhtDocument:()=>yc,DidDhtRegisteredDidType:()=>vh,DidDhtRegisteredKeyType:()=>Ou,DidDhtUtils:()=>et,DidDhtVerificationRelationship:()=>Sh,DidError:()=>J,DidErrorCode:()=>Gr,DidIon:()=>Xh,DidIonRegisteredKeyType:()=>ox,DidIonUtils:()=>Yn,DidJwk:()=>Zh,DidKey:()=>Qh,DidKeyRegisteredKeyType:()=>sx,DidKeyUtils:()=>or,DidKeyVerificationMethodType:()=>ju,DidMethod:()=>qt,DidResolverCacheLevel:()=>tp,DidResolverCacheNoop:()=>rp,DidVerificationRelationship:()=>ni,DidWeb:()=>ep,EMPTY_DID_RESOLUTION_RESULT:()=>Ce,UniversalResolver:()=>np,utils:()=>ch});var v4=f(h(),1);var P6=f(h(),1),ni=(o=>(o.authentication="authentication",o.assertionMethod="assertionMethod",o.keyAgreement="keyAgreement",o.capabilityInvocation="capabilityInvocation",o.capabilityDelegation="capabilityDelegation",o))(ni||{});var K6=f(h(),1),Ce={"@context":"https://w3id.org/did-resolution/v1",didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};var M6=f(h(),1),Je=class Je{constructor({method:e,id:r,path:n,query:i,fragment:o,params:s}){this.uri=`did:${e}:${r}`,this.method=e,this.id=r,this.path=n,this.query=i,this.fragment=o,this.params=s}static parse(e){if(!e)return null;let r=Je.DID_URI_PATTERN.exec(e);if(!r||!r.groups)return null;let{method:n,id:i,path:o,query:s,fragment:c}=r.groups,a={uri:`did:${n}:${i}`,method:n,id:i};if(o&&(a.path=o),s&&(a.query=s.slice(1)),c&&(a.fragment=c.slice(1)),s){let d={},u=s.slice(1).split("&");for(let l of u){let[y,g]=l.split("=");d[y]=g}a.params=d}return a}};Je.METHOD_PATTERN="([a-z0-9]+)",Je.PCT_ENCODED_PATTERN="(?:%[0-9a-fA-F]{2})",Je.ID_CHAR_PATTERN=`(?:[a-zA-Z0-9._-]|${Je.PCT_ENCODED_PATTERN})`,Je.METHOD_ID_PATTERN=`((?:${Je.ID_CHAR_PATTERN}*:)*(${Je.ID_CHAR_PATTERN}+))`,Je.PATH_PATTERN="(/[^#?]*)?",Je.QUERY_PATTERN="([?][^#]*)?",Je.FRAGMENT_PATTERN="(#.*)?",Je.DID_URI_PATTERN=new RegExp(`^did:(?${Je.METHOD_PATTERN}):(?${Je.METHOD_ID_PATTERN})(?${Je.PATH_PATTERN})(?${Je.QUERY_PATTERN})(?${Je.FRAGMENT_PATTERN})$`);var Pe=Je;var $6=f(h(),1),J=class t extends Error{constructor(r,n){super(`${r}: ${n}`);this.code=r;this.name="DidError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,t)}},Gr=(p=>(p.InvalidDid="invalidDid",p.MethodNotSupported="methodNotSupported",p.InternalError="internalError",p.InvalidDidDocument="invalidDidDocument",p.InvalidDidDocumentLength="invalidDidDocumentLength",p.InvalidDidUrl="invalidDidUrl",p.InvalidPreviousDidProof="invalidPreviousDidProof",p.InvalidPublicKey="invalidPublicKey",p.InvalidPublicKeyLength="invalidPublicKeyLength",p.InvalidPublicKeyType="invalidPublicKeyType",p.InvalidSignature="invalidSignature",p.NotFound="notFound",p.RepresentationNotSupported="representationNotSupported",p.UnsupportedPublicKeyType="unsupportedPublicKeyType",p))(Gr||{});var dk=f(h(),1);var BP=f(h(),1);var sC=f(h(),1);var x5=f(h(),1);var H6=f(h(),1),wE=f(Kp(),1);var BD=f(h(),1);var dD=f(h(),1);var eD=f(h(),1);var W6=f(h(),1);function bE(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,R=new Uint8Array(E);S!==T;){for(var D=p[S],O=0,k=E-1;(D!==0||O>>0,R[k]=D%c>>>0,D=D/c>>>0;if(D!==0)throw new Error("Non-zero carry");x=O,S++}for(var P=E-x;P!==E&&R[P]===0;)P++;for(var $=a.repeat(w);P>>0,E=new Uint8Array(T);p[w];){var R=r[p.charCodeAt(w)];if(R===255)return;for(var D=0,O=T-1;(R!==0||D>>0,E[O]=R%256>>>0,R=R/256>>>0;if(R!==0)throw new Error("Non-zero carry");S=D,w++}if(p[w]!==" "){for(var k=T-S;k!==T&&E[k]===0;)k++;for(var P=new Uint8Array(x+(T-k)),$=x;k!==T;)P[$++]=E[k++];return P}}}function g(p){var w=y(p);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:y,decode:g}}var xE=bE,EE=xE,Lp=EE;var G6=f(h(),1),z6=new Uint8Array(0);var Mp=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var J6=f(h(),1);var ld=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},fd=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Np(this,e)}},hd=class{constructor(e){this.decoders=e}or(e){return Np(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Np=(t,e)=>new hd({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),pd=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new ld(e,r,n),this.decoder=new fd(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},$p=({name:t,prefix:e,encode:r,decode:n})=>new pd(t,e,r,n),yd=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:i}=Lp(r,e);return $p({prefix:t,name:e,encode:n,decode:o=>io(i(o))})},SE=(t,e,r,n)=>{let i={};for(let u=0;u=8&&(c-=8,s[d++]=255&a>>c)}if(c>=r||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return s},AE=(t,e,r)=>{let n=e[e.length-1]==="=",i=(1<r;)s-=r,o+=e[i&c>>s];if(s&&(o+=e[i&c<$p({prefix:e,name:t,encode(i){return AE(i,n,r)},decode(i){return SE(i,n,r,t)}});var ls=gt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),rD=gt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),nD=gt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),iD=gt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),oD=gt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),sD=gt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),cD=gt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),aD=gt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),md=gt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var pD=f(h(),1);var Tt=yd({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),fD=yd({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var xD=f(h(),1);var mD=gt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),gD=gt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),vr=gt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wD=gt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var vD=f(h(),1);function qp(t){return t.byteOffset!==0||t.byteLength!==t.buffer.byteLength}function Fp(t){return typeof t!="object"||t===null?!1:typeof t[Symbol.asyncIterator]=="function"}function oo(t){let r=Object.prototype.toString.call(t).match(/\s([a-zA-Z0-9]+)/),[n,i]=r;return i}var fs=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{d(n.next(u))}catch(l){s(l)}}function a(u){try{d(n.throw(u))}catch(l){s(l)}}function d(u){u.done?o(u.value):i(u.value).then(c,a)}d((n=n.apply(t,e||[])).next())})},Vp=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=t[o]&&function(s){return new Promise(function(c,a){s=t[o](s),i(c,a,s.done,s.value)})}}function i(o,s,c,a){Promise.resolve(a).then(function(d){o({value:d,done:c})},s)}},Mc=new TextEncoder,ii=new TextDecoder,W=class t{constructor(e,r){this.data=e,this.format=r}static arrayBuffer(e){return new t(e,"ArrayBuffer")}static asyncIterable(e){if(!Fp(e))throw new TypeError("Input must be of type AsyncIterable.");return new t(e,"AsyncIterable")}static base32Z(e){return new t(e,"Base32Z")}static base58Btc(e){return new t(e,"Base58Btc")}static base64Url(e){return new t(e,"Base64Url")}static bufferSource(e){return new t(e,"BufferSource")}static hex(e){if(typeof e!="string")throw new TypeError("Hex input must be a string.");if(e.length%2!==0)throw new TypeError("Hex input must have an even number of characters.");return new t(e,"Hex")}static multibase(e){return new t(e,"Multibase")}static object(e){return new t(e,"Object")}static string(e){return new t(e,"String")}static uint8Array(e){return new t(e,"Uint8Array")}toArrayBuffer(){switch(this.format){case"Base58Btc":return Tt.baseDecode(this.data).buffer;case"Base64Url":return vr.baseDecode(this.data).buffer;case"BufferSource":{if(oo(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return qp(this.data)?this.data.buffer.slice(this.data.byteOffset,this.data.byteOffset+this.data.byteLength):this.data.buffer;throw new TypeError(`${this.format} value is not of type: ArrayBuffer, DataView, or TypedArray.`)}case"Hex":return this.toUint8Array().buffer;case"String":return this.toUint8Array().buffer;case"Uint8Array":return this.data.buffer;default:throw new TypeError(`Conversion from ${this.format} to ArrayBuffer is not supported.`)}}toArrayBufferAsync(){return fs(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":return yield(yield this.toBlobAsync()).arrayBuffer();default:throw new TypeError(`Asynchronous conversion from ${this.format} to ArrayBuffer is not supported.`)}})}toBase32Z(){switch(this.format){case"Uint8Array":return md.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Z is not supported.`)}}toBase58Btc(){switch(this.format){case"ArrayBuffer":{let e=new Uint8Array(this.data);return Tt.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return Tt.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base58Btc is not supported.`)}}toBase64Url(){switch(this.format){case"ArrayBuffer":{let e=new Uint8Array(this.data);return vr.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return vr.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),r=Mc.encode(e);return vr.baseEncode(r)}case"String":{let e=Mc.encode(this.data);return vr.baseEncode(e)}case"Uint8Array":return vr.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){var e,r,n,i;return fs(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let a=[];try{for(var o=!0,s=Vp(this.data),c;c=yield s.next(),e=c.done,!e;o=!0){i=c.value,o=!1;let u=i;a.push(u)}}catch(u){r={error:u}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return new Blob(a)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Blob is not supported.`)}})}toHex(){let e=Array.from({length:256},(r,n)=>n.toString(16).padStart(2,"0"));switch(this.format){case"ArrayBuffer":{let r=this.toUint8Array();return t.uint8Array(r).toHex()}case"Base64Url":{let r=this.toUint8Array();return t.uint8Array(r).toHex()}case"Uint8Array":{let r="";for(let n=0;nso,encodeTo:()=>oi,encodingLength:()=>si});var UD=f(h(),1);var RD=f(h(),1),TE=Wp,Hp=128,_E=127,IE=~_E,BE=Math.pow(2,31);function Wp(t,e,r){e=e||[],r=r||0;for(var n=r;t>=BE;)e[r++]=t&255|Hp,t/=128;for(;t&IE;)e[r++]=t&255|Hp,t>>>=7;return e[r]=t|0,Wp.bytes=r-n+1,e}var DE=gd,RE=128,jp=127;function gd(t,n){var r=0,n=n||0,i=0,o=n,s,c=t.length;do{if(o>=c)throw gd.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&jp)<=RE);return gd.bytes=o-n,r}var OE=Math.pow(2,7),UE=Math.pow(2,14),CE=Math.pow(2,21),PE=Math.pow(2,28),kE=Math.pow(2,35),KE=Math.pow(2,42),LE=Math.pow(2,49),ME=Math.pow(2,56),NE=Math.pow(2,63),$E=function(t){return t[hs.decode(t,e),hs.decode.bytes],oi=(t,e,r=0)=>(hs.encode(t,e,r),e),si=t=>hs.encodingLength(t);var PD=f(h(),1);var wd=(t,e)=>{let r=e.byteLength,n=si(t),i=n+si(r),o=new Uint8Array(i+r);return oi(t,o,0),oi(r,o,n),o.set(e,i),new co(t,r,e,o)},zp=t=>{let e=io(t),[r,n]=so(e),[i,o]=so(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new co(r,i,s,e)},Gp=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Mp(t.bytes,r.bytes)}},co=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};var kD=f(h(),1);var Jp=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return HE(r,xd(t),e||Tt.encoder);default:return jE(r,xd(t),e||ls.encoder)}};var Yp=new WeakMap,xd=t=>{let e=Yp.get(t);if(e==null){let r=new Map;return Yp.set(t,r),r}return e},Ed=class t{constructor(e,r,n,i){this.code=r,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==ps)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==WE)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=wd(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&Gp(e.multihash,n.multihash)}toString(e){return Jp(this,e)}toJSON(){return{"/":Jp(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:i,multihash:o,bytes:s}=r;return new t(n,i,o,s||Xp(n,i,o.bytes))}else if(r[zE]===!0){let{version:n,multihash:i,code:o}=r,s=zp(i);return t.create(n,o,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==ps)throw new Error(`Version 0 CID must use dag-pb (code: ${ps}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=Xp(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,ps,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,i=io(e.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let o=i.subarray(r.multihashSize-r.digestSize),s=new co(r.multihashCode,r.digestSize,o,i);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,y]=so(e.subarray(r));return r+=y,l},i=n(),o=ps;if(i===18?(i=0,r=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=r,c=n(),a=n(),d=r+a,u=d-s;return{version:i,codec:o,multihashCode:c,digestSize:a,multihashSize:u,size:d}}static parse(e,r){let[n,i]=VE(e,r),o=t.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return xd(o).set(n,e),o}},VE=(t,e)=>{switch(t[0]){case"Q":{let r=e||Tt;return[Tt.prefix,r.decode(`${Tt.prefix}${t}`)]}case Tt.prefix:{let r=e||Tt;return[Tt.prefix,r.decode(t)]}case ls.prefix:{let r=e||ls;return[ls.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},HE=(t,e,r)=>{let{prefix:n}=r;if(n!==Tt.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=e.get(n);if(i==null){let o=r.encode(t).slice(1);return e.set(n,o),o}else return i},jE=(t,e,r)=>{let{prefix:n}=r,i=e.get(n);if(i==null){let o=r.encode(t);return e.set(n,o),o}else return i},ps=112,WE=18,Xp=(t,e,r)=>{let n=si(t),i=n+si(e),o=new Uint8Array(i+r.byteLength);return oi(t,o,0),oi(e,o,n),o.set(r,i),o},zE=Symbol.for("@ipld/js-cid/CID");var VD=f(h(),1);var HD=f(h(),1);var pt=class t{static addPrefix(e){var r;let{code:n,data:i,name:o}=e;if(!(o?!n:n))throw new Error("Either 'name' or 'code' must be defined, but not both.");if(n=t.codeToName.has(n)?n:t.nameToCode.get(o),n===void 0)throw new Error(`Unsupported multicodec: ${(r=e.name)!==null&&r!==void 0?r:e.code}`);let s=Jr.encodingLength(n),c=new Uint8Array(s+i.byteLength);return c.set(i,s),Jr.encodeTo(n,c),c}static getCodeFromData(e){let{prefixedData:r}=e,[n,i]=Jr.decode(r);return n}static getCodeFromName(e){let{name:r}=e,n=t.nameToCode.get(r);if(n===void 0)throw new Error(`Unsupported multicodec: ${r}`);return n}static getNameFromCode(e){let{code:r}=e,n=t.codeToName.get(r);if(n===void 0)throw new Error(`Unsupported multicodec: ${r}`);return n}static registerCodec(e){t.codeToName.set(e.code,e.name),t.nameToCode.set(e.name,e.code)}static removePrefix(e){let{prefixedData:r}=e,[n,i]=Jr.decode(r),o=t.codeToName.get(n);if(o===void 0)throw new Error(`Unsupported multicodec: ${n}`);return{code:n,data:r.slice(i),name:o}}};pt.codeToName=new Map;pt.nameToCode=new Map;pt.registerCodec({code:237,name:"ed25519-pub"});pt.registerCodec({code:4864,name:"ed25519-priv"});pt.registerCodec({code:236,name:"x25519-pub"});pt.registerCodec({code:4866,name:"x25519-priv"});pt.registerCodec({code:231,name:"secp256k1-pub"});pt.registerCodec({code:4865,name:"secp256k1-priv"});var QD=f(h(),1);function vd(t){Object.keys(t).forEach(e=>{t[e]===void 0?delete t[e]:typeof t[e]=="object"&&vd(t[e])})}var aR=f(h(),1),ev=f(u0(),1),Ei=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{d(n.next(u))}catch(l){s(l)}}function a(u){try{d(n.throw(u))}catch(l){s(l)}}function d(u){u.done?o(u.value):i(u.value).then(c,a)}d((n=n.apply(t,e||[])).next())})};var fa=class{constructor(){this.store=new Map}clear(){return Ei(this,void 0,void 0,function*(){this.store.clear()})}close(){return Ei(this,void 0,void 0,function*(){})}delete(e){return Ei(this,void 0,void 0,function*(){return this.store.delete(e)})}get(e){return Ei(this,void 0,void 0,function*(){return this.store.get(e)})}has(e){return Ei(this,void 0,void 0,function*(){return this.store.has(e)})}list(){return Ei(this,void 0,void 0,function*(){return Array.from(this.store.values())})}set(e,r){return Ei(this,void 0,void 0,function*(){this.store.set(e,r)})}};var lR=f(h(),1);var w5=f(h(),1),XT=f(If(),1);var ZT=f(If(),1);var Q5=f(h(),1);var z5=f(h(),1);var H5=f(h(),1);var $5=f(h(),1);var R5=f(h(),1);function Gg(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function QT(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Bf(t,...e){if(!QT(t))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function Jg(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Gg(t.outputLen),Gg(t.blockLen)}function Do(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Yg(t,e){Bf(t);let r=e.outputLen;if(t.lengthnew DataView(t.buffer,t.byteOffset,t.byteLength),lr=(t,e)=>t<<32-e|t>>>e,e_=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!e_)throw new Error("Non little-endian hardware is not supported");function Df(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Ws(t){if(typeof t=="string"&&(t=Df(t)),!Xg(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function ja(...t){let e=0;for(let n=0;nt().update(Ws(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Pi(t=32){if(Ro&&typeof Ro.getRandomValues=="function")return Ro.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function t_(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),c=Number(r&o),a=n?4:0,d=n?0:4;t.setUint32(e+a,s,n),t.setUint32(e+d,c,n)}var Uo=class extends Oo{constructor(e,r,n,i){super(),this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Ha(this.buffer)}update(e){Do(this);let{view:r,buffer:n,blockLen:i}=this;e=Ws(e);let o=e.length;for(let s=0;si-s&&(this.process(n,0),s=0);for(let l=s;lu.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;lt&e^~t&r,n_=(t,e,r)=>t&e^t&r^e&r,i_=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Mn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Nn=new Uint32Array(64),Rf=class extends Uo{constructor(){super(64,32,8,!1),this.A=Mn[0]|0,this.B=Mn[1]|0,this.C=Mn[2]|0,this.D=Mn[3]|0,this.E=Mn[4]|0,this.F=Mn[5]|0,this.G=Mn[6]|0,this.H=Mn[7]|0}get(){let{A:e,B:r,C:n,D:i,E:o,F:s,G:c,H:a}=this;return[e,r,n,i,o,s,c,a]}set(e,r,n,i,o,s,c,a){this.A=e|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=c|0,this.H=a|0}process(e,r){for(let l=0;l<16;l++,r+=4)Nn[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let y=Nn[l-15],g=Nn[l-2],p=lr(y,7)^lr(y,18)^y>>>3,w=lr(g,17)^lr(g,19)^g>>>10;Nn[l]=w+Nn[l-7]+p+Nn[l-16]|0}let{A:n,B:i,C:o,D:s,E:c,F:a,G:d,H:u}=this;for(let l=0;l<64;l++){let y=lr(c,6)^lr(c,11)^lr(c,25),g=u+y+r_(c,a,d)+i_[l]+Nn[l]|0,w=(lr(n,2)^lr(n,13)^lr(n,22))+n_(n,i,o)|0;u=d,d=a,a=c,c=s+g|0,s=o,o=i,i=n,n=g+w|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,d=d+this.G|0,u=u+this.H|0,this.set(n,i,o,s,c,a,d,u)}roundClean(){Nn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Zt=Wa(()=>new Rf);var o_=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{d(n.next(u))}catch(l){s(l)}}function a(u){try{d(n.throw(u))}catch(l){s(l)}}function d(u){u.done?o(u.value):i(u.value).then(c,a)}d((n=n.apply(t,e||[])).next())})},Co=class{static digest({data:e}){return o_(this,void 0,void 0,function*(){return Zt(e)})}};var J5=f(h(),1),kr=class{};var s_=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{d(n.next(u))}catch(l){s(l)}}function a(u){try{d(n.throw(u))}catch(l){s(l)}}function d(u){u.done?o(u.value):i(u.value).then(c,a)}d((n=n.apply(t,e||[])).next())})},za=class extends kr{digest({algorithm:e,data:r}){return s_(this,void 0,void 0,function*(){switch(e){case"SHA-256":return yield Co.digest({data:r})}})}};var cU=f(h(),1);var VO=f(h(),1);var DO=f(h(),1);var rO=f(h(),1);var Ja={};us(Ja,{bitGet:()=>h_,bitLen:()=>f_,bitMask:()=>zs,bitSet:()=>p_,bytesToHex:()=>ln,bytesToNumberBE:()=>fn,bytesToNumberLE:()=>hr,concatBytes:()=>pn,createHmacDrbg:()=>Cf,ensureBytes:()=>De,equalBytes:()=>d_,hexToBytes:()=>ki,hexToNumber:()=>Uf,isBytes:()=>fr,numberToBytesBE:()=>It,numberToBytesLE:()=>hn,numberToHexUnpadded:()=>tw,numberToVarBytesBE:()=>u_,utf8ToBytes:()=>l_,validateObject:()=>Qt});var eO=f(h(),1);var ew=BigInt(0),Ga=BigInt(1),c_=BigInt(2);function fr(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var a_=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ln(t){if(!fr(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r=dn._0&&t<=dn._9)return t-dn._0;if(t>=dn._A&&t<=dn._F)return t-(dn._A-10);if(t>=dn._a&&t<=dn._f)return t-(dn._a-10)}function ki(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);let e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let i=0,o=0;iew;t>>=Ga,e+=1);return e}function h_(t,e){return t>>BigInt(e)&Ga}var p_=(t,e,r)=>t|(r?Ga:ew)<(c_<new Uint8Array(t),Qg=t=>Uint8Array.from(t);function Cf(t,e,r){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=Of(t),i=Of(t),o=0,s=()=>{n.fill(1),i.fill(0),o=0},c=(...l)=>r(i,n,...l),a=(l=Of())=>{i=c(Qg([0]),l),n=c(),l.length!==0&&(i=c(Qg([1]),l),n=c())},d=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,y=[];for(;l{s(),a(l);let g;for(;!(g=y(d()));)a();return s(),g}}var y_={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||fr(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Qt(t,e,r={}){let n=(i,o,s)=>{let c=y_[o];if(typeof c!="function")throw new Error(`Invalid validator "${o}", expected function`);let a=t[i];if(!(s&&a===void 0)&&!c(a,t))throw new Error(`Invalid param ${String(i)}=${a} (${typeof a}), expected ${o}`)};for(let[i,o]of Object.entries(e))n(i,o,!1);for(let[i,o]of Object.entries(r))n(i,o,!0);return t}var Xe=BigInt(0),ke=BigInt(1),Ki=BigInt(2),m_=BigInt(3),Pf=BigInt(4),rw=BigInt(5),nw=BigInt(8),g_=BigInt(9),w_=BigInt(16);function Ee(t,e){let r=t%e;return r>=Xe?r:e+r}function kf(t,e,r){if(r<=Xe||e 0");if(r===ke)return Xe;let n=ke;for(;e>Xe;)e&ke&&(n=n*t%r),t=t*t%r,e>>=ke;return n}function Re(t,e,r){let n=t;for(;e-- >Xe;)n*=n,n%=r;return n}function Ya(t,e){if(t===Xe||e<=Xe)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Ee(t,e),n=e,i=Xe,o=ke,s=ke,c=Xe;for(;r!==Xe;){let d=n/r,u=n%r,l=i-s*d,y=o-c*d;n=r,r=u,i=s,o=c,s=l,c=y}if(n!==ke)throw new Error("invert: does not exist");return Ee(i,e)}function b_(t){let e=(t-ke)/Ki,r,n,i;for(r=t-ke,n=0;r%Ki===Xe;r/=Ki,n++);for(i=Ki;i(Ee(t,e)&ke)===ke,E_=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Kf(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=E_.reduce((n,i)=>(n[i]="function",n),e);return Qt(t,r)}function v_(t,e,r){if(r 0");if(r===Xe)return t.ONE;if(r===ke)return e;let n=t.ONE,i=e;for(;r>Xe;)r&ke&&(n=t.mul(n,i)),i=t.sqr(i),r>>=ke;return n}function S_(t,e){let r=new Array(e.length),n=e.reduce((o,s,c)=>t.is0(s)?o:(r[c]=o,t.mul(o,s)),t.ONE),i=t.inv(n);return e.reduceRight((o,s,c)=>t.is0(s)?o:(r[c]=t.mul(o,r[c]),t.mul(o,s)),i),r}function Lf(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Po(t,e,r=!1,n={}){if(t<=Xe)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:o}=Lf(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=x_(t),c=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:zs(i),ZERO:Xe,ONE:ke,create:a=>Ee(a,t),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return Xe<=a&&aa===Xe,isOdd:a=>(a&ke)===ke,neg:a=>Ee(-a,t),eql:(a,d)=>a===d,sqr:a=>Ee(a*a,t),add:(a,d)=>Ee(a+d,t),sub:(a,d)=>Ee(a-d,t),mul:(a,d)=>Ee(a*d,t),pow:(a,d)=>v_(c,a,d),div:(a,d)=>Ee(a*Ya(d,t),t),sqrN:a=>a*a,addN:(a,d)=>a+d,subN:(a,d)=>a-d,mulN:(a,d)=>a*d,inv:a=>Ya(a,t),sqrt:n.sqrt||(a=>s(c,a)),invertBatch:a=>S_(c,a),cmov:(a,d,u)=>u?d:a,toBytes:a=>r?hn(a,o):It(a,o),fromBytes:a=>{if(a.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${a.length}`);return r?hr(a):fn(a)}});return Object.freeze(c)}function ow(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");let r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r}function sw(t){if(typeof t!="bigint")throw new Error("field order must be bigint");let e=t.toString(2).length;return Math.ceil(e/8)}function Mf(t){let e=sw(t);return e+Math.ceil(e/2)}function cw(t,e,r=!1){let n=t.length,i=sw(e),o=Mf(e);if(n<16||n1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=r?fn(t):hr(t),c=Ee(s,e-ke)+ke;return r?hn(c,i):It(c,i)}var hO=f(h(),1);var sO=f(h(),1);var T_=BigInt(0),Nf=BigInt(1);function Xa(t,e){let r=(i,o)=>{let s=o.negate();return i?s:o},n=i=>{let o=Math.ceil(e/i)+1,s=2**(i-1);return{windows:o,windowSize:s}};return{constTimeNegate:r,unsafeLadder(i,o){let s=t.ZERO,c=i;for(;o>T_;)o&Nf&&(s=s.add(c)),c=c.double(),o>>=Nf;return s},precomputeWindow(i,o){let{windows:s,windowSize:c}=n(o),a=[],d=i,u=d;for(let l=0;l>=g,x>a&&(x-=y,s+=Nf);let S=w,T=w+Math.abs(x)-1,E=p%2!==0,R=x<0;x===0?u=u.add(r(E,o[S])):d=d.add(r(R,o[T]))}return{p:d,f:u}},wNAFCached(i,o,s,c){let a=i._WINDOW_SIZE||1,d=o.get(i);return d||(d=this.precomputeWindow(i,a),a!==1&&o.set(i,c(d))),this.wNAF(a,d,s)}}}function Gs(t){return Kf(t.Fp),Qt(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Lf(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function __(t){let e=Gs(t);Qt(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:I_,hexToBytes:B_}=Ja,Li={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=Li;if(t.length<2||t[0]!==2)throw new e("Invalid signature integer tag");let r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(n[0]&128)throw new e("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:I_(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=Li,r=typeof t=="string"?B_(t):t;if(!fr(r))throw new Error("ui8a expected");let n=r.length;if(n<2||r[0]!=48)throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");let{d:i,l:o}=Li._parseInt(r.subarray(2)),{d:s,l:c}=Li._parseInt(o);if(c.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){let e=d=>Number.parseInt(d[0],16)&8?"00"+d:d,r=d=>{let u=d.toString(16);return u.length&1?`0${u}`:u},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,c=r(o),a=r(s);return`30${r(s+o+4)}02${a}${i}02${c}${n}`}},yn=BigInt(0),er=BigInt(1),dO=BigInt(2),aw=BigInt(3),lO=BigInt(4);function D_(t){let e=__(t),{Fp:r}=e,n=e.toBytes||((p,w,x)=>{let S=w.toAffine();return pn(Uint8Array.from([4]),r.toBytes(S.x),r.toBytes(S.y))}),i=e.fromBytes||(p=>{let w=p.subarray(1),x=r.fromBytes(w.subarray(0,r.BYTES)),S=r.fromBytes(w.subarray(r.BYTES,2*r.BYTES));return{x,y:S}});function o(p){let{a:w,b:x}=e,S=r.sqr(p),T=r.mul(S,p);return r.add(r.add(T,r.mul(p,w)),x)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(p){return typeof p=="bigint"&&ynr.eql(E,r.ZERO);return T(x)&&T(S)?l.ZERO:new l(x,S,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(w){let x=r.invertBatch(w.map(S=>S.pz));return w.map((S,T)=>S.toAffine(x[T])).map(l.fromAffine)}static fromHex(w){let x=l.fromAffine(i(De("pointHex",w)));return x.assertValidity(),x}static fromPrivateKey(w){return l.BASE.multiply(a(w))}_setWindowSize(w){this._WINDOW_SIZE=w,d.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:w,y:x}=this.toAffine();if(!r.isValid(w)||!r.isValid(x))throw new Error("bad point: x or y not FE");let S=r.sqr(x),T=o(w);if(!r.eql(S,T))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:w}=this.toAffine();if(r.isOdd)return!r.isOdd(w);throw new Error("Field doesn't support isOdd")}equals(w){u(w);let{px:x,py:S,pz:T}=this,{px:E,py:R,pz:D}=w,O=r.eql(r.mul(x,D),r.mul(E,T)),k=r.eql(r.mul(S,D),r.mul(R,T));return O&&k}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:w,b:x}=e,S=r.mul(x,aw),{px:T,py:E,pz:R}=this,D=r.ZERO,O=r.ZERO,k=r.ZERO,P=r.mul(T,T),$=r.mul(E,E),N=r.mul(R,R),q=r.mul(T,E);return q=r.add(q,q),k=r.mul(T,R),k=r.add(k,k),D=r.mul(w,k),O=r.mul(S,N),O=r.add(D,O),D=r.sub($,O),O=r.add($,O),O=r.mul(D,O),D=r.mul(q,D),k=r.mul(S,k),N=r.mul(w,N),q=r.sub(P,N),q=r.mul(w,q),q=r.add(q,k),k=r.add(P,P),P=r.add(k,P),P=r.add(P,N),P=r.mul(P,q),O=r.add(O,P),N=r.mul(E,R),N=r.add(N,N),P=r.mul(N,q),D=r.sub(D,P),k=r.mul(N,$),k=r.add(k,k),k=r.add(k,k),new l(D,O,k)}add(w){u(w);let{px:x,py:S,pz:T}=this,{px:E,py:R,pz:D}=w,O=r.ZERO,k=r.ZERO,P=r.ZERO,$=e.a,N=r.mul(e.b,aw),q=r.mul(x,E),V=r.mul(S,R),X=r.mul(T,D),ce=r.add(x,S),U=r.add(E,R);ce=r.mul(ce,U),U=r.add(q,V),ce=r.sub(ce,U),U=r.add(x,T);let L=r.add(E,D);return U=r.mul(U,L),L=r.add(q,X),U=r.sub(U,L),L=r.add(S,T),O=r.add(R,D),L=r.mul(L,O),O=r.add(V,X),L=r.sub(L,O),P=r.mul($,U),O=r.mul(N,X),P=r.add(O,P),O=r.sub(V,P),P=r.add(V,P),k=r.mul(O,P),V=r.add(q,q),V=r.add(V,q),X=r.mul($,X),U=r.mul(N,U),V=r.add(V,X),X=r.sub(q,X),X=r.mul($,X),U=r.add(U,X),q=r.mul(V,U),k=r.add(k,q),q=r.mul(L,U),O=r.mul(ce,O),O=r.sub(O,q),q=r.mul(ce,V),P=r.mul(L,P),P=r.add(P,q),new l(O,k,P)}subtract(w){return this.add(w.negate())}is0(){return this.equals(l.ZERO)}wNAF(w){return g.wNAFCached(this,d,w,x=>{let S=r.invertBatch(x.map(T=>T.pz));return x.map((T,E)=>T.toAffine(S[E])).map(l.fromAffine)})}multiplyUnsafe(w){let x=l.ZERO;if(w===yn)return x;if(c(w),w===er)return this;let{endo:S}=e;if(!S)return g.unsafeLadder(this,w);let{k1neg:T,k1:E,k2neg:R,k2:D}=S.splitScalar(w),O=x,k=x,P=this;for(;E>yn||D>yn;)E&er&&(O=O.add(P)),D&er&&(k=k.add(P)),P=P.double(),E>>=er,D>>=er;return T&&(O=O.negate()),R&&(k=k.negate()),k=new l(r.mul(k.px,S.beta),k.py,k.pz),O.add(k)}multiply(w){c(w);let x=w,S,T,{endo:E}=e;if(E){let{k1neg:R,k1:D,k2neg:O,k2:k}=E.splitScalar(x),{p:P,f:$}=this.wNAF(D),{p:N,f:q}=this.wNAF(k);P=g.constTimeNegate(R,P),N=g.constTimeNegate(O,N),N=new l(r.mul(N.px,E.beta),N.py,N.pz),S=P.add(N),T=$.add(q)}else{let{p:R,f:D}=this.wNAF(x);S=R,T=D}return l.normalizeZ([S,T])[0]}multiplyAndAddUnsafe(w,x,S){let T=l.BASE,E=(D,O)=>O===yn||O===er||!D.equals(T)?D.multiplyUnsafe(O):D.multiply(O),R=E(this,x).add(E(w,S));return R.is0()?void 0:R}toAffine(w){let{px:x,py:S,pz:T}=this,E=this.is0();w==null&&(w=E?r.ONE:r.inv(T));let R=r.mul(x,w),D=r.mul(S,w),O=r.mul(T,w);if(E)return{x:r.ZERO,y:r.ZERO};if(!r.eql(O,r.ONE))throw new Error("invZ was invalid");return{x:R,y:D}}isTorsionFree(){let{h:w,isTorsionFree:x}=e;if(w===er)return!0;if(x)return x(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:w,clearCofactor:x}=e;return w===er?this:x?x(l,this):this.multiplyUnsafe(e.h)}toRawBytes(w=!0){return this.assertValidity(),n(l,this,w)}toHex(w=!0){return ln(this.toRawBytes(w))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let y=e.nBitLength,g=Xa(l,e.endo?Math.ceil(y/2):y);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:a,weierstrassEquation:o,isWithinCurveOrder:s}}function R_(t){let e=Gs(t);return Qt(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function uw(t){let e=R_(t),{Fp:r,n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(U){return ynln(It(U,e.nByteLength));function p(U){let L=n>>er;return U>L}function w(U){return p(U)?c(-U):U}let x=(U,L,H)=>fn(U.slice(L,H));class S{constructor(L,H,C){this.r=L,this.s=H,this.recovery=C,this.assertValidity()}static fromCompact(L){let H=e.nByteLength;return L=De("compactSignature",L,H*2),new S(x(L,0,H),x(L,H,2*H))}static fromDER(L){let{r:H,s:C}=Li.toSig(De("DER",L));return new S(H,C)}assertValidity(){if(!y(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!y(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(L){return new S(this.r,this.s,L)}recoverPublicKey(L){let{r:H,s:C,recovery:A}=this,K=k(De("msgHash",L));if(A==null||![0,1,2,3].includes(A))throw new Error("recovery id invalid");let M=A===2||A===3?H+e.n:H;if(M>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let F=A&1?"03":"02",te=d.fromHex(F+g(M)),re=a(M),ne=c(-K*re),Q=c(C*re),oe=d.BASE.multiplyAndAddUnsafe(te,ne,Q);if(!oe)throw new Error("point at infinify");return oe.assertValidity(),oe}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return ki(this.toDERHex())}toDERHex(){return Li.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return ki(this.toCompactHex())}toCompactHex(){return g(this.r)+g(this.s)}}let T={isValidPrivateKey(U){try{return u(U),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let U=Mf(e.n);return cw(e.randomBytes(U),e.n)},precompute(U=8,L=d.BASE){return L._setWindowSize(U),L.multiply(BigInt(3)),L}};function E(U,L=!0){return d.fromPrivateKey(U).toRawBytes(L)}function R(U){let L=fr(U),H=typeof U=="string",C=(L||H)&&U.length;return L?C===i||C===o:H?C===2*i||C===2*o:U instanceof d}function D(U,L,H=!0){if(R(U))throw new Error("first arg must be private key");if(!R(L))throw new Error("second arg must be public key");return d.fromHex(L).multiply(u(U)).toRawBytes(H)}let O=e.bits2int||function(U){let L=fn(U),H=U.length*8-e.nBitLength;return H>0?L>>BigInt(H):L},k=e.bits2int_modN||function(U){return c(O(U))},P=zs(e.nBitLength);function $(U){if(typeof U!="bigint")throw new Error("bigint expected");if(!(yn<=U&&Uge in H))throw new Error("sign() legacy options not supported");let{hash:C,randomBytes:A}=e,{lowS:K,prehash:M,extraEntropy:F}=H;K==null&&(K=!0),U=De("msgHash",U),M&&(U=De("prehashed msgHash",C(U)));let te=k(U),re=u(L),ne=[$(re),$(te)];if(F!=null){let ge=F===!0?A(r.BYTES):F;ne.push(De("extraEntropy",ge))}let Q=pn(...ne),oe=te;function xe(ge){let Ne=O(ge);if(!y(Ne))return;let He=a(Ne),$e=d.BASE.multiply(Ne).toAffine(),rt=c($e.x);if(rt===yn)return;let Ge=c(He*c(oe+rt*re));if(Ge===yn)return;let Vr=($e.x===rt?0:2)|Number($e.y&er),vn=Ge;return K&&p(Ge)&&(vn=w(Ge),Vr^=1),new S(rt,vn,Vr)}return{seed:Q,k2sig:xe}}let q={lowS:e.lowS,prehash:!1},V={lowS:e.lowS,prehash:!1};function X(U,L,H=q){let{seed:C,k2sig:A}=N(U,L,H),K=e;return Cf(K.hash.outputLen,K.nByteLength,K.hmac)(C,A)}d.BASE._setWindowSize(8);function ce(U,L,H,C=V){let A=U;if(L=De("msgHash",L),H=De("publicKey",H),"strict"in C)throw new Error("options.strict was renamed to lowS");let{lowS:K,prehash:M}=C,F,te;try{if(typeof A=="string"||fr(A))try{F=S.fromDER(A)}catch($e){if(!($e instanceof Li.Err))throw $e;F=S.fromCompact(A)}else if(typeof A=="object"&&typeof A.r=="bigint"&&typeof A.s=="bigint"){let{r:$e,s:rt}=A;F=new S($e,rt)}else throw new Error("PARSE");te=d.fromHex(H)}catch($e){if($e.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(K&&F.hasHighS())return!1;M&&(L=e.hash(L));let{r:re,s:ne}=F,Q=k(L),oe=a(ne),xe=c(Q*oe),ge=c(re*oe),Ne=d.BASE.multiplyAndAddUnsafe(te,xe,ge)?.toAffine();return Ne?c(Ne.x)===re:!1}return{CURVE:e,getPublicKey:E,getSharedSecret:D,sign:X,verify:ce,ProjectivePoint:d,Signature:S,utils:T}}var vO=f(h(),1);var gO=f(h(),1);var Za=class extends Oo{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,Jg(e);let n=Ws(r);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?e.create().update(n).digest():n);for(let s=0;snew Za(t,e).update(r).digest();$f.create=(t,e)=>new Za(t,e);function O_(t){return{hash:t,hmac:(e,...r)=>$f(t,e,ja(...r)),randomBytes:Pi}}function Qa(t,e){let r=n=>uw({...t,...O_(n)});return Object.freeze({...r(e),create:r})}var fw=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),dw=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),U_=BigInt(1),qf=BigInt(2),lw=(t,e)=>(t+e/qf)/e;function C_(t){let e=fw,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),d=t*t*t%e,u=d*d*t%e,l=Re(u,r,e)*u%e,y=Re(l,r,e)*u%e,g=Re(y,qf,e)*d%e,p=Re(g,i,e)*g%e,w=Re(p,o,e)*p%e,x=Re(w,c,e)*w%e,S=Re(x,a,e)*x%e,T=Re(S,c,e)*w%e,E=Re(T,r,e)*u%e,R=Re(E,s,e)*p%e,D=Re(R,n,e)*d%e,O=Re(D,qf,e);if(!Ff.eql(Ff.sqr(O),t))throw new Error("Cannot find square root");return O}var Ff=Po(fw,void 0,void 0,{sqrt:C_}),Bt=Qa({a:BigInt(0),b:BigInt(7),Fp:Ff,n:dw,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=dw,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-U_*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),c=lw(o*t,e),a=lw(-n*t,e),d=Ee(t-c*r-a*i,e),u=Ee(-c*n-a*o,e),l=d>s,y=u>s;if(l&&(d=e-d),y&&(u=e-u),d>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:d,k2neg:y,k2:u}}}},Zt),_O=BigInt(0);var IO=Bt.ProjectivePoint;var KO=f(h(),1);var OO=f(h(),1);function hw(t){let e=n=>{if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let i=Object.keys(n).sort(),o={};for(let s of i)o[s]=e(n[s]);return o}return n},r=e(t);return JSON.stringify(r)}var P_=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{d(n.next(u))}catch(l){s(l)}}function a(u){try{d(n.throw(u))}catch(l){s(l)}}function d(u){u.done?o(u.value):i(u.value).then(c,a)}d((n=n.apply(t,e||[])).next())})},Vf="urn:jwk:";function ae({jwk:t}){return P_(this,void 0,void 0,function*(){let e=t.kty,r;if(e==="EC")r={crv:t.crv,kty:t.kty,x:t.x,y:t.y};else if(e==="oct")r={k:t.k,kty:t.kty};else if(e==="OKP")r={crv:t.crv,kty:t.kty,x:t.x};else if(e==="RSA")r={e:t.e,kty:t.kty,n:t.n};else throw new Error(`Unsupported key type: ${e}`);vd(r);let n=hw(r),i=W.string(n).toUint8Array(),o=yield Co.digest({data:i});return W.uint8Array(o).toBase64Url()})}function Kr(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t&&"d"in t)||t.kty!=="EC"||typeof t.d!="string"||typeof t.x!="string")}function ko(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t)||"d"in t||t.kty!=="EC"||typeof t.x!="string")}function Lr(t){return!(!t||typeof t!="object"||!("kty"in t&&"crv"in t&&"x"in t&&"d"in t)||t.kty!=="OKP"||typeof t.d!="string"||typeof t.x!="string")}function Ko(t){return!(!t||typeof t!="object"||"d"in t||!("kty"in t&&"crv"in t&&"x"in t)||t.kty!=="OKP"||typeof t.x!="string")}function pw(t){if(!t||typeof t!="object")return!1;switch(t.kty){case"EC":case"OKP":case"RSA":return"d"in t;case"oct":return"k"in t;default:return!1}}var at=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{d(n.next(u))}catch(l){s(l)}}function a(u){try{d(n.throw(u))}catch(l){s(l)}}function d(u){u.done?o(u.value):i(u.value).then(c,a)}d((n=n.apply(t,e||[])).next())})},k_=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i>Hf&eu)}:{h:Number(t>>Hf&eu)|0,l:Number(t&eu)|0}}function $_(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;iBigInt(t>>>0)<>>0),F_=(t,e,r)=>t>>>r,V_=(t,e,r)=>t<<32-r|e>>>r,H_=(t,e,r)=>t>>>r|e<<32-r,j_=(t,e,r)=>t<<32-r|e>>>r,W_=(t,e,r)=>t<<64-r|e>>>r-32,z_=(t,e,r)=>t>>>r-32|e<<64-r,G_=(t,e)=>e,J_=(t,e)=>t,Y_=(t,e,r)=>t<>>32-r,X_=(t,e,r)=>e<>>32-r,Z_=(t,e,r)=>e<>>64-r,Q_=(t,e,r)=>t<>>64-r;function eI(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var tI=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),rI=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,nI=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),iI=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,oI=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),sI=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;var cI={fromBig:mw,split:$_,toBig:q_,shrSH:F_,shrSL:V_,rotrSH:H_,rotrSL:j_,rotrBH:W_,rotrBL:z_,rotr32H:G_,rotr32L:J_,rotlSH:Y_,rotlSL:X_,rotlBH:Z_,rotlBL:Q_,add:eI,add3L:tI,add3H:rI,add4L:nI,add4H:iI,add5H:sI,add5L:oI},de=cI;var[aI,uI]=de.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),$n=new Uint32Array(80),qn=new Uint32Array(80),jf=class extends Uo{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:r,Bh:n,Bl:i,Ch:o,Cl:s,Dh:c,Dl:a,Eh:d,El:u,Fh:l,Fl:y,Gh:g,Gl:p,Hh:w,Hl:x}=this;return[e,r,n,i,o,s,c,a,d,u,l,y,g,p,w,x]}set(e,r,n,i,o,s,c,a,d,u,l,y,g,p,w,x){this.Ah=e|0,this.Al=r|0,this.Bh=n|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=c|0,this.Dl=a|0,this.Eh=d|0,this.El=u|0,this.Fh=l|0,this.Fl=y|0,this.Gh=g|0,this.Gl=p|0,this.Hh=w|0,this.Hl=x|0}process(e,r){for(let E=0;E<16;E++,r+=4)$n[E]=e.getUint32(r),qn[E]=e.getUint32(r+=4);for(let E=16;E<80;E++){let R=$n[E-15]|0,D=qn[E-15]|0,O=de.rotrSH(R,D,1)^de.rotrSH(R,D,8)^de.shrSH(R,D,7),k=de.rotrSL(R,D,1)^de.rotrSL(R,D,8)^de.shrSL(R,D,7),P=$n[E-2]|0,$=qn[E-2]|0,N=de.rotrSH(P,$,19)^de.rotrBH(P,$,61)^de.shrSH(P,$,6),q=de.rotrSL(P,$,19)^de.rotrBL(P,$,61)^de.shrSL(P,$,6),V=de.add4L(k,q,qn[E-7],qn[E-16]),X=de.add4H(V,O,N,$n[E-7],$n[E-16]);$n[E]=X|0,qn[E]=V|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:c,Cl:a,Dh:d,Dl:u,Eh:l,El:y,Fh:g,Fl:p,Gh:w,Gl:x,Hh:S,Hl:T}=this;for(let E=0;E<80;E++){let R=de.rotrSH(l,y,14)^de.rotrSH(l,y,18)^de.rotrBH(l,y,41),D=de.rotrSL(l,y,14)^de.rotrSL(l,y,18)^de.rotrBL(l,y,41),O=l&g^~l&w,k=y&p^~y&x,P=de.add5L(T,D,k,uI[E],qn[E]),$=de.add5H(P,S,R,O,aI[E],$n[E]),N=P|0,q=de.rotrSH(n,i,28)^de.rotrBH(n,i,34)^de.rotrBH(n,i,39),V=de.rotrSL(n,i,28)^de.rotrBL(n,i,34)^de.rotrBL(n,i,39),X=n&o^n&c^o&c,ce=i&s^i&a^s&a;S=w|0,T=x|0,w=g|0,x=p|0,g=l|0,p=y|0,{h:l,l:y}=de.add(d|0,u|0,$|0,N|0),d=c|0,u=a|0,c=o|0,a=s|0,o=n|0,s=i|0;let U=de.add3L(N,V,ce);n=de.add3H(U,$,q,X),i=U|0}({h:n,l:i}=de.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=de.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:c,l:a}=de.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:d,l:u}=de.add(this.Dh|0,this.Dl|0,d|0,u|0),{h:l,l:y}=de.add(this.Eh|0,this.El|0,l|0,y|0),{h:g,l:p}=de.add(this.Fh|0,this.Fl|0,g|0,p|0),{h:w,l:x}=de.add(this.Gh|0,this.Gl|0,w|0,x|0),{h:S,l:T}=de.add(this.Hh|0,this.Hl|0,S|0,T|0),this.set(n,i,o,s,c,a,d,u,l,y,g,p,w,x,S,T)}roundClean(){$n.fill(0),qn.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var Wf=Wa(()=>new jf);var bU=f(h(),1);var pr=BigInt(0),Nt=BigInt(1),tu=BigInt(2),dI=BigInt(8),lI={zip215:!0};function fI(t){let e=Gs(t);return Qt(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function ru(t){let e=fI(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:c,h:a}=e,d=tu<{try{return{isValid:!0,value:r.sqrt(C*r.inv(A))}}catch{return{isValid:!1,value:pr}}}),y=e.adjustScalarBytes||(C=>C),g=e.domain||((C,A,K)=>{if(A.length||K)throw new Error("Contexts/pre-hash are not supported");return C}),p=C=>typeof C=="bigint"&&prp(C)&&p(A)&&CC===pr||w(C,d);function S(C,A){if(w(C,A))return C;throw new Error(`Expected valid scalar < ${A}, got ${typeof C} ${C}`)}function T(C){return C===pr?C:S(C,n)}let E=new Map;function R(C){if(!(C instanceof D))throw new Error("ExtendedPoint expected")}class D{constructor(A,K,M,F){if(this.ex=A,this.ey=K,this.ez=M,this.et=F,!x(A))throw new Error("x required");if(!x(K))throw new Error("y required");if(!x(M))throw new Error("z required");if(!x(F))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(A){if(A instanceof D)throw new Error("extended point not allowed");let{x:K,y:M}=A||{};if(!x(K)||!x(M))throw new Error("invalid affine point");return new D(K,M,Nt,u(K*M))}static normalizeZ(A){let K=r.invertBatch(A.map(M=>M.ez));return A.map((M,F)=>M.toAffine(K[F])).map(D.fromAffine)}_setWindowSize(A){this._WINDOW_SIZE=A,E.delete(this)}assertValidity(){let{a:A,d:K}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:M,ey:F,ez:te,et:re}=this,ne=u(M*M),Q=u(F*F),oe=u(te*te),xe=u(oe*oe),ge=u(ne*A),Ne=u(oe*u(ge+Q)),He=u(xe+u(K*u(ne*Q)));if(Ne!==He)throw new Error("bad point: equation left != right (1)");let $e=u(M*F),rt=u(te*re);if($e!==rt)throw new Error("bad point: equation left != right (2)")}equals(A){R(A);let{ex:K,ey:M,ez:F}=this,{ex:te,ey:re,ez:ne}=A,Q=u(K*ne),oe=u(te*F),xe=u(M*ne),ge=u(re*F);return Q===oe&&xe===ge}is0(){return this.equals(D.ZERO)}negate(){return new D(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:A}=e,{ex:K,ey:M,ez:F}=this,te=u(K*K),re=u(M*M),ne=u(tu*u(F*F)),Q=u(A*te),oe=K+M,xe=u(u(oe*oe)-te-re),ge=Q+re,Ne=ge-ne,He=Q-re,$e=u(xe*Ne),rt=u(ge*He),Ge=u(xe*He),Vr=u(Ne*ge);return new D($e,rt,Vr,Ge)}add(A){R(A);let{a:K,d:M}=e,{ex:F,ey:te,ez:re,et:ne}=this,{ex:Q,ey:oe,ez:xe,et:ge}=A;if(K===BigInt(-1)){let ts=u((te-F)*(oe+Q)),Tc=u((te+F)*(oe-Q)),rs=u(Tc-ts);if(rs===pr)return this.double();let _c=u(re*tu*ge),Ic=u(ne*tu*xe),Ht=Ic+_c,An=Tc+ts,ns=Ic-_c,Bc=u(Ht*rs),Xn=u(An*ns),Dc=u(Ht*ns),Ju=u(rs*An);return new D(Bc,Xn,Ju,Dc)}let Ne=u(F*Q),He=u(te*oe),$e=u(ne*M*ge),rt=u(re*xe),Ge=u((F+te)*(Q+oe)-Ne-He),Vr=rt-$e,vn=rt+$e,es=u(He-K*Ne),Ac=u(Ge*Vr),Gu=u(vn*es),Sn=u(Ge*es),Vt=u(Vr*vn);return new D(Ac,Gu,Vt,Sn)}subtract(A){return this.add(A.negate())}wNAF(A){return P.wNAFCached(this,E,A,D.normalizeZ)}multiply(A){let{p:K,f:M}=this.wNAF(S(A,n));return D.normalizeZ([K,M])[0]}multiplyUnsafe(A){let K=T(A);return K===pr?k:this.equals(k)||K===Nt?this:this.equals(O)?this.wNAF(K).p:P.unsafeLadder(this,K)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return P.unsafeLadder(this,n).is0()}toAffine(A){let{ex:K,ey:M,ez:F}=this,te=this.is0();A==null&&(A=te?dI:r.inv(F));let re=u(K*A),ne=u(M*A),Q=u(F*A);if(te)return{x:pr,y:Nt};if(Q!==Nt)throw new Error("invZ was invalid");return{x:re,y:ne}}clearCofactor(){let{h:A}=e;return A===Nt?this:this.multiplyUnsafe(A)}static fromHex(A,K=!1){let{d:M,a:F}=e,te=r.BYTES;A=De("pointHex",A,te);let re=A.slice(),ne=A[te-1];re[te-1]=ne&-129;let Q=hr(re);Q===pr||(K?S(Q,d):S(Q,r.ORDER));let oe=u(Q*Q),xe=u(oe-Nt),ge=u(M*oe-F),{isValid:Ne,value:He}=l(xe,ge);if(!Ne)throw new Error("Point.fromHex: invalid y coordinate");let $e=(He&Nt)===Nt,rt=(ne&128)!==0;if(!K&&He===pr&&rt)throw new Error("Point.fromHex: x=0 and x_0=1");return rt!==$e&&(He=u(-He)),D.fromAffine({x:He,y:Q})}static fromPrivateKey(A){return q(A).point}toRawBytes(){let{x:A,y:K}=this.toAffine(),M=hn(K,r.BYTES);return M[M.length-1]|=A&Nt?128:0,M}toHex(){return ln(this.toRawBytes())}}D.BASE=new D(e.Gx,e.Gy,Nt,u(e.Gx*e.Gy)),D.ZERO=new D(pr,Nt,Nt,pr);let{BASE:O,ZERO:k}=D,P=Xa(D,c*8);function $(C){return Ee(C,n)}function N(C){return $(hr(C))}function q(C){let A=c;C=De("private key",C,A);let K=De("hashed private key",o(C),2*A),M=y(K.slice(0,A)),F=K.slice(A,2*A),te=N(M),re=O.multiply(te),ne=re.toRawBytes();return{head:M,prefix:F,scalar:te,point:re,pointBytes:ne}}function V(C){return q(C).pointBytes}function X(C=new Uint8Array,...A){let K=pn(...A);return N(o(g(K,De("context",C),!!i)))}function ce(C,A,K={}){C=De("message",C),i&&(C=i(C));let{prefix:M,scalar:F,pointBytes:te}=q(A),re=X(K.context,M,C),ne=O.multiply(re).toRawBytes(),Q=X(K.context,ne,te,C),oe=$(re+Q*F);T(oe);let xe=pn(ne,hn(oe,r.BYTES));return De("result",xe,c*2)}let U=lI;function L(C,A,K,M=U){let{context:F,zip215:te}=M,re=r.BYTES;C=De("signature",C,2*re),A=De("message",A),i&&(A=i(A));let ne=hr(C.slice(re,2*re)),Q,oe,xe;try{Q=D.fromHex(K,te),oe=D.fromHex(C.slice(0,re),te),xe=O.multiplyUnsafe(ne)}catch{return!1}if(!te&&Q.isSmallOrder())return!1;let ge=X(F,oe.toRawBytes(),Q.toRawBytes(),A);return oe.add(Q.multiplyUnsafe(ge)).subtract(xe).clearCofactor().equals(D.ZERO)}return O._setWindowSize(8),{CURVE:e,getPublicKey:V,sign:ce,verify:L,ExtendedPoint:D,utils:{getExtendedPublicKey:q,randomPrivateKey:()=>s(r.BYTES),precompute(C=8,A=D.BASE){return A._setWindowSize(C),A.multiply(BigInt(3)),A}}}}var SU=f(h(),1);var Xs=BigInt(0),zf=BigInt(1);function hI(t){return Qt(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function gw(t){let e=hI(t),{P:r}=e,n=E=>Ee(E,r),i=e.montgomeryBits,o=Math.ceil(i/8),s=e.nByteLength,c=e.adjustScalarBytes||(E=>E),a=e.powPminus2||(E=>kf(E,r-BigInt(2),r));function d(E,R,D){let O=n(E*(R-D));return R=n(R-O),D=n(D+O),[R,D]}function u(E){if(typeof E=="bigint"&&Xs<=E&&E=Xs;U--){let L=O>>U&zf;V^=L,X=d(V,P,N),P=X[0],N=X[1],X=d(V,$,q),$=X[0],q=X[1],V=L;let H=P+$,C=n(H*H),A=P-$,K=n(A*A),M=C-K,F=N+q,te=N-q,re=n(te*H),ne=n(F*A),Q=re+ne,oe=re-ne;N=n(Q*Q),q=n(k*n(oe*oe)),P=n(C*K),$=n(M*(C+n(l*M)))}X=d(V,P,N),P=X[0],N=X[1],X=d(V,$,q),$=X[0],q=X[1];let ce=a($);return n(P*ce)}function g(E){return hn(n(E),o)}function p(E){let R=De("u coordinate",E,o);return s===32&&(R[31]&=127),hr(R)}function w(E){let R=De("scalar",E),D=R.length;if(D!==o&&D!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${D}`);return hr(c(R))}function x(E,R){let D=p(R),O=w(E),k=y(D,O);if(k===Xs)throw new Error("Invalid private or public key received");return g(k)}let S=g(e.Gu);function T(E){return x(E,S)}return{scalarMult:x,scalarMultBase:T,getSharedSecret:(E,R)=>x(E,R),getPublicKey:E=>T(E),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:S}}var Zs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ww=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),DU=BigInt(0),pI=BigInt(1),Gf=BigInt(2),yI=BigInt(5),bw=BigInt(10),mI=BigInt(20),gI=BigInt(40),xw=BigInt(80);function Ew(t){let e=Zs,n=t*t%e*t%e,i=Re(n,Gf,e)*n%e,o=Re(i,pI,e)*t%e,s=Re(o,yI,e)*o%e,c=Re(s,bw,e)*s%e,a=Re(c,mI,e)*c%e,d=Re(a,gI,e)*a%e,u=Re(d,xw,e)*d%e,l=Re(u,xw,e)*d%e,y=Re(l,bw,e)*s%e;return{pow_p_5_8:Re(y,Gf,e)*t%e,b2:n}}function vw(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function wI(t,e){let r=Zs,n=Ee(e*e*e,r),i=Ee(n*n*e,r),o=Ew(t*i).pow_p_5_8,s=Ee(t*n*o,r),c=Ee(e*s*s,r),a=s,d=Ee(s*ww,r),u=c===t,l=c===Ee(-t,r),y=c===Ee(-t*ww,r);return u&&(s=a),(l||y)&&(s=d),iw(s,r)&&(s=Ee(-s,r)),{isValid:u||l,value:s}}var tr=Po(Zs,void 0,!0),Qs={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:tr,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Wf,randomBytes:Pi,adjustScalarBytes:vw,uvRatio:wI},Fn=ru(Qs);function Sw(t,e,r){if(e.length>255)throw new Error("Context is too big");return ja(Df("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var RU=ru({...Qs,domain:Sw}),OU=ru({...Qs,domain:Sw,prehash:Wf}),Mi=gw({P:Zs,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=Zs,{pow_p_5_8:r,b2:n}=Ew(t);return Ee(Re(r,BigInt(3),e)*n,e)},adjustScalarBytes:vw,randomBytes:Pi});function Aw(t){let{y:e}=Fn.ExtendedPoint.fromHex(t),r=BigInt(1);return tr.toBytes(tr.create((r+e)*tr.inv(r-e)))}function Tw(t){let e=Qs.hash(t.subarray(0,32));return Qs.adjustScalarBytes(e).subarray(0,32)}var bI=(tr.ORDER+BigInt(3))/BigInt(8),UU=tr.pow(Gf,bI),CU=tr.sqrt(tr.neg(tr.ONE)),PU=(tr.ORDER-BigInt(5))/BigInt(8),kU=BigInt(486662);var KU=ow(tr,tr.neg(BigInt(486664)));var LU=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),MU=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),NU=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),$U=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var qU=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var rr=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{d(n.next(u))}catch(l){s(l)}}function a(u){try{d(n.throw(u))}catch(l){s(l)}}function d(u){u.done?o(u.value):i(u.value).then(c,a)}d((n=n.apply(t,e||[])).next())})},xI=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);iEI,checkValidProperty:()=>vI,getJoseSignatureAlgorithmFromPublicKey:()=>SI,isWebCryptoSupported:()=>AI,randomBytes:()=>TI,randomUuid:()=>_I});var uC=f(h(),1);function EI(t){if(!t||t.property===void 0||t.inObject===void 0)throw new TypeError("One or more required parameters missing: 'property, properties'");let{property:e,inObject:r}=t;if(!(e in r))throw new TypeError(`Required parameter missing: '${e}'`)}function vI(t){if(!t||t.property===void 0||t.allowedProperties===void 0)throw new TypeError("One or more required parameters missing: 'property, allowedProperties'");let{property:e,allowedProperties:r}=t;if(Array.isArray(r)&&!r.includes(e)||r instanceof Set&&!r.has(e)||r instanceof Map&&!r.has(e)){let n=Array.from(r instanceof Map?r.keys():r).join(", ");throw new TypeError(`Out of range: '${e}'. Must be one of '${n}'`)}}function SI(t){let e={Ed25519:"EdDSA","P-256":"ES256","P-384":"ES384","P-521":"ES512",secp256k1:"ES256K"};if(t.alg&&Object.values(e).includes(t.alg))return t.alg;if(t.crv&&Object.keys(e).includes(t.crv))return e[t.crv];throw new Error(`Unable to determine algorithm based on provided input: alg=${t.alg}, crv=${t.crv}. Supported 'alg' values: ${Object.values(e).join(", ")}. Supported 'crv' values: ${Object.keys(e).join(", ")}.`)}function AI(){return!!(globalThis.crypto&&globalThis.crypto.subtle)}function TI(t){return Pi(t)}function _I(){return Ro.randomUUID()}var OC=f(h(),1);var _C=f(h(),1);var EC=f(h(),1);var lC=f(h(),1),II=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var hC=f(h(),1);var gn=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));function _w(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var Iw=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),BI=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!BI)throw new Error("Non little-endian hardware is not supported");function ou(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function su(t){if(typeof t=="string")t=ou(t);else if(_w(t))t=t.slice();else throw new Error(`expected Uint8Array, got ${typeof t}`);return t}var DI=t=>Object.prototype.toString.call(t)==="[object Object]"&&t.constructor===Object;function Bw(t,e){if(e!==void 0&&(typeof e!="object"||!DI(e)))throw new Error("options must be object or undefined");return Object.assign(t,e)}function Ni(t,e){if(!_w(t))throw new Error("Uint8Array expected");if(typeof e=="number"&&t.length!==e)throw new Error(`Uint8Array length ${e} expected`)}function Dw(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n(Object.assign(e,t),e);function Xf(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),c=Number(r&o),a=n?4:0,d=n?0:4;t.setUint32(e+a,s,n),t.setUint32(e+d,c,n)}var yC=f(h(),1);function tc(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`wrong positive integer: ${t}`)}function Zf(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function RI(t){return t!=null&&typeof t=="object"&&(t instanceof Uint8Array||t.constructor.name==="Uint8Array")}function Lo(t,...e){if(!RI(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function Qf(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Rw(t,e){Lo(t);let r=e.outputLen;if(t.lengtht[e++]&255|(t[e++]&255)<<8,rh=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=su(e),Ni(e,32);let r=lt(e,0),n=lt(e,2),i=lt(e,4),o=lt(e,6),s=lt(e,8),c=lt(e,10),a=lt(e,12),d=lt(e,14);this.r[0]=r&8191,this.r[1]=(r>>>13|n<<3)&8191,this.r[2]=(n>>>10|i<<6)&7939,this.r[3]=(i>>>7|o<<9)&8191,this.r[4]=(o>>>4|s<<12)&255,this.r[5]=s>>>1&8190,this.r[6]=(s>>>14|c<<2)&8191,this.r[7]=(c>>>11|a<<5)&8065,this.r[8]=(a>>>8|d<<8)&8191,this.r[9]=d>>>5&127;for(let u=0;u<8;u++)this.pad[u]=lt(e,16+2*u)}process(e,r,n=!1){let i=n?0:2048,{h:o,r:s}=this,c=s[0],a=s[1],d=s[2],u=s[3],l=s[4],y=s[5],g=s[6],p=s[7],w=s[8],x=s[9],S=lt(e,r+0),T=lt(e,r+2),E=lt(e,r+4),R=lt(e,r+6),D=lt(e,r+8),O=lt(e,r+10),k=lt(e,r+12),P=lt(e,r+14),$=o[0]+(S&8191),N=o[1]+((S>>>13|T<<3)&8191),q=o[2]+((T>>>10|E<<6)&8191),V=o[3]+((E>>>7|R<<9)&8191),X=o[4]+((R>>>4|D<<12)&8191),ce=o[5]+(D>>>1&8191),U=o[6]+((D>>>14|O<<2)&8191),L=o[7]+((O>>>11|k<<5)&8191),H=o[8]+((k>>>8|P<<8)&8191),C=o[9]+(P>>>5|i),A=0,K=A+$*c+N*(5*x)+q*(5*w)+V*(5*p)+X*(5*g);A=K>>>13,K&=8191,K+=ce*(5*y)+U*(5*l)+L*(5*u)+H*(5*d)+C*(5*a),A+=K>>>13,K&=8191;let M=A+$*a+N*c+q*(5*x)+V*(5*w)+X*(5*p);A=M>>>13,M&=8191,M+=ce*(5*g)+U*(5*y)+L*(5*l)+H*(5*u)+C*(5*d),A+=M>>>13,M&=8191;let F=A+$*d+N*a+q*c+V*(5*x)+X*(5*w);A=F>>>13,F&=8191,F+=ce*(5*p)+U*(5*g)+L*(5*y)+H*(5*l)+C*(5*u),A+=F>>>13,F&=8191;let te=A+$*u+N*d+q*a+V*c+X*(5*x);A=te>>>13,te&=8191,te+=ce*(5*w)+U*(5*p)+L*(5*g)+H*(5*y)+C*(5*l),A+=te>>>13,te&=8191;let re=A+$*l+N*u+q*d+V*a+X*c;A=re>>>13,re&=8191,re+=ce*(5*x)+U*(5*w)+L*(5*p)+H*(5*g)+C*(5*y),A+=re>>>13,re&=8191;let ne=A+$*y+N*l+q*u+V*d+X*a;A=ne>>>13,ne&=8191,ne+=ce*c+U*(5*x)+L*(5*w)+H*(5*p)+C*(5*g),A+=ne>>>13,ne&=8191;let Q=A+$*g+N*y+q*l+V*u+X*d;A=Q>>>13,Q&=8191,Q+=ce*a+U*c+L*(5*x)+H*(5*w)+C*(5*p),A+=Q>>>13,Q&=8191;let oe=A+$*p+N*g+q*y+V*l+X*u;A=oe>>>13,oe&=8191,oe+=ce*d+U*a+L*c+H*(5*x)+C*(5*w),A+=oe>>>13,oe&=8191;let xe=A+$*w+N*p+q*g+V*y+X*l;A=xe>>>13,xe&=8191,xe+=ce*u+U*d+L*a+H*c+C*(5*x),A+=xe>>>13,xe&=8191;let ge=A+$*x+N*w+q*p+V*g+X*y;A=ge>>>13,ge&=8191,ge+=ce*l+U*u+L*d+H*a+C*c,A+=ge>>>13,ge&=8191,A=(A<<2)+A|0,A=A+K|0,K=A&8191,A=A>>>13,M+=A,o[0]=K,o[1]=M,o[2]=F,o[3]=te,o[4]=re,o[5]=ne,o[6]=Q,o[7]=oe,o[8]=xe,o[9]=ge}finalize(){let{h:e,pad:r}=this,n=new Uint16Array(10),i=e[1]>>>13;e[1]&=8191;for(let c=2;c<10;c++)e[c]+=i,i=e[c]>>>13,e[c]&=8191;e[0]+=i*5,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,n[0]=e[0]+5,i=n[0]>>>13,n[0]&=8191;for(let c=1;c<10;c++)n[c]=e[c]+i,i=n[c]>>>13,n[c]&=8191;n[9]-=8192;let o=(i^1)-1;for(let c=0;c<10;c++)n[c]&=o;o=~o;for(let c=0;c<10;c++)e[c]=e[c]&o|n[c];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let s=e[0]+r[0];e[0]=s&65535;for(let c=1;c<8;c++)s=(e[c]+r[c]|0)+(s>>>16)|0,e[c]=s&65535}update(e){Qf(this);let{buffer:r,blockLen:n}=this;e=su(e);let i=e.length;for(let o=0;o>>0,e[o++]=n[s]>>>8;return e}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}};function UI(t){let e=(n,i)=>t(i).update(su(n)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}var Ow=UI(t=>new rh(t));var aP=f(h(),1);var CI=ou("expand 16-byte k"),PI=ou("expand 32-byte k"),kI=gn(CI),KI=gn(PI);function G(t,e){return t<>>32-e}function nh(t){return t.byteOffset%4===0}var cu=64,LI=16,Cw=2**32-1,Uw=new Uint32Array;function MI(t,e,r,n,i,o,s,c){let a=i.length,d=new Uint8Array(cu),u=gn(d),l=nh(i)&&nh(o),y=l?gn(i):Uw,g=l?gn(o):Uw;for(let p=0;p=Cw)throw new Error("arx: counter overflow");let w=Math.min(cu,a-p);if(l&&w===cu){let x=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let S=0,T;S{Lo(c),Lo(a),Lo(d);let y=d.length;if(u||(u=new Uint8Array(y)),Lo(u),tc(l),l<0||l>=Cw)throw new Error("arx: counter overflow");if(u.length0;)g.pop().fill(0);return u}}function Kw(t,e,r,n,i,o=20){let s=t[0],c=t[1],a=t[2],d=t[3],u=e[0],l=e[1],y=e[2],g=e[3],p=e[4],w=e[5],x=e[6],S=e[7],T=i,E=r[0],R=r[1],D=r[2],O=s,k=c,P=a,$=d,N=u,q=l,V=y,X=g,ce=p,U=w,L=x,H=S,C=T,A=E,K=R,M=D;for(let te=0;te{t.update(e);let r=e.length%16;r&&t.update(qI.subarray(r))},FI=new Uint8Array(32);function kw(t,e,r,n,i){let o=t(e,r,FI),s=Ow.create(o);i&&Pw(s,i),Pw(s,n);let c=new Uint8Array(16),a=Iw(c);Xf(a,0,BigInt(i?i.length:0),!0),Xf(a,8,BigInt(n.length),!0),s.update(c);let d=s.digest();return o.fill(0),d}var Mw=t=>(e,r,n)=>(Ni(e,32),Ni(r),{encrypt:(o,s)=>{let c=o.length,a=c+16;s?Ni(s,a):s=new Uint8Array(a),t(e,r,o,s,1);let d=kw(t,e,r,s.subarray(0,-16),n);return s.set(d,c),s},decrypt:(o,s)=>{let c=o.length,a=c-16;if(c<16)throw new Error("encrypted data must be at least 16 bytes");s?Ni(s,a):s=new Uint8Array(a);let d=o.subarray(0,-16),u=o.subarray(-16),l=kw(t,e,r,d,n);if(!Dw(u,l))throw new Error("invalid tag");return t(e,r,d,s,1),s}}),fP=Yf({blockSize:64,nonceLength:12,tagLength:16},Mw($I)),VI=Yf({blockSize:64,nonceLength:24,tagLength:16},Mw(Lw));var _P=f(h(),1);var ch={};us(ch,{extractDidFragment:()=>Dt,getServices:()=>HI,getVerificationMethodByKey:()=>jI,getVerificationMethodTypes:()=>oh,getVerificationMethods:()=>rc,getVerificationRelationshipsById:()=>sh,isDidService:()=>Nw,isDidVerificationMethod:()=>au,isDwnDidService:()=>WI,keyBytesToMultibaseId:()=>uu,multibaseIdToKeyBytes:()=>du});var ok=f(h(),1);function Dt(t){if(typeof t=="string"&&t.length!==0)return t.split("#").pop()}function HI({didDocument:t,id:e,type:r}){return t?.service?.filter(n=>!(e&&n.id!==e||r&&n.type!==r))??[]}async function jI({didDocument:t,publicKeyJwk:e,publicKeyMultibase:r}){let n=rc({didDocument:t});for(let i of n)if(e&&i.publicKeyJwk){if(await ae({jwk:e})===await ae({jwk:i.publicKeyJwk}))return i}else if(r&&i.publicKeyMultibase&&r===i.publicKeyMultibase)return i;return null}function rc({didDocument:t}){if(!t)throw new TypeError("Required parameter missing: 'didDocument'");let e=[];return e.push(...t.verificationMethod?.filter(au)??[]),Object.keys(ni).forEach(r=>{e.push(...t[r]?.filter(au)??[])}),e}function oh({didDocument:t}){let r=rc({didDocument:t}).map(n=>n.type);return[...new Set(r)]}function sh({didDocument:t,methodId:e}){let r=[];return Object.keys(ni).forEach(n=>{if(Array.isArray(t[n])){let i=t[n],o=Dt(e);i.some(c=>{let a=Dt(c)===o,d=au(c)&&Dt(c.id)===o;return a||d})&&r.push(n)}}),r}function Nw(t){return!t||typeof t!="object"||t===null?!1:"id"in t&&"type"in t&&"serviceEndpoint"in t}function WI(t){if(!Nw(t)||t.type!=="DecentralizedWebNode"||!("enc"in t&&"sig"in t))return!1;let e=r=>typeof r=="string"||Array.isArray(r)&&r.every(n=>typeof n=="string");return e(t.enc)&&e(t.sig)}function au(t){return!(!t||typeof t!="object"||t===null||!("id"in t&&"type"in t&&"controller"in t)||typeof t.id!="string"||typeof t.type!="string"||typeof t.controller!="string")}function uu({keyBytes:t,multicodecCode:e,multicodecName:r}){let n=pt.addPrefix({code:e,data:t,name:r}),i=W.uint8Array(n).toBase58Btc();return W.base58Btc(i).toMultibase()}function du({multibaseKeyId:t}){try{let e=W.multibase(t).toBase58Btc(),r=W.base58Btc(e).toUint8Array(),{code:n,data:i,name:o}=pt.removePrefix({prefixedData:r});return{keyBytes:i,multicodecCode:n,multicodecName:o}}catch{throw new J("invalidDid",`Invalid multibase identifier: ${t}`)}}var xt=class t{constructor({uri:e,document:r,metadata:n,keyManager:i}){this.uri=e,this.document=r,this.metadata=n,this.keyManager=i}async export(){if(!(Array.isArray(this.document.verificationMethod)&&this.document.verificationMethod.length>0))throw new Error(`DID document for '${this.uri}' is missing verification methods`);let e={uri:this.uri,document:this.document,metadata:this.metadata};if("exportKey"in this.keyManager&&typeof this.keyManager.exportKey=="function"){let r=[];for(let n of this.document.verificationMethod){if(!n.publicKeyJwk)throw new Error(`Verification method '${n.id}' does not contain a public key in JWK format`);let i=await this.keyManager.getKeyUri({key:n.publicKeyJwk}),o=await this.keyManager.exportKey({keyUri:i});r.push({...o})}e.privateKeys=r}return e}async getSigner(e){let r=this.document.verificationMethod?.find(c=>Dt(c.id)===(Dt(e?.methodId)??Dt(this.document.assertionMethod?.[0])));if(!(r&&r.publicKeyJwk))throw new J("internalError","A verification method intended for signing could not be determined from the DID Document");let n=await this.keyManager.getKeyUri({key:r.publicKeyJwk}),i=await this.keyManager.getPublicKey({keyUri:n}),o=this.keyManager;return{algorithm:iu.getJoseSignatureAlgorithmFromPublicKey(i),keyId:r.id,async sign({data:c}){return await o.sign({data:c,keyUri:n})},async verify({data:c,signature:a}){return await o.verify({data:c,key:i,signature:a})}}}static async import({portableDid:e,keyManager:r=new mt}){let n=rc({didDocument:e.document});if(n.length===0)throw new J("invalidDidDocument","At least one verification method is required but 0 were given");for(let o of e.privateKeys??[])await r.importKey({key:o});for(let o of n){if(!o.publicKeyJwk)throw new Error(`Verification method '${o.id}' does not contain a public key in JWK format`);let s=await r.getKeyUri({key:o.publicKeyJwk});await r.getPublicKey({keyUri:s})}return new t({uri:e.uri,document:e.document,metadata:e.metadata,keyManager:r})}};var h3=f(h(),1);var qk=f(h(),1);var Dk=f(h(),1);var vk=f(h(),1);var fk=f(h(),1);var ah="0123456789abcdef",qw=[],$w=[];for(let t=0;t<256;t++)qw[t]=ah[t>>4&15]+ah[t&15],t<16&&(t<10?$w[48+t]=t:$w[87+t]=t);var uh=t=>{let e=t.length,r="",n=0;for(;n{let r=t.length||0;if(!e){let s=r;for(;s--;)e+=t[s].length}let n=new Uint8Array(e),i=e,o=r;for(;o--;)i-=t[o].length,n.set(t[o],i);return n};var pk=f(h()),Vw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",zI=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(nc=0;nce?new TextDecoder(e).decode(t):GI.decode(t),JI=new TextEncoder,nr=t=>JI.encode(t);var Hw=typeof window<"u"?window:self,jw=Hw.crypto||Hw.msCrypto||{},xk=jw.subtle||jw.webkitSubtle;var Tk=f(h(),1);function No(t){let e=t<0?1:0;return t=Math.abs(Number(t||1)),Math.floor(Math.log10(t))+1+e}function lu(t){return ArrayBuffer.isView(t)?"arraybufferview":Array.isArray(t)?"array":t instanceof Number?"number":t instanceof Boolean?"boolean":t instanceof Set?"set":t instanceof Map?"map":t instanceof String?"string":t instanceof ArrayBuffer?"arraybuffer":typeof t}function ve(t,e,r){let n=[],i=null;return ve._encode(n,t),i=Fw(n),ve.bytes=i.length,ArrayBuffer.isView(e)?(e.set(i,r),e):i}ve.bytes=-1;ve._floatConversionDetected=!1;ve._encode=function(t,e){if(e!=null)switch(lu(e)){case"object":ve.dict(t,e);break;case"map":ve.dictMap(t,e);break;case"array":ve.list(t,e);break;case"set":ve.listSet(t,e);break;case"string":ve.string(t,e);break;case"number":ve.number(t,e);break;case"boolean":ve.number(t,e);break;case"arraybufferview":ve.buffer(t,new Uint8Array(e.buffer,e.byteOffset,e.byteLength));break;case"arraybuffer":ve.buffer(t,new Uint8Array(e));break}};var fu=new Uint8Array([101]),Ww=new Uint8Array([100]),zw=new Uint8Array([108]);ve.buffer=function(t,e){t.push(nr(e.length+":"),e)};ve.string=function(t,e){t.push(nr(nr(e).byteLength+":"+e))};ve.number=function(t,e){if(Number.isInteger(e))return t.push(nr("i"+BigInt(e)+"e"));let r=2147483648,n=e/r<<0,i=e%r<<0,o=n*r+i;t.push(nr("i"+o+"e")),o!==e&&!ve._floatConversionDetected&&(ve._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value "'+e+'":','Bencoding only defines support for integers, value was converted to "'+o+'"'),console.trace())};ve.dict=function(t,e){t.push(Ww);let r=0,n,i=Object.keys(e).sort(),o=i.length;for(;r=48){n=n*10+(s-48);continue}if(!(o===e&&s===43)){if(o===e&&s===45){i=-1;continue}if(s===46)break;throw new Error("not a number: buffer["+o+"] = "+s)}}return n*i}function se(t,e,r,n){return t==null||t.length===0?null:(typeof e!="number"&&n==null&&(n=e,e=void 0),typeof r!="number"&&n==null&&(n=r,r=void 0),se.position=0,se.encoding=n||null,se.data=ArrayBuffer.isView(t)?new Uint8Array(t.slice(e,r)):nr(t),se.bytes=se.data.length,se.next())}se.bytes=0;se.position=0;se.data=null;se.encoding=null;se.next=function(){switch(se.data[se.position]){case ZI:return se.dictionary();case QI:return se.list();case YI:return se.integer();default:return se.buffer()}};se.find=function(t){let e=se.position,r=se.data.length,n=se.data;for(;esB.test(t),encode(t,e,r){r=~~r,e=e||new Uint8Array(r+4);let n=t.length,i=0;for(let o=0;ot.length>0&&cB.test(t),encode(t,e,r){r=~~r;let n=r+16,i=-1,o=0,s=0,c=!0,a=!1;e=e||new Uint8Array(r+16);for(let d=0;d>8),r=97?u-=87:u>=65?u-=55:(u-=48,s=s*10+u),o=(o<<4)+u)}if(c===!1)a===!0?(r>8),r=i+2;d--)e[d]=e[d-2];e[i]=0,e[i+1]=0,i=r}if(i!==r&&i!==-1)for(r>n-2&&(r=n-2);n>i;)e[--n]=ri?e[--r]:0;else for(;r=56320||(t.charCodeAt(o)&64512)!==56320?e+=3:(n=o,e+=4)}}return e}function qo(t,e,r){let n=t.length;r==null&&(r=0),e===void 0&&(e=new Uint8Array(gh(t)+r));let i=r;for(let o=0;o>6,e[i++]=128|s&63;else if((s&63488)!==55296)e[i++]=224|(s&61440)>>12,e[i++]=128|(s&4032)>>6,e[i++]=128|s&63;else{let c=o+1;if(c===n||s>=56320)e[i++]=239,e[i++]=191,e[i++]=189;else{let a=t.charCodeAt(c);(a&64512)!==56320?(e[i++]=239,e[i++]=191,e[i++]=189):(o=c,s=65536|(s&1023)<<10|a&1023,e[i++]=240|(s&1835008)>>18,e[i++]=128|(s&258048)>>12,e[i++]=128|(s&4032)>>6,e[i++]=128|s&63)}}}return qo.bytes=i-r,e}qo.bytes=0;function Fo(t,e,r){let n="";e==null&&(e=0),r==null&&(r=t.length);for(let i=e;i191&&o<224)s=(o&31)<<6|t[i++]&63;else if(o>239&&o<365){s=((o&7)<<18|(t[i++]&63)<<12|(t[i++]&63)<<6|t[i++]&63)-65536;let c=55296|s>>10&1023;n+=String.fromCharCode(c),s=56320|s&1023}else s=(o&15)<<12|(t[i++]&63)<<6|t[i++]&63;n+=String.fromCharCode(s)}return Fo.bytes=r-e,n}Fo.bytes=0;var Hn=t=>t instanceof Uint8Array;function bn(t){return typeof t=="string"?gh(t):t.byteLength}function pu(t){return t instanceof Uint8Array?t:Array.isArray(t)?new Uint8Array(t):qo(t)}function yu(t,e,r){if(typeof e!="string")throw new Error("unknown input type");return qo(e,t,r),qo.bytes}var oc={},ib=new Array(255);for(let t=0;t<=15;t+=1){let e=t.toString(16),r=e.toUpperCase();for(let n=0;n<=15;n+=1){let i=n.toString(16),o=i.toUpperCase(),s=t<<4|n,c=`${e}${i}`;ib[s]=c,oc[c]=s,oc[`${r}${i}`]=s,oc[`${e}${o}`]=s,oc[`${r}${o}`]=s}}function ob(t,e,r){let n="";for(let i=e;i>>1}function sb(t,e,r,n){let i=0;for(;rt[e]*yB+t[e+1]*mB+t[e+2]*gB+t[e+3],le=(t,e)=>t[e]<<8|t[e+1],Nr=(t,e,r)=>(e=+e,t[r+3]=e,e=e>>>8,t[r+2]=e,e=e>>>8,t[r+1]=e,e=e>>>8,t[r]=e,r+4),ee=(t,e,r)=>(t[r]=e>>8,t[r+1]=e&255,r+2);function Rt(t,e,r,n,i){return r<0&&(n-=r,r=0),n<0&&(n=0),i<0?new Uint8Array(0):r>=e.length||n>=i?0:wB(t,e,r,n,i)}function wB(t,e,r,n,i){i-n>e.length-r&&(i=n+e.length-r);let o=i-n,s=t.length-n;return o>s&&(o=s),(n!==0||it)}}var Y=Be({encode(t,e,r){e||(e=new Uint8Array(Y.encodingLength(t))),r||(r=0);let n=r,i=t.replace(/^\.|\.$/gm,"");if(i.length){let o=i.split(".");for(let s=0;s=t.length)throw new Error("Cannot decode name (buffer overflow)");let c=t[e++];if(o+=s?0:1,c===0)break;if(c&192)if((c&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let a=le(t,e-1)-49152;if(a>=n)throw new Error("Cannot decode name (bad pointer)");e=a,n=a,o+=s?0:1,s=!0}else throw new Error("Cannot decode name (bad label)");else{if(e+c>t.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=c+1,i>254)throw new Error("Cannot decode name (name too long)");r.push(Fo(t,e,e+c)),e+=c,o+=s?0:c}}return Y.decode.bytes=o,r.length===0?".":r.join(".")},encodingLength(t){return t==="."||t===".."?1:bn(t.replace(/^\.|\.$/gm,""))+2}}),Qe=Be({encode(t,e,r){e||(e=new Uint8Array(Qe.encodingLength(t))),r||(r=0);let n=yu(e,t,r+1);return e[r]=n,Qe.encode.bytes=n+1,e},decode(t,e){e||(e=0);let r=t[e],n=Fo(t,e+1,e+1+r);return Qe.decode.bytes=r+1,n},encodingLength(t){return bn(t)+1}}),Vo=Be({bytes:12,encode(t,e,r){e||(e=new Uint8Array(Vo.encodingLength(t))),r||(r=0);let n=(t.flags||0)&32767,i=t.type==="response"?cb:xB;return ee(e,t.id||0,r),ee(e,n|i,r+2),ee(e,t.questions.length,r+4),ee(e,t.answers.length,r+6),ee(e,t.authorities.length,r+8),ee(e,t.additionals.length,r+10),e},decode(t,e){if(e||(e=0),t.length<12)throw new Error("Header must be 12 bytes");let r=le(t,e+2);return{id:le(t,e),type:r&cb?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:rb(r>>11&15),flag_aa:(r>>10&1)===1,flag_tc:(r>>9&1)===1,flag_rd:(r>>8&1)===1,flag_ra:(r>>7&1)===1,flag_z:(r>>6&1)===1,flag_ad:(r>>5&1)===1,flag_cd:(r>>4&1)===1,rcode:tb(r&15),questions:new Array(le(t,e+4)),answers:new Array(le(t,e+6)),authorities:new Array(le(t,e+8)),additionals:new Array(le(t,e+10))}},encodingLength(){return 12}}),gu=Be({encode(t,e,r){e||(e=new Uint8Array(gu.encodingLength(t))),r||(r=0);let n=t.length;return ee(e,n,r),Rt(t,e,r+2,0,n),gu.encode.bytes=n+2,e},decode(t,e){e||(e=0);let r=le(t,e),n=t.slice(e+2,e+2+r);return gu.decode.bytes=r+2,n},encodingLength(t){return t.length+2}}),wu=Be({encode(t,e,r){return e||(e=new Uint8Array(wu.encodingLength(t))),r||(r=0),Y.encode(t,e,r+2),ee(e,Y.encode.bytes,r),wu.encode.bytes=Y.encode.bytes+2,e},decode(t,e){e||(e=0);let r=le(t,e),n=Y.decode(t,e+2);return wu.decode.bytes=r+2,n},encodingLength(t){return Y.encodingLength(t)+2}}),bu=Be({encode(t,e,r){e||(e=new Uint8Array(bu.encodingLength(t))),r||(r=0);let n=r;return r+=2,Y.encode(t.mname,e,r),r+=Y.encode.bytes,Y.encode(t.rname,e,r),r+=Y.encode.bytes,Nr(e,t.serial||0,r),r+=4,Nr(e,t.refresh||0,r),r+=4,Nr(e,t.retry||0,r),r+=4,Nr(e,t.expire||0,r),r+=4,Nr(e,t.minimum||0,r),r+=4,ee(e,r-n-2,n),bu.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=Y.decode(t,e),e+=Y.decode.bytes,n.rname=Y.decode(t,e),e+=Y.decode.bytes,n.serial=Mr(t,e),e+=4,n.refresh=Mr(t,e),e+=4,n.retry=Mr(t,e),e+=4,n.expire=Mr(t,e),e+=4,n.minimum=Mr(t,e),e+=4,bu.decode.bytes=e-r,n},encodingLength(t){return 22+Y.encodingLength(t.mname)+Y.encodingLength(t.rname)}}),xu=Be({encode(t,e,r){Array.isArray(t)||(t=[t]);for(let i=0;i0;){let o=t[e++];if(--n,nnew Uint8Array(t),xn=Be({encode(t,e,r){e||(e=new Uint8Array(xn.encodingLength(t))),r||(r=0);let n=r,i=mh(t.code);if(ee(e,i,r),r+=2,t.data)ee(e,t.data.length,r),r+=2,Rt(t.data,e,r),r+=t.data.length;else switch(i){case 8:{let o=t.sourcePrefixLength||0,s=t.family||Zw(t.ip,ab),c=Qw(t.ip,ab),a=Math.ceil(o/8);ee(e,a+4,r),r+=2,ee(e,s,r),r+=2,e[r++]=o,e[r++]=t.scopePrefixLength||0,Rt(c,e,r,0,a),r+=a}break;case 11:t.timeout?(ee(e,2,r),r+=2,ee(e,t.timeout,r),r+=2):(ee(e,0,r),r+=2);break;case 12:{let o=t.length||0;ee(e,o,r),r+=2,e.fill(0,r,r+o),r+=o}break;case 14:{let o=t.tags.length*2;ee(e,o,r),r+=2;for(let s of t.tags)ee(e,s,r),r+=2}break;default:throw new Error(`Unknown roption code: ${t.code}`)}return xn.encode.bytes=r-n,e},decode(t,e){e||(e=0);let r={};r.code=le(t,e),r.type=nb(r.code),e+=2;let n=le(t,e);switch(e+=2,r.data=t.slice(e,e+n),r.code){case 8:r.family=le(t,e),e+=2,r.sourcePrefixLength=t[e++],r.scopePrefixLength=t[e++];{let i=new Uint8Array(r.family===1?4:16);Rt(t,i,0,e,e+n-4),r.ip=eb(i)}break;case 11:n>0&&(r.timeout=le(t,e),e+=2);break;case 14:r.tags=[];for(let i=0;i0;)n[o++]=xn.decode(t,e),e+=xn.decode.bytes,i-=xn.decode.bytes;return Wn.decode.bytes=e-r,n},encodingLength(t){return 2+jo(t||[],xn)}}),$r=Be({encode(t,e,r){e||(e=new Uint8Array($r.encodingLength(t))),r||(r=0);let n=r,i=t.key;if(!Hn(i))throw new Error("Key must be a Buffer");return r+=2,ee(e,t.flags,r),r+=2,e[r]=$r.PROTOCOL_DNSSEC,r+=1,e[r]=t.algorithm,r+=1,Rt(i,e,r,0,i.length),r+=i.length,$r.encode.bytes=r-n,ee(e,$r.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={},i=le(t,e);if(e+=2,n.flags=le(t,e),e+=2,t[e]!==$r.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=t[e],e+=1,n.key=t.slice(e,r+i+2),e+=n.key.length,$r.decode.bytes=e-r,n},encodingLength(t){return 6+bn(t.key)}});$r.PROTOCOL_DNSSEC=3;$r.ZONE_KEY=128;$r.SECURE_ENTRYPOINT=32768;var sc=Be({encode(t,e,r){e||(e=new Uint8Array(sc.encodingLength(t))),r||(r=0);let n=r,i=t.signature;if(!Hn(i))throw new Error("Signature must be a Buffer");return r+=2,ee(e,$o(t.typeCovered),r),r+=2,e[r]=t.algorithm,r+=1,e[r]=t.labels,r+=1,Nr(e,t.originalTTL,r),r+=4,Nr(e,t.expiration,r),r+=4,Nr(e,t.inception,r),r+=4,ee(e,t.keyTag,r),r+=2,Y.encode(t.signersName,e,r),r+=Y.encode.bytes,Rt(i,e,r,0,i.length),r+=i.length,sc.encode.bytes=r-n,ee(e,sc.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={},i=le(t,e);return e+=2,n.typeCovered=ic(le(t,e)),e+=2,n.algorithm=t[e],e+=1,n.labels=t[e],e+=1,n.originalTTL=Mr(t,e),e+=4,n.expiration=Mr(t,e),e+=4,n.inception=Mr(t,e),e+=4,n.keyTag=le(t,e),e+=2,n.signersName=Y.decode(t,e),e+=Y.decode.bytes,n.signature=t.slice(e,r+i+2),e+=n.signature.length,sc.decode.bytes=e-r,n},encodingLength(t){return 20+Y.encodingLength(t.signersName)+bn(t.signature)}}),cc=Be({encode(t,e,r){e||(e=new Uint8Array(cc.encodingLength(t))),r||(r=0);let n=r;return r+=2,Y.encode(t.mbox||".",e,r),r+=Y.encode.bytes,Y.encode(t.txt||".",e,r),r+=Y.encode.bytes,cc.encode.bytes=r-n,ee(e,cc.encode.bytes-2,n),e},decode(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=Y.decode(t,e)||".",e+=Y.decode.bytes,n.txt=Y.decode(t,e)||".",e+=Y.decode.bytes,cc.decode.bytes=e-r,n},encodingLength(t){return 2+Y.encodingLength(t.mbox||".")+Y.encodingLength(t.txt||".")}}),$t=Be({encode(t,e,r){e||(e=new Uint8Array($t.encodingLength(t))),r||(r=0);let n=r,i=[];for(let o=0;o>8]===void 0&&(i[s>>8]=[]),i[s>>8][s>>3&31]|=1<<7-(s&7)}for(let o=0;o>8]=Math.max(e[i>>8]||0,i&255)}let r=0;for(let n=0;n>15&1)===1,r.options=Wn.decode(t,e+8),e+=8+Wn.decode.bytes;else{let i=le(t,e+2);r.ttl=Mr(t,e+4),r.class=ph(i&EB),r.flush=!!(i&xh);let o=bh(r.type);r.data=o.decode(t,e+8),e+=8+o.decode.bytes}return ir.decode.bytes=e-n,r},encodingLength(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return Y.encodingLength(t.name)+8+bh(t.type).encodingLength(e)}}),zo=Be({encode(t,e,r){e||(e=new Uint8Array(zo.encodingLength(t))),r||(r=0);let n=r;return Y.encode(t.name,e,r),r+=Y.encode.bytes,ee(e,$o(t.type),r),r+=2,ee(e,yh(t.class===void 0?"IN":t.class),r),r+=2,zo.encode.bytes=r-n,t},decode(t,e){e||(e=0);let r=e,n={};return n.name=Y.decode(t,e),e+=Y.decode.bytes,n.type=ic(le(t,e)),e+=2,n.class=ph(le(t,e)),e+=2,!!(n.class&ub)&&(n.class&=vB),zo.decode.bytes=e-r,n},encodingLength(t){return Y.encodingLength(t.name)+4}});var lb=1024;var ft={encode:function(t,e,r){let n=!e;n&&(e=new Uint8Array(SB(t))),r||(r=0);let i=r;return t.questions||(t.questions=[]),t.answers||(t.answers=[]),t.authorities||(t.authorities=[]),t.additionals||(t.additionals=[]),Vo.encode(t,e,r),r+=Vo.encode.bytes,r=lc(t.questions,zo,e,r),r=lc(t.answers,ir,e,r),r=lc(t.authorities,ir,e,r),r=lc(t.additionals,ir,e,r),ft.encode.bytes=r-i,n&&fc.bytes!==e.length?e.slice(0,fc.bytes):e},decode:function(t,e){e||(e=0);let r=e,n=Vo.decode(t,e);return e+=Vo.decode.bytes,e=mu(n.questions,zo,t,e),e=mu(n.answers,ir,t,e),e=mu(n.authorities,ir,t,e),e=mu(n.additionals,ir,t,e),ft.decode.bytes=e-r,n},encodingLength:function(t){return Vo.encodingLength(t)+jo(t.questions||[],zo)+jo(t.answers||[],ir)+jo(t.authorities||[],ir)+jo(t.additionals||[],ir)}};ft.encode.bytes=0;ft.decode.bytes=0;function _u(t,e){if(t.questions)throw new Error("Only one .question object expected instead of a .questions array!");let r=Object.assign({type:e},t);return r.question&&(r.questions=[r.question],delete r.question),r}var Iu={encode:function(t,e,r){return e=ft.encode(_u(t,"query"),e,r),Iu.encode.bytes=ft.encode.bytes,e},decode:function(t,e){let r=ft.decode(t,e);return Iu.decode.bytes=ft.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(t){return ft.encodingLength(_u(t,"query"))}};Iu.encode.bytes=0;Iu.decode.bytes=0;var Bu={encode:function(t,e,r){return e=ft.encode(_u(t,"response"),e,r),Bu.encode.bytes=ft.encode.bytes,e},decode:function(t,e){let r=ft.decode(t,e);return Bu.decode.bytes=ft.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(t){return ft.encodingLength(_u(t,"response"))}};Bu.encode.bytes=0;Bu.decode.bytes=0;var fc=ft.encode,Du=ft.decode,SB=ft.encodingLength;function fb(t){let e=fc(t),r=new Uint8Array(2+e.byteLength);return ee(r,e.byteLength),Rt(e,r,2,0,e.length),fb.bytes=r.byteLength,r}fb.bytes=0;function hb(t){let e=le(t,0);if(t.byteLength(a[a.Discoverable=0]="Discoverable",a[a.Organization=1]="Organization",a[a.Government=2]="Government",a[a.Corporation=3]="Corporation",a[a.LocalBusiness=4]="LocalBusiness",a[a.SoftwarePackage=5]="SoftwarePackage",a[a.WebApp=6]="WebApp",a[a.FinancialInstitution=7]="FinancialInstitution",a))(vh||{}),Ou=(i=>(i[i.Ed25519=0]="Ed25519",i[i.secp256k1=1]="secp256k1",i[i.secp256r1=2]="secp256r1",i[i.X25519=3]="X25519",i))(Ou||{}),Sh=(o=>(o.authentication="auth",o.assertionMethod="asm",o.capabilityDelegation="del",o.capabilityInvocation="inv",o.keyAgreement="agm",o))(Sh||{}),mb={Ed25519:0,ES256K:1,ES256:2,"P-256":2,secp256k1:1,secp256r1:2,X25519:3},yb={0:"Ed25519",1:"ES256K",2:"ES256",3:"ECDH-ES+A256KW"},hc=class hc extends qt{static async create({keyManager:e=new mt,options:r={}}={}){if(r.verificationMethods?.some(u=>!(u.algorithm in mb)))throw new Error("One or more verification method algorithms are not supported");let n=r.verificationMethods?.filter(u=>"id"in u).map(u=>u.id);if(n&&n.length!==new Set(n).size)throw new Error("One or more verification method IDs are not unique");if(r.services?.some(u=>!u.id||!u.type||!u.serviceEndpoint))throw new Error("One or more services are missing required properties");let i=await e.generateKey({algorithm:"Ed25519"}),o=await e.getPublicKey({keyUri:i}),s=await et.identityKeyToIdentifier({identityKey:o}),c={id:s,...r.alsoKnownAs&&{alsoKnownAs:r.alsoKnownAs},...r.controllers&&{controller:r.controllers}},a=[...r.verificationMethods??[]];a?.some(u=>u.id?.split("#").pop()==="0")||a.unshift({algorithm:"Ed25519",id:"0",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]});for(let u of a){let l=u.id&&u.id.split("#").pop()==="0"?i:await e.generateKey({algorithm:u.algorithm}),y=await e.getPublicKey({keyUri:l}),g=u.id??y.kid??await ae({jwk:y});g=`${s}#${Dt(g)}`,c.verificationMethod??=[],c.verificationMethod.push({id:g,type:"JsonWebKey",controller:u.controller??s,publicKeyJwk:y});for(let p of u.purposes??[])c[p]||(c[p]=[]),c[p].push(g)}r.services?.forEach(u=>{c.service??=[],u.id=`${s}#${u.id.split("#").pop()}`,c.service.push(u)});let d=new xt({uri:s,document:c,metadata:{published:!1,...r.types&&{types:r.types}},keyManager:e});if(r.publish??!0){let u=await hc.publish({did:d,gatewayUri:r.gatewayUri});d.metadata=u.didDocumentMetadata}return d}static async import({portableDid:e,keyManager:r=new mt}){if(Pe.parse(e.uri)?.method!==hc.methodName)throw new J("methodNotSupported","Method not supported");let i=await xt.import({portableDid:e,keyManager:r});if(!i.document.verificationMethod?.some(o=>o.id?.split("#").pop()==="0"))throw new J("invalidDidDocument","DID document must contain an Identity Key");return i}static async getSigningMethod({didDocument:e,methodId:r="#0"}){let n=Pe.parse(e.id);if(n&&n.method!==this.methodName)throw new J("methodNotSupported",`Method not supported: ${n.method}`);let i=e.verificationMethod?.find(o=>Dt(o.id)===(Dt(r)??Dt(e.assertionMethod?.[0])));if(!(i&&i.publicKeyJwk))throw new J("internalError","A verification method intended for signing could not be determined from the DID Document");return i}static async publish({did:e,gatewayUri:r=pb}){return await yc.put({did:e,gatewayUri:r})}static async resolve(e,r={}){let n=r?.gatewayUri??pb;try{await et.identifierToIdentityKey({didUri:e});let{didDocument:i,didDocumentMetadata:o}=await yc.get({didUri:e,gatewayUri:n});return{...Ce,didDocument:i,didDocumentMetadata:o}}catch(i){if(!(i instanceof J))throw new Error(i);return{...Ce,didResolutionMetadata:{error:i.code,...i.message&&{errorMessage:i.message}}}}}};hc.methodName="dht";var pc=hc,yc=class t{static async get({didUri:e,gatewayUri:r}){let n=et.identifierToIdentityKeyBytes({didUri:e}),i=await t.pkarrGet({gatewayUri:r,publicKeyBytes:n}),o=await et.parseBep44GetMessage({bep44Message:i}),s=await t.fromDnsPacket({didUri:e,dnsPacket:o});return s.didDocumentMetadata.versionId=i.seq.toString(),s}static async put({did:e,gatewayUri:r}){let n=await t.toDnsPacket({didDocument:e.document,didMetadata:e.metadata,authoritativeGatewayUris:[r]}),i=await et.createBep44PutMessage({dnsPacket:n,publicKeyBytes:et.identifierToIdentityKeyBytes({didUri:e.uri}),signer:await e.getSigner({methodId:"0"})}),o=await t.pkarrPut({gatewayUri:r,bep44Message:i});return{didDocument:e.document,didDocumentMetadata:{...e.metadata,published:o,versionId:i.seq.toString()},didRegistrationMetadata:{}}}static async pkarrGet({gatewayUri:e,publicKeyBytes:r}){let n=W.uint8Array(r).toBase32Z(),i=new URL(n,e).href,o;try{if(o=await fetch(i,{method:"GET"}),!o.ok)throw new J("notFound",`Pkarr record not found for: ${n}`)}catch(a){throw a instanceof J?a:new J("internalError",`Failed to fetch Pkarr record: ${a.message}`)}let s=await o.arrayBuffer();if(!s)throw new J("notFound",`Pkarr record not found for: ${n}`);if(s.byteLength<72)throw new J("invalidDidDocumentLength",`Pkarr response must be at least 72 bytes but got: ${s.byteLength}`);if(s.byteLength>1072)throw new J("invalidDidDocumentLength",`Pkarr response exceeds 1000 byte limit: ${s.byteLength}`);return{k:r,seq:Number(new DataView(s).getBigUint64(64)),sig:new Uint8Array(s,0,64),v:new Uint8Array(s,72)}}static async pkarrPut({gatewayUri:e,bep44Message:r}){let n=W.uint8Array(r.k).toBase32Z(),i=new URL(n,e).href,o=new Uint8Array(r.v.length+72);o.set(r.sig,0),new DataView(o.buffer).setBigUint64(r.sig.length,BigInt(r.seq)),o.set(r.v,r.sig.length+8);let s;try{s=await fetch(i,{method:"PUT",headers:{"Content-Type":"application/octet-stream"},body:o})}catch(c){throw new J("internalError",`Failed to put Pkarr record for identifier ${n}: ${c.message}`)}return s.ok}static async fromDnsPacket({didUri:e,dnsPacket:r}){let n={id:e},i={published:!0},o=new Map;for(let s of r?.answers??[]){if(s.type!=="TXT")continue;let c=s.name.split(".")[0].substring(1);switch(!0){case c.startsWith("aka"):{let a=et.parseTxtDataToString(s.data);n.alsoKnownAs=a.split(Et);break}case c.startsWith("cnt"):{let a=et.parseTxtDataToString(s.data);n.controller=a.includes(Et)?a.split(Et):a;break}case c.startsWith("k"):{let{id:a,t:d,k:u,c:l,a:y}=et.parseTxtDataToObject(s.data),g=W.base64Url(u).toUint8Array(),p=Ou[Number(d)],w=await et.keyConverter(p).bytesToPublicKey({publicKeyBytes:g});w.alg=y||yb[Number(d)];let x=c==="k0"?"0":a!==void 0?a:await ae({jwk:w});n.verificationMethod??=[];let S=`${e}#${x}`;n.verificationMethod.push({id:S,type:"JsonWebKey",controller:l??e,publicKeyJwk:w}),o.set(c,S);break}case c.startsWith("s"):{let{id:a,t:d,se:u,...l}=et.parseTxtDataToObject(s.data),y=u.includes(Et)?u.split(Et):[u],g=Object.fromEntries(Object.entries(l).map(([p,w])=>[p,w.includes(Et)?w.split(Et):w]));n.service??=[],n.service.push({...g,id:`${e}#${a}`,type:d,serviceEndpoint:y});break}case c.startsWith("typ"):{let{id:a}=et.parseTxtDataToObject(s.data);i.types=a.split(Et).map(d=>Number(d));break}case c.startsWith("did"):{let a=p=>p.split(Et).map(w=>o.get(w)).filter(w=>typeof w=="string"),{auth:d,asm:u,del:l,inv:y,agm:g}=et.parseTxtDataToObject(s.data);d&&(n.authentication=a(d)),u&&(n.assertionMethod=a(u)),l&&(n.capabilityDelegation=a(l)),y&&(n.capabilityInvocation=a(y)),g&&(n.keyAgreement=a(g));break}}}return{didDocument:n,didDocumentMetadata:i,didResolutionMetadata:{}}}static async toDnsPacket({didDocument:e,didMetadata:r,authoritativeGatewayUris:n,previousDidProof:i}){let o=[],s=[],c=new Map,a=[],d=[];if(i!==void 0){let{signature:y,previousDid:g}=i;await et.validatePreviousDidProof({newDid:e.id,previousDidProof:i}),o.push({type:"TXT",name:"_prv._did.",ttl:zn,data:`id=${g};s=${y}`})}if(e.alsoKnownAs&&o.push({type:"TXT",name:"_aka._did.",ttl:zn,data:e.alsoKnownAs.join(Et)}),e.controller){let y=Array.isArray(e.controller)?e.controller.join(Et):e.controller;o.push({type:"TXT",name:"_cnt._did.",ttl:zn,data:y})}for(let[y,g]of e.verificationMethod?.entries()??[]){let p=`k${y}`;d.push(p);let w=g.id.split("#").pop();c.set(w,p);let x=g.publicKeyJwk;if(!(x?.crv&&x.crv in mb))throw new J("invalidPublicKeyType",`Verification method '${g.id}' contains an unsupported key type: ${x?.crv??"undefined"}`);let S=Ou[x.crv],T=await et.keyConverter(x.crv).publicKeyToBytes({publicKey:x}),E=W.uint8Array(T).toBase64Url(),R=[`t=${S}`,`k=${E}`];w!=="0"&&await ae({jwk:x})!==w&&R.unshift(`id=${w}`),x.alg!==yb[S]&&R.push(`a=${x.alg}`),g.controller!==e.id&&R.push(`c=${g.controller}`),o.push({type:"TXT",name:`_${p}._did.`,ttl:zn,data:R.join(Ru)})}e.service?.forEach((y,g)=>{let p=`s${g}`;a.push(p);let{id:w,type:x,serviceEndpoint:S,...T}=y;w=Dt(w),S=Array.isArray(S)?S.join(","):S;let R=Object.entries({id:w,t:x,se:S,...T}).map(([O,k])=>`${O}=${k}`).join(Ru),D=et.chunkDataIfNeeded(R);o.push({type:"TXT",name:`_${p}._did.`,ttl:zn,data:D})});let u=[`v=${AB}`];if(d.length&&u.push(`vm=${d.join(Et)}`),Object.keys(ni).forEach(y=>{let g=e[y]?.map(p=>c.get(p.split("#").pop()));if(g){let p=Sh[y];u.push(`${p}=${g.join(Et)}`)}}),a.length&&u.push(`svc=${a.join(Et)}`),r.types?.length){let g=r.types.map(p=>typeof p=="string"?vh[p]:p);o.push({type:"TXT",name:"_typ._did.",ttl:zn,data:`id=${g.join(Et)}`})}o.push({type:"TXT",name:"_did."+t.getUniqueDidSuffix(e.id)+".",ttl:zn,data:u.join(Ru)});for(let y of n||[])s.push({type:"NS",name:"_did."+t.getUniqueDidSuffix(e.id)+".",ttl:zn,data:y+"."});return{id:0,type:"response",flags:lb,answers:[...o,...s]}}static getUniqueDidSuffix(e){return e.split(":")[2]}},et=class t{static async createBep44PutMessage({dnsPacket:e,publicKeyBytes:r,signer:n}){let i=Math.ceil(Date.now()/1e3),o=fc(e),s=hh.encode({seq:i,v:o}).subarray(1,-1);if(s.length>1e3)throw new J("invalidDidDocumentLength",`DNS packet exceeds the 1000 byte maximum size: ${s.length} bytes`);let c=await n.sign({data:s});return{k:r,seq:i,sig:c,v:o}}static async identifierToIdentityKey({didUri:e}){let r=t.identifierToIdentityKeyBytes({didUri:e});return await Ze.bytesToPublicKey({publicKeyBytes:r})}static identifierToIdentityKeyBytes({didUri:e}){let r=Pe.parse(e);if(!r)throw new J("invalidDid",`Invalid DID URI: ${e}`);if(r.method!==pc.methodName)throw new J("methodNotSupported",`Method not supported: ${r.method}`);let n;try{n=W.base32Z(r.id).toUint8Array()}catch{throw new J("invalidPublicKey","Failed to decode method-specific identifier")}if(n.length!==32)throw new J("invalidPublicKeyLength",`Invalid public key length: ${n.length}`);return n}static async identityKeyToIdentifier({identityKey:e}){let r=await Ze.publicKeyToBytes({publicKey:e}),n=W.uint8Array(r).toBase32Z();return`did:${pc.methodName}:${n}`}static keyConverter(e){let n={Ed25519:Ze,"P-256":{publicKeyToBytes:async({publicKey:i})=>{let o=await dt.publicKeyToBytes({publicKey:i});return await dt.compressPublicKey({publicKeyBytes:o})},bytesToPublicKey:dt.bytesToPublicKey,privateKeyToBytes:dt.privateKeyToBytes,bytesToPrivateKey:dt.bytesToPrivateKey},secp256k1:{publicKeyToBytes:async({publicKey:i})=>{let o=await it.publicKeyToBytes({publicKey:i});return await it.compressPublicKey({publicKeyBytes:o})},bytesToPublicKey:it.bytesToPublicKey,privateKeyToBytes:it.privateKeyToBytes,bytesToPrivateKey:it.bytesToPrivateKey},X25519:Mo}[e];if(!n)throw new J("invalidPublicKeyType",`Unsupported curve: ${e}`);return n}static async parseBep44GetMessage({bep44Message:e}){let r=await Ze.bytesToPublicKey({publicKeyBytes:e.k}),n=hh.encode({seq:e.seq,v:e.v}).subarray(1,-1);if(!await Ze.verify({key:r,signature:e.sig,data:n}))throw new J("invalidSignature","Invalid signature for DHT BEP44 message");return Du(e.v)}static parseTxtDataToObject(e){return this.parseTxtDataToString(e).split(Ru).reduce((r,n)=>{let[i,o]=n.split("=");return r[i]=o,r},{})}static parseTxtDataToString(e){if(typeof e=="string")return e;if(e instanceof Uint8Array)return W.uint8Array(e).toString();if(Array.isArray(e))return e.map(r=>this.parseTxtDataToString(r)).join("");throw new J("internalError","Pkarr returned DNS TXT record with invalid data type")}static async validatePreviousDidProof({newDid:e,previousDidProof:r}){let n=await t.identifierToIdentityKey({didUri:r.previousDid}),i=t.identifierToIdentityKeyBytes({didUri:e}),o=W.base64Url(r.signature).toUint8Array();if(!await Ze.verify({key:n,data:i,signature:o}))throw new J("invalidPreviousDidProof","The previous DID proof is invalid.")}static chunkDataIfNeeded(e){if(e.length<=255)return e;let r=[];for(let n=0;n{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var S3=f(h(),1);var Th=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},_h=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return gb(this,e)}},Ih=class{constructor(e){this.decoders=e}or(e){return gb(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},gb=(t,e)=>new Ih({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),Bh=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Th(e,r,n),this.decoder=new _h(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},TB=({name:t,prefix:e,encode:r,decode:n})=>new Bh(t,e,r,n);var _B=(t,e,r,n)=>{let i={};for(let u=0;u=8&&(c-=8,s[d++]=255&a>>c)}if(c>=r||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return s},IB=(t,e,r)=>{let n=e[e.length-1]==="=",i=(1<r;)s-=r,o+=e[i&c>>s];if(s&&(o+=e[i&c<TB({prefix:e,name:t,encode(i){return IB(i,n,r)},decode(i){return _B(i,n,r,t)}});var O3=mc({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),U3=mc({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),gc=mc({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),C3=mc({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ot=class t{static encode(e){return gc.baseEncode(e)}static decodeAsBytes(e,r){if(!t.isBase64UrlString(e))throw new _e(Oe.EncodedStringIncorrectEncoding,`Given ${r} must be base64url string.`);return gc.baseDecode(e)}static decodeAsString(e,r){let n=t.decodeAsBytes(e,r);return t.bytesToString(n)}static isBase64UrlString(e){return/^[A-Za-z0-9_-]+$/.test(e)}static stringToBytes(e){return new TextEncoder().encode(e)}static bytesToString(e){return new TextDecoder().decode(e)}};var NK=f(h(),1),Bb=f(bb(),1);var J3=f(h(),1);var V3=f(h(),1),Dh;(function(t){t.Public="public",t.Private="private"})(Dh||(Dh={}));var Ft=Dh;var tt=class{static validateEs256kOperationKey(e,r){let n=new Set(["kty","crv","x","y"]);r===Ft.Private&&n.add("d");for(let i in e)if(!n.has(i))throw new _e(Oe.PublicKeyJwkEs256kHasUnexpectedProperty,`SECP256K1 JWK key has unexpected property '${i}'.`);if(e.crv!=="secp256k1")throw new _e(Oe.JwkEs256kMissingOrInvalidCrv,`SECP256K1 JWK 'crv' property must be 'secp256k1' but got '${e.crv}.'`);if(e.kty!=="EC")throw new _e(Oe.JwkEs256kMissingOrInvalidKty,`SECP256K1 JWK 'kty' property must be 'EC' but got '${e.kty}.'`);if(e.x.length!==43)throw new _e(Oe.JwkEs256kHasIncorrectLengthOfX,"SECP256K1 JWK 'x' property must be 43 bytes.");if(e.y.length!==43)throw new _e(Oe.JwkEs256kHasIncorrectLengthOfY,"SECP256K1 JWK 'y' property must be 43 bytes.");if(r===Ft.Private&&(e.d===void 0||e.d.length!==43))throw new _e(Oe.JwkEs256kHasIncorrectLengthOfD,"SECP256K1 JWK 'd' property must be 43 bytes.")}static validateId(e){if(e.length>50)throw new _e(Oe.IdTooLong,`Key ID length ${e.length} exceed max allowed length of 50.`);if(!Ot.isBase64UrlString(e))throw new _e(Oe.IdNotUsingBase64UrlCharacterSet,`Key ID '${e}' is not a Base64URL string.`)}static validatePublicKeyPurposes(e){if(e===void 0)return;let r=new Set;for(let n of e){if(r.has(n))throw new _e(Oe.PublicKeyPurposeDuplicated,`Public key purpose '${n}' already specified.`);r.add(n)}}};var X3=f(h(),1),wc=class{};wc.hashAlgorithmInMultihashCode=18;wc.maxCanonicalizedDeltaSizeInBytes=1e3;var vt=wc;var rK=f(h(),1),vb=f(Eb(),1);var mr=class t{static canonicalizeAsBytes(e){let r=t.removeAllUndefinedProperties(e),n=vb.default(r);return Ot.stringToBytes(n)}static removeAllUndefinedProperties(e){for(let r in e)typeof e[r]=="object"?t.removeAllUndefinedProperties(e[r]):e[r]===void 0&&delete e[r];return e}};var AK=f(h(),1);var uK=f(h(),1);var sK=f(h(),1);var iK=f(h(),1),BB=Tb,Sb=128,DB=127,RB=~DB,OB=Math.pow(2,31);function Tb(t,e,r){e=e||[],r=r||0;for(var n=r;t>=OB;)e[r++]=t&255|Sb,t/=128;for(;t&RB;)e[r++]=t&255|Sb,t>>>=7;return e[r]=t|0,Tb.bytes=r-n+1,e}var UB=Rh,CB=128,Ab=127;function Rh(t,n){var r=0,n=n||0,i=0,o=n,s,c=t.length;do{if(o>=c)throw Rh.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&Ab)<=CB);return Rh.bytes=o-n,r}var PB=Math.pow(2,7),kB=Math.pow(2,14),KB=Math.pow(2,21),LB=Math.pow(2,28),MB=Math.pow(2,35),NB=Math.pow(2,42),$B=Math.pow(2,49),qB=Math.pow(2,56),FB=Math.pow(2,63),VB=function(t){return t[bc.decode(t,e),bc.decode.bytes],Uh=(t,e,r=0)=>(bc.encode(t,e,r),e),Ch=t=>bc.encodingLength(t);var Ph=(t,e)=>{let r=e.byteLength,n=Ch(t),i=n+Ch(r),o=new Uint8Array(i+r);return Uh(t,o,0),Uh(r,o,n),o.set(e,i),new Cu(t,r,e,o)},_b=t=>{let e=Ah(t),[r,n]=Oh(e),[i,o]=Oh(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Cu(r,i,s,e)};var Cu=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};var yK=f(h(),1);var lK=f(h(),1);var Kh=({name:t,code:e,encode:r})=>new kh(t,e,r),kh=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?Ph(this.code,r):r.then(n=>Ph(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Ib=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Pu=Kh({name:"sha2-256",code:18,encode:Ib("SHA-256")}),hK=Kh({name:"sha2-512",code:19,encode:Ib("SHA-512")});var xc=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{d(n.next(u))}catch(l){s(l)}}function a(u){try{d(n.throw(u))}catch(l){s(l)}}function d(u){u.done?o(u.value):i(u.value).then(c,a)}d((n=n.apply(t,e||[])).next())})},ot=class t{static hash(e,r){return xc(this,void 0,void 0,function*(){let n;switch(r){case 18:n=(yield Pu.digest(e)).bytes;break;default:throw new _e(Oe.MultihashUnsupportedHashAlgorithm,`Hash algorithm defined in multihash code ${r} is not supported.`)}return n})}static hashAsNonMultihashBytes(e,r){return xc(this,void 0,void 0,function*(){let n;switch(r){case 18:n=yield Pu.encode(e);break;default:throw new _e(Oe.MultihashUnsupportedHashAlgorithm,`Hash algorithm defined in multihash code ${r} is not supported.`)}return n})}static canonicalizeThenHashThenEncode(e,r){return xc(this,void 0,void 0,function*(){let n=mr.canonicalizeAsBytes(e);return yield t.hashThenEncode(n,r)})}static canonicalizeThenDoubleHashThenEncode(e,r){return xc(this,void 0,void 0,function*(){let n=mr.canonicalizeAsBytes(e),i=yield t.hashAsNonMultihashBytes(n,r);return yield t.hashThenEncode(i,r)})}static hashThenEncode(e,r){return xc(this,void 0,void 0,function*(){let n=yield t.hash(e,r);return Ot.encode(n)})}static validateEncodedHashComputedUsingSupportedHashAlgorithm(e,r){let n,i=Ot.decodeAsBytes(e,r);try{n=_b(i)}catch{throw new _e(Oe.MultihashStringNotAMultihash,`Given ${r} string '${e}' is not a multihash after decoding.`)}let o=vt.hashAlgorithmInMultihashCode;if(o!==n.code)throw new _e(Oe.MultihashUnsupportedHashAlgorithm,`Given ${r} uses unsupported multihash algorithm with code ${n.code}, should use ${o} or change IonSdkConfig to desired hashing algorithm.`)}};var _K=f(h(),1),Lh;(function(t){t.Create="create",t.Update="update",t.Deactivate="deactivate",t.Recover="recover"})(Lh||(Lh={}));var Ec=Lh;var BK=f(h(),1),Mh;(function(t){t.Replace="replace",t.AddPublicKeys="add-public-keys",t.RemovePublicKeys="remove-public-keys",t.AddServices="add-services",t.RemoveServices="remove-services"})(Mh||(Mh={}));var $i=Mh;var ku=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{d(n.next(u))}catch(l){s(l)}}function a(u){try{d(n.throw(u))}catch(l){s(l)}}function d(u){u.done?o(u.value):i(u.value).then(c,a)}d((n=n.apply(t,e||[])).next())})},Gn=class t{static createCreateRequest(e){return ku(this,void 0,void 0,function*(){let r=e.recoveryKey,n=e.updateKey,i=e.document.publicKeys,o=e.document.services;tt.validateEs256kOperationKey(r,Ft.Public),tt.validateEs256kOperationKey(n,Ft.Public),t.validateDidDocumentKeys(i),t.validateServices(o);let s=vt.hashAlgorithmInMultihashCode,c=[{action:$i.Replace,document:e.document}],a={updateCommitment:yield ot.canonicalizeThenDoubleHashThenEncode(n,s),patches:c};t.validateDeltaSize(a);let u={deltaHash:yield ot.canonicalizeThenHashThenEncode(a,s),recoveryCommitment:yield ot.canonicalizeThenDoubleHashThenEncode(r,s)};return{type:Ec.Create,suffixData:u,delta:a}})}static createDeactivateRequest(e){return ku(this,void 0,void 0,function*(){t.validateDidSuffix(e.didSuffix),tt.validateEs256kOperationKey(e.recoveryPublicKey,Ft.Public);let r=vt.hashAlgorithmInMultihashCode,n=yield ot.canonicalizeThenHashThenEncode(e.recoveryPublicKey,r),i={didSuffix:e.didSuffix,recoveryKey:e.recoveryPublicKey},o=yield e.signer.sign({alg:"ES256K"},i);return{type:Ec.Deactivate,didSuffix:e.didSuffix,revealValue:n,signedData:o}})}static createRecoverRequest(e){return ku(this,void 0,void 0,function*(){t.validateDidSuffix(e.didSuffix),tt.validateEs256kOperationKey(e.recoveryPublicKey,Ft.Public),tt.validateEs256kOperationKey(e.nextRecoveryPublicKey,Ft.Public),tt.validateEs256kOperationKey(e.nextUpdatePublicKey,Ft.Public),t.validateDidDocumentKeys(e.document.publicKeys),t.validateServices(e.document.services);let r=vt.hashAlgorithmInMultihashCode,n=yield ot.canonicalizeThenHashThenEncode(e.recoveryPublicKey,r),i=[{action:$i.Replace,document:e.document}],o=yield ot.canonicalizeThenDoubleHashThenEncode(e.nextUpdatePublicKey,r),s={patches:i,updateCommitment:o},c=yield ot.canonicalizeThenHashThenEncode(s,r),d={recoveryCommitment:yield ot.canonicalizeThenDoubleHashThenEncode(e.nextRecoveryPublicKey,r),recoveryKey:e.recoveryPublicKey,deltaHash:c},u=yield e.signer.sign({alg:"ES256K"},d);return{type:Ec.Recover,didSuffix:e.didSuffix,revealValue:n,delta:s,signedData:u}})}static createUpdateRequest(e){return ku(this,void 0,void 0,function*(){if(t.validateDidSuffix(e.didSuffix),tt.validateEs256kOperationKey(e.updatePublicKey,Ft.Public),tt.validateEs256kOperationKey(e.nextUpdatePublicKey,Ft.Public),t.validateServices(e.servicesToAdd),t.validateDidDocumentKeys(e.publicKeysToAdd),e.idsOfServicesToRemove!==void 0)for(let p of e.idsOfServicesToRemove)tt.validateId(p);if(e.idsOfPublicKeysToRemove!==void 0)for(let p of e.idsOfPublicKeysToRemove)tt.validateId(p);let r=[],n=e.servicesToAdd;if(n!==void 0&&n.length>0){let p={action:$i.AddServices,services:n};r.push(p)}let i=e.idsOfServicesToRemove;if(i!==void 0&&i.length>0){let p={action:$i.RemoveServices,ids:i};r.push(p)}let o=e.publicKeysToAdd;if(o!==void 0&&o.length>0){let p={action:$i.AddPublicKeys,publicKeys:o};r.push(p)}let s=e.idsOfPublicKeysToRemove;if(s!==void 0&&s.length>0){let p={action:$i.RemovePublicKeys,ids:s};r.push(p)}let c=vt.hashAlgorithmInMultihashCode,a=yield ot.canonicalizeThenHashThenEncode(e.updatePublicKey,c),d=yield ot.canonicalizeThenDoubleHashThenEncode(e.nextUpdatePublicKey,c),u={patches:r,updateCommitment:d},l=yield ot.canonicalizeThenHashThenEncode(u,c),y={updateKey:e.updatePublicKey,deltaHash:l},g=yield e.signer.sign({alg:"ES256K"},y);return{type:Ec.Update,didSuffix:e.didSuffix,revealValue:a,delta:u,signedData:g}})}static validateDidSuffix(e){ot.validateEncodedHashComputedUsingSupportedHashAlgorithm(e,"didSuffix")}static validateDidDocumentKeys(e){if(e===void 0)return;let r=new Set;for(let n of e){if(Array.isArray(n.publicKeyJwk))throw new _e(Oe.DidDocumentPublicKeyMissingOrIncorrectType,"DID Document key 'publicKeyJwk' property is not a non-array object.");if(tt.validateId(n.id),r.has(n.id))throw new _e(Oe.DidDocumentPublicKeyIdDuplicated,`DID Document key with ID '${n.id}' already exists.`);r.add(n.id),tt.validatePublicKeyPurposes(n.purposes)}}static validateServices(e){if(e!==void 0&&e.length!==0){let r=new Set;for(let n of e){if(t.validateService(n),r.has(n.id))throw new _e(Oe.DidDocumentServiceIdDuplicated,"Service id has to be unique");r.add(n.id)}}}static validateService(e){tt.validateId(e.id);let r=30;if(e.type.length>r){let n=`Service endpoint type length ${e.type.length} exceeds max allowed length of ${r}.`;throw new _e(Oe.ServiceTypeTooLong,n)}if(Array.isArray(e.serviceEndpoint)){let n="Service endpoint value cannot be an array.";throw new _e(Oe.ServiceEndpointCannotBeAnArray,n)}if(typeof e.serviceEndpoint=="string"&&Bb.parse(e.serviceEndpoint).error!==void 0)throw new _e(Oe.ServiceEndpointStringNotValidUri,`Service endpoint string '${e.serviceEndpoint}' is not a URI.`)}static validateDeltaSize(e){let r=mr.canonicalizeAsBytes(e);if(r.length>vt.maxCanonicalizedDeltaSizeInBytes){let n=`Delta of ${r.length} bytes exceeded limit of ${vt.maxCanonicalizedDeltaSizeInBytes} bytes.`;throw new _e(Oe.DeltaExceedsMaximumSize,n)}}};var Db=function(t,e,r,n){function i(o){return o instanceof r?o:new r(function(s){s(o)})}return new(r||(r=Promise))(function(o,s){function c(u){try{d(n.next(u))}catch(l){s(l)}}function a(u){try{d(n.throw(u))}catch(l){s(l)}}function d(u){u.done?o(u.value):i(u.value).then(c,a)}d((n=n.apply(t,e||[])).next())})},Go=class t{static createLongFormDid(e){return Db(this,void 0,void 0,function*(){let r=yield Gn.createCreateRequest(e),n=yield t.computeDidUniqueSuffix(r.suffixData),i;vt.network===void 0||vt.network==="mainnet"?i=`did:ion:${n}`:i=`did:ion:${vt.network}:${n}`;let o={suffixData:r.suffixData,delta:r.delta},s=mr.canonicalizeAsBytes(o),c=Ot.encode(s);return`${i}:${c}`})}static computeDidUniqueSuffix(e){return Db(this,void 0,void 0,function*(){let r=mr.canonicalizeAsBytes(e),n=yield ot.hash(r,vt.hashAlgorithmInMultihashCode);return Ot.encode(n)})}};var rL=f(h(),1);var zK=f(h(),1);var ht=2n**255n-19n,Lu=2n**252n+27742317777372353535851937790883648493n,$h=0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,qh=0x6666666666666666666666666666666666666666666666666666666666666658n,Ku={a:-1n,d:37095705934669439343138083508754565189542113879843219016388785533085940283555n,p:ht,n:Lu,h:8,Gx:$h,Gy:qh},Ut=(t="")=>{throw new Error(t)},kb=t=>typeof t=="string",Fh=(t,e)=>!(t instanceof Uint8Array)||typeof e=="number"&&e>0&&t.length!==e?Ut("Uint8Array expected"):t,Jo=t=>new Uint8Array(t),GB=(t,e)=>Fh(kb(t)?Hh(t):Jo(t),e),ie=(t,e=ht)=>{let r=t%e;return r>=0n?r:e+r},Rb=t=>t instanceof Jn?t:Ut("Point expected"),Ob,Jn=class t{constructor(e,r,n,i){this.ex=e,this.ey=r,this.ez=n,this.et=i}static fromAffine(e){return new t(e.x,e.y,1n,ie(e.x*e.y))}static fromHex(e,r=!0){let{d:n}=Ku;e=GB(e,32);let i=e.slice();i[31]=e[31]&-129;let o=YB(i);o===0n||(r&&!(0n0n;o=o.double(),e>>=1n)e&1n?n=n.add(o):r&&(i=i.add(o));return n}multiply(e){return this.mul(e)}clearCofactor(){return this.mul(BigInt(Ku.h),!1)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){let e=this.mul(Lu/2n,!1).double();return Lu%2n&&(e=e.add(this)),e.is0()}toAffine(){let{ex:e,ey:r,ez:n}=this;if(this.is0())return{x:0n,y:0n};let i=Lb(n);return ie(n*i)!==1n&&Ut("invalid inverse"),{x:ie(e*i),y:ie(r*i)}}toRawBytes(){let{x:e,y:r}=this.toAffine(),n=JB(r);return n[31]|=e&1n?128:0,n}toHex(){return Vh(this.toRawBytes())}};Jn.BASE=new Jn($h,qh,1n,ie($h*qh));Jn.ZERO=new Jn(0n,1n,1n,0n);var{BASE:Nu,ZERO:Mu}=Jn,Kb=(t,e)=>t.toString(16).padStart(e,"0"),Vh=t=>Array.from(t).map(e=>Kb(e,2)).join(""),Hh=t=>{let e=t.length;(!kb(t)||e%2)&&Ut("hex invalid 1");let r=Jo(e/2);for(let n=0;nHh(Kb(t,32*2)).reverse(),YB=t=>BigInt("0x"+Vh(Jo(Fh(t)).reverse())),Ub=(...t)=>{let e=Jo(t.reduce((n,i)=>n+Fh(i).length,0)),r=0;return t.forEach(n=>{e.set(n,r),r+=n.length}),e},Lb=(t,e=ht)=>{(t===0n||e<=0n)&&Ut("no inverse n="+t+" mod="+e);let r=ie(t,e),n=e,i=0n,o=1n,s=1n,c=0n;for(;r!==0n;){let a=n/r,d=n%r,u=i-s*a,l=o-c*a;n=r,r=d,i=s,o=c,s=u,c=l}return n===1n?ie(i,e):Ut("no inverse")},qr=(t,e)=>{let r=t;for(;e-- >0n;)r*=r,r%=ht;return r},XB=t=>{let r=t*t%ht*t%ht,n=qr(r,2n)*r%ht,i=qr(n,1n)*t%ht,o=qr(i,5n)*i%ht,s=qr(o,10n)*o%ht,c=qr(s,20n)*s%ht,a=qr(c,40n)*c%ht,d=qr(a,80n)*a%ht,u=qr(d,80n)*a%ht,l=qr(u,10n)*o%ht;return{pow_p_5_8:qr(l,2n)*t%ht,b2:r}},Cb=19681161376707505956807079304988542015446066515923890162744021073123829784752n,ZB=(t,e)=>{let r=ie(e*e*e),n=ie(r*r*e),i=XB(t*n).pow_p_5_8,o=ie(t*r*i),s=ie(e*o*o),c=o,a=ie(o*Cb),d=s===t,u=s===ie(-t),l=s===ie(-t*Cb);return d&&(o=c),(u||l)&&(o=a),(ie(o)&1n)===1n&&(o=ie(-o)),{isValid:d||u,value:o}};var Nh;var Pb=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,Mb={bytesToHex:Vh,hexToBytes:Hh,concatBytes:Ub,mod:ie,invert:Lb,randomBytes:t=>{let e=Pb();return e||Ut("crypto.getRandomValues must be defined"),e.getRandomValues(Jo(t))},sha512Async:async(...t)=>{let e=Pb();e||Ut("crypto.subtle or etc.sha512Async must be defined");let r=Ub(...t);return Jo(await e.subtle.digest("SHA-512",r.buffer))},sha512Sync:void 0};Object.defineProperties(Mb,{sha512Sync:{configurable:!1,get(){return Nh},set(t){Nh||(Nh=t)}}});var qi=8,QB=()=>{let t=[],e=256/qi+1,r=Nu,n=r;for(let i=0;i{let e=Ob||(Ob=QB()),r=(u,l)=>{let y=l.negate();return u?y:l},n=Mu,i=Nu,o=1+256/qi,s=2**(qi-1),c=BigInt(2**qi-1),a=2**qi,d=BigInt(qi);for(let u=0;u>=d,y>s&&(y-=a,t+=1n);let g=l,p=l+Math.abs(y)-1,w=u%2!==0,x=y<0;y===0?i=i.add(r(w,e[g])):n=n.add(r(x,e[p]))}return{p:n,f:i}};var GK=f(h(),1);var Wh=2n**256n,Vi=Wh-0x1000003d1n,zh=Wh-0x14551231950b75fc4402da1732fc9bebfn,Wb=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,zb=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n,Gb={p:Vi,n:zh,a:0n,b:7n,Gx:Wb,Gy:zb},Yo=32,Nb=t=>Z(Z(t*t)*t+Gb.b),st=(t="")=>{throw new Error(t)},Fu=t=>typeof t=="bigint",Jb=t=>typeof t=="string",jh=t=>Fu(t)&&0nFu(t)&&0n!(t instanceof Uint8Array)||typeof e=="number"&&e>0&&t.length!==e?st("Uint8Array expected"):t,Sc=t=>new Uint8Array(t),Gh=(t,e)=>Xb(Jb(t)?Vu(t):Sc(t),e),Z=(t,e=Vi)=>{let r=t%e;return r>=0n?r:e+r},$b=t=>t instanceof En?t:st("Point expected"),qb,En=class t{constructor(e,r,n){this.px=e,this.py=r,this.pz=n}static fromAffine(e){return new t(e.x,e.y,1n)}static fromHex(e){e=Gh(e);let r,n=e[0],i=e.subarray(1),o=Fb(i,0,Yo),s=e.length;if(s===33&&[2,3].includes(n)){jh(o)||st("Point hex invalid: x not FE");let c=r6(Nb(o)),a=(c&1n)===1n;(n&1)===1!==a&&(c=Z(-c)),r=new t(o,c,1n)}return s===65&&n===4&&(r=new t(o,Fb(i,Yo,2*Yo),1n)),r?r.ok():st("Point is not on curve")}static fromPrivateKey(e){return vc.mul(n6(e))}get x(){return this.aff().x}get y(){return this.aff().y}equals(e){let{px:r,py:n,pz:i}=this,{px:o,py:s,pz:c}=$b(e),a=Z(r*c),d=Z(o*i),u=Z(n*c),l=Z(s*i);return a===d&&u===l}negate(){return new t(this.px,Z(-this.py),this.pz)}double(){return this.add(this)}add(e){let{px:r,py:n,pz:i}=this,{px:o,py:s,pz:c}=$b(e),{a,b:d}=Gb,u=0n,l=0n,y=0n,g=Z(d*3n),p=Z(r*o),w=Z(n*s),x=Z(i*c),S=Z(r+n),T=Z(o+s);S=Z(S*T),T=Z(p+w),S=Z(S-T),T=Z(r+i);let E=Z(o+c);return T=Z(T*E),E=Z(p+x),T=Z(T-E),E=Z(n+i),u=Z(s+c),E=Z(E*u),u=Z(w+x),E=Z(E-u),y=Z(a*T),u=Z(g*x),y=Z(u+y),u=Z(w-y),y=Z(w+y),l=Z(u*y),w=Z(p+p),w=Z(w+p),x=Z(a*x),T=Z(g*T),w=Z(w+x),x=Z(p-x),x=Z(a*x),T=Z(T+x),p=Z(w*T),l=Z(l+p),p=Z(E*T),u=Z(S*u),u=Z(u-p),p=Z(S*w),y=Z(E*y),y=Z(y+p),new t(u,l,y)}mul(e,r=!0){if(!r&&e===0n)return $u;if(Yb(e)||st("invalid scalar"),this.equals(vc))return s6(e).p;let n=$u,i=vc;for(let o=this;e>0n;o=o.double(),e>>=1n)e&1n?n=n.add(o):r&&(i=i.add(o));return n}mulAddQUns(e,r,n){return this.mul(r,!1).add(e.mul(n,!1)).ok()}toAffine(){let{px:e,py:r,pz:n}=this;if(this.equals($u))return{x:0n,y:0n};if(n===1n)return{x:e,y:r};let i=Qb(n);return Z(n*i)!==1n&&st("invalid inverse"),{x:Z(e*i),y:Z(r*i)}}assertValidity(){let{x:e,y:r}=this.aff();return(!jh(e)||!jh(r))&&st("Point invalid: x or y"),Z(r*r)===Nb(e)?this:st("Point invalid: not on curve")}multiply(e){return this.mul(e)}aff(){return this.toAffine()}ok(){return this.assertValidity()}toHex(e=!0){let{x:r,y:n}=this.aff();return(e?(n&1n)===0n?"02":"03":"04")+Vb(r)+(e?"":Vb(n))}toRawBytes(e=!0){return Vu(this.toHex(e))}};En.BASE=new En(Wb,zb,1n);En.ZERO=new En(0n,1n,0n);var{BASE:vc,ZERO:$u}=En,Zb=(t,e)=>t.toString(16).padStart(e,"0"),Jh=t=>Array.from(t).map(e=>Zb(e,2)).join(""),Vu=t=>{let e=t.length;(!Jb(t)||e%2)&&st("hex invalid 1");let r=Sc(e/2);for(let n=0;nBigInt("0x"+(Jh(t)||"0")),Fb=(t,e,r)=>Hu(t.slice(e,r)),Yh=t=>Fu(t)&&t>=0n&&tJh(Yh(t)),Hb=(...t)=>{let e=Sc(t.reduce((n,i)=>n+Xb(i).length,0)),r=0;return t.forEach(n=>{e.set(n,r),r+=n.length}),e},Qb=(t,e=Vi)=>{(t===0n||e<=0n)&&st("no inverse n="+t+" mod="+e);let r=Z(t,e),n=e,i=0n,o=1n,s=1n,c=0n;for(;r!==0n;){let a=n/r,d=n%r,u=i-s*a,l=o-c*a;n=r,r=d,i=s,o=c,s=u,c=l}return n===1n?Z(i,e):st("no inverse")},r6=t=>{let e=1n;for(let r=t,n=(Vi+1n)/4n;n>0n;n>>=1n)n&1n&&(e=e*r%Vi),r=r*r%Vi;return Z(e*e)===t?e:st("sqrt invalid")},n6=t=>(Fu(t)||(t=Hu(Gh(t,Yo))),Yb(t)?t:st("private key out of range"));var jb=()=>typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0,qu;function i6(t){t=Gh(t);let e=Yo+8;(t.length1024)&&st("expected proper params");let r=Z(Hu(t),zh-1n)+1n;return Yh(r)}var ex={hexToBytes:Vu,bytesToHex:Jh,concatBytes:Hb,bytesToNumberBE:Hu,numberToBytesBE:Yh,mod:Z,invert:Qb,hmacSha256Async:async(t,...e)=>{let r=jb();if(!r)return st("etc.hmacSha256Async not set");let n=r.subtle,i=await n.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]);return Sc(await n.sign("HMAC",i,Hb(...e)))},hmacSha256Sync:qu,hashToPrivateKey:i6,randomBytes:t=>{let e=jb();return e||st("crypto.getRandomValues must be defined"),e.getRandomValues(Sc(t))}};Object.defineProperties(ex,{hmacSha256Sync:{configurable:!1,get(){return qu},set(t){qu||(qu=t)}}});var Fi=8,o6=()=>{let t=[],e=256/Fi+1,r=vc,n=r;for(let i=0;i{let e=qb||(qb=o6()),r=(u,l)=>{let y=l.negate();return u?y:l},n=$u,i=vc,o=1+256/Fi,s=2**(Fi-1),c=BigInt(2**Fi-1),a=2**Fi,d=BigInt(Fi);for(let u=0;u>=d,y>s&&(y-=a,t+=1n);let g=l,p=l+Math.abs(y)-1,w=u%2!==0,x=y<0;y===0?i=i.add(r(w,e[g])):n=n.add(r(x,e[p]))}return{p:n,f:i}};var iL=f(h(),1),rx;(function(t){t.Mainnet="mainnet",t.Testnet="test"})(rx||(rx={}));var sL=f(h(),1),nx;(function(t){t.Authentication="authentication",t.AssertionMethod="assertionMethod",t.CapabilityInvocation="capabilityInvocation",t.CapabilityDelegation="capabilityDelegation",t.KeyAgreement="keyAgreement"})(nx||(nx={}));var pL=f(h(),1);var ox=(i=>(i.Ed25519="Ed25519",i.secp256k1="secp256k1",i.secp256r1="secp256r1",i.X25519="X25519",i))(ox||{}),c6={Ed25519:"Ed25519",ES256K:"secp256k1",ES256:"secp256r1","P-256":"secp256r1",secp256k1:"secp256k1",secp256r1:"secp256r1"},ix="https://ion.tbd.engineering",Hi=class Hi extends qt{static async create({keyManager:e=new mt,options:r={}}={}){if(r.verificationMethods?.some(p=>!(p.algorithm in c6)))throw new Error("One or more verification method algorithms are not supported");let n=r.verificationMethods?.filter(p=>"id"in p).map(p=>p.id);if(n&&n.length!==new Set(n).size)throw new Error("One or more verification method IDs are not unique");if(r.services?.some(p=>!p.id||!p.type||!p.serviceEndpoint))throw new Error("One or more services are missing required properties");let i={algorithm:"Ed25519",purposes:["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]},o=[];for(let p of r.verificationMethods??[i]){let w=await e.generateKey({algorithm:p.algorithm}),x=await e.getPublicKey({keyUri:w});o.push({id:p.id,publicKeyJwk:x,purposes:p.purposes??["authentication","assertionMethod","capabilityDelegation","capabilityInvocation"]})}let s=await e.generateKey({algorithm:"secp256k1"}),c=await e.getPublicKey({keyUri:s}),a=await e.generateKey({algorithm:"secp256k1"}),d=await e.getPublicKey({keyUri:a}),u=await Yn.computeLongFormDidUri({recoveryKey:c,updateKey:d,services:r.services??[],verificationMethods:o}),{didDocument:l,didResolutionMetadata:y}=await Hi.resolve(u,{gatewayUri:r.gatewayUri});if(l===null)throw new Error(`Unable to resolve DID during creation: ${y?.error}`);let g=new xt({uri:u,document:l,metadata:{published:!1,canonicalId:u.split(":",3).join(":"),recoveryKey:c,updateKey:d},keyManager:e});if(r.publish??!0){let p=await Hi.publish({did:g,gatewayUri:r.gatewayUri});g.metadata=p.didDocumentMetadata}return g}static async getSigningMethod({didDocument:e,methodId:r}){let n=Pe.parse(e.id);if(n&&n.method!==this.methodName)throw new J("methodNotSupported",`Method not supported: ${n.method}`);let i=e.verificationMethod?.find(o=>o.id===(r??e.assertionMethod?.[0]));if(!(i&&i.publicKeyJwk))throw new J("internalError","A verification method intended for signing could not be determined from the DID Document");return i}static async import({portableDid:e,keyManager:r=new mt}){if(Pe.parse(e.uri)?.method!==Hi.methodName)throw new J("methodNotSupported","Method not supported");return await xt.import({portableDid:e,keyManager:r})}static async publish({did:e,gatewayUri:r=ix}){let n=e.document.verificationMethod?.map(s=>({id:s.id,publicKeyJwk:s.publicKeyJwk,purposes:sh({didDocument:e.document,methodId:s.id})}))??[],i=await Yn.createIonDocument({services:e.document.service??[],verificationMethods:n}),o=await Yn.constructCreateRequest({ionDocument:i,recoveryKey:e.metadata.recoveryKey,updateKey:e.metadata.updateKey});try{let s=Yn.appendPathToUrl({baseUrl:r,path:"/operations"}),c=await fetch(s,{method:"POST",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});return{didDocument:e.document,didDocumentMetadata:{...e.metadata,published:c.ok},didRegistrationMetadata:{}}}catch{return{didDocument:null,didDocumentMetadata:{published:!1},didRegistrationMetadata:{error:"internalError",errorMessage:`Failed to publish DID document for: ${e.uri}`}}}}static async resolve(e,r={}){let n=Pe.parse(e);if(!n)return{...Ce,didResolutionMetadata:{error:"invalidDid"}};if(n.method!==Hi.methodName)return{...Ce,didResolutionMetadata:{error:"methodNotSupported"}};let i=r?.gatewayUri??ix;try{let o=Yn.appendPathToUrl({baseUrl:i,path:`/identifiers/${e}`}),s=await fetch(o);if(!s.ok)throw new J("notFound",`Unable to find DID document for: ${e}`);let{didDocument:c,didDocumentMetadata:a}=await s.json();return{...Ce,...c&&{didDocument:c},didDocumentMetadata:{published:a?.method?.published,...a}}}catch(o){if(!(o instanceof J))throw new Error(o);return{...Ce,didResolutionMetadata:{error:o.code,...o.message&&{errorMessage:o.message}}}}}};Hi.methodName="ion";var Xh=Hi,Yn=class t{static appendPathToUrl({baseUrl:e,path:r}){let n=new URL(e);return n.pathname=n.pathname.endsWith("/")?n.pathname:n.pathname+"/",n.pathname+=r.startsWith("/")?r.substring(1):r,n.toString()}static async computeLongFormDidUri({recoveryKey:e,updateKey:r,services:n,verificationMethods:i}){let o=await t.createIonDocument({services:n,verificationMethods:i}),s=t.normalizeJwk(e),c=t.normalizeJwk(r);return await Go.createLongFormDid({document:o,recoveryKey:s,updateKey:c})}static async constructCreateRequest({ionDocument:e,recoveryKey:r,updateKey:n}){return await Gn.createCreateRequest({document:e,recoveryKey:t.normalizeJwk(r),updateKey:t.normalizeJwk(n)})}static async createIonDocument({services:e,verificationMethods:r}){let n=[];for(let s of r){let c=s.id??s.publicKeyJwk.kid??await ae({jwk:s.publicKeyJwk});c=`${c.split("#").pop()}`;let a={id:c,publicKeyJwk:t.normalizeJwk(s.publicKeyJwk),purposes:s.purposes,type:"JsonWebKey2020"};n.push(a)}let i=e.map(s=>({...s,id:`${s.id.split("#").pop()}`}));return{publicKeys:n,services:i}}static normalizeJwk(e){let r=e.kty,n;if(r==="EC")n={crv:e.crv,kty:e.kty,x:e.x,y:e.y};else if(r==="oct")n={k:e.k,kty:e.kty};else if(r==="OKP")n={crv:e.crv,kty:e.kty,x:e.x};else if(r==="RSA")n={e:e.e,kty:e.kty,n:e.n};else throw new Error(`Unsupported key type: ${r}`);return n}};var WL=f(h(),1);var ji=class ji extends qt{static async create({keyManager:e=new mt,options:r={}}={}){if(r.algorithm&&r.verificationMethods)throw new Error("The 'algorithm' and 'verificationMethods' options are mutually exclusive");if(r.verificationMethods&&r.verificationMethods.length!==1)throw new Error("The 'verificationMethods' option must contain exactly one entry");let n=r.algorithm??r.verificationMethods?.[0]?.algorithm??"Ed25519",i=await e.generateKey({algorithm:n}),o=await e.getPublicKey({keyUri:i}),s=W.object(o).toBase64Url(),c=`did:${ji.methodName}:${s}`,d=(await ji.resolve(c)).didDocument;return new xt({uri:c,document:d,metadata:{},keyManager:e})}static async getSigningMethod({didDocument:e}){let r=Pe.parse(e.id);if(r&&r.method!==this.methodName)throw new J("methodNotSupported",`Method not supported: ${r.method}`);let[n]=e.verificationMethod??[];if(!(n&&n.publicKeyJwk))throw new J("internalError","A verification method intended for signing could not be determined from the DID Document");return n}static async import({portableDid:e,keyManager:r=new mt}){if(Pe.parse(e.uri)?.method!==ji.methodName)throw new J("methodNotSupported","Method not supported");let i=await xt.import({portableDid:e,keyManager:r});if(i.document.verificationMethod.length!==1)throw new J("invalidDidDocument","DID document must contain exactly one verification method");return i}static async resolve(e,r){let n=Pe.parse(e),i;try{i=W.base64Url(n.id).toObject()}catch{}if(!n||!i)return{...Ce,didResolutionMetadata:{error:"invalidDid"}};if(n.method!==ji.methodName)return{...Ce,didResolutionMetadata:{error:"methodNotSupported"}};let o={"@context":["https://www.w3.org/ns/did/v1"],id:n.uri},s=`${o.id}#0`;switch(o.verificationMethod=[{id:s,type:"JsonWebKey",controller:o.id,publicKeyJwk:i}],o.authentication=[s],o.assertionMethod=[s],o.capabilityInvocation=[s],o.capabilityDelegation=[s],o.keyAgreement=[s],i.use){case"sig":{delete o.keyAgreement;break}case"enc":{delete o.authentication,delete o.assertionMethod,delete o.capabilityInvocation,delete o.capabilityDelegation;break}}return{...Ce,didDocument:o}}};ji.methodName="jwk";var Zh=ji;var r4=f(h(),1);var sx=(i=>(i.Ed25519="Ed25519",i.secp256k1="secp256k1",i.secp256r1="secp256r1",i.X25519="X25519",i))(sx||{}),ju={Ed25519VerificationKey2020:"https://w3id.org/security/suites/ed25519-2020/v1",JsonWebKey2020:"https://w3id.org/security/suites/jws-2020/v1",X25519KeyAgreementKey2020:"https://w3id.org/security/suites/x25519-2020/v1"},a6={Ed25519:"Ed25519",ES256K:"secp256k1",ES256:"secp256r1","P-256":"secp256r1",secp256k1:"secp256k1",secp256r1:"secp256r1",X25519:"X25519"},gr=class gr extends qt{static async create({keyManager:e=new mt,options:r={}}={}){if(r.algorithm&&r.verificationMethods)throw new Error("The 'algorithm' and 'verificationMethods' options are mutually exclusive");if(r.verificationMethods&&r.verificationMethods.length!==1)throw new Error("The 'verificationMethods' option must contain exactly one entry");let n=r.algorithm??r.verificationMethods?.[0]?.algorithm??"Ed25519",i=await e.generateKey({algorithm:n}),o=await e.getPublicKey({keyUri:i}),s=await or.publicKeyToMultibaseId({publicKey:o}),c=`did:${gr.methodName}:${s}`,d=(await gr.resolve(c,r)).didDocument;return new xt({uri:c,document:d,metadata:{},keyManager:e})}static async getSigningMethod({didDocument:e}){let r=Pe.parse(e.id);if(r&&r.method!==this.methodName)throw new J("methodNotSupported",`Method not supported: ${r.method}`);let[n]=e.assertionMethod||[],i=e.verificationMethod?.find(o=>o.id===n);if(!(i&&i.publicKeyJwk))throw new J("internalError","A verification method intended for signing could not be determined from the DID Document");return i}static async import({portableDid:e,keyManager:r=new mt}){if(Pe.parse(e.uri)?.method!==gr.methodName)throw new J("methodNotSupported","Method not supported");let i=await xt.import({portableDid:e,keyManager:r});if(i.document.verificationMethod.length!==1)throw new J("invalidDidDocument","DID document must contain exactly one verification method");return i}static async resolve(e,r){try{let n=await gr.createDocument({didUri:e,options:r});return{...Ce,didDocument:n}}catch(n){if(!(n instanceof J))throw new Error(n);return{...Ce,didResolutionMetadata:{error:n.code,...n.message&&{errorMessage:n.message}}}}}static async createDocument({didUri:e,options:r={}}){let{defaultContext:n="https://www.w3.org/ns/did/v1",enableEncryptionKeyDerivation:i=!1,enableExperimentalPublicKeyTypes:o=!1,publicKeyFormat:s="JsonWebKey2020"}=r,c={id:""},a=Pe.parse(e);if(!a)throw new J("invalidDid",`Invalid DID URI: ${e}`);let d=a.id;if(a.method!==gr.methodName)throw new J("methodNotSupported",`Method not supported: ${a.method}`);if(!gr.validateIdentifier(a))throw new J("invalidDid",`Invalid DID URI: ${e}`);let u=await gr.createSignatureMethod({didUri:e,multibaseValue:d,options:{enableExperimentalPublicKeyTypes:o,publicKeyFormat:s}});if(c.id=a.uri,c.verificationMethod=[u],c.authentication=[u.id],c.assertionMethod=[u.id],c.capabilityInvocation=[u.id],c.capabilityDelegation=[u.id],i===!0){let g=s==="Ed25519VerificationKey2020"?"X25519KeyAgreementKey2020":"JsonWebKey2020",p=await this.createEncryptionMethod({didUri:e,multibaseValue:d,options:{enableExperimentalPublicKeyTypes:o,publicKeyFormat:g}});c.verificationMethod.push(p),c.keyAgreement=[p.id]}let l=[n];return oh({didDocument:c}).forEach(g=>{let p=ju[g];l.push(p)}),c["@context"]=l,c}static async createEncryptionMethod({didUri:e,multibaseValue:r,options:n}){let{enableExperimentalPublicKeyTypes:i,publicKeyFormat:o}=n,s={id:"",type:"",controller:""},{keyBytes:c,multicodecCode:a}=await gr.deriveEncryptionKey({multibaseValue:r}),d=c.byteLength,u=or.MULTICODEC_PUBLIC_KEY_LENGTH[a];if(d!==u)throw new J("invalidPublicKeyLength",`Expected ${d} bytes. Actual: ${u}`);let l=uu({keyBytes:c,multicodecCode:a});s.id=`${e}#${l}`;try{new URL(s.id)}catch{throw new J("invalidDidUrl","Verification Method ID is not a valid DID URL.")}if(!(o in ju))throw new J("unsupportedPublicKeyType",`Unsupported format: ${o}`);if(i===!1&&!["Multikey","JsonWebKey2020","X25519KeyAgreementKey2020"].includes(o))throw new J("invalidPublicKeyType",`Specified '${o}' without setting enableExperimentalPublicKeyTypes to true.`);if(s.type=o,s.controller=e,o==="X25519KeyAgreementKey2020"&&(s.publicKeyMultibase=l),o==="JsonWebKey2020"){let{crv:g}=await or.multicodecToJwk({code:a});s.publicKeyJwk=await or.keyConverter(g).bytesToPublicKey({publicKeyBytes:c})}return s}static async createSignatureMethod({didUri:e,multibaseValue:r,options:n}){let{enableExperimentalPublicKeyTypes:i,publicKeyFormat:o}=n,s={id:"",type:"",controller:""},{keyBytes:c,multicodecCode:a,multicodecName:d}=du({multibaseKeyId:r}),u=c.byteLength,l=or.MULTICODEC_PUBLIC_KEY_LENGTH[a];if(u!==l)throw new J("invalidPublicKeyLength",`Expected ${u} bytes. Actual: ${l}`);let y=!1;switch(d){case"secp256k1-pub":y=await it.validatePublicKey({publicKeyBytes:c});break;case"ed25519-pub":y=await Ze.validatePublicKey({publicKeyBytes:c});break;case"x25519-pub":y=!0;break}if(!y)throw new J("invalidPublicKey","Invalid public key detected.");s.id=`${e}#${r}`;try{new URL(s.id)}catch{throw new J("invalidDidUrl","Verification Method ID is not a valid DID URL.")}if(!(o in ju))throw new J("unsupportedPublicKeyType",`Unsupported format: ${o}`);if(i===!1&&!["Multikey","JsonWebKey2020","Ed25519VerificationKey2020"].includes(o))throw new J("invalidPublicKeyType",`Specified '${o}' without setting enableExperimentalPublicKeyTypes to true.`);if(s.type=o,s.controller=e,o==="Ed25519VerificationKey2020"&&(s.publicKeyMultibase=r),o==="JsonWebKey2020"){let{crv:p}=await or.multicodecToJwk({code:a});s.publicKeyJwk=await or.keyConverter(p).bytesToPublicKey({publicKeyBytes:c})}return s}static async deriveEncryptionKey({multibaseValue:e}){let r={keyBytes:new Uint8Array,multicodecCode:0},{keyBytes:n,multicodecCode:i}=du({multibaseKeyId:e});if(i===237){let o=await or.keyConverter("Ed25519").bytesToPublicKey({publicKeyBytes:n}),s=await Ze.convertPublicKeyToX25519({publicKey:o});r={keyBytes:await or.keyConverter("Ed25519").publicKeyToBytes({publicKey:s}),multicodecCode:236}}return r}static validateIdentifier(e){let{method:r,id:n}=e,[i]=e.uri.split(":",1);return i==="did"&&r==="key"&&Number("1")>0&&oo(n)==="String"&&n.startsWith("z")}};gr.methodName="key";var Qh=gr,Fr=class Fr{static async jwkToMulticodec({jwk:e}){let r=[];e.crv&&(r.push(e.crv),e.d?r.push("private"):r.push("public"));let n=r.join(":"),i=Fr.JWK_TO_MULTICODEC[n];if(i===void 0)throw new Error(`Unsupported JWK to Multicodec conversion: '${n}'`);return{code:pt.getCodeFromName({name:i}),name:i}}static keyCompressor(e){let n={"P-256":dt.compressPublicKey,secp256k1:it.compressPublicKey}[e];if(!n)throw new J("invalidPublicKeyType",`Unsupported curve: ${e}`);return n}static keyConverter(e){let n={Ed25519:Ze,"P-256":dt,secp256k1:it,X25519:Mo}[e];if(!n)throw new J("invalidPublicKeyType",`Unsupported curve: ${e}`);return n}static async multicodecToJwk({code:e,name:r}){if(!(r?!e:e))throw new Error("Either 'name' or 'code' must be defined, but not both.");r=r===void 0?pt.getNameFromCode({code:e}):r;let n=r,i=Fr.MULTICODEC_TO_JWK[n];if(i===void 0)throw new Error("Unsupported Multicodec to JWK conversion");return{...i}}static async publicKeyToMultibaseId({publicKey:e}){if(!(e?.crv&&e.crv in a6))throw new J("invalidPublicKeyType",`Public key contains an unsupported key type: ${e?.crv??"undefined"}`);let r=await Fr.keyConverter(e.crv).publicKeyToBytes({publicKey:e});/^(secp256k1|P-256|P-384|P-521)$/.test(e.crv)&&(r=await Fr.keyCompressor(e.crv)({publicKeyBytes:r}));let{name:n}=await Fr.jwkToMulticodec({jwk:e});return uu({keyBytes:r,multicodecName:n})}};Fr.JWK_TO_MULTICODEC={"Ed25519:public":"ed25519-pub","Ed25519:private":"ed25519-priv","secp256k1:public":"secp256k1-pub","secp256k1:private":"secp256k1-priv","X25519:public":"x25519-pub","X25519:private":"x25519-priv"},Fr.MULTICODEC_PUBLIC_KEY_LENGTH={231:33,236:32,237:32},Fr.MULTICODEC_TO_JWK={"ed25519-pub":{crv:"Ed25519",kty:"OKP",x:""},"ed25519-priv":{crv:"Ed25519",kty:"OKP",x:"",d:""},"secp256k1-pub":{crv:"secp256k1",kty:"EC",x:"",y:""},"secp256k1-priv":{crv:"secp256k1",kty:"EC",x:"",y:"",d:""},"x25519-pub":{crv:"X25519",kty:"OKP",x:""},"x25519-priv":{crv:"X25519",kty:"OKP",x:"",d:""}};var or=Fr;var c4=f(h(),1);var Wu=class Wu extends qt{static async resolve(e,r){let n=Pe.parse(e);if(!n)return{...Ce,didResolutionMetadata:{error:"invalidDid"}};if(n.method!==Wu.methodName)return{...Ce,didResolutionMetadata:{error:"methodNotSupported"}};let i=`https://${n.id.replace(/:/g,"/")}`;i=decodeURIComponent(i);let o=n.id.includes(":")?`${i}/did.json`:`${i}/.well-known/did.json`;try{let s=await fetch(o);if(!s.ok)throw new Error("HTTP error status code returned");let c=await s.json();return{...Ce,didDocument:c}}catch{return{...Ce,didResolutionMetadata:{error:"notFound"}}}}};Wu.methodName="web";var ep=Wu;var h4=f(h(),1),lx=f(ax(),1),fx=f(dx(),1),tp=class{constructor({db:e,location:r="DATA/DID_RESOLVERCACHE",ttl:n="15m"}={}){this.cache=e??new fx.Level(r),this.ttl=(0,lx.default)(n)}async get(e){try{let r=await this.cache.get(e),n=JSON.parse(r);if(Date.now()>=n.ttlMillis){this.cache.nextTick(()=>this.cache.del(e));return}else return n.value}catch(r){if(r.notFound)return;throw r}}set(e,r){let n={ttlMillis:Date.now()+this.ttl,value:r},i=JSON.stringify(n);return this.cache.put(e,i)}delete(e){return this.cache.del(e)}clear(){return this.cache.clear()}close(){return this.cache.close()}};var y4=f(h(),1),rp={get:function(t){return null},set:function(t,e){return null},delete:function(t){return null},clear:function(){return null},close:function(){return null}};var E4=f(h(),1);var np=class{constructor({cache:e,didResolvers:r}){this.didResolvers=new Map;this.cache=e||rp;for(let n of r)this.didResolvers.set(n.methodName,n)}async resolve(e,r){let n=Pe.parse(e);if(!n)return{...Ce,didResolutionMetadata:{error:"invalidDid",errorMessage:`Invalid DID URI: ${e}`}};let i=this.didResolvers.get(n.method);if(!i)return{...Ce,didResolutionMetadata:{error:"methodNotSupported",errorMessage:`Method not supported: ${n.method}`}};let o=await this.cache.get(n.uri);if(o)return o;{let s=await i.resolve(n.uri,r);return s.didResolutionMetadata.error||await this.cache.set(n.uri,s),s}}async dereference(e,r){let n=Pe.parse(e);if(!n)return{dereferencingMetadata:{error:"invalidDidUrl"},contentStream:null,contentMetadata:{}};let{didDocument:i,didResolutionMetadata:o,didDocumentMetadata:s}=await this.resolve(n.uri);if(!i)return{dereferencingMetadata:{error:o.error},contentStream:null,contentMetadata:{}};if(!n.fragment||n.query)return{dereferencingMetadata:{contentType:"application/did+json"},contentStream:i,contentMetadata:s};let{service:c=[],verificationMethod:a=[]}=i,d=new Set([e,n.fragment,`#${n.fragment}`]),u;for(let l of a)if(d.has(l.id)){u=l;break}for(let l of c)if(d.has(l.id)){u=l;break}return u?{dereferencingMetadata:{contentType:"application/did+json"},contentStream:u,contentMetadata:o}:{dereferencingMetadata:{error:"notFound"},contentStream:null,contentMetadata:{}}}};return Kx(p6);})(); /*! Bundled license information: ieee754/index.js: (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh *) buffer/index.js: (*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT *) queue-microtask/index.js: (*! queue-microtask. MIT License. Feross Aboukhadijeh *) run-parallel-limit/index.js: (*! run-parallel-limit. MIT License. Feross Aboukhadijeh *) safe-buffer/index.js: (*! safe-buffer. MIT License. Feross Aboukhadijeh *) uri-js/dist/es5/uri.all.js: (** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js *) @noble/hashes/esm/utils.js: (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/esm/abstract/utils.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/esm/abstract/modular.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/esm/abstract/curve.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/esm/abstract/weierstrass.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/esm/_shortw_utils.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/esm/secp256k1.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/esm/p256.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/esm/abstract/edwards.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/esm/abstract/montgomery.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/curves/esm/ed25519.js: (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *) @noble/ciphers/esm/utils.js: (*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *) uint8-util/util.js: (* Common package for dealing with hex/string/uint8 conversions (and sha1 hashing) * * @author Jimmy Wärting (https://jimmy.warting.se/opensource) * @license MIT *) @noble/ed25519/index.js: (*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *) @noble/secp256k1/index.js: (*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) *) */ //# sourceMappingURL=browser.js.map