Dorian 0d073fa89e Add comprehensive installation and setup documentation
- Add GETTING_STARTED.md with quick start guide and development modes
- Add INSTALL.sh automated installation script
- Add INSTALLATION_CHECKLIST.md, INSTALLATION_SUCCESS.md, and INSTALLATION_SUMMARY.md
- Add QUICK_REFERENCE.md for common commands
- Add SETUP_GUIDE.md with detailed setup instructions
- Update README.md with improved project overview
- Add did-wallet app dependencies and node_modules
2026-01-27 17:18:21 +00:00

62 lines
261 KiB
JavaScript

"use strict";var Web5Crypto=(()=>{var hy=Object.create;var Ci=Object.defineProperty;var py=Object.getOwnPropertyDescriptor;var yy=Object.getOwnPropertyNames;var wy=Object.getPrototypeOf,my=Object.prototype.hasOwnProperty;var D=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Li=(t,e)=>{for(var r in e)Ci(t,r,{get:e[r],enumerable:!0})},Lf=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of yy(e))!my.call(t,i)&&i!==r&&Ci(t,i,{get:()=>e[i],enumerable:!(n=py(e,i))||n.enumerable});return t};var Oi=(t,e,r)=>(r=t!=null?hy(wy(t)):{},Lf(e||!t||!t.__esModule?Ci(r,"default",{value:t,enumerable:!0}):r,t)),by=t=>Lf(Ci({},"__esModule",{value:!0}),t);var Kf=D((x2,Of)=>{var gy=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ki=()=>gy.now(),xy=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),ds=t=>t===1/0||xy(t),hs=class t{constructor({max:e=1/0,ttl:r,updateAgeOnGet:n=!1,checkAgeOnGet:i=!1,noUpdateTTL:o=!1,dispose:s,noDisposeOnSet:a=!1}={}){if(this.expirations=Object.create(null),this.data=new Map,this.expirationMap=new Map,r!==void 0&&!ds(r))throw new TypeError("ttl must be positive integer or Infinity if set");if(!ds(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=!!a,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<e)return;this.timer&&clearTimeout(this.timer);let n=setTimeout(()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let i in this.expirations){this.setTimer(i,i-Ki());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(Ki()+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(!ds(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-Ki())):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(Ki());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()}};Of.exports=hs});var Qf=D(Xf=>{"use strict";Xf.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 Je=D((d_,eu)=>{"use strict";eu.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 nu=D(Di=>{"use strict";Di.byteLength=Qy;Di.toByteArray=t0;Di.fromByteArray=i0;var st=[],Ne=[],Xy=typeof Uint8Array<"u"?Uint8Array:Array,Ts="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(wr=0,tu=Ts.length;wr<tu;++wr)st[wr]=Ts[wr],Ne[Ts.charCodeAt(wr)]=wr;var wr,tu;Ne[45]=62;Ne[95]=63;function ru(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function Qy(t){var e=ru(t),r=e[0],n=e[1];return(r+n)*3/4-n}function e0(t,e,r){return(e+r)*3/4-r}function t0(t){var e,r=ru(t),n=r[0],i=r[1],o=new Xy(e0(t,n,i)),s=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=Ne[t.charCodeAt(c)]<<18|Ne[t.charCodeAt(c+1)]<<12|Ne[t.charCodeAt(c+2)]<<6|Ne[t.charCodeAt(c+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=Ne[t.charCodeAt(c)]<<2|Ne[t.charCodeAt(c+1)]>>4,o[s++]=e&255),i===1&&(e=Ne[t.charCodeAt(c)]<<10|Ne[t.charCodeAt(c+1)]<<4|Ne[t.charCodeAt(c+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function r0(t){return st[t>>18&63]+st[t>>12&63]+st[t>>6&63]+st[t&63]}function n0(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(t[o+2]&255),i.push(r0(n));return i.join("")}function i0(t){for(var e,r=t.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(n0(t,s,s+o>a?a:s+o));return n===1?(e=t[r-1],i.push(st[e>>2]+st[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(st[e>>10]+st[e>>4&63]+st[e<<2&63]+"=")),i.join("")}});var iu=D(Bs=>{Bs.read=function(t,e,r,n,i){var o,s,a=i*8-n-1,c=(1<<a)-1,f=c>>1,u=-7,l=r?i-1:0,p=r?-1:1,y=t[e+l];for(l+=p,o=y&(1<<-u)-1,y>>=-u,u+=a;u>0;o=o*256+t[e+l],l+=p,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=n;u>0;s=s*256+t[e+l],l+=p,u-=8);if(o===0)o=1-f;else{if(o===c)return s?NaN:(y?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-f}return(y?-1:1)*s*Math.pow(2,o-n)};Bs.write=function(t,e,r,n,i,o){var s,a,c,f=o*8-i-1,u=(1<<f)-1,l=u>>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=n?0:o-1,d=n?1:-1,h=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+l>=1?e+=p/c:e+=p*Math.pow(2,1-l),e*c>=2&&(s++,c/=2),s+l>=u?(a=0,s=u):s+l>=1?(a=(e*c-1)*Math.pow(2,i),s=s+l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;t[r+y]=a&255,y+=d,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;t[r+y]=s&255,y+=d,s/=256,f-=8);t[r+y-d]|=h*128}});var De=D(un=>{"use strict";var Ps=nu(),cn=iu(),ou=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;un.Buffer=E;un.SlowBuffer=u0;un.INSPECT_MAX_BYTES=50;var Mi=2147483647;un.kMaxLength=Mi;E.TYPED_ARRAY_SUPPORT=o0();!E.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 o0(){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(E.prototype,"parent",{enumerable:!0,get:function(){if(E.isBuffer(this))return this.buffer}});Object.defineProperty(E.prototype,"offset",{enumerable:!0,get:function(){if(E.isBuffer(this))return this.byteOffset}});function _t(t){if(t>Mi)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,E.prototype),e}function E(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 Us(t)}return fu(t,e,r)}E.poolSize=8192;function fu(t,e,r){if(typeof t=="string")return a0(t,e);if(ArrayBuffer.isView(t))return c0(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(at(t,ArrayBuffer)||t&&at(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(at(t,SharedArrayBuffer)||t&&at(t.buffer,SharedArrayBuffer)))return Is(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 E.from(n,e,r);let i=f0(t);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return E.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)}E.from=function(t,e,r){return fu(t,e,r)};Object.setPrototypeOf(E.prototype,Uint8Array.prototype);Object.setPrototypeOf(E,Uint8Array);function uu(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 s0(t,e,r){return uu(t),t<=0?_t(t):e!==void 0?typeof r=="string"?_t(t).fill(e,r):_t(t).fill(e):_t(t)}E.alloc=function(t,e,r){return s0(t,e,r)};function Us(t){return uu(t),_t(t<0?0:Cs(t)|0)}E.allocUnsafe=function(t){return Us(t)};E.allocUnsafeSlow=function(t){return Us(t)};function a0(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!E.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=lu(t,e)|0,n=_t(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function ks(t){let e=t.length<0?0:Cs(t.length)|0,r=_t(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function c0(t){if(at(t,Uint8Array)){let e=new Uint8Array(t);return Is(e.buffer,e.byteOffset,e.byteLength)}return ks(t)}function Is(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,E.prototype),n}function f0(t){if(E.isBuffer(t)){let e=Cs(t.length)|0,r=_t(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Os(t.length)?_t(0):ks(t);if(t.type==="Buffer"&&Array.isArray(t.data))return ks(t.data)}function Cs(t){if(t>=Mi)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Mi.toString(16)+" bytes");return t|0}function u0(t){return+t!=t&&(t=0),E.alloc(+t)}E.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==E.prototype};E.compare=function(e,r){if(at(e,Uint8Array)&&(e=E.from(e,e.offset,e.byteLength)),at(r,Uint8Array)&&(r=E.from(r,r.offset,r.byteLength)),!E.isBuffer(e)||!E.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);o<s;++o)if(e[o]!==r[o]){n=e[o],i=r[o];break}return n<i?-1:i<n?1:0};E.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};E.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return E.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=E.allocUnsafe(r),o=0;for(n=0;n<e.length;++n){let s=e[n];if(at(s,Uint8Array))o+s.length>i.length?(E.isBuffer(s)||(s=E.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(E.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function lu(t,e){if(E.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||at(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 Rs(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return xu(t).length;default:if(i)return n?-1:Rs(t).length;e=(""+e).toLowerCase(),i=!0}}E.byteLength=lu;function l0(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 E0(this,e,r);case"utf8":case"utf-8":return hu(this,e,r);case"ascii":return g0(this,e,r);case"latin1":case"binary":return x0(this,e,r);case"base64":return m0(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _0(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}E.prototype._isBuffer=!0;function mr(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}E.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;r<e;r+=2)mr(this,r,r+1);return this};E.prototype.swap32=function(){let e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)mr(this,r,r+3),mr(this,r+1,r+2);return this};E.prototype.swap64=function(){let e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)mr(this,r,r+7),mr(this,r+1,r+6),mr(this,r+2,r+5),mr(this,r+3,r+4);return this};E.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?hu(this,0,e):l0.apply(this,arguments)};E.prototype.toLocaleString=E.prototype.toString;E.prototype.equals=function(e){if(!E.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:E.compare(this,e)===0};E.prototype.inspect=function(){let e="",r=un.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};ou&&(E.prototype[ou]=E.prototype.inspect);E.prototype.compare=function(e,r,n,i,o){if(at(e,Uint8Array)&&(e=E.from(e,e.offset,e.byteLength)),!E.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,a=n-r,c=Math.min(s,a),f=this.slice(i,o),u=e.slice(r,n);for(let l=0;l<c;++l)if(f[l]!==u[l]){s=f[l],a=u[l];break}return s<a?-1:a<s?1:0};function du(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Os(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=E.from(e,n)),E.isBuffer(e))return e.length===0?-1:su(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):su(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function su(t,e,r,n,i){let o=1,s=t.length,a=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,a/=2,r/=2}function c(u,l){return o===1?u[l]:u.readUInt16BE(l*o)}let f;if(i){let u=-1;for(f=r;f<s;f++)if(c(t,f)===c(e,u===-1?0:f-u)){if(u===-1&&(u=f),f-u+1===a)return u*o}else u!==-1&&(f-=f-u),u=-1}else for(r+a>s&&(r=s-a),f=r;f>=0;f--){let u=!0;for(let l=0;l<a;l++)if(c(t,f+l)!==c(e,l)){u=!1;break}if(u)return f}return-1}E.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};E.prototype.indexOf=function(e,r,n){return du(this,e,r,n,!0)};E.prototype.lastIndexOf=function(e,r,n){return du(this,e,r,n,!1)};function d0(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let a=parseInt(e.substr(s*2,2),16);if(Os(a))return s;t[r+s]=a}return s}function h0(t,e,r,n){return qi(Rs(e,t.length-r),t,r,n)}function p0(t,e,r,n){return qi(T0(e),t,r,n)}function y0(t,e,r,n){return qi(xu(e),t,r,n)}function w0(t,e,r,n){return qi(B0(e,t.length-r),t,r,n)}E.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>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 d0(this,e,r,n);case"utf8":case"utf-8":return h0(this,e,r,n);case"ascii":case"latin1":case"binary":return p0(this,e,r,n);case"base64":return y0(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w0(this,e,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};E.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function m0(t,e,r){return e===0&&r===t.length?Ps.fromByteArray(t):Ps.fromByteArray(t.slice(e,r))}function hu(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let o=t[i],s=null,a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){let c,f,u,l;switch(a){case 1:o<128&&(s=o);break;case 2:c=t[i+1],(c&192)===128&&(l=(o&31)<<6|c&63,l>127&&(s=l));break;case 3:c=t[i+1],f=t[i+2],(c&192)===128&&(f&192)===128&&(l=(o&15)<<12|(c&63)<<6|f&63,l>2047&&(l<55296||l>57343)&&(s=l));break;case 4:c=t[i+1],f=t[i+2],u=t[i+3],(c&192)===128&&(f&192)===128&&(u&192)===128&&(l=(o&15)<<18|(c&63)<<12|(f&63)<<6|u&63,l>65535&&l<1114112&&(s=l))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=a}return b0(n)}var au=4096;function b0(t){let e=t.length;if(e<=au)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=au));return r}function g0(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function x0(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function E0(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let o=e;o<r;++o)i+=P0[t[o]];return i}function _0(t,e,r){let n=t.slice(e,r),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}E.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,E.prototype),i};function ye(t,e,r){if(t%1!==0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}E.prototype.readUintLE=E.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||ye(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return i};E.prototype.readUintBE=E.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||ye(e,r,this.length);let i=this[e+--r],o=1;for(;r>0&&(o*=256);)i+=this[e+--r]*o;return i};E.prototype.readUint8=E.prototype.readUInt8=function(e,r){return e=e>>>0,r||ye(e,1,this.length),this[e]};E.prototype.readUint16LE=E.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||ye(e,2,this.length),this[e]|this[e+1]<<8};E.prototype.readUint16BE=E.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||ye(e,2,this.length),this[e]<<8|this[e+1]};E.prototype.readUint32LE=E.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||ye(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};E.prototype.readUint32BE=E.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||ye(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};E.prototype.readBigUInt64LE=Wt(function(e){e=e>>>0,fn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&$n(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)<<BigInt(32))});E.prototype.readBigUInt64BE=Wt(function(e){e=e>>>0,fn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&$n(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)<<BigInt(32))+BigInt(o)});E.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||ye(e,r,this.length);let i=this[e],o=1,s=0;for(;++s<r&&(o*=256);)i+=this[e+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};E.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||ye(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};E.prototype.readInt8=function(e,r){return e=e>>>0,r||ye(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};E.prototype.readInt16LE=function(e,r){e=e>>>0,r||ye(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};E.prototype.readInt16BE=function(e,r){e=e>>>0,r||ye(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};E.prototype.readInt32LE=function(e,r){return e=e>>>0,r||ye(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};E.prototype.readInt32BE=function(e,r){return e=e>>>0,r||ye(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};E.prototype.readBigInt64LE=Wt(function(e){e=e>>>0,fn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&$n(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});E.prototype.readBigInt64BE=Wt(function(e){e=e>>>0,fn(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&$n(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});E.prototype.readFloatLE=function(e,r){return e=e>>>0,r||ye(e,4,this.length),cn.read(this,e,!0,23,4)};E.prototype.readFloatBE=function(e,r){return e=e>>>0,r||ye(e,4,this.length),cn.read(this,e,!1,23,4)};E.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||ye(e,8,this.length),cn.read(this,e,!0,52,8)};E.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||ye(e,8,this.length),cn.read(this,e,!1,52,8)};function Te(t,e,r,n,i,o){if(!E.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}E.prototype.writeUintLE=E.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Te(this,e,r,n,a,0)}let o=1,s=0;for(this[r]=e&255;++s<n&&(o*=256);)this[r+s]=e/o&255;return r+n};E.prototype.writeUintBE=E.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;Te(this,e,r,n,a,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};E.prototype.writeUint8=E.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||Te(this,e,r,1,255,0),this[r]=e&255,r+1};E.prototype.writeUint16LE=E.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Te(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};E.prototype.writeUint16BE=E.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Te(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};E.prototype.writeUint32LE=E.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Te(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};E.prototype.writeUint32BE=E.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Te(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 pu(t,e,r,n,i){gu(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 yu(t,e,r,n,i){gu(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}E.prototype.writeBigUInt64LE=Wt(function(e,r=0){return pu(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});E.prototype.writeBigUInt64BE=Wt(function(e,r=0){return yu(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});E.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Te(this,e,r,n,c-1,-c)}let o=0,s=1,a=0;for(this[r]=e&255;++o<n&&(s*=256);)e<0&&a===0&&this[r+o-1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};E.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);Te(this,e,r,n,c-1,-c)}let o=n-1,s=1,a=0;for(this[r+o]=e&255;--o>=0&&(s*=256);)e<0&&a===0&&this[r+o+1]!==0&&(a=1),this[r+o]=(e/s>>0)-a&255;return r+n};E.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||Te(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};E.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||Te(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};E.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||Te(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};E.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||Te(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};E.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||Te(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};E.prototype.writeBigInt64LE=Wt(function(e,r=0){return pu(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});E.prototype.writeBigInt64BE=Wt(function(e,r=0){return yu(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function wu(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 mu(t,e,r,n,i){return e=+e,r=r>>>0,i||wu(t,e,r,4,34028234663852886e22,-34028234663852886e22),cn.write(t,e,r,n,23,4),r+4}E.prototype.writeFloatLE=function(e,r,n){return mu(this,e,r,!0,n)};E.prototype.writeFloatBE=function(e,r,n){return mu(this,e,r,!1,n)};function bu(t,e,r,n,i){return e=+e,r=r>>>0,i||wu(t,e,r,8,17976931348623157e292,-17976931348623157e292),cn.write(t,e,r,n,52,8),r+8}E.prototype.writeDoubleLE=function(e,r,n){return bu(this,e,r,!0,n)};E.prototype.writeDoubleBE=function(e,r,n){return bu(this,e,r,!1,n)};E.prototype.copy=function(e,r,n,i){if(!E.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<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=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<i-n&&(i=e.length-r+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),o};E.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!E.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let s=e.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(e=s)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=r;o<n;++o)this[o]=e;else{let s=E.isBuffer(e)?e:E.from(e,i),a=s.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-r;++o)this[o+r]=s[o%a]}return this};var an={};function Ls(t,e,r){an[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Ls("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Ls("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Ls("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=cu(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=cu(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function cu(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 v0(t,e,r){fn(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&$n(e,t.length-(r+1))}function gu(t,e,r,n,i,o){if(t>r||t<e){let s=typeof e=="bigint"?"n":"",a;throw o>3?e===0||e===BigInt(0)?a=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:a=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:a=`>= ${e}${s} and <= ${r}${s}`,new an.ERR_OUT_OF_RANGE("value",a,t)}v0(n,i,o)}function fn(t,e){if(typeof t!="number")throw new an.ERR_INVALID_ARG_TYPE(e,"number",t)}function $n(t,e,r){throw Math.floor(t)!==t?(fn(t,r),new an.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new an.ERR_BUFFER_OUT_OF_BOUNDS:new an.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var A0=/[^+/0-9A-Za-z-_]/g;function S0(t){if(t=t.split("=")[0],t=t.trim().replace(A0,""),t.length<2)return"";for(;t.length%4!==0;)t=t+"=";return t}function Rs(t,e){e=e||1/0;let r,n=t.length,i=null,o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&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 T0(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function B0(t,e){let r,n,i,o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function xu(t){return Ps.toByteArray(S0(t))}function qi(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function at(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Os(t){return t!==t}var P0=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 Wt(t){return typeof BigInt>"u"?k0:t}function k0(){throw new Error("BigInt not supported")}});var Ns=D((m_,Eu)=>{"use strict";var Ks=null;Eu.exports=function(){return Ks===null&&(Ks={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),Ks}});var qs=D(_u=>{"use strict";var Ds=Je(),I0=new Set(["buffer","view","utf8"]),Ms=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"||!I0.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 Ds(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new Ds(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new Ds(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};_u.Encoding=Ms});var Vs=D(ji=>{"use strict";var{Buffer:Fs}=De()||{},{Encoding:$s}=qs(),R0=Ns(),Vn=class extends $s{constructor(e){super({...e,format:"buffer"})}createViewTranscoder(){return new Hn({encode:this.encode,decode:e=>this.decode(Fs.from(e.buffer,e.byteOffset,e.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},Hn=class extends $s{constructor(e){super({...e,format:"view"})}createBufferTranscoder(){return new Vn({encode:e=>{let r=this.encode(e);return Fs.from(r.buffer,r.byteOffset,r.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},js=class extends $s{constructor(e){super({...e,format:"utf8"})}createBufferTranscoder(){return new Vn({encode:e=>Fs.from(this.encode(e),"utf8"),decode:e=>this.decode(e.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:e,textDecoder:r}=R0();return new Hn({encode:n=>e.encode(this.encode(n)),decode:n=>this.decode(r.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};ji.BufferFormat=Vn;ji.ViewFormat=Hn;ji.UTF8Format=js});var Tu=D(br=>{"use strict";var{Buffer:Ee}=De()||{Buffer:{isBuffer:()=>!1}},{textEncoder:Au,textDecoder:vu}=Ns()(),{BufferFormat:Gn,ViewFormat:Hs,UTF8Format:Su}=Vs(),Fi=t=>t;br.utf8=new Su({encode:function(t){return Ee.isBuffer(t)?t.toString("utf8"):ArrayBuffer.isView(t)?vu.decode(t):String(t)},decode:Fi,name:"utf8",createViewTranscoder(){return new Hs({encode:function(t){return ArrayBuffer.isView(t)?t:Au.encode(t)},decode:function(t){return vu.decode(t)},name:`${this.name}+view`})},createBufferTranscoder(){return new Gn({encode:function(t){return Ee.isBuffer(t)?t:ArrayBuffer.isView(t)?Ee.from(t.buffer,t.byteOffset,t.byteLength):Ee.from(String(t),"utf8")},decode:function(t){return t.toString("utf8")},name:`${this.name}+buffer`})}});br.json=new Su({encode:JSON.stringify,decode:JSON.parse,name:"json"});br.buffer=new Gn({encode:function(t){return Ee.isBuffer(t)?t:ArrayBuffer.isView(t)?Ee.from(t.buffer,t.byteOffset,t.byteLength):Ee.from(String(t),"utf8")},decode:Fi,name:"buffer",createViewTranscoder(){return new Hs({encode:function(t){return ArrayBuffer.isView(t)?t:Ee.from(String(t),"utf8")},decode:function(t){return Ee.from(t.buffer,t.byteOffset,t.byteLength)},name:`${this.name}+view`})}});br.view=new Hs({encode:function(t){return ArrayBuffer.isView(t)?t:Au.encode(t)},decode:Fi,name:"view",createBufferTranscoder(){return new Gn({encode:function(t){return Ee.isBuffer(t)?t:ArrayBuffer.isView(t)?Ee.from(t.buffer,t.byteOffset,t.byteLength):Ee.from(String(t),"utf8")},decode:Fi,name:`${this.name}+buffer`})}});br.hex=new Gn({encode:function(t){return Ee.isBuffer(t)?t:Ee.from(String(t),"hex")},decode:function(t){return t.toString("hex")},name:"hex"});br.base64=new Gn({encode:function(t){return Ee.isBuffer(t)?t:Ee.from(String(t),"base64")},decode:function(t){return t.toString("base64")},name:"base64"})});var ku=D(Pu=>{"use strict";var Bu=Je(),Vi=Tu(),{Encoding:U0}=qs(),{BufferFormat:C0,ViewFormat:L0,UTF8Format:O0}=Vs(),Jn=Symbol("formats"),$i=Symbol("encodings"),K0=new Set(["buffer","view","utf8"]),Gs=class{constructor(e){if(Array.isArray(e)){if(!e.every(r=>K0.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[$i]=new Map,this[Jn]=new Set(e);for(let r in Vi)try{this.encoding(r)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[$i].values()))}encoding(e){let r=this[$i].get(e);if(r===void 0){if(typeof e=="string"&&e!==""){if(r=q0[e],!r)throw new Bu(`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=N0(e)}let{name:n,format:i}=r;if(!this[Jn].has(i))if(this[Jn].has("view"))r=r.createViewTranscoder();else if(this[Jn].has("buffer"))r=r.createBufferTranscoder();else if(this[Jn].has("utf8"))r=r.createUTF8Transcoder();else throw new Bu(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[e,n,r.name,r.commonName])this[$i].set(o,r)}return r}};Pu.Transcoder=Gs;function N0(t){if(t instanceof U0)return t;let e="type"in t&&typeof t.type=="string"?t.type:void 0,r=t.name||e||`anonymous-${j0++}`;switch(D0(t)){case"view":return new L0({...t,name:r});case"utf8":return new O0({...t,name:r});case"buffer":return new C0({...t,name:r});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function D0(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 M0={binary:Vi.buffer,"utf-8":Vi.utf8},q0={...Vi,...M0},j0=0});var Wn=D((__,Js)=>{"use strict";var ln=typeof Reflect=="object"?Reflect:null,Iu=ln&&typeof ln.apply=="function"?ln.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Hi;ln&&typeof ln.ownKeys=="function"?Hi=ln.ownKeys:Object.getOwnPropertySymbols?Hi=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Hi=function(e){return Object.getOwnPropertyNames(e)};function F0(t){console&&console.warn&&console.warn(t)}var Uu=Number.isNaN||function(e){return e!==e};function re(){re.init.call(this)}Js.exports=re;Js.exports.once=G0;re.EventEmitter=re;re.prototype._events=void 0;re.prototype._eventsCount=0;re.prototype._maxListeners=void 0;var Ru=10;function Gi(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(re,"defaultMaxListeners",{enumerable:!0,get:function(){return Ru},set:function(t){if(typeof t!="number"||t<0||Uu(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Ru=t}});re.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};re.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Uu(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 Cu(t){return t._maxListeners===void 0?re.defaultMaxListeners:t._maxListeners}re.prototype.getMaxListeners=function(){return Cu(this)};re.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",o=this._events;if(o!==void 0)i=i&&o.error===void 0;else if(!i)return!1;if(i){var s;if(r.length>0&&(s=r[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(c===void 0)return!1;if(typeof c=="function")Iu(c,this,r);else for(var f=c.length,u=Du(c,f),n=0;n<f;++n)Iu(u[n],this,r);return!0};function Lu(t,e,r,n){var i,o,s;if(Gi(r),o=t._events,o===void 0?(o=t._events=Object.create(null),t._eventsCount=0):(o.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),s===void 0)s=o[e]=r,++t._eventsCount;else if(typeof s=="function"?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),i=Cu(t),i>0&&s.length>i&&!s.warned){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=s.length,F0(a)}return t}re.prototype.addListener=function(e,r){return Lu(this,e,r,!1)};re.prototype.on=re.prototype.addListener;re.prototype.prependListener=function(e,r){return Lu(this,e,r,!0)};function $0(){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 Ou(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=$0.bind(n);return i.listener=r,n.wrapFn=i,i}re.prototype.once=function(e,r){return Gi(r),this.on(e,Ou(this,e,r)),this};re.prototype.prependOnceListener=function(e,r){return Gi(r),this.prependListener(e,Ou(this,e,r)),this};re.prototype.removeListener=function(e,r){var n,i,o,s,a;if(Gi(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){a=n[s].listener,o=s;break}if(o<0)return this;o===0?n.shift():V0(n,o),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};re.prototype.off=re.prototype.removeListener;re.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<o.length;++i)s=o[i],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function Ku(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?H0(i):Du(i,i.length)}re.prototype.listeners=function(e){return Ku(this,e,!0)};re.prototype.rawListeners=function(e){return Ku(this,e,!1)};re.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Nu.call(t,e)};re.prototype.listenerCount=Nu;function Nu(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}re.prototype.eventNames=function(){return this._eventsCount>0?Hi(this._events):[]};function Du(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function V0(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function H0(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function G0(t,e){return new Promise(function(r,n){function i(s){t.removeListener(e,o),n(s)}function o(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}Mu(t,e,o,{once:!0}),e!=="error"&&J0(t,i,{once:!0})})}function J0(t,e,r){typeof t.on=="function"&&Mu(t,"error",e,r)}function Mu(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(o){n.once&&t.removeEventListener(e,i),r(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var ju=D((v_,qu)=>{qu.exports=typeof queueMicrotask=="function"?queueMicrotask:t=>Promise.resolve().then(t)});var zn=D(Ws=>{"use strict";var Fu=ju();Ws.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};Ws.fromPromise=function(t,e){if(e===void 0)return t;t.then(function(r){Fu(()=>e(null,r))}).catch(function(r){Fu(()=>e(r))})}});var Ji=D(zs=>{"use strict";zs.getCallback=function(t,e){return typeof t=="function"?t:e};zs.getOptions=function(t,e){return typeof t=="object"&&t!==null?t:e!==void 0?e:{}}});var er=D(Zi=>{"use strict";var{fromCallback:Ys}=zn(),Re=Je(),{getOptions:Zs,getCallback:$u}=Ji(),gr=Symbol("promise"),dn=Symbol("callback"),ct=Symbol("working"),xr=Symbol("handleOne"),vt=Symbol("handleMany"),Xs=Symbol("autoClose"),Xt=Symbol("finishWork"),ft=Symbol("returnMany"),zt=Symbol("closing"),Yn=Symbol("handleClose"),Wi=Symbol("closed"),Zn=Symbol("closeCallbacks"),Zt=Symbol("keyEncoding"),Er=Symbol("valueEncoding"),Qs=Symbol("abortOnClose"),zi=Symbol("legacy"),ea=Symbol("keys"),ta=Symbol("values"),Yt=Symbol("limit"),Me=Symbol("count"),Yi=Object.freeze({}),W0=()=>{},Vu=!1,Xn=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[Wi]=!1,this[Zn]=[],this[ct]=!1,this[zt]=!1,this[Xs]=!1,this[dn]=null,this[xr]=this[xr].bind(this),this[vt]=this[vt].bind(this),this[Yn]=this[Yn].bind(this),this[Zt]=r[Zt],this[Er]=r[Er],this[zi]=n,this[Yt]=Number.isInteger(r.limit)&&r.limit>=0?r.limit:1/0,this[Me]=0,this[Qs]=!!r.abortOnClose,this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get count(){return this[Me]}get limit(){return this[Yt]}next(e){let r;if(e===void 0)r=new Promise((n,i)=>{e=(o,s,a)=>{o?i(o):this[zi]?s===void 0&&a===void 0?n():n([s,a]):n(s)}});else if(typeof e!="function")throw new TypeError("Callback must be a function");return this[zt]?this.nextTick(e,new Re("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[ct]?this.nextTick(e,new Re("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[ct]=!0,this[dn]=e,this[Me]>=this[Yt]?this.nextTick(this[xr],null):this._next(this[xr])),r}_next(e){this.nextTick(e)}nextv(e,r,n){return n=$u(r,n),n=Ys(n,gr),r=Zs(r,Yi),Number.isInteger(e)?(this[zt]?this.nextTick(n,new Re("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[ct]?this.nextTick(n,new Re("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(e<1&&(e=1),this[Yt]<1/0&&(e=Math.min(e,this[Yt]-this[Me])),this[ct]=!0,this[dn]=n,e<=0?this.nextTick(this[vt],null,[]):this._nextv(e,r,this[vt])),n[gr]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[gr])}_nextv(e,r,n){let i=[],o=(s,a,c)=>{if(s)return n(s);if(this[zi]?a===void 0&&c===void 0:a===void 0)return n(null,i);i.push(this[zi]?[a,c]:a),i.length===e?n(null,i):this._next(o)};this._next(o)}all(e,r){return r=$u(e,r),r=Ys(r,gr),e=Zs(e,Yi),this[zt]?this.nextTick(r,new Re("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[ct]?this.nextTick(r,new Re("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[ct]=!0,this[dn]=r,this[Xs]=!0,this[Me]>=this[Yt]?this.nextTick(this[vt],null,[]):this._all(e,this[vt])),r[gr]}_all(e,r){let n=this[Me],i=[],o=()=>{let a=this[Yt]<1/0?Math.min(1e3,this[Yt]-n):1e3;a<=0?this.nextTick(r,null,i):this._nextv(a,Yi,s)},s=(a,c)=>{a?r(a):c.length===0?r(null,i):(i.push.apply(i,c),n+=c.length,o())};o()}[Xt](){let e=this[dn];return this[Qs]&&e===null?W0:(this[ct]=!1,this[dn]=null,this[zt]&&this._close(this[Yn]),e)}[ft](e,r,n){this[Xs]?this.close(e.bind(null,r,n)):e(r,n)}seek(e,r){if(r=Zs(r,Yi),!this[zt]){if(this[ct])throw new Re("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let n=this.db.keyEncoding(r.keyEncoding||this[Zt]),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 Re("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(e){return e=Ys(e,gr),this[Wi]?this.nextTick(e):this[zt]?this[Zn].push(e):(this[zt]=!0,this[Zn].push(e),this[ct]?this[Qs]&&this[Xt]()(new Re("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[Yn])),e[gr]}_close(e){this.nextTick(e)}[Yn](){this[Wi]=!0,this.db.detachResource(this);let e=this[Zn];this[Zn]=[];for(let r of e)r()}async*[Symbol.asyncIterator](){try{let e;for(;(e=await this.next())!==void 0;)yield e}finally{this[Wi]||await this.close()}}},hn=class extends Xn{constructor(e,r){super(e,r,!0),this[ea]=r.keys!==!1,this[ta]=r.values!==!1}[xr](e,r,n){let i=this[Xt]();if(e)return i(e);try{r=this[ea]&&r!==void 0?this[Zt].decode(r):void 0,n=this[ta]&&n!==void 0?this[Er].decode(n):void 0}catch(o){return i(new Qt("entry",o))}r===void 0&&n===void 0||this[Me]++,i(null,r,n)}[vt](e,r){let n=this[Xt]();if(e)return this[ft](n,e);try{for(let i of r){let o=i[0],s=i[1];i[0]=this[ea]&&o!==void 0?this[Zt].decode(o):void 0,i[1]=this[ta]&&s!==void 0?this[Er].decode(s):void 0}}catch(i){return this[ft](n,new Qt("entries",i))}this[Me]+=r.length,this[ft](n,null,r)}end(e){return!Vu&&typeof console<"u"&&(Vu=!0,console.warn(new Re("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)}},ra=class extends Xn{constructor(e,r){super(e,r,!1)}[xr](e,r){let n=this[Xt]();if(e)return n(e);try{r=r!==void 0?this[Zt].decode(r):void 0}catch(i){return n(new Qt("key",i))}r!==void 0&&this[Me]++,n(null,r)}[vt](e,r){let n=this[Xt]();if(e)return this[ft](n,e);try{for(let i=0;i<r.length;i++){let o=r[i];r[i]=o!==void 0?this[Zt].decode(o):void 0}}catch(i){return this[ft](n,new Qt("keys",i))}this[Me]+=r.length,this[ft](n,null,r)}},na=class extends Xn{constructor(e,r){super(e,r,!1)}[xr](e,r){let n=this[Xt]();if(e)return n(e);try{r=r!==void 0?this[Er].decode(r):void 0}catch(i){return n(new Qt("value",i))}r!==void 0&&this[Me]++,n(null,r)}[vt](e,r){let n=this[Xt]();if(e)return this[ft](n,e);try{for(let i=0;i<r.length;i++){let o=r[i];r[i]=o!==void 0?this[Er].decode(o):void 0}}catch(i){return this[ft](n,new Qt("values",i))}this[Me]+=r.length,this[ft](n,null,r)}},Qt=class extends Re{constructor(e,r){super(`Iterator could not decode ${e}`,{code:"LEVEL_DECODE_ERROR",cause:r})}};for(let t of["_ended property","_nexting property","_end method"])Object.defineProperty(hn.prototype,t.split(" ")[0],{get(){throw new Re(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new Re(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})}});hn.keyEncoding=Zt;hn.valueEncoding=Er;Zi.AbstractIterator=hn;Zi.AbstractKeyIterator=ra;Zi.AbstractValueIterator=na});var Hu=D(ia=>{"use strict";var{AbstractKeyIterator:z0,AbstractValueIterator:Y0}=er(),_r=Symbol("iterator"),Qn=Symbol("callback"),pn=Symbol("handleOne"),vr=Symbol("handleMany"),ei=class extends z0{constructor(e,r){super(e,r),this[_r]=e.iterator({...r,keys:!0,values:!1}),this[pn]=this[pn].bind(this),this[vr]=this[vr].bind(this)}},Xi=class extends Y0{constructor(e,r){super(e,r),this[_r]=e.iterator({...r,keys:!1,values:!0}),this[pn]=this[pn].bind(this),this[vr]=this[vr].bind(this)}};for(let t of[ei,Xi]){let e=t===ei,r=e?n=>n[0]:n=>n[1];t.prototype._next=function(n){this[Qn]=n,this[_r].next(this[pn])},t.prototype[pn]=function(n,i,o){let s=this[Qn];n?s(n):s(null,e?i:o)},t.prototype._nextv=function(n,i,o){this[Qn]=o,this[_r].nextv(n,i,this[vr])},t.prototype._all=function(n,i){this[Qn]=i,this[_r].all(n,this[vr])},t.prototype[vr]=function(n,i){let o=this[Qn];n?o(n):o(null,i.map(r))},t.prototype._seek=function(n,i){this[_r].seek(n,i)},t.prototype._close=function(n){this[_r].close(n)}}ia.DefaultKeyIterator=ei;ia.DefaultValueIterator=Xi});var Gu=D(io=>{"use strict";var{AbstractIterator:Z0,AbstractKeyIterator:X0,AbstractValueIterator:Q0}=er(),oa=Je(),Be=Symbol("nut"),ro=Symbol("undefer"),no=Symbol("factory"),Qi=class extends Z0{constructor(e,r){super(e,r),this[Be]=null,this[no]=()=>e.iterator(r),this.db.defer(()=>this[ro]())}},eo=class extends X0{constructor(e,r){super(e,r),this[Be]=null,this[no]=()=>e.keys(r),this.db.defer(()=>this[ro]())}},to=class extends Q0{constructor(e,r){super(e,r),this[Be]=null,this[no]=()=>e.values(r),this.db.defer(()=>this[ro]())}};for(let t of[Qi,eo,to])t.prototype[ro]=function(){this.db.status==="open"&&(this[Be]=this[no]())},t.prototype._next=function(e){this[Be]!==null?this[Be].next(e):this.db.status==="opening"?this.db.defer(()=>this._next(e)):this.nextTick(e,new oa("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._nextv=function(e,r,n){this[Be]!==null?this[Be].nextv(e,r,n):this.db.status==="opening"?this.db.defer(()=>this._nextv(e,r,n)):this.nextTick(n,new oa("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._all=function(e,r){this[Be]!==null?this[Be].all(r):this.db.status==="opening"?this.db.defer(()=>this._all(e,r)):this.nextTick(r,new oa("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._seek=function(e,r){this[Be]!==null?this[Be]._seek(e,r):this.db.status==="opening"&&this.db.defer(()=>this._seek(e,r))},t.prototype._close=function(e){this[Be]!==null?this[Be].close(e):this.db.status==="opening"?this.db.defer(()=>this._close(e)):this.nextTick(e)};io.DeferredIterator=Qi;io.DeferredKeyIterator=eo;io.DeferredValueIterator=to});var aa=D(Wu=>{"use strict";var{fromCallback:Ju}=zn(),oo=Je(),{getCallback:ew,getOptions:tw}=Ji(),so=Symbol("promise"),qe=Symbol("status"),yn=Symbol("operations"),ti=Symbol("finishClose"),wn=Symbol("closeCallbacks"),sa=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[yn]=[],this[wn]=[],this[qe]="open",this[ti]=this[ti].bind(this),this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get length(){return this[yn].length}put(e,r,n){if(this[qe]!=="open")throw new oo("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,a=o.keyEncoding(n&&n.keyEncoding),c=o.valueEncoding(n&&n.valueEncoding),f=a.format;n={...n,keyEncoding:f,valueEncoding:c.format},o!==this.db&&(n.sublevel=null);let u=o.prefixKey(a.encode(e),f),l=c.encode(r);return this._put(u,l,n),this[yn].push({...s,type:"put",key:e,value:r}),this}_put(e,r,n){}del(e,r){if(this[qe]!=="open")throw new oo("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),a=s.format;return r={...r,keyEncoding:a},i!==this.db&&(r.sublevel=null),this._del(i.prefixKey(s.encode(e),a),r),this[yn].push({...o,type:"del",key:e}),this}_del(e,r){}clear(){if(this[qe]!=="open")throw new oo("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[yn]=[],this}_clear(){}write(e,r){return r=ew(e,r),r=Ju(r,so),e=tw(e),this[qe]!=="open"?this.nextTick(r,new oo("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(r):(this[qe]="writing",this._write(e,n=>{this[qe]="closing",this[wn].push(()=>r(n)),n||this.db.emit("batch",this[yn]),this._close(this[ti])})),r[so]}_write(e,r){}close(e){return e=Ju(e,so),this[qe]==="closing"?this[wn].push(e):this[qe]==="closed"?this.nextTick(e):(this[wn].push(e),this[qe]!=="writing"&&(this[qe]="closing",this._close(this[ti]))),e[so]}_close(e){this.nextTick(e)}[ti](){this[qe]="closed",this.db.detachResource(this);let e=this[wn];this[wn]=[];for(let r of e)r()}};Wu.AbstractChainedBatch=sa});var Yu=D(zu=>{"use strict";var{AbstractChainedBatch:rw}=aa(),nw=Je(),mn=Symbol("encoded"),ca=class extends rw{constructor(e){super(e),this[mn]=[]}_put(e,r,n){this[mn].push({...n,type:"put",key:e,value:r})}_del(e,r){this[mn].push({...r,type:"del",key:e})}_clear(){this[mn]=[]}_write(e,r){this.db.status==="opening"?this.db.defer(()=>this._write(e,r)):this.db.status==="open"?this[mn].length===0?this.nextTick(r):this.db._batch(this[mn],e,r):this.nextTick(r,new nw("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};zu.DefaultChainedBatch=ca});var Qu=D((R_,Xu)=>{"use strict";var Zu=Je(),iw=Object.prototype.hasOwnProperty,ow=new Set(["lt","lte","gt","gte"]);Xu.exports=function(t,e){let r={};for(let n in t)if(iw.call(t,n)&&!(n==="keyEncoding"||n==="valueEncoding")){if(n==="start"||n==="end")throw new Zu(`The legacy range option '${n}' has been removed`,{code:"LEVEL_LEGACY"});if(n==="encoding")throw new Zu("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});ow.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 fa=D((U_,tl)=>{var el;tl.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):t=>(el||(el=Promise.resolve())).then(t).catch(e=>setTimeout(()=>{throw e},0))});var il=D((C_,nl)=>{"use strict";var rl=fa();nl.exports=function(t,...e){e.length===0?rl(t):rl(()=>t(...e))}});var ol=D(ao=>{"use strict";var{AbstractIterator:sw,AbstractKeyIterator:aw,AbstractValueIterator:cw}=er(),bn=Symbol("unfix"),We=Symbol("iterator"),Ar=Symbol("handleOne"),tr=Symbol("handleMany"),At=Symbol("callback"),ri=class extends sw{constructor(e,r,n,i){super(e,r),this[We]=n,this[bn]=i,this[Ar]=this[Ar].bind(this),this[tr]=this[tr].bind(this),this[At]=null}[Ar](e,r,n){let i=this[At];if(e)return i(e);r!==void 0&&(r=this[bn](r)),i(e,r,n)}[tr](e,r){let n=this[At];if(e)return n(e);for(let i of r){let o=i[0];o!==void 0&&(i[0]=this[bn](o))}n(e,r)}},ni=class extends aw{constructor(e,r,n,i){super(e,r),this[We]=n,this[bn]=i,this[Ar]=this[Ar].bind(this),this[tr]=this[tr].bind(this),this[At]=null}[Ar](e,r){let n=this[At];if(e)return n(e);r!==void 0&&(r=this[bn](r)),n(e,r)}[tr](e,r){let n=this[At];if(e)return n(e);for(let i=0;i<r.length;i++){let o=r[i];o!==void 0&&(r[i]=this[bn](o))}n(e,r)}},ii=class extends cw{constructor(e,r,n){super(e,r),this[We]=n}};for(let t of[ri,ni])t.prototype._next=function(e){this[At]=e,this[We].next(this[Ar])},t.prototype._nextv=function(e,r,n){this[At]=n,this[We].nextv(e,r,this[tr])},t.prototype._all=function(e,r){this[At]=r,this[We].all(e,this[tr])};for(let t of[ii])t.prototype._next=function(e){this[We].next(e)},t.prototype._nextv=function(e,r,n){this[We].nextv(e,r,n)},t.prototype._all=function(e,r){this[We].all(e,r)};for(let t of[ri,ni,ii])t.prototype._seek=function(e,r){this[We].seek(e,r)},t.prototype._close=function(e){this[We].close(e)};ao.AbstractSublevelIterator=ri;ao.AbstractSublevelKeyIterator=ni;ao.AbstractSublevelValueIterator=ii});var fl=D((O_,cl)=>{"use strict";var ua=Je(),{Buffer:ha}=De()||{},{AbstractSublevelIterator:fw,AbstractSublevelKeyIterator:uw,AbstractSublevelValueIterator:lw}=ol(),St=Symbol("prefix"),sl=Symbol("upperBound"),oi=Symbol("prefixRange"),Ue=Symbol("parent"),la=Symbol("unfix"),al=new TextEncoder,dw={separator:"!"};cl.exports=function({AbstractLevel:t}){class e extends t{static defaults(n){if(typeof n=="string")throw new ua("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(n&&n.open)throw new ua("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return n==null?dw:n.separator?n:{...n,separator:"!"}}constructor(n,i,o){let{separator:s,manifest:a,...c}=e.defaults(o);i=pw(i,s);let f=s.charCodeAt(0)+1,u=n[Ue]||n;if(!al.encode(i).every(y=>y>f&&y<127))throw new ua(`Prefix must use bytes > ${f} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(hw(u,a),c);let l=(n.prefix||"")+s+i+s,p=l.slice(0,-1)+String.fromCharCode(f);this[Ue]=u,this[St]=new co(l),this[sl]=new co(p),this[la]=new pa,this.nextTick=u.nextTick}prefixKey(n,i){if(i==="utf8")return this[St].utf8+n;if(n.byteLength===0)return this[St][i];if(i==="view"){let o=this[St].view,s=new Uint8Array(o.byteLength+n.byteLength);return s.set(o,0),s.set(n,o.byteLength),s}else{let o=this[St].buffer;return ha.concat([o,n],o.byteLength+n.byteLength)}}[oi](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[St][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[sl][i]}get prefix(){return this[St].utf8}get db(){return this[Ue]}_open(n,i){this[Ue].open({passive:!0},i)}_put(n,i,o,s){this[Ue].put(n,i,o,s)}_get(n,i,o){this[Ue].get(n,i,o)}_getMany(n,i,o){this[Ue].getMany(n,i,o)}_del(n,i,o){this[Ue].del(n,i,o)}_batch(n,i,o){this[Ue].batch(n,i,o)}_clear(n,i){this[oi](n,n.keyEncoding),this[Ue].clear(n,i)}_iterator(n){this[oi](n,n.keyEncoding);let i=this[Ue].iterator(n),o=this[la].get(this[St].utf8.length,n.keyEncoding);return new fw(this,n,i,o)}_keys(n){this[oi](n,n.keyEncoding);let i=this[Ue].keys(n),o=this[la].get(this[St].utf8.length,n.keyEncoding);return new uw(this,n,i,o)}_values(n){this[oi](n,n.keyEncoding);let i=this[Ue].values(n);return new lw(this,n,i)}}return{AbstractSublevel:e}};var hw=function(t,e){return{...t.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...e,encodings:{utf8:da(t,"utf8"),buffer:da(t,"buffer"),view:da(t,"view")}}},da=function(t,e){return t.supports.encodings[e]?t.keyEncoding(e).name===e:!1},co=class{constructor(e){this.utf8=e,this.view=al.encode(e),this.buffer=ha?ha.from(this.view.buffer,0,this.view.byteLength):{}}},pa=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}},pw=function(t,e){let r=0,n=t.length;for(;r<n&&t[r]===e;)r++;for(;n>r&&t[n-1]===e;)n--;return t.slice(r,n)}});var ga=D(ba=>{"use strict";var{supports:yw}=Qf(),{Transcoder:ww}=ku(),{EventEmitter:mw}=Wn(),{fromCallback:rr}=zn(),ze=Je(),{AbstractIterator:Sr}=er(),{DefaultKeyIterator:bw,DefaultValueIterator:gw}=Hu(),{DeferredIterator:xw,DeferredKeyIterator:Ew,DeferredValueIterator:_w}=Gu(),{DefaultChainedBatch:ul}=Yu(),{getCallback:Tr,getOptions:nr}=Ji(),fo=Qu(),W=Symbol("promise"),Tt=Symbol("landed"),Br=Symbol("resources"),ya=Symbol("closeResources"),si=Symbol("operations"),ai=Symbol("undefer"),uo=Symbol("deferOpen"),ll=Symbol("options"),X=Symbol("status"),Pr=Symbol("defaultOptions"),gn=Symbol("transcoder"),lo=Symbol("keyEncoding"),wa=Symbol("valueEncoding"),vw=()=>{},ci=class extends mw{constructor(e,r){if(super(),typeof e!="object"||e===null)throw new TypeError("The first argument 'manifest' must be an object");r=nr(r);let{keyEncoding:n,valueEncoding:i,passive:o,...s}=r;this[Br]=new Set,this[si]=[],this[uo]=!0,this[ll]=s,this[X]="opening",this.supports=yw(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[gn]=new ww(Aw(this)),this[lo]=this[gn].encoding(n||"utf8"),this[wa]=this[gn].encoding(i||"utf8");for(let a of this[gn].encodings())this.supports.encodings[a.commonName]||(this.supports.encodings[a.commonName]=!0);this[Pr]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[lo].commonName,valueEncoding:this[wa].commonName}),key:Object.freeze({keyEncoding:this[lo].commonName})},this.nextTick(()=>{this[uo]&&this.open({passive:!1},vw)})}get status(){return this[X]}keyEncoding(e){return this[gn].encoding(e??this[lo])}valueEncoding(e){return this[gn].encoding(e??this[wa])}open(e,r){r=Tr(e,r),r=rr(r,W),e={...this[ll],...nr(e)},e.createIfMissing=e.createIfMissing!==!1,e.errorIfExists=!!e.errorIfExists;let n=i=>{this[X]==="closing"||this[X]==="opening"?this.once(Tt,i?()=>n(i):n):this[X]!=="open"?r(new ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):r()};return e.passive?this[X]==="opening"?this.once(Tt,n):this.nextTick(n):this[X]==="closed"||this[uo]?(this[uo]=!1,this[X]="opening",this.emit("opening"),this._open(e,i=>{if(i){this[X]="closed",this[ya](()=>{this.emit(Tt),n(i)}),this[ai]();return}this[X]="open",this[ai](),this.emit(Tt),this[X]==="open"&&this.emit("open"),this[X]==="open"&&this.emit("ready"),n()})):this[X]==="open"?this.nextTick(n):this.once(Tt,()=>this.open(e,r)),r[W]}_open(e,r){this.nextTick(r)}close(e){e=rr(e,W);let r=n=>{this[X]==="opening"||this[X]==="closing"?this.once(Tt,n?r(n):r):this[X]!=="closed"?e(new ze("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):e()};if(this[X]==="open"){this[X]="closing",this.emit("closing");let n=i=>{this[X]="open",this[ai](),this.emit(Tt),r(i)};this[ya](()=>{this._close(i=>{if(i)return n(i);this[X]="closed",this[ai](),this.emit(Tt),this[X]==="closed"&&this.emit("closed"),r()})})}else this[X]==="closed"?this.nextTick(r):this.once(Tt,()=>this.close(e));return e[W]}[ya](e){if(this[Br].size===0)return this.nextTick(e);let r=this[Br].size,n=!0,i=()=>{--r===0&&(n?this.nextTick(e):e())};for(let o of this[Br])o.close(i);n=!1,this[Br].clear()}_close(e){this.nextTick(e)}get(e,r,n){if(n=Tr(r,n),n=rr(n,W),r=nr(r,this[Pr].entry),this[X]==="opening")return this.defer(()=>this.get(e,r,n)),n[W];if(xn(this,n))return n[W];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[W];let o=this.keyEncoding(r.keyEncoding),s=this.valueEncoding(r.valueEncoding),a=o.format,c=s.format;return(r.keyEncoding!==a||r.valueEncoding!==c)&&(r=Object.assign({},r,{keyEncoding:a,valueEncoding:c})),this._get(this.prefixKey(o.encode(e),a),r,(f,u)=>{if(f)return(f.code==="LEVEL_NOT_FOUND"||f.notFound||/NotFound/i.test(f))&&(f.code||(f.code="LEVEL_NOT_FOUND"),f.notFound||(f.notFound=!0),f.status||(f.status=404)),n(f);try{u=s.decode(u)}catch(l){return n(new ze("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:l}))}n(null,u)}),n[W]}_get(e,r,n){this.nextTick(n,new Error("NotFound"))}getMany(e,r,n){if(n=Tr(r,n),n=rr(n,W),r=nr(r,this[Pr].entry),this[X]==="opening")return this.defer(()=>this.getMany(e,r,n)),n[W];if(xn(this,n))return n[W];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[W];if(e.length===0)return this.nextTick(n,null,[]),n[W];let i=this.keyEncoding(r.keyEncoding),o=this.valueEncoding(r.valueEncoding),s=i.format,a=o.format;(r.keyEncoding!==s||r.valueEncoding!==a)&&(r=Object.assign({},r,{keyEncoding:s,valueEncoding:a}));let c=new Array(e.length);for(let f=0;f<e.length;f++){let u=e[f],l=this._checkKey(u);if(l)return this.nextTick(n,l),n[W];c[f]=this.prefixKey(i.encode(u),s)}return this._getMany(c,r,(f,u)=>{if(f)return n(f);try{for(let l=0;l<u.length;l++)u[l]!==void 0&&(u[l]=o.decode(u[l]))}catch(l){return n(new ze(`Could not decode one or more of ${u.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:l}))}n(null,u)}),n[W]}_getMany(e,r,n){this.nextTick(n,null,new Array(e.length).fill(void 0))}put(e,r,n,i){if(i=Tr(n,i),i=rr(i,W),n=nr(n,this[Pr].entry),this[X]==="opening")return this.defer(()=>this.put(e,r,n,i)),i[W];if(xn(this,i))return i[W];let o=this._checkKey(e)||this._checkValue(r);if(o)return this.nextTick(i,o),i[W];let s=this.keyEncoding(n.keyEncoding),a=this.valueEncoding(n.valueEncoding),c=s.format,f=a.format;(n.keyEncoding!==c||n.valueEncoding!==f)&&(n=Object.assign({},n,{keyEncoding:c,valueEncoding:f}));let u=this.prefixKey(s.encode(e),c),l=a.encode(r);return this._put(u,l,n,p=>{if(p)return i(p);this.emit("put",e,r),i()}),i[W]}_put(e,r,n,i){this.nextTick(i)}del(e,r,n){if(n=Tr(r,n),n=rr(n,W),r=nr(r,this[Pr].key),this[X]==="opening")return this.defer(()=>this.del(e,r,n)),n[W];if(xn(this,n))return n[W];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[W];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,a=>{if(a)return n(a);this.emit("del",e),n()}),n[W]}_del(e,r,n){this.nextTick(n)}batch(e,r,n){if(!arguments.length){if(this[X]==="opening")return new ul(this);if(this[X]!=="open")throw new ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof e=="function"?n=e:n=Tr(r,n),n=rr(n,W),r=nr(r,this[Pr].empty),this[X]==="opening")return this.defer(()=>this.batch(e,r,n)),n[W];if(xn(this,n))return n[W];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[W];if(e.length===0)return this.nextTick(n),n[W];let i=new Array(e.length),{keyEncoding:o,valueEncoding:s,...a}=r;for(let c=0;c<e.length;c++){if(typeof e[c]!="object"||e[c]===null)return this.nextTick(n,new TypeError("A batch operation must be an object")),n[W];let f=Object.assign({},e[c]);if(f.type!=="put"&&f.type!=="del")return this.nextTick(n,new TypeError("A batch operation must have a type property that is 'put' or 'del'")),n[W];let u=this._checkKey(f.key);if(u)return this.nextTick(n,u),n[W];let l=f.sublevel!=null?f.sublevel:this,p=l.keyEncoding(f.keyEncoding||o),y=p.format;if(f.key=l.prefixKey(p.encode(f.key),y),f.keyEncoding=y,f.type==="put"){let d=this._checkValue(f.value);if(d)return this.nextTick(n,d),n[W];let h=l.valueEncoding(f.valueEncoding||s);f.value=h.encode(f.value),f.valueEncoding=h.format}l!==this&&(f.sublevel=null),i[c]=f}return this._batch(i,a,c=>{if(c)return n(c);this.emit("batch",e),n()}),n[W]}_batch(e,r,n){this.nextTick(n)}sublevel(e,r){return this._sublevel(e,ma.defaults(r))}_sublevel(e,r){return new ma(this,e,r)}prefixKey(e,r){return e}clear(e,r){if(r=Tr(e,r),r=rr(r,W),e=nr(e,this[Pr].empty),this[X]==="opening")return this.defer(()=>this.clear(e,r)),r[W];if(xn(this,r))return r[W];let n=e,i=this.keyEncoding(e.keyEncoding);return e=fo(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[W]}_clear(e,r){this.nextTick(r)}iterator(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=fo(e,r),e.keys=e.keys!==!1,e.values=e.values!==!1,e[Sr.keyEncoding]=r,e[Sr.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[X]==="opening")return new xw(this,e);if(this[X]!=="open")throw new ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(e)}_iterator(e){return new Sr(this,e)}keys(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=fo(e,r),e[Sr.keyEncoding]=r,e[Sr.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[X]==="opening")return new Ew(this,e);if(this[X]!=="open")throw new ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(e)}_keys(e){return new bw(this,e)}values(e){let r=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=fo(e,r),e[Sr.keyEncoding]=r,e[Sr.valueEncoding]=n,e.keyEncoding=r.format,e.valueEncoding=n.format,this[X]==="opening")return new _w(this,e);if(this[X]!=="open")throw new ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(e)}_values(e){return new gw(this,e)}defer(e){if(typeof e!="function")throw new TypeError("The first argument must be a function");this[si].push(e)}[ai](){if(this[si].length===0)return;let e=this[si];this[si]=[];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[Br].add(e)}detachResource(e){this[Br].delete(e)}_chainedBatch(){return new ul(this)}_checkKey(e){if(e==null)return new ze("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(e){if(e==null)return new ze("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};ci.prototype.nextTick=il();var{AbstractSublevel:ma}=fl()({AbstractLevel:ci});ba.AbstractLevel=ci;ba.AbstractSublevel=ma;var xn=function(t,e){return t[X]!=="open"?(t.nextTick(e,new ze("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},Aw=function(t){return Object.keys(t.supports.encodings).filter(e=>!!t.supports.encodings[e])}});var xa=D(kr=>{"use strict";kr.AbstractLevel=ga().AbstractLevel;kr.AbstractSublevel=ga().AbstractSublevel;kr.AbstractIterator=er().AbstractIterator;kr.AbstractKeyIterator=er().AbstractKeyIterator;kr.AbstractValueIterator=er().AbstractValueIterator;kr.AbstractChainedBatch=aa().AbstractChainedBatch});var hl=D((D_,dl)=>{dl.exports=Tw;var Sw=fa();function Tw(t,e,r){if(typeof e!="number")throw new Error("second argument must be a Number");let n,i,o,s,a,c=!0,f;Array.isArray(t)?(n=[],o=i=t.length):(s=Object.keys(t),n={},o=i=s.length);function u(p){function y(){r&&r(p,n),r=null}c?Sw(y):y()}function l(p,y,d){if(n[p]=d,y&&(a=!0),--o===0||y)u(y);else if(!a&&f<i){let h;s?(h=s[f],f+=1,t[h](function(m,g){l(h,m,g)})):(h=f,f+=1,t[h](function(m,g){l(h,m,g)}))}}f=e,o?s?s.some(function(p,y){return t[p](function(d,h){l(p,d,h)}),y===e-1}):t.some(function(p,y){return p(function(d,h){l(y,d,h)}),y===e-1}):u(null),c=!1}});var Ea=D((M_,pl)=>{"use strict";pl.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 _a=D((q_,yl)=>{"use strict";var Bw=new TextEncoder;yl.exports=function(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):Bw.encode(t)}});var xl=D(gl=>{"use strict";var{AbstractIterator:Pw}=xa(),wl=Ea(),ho=_a(),ut=Symbol("cache"),Bt=Symbol("finished"),Ce=Symbol("options"),Pt=Symbol("currentOptions"),Ir=Symbol("position"),va=Symbol("location"),En=Symbol("first"),ml={},Aa=class extends Pw{constructor(e,r,n){super(e,n),this[ut]=[],this[Bt]=this.limit===0,this[Ce]=n,this[Pt]={...n},this[Ir]=void 0,this[va]=r,this[En]=!0}_nextv(e,r,n){if(this[En]=!1,this[Bt])return this.nextTick(n,null,[]);if(this[ut].length>0)return e=Math.min(e,this[ut].length),this.nextTick(n,null,this[ut].splice(0,e));this[Ir]!==void 0&&(this[Ce].reverse?(this[Pt].lt=this[Ir],this[Pt].lte=void 0):(this[Pt].gt=this[Ir],this[Pt].gte=void 0));let i;try{i=wl(this[Pt])}catch{return this[Bt]=!0,this.nextTick(n,null,[])}let o=this.db.db.transaction([this[va]],"readonly"),s=o.objectStore(this[va]),a=[];if(this[Ce].reverse){let c=!this[Ce].values&&s.openKeyCursor?"openKeyCursor":"openCursor";s[c](i,"prev").onsuccess=f=>{let u=f.target.result;if(u){let{key:l,value:p}=u;this[Ir]=l,a.push([this[Ce].keys&&l!==void 0?ho(l):void 0,this[Ce].values&&p!==void 0?ho(p):void 0]),a.length<e?u.continue():bl(o)}else this[Bt]=!0}}else{let c,f,u=()=>{if(c===void 0||f===void 0)return;let l=Math.max(c.length,f.length);l===0||e===1/0?this[Bt]=!0:this[Ir]=c[l-1],a.length=l;for(let p=0;p<l;p++){let y=c[p],d=f[p];a[p]=[this[Ce].keys&&y!==void 0?ho(y):void 0,this[Ce].values&&d!==void 0?ho(d):void 0]}bl(o)};this[Ce].keys||e<1/0?s.getAllKeys(i,e<1/0?e:void 0).onsuccess=l=>{c=l.target.result,u()}:(c=[],this.nextTick(u)),this[Ce].values?s.getAll(i,e<1/0?e:void 0).onsuccess=l=>{f=l.target.result,u()}:(f=[],this.nextTick(u))}o.onabort=()=>{n(o.error||new Error("aborted by user")),n=null},o.oncomplete=()=>{n(null,a),n=null}}_next(e){if(this[ut].length>0){let[r,n]=this[ut].shift();this.nextTick(e,null,r,n)}else if(this[Bt])this.nextTick(e);else{let r=Math.min(100,this.limit-this.count);this[En]&&(this[En]=!1,r=1),this._nextv(r,ml,(n,i)=>{if(n)return e(n);this[ut]=i,this._next(e)})}}_all(e,r){this[En]=!1;let n=this[ut].splice(0,this[ut].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(r,null,n);this._nextv(i,ml,(o,s)=>{if(o)return r(o);n.length>0&&(s=n.concat(s)),r(null,s)})}_seek(e,r){this[En]=!0,this[ut]=[],this[Bt]=!1,this[Ir]=void 0,this[Pt]={...this[Ce]};let n;try{n=wl(this[Ce])}catch{this[Bt]=!0;return}n!==null&&!n.includes(e)?this[Bt]=!0:this[Ce].reverse?this[Pt].lte=e:this[Pt].gte=e}};gl.Iterator=Aa;function bl(t){typeof t.commit=="function"&&t.commit()}});var _l=D((F_,El)=>{"use strict";El.exports=function(e,r,n,i,o){if(i.limit===0)return e.nextTick(o);let s=e.db.transaction([r],"readwrite"),a=s.objectStore(r),c=0;s.oncomplete=function(){o()},s.onabort=function(){o(s.error||new Error("aborted by user"))};let f=a.openKeyCursor?"openKeyCursor":"openCursor",u=i.reverse?"prev":"next";a[f](n,u).onsuccess=function(l){let p=l.target.result;p&&(a.delete(p.key).onsuccess=function(){(i.limit<=0||++c<i.limit)&&p.continue()})}}});var Pl=D(Bl=>{"use strict";var{AbstractLevel:kw}=xa(),vl=Je(),Iw=hl(),{fromCallback:Rw}=zn(),{Iterator:Uw}=xl(),Al=_a(),Cw=_l(),Lw=Ea(),Tl="level-js-",fi=Symbol("idb"),Sa=Symbol("namePrefix"),kt=Symbol("location"),Ta=Symbol("version"),Rr=Symbol("store"),ui=Symbol("onComplete"),Sl=Symbol("promise"),po=class extends kw{constructor(e,r,n){if(typeof r=="function"||typeof n=="function")throw new vl("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[kt]=e,this[Sa]=i??Tl,this[Ta]=parseInt(o||1,10),this[fi]=null}get location(){return this[kt]}get namePrefix(){return this[Sa]}get version(){return this[Ta]}get db(){return this[fi]}get type(){return"browser-level"}_open(e,r){let n=indexedDB.open(this[Sa]+this[kt],this[Ta]);n.onerror=function(){r(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[fi]=n.result,r()},n.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[kt])||o.createObjectStore(this[kt])}}[Rr](e){return this[fi].transaction([this[kt]],e).objectStore(this[kt])}[ui](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[Rr]("readonly"),o;try{o=i.get(e)}catch(s){return this.nextTick(n,s)}this[ui](o,function(s,a){if(s)return n(s);if(a===void 0)return n(new vl("Entry not found",{code:"LEVEL_NOT_FOUND"}));n(null,Al(a))})}_getMany(e,r,n){let i=this[Rr]("readonly"),o=e.map(s=>a=>{let c;try{c=i.get(s)}catch(f){return a(f)}c.onsuccess=()=>{let f=c.result;a(null,f===void 0?f:Al(f))},c.onerror=f=>{f.stopPropagation(),a(c.error)}});Iw(o,16,n)}_del(e,r,n){let i=this[Rr]("readwrite"),o;try{o=i.delete(e)}catch(s){return this.nextTick(n,s)}this[ui](o,n)}_put(e,r,n,i){let o=this[Rr]("readwrite"),s;try{s=o.put(r,e)}catch(a){return this.nextTick(i,a)}this[ui](s,i)}_iterator(e){return new Uw(this,this[kt],e)}_batch(e,r,n){let i=this[Rr]("readwrite"),o=i.transaction,s=0,a;o.onabort=function(){n(a||o.error||new Error("aborted by user"))},o.oncomplete=function(){n()};function c(){let f=e[s++],u=f.key,l;try{l=f.type==="del"?i.delete(u):i.put(f.value,u)}catch(p){a=p,o.abort();return}s<e.length?l.onsuccess=c:typeof o.commit=="function"&&o.commit()}c()}_clear(e,r){let n,i;try{n=Lw(e)}catch{return this.nextTick(r)}if(e.limit>=0)return Cw(this,this[kt],n,e,r);try{let o=this[Rr]("readwrite");i=n?o.delete(n):o.clear()}catch(o){return this.nextTick(r,o)}this[ui](i,r)}_close(e){this[fi].close(),this.nextTick(e)}};po.destroy=function(t,e,r){typeof e=="function"&&(r=e,e=Tl),r=Rw(r,Sl);let n=indexedDB.deleteDatabase(e+t);return n.onsuccess=function(){r()},n.onerror=function(i){r(i)},r[Sl]};Bl.BrowserLevel=po});var Il=D(kl=>{kl.Level=Pl().BrowserLevel});var le=D((W_,Rl)=>{"use strict";Rl.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 lt=D((z_,Pa)=>{"use strict";var Kw=De(),Nw=Object.getPrototypeOf(async function(){}).constructor,Ul=globalThis.Blob||Kw.Blob,Dw=typeof Ul<"u"?function(e){return e instanceof Ul}:function(e){return!1},Ba=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<e.length;n++)r+=` ${e[n].stack}
`;super(r),this.name="AggregateError",this.errors=e}};Pa.exports={AggregateError:Ba,kEmptyObject:Object.freeze({}),once(t){let e=!1;return function(...r){e||(e=!0,t.apply(this,r))}},createDeferredPromise:function(){let t,e;return{promise:new Promise((n,i)=>{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 Nw},isArrayBufferView(t){return ArrayBuffer.isView(t)}},isBlob:Dw};Pa.exports.promisify.custom=Symbol.for("nodejs.util.promisify.custom")});var mo=D((Y_,wo)=>{"use strict";var{AbortController:Cl,AbortSignal:Mw}=typeof self<"u"?self:typeof window<"u"?window:void 0;wo.exports=Cl;wo.exports.AbortSignal=Mw;wo.exports.default=Cl});var ve=D((Z_,Kl)=>{"use strict";var{format:qw,inspect:bo,AggregateError:jw}=lt(),Fw=globalThis.AggregateError||jw,$w=Symbol("kIsNodeError"),Vw=["string","function","number","object","Function","Object","boolean","bigint","symbol"],Hw=/^([A-Z][a-z0-9]*)+$/,Gw="__node_internal_",go={};function Cr(t,e){if(!t)throw new go.ERR_INTERNAL_ASSERTION(e)}function Ll(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 Jw(t,e,r){if(typeof e=="function")return Cr(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 Cr(n===r.length,`Code: ${t}; The provided arguments length (${r.length}) does not match the required ones (${n}).`),r.length===0?e:qw(e,...r)}function be(t,e,r){r||(r=Error);class n extends r{constructor(...o){super(Jw(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[$w]=!0,go[t]=n}function Ol(t){let e=Gw+t.name;return Object.defineProperty(t,"name",{value:e}),t}function Ww(t,e){if(t&&e&&t!==e){if(Array.isArray(e.errors))return e.errors.push(t),e;let r=new Fw([e,t],e.message);return r.code=e.code,r}return t||e}var ka=class extends Error{constructor(e="The operation was aborted",r=void 0){if(r!==void 0&&typeof r!="object")throw new go.ERR_INVALID_ARG_TYPE("options","Object",r);super(e,r),this.code="ABORT_ERR",this.name="AbortError"}};be("ERR_ASSERTION","%s",Error);be("ERR_INVALID_ARG_TYPE",(t,e,r)=>{Cr(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 c of e)Cr(typeof c=="string","All expected entries have to be of type string"),Vw.includes(c)?i.push(c.toLowerCase()):Hw.test(c)?o.push(c):(Cr(c!=="object",'The value "object" should be written as "Object"'),s.push(c));if(o.length>0){let c=i.indexOf("object");c!==-1&&(i.splice(i,c,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 c=i.pop();n+=`one of type ${i.join(", ")}, or ${c}`}}(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 c=o.pop();n+=`an instance of ${o.join(", ")}, or ${c}`}}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 c=s.pop();n+=`one of ${s.join(", ")}, or ${c}`}}if(r==null)n+=`. Received ${r}`;else if(typeof r=="function"&&r.name)n+=`. Received function ${r.name}`;else if(typeof r=="object"){var a;if((a=r.constructor)!==null&&a!==void 0&&a.name)n+=`. Received an instance of ${r.constructor.name}`;else{let c=bo(r,{depth:-1});n+=`. Received ${c}`}}else{let c=bo(r,{colors:!1});c.length>25&&(c=`${c.slice(0,25)}...`),n+=`. Received type ${typeof r} (${c})`}return n},TypeError);be("ERR_INVALID_ARG_VALUE",(t,e,r="is invalid")=>{let n=bo(e);return n.length>128&&(n=n.slice(0,128)+"..."),`The ${t.includes(".")?"property":"argument"} '${t}' ${r}. Received ${n}`},TypeError);be("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);be("ERR_MISSING_ARGS",(...t)=>{Cr(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);be("ERR_OUT_OF_RANGE",(t,e,r)=>{Cr(e,'Missing "range" argument');let n;return Number.isInteger(r)&&Math.abs(r)>2**32?n=Ll(String(r)):typeof r=="bigint"?(n=String(r),(r>2n**32n||r<-(2n**32n))&&(n=Ll(n)),n+="n"):n=bo(r),`The value of "${t}" is out of range. It must be ${e}. Received ${n}`},RangeError);be("ERR_MULTIPLE_CALLBACK","Callback called multiple times",Error);be("ERR_METHOD_NOT_IMPLEMENTED","The %s method is not implemented",Error);be("ERR_STREAM_ALREADY_FINISHED","Cannot call %s after a stream was finished",Error);be("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable",Error);be("ERR_STREAM_DESTROYED","Cannot call %s after a stream was destroyed",Error);be("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);be("ERR_STREAM_PREMATURE_CLOSE","Premature close",Error);be("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF",Error);be("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event",Error);be("ERR_STREAM_WRITE_AFTER_END","write after end",Error);be("ERR_UNKNOWN_ENCODING","Unknown encoding: %s",TypeError);Kl.exports={AbortError:ka,aggregateTwoErrors:Ol(Ww),hideStackFrames:Ol,codes:go}});var li=D((X_,Hl)=>{"use strict";var{ArrayIsArray:Ra,ArrayPrototypeIncludes:ql,ArrayPrototypeJoin:jl,ArrayPrototypeMap:zw,NumberIsInteger:Ua,NumberIsNaN:Yw,NumberMAX_SAFE_INTEGER:Zw,NumberMIN_SAFE_INTEGER:Xw,NumberParseInt:Qw,ObjectPrototypeHasOwnProperty:em,RegExpPrototypeExec:Fl,String:tm,StringPrototypeToUpperCase:rm,StringPrototypeTrim:nm}=le(),{hideStackFrames:je,codes:{ERR_SOCKET_BAD_PORT:im,ERR_INVALID_ARG_TYPE:Ae,ERR_INVALID_ARG_VALUE:_n,ERR_OUT_OF_RANGE:Lr,ERR_UNKNOWN_SIGNAL:Nl}}=ve(),{normalizeEncoding:om}=lt(),{isAsyncFunction:sm,isArrayBufferView:am}=lt().types,Dl={};function cm(t){return t===(t|0)}function fm(t){return t===t>>>0}var um=/^[0-7]+$/,lm="must be a 32-bit unsigned integer or an octal string";function dm(t,e,r){if(typeof t>"u"&&(t=r),typeof t=="string"){if(Fl(um,t)===null)throw new _n(e,t,lm);t=Qw(t,8)}return $l(t,e),t}var hm=je((t,e,r=Xw,n=Zw)=>{if(typeof t!="number")throw new Ae(e,"number",t);if(!Ua(t))throw new Lr(e,"an integer",t);if(t<r||t>n)throw new Lr(e,`>= ${r} && <= ${n}`,t)}),pm=je((t,e,r=-2147483648,n=2147483647)=>{if(typeof t!="number")throw new Ae(e,"number",t);if(!Ua(t))throw new Lr(e,"an integer",t);if(t<r||t>n)throw new Lr(e,`>= ${r} && <= ${n}`,t)}),$l=je((t,e,r=!1)=>{if(typeof t!="number")throw new Ae(e,"number",t);if(!Ua(t))throw new Lr(e,"an integer",t);let n=r?1:0,i=4294967295;if(t<n||t>i)throw new Lr(e,`>= ${n} && <= ${i}`,t)});function Ca(t,e){if(typeof t!="string")throw new Ae(e,"string",t)}function ym(t,e,r=void 0,n){if(typeof t!="number")throw new Ae(e,"number",t);if(r!=null&&t<r||n!=null&&t>n||(r!=null||n!=null)&&Yw(t))throw new Lr(e,`${r!=null?`>= ${r}`:""}${r!=null&&n!=null?" && ":""}${n!=null?`<= ${n}`:""}`,t)}var wm=je((t,e,r)=>{if(!ql(r,t)){let i="must be one of: "+jl(zw(r,o=>typeof o=="string"?`'${o}'`:tm(o)),", ");throw new _n(e,t,i)}});function Vl(t,e){if(typeof t!="boolean")throw new Ae(e,"boolean",t)}function Ia(t,e,r){return t==null||!em(t,e)?r:t[e]}var mm=je((t,e,r=null)=>{let n=Ia(r,"allowArray",!1),i=Ia(r,"allowFunction",!1);if(!Ia(r,"nullable",!1)&&t===null||!n&&Ra(t)||typeof t!="object"&&(!i||typeof t!="function"))throw new Ae(e,"Object",t)}),bm=je((t,e)=>{if(t!=null&&typeof t!="object"&&typeof t!="function")throw new Ae(e,"a dictionary",t)}),La=je((t,e,r=0)=>{if(!Ra(t))throw new Ae(e,"Array",t);if(t.length<r){let n=`must be longer than ${r}`;throw new _n(e,t,n)}});function gm(t,e){La(t,e);for(let r=0;r<t.length;r++)Ca(t[r],`${e}[${r}]`)}function xm(t,e){La(t,e);for(let r=0;r<t.length;r++)Vl(t[r],`${e}[${r}]`)}function Em(t,e="signal"){if(Ca(t,e),Dl[t]===void 0)throw Dl[rm(t)]!==void 0?new Nl(t+" (signals must use all capital letters)"):new Nl(t)}var _m=je((t,e="buffer")=>{if(!am(t))throw new Ae(e,["Buffer","TypedArray","DataView"],t)});function vm(t,e){let r=om(e),n=t.length;if(r==="hex"&&n%2!==0)throw new _n("encoding",e,`is invalid for data of length ${n}`)}function Am(t,e="Port",r=!0){if(typeof t!="number"&&typeof t!="string"||typeof t=="string"&&nm(t).length===0||+t!==+t>>>0||t>65535||t===0&&!r)throw new im(e,t,r);return t|0}var Sm=je((t,e)=>{if(t!==void 0&&(t===null||typeof t!="object"||!("aborted"in t)))throw new Ae(e,"AbortSignal",t)}),Tm=je((t,e)=>{if(typeof t!="function")throw new Ae(e,"Function",t)}),Bm=je((t,e)=>{if(typeof t!="function"||sm(t))throw new Ae(e,"Function",t)}),Pm=je((t,e)=>{if(t!==void 0)throw new Ae(e,"undefined",t)});function km(t,e,r){if(!ql(r,t))throw new Ae(e,`('${jl(r,"|")}')`,t)}var Im=/^(?:<[^>]*>)(?:\s*;\s*[^;"\s]+(?:=(")?[^;"\s]*\1)?)*$/;function Ml(t,e){if(typeof t>"u"||!Fl(Im,t))throw new _n(e,t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}function Rm(t){if(typeof t=="string")return Ml(t,"hints"),t;if(Ra(t)){let e=t.length,r="";if(e===0)return r;for(let n=0;n<e;n++){let i=t[n];Ml(i,"hints"),r+=i,n!==e-1&&(r+=", ")}return r}throw new _n("hints",t,'must be an array or string of format "</styles.css>; rel=preload; as=style"')}Hl.exports={isInt32:cm,isUint32:fm,parseFileMode:dm,validateArray:La,validateStringArray:gm,validateBooleanArray:xm,validateBoolean:Vl,validateBuffer:_m,validateDictionary:bm,validateEncoding:vm,validateFunction:Tm,validateInt32:pm,validateInteger:hm,validateNumber:ym,validateObject:mm,validateOneOf:wm,validatePlainFunction:Bm,validatePort:Am,validateSignalName:Em,validateString:Ca,validateUint32:$l,validateUndefined:Pm,validateUnion:km,validateAbortSignal:Sm,validateLinkHeaderValue:Rm}});var ir=D((Q_,zl)=>{var ce=zl.exports={},dt,ht;function Oa(){throw new Error("setTimeout has not been defined")}function Ka(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?dt=setTimeout:dt=Oa}catch{dt=Oa}try{typeof clearTimeout=="function"?ht=clearTimeout:ht=Ka}catch{ht=Ka}})();function Gl(t){if(dt===setTimeout)return setTimeout(t,0);if((dt===Oa||!dt)&&setTimeout)return dt=setTimeout,setTimeout(t,0);try{return dt(t,0)}catch{try{return dt.call(null,t,0)}catch{return dt.call(this,t,0)}}}function Um(t){if(ht===clearTimeout)return clearTimeout(t);if((ht===Ka||!ht)&&clearTimeout)return ht=clearTimeout,clearTimeout(t);try{return ht(t)}catch{try{return ht.call(null,t)}catch{return ht.call(this,t)}}}var It=[],vn=!1,Or,xo=-1;function Cm(){!vn||!Or||(vn=!1,Or.length?It=Or.concat(It):xo=-1,It.length&&Jl())}function Jl(){if(!vn){var t=Gl(Cm);vn=!0;for(var e=It.length;e;){for(Or=It,It=[];++xo<e;)Or&&Or[xo].run();xo=-1,e=It.length}Or=null,vn=!1,Um(t)}}ce.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];It.push(new Wl(t,e)),It.length===1&&!vn&&Gl(Jl)};function Wl(t,e){this.fun=t,this.array=e}Wl.prototype.run=function(){this.fun.apply(null,this.array)};ce.title="browser";ce.browser=!0;ce.env={};ce.argv=[];ce.version="";ce.versions={};function Rt(){}ce.on=Rt;ce.addListener=Rt;ce.once=Rt;ce.off=Rt;ce.removeListener=Rt;ce.removeAllListeners=Rt;ce.emit=Rt;ce.prependListener=Rt;ce.prependOnceListener=Rt;ce.listeners=function(t){return[]};ce.binding=function(t){throw new Error("process.binding is not supported")};ce.cwd=function(){return"/"};ce.chdir=function(t){throw new Error("process.chdir is not supported")};ce.umask=function(){return 0}});var yt=D((ev,ld)=>{"use strict";var{Symbol:Eo,SymbolAsyncIterator:Yl,SymbolIterator:Zl,SymbolFor:Xl}=le(),Ql=Eo("kDestroyed"),ed=Eo("kIsErrored"),Na=Eo("kIsReadable"),td=Eo("kIsDisturbed"),Lm=Xl("nodejs.webstream.isClosedPromise"),Om=Xl("nodejs.webstream.controllerErrorFunction");function _o(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 vo(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 Km(t){return!!(t&&typeof t.pipe=="function"&&t._readableState&&typeof t.on=="function"&&typeof t.write=="function")}function pt(t){return t&&(t._readableState||t._writableState||typeof t.write=="function"&&typeof t.on=="function"||typeof t.pipe=="function"&&typeof t.on=="function")}function rd(t){return!!(t&&!pt(t)&&typeof t.pipeThrough=="function"&&typeof t.getReader=="function"&&typeof t.cancel=="function")}function nd(t){return!!(t&&!pt(t)&&typeof t.getWriter=="function"&&typeof t.abort=="function")}function id(t){return!!(t&&!pt(t)&&typeof t.readable=="object"&&typeof t.writable=="object")}function Nm(t){return rd(t)||nd(t)||id(t)}function Dm(t,e){return t==null?!1:e===!0?typeof t[Yl]=="function":e===!1?typeof t[Zl]=="function":typeof t[Yl]=="function"||typeof t[Zl]=="function"}function Ao(t){if(!pt(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!!(t.destroyed||t[Ql]||n!=null&&n.destroyed)}function od(t){if(!vo(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 Mm(t,e){if(!vo(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 qm(t){if(!_o(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 sd(t,e){if(!_o(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 ad(t){return t&&t[Na]!=null?t[Na]:typeof t?.readable!="boolean"?null:Ao(t)?!1:_o(t)&&t.readable&&!sd(t)}function cd(t){return typeof t?.writable!="boolean"?null:Ao(t)?!1:vo(t)&&t.writable&&!od(t)}function jm(t,e){return pt(t)?Ao(t)?!0:!(e?.readable!==!1&&ad(t)||e?.writable!==!1&&cd(t)):null}function Fm(t){var e,r;return pt(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 $m(t){var e,r;return pt(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 Vm(t){if(!pt(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"&&fd(t)?t._closed:null}function fd(t){return typeof t._closed=="boolean"&&typeof t._defaultKeepAlive=="boolean"&&typeof t._removedConnection=="boolean"&&typeof t._removedContLen=="boolean"}function ud(t){return typeof t._sent100=="boolean"&&fd(t)}function Hm(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 Gm(t){if(!pt(t))return null;let e=t._writableState,r=t._readableState,n=e||r;return!n&&ud(t)||!!(n&&n.autoDestroy&&n.emitClose&&n.closed===!1)}function Jm(t){var e;return!!(t&&((e=t[td])!==null&&e!==void 0?e:t.readableDidRead||t.readableAborted))}function Wm(t){var e,r,n,i,o,s,a,c,f,u;return!!(t&&((e=(r=(n=(i=(o=(s=t[ed])!==null&&s!==void 0?s:t.readableErrored)!==null&&o!==void 0?o:t.writableErrored)!==null&&i!==void 0?i:(a=t._readableState)===null||a===void 0?void 0:a.errorEmitted)!==null&&n!==void 0?n:(c=t._writableState)===null||c===void 0?void 0:c.errorEmitted)!==null&&r!==void 0?r:(f=t._readableState)===null||f===void 0?void 0:f.errored)!==null&&e!==void 0?e:!((u=t._writableState)===null||u===void 0)&&u.errored))}ld.exports={kDestroyed:Ql,isDisturbed:Jm,kIsDisturbed:td,isErrored:Wm,kIsErrored:ed,isReadable:ad,kIsReadable:Na,kIsClosedPromise:Lm,kControllerErrorFunction:Om,isClosed:Vm,isDestroyed:Ao,isDuplexNodeStream:Km,isFinished:jm,isIterable:Dm,isReadableNodeStream:_o,isReadableStream:rd,isReadableEnded:qm,isReadableFinished:sd,isReadableErrored:$m,isNodeStream:pt,isWebStream:Nm,isWritable:cd,isWritableNodeStream:vo,isWritableStream:nd,isWritableEnded:od,isWritableFinished:Mm,isWritableErrored:Fm,isServerRequest:Hm,isServerResponse:ud,willEmitClose:Gm,isTransformStream:id}});var Ut=D((tv,Fa)=>{var or=ir(),{AbortError:xd,codes:zm}=ve(),{ERR_INVALID_ARG_TYPE:Ym,ERR_STREAM_PREMATURE_CLOSE:dd}=zm,{kEmptyObject:Ma,once:qa}=lt(),{validateAbortSignal:Zm,validateFunction:Xm,validateObject:Qm,validateBoolean:eb}=li(),{Promise:tb,PromisePrototypeThen:rb}=le(),{isClosed:nb,isReadable:hd,isReadableNodeStream:Da,isReadableStream:ib,isReadableFinished:pd,isReadableErrored:yd,isWritable:wd,isWritableNodeStream:md,isWritableStream:ob,isWritableFinished:bd,isWritableErrored:gd,isNodeStream:sb,willEmitClose:ab,kIsClosedPromise:cb}=yt();function fb(t){return t.setHeader&&typeof t.abort=="function"}var ja=()=>{};function Ed(t,e,r){var n,i;if(arguments.length===2?(r=e,e=Ma):e==null?e=Ma:Qm(e,"options"),Xm(r,"callback"),Zm(e.signal,"options.signal"),r=qa(r),ib(t)||ob(t))return ub(t,e,r);if(!sb(t))throw new Ym("stream",["ReadableStream","WritableStream","Stream"],t);let o=(n=e.readable)!==null&&n!==void 0?n:Da(t),s=(i=e.writable)!==null&&i!==void 0?i:md(t),a=t._writableState,c=t._readableState,f=()=>{t.writable||p()},u=ab(t)&&Da(t)===o&&md(t)===s,l=bd(t,!1),p=()=>{l=!0,t.destroyed&&(u=!1),!(u&&(!t.readable||o))&&(!o||y)&&r.call(t)},y=pd(t,!1),d=()=>{y=!0,t.destroyed&&(u=!1),!(u&&(!t.writable||s))&&(!s||l)&&r.call(t)},h=_=>{r.call(t,_)},m=nb(t),g=()=>{m=!0;let _=gd(t)||yd(t);if(_&&typeof _!="boolean")return r.call(t,_);if(o&&!y&&Da(t,!0)&&!pd(t,!1))return r.call(t,new dd);if(s&&!l&&!bd(t,!1))return r.call(t,new dd);r.call(t)},x=()=>{m=!0;let _=gd(t)||yd(t);if(_&&typeof _!="boolean")return r.call(t,_);r.call(t)},w=()=>{t.req.on("finish",p)};fb(t)?(t.on("complete",p),u||t.on("abort",g),t.req?w():t.on("request",w)):s&&!a&&(t.on("end",f),t.on("close",f)),!u&&typeof t.aborted=="boolean"&&t.on("aborted",g),t.on("end",d),t.on("finish",p),e.error!==!1&&t.on("error",h),t.on("close",g),m?or.nextTick(g):a!=null&&a.errorEmitted||c!=null&&c.errorEmitted?u||or.nextTick(x):(!o&&(!u||hd(t))&&(l||wd(t)===!1)||!s&&(!u||wd(t))&&(y||hd(t)===!1)||c&&t.req&&t.aborted)&&or.nextTick(x);let T=()=>{r=ja,t.removeListener("aborted",g),t.removeListener("complete",p),t.removeListener("abort",g),t.removeListener("request",w),t.req&&t.req.removeListener("finish",p),t.removeListener("end",f),t.removeListener("close",f),t.removeListener("finish",p),t.removeListener("end",d),t.removeListener("error",h),t.removeListener("close",g)};if(e.signal&&!m){let _=()=>{let A=r;T(),A.call(t,new xd(void 0,{cause:e.signal.reason}))};if(e.signal.aborted)or.nextTick(_);else{let A=r;r=qa((...I)=>{e.signal.removeEventListener("abort",_),A.apply(t,I)}),e.signal.addEventListener("abort",_)}}return T}function ub(t,e,r){let n=!1,i=ja;if(e.signal)if(i=()=>{n=!0,r.call(t,new xd(void 0,{cause:e.signal.reason}))},e.signal.aborted)or.nextTick(i);else{let s=r;r=qa((...a)=>{e.signal.removeEventListener("abort",i),s.apply(t,a)}),e.signal.addEventListener("abort",i)}let o=(...s)=>{n||or.nextTick(()=>r.apply(t,s))};return rb(t[cb].promise,o,o),ja}function lb(t,e){var r;let n=!1;return e===null&&(e=Ma),(r=e)!==null&&r!==void 0&&r.cleanup&&(eb(e.cleanup,"cleanup"),n=e.cleanup),new tb((i,o)=>{let s=Ed(t,e,a=>{n&&s(),a?o(a):i()})})}Fa.exports=Ed;Fa.exports.finished=lb});var Kr=D((rv,kd)=>{"use strict";var wt=ir(),{aggregateTwoErrors:db,codes:{ERR_MULTIPLE_CALLBACK:hb},AbortError:pb}=ve(),{Symbol:Ad}=le(),{kDestroyed:yb,isDestroyed:wb,isFinished:mb,isServerRequest:bb}=yt(),Sd=Ad("kDestroy"),$a=Ad("kConstruct");function Td(t,e,r){t&&(t.stack,e&&!e.errored&&(e.errored=t),r&&!r.errored&&(r.errored=t))}function gb(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):(Td(t,n,r),n&&(n.destroyed=!0),r&&(r.destroyed=!0),i.constructed?_d(this,t,e):this.once(Sd,function(o){_d(this,db(o,t),e)}),this)}function _d(t,e,r){let n=!1;function i(o){if(n)return;n=!0;let s=t._readableState,a=t._writableState;Td(o,a,s),a&&(a.closed=!0),s&&(s.closed=!0),typeof r=="function"&&r(o),o?wt.nextTick(xb,t,o):wt.nextTick(Bd,t)}try{t._destroy(e||null,i)}catch(o){i(o)}}function xb(t,e){Va(t,e),Bd(t)}function Bd(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 Va(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 Eb(){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 Ha(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?wt.nextTick(Va,t,e):Va(t,e))}function _b(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($a,e),!(t.listenerCount($a)>1)&&wt.nextTick(vb,t)}function vb(t){let e=!1;function r(n){if(e){Ha(t,n??new hb);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(Sd,n):n?Ha(t,n,!0):wt.nextTick(Ab,t)}try{t._construct(n=>{wt.nextTick(r,n)})}catch(n){wt.nextTick(r,n)}}function Ab(t){t.emit($a)}function vd(t){return t?.setHeader&&typeof t.abort=="function"}function Pd(t){t.emit("close")}function Sb(t,e){t.emit("error",e),wt.nextTick(Pd,t)}function Tb(t,e){!t||wb(t)||(!e&&!mb(t)&&(e=new pb),bb(t)?(t.socket=null,t.destroy(e)):vd(t)?t.abort():vd(t.req)?t.req.abort():typeof t.destroy=="function"?t.destroy(e):typeof t.close=="function"?t.close():e?wt.nextTick(Sb,t,e):wt.nextTick(Pd,t),t.destroyed||(t[yb]=!0))}kd.exports={construct:_b,destroyer:Tb,destroy:gb,undestroy:Eb,errorOrDestroy:Ha}});var Bo=D((nv,Rd)=>{"use strict";var{ArrayIsArray:Bb,ObjectSetPrototypeOf:Id}=le(),{EventEmitter:So}=Wn();function To(t){So.call(this,t)}Id(To.prototype,So.prototype);Id(To,So);To.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",a));let o=!1;function s(){o||(o=!0,t.end())}function a(){o||(o=!0,typeof t.destroy=="function"&&t.destroy())}function c(u){f(),So.listenerCount(this,"error")===0&&this.emit("error",u)}Ga(r,"error",c),Ga(t,"error",c);function f(){r.removeListener("data",n),t.removeListener("drain",i),r.removeListener("end",s),r.removeListener("close",a),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("end",f),r.on("close",f),t.on("close",f),t.emit("pipe",r),t};function Ga(t,e,r){if(typeof t.prependListener=="function")return t.prependListener(e,r);!t._events||!t._events[e]?t.on(e,r):Bb(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]}Rd.exports={Stream:To,prependListener:Ga}});var di=D((iv,Po)=>{"use strict";var{AbortError:Ud,codes:Pb}=ve(),{isNodeStream:Cd,isWebStream:kb,kControllerErrorFunction:Ib}=yt(),Rb=Ut(),{ERR_INVALID_ARG_TYPE:Ld}=Pb,Ub=(t,e)=>{if(typeof t!="object"||!("aborted"in t))throw new Ld(e,"AbortSignal",t)};Po.exports.addAbortSignal=function(e,r){if(Ub(e,"signal"),!Cd(r)&&!kb(r))throw new Ld("stream",["ReadableStream","WritableStream","Stream"],r);return Po.exports.addAbortSignalNoValidate(e,r)};Po.exports.addAbortSignalNoValidate=function(t,e){if(typeof t!="object"||!("aborted"in t))return e;let r=Cd(e)?()=>{e.destroy(new Ud(void 0,{cause:t.reason}))}:()=>{e[Ib](new Ud(void 0,{cause:t.reason}))};return t.aborted?r():(t.addEventListener("abort",r),Rb(e,()=>t.removeEventListener("abort",r))),e}});var Nd=D((sv,Kd)=>{"use strict";var{StringPrototypeSlice:Od,SymbolIterator:Cb,TypedArrayPrototypeSet:ko,Uint8Array:Lb}=le(),{Buffer:Ja}=De(),{inspect:Ob}=lt();Kd.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 Ja.alloc(0);let r=Ja.allocUnsafe(e>>>0),n=this.head,i=0;for(;n;)ko(r,n.data,i),i+=n.data.length,n=n.next;return r}consume(e,r){let n=this.head.data;if(e<n.length){let i=n.slice(0,e);return this.head.data=n.slice(e),i}return e===n.length?this.shift():r?this._getString(e):this._getBuffer(e)}first(){return this.head.data}*[Cb](){for(let e=this.head;e;e=e.next)yield e.data}_getString(e){let r="",n=this.head,i=0;do{let o=n.data;if(e>o.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+=Od(o,0,e),this.head=n,n.data=Od(o,e));break}++i}while((n=n.next)!==null);return this.length-=i,r}_getBuffer(e){let r=Ja.allocUnsafe(e),n=e,i=this.head,o=0;do{let s=i.data;if(e>s.length)ko(r,s,n-e),e-=s.length;else{e===s.length?(ko(r,s,n-e),++o,i.next?this.head=i.next:this.head=this.tail=null):(ko(r,new Lb(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 Ob(this,{...r,depth:0,customInspect:!1})}}});var Io=D((av,Md)=>{"use strict";var{MathFloor:Kb,NumberIsInteger:Nb}=le(),{ERR_INVALID_ARG_VALUE:Db}=ve().codes;function Mb(t,e,r){return t.highWaterMark!=null?t.highWaterMark:e?t[r]:null}function Dd(t){return t?16:16*1024}function qb(t,e,r,n){let i=Mb(e,n,r);if(i!=null){if(!Nb(i)||i<0){let o=n?`options.${r}`:"options.highWaterMark";throw new Db(o,i)}return Kb(i)}return Dd(t.objectMode)}Md.exports={getHighWaterMark:qb,getDefaultHighWaterMark:Dd}});var Fd=D((Wa,jd)=>{var Ro=De(),mt=Ro.Buffer;function qd(t,e){for(var r in t)e[r]=t[r]}mt.from&&mt.alloc&&mt.allocUnsafe&&mt.allocUnsafeSlow?jd.exports=Ro:(qd(Ro,Wa),Wa.Buffer=Nr);function Nr(t,e,r){return mt(t,e,r)}Nr.prototype=Object.create(mt.prototype);qd(mt,Nr);Nr.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return mt(t,e,r)};Nr.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=mt(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};Nr.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return mt(t)};Nr.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Ro.SlowBuffer(t)}});var Hd=D(Vd=>{"use strict";var Ya=Fd().Buffer,$d=Ya.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 jb(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 Fb(t){var e=jb(t);if(typeof e!="string"&&(Ya.isEncoding===$d||!$d(t)))throw new Error("Unknown encoding: "+t);return e||t}Vd.StringDecoder=hi;function hi(t){this.encoding=Fb(t);var e;switch(this.encoding){case"utf16le":this.text=Wb,this.end=zb,e=4;break;case"utf8":this.fillLast=Hb,e=4;break;case"base64":this.text=Yb,this.end=Zb,e=3;break;default:this.write=Xb,this.end=Qb;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Ya.allocUnsafe(e)}hi.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<t.length?e?e+this.text(t,r):this.text(t,r):e||""};hi.prototype.end=Jb;hi.prototype.text=Gb;hi.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length};function za(t){return t<=127?0:t>>5===6?2:t>>4===14?3:t>>3===30?4:t>>6===2?-1:-2}function $b(t,e,r){var n=e.length-1;if(n<r)return 0;var i=za(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||i===-2?0:(i=za(e[n]),i>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||i===-2?0:(i=za(e[n]),i>=0?(i>0&&(i===2?i=0:t.lastNeed=i-3),i):0))}function Vb(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 Hb(t){var e=this.lastTotal-this.lastNeed,r=Vb(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 Gb(t,e){var r=$b(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 Jb(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"\uFFFD":e}function Wb(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 zb(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 Yb(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 Zb(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function Xb(t){return t.toString(this.encoding)}function Qb(t){return t&&t.length?this.write(t):""}});var Za=D((fv,zd)=>{"use strict";var Gd=ir(),{PromisePrototypeThen:eg,SymbolAsyncIterator:Jd,SymbolIterator:Wd}=le(),{Buffer:tg}=De(),{ERR_INVALID_ARG_TYPE:rg,ERR_STREAM_NULL_VALUES:ng}=ve().codes;function ig(t,e,r){let n;if(typeof e=="string"||e instanceof tg)return new t({objectMode:!0,...r,read(){this.push(e),this.push(null)}});let i;if(e&&e[Jd])i=!0,n=e[Jd]();else if(e&&e[Wd])i=!1,n=e[Wd]();else throw new rg("iterable",["Iterable"],e);let o=new t({objectMode:!0,highWaterMark:1,...r}),s=!1;o._read=function(){s||(s=!0,c())},o._destroy=function(f,u){eg(a(f),()=>Gd.nextTick(u,f),l=>Gd.nextTick(u,l||f))};async function a(f){let u=f!=null,l=typeof n.throw=="function";if(u&&l){let{value:p,done:y}=await n.throw(f);if(await p,y)return}if(typeof n.return=="function"){let{value:p}=await n.return();await p}}async function c(){for(;;){try{let{value:f,done:u}=i?await n.next():n.next();if(u)o.push(null);else{let l=f&&typeof f.then=="function"?await f:f;if(l===null)throw s=!1,new ng;if(o.push(l))continue;s=!1}}catch(f){o.destroy(f)}break}}return o}zd.exports=ig});var pi=D((uv,ch)=>{var Ye=ir(),{ArrayPrototypeIndexOf:og,NumberIsInteger:sg,NumberIsNaN:ag,NumberParseInt:cg,ObjectDefineProperties:Xd,ObjectKeys:fg,ObjectSetPrototypeOf:Qd,Promise:ug,SafeSet:lg,SymbolAsyncIterator:dg,Symbol:hg}=le();ch.exports=Z;Z.ReadableState=nc;var{EventEmitter:pg}=Wn(),{Stream:sr,prependListener:yg}=Bo(),{Buffer:Xa}=De(),{addAbortSignal:wg}=di(),mg=Ut(),Q=lt().debuglog("stream",t=>{Q=t}),bg=Nd(),Sn=Kr(),{getHighWaterMark:gg,getDefaultHighWaterMark:xg}=Io(),{aggregateTwoErrors:Yd,codes:{ERR_INVALID_ARG_TYPE:Eg,ERR_METHOD_NOT_IMPLEMENTED:_g,ERR_OUT_OF_RANGE:vg,ERR_STREAM_PUSH_AFTER_EOF:Ag,ERR_STREAM_UNSHIFT_AFTER_END_EVENT:Sg}}=ve(),{validateObject:Tg}=li(),Dr=hg("kPaused"),{StringDecoder:eh}=Hd(),Bg=Za();Qd(Z.prototype,sr.prototype);Qd(Z,sr);var Qa=()=>{},{errorOrDestroy:An}=Sn;function nc(t,e,r){typeof r!="boolean"&&(r=e instanceof bt()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.readableObjectMode)),this.highWaterMark=t?gg(this,t,"readableHighWaterMark",r):xg(!1),this.buffer=new bg,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[Dr]=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 eh(t.encoding),this.encoding=t.encoding)}function Z(t){if(!(this instanceof Z))return new Z(t);let e=this instanceof bt();this._readableState=new nc(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&&wg(t.signal,this)),sr.call(this,t),Sn.construct(this,()=>{this._readableState.needReadable&&Uo(this,this._readableState)})}Z.prototype.destroy=Sn.destroy;Z.prototype._undestroy=Sn.undestroy;Z.prototype._destroy=function(t,e){e(t)};Z.prototype[pg.captureRejectionSymbol]=function(t){this.destroy(t)};Z.prototype.push=function(t,e){return th(this,t,e,!1)};Z.prototype.unshift=function(t,e){return th(this,t,e,!0)};function th(t,e,r,n){Q("readableAddChunk",e);let i=t._readableState,o;if(i.objectMode||(typeof e=="string"?(r=r||i.defaultEncoding,i.encoding!==r&&(n&&i.encoding?e=Xa.from(e,r).toString(i.encoding):(e=Xa.from(e,r),r=""))):e instanceof Xa?r="":sr._isUint8Array(e)?(e=sr._uint8ArrayToBuffer(e),r=""):e!=null&&(o=new Eg("chunk",["string","Buffer","Uint8Array"],e))),o)An(t,o);else if(e===null)i.reading=!1,Ig(t,i);else if(i.objectMode||e&&e.length>0)if(n)if(i.endEmitted)An(t,new Sg);else{if(i.destroyed||i.errored)return!1;ec(t,i,e,!0)}else if(i.ended)An(t,new Ag);else{if(i.destroyed||i.errored)return!1;i.reading=!1,i.decoder&&!r?(e=i.decoder.write(e),i.objectMode||e.length!==0?ec(t,i,e,!1):Uo(t,i)):ec(t,i,e,!1)}else n||(i.reading=!1,Uo(t,i));return!i.ended&&(i.length<i.highWaterMark||i.length===0)}function ec(t,e,r,n){e.flowing&&e.length===0&&!e.sync&&t.listenerCount("data")>0?(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&&Co(t)),Uo(t,e)}Z.prototype.isPaused=function(){let t=this._readableState;return t[Dr]===!0||t.flowing===!1};Z.prototype.setEncoding=function(t){let e=new eh(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 Pg=1073741824;function kg(t){if(t>Pg)throw new vg("size","<= 1GiB",t);return t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++,t}function Zd(t,e){return t<=0||e.length===0&&e.ended?0:e.objectMode?1:ag(t)?e.flowing&&e.length?e.buffer.first().length:e.length:t<=e.length?t:e.ended?e.length:0}Z.prototype.read=function(t){Q("read",t),t===void 0?t=NaN:sg(t)||(t=cg(t,10));let e=this._readableState,r=t;if(t>e.highWaterMark&&(e.highWaterMark=kg(t)),t!==0&&(e.emittedReadable=!1),t===0&&e.needReadable&&((e.highWaterMark!==0?e.length>=e.highWaterMark:e.length>0)||e.ended))return Q("read: emitReadable",e.length,e.ended),e.length===0&&e.ended?tc(this):Co(this),null;if(t=Zd(t,e),t===0&&e.ended)return e.length===0&&tc(this),null;let n=e.needReadable;if(Q("need readable",n),(e.length===0||e.length-t<e.highWaterMark)&&(n=!0,Q("length less than watermark",n)),e.ended||e.reading||e.destroyed||e.errored||!e.constructed)n=!1,Q("reading, ended or constructing",n);else if(n){Q("do read"),e.reading=!0,e.sync=!0,e.length===0&&(e.needReadable=!0);try{this._read(e.highWaterMark)}catch(o){An(this,o)}e.sync=!1,e.reading||(t=Zd(r,e))}let i;return t>0?i=sh(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&&tc(this)),i!==null&&!e.errorEmitted&&!e.closeEmitted&&(e.dataEmitted=!0,this.emit("data",i)),i};function Ig(t,e){if(Q("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?Co(t):(e.needReadable=!1,e.emittedReadable=!0,rh(t))}}function Co(t){let e=t._readableState;Q("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(Q("emitReadable",e.flowing),e.emittedReadable=!0,Ye.nextTick(rh,t))}function rh(t){let e=t._readableState;Q("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,ih(t)}function Uo(t,e){!e.readingMore&&e.constructed&&(e.readingMore=!0,Ye.nextTick(Rg,t,e))}function Rg(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&e.length===0);){let r=e.length;if(Q("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}Z.prototype._read=function(t){throw new _g("_read()")};Z.prototype.pipe=function(t,e){let r=this,n=this._readableState;n.pipes.length===1&&(n.multiAwaitDrain||(n.multiAwaitDrain=!0,n.awaitDrainWriters=new lg(n.awaitDrainWriters?[n.awaitDrainWriters]:[]))),n.pipes.push(t),Q("pipe count=%d opts=%j",n.pipes.length,e);let o=(!e||e.end!==!1)&&t!==Ye.stdout&&t!==Ye.stderr?a:m;n.endEmitted?Ye.nextTick(o):r.once("end",o),t.on("unpipe",s);function s(g,x){Q("onunpipe"),g===r&&x&&x.hasUnpiped===!1&&(x.hasUnpiped=!0,u())}function a(){Q("onend"),t.end()}let c,f=!1;function u(){Q("cleanup"),t.removeListener("close",d),t.removeListener("finish",h),c&&t.removeListener("drain",c),t.removeListener("error",y),t.removeListener("unpipe",s),r.removeListener("end",a),r.removeListener("end",m),r.removeListener("data",p),f=!0,c&&n.awaitDrainWriters&&(!t._writableState||t._writableState.needDrain)&&c()}function l(){f||(n.pipes.length===1&&n.pipes[0]===t?(Q("false write response, pause",0),n.awaitDrainWriters=t,n.multiAwaitDrain=!1):n.pipes.length>1&&n.pipes.includes(t)&&(Q("false write response, pause",n.awaitDrainWriters.size),n.awaitDrainWriters.add(t)),r.pause()),c||(c=Ug(r,t),t.on("drain",c))}r.on("data",p);function p(g){Q("ondata");let x=t.write(g);Q("dest.write",x),x===!1&&l()}function y(g){if(Q("onerror",g),m(),t.removeListener("error",y),t.listenerCount("error")===0){let x=t._writableState||t._readableState;x&&!x.errorEmitted?An(t,g):t.emit("error",g)}}yg(t,"error",y);function d(){t.removeListener("finish",h),m()}t.once("close",d);function h(){Q("onfinish"),t.removeListener("close",d),m()}t.once("finish",h);function m(){Q("unpipe"),r.unpipe(t)}return t.emit("pipe",r),t.writableNeedDrain===!0?n.flowing&&l():n.flowing||(Q("pipe resume"),r.resume()),t};function Ug(t,e){return function(){let n=t._readableState;n.awaitDrainWriters===e?(Q("pipeOnDrain",1),n.awaitDrainWriters=null):n.multiAwaitDrain&&(Q("pipeOnDrain",n.awaitDrainWriters.size),n.awaitDrainWriters.delete(e)),(!n.awaitDrainWriters||n.awaitDrainWriters.size===0)&&t.listenerCount("data")&&t.resume()}}Z.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;o<i.length;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}let n=og(e.pipes,t);return n===-1?this:(e.pipes.splice(n,1),e.pipes.length===0&&this.pause(),t.emit("unpipe",this,r),this)};Z.prototype.on=function(t,e){let r=sr.prototype.on.call(this,t,e),n=this._readableState;return t==="data"?(n.readableListening=this.listenerCount("readable")>0,n.flowing!==!1&&this.resume()):t==="readable"&&!n.endEmitted&&!n.readableListening&&(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,Q("on readable",n.length,n.reading),n.length?Co(this):n.reading||Ye.nextTick(Cg,this)),r};Z.prototype.addListener=Z.prototype.on;Z.prototype.removeListener=function(t,e){let r=sr.prototype.removeListener.call(this,t,e);return t==="readable"&&Ye.nextTick(nh,this),r};Z.prototype.off=Z.prototype.removeListener;Z.prototype.removeAllListeners=function(t){let e=sr.prototype.removeAllListeners.apply(this,arguments);return(t==="readable"||t===void 0)&&Ye.nextTick(nh,this),e};function nh(t){let e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&e[Dr]===!1?e.flowing=!0:t.listenerCount("data")>0?t.resume():e.readableListening||(e.flowing=null)}function Cg(t){Q("readable nexttick read 0"),t.read(0)}Z.prototype.resume=function(){let t=this._readableState;return t.flowing||(Q("resume"),t.flowing=!t.readableListening,Lg(this,t)),t[Dr]=!1,this};function Lg(t,e){e.resumeScheduled||(e.resumeScheduled=!0,Ye.nextTick(Og,t,e))}function Og(t,e){Q("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),ih(t),e.flowing&&!e.reading&&t.read(0)}Z.prototype.pause=function(){return Q("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Q("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState[Dr]=!0,this};function ih(t){let e=t._readableState;for(Q("flow",e.flowing);e.flowing&&t.read()!==null;);}Z.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=>{An(this,n)}),t.on("close",()=>{this.destroy()}),t.on("destroy",()=>{this.destroy()}),this._read=()=>{e&&t.resume&&(e=!1,t.resume())};let r=fg(t);for(let n=1;n<r.length;n++){let i=r[n];this[i]===void 0&&typeof t[i]=="function"&&(this[i]=t[i].bind(t))}return this};Z.prototype[dg]=function(){return oh(this)};Z.prototype.iterator=function(t){return t!==void 0&&Tg(t,"options"),oh(this,t)};function oh(t,e){typeof t.read!="function"&&(t=Z.wrap(t,{objectMode:!0}));let r=Kg(t,e);return r.stream=t,r}async function*Kg(t,e){let r=Qa;function n(s){this===t?(r(),r=Qa):r=s}t.on("readable",n);let i,o=mg(t,{writable:!1},s=>{i=s?Yd(i,s):null,r(),r=Qa});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 ug(n)}}}catch(s){throw i=Yd(i,s),i}finally{(i||e?.destroyOnReturn!==!1)&&(i===void 0||t._readableState.autoDestroy)?Sn.destroyer(t,null):(t.off("readable",n),o())}}Xd(Z.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}}});Xd(nc.prototype,{pipesCount:{__proto__:null,get(){return this.pipes.length}},paused:{__proto__:null,get(){return this[Dr]!==!1},set(t){this[Dr]=!!t}}});Z._fromList=sh;function sh(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 tc(t){let e=t._readableState;Q("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,Ye.nextTick(Ng,e,t))}function Ng(t,e){if(Q("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)Ye.nextTick(Dg,e);else if(t.autoDestroy){let r=e._writableState;(!r||r.autoDestroy&&(r.finished||r.writable===!1))&&e.destroy()}}}function Dg(t){t.writable&&!t.writableEnded&&!t.destroyed&&t.end()}Z.from=function(t,e){return Bg(Z,t,e)};var rc;function ah(){return rc===void 0&&(rc={}),rc}Z.fromWeb=function(t,e){return ah().newStreamReadableFromReadableStream(t,e)};Z.toWeb=function(t,e){return ah().newReadableStreamFromStreamReadable(t,e)};Z.wrap=function(t,e){var r,n;return new Z({objectMode:(r=(n=t.readableObjectMode)!==null&&n!==void 0?n:t.objectMode)!==null&&r!==void 0?r:!0,...e,destroy(i,o){Sn.destroyer(t,i),o(i)}}).wrap(t)}});var uc=D((lv,xh)=>{var Mr=ir(),{ArrayPrototypeSlice:lh,Error:Mg,FunctionPrototypeSymbolHasInstance:dh,ObjectDefineProperty:hh,ObjectDefineProperties:qg,ObjectSetPrototypeOf:ph,StringPrototypeToLowerCase:jg,Symbol:Fg,SymbolHasInstance:$g}=le();xh.exports=ae;ae.WritableState=mi;var{EventEmitter:Vg}=Wn(),yi=Bo().Stream,{Buffer:Lo}=De(),No=Kr(),{addAbortSignal:Hg}=di(),{getHighWaterMark:Gg,getDefaultHighWaterMark:Jg}=Io(),{ERR_INVALID_ARG_TYPE:Wg,ERR_METHOD_NOT_IMPLEMENTED:zg,ERR_MULTIPLE_CALLBACK:yh,ERR_STREAM_CANNOT_PIPE:Yg,ERR_STREAM_DESTROYED:wi,ERR_STREAM_ALREADY_FINISHED:Zg,ERR_STREAM_NULL_VALUES:Xg,ERR_STREAM_WRITE_AFTER_END:Qg,ERR_UNKNOWN_ENCODING:wh}=ve().codes,{errorOrDestroy:Tn}=No;ph(ae.prototype,yi.prototype);ph(ae,yi);function sc(){}var Bn=Fg("kOnFinished");function mi(t,e,r){typeof r!="boolean"&&(r=e instanceof bt()),this.objectMode=!!(t&&t.objectMode),r&&(this.objectMode=this.objectMode||!!(t&&t.writableObjectMode)),this.highWaterMark=t?Gg(this,t,"writableHighWaterMark",r):Jg(!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=tx.bind(void 0,e),this.writecb=null,this.writelen=0,this.afterWriteTickInfo=null,Ko(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[Bn]=[]}function Ko(t){t.buffered=[],t.bufferedIndex=0,t.allBuffers=!0,t.allNoop=!0}mi.prototype.getBuffer=function(){return lh(this.buffered,this.bufferedIndex)};hh(mi.prototype,"bufferedRequestCount",{__proto__:null,get(){return this.buffered.length-this.bufferedIndex}});function ae(t){let e=this instanceof bt();if(!e&&!dh(ae,this))return new ae(t);this._writableState=new mi(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&&Hg(t.signal,this)),yi.call(this,t),No.construct(this,()=>{let r=this._writableState;r.writing||cc(this,r),fc(this,r)})}hh(ae,$g,{__proto__:null,value:function(t){return dh(this,t)?!0:this!==ae?!1:t&&t._writableState instanceof mi}});ae.prototype.pipe=function(){Tn(this,new Yg)};function mh(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"&&!Lo.isEncoding(r))throw new wh(r);typeof n!="function"&&(n=sc)}if(e===null)throw new Xg;if(!i.objectMode)if(typeof e=="string")i.decodeStrings!==!1&&(e=Lo.from(e,r),r="buffer");else if(e instanceof Lo)r="buffer";else if(yi._isUint8Array(e))e=yi._uint8ArrayToBuffer(e),r="buffer";else throw new Wg("chunk",["string","Buffer","Uint8Array"],e);let o;return i.ending?o=new Qg:i.destroyed&&(o=new wi("write")),o?(Mr.nextTick(n,o),Tn(t,o,!0),o):(i.pendingcb++,ex(t,i,e,r,n))}ae.prototype.write=function(t,e,r){return mh(this,t,e,r)===!0};ae.prototype.cork=function(){this._writableState.corked++};ae.prototype.uncork=function(){let t=this._writableState;t.corked&&(t.corked--,t.writing||cc(this,t))};ae.prototype.setDefaultEncoding=function(e){if(typeof e=="string"&&(e=jg(e)),!Lo.isEncoding(e))throw new wh(e);return this._writableState.defaultEncoding=e,this};function ex(t,e,r,n,i){let o=e.objectMode?1:r.length;e.length+=o;let s=e.length<e.highWaterMark;return s||(e.needDrain=!0),e.writing||e.corked||e.errored||!e.constructed?(e.buffered.push({chunk:r,encoding:n,callback:i}),e.allBuffers&&n!=="buffer"&&(e.allBuffers=!1),e.allNoop&&i!==sc&&(e.allNoop=!1)):(e.writelen=o,e.writecb=i,e.writing=!0,e.sync=!0,t._write(r,n,e.onwrite),e.sync=!1),s&&!e.errored&&!e.destroyed}function fh(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new wi("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function uh(t,e,r,n){--e.pendingcb,n(r),ac(e),Tn(t,r)}function tx(t,e){let r=t._writableState,n=r.sync,i=r.writecb;if(typeof i!="function"){Tn(t,new yh);return}r.writing=!1,r.writecb=null,r.length-=r.writelen,r.writelen=0,e?(e.stack,r.errored||(r.errored=e),t._readableState&&!t._readableState.errored&&(t._readableState.errored=e),n?Mr.nextTick(uh,t,r,e,i):uh(t,r,e,i)):(r.buffered.length>r.bufferedIndex&&cc(t,r),n?r.afterWriteTickInfo!==null&&r.afterWriteTickInfo.cb===i?r.afterWriteTickInfo.count++:(r.afterWriteTickInfo={count:1,cb:i,stream:t,state:r},Mr.nextTick(rx,r.afterWriteTickInfo)):bh(t,r,1,i))}function rx({stream:t,state:e,count:r,cb:n}){return e.afterWriteTickInfo=null,bh(t,e,r,n)}function bh(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&&ac(e),fc(t,e)}function ac(t){if(t.writing)return;for(let i=t.bufferedIndex;i<t.buffered.length;++i){var e;let{chunk:o,callback:s}=t.buffered[i],a=t.objectMode?1:o.length;t.length-=a,s((e=t.errored)!==null&&e!==void 0?e:new wi("write"))}let r=t[Bn].splice(0);for(let i=0;i<r.length;i++){var n;r[i]((n=t.errored)!==null&&n!==void 0?n:new wi("end"))}Ko(t)}function cc(t,e){if(e.corked||e.bufferProcessing||e.destroyed||!e.constructed)return;let{buffered:r,bufferedIndex:n,objectMode:i}=e,o=r.length-n;if(!o)return;let s=n;if(e.bufferProcessing=!0,o>1&&t._writev){e.pendingcb-=o-1;let a=e.allNoop?sc:f=>{for(let u=s;u<r.length;++u)r[u].callback(f)},c=e.allNoop&&s===0?r:lh(r,s);c.allBuffers=e.allBuffers,fh(t,e,!0,e.length,c,"",a),Ko(e)}else{do{let{chunk:a,encoding:c,callback:f}=r[s];r[s++]=null;let u=i?1:a.length;fh(t,e,!1,u,a,c,f)}while(s<r.length&&!e.writing);s===r.length?Ko(e):s>256?(r.splice(0,s),e.bufferedIndex=0):e.bufferedIndex=s}e.bufferProcessing=!1}ae.prototype._write=function(t,e,r){if(this._writev)this._writev([{chunk:t,encoding:e}],r);else throw new zg("_write()")};ae.prototype._writev=null;ae.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=mh(this,t,e);o instanceof Mg&&(i=o)}return n.corked&&(n.corked=1,this.uncork()),i||(!n.errored&&!n.ending?(n.ending=!0,fc(this,n,!0),n.ended=!0):n.finished?i=new Zg("end"):n.destroyed&&(i=new wi("end"))),typeof r=="function"&&(i||n.finished?Mr.nextTick(r,i):n[Bn].push(r)),this};function Oo(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 nx(t,e){let r=!1;function n(i){if(r){Tn(t,i??yh());return}if(r=!0,e.pendingcb--,i){let o=e[Bn].splice(0);for(let s=0;s<o.length;s++)o[s](i);Tn(t,i,e.sync)}else Oo(e)&&(e.prefinished=!0,t.emit("prefinish"),e.pendingcb++,Mr.nextTick(oc,t,e))}e.sync=!0,e.pendingcb++;try{t._final(n)}catch(i){n(i)}e.sync=!1}function ix(t,e){!e.prefinished&&!e.finalCalled&&(typeof t._final=="function"&&!e.destroyed?(e.finalCalled=!0,nx(t,e)):(e.prefinished=!0,t.emit("prefinish")))}function fc(t,e,r){Oo(e)&&(ix(t,e),e.pendingcb===0&&(r?(e.pendingcb++,Mr.nextTick((n,i)=>{Oo(i)?oc(n,i):i.pendingcb--},t,e)):Oo(e)&&(e.pendingcb++,oc(t,e))))}function oc(t,e){e.pendingcb--,e.finished=!0;let r=e[Bn].splice(0);for(let n=0;n<r.length;n++)r[n]();if(t.emit("finish"),e.autoDestroy){let n=t._readableState;(!n||n.autoDestroy&&(n.endEmitted||n.readable===!1))&&t.destroy()}}qg(ae.prototype,{closed:{__proto__:null,get(){return this._writableState?this._writableState.closed:!1}},destroyed:{__proto__:null,get(){return this._writableState?this._writableState.destroyed:!1},set(t){this._writableState&&(this._writableState.destroyed=t)}},writable:{__proto__:null,get(){let t=this._writableState;return!!t&&t.writable!==!1&&!t.destroyed&&!t.errored&&!t.ending&&!t.ended},set(t){this._writableState&&(this._writableState.writable=!!t)}},writableFinished:{__proto__:null,get(){return this._writableState?this._writableState.finished:!1}},writableObjectMode:{__proto__:null,get(){return this._writableState?this._writableState.objectMode:!1}},writableBuffer:{__proto__:null,get(){return this._writableState&&this._writableState.getBuffer()}},writableEnded:{__proto__:null,get(){return this._writableState?this._writableState.ending:!1}},writableNeedDrain:{__proto__:null,get(){let t=this._writableState;return t?!t.destroyed&&!t.ending&&t.needDrain:!1}},writableHighWaterMark:{__proto__:null,get(){return this._writableState&&this._writableState.highWaterMark}},writableCorked:{__proto__:null,get(){return this._writableState?this._writableState.corked:0}},writableLength:{__proto__:null,get(){return this._writableState&&this._writableState.length}},errored:{__proto__:null,enumerable:!1,get(){return this._writableState?this._writableState.errored:null}},writableAborted:{__proto__:null,enumerable:!1,get:function(){return!!(this._writableState.writable!==!1&&(this._writableState.destroyed||this._writableState.errored)&&!this._writableState.finished)}}});var ox=No.destroy;ae.prototype.destroy=function(t,e){let r=this._writableState;return!r.destroyed&&(r.bufferedIndex<r.buffered.length||r[Bn].length)&&Mr.nextTick(ac,r),ox.call(this,t,e),this};ae.prototype._undestroy=No.undestroy;ae.prototype._destroy=function(t,e){e(t)};ae.prototype[Vg.captureRejectionSymbol]=function(t){this.destroy(t)};var ic;function gh(){return ic===void 0&&(ic={}),ic}ae.fromWeb=function(t,e){return gh().newStreamWritableFromWritableStream(t,e)};ae.toWeb=function(t){return gh().newWritableStreamFromStreamWritable(t)}});var Uh=D((dv,Rh)=>{var lc=ir(),sx=De(),{isReadable:ax,isWritable:cx,isIterable:Eh,isNodeStream:fx,isReadableNodeStream:_h,isWritableNodeStream:vh,isDuplexNodeStream:ux}=yt(),Ah=Ut(),{AbortError:Ih,codes:{ERR_INVALID_ARG_TYPE:lx,ERR_INVALID_RETURN_VALUE:Sh}}=ve(),{destroyer:Pn}=Kr(),dx=bt(),hx=pi(),{createDeferredPromise:Th}=lt(),Bh=Za(),Ph=globalThis.Blob||sx.Blob,px=typeof Ph<"u"?function(e){return e instanceof Ph}:function(e){return!1},yx=globalThis.AbortController||mo().AbortController,{FunctionPrototypeCall:kh}=le(),qr=class extends dx{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)}};Rh.exports=function t(e,r){if(ux(e))return e;if(_h(e))return Do({readable:e});if(vh(e))return Do({writable:e});if(fx(e))return Do({writable:!1,readable:!1});if(typeof e=="function"){let{value:i,write:o,final:s,destroy:a}=wx(e);if(Eh(i))return Bh(qr,i,{objectMode:!0,write:o,final:s,destroy:a});let c=i?.then;if(typeof c=="function"){let f,u=kh(c,i,l=>{if(l!=null)throw new Sh("nully","body",l)},l=>{Pn(f,l)});return f=new qr({objectMode:!0,readable:!1,write:o,final(l){s(async()=>{try{await u,lc.nextTick(l,null)}catch(p){lc.nextTick(l,p)}})},destroy:a})}throw new Sh("Iterable, AsyncIterable or AsyncFunction",r,i)}if(px(e))return t(e.arrayBuffer());if(Eh(e))return Bh(qr,e,{objectMode:!0,writable:!1});if(typeof e?.writable=="object"||typeof e?.readable=="object"){let i=e!=null&&e.readable?_h(e?.readable)?e?.readable:t(e.readable):void 0,o=e!=null&&e.writable?vh(e?.writable)?e?.writable:t(e.writable):void 0;return Do({readable:i,writable:o})}let n=e?.then;if(typeof n=="function"){let i;return kh(n,e,o=>{o!=null&&i.push(o),i.push(null)},o=>{Pn(i,o)}),i=new qr({objectMode:!0,writable:!1,read(){}})}throw new lx(r,["Blob","ReadableStream","WritableStream","Stream","Iterable","AsyncIterable","Function","{ readable, writable } pair","Promise"],e)};function wx(t){let{promise:e,resolve:r}=Th(),n=new yx,i=n.signal;return{value:t(async function*(){for(;;){let s=e;e=null;let{chunk:a,done:c,cb:f}=await s;if(lc.nextTick(f),c)return;if(i.aborted)throw new Ih(void 0,{cause:i.reason});({promise:e,resolve:r}=Th()),yield a}}(),{signal:i}),write(s,a,c){let f=r;r=null,f({chunk:s,done:!1,cb:c})},final(s){let a=r;r=null,a({done:!0,cb:s})},destroy(s,a){n.abort(),a(s)}}}function Do(t){let e=t.readable&&typeof t.readable.read!="function"?hx.wrap(t.readable):t.readable,r=t.writable,n=!!ax(e),i=!!cx(r),o,s,a,c,f;function u(l){let p=c;c=null,p?p(l):l&&f.destroy(l)}return f=new qr({readableObjectMode:!!(e!=null&&e.readableObjectMode),writableObjectMode:!!(r!=null&&r.writableObjectMode),readable:n,writable:i}),i&&(Ah(r,l=>{i=!1,l&&Pn(e,l),u(l)}),f._write=function(l,p,y){r.write(l,p)?y():o=y},f._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&&(Ah(e,l=>{n=!1,l&&Pn(e,l),u(l)}),e.on("readable",function(){if(a){let l=a;a=null,l()}}),e.on("end",function(){f.push(null)}),f._read=function(){for(;;){let l=e.read();if(l===null){a=f._read;return}if(!f.push(l))return}}),f._destroy=function(l,p){!l&&c!==null&&(l=new Ih),a=null,o=null,s=null,c===null?p(l):(c=p,Pn(r,l),Pn(e,l))},f}});var bt=D((hv,Oh)=>{"use strict";var{ObjectDefineProperties:mx,ObjectGetOwnPropertyDescriptor:Ct,ObjectKeys:bx,ObjectSetPrototypeOf:Ch}=le();Oh.exports=Ze;var pc=pi(),Fe=uc();Ch(Ze.prototype,pc.prototype);Ch(Ze,pc);{let t=bx(Fe.prototype);for(let e=0;e<t.length;e++){let r=t[e];Ze.prototype[r]||(Ze.prototype[r]=Fe.prototype[r])}}function Ze(t){if(!(this instanceof Ze))return new Ze(t);pc.call(this,t),Fe.call(this,t),t?(this.allowHalfOpen=t.allowHalfOpen!==!1,t.readable===!1&&(this._readableState.readable=!1,this._readableState.ended=!0,this._readableState.endEmitted=!0),t.writable===!1&&(this._writableState.writable=!1,this._writableState.ending=!0,this._writableState.ended=!0,this._writableState.finished=!0)):this.allowHalfOpen=!0}mx(Ze.prototype,{writable:{__proto__:null,...Ct(Fe.prototype,"writable")},writableHighWaterMark:{__proto__:null,...Ct(Fe.prototype,"writableHighWaterMark")},writableObjectMode:{__proto__:null,...Ct(Fe.prototype,"writableObjectMode")},writableBuffer:{__proto__:null,...Ct(Fe.prototype,"writableBuffer")},writableLength:{__proto__:null,...Ct(Fe.prototype,"writableLength")},writableFinished:{__proto__:null,...Ct(Fe.prototype,"writableFinished")},writableCorked:{__proto__:null,...Ct(Fe.prototype,"writableCorked")},writableEnded:{__proto__:null,...Ct(Fe.prototype,"writableEnded")},writableNeedDrain:{__proto__:null,...Ct(Fe.prototype,"writableNeedDrain")},destroyed:{__proto__:null,get(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set(t){this._readableState&&this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}}});var dc;function Lh(){return dc===void 0&&(dc={}),dc}Ze.fromWeb=function(t,e){return Lh().newStreamDuplexFromReadableWritablePair(t,e)};Ze.toWeb=function(t){return Lh().newReadableWritablePairFromDuplex(t)};var hc;Ze.from=function(t){return hc||(hc=Uh()),hc(t,"body")}});var mc=D((pv,Nh)=>{"use strict";var{ObjectSetPrototypeOf:Kh,Symbol:gx}=le();Nh.exports=Lt;var{ERR_METHOD_NOT_IMPLEMENTED:xx}=ve().codes,wc=bt(),{getHighWaterMark:Ex}=Io();Kh(Lt.prototype,wc.prototype);Kh(Lt,wc);var bi=gx("kCallback");function Lt(t){if(!(this instanceof Lt))return new Lt(t);let e=t?Ex(this,t,"readableHighWaterMark",!0):null;e===0&&(t={...t,highWaterMark:null,readableHighWaterMark:e,writableHighWaterMark:t.writableHighWaterMark||0}),wc.call(this,t),this._readableState.sync=!1,this[bi]=null,t&&(typeof t.transform=="function"&&(this._transform=t.transform),typeof t.flush=="function"&&(this._flush=t.flush)),this.on("prefinish",_x)}function yc(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 _x(){this._final!==yc&&yc.call(this)}Lt.prototype._final=yc;Lt.prototype._transform=function(t,e,r){throw new xx("_transform()")};Lt.prototype._write=function(t,e,r){let n=this._readableState,i=this._writableState,o=n.length;this._transform(t,e,(s,a)=>{if(s){r(s);return}a!=null&&this.push(a),i.ended||o===n.length||n.length<n.highWaterMark?r():this[bi]=r})};Lt.prototype._read=function(){if(this[bi]){let t=this[bi];this[bi]=null,t()}}});var gc=D((yv,Mh)=>{"use strict";var{ObjectSetPrototypeOf:Dh}=le();Mh.exports=kn;var bc=mc();Dh(kn.prototype,bc.prototype);Dh(kn,bc);function kn(t){if(!(this instanceof kn))return new kn(t);bc.call(this,t)}kn.prototype._transform=function(t,e,r){r(null,t)}});var Fo=D((wv,Vh)=>{var gi=ir(),{ArrayIsArray:vx,Promise:Ax,SymbolAsyncIterator:Sx}=le(),jo=Ut(),{once:Tx}=lt(),Bx=Kr(),qh=bt(),{aggregateTwoErrors:Px,codes:{ERR_INVALID_ARG_TYPE:Bc,ERR_INVALID_RETURN_VALUE:xc,ERR_MISSING_ARGS:kx,ERR_STREAM_DESTROYED:Ix,ERR_STREAM_PREMATURE_CLOSE:Rx},AbortError:Ux}=ve(),{validateFunction:Cx,validateAbortSignal:Lx}=li(),{isIterable:jr,isReadable:Ec,isReadableNodeStream:qo,isNodeStream:jh,isTransformStream:In,isWebStream:Ox,isReadableStream:_c,isReadableEnded:Kx}=yt(),Nx=globalThis.AbortController||mo().AbortController,vc,Ac;function Fh(t,e,r){let n=!1;t.on("close",()=>{n=!0});let i=jo(t,{readable:e,writable:r},o=>{n=!o});return{destroy:o=>{n||(n=!0,Bx.destroyer(t,o||new Ix("pipe")))},cleanup:i}}function Dx(t){return Cx(t[t.length-1],"streams[stream.length - 1]"),t.pop()}function Sc(t){if(jr(t))return t;if(qo(t))return Mx(t);throw new Bc("val",["Readable","Iterable","AsyncIterable"],t)}async function*Mx(t){Ac||(Ac=pi()),yield*Ac.prototype[Sx].call(t)}async function Mo(t,e,r,{end:n}){let i,o=null,s=f=>{if(f&&(i=f),o){let u=o;o=null,u()}},a=()=>new Ax((f,u)=>{i?u(i):o=()=>{i?u(i):f()}});e.on("drain",s);let c=jo(e,{readable:!1},s);try{e.writableNeedDrain&&await a();for await(let f of t)e.write(f)||await a();n&&e.end(),await a(),r()}catch(f){r(i!==f?Px(i,f):f)}finally{c(),e.off("drain",s)}}async function Tc(t,e,r,{end:n}){In(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 qx(...t){return $h(t,Tx(Dx(t)))}function $h(t,e,r){if(t.length===1&&vx(t[0])&&(t=t[0]),t.length<2)throw new kx("streams");let n=new Nx,i=n.signal,o=r?.signal,s=[];Lx(o,"options.signal");function a(){y(new Ux)}o?.addEventListener("abort",a);let c,f,u=[],l=0;function p(x){y(x,--l===0)}function y(x,w){if(x&&(!c||c.code==="ERR_STREAM_PREMATURE_CLOSE")&&(c=x),!(!c&&!w)){for(;u.length;)u.shift()(c);o?.removeEventListener("abort",a),n.abort(),w&&(c||s.forEach(T=>T()),gi.nextTick(e,c,f))}}let d;for(let x=0;x<t.length;x++){let w=t[x],T=x<t.length-1,_=x>0,A=T||r?.end!==!1,I=x===t.length-1;if(jh(w)){let B=function(U){U&&U.name!=="AbortError"&&U.code!=="ERR_STREAM_PREMATURE_CLOSE"&&p(U)};var g=B;if(A){let{destroy:U,cleanup:O}=Fh(w,T,_);u.push(U),Ec(w)&&I&&s.push(O)}w.on("error",B),Ec(w)&&I&&s.push(()=>{w.removeListener("error",B)})}if(x===0)if(typeof w=="function"){if(d=w({signal:i}),!jr(d))throw new xc("Iterable, AsyncIterable or Stream","source",d)}else jr(w)||qo(w)||In(w)?d=w:d=qh.from(w);else if(typeof w=="function"){if(In(d)){var h;d=Sc((h=d)===null||h===void 0?void 0:h.readable)}else d=Sc(d);if(d=w(d,{signal:i}),T){if(!jr(d,!0))throw new xc("AsyncIterable",`transform[${x-1}]`,d)}else{var m;vc||(vc=gc());let B=new vc({objectMode:!0}),U=(m=d)===null||m===void 0?void 0:m.then;if(typeof U=="function")l++,U.call(d,M=>{f=M,M!=null&&B.write(M),A&&B.end(),gi.nextTick(p)},M=>{B.destroy(M),gi.nextTick(p,M)});else if(jr(d,!0))l++,Mo(d,B,p,{end:A});else if(_c(d)||In(d)){let M=d.readable||d;l++,Mo(M,B,p,{end:A})}else throw new xc("AsyncIterable or Promise","destination",d);d=B;let{destroy:O,cleanup:C}=Fh(d,!1,!0);u.push(O),I&&s.push(C)}}else if(jh(w)){if(qo(d)){l+=2;let B=jx(d,w,p,{end:A});Ec(w)&&I&&s.push(B)}else if(In(d)||_c(d)){let B=d.readable||d;l++,Mo(B,w,p,{end:A})}else if(jr(d))l++,Mo(d,w,p,{end:A});else throw new Bc("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],d);d=w}else if(Ox(w)){if(qo(d))l++,Tc(Sc(d),w,p,{end:A});else if(_c(d)||jr(d))l++,Tc(d,w,p,{end:A});else if(In(d))l++,Tc(d.readable,w,p,{end:A});else throw new Bc("val",["Readable","Iterable","AsyncIterable","ReadableStream","TransformStream"],d);d=w}else d=qh.from(w)}return(i!=null&&i.aborted||o!=null&&o.aborted)&&gi.nextTick(a),d}function jx(t,e,r,{end:n}){let i=!1;if(e.on("close",()=>{i||r(new Rx)}),t.pipe(e,{end:!1}),n){let s=function(){i=!0,e.end()};var o=s;Kx(t)?gi.nextTick(s):t.once("end",s)}else r();return jo(t,{readable:!0,writable:!1},s=>{let a=t._readableState;s&&s.code==="ERR_STREAM_PREMATURE_CLOSE"&&a&&a.ended&&!a.errored&&!a.errorEmitted?t.once("end",r).once("error",r):r(s)}),jo(e,{readable:!1,writable:!0},r)}Vh.exports={pipelineImpl:$h,pipeline:qx}});var kc=D((mv,Yh)=>{"use strict";var{pipeline:Fx}=Fo(),$o=bt(),{destroyer:$x}=Kr(),{isNodeStream:Vo,isReadable:Hh,isWritable:Gh,isWebStream:Pc,isTransformStream:Fr,isWritableStream:Jh,isReadableStream:Wh}=yt(),{AbortError:Vx,codes:{ERR_INVALID_ARG_VALUE:zh,ERR_MISSING_ARGS:Hx}}=ve(),Gx=Ut();Yh.exports=function(...e){if(e.length===0)throw new Hx("streams");if(e.length===1)return $o.from(e[0]);let r=[...e];if(typeof e[0]=="function"&&(e[0]=$o.from(e[0])),typeof e[e.length-1]=="function"){let y=e.length-1;e[y]=$o.from(e[y])}for(let y=0;y<e.length;++y)if(!(!Vo(e[y])&&!Pc(e[y]))){if(y<e.length-1&&!(Hh(e[y])||Wh(e[y])||Fr(e[y])))throw new zh(`streams[${y}]`,r[y],"must be readable");if(y>0&&!(Gh(e[y])||Jh(e[y])||Fr(e[y])))throw new zh(`streams[${y}]`,r[y],"must be writable")}let n,i,o,s,a;function c(y){let d=s;s=null,d?d(y):y?a.destroy(y):!p&&!l&&a.destroy()}let f=e[0],u=Fx(e,c),l=!!(Gh(f)||Jh(f)||Fr(f)),p=!!(Hh(u)||Wh(u)||Fr(u));if(a=new $o({writableObjectMode:!!(f!=null&&f.writableObjectMode),readableObjectMode:!!(u!=null&&u.writableObjectMode),writable:l,readable:p}),l){if(Vo(f))a._write=function(d,h,m){f.write(d,h)?m():n=m},a._final=function(d){f.end(),i=d},f.on("drain",function(){if(n){let d=n;n=null,d()}});else if(Pc(f)){let h=(Fr(f)?f.writable:f).getWriter();a._write=async function(m,g,x){try{await h.ready,h.write(m).catch(()=>{}),x()}catch(w){x(w)}},a._final=async function(m){try{await h.ready,h.close().catch(()=>{}),i=m}catch(g){m(g)}}}let y=Fr(u)?u.readable:u;Gx(y,()=>{if(i){let d=i;i=null,d()}})}if(p){if(Vo(u))u.on("readable",function(){if(o){let y=o;o=null,y()}}),u.on("end",function(){a.push(null)}),a._read=function(){for(;;){let y=u.read();if(y===null){o=a._read;return}if(!a.push(y))return}};else if(Pc(u)){let d=(Fr(u)?u.readable:u).getReader();a._read=async function(){for(;;)try{let{value:h,done:m}=await d.read();if(!a.push(h))return;if(m){a.push(null);return}}catch{return}}}}return a._destroy=function(y,d){!y&&s!==null&&(y=new Vx),o=null,n=null,i=null,s===null?d(y):(s=d,Vo(u)&&$x(u,y))},a}});var ip=D((bv,Uc)=>{"use strict";var ep=globalThis.AbortController||mo().AbortController,{codes:{ERR_INVALID_ARG_VALUE:Jx,ERR_INVALID_ARG_TYPE:xi,ERR_MISSING_ARGS:Wx,ERR_OUT_OF_RANGE:zx},AbortError:gt}=ve(),{validateAbortSignal:$r,validateInteger:Yx,validateObject:Vr}=li(),Zx=le().Symbol("kWeak"),{finished:Xx}=Ut(),Qx=kc(),{addAbortSignalNoValidate:eE}=di(),{isWritable:tE,isNodeStream:rE}=yt(),{ArrayPrototypePush:nE,MathFloor:iE,Number:oE,NumberIsNaN:sE,Promise:Zh,PromiseReject:Xh,PromisePrototypeThen:aE,Symbol:tp}=le(),Ho=tp("kEmpty"),Qh=tp("kEof");function cE(t,e){if(e!=null&&Vr(e,"options"),e?.signal!=null&&$r(e.signal,"options.signal"),rE(t)&&!tE(t))throw new Jx("stream",t,"must be writable");let r=Qx(this,t);return e!=null&&e.signal&&eE(e.signal,r),r}function Go(t,e){if(typeof t!="function")throw new xi("fn",["Function","AsyncFunction"],t);e!=null&&Vr(e,"options"),e?.signal!=null&&$r(e.signal,"options.signal");let r=1;return e?.concurrency!=null&&(r=iE(e.concurrency)),Yx(r,"concurrency",1),(async function*(){var i,o;let s=new ep,a=this,c=[],f=s.signal,u={signal:f},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 p,y,d=!1;function h(){d=!0}async function m(){try{for await(let w of a){var g;if(d)return;if(f.aborted)throw new gt;try{w=t(w,u)}catch(T){w=Xh(T)}w!==Ho&&(typeof((g=w)===null||g===void 0?void 0:g.catch)=="function"&&w.catch(h),c.push(w),p&&(p(),p=null),!d&&c.length&&c.length>=r&&await new Zh(T=>{y=T}))}c.push(Qh)}catch(w){let T=Xh(w);aE(T,void 0,h),c.push(T)}finally{var x;d=!0,p&&(p(),p=null),e==null||(x=e.signal)===null||x===void 0||x.removeEventListener("abort",l)}}m();try{for(;;){for(;c.length>0;){let g=await c[0];if(g===Qh)return;if(f.aborted)throw new gt;g!==Ho&&(yield g),c.shift(),y&&(y(),y=null)}await new Zh(g=>{p=g})}}finally{s.abort(),d=!0,y&&(y(),y=null)}}).call(this)}function fE(t=void 0){return t!=null&&Vr(t,"options"),t?.signal!=null&&$r(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 gt({cause:t.signal.reason});yield[r++,i]}}).call(this)}async function rp(t,e=void 0){for await(let r of Rc.call(this,t,e))return!0;return!1}async function uE(t,e=void 0){if(typeof t!="function")throw new xi("fn",["Function","AsyncFunction"],t);return!await rp.call(this,async(...r)=>!await t(...r),e)}async function lE(t,e){for await(let r of Rc.call(this,t,e))return r}async function dE(t,e){if(typeof t!="function")throw new xi("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i),Ho}for await(let n of Go.call(this,r,e));}function Rc(t,e){if(typeof t!="function")throw new xi("fn",["Function","AsyncFunction"],t);async function r(n,i){return await t(n,i)?n:Ho}return Go.call(this,r,e)}var Ic=class extends Wx{constructor(){super("reduce"),this.message="Reduce of an empty stream requires an initial value"}};async function hE(t,e,r){var n;if(typeof t!="function")throw new xi("reducer",["Function","AsyncFunction"],t);r!=null&&Vr(r,"options"),r?.signal!=null&&$r(r.signal,"options.signal");let i=arguments.length>1;if(r!=null&&(n=r.signal)!==null&&n!==void 0&&n.aborted){let f=new gt(void 0,{cause:r.signal.reason});throw this.once("error",()=>{}),await Xx(this.destroy(f)),f}let o=new ep,s=o.signal;if(r!=null&&r.signal){let f={once:!0,[Zx]:this};r.signal.addEventListener("abort",()=>o.abort(),f)}let a=!1;try{for await(let f of this){var c;if(a=!0,r!=null&&(c=r.signal)!==null&&c!==void 0&&c.aborted)throw new gt;i?e=await t(e,f,{signal:s}):(e=f,i=!0)}if(!a&&!i)throw new Ic}finally{o.abort()}return e}async function pE(t){t!=null&&Vr(t,"options"),t?.signal!=null&&$r(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 gt(void 0,{cause:t.signal.reason});nE(e,n)}return e}function yE(t,e){let r=Go.call(this,t,e);return(async function*(){for await(let i of r)yield*i}).call(this)}function np(t){if(t=oE(t),sE(t))return 0;if(t<0)throw new zx("number",">= 0",t);return t}function wE(t,e=void 0){return e!=null&&Vr(e,"options"),e?.signal!=null&&$r(e.signal,"options.signal"),t=np(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new gt;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new gt;t--<=0&&(yield o)}}).call(this)}function mE(t,e=void 0){return e!=null&&Vr(e,"options"),e?.signal!=null&&$r(e.signal,"options.signal"),t=np(t),(async function*(){var n;if(e!=null&&(n=e.signal)!==null&&n!==void 0&&n.aborted)throw new gt;for await(let o of this){var i;if(e!=null&&(i=e.signal)!==null&&i!==void 0&&i.aborted)throw new gt;if(t-- >0)yield o;else return}}).call(this)}Uc.exports.streamReturningOperators={asIndexedPairs:fE,drop:wE,filter:Rc,flatMap:yE,map:Go,take:mE,compose:cE};Uc.exports.promiseReturningOperators={every:uE,forEach:dE,reduce:hE,toArray:pE,some:rp,find:lE}});var Cc=D((gv,op)=>{"use strict";var{ArrayPrototypePop:bE,Promise:gE}=le(),{isIterable:xE,isNodeStream:EE,isWebStream:_E}=yt(),{pipelineImpl:vE}=Fo(),{finished:AE}=Ut();Lc();function SE(...t){return new gE((e,r)=>{let n,i,o=t[t.length-1];if(o&&typeof o=="object"&&!EE(o)&&!xE(o)&&!_E(o)){let s=bE(t);n=s.signal,i=s.end}vE(t,(s,a)=>{s?r(s):e(a)},{signal:n,end:i})})}op.exports={finished:AE,pipeline:SE}});var Lc=D((xv,pp)=>{var{Buffer:TE}=De(),{ObjectDefineProperty:Ot,ObjectKeys:cp,ReflectApply:fp}=le(),{promisify:{custom:up}}=lt(),{streamReturningOperators:sp,promiseReturningOperators:ap}=ip(),{codes:{ERR_ILLEGAL_CONSTRUCTOR:lp}}=ve(),BE=kc(),{pipeline:dp}=Fo(),{destroyer:PE}=Kr(),hp=Ut(),Oc=Cc(),Kc=yt(),fe=pp.exports=Bo().Stream;fe.isDisturbed=Kc.isDisturbed;fe.isErrored=Kc.isErrored;fe.isReadable=Kc.isReadable;fe.Readable=pi();for(let t of cp(sp)){let r=function(...n){if(new.target)throw lp();return fe.Readable.from(fp(e,this,n))};Nc=r;let e=sp[t];Ot(r,"name",{__proto__:null,value:e.name}),Ot(r,"length",{__proto__:null,value:e.length}),Ot(fe.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var Nc;for(let t of cp(ap)){let r=function(...i){if(new.target)throw lp();return fp(e,this,i)};Nc=r;let e=ap[t];Ot(r,"name",{__proto__:null,value:e.name}),Ot(r,"length",{__proto__:null,value:e.length}),Ot(fe.Readable.prototype,t,{__proto__:null,value:r,enumerable:!1,configurable:!0,writable:!0})}var Nc;fe.Writable=uc();fe.Duplex=bt();fe.Transform=mc();fe.PassThrough=gc();fe.pipeline=dp;var{addAbortSignal:kE}=di();fe.addAbortSignal=kE;fe.finished=hp;fe.destroy=PE;fe.compose=BE;Ot(fe,"promises",{__proto__:null,configurable:!0,enumerable:!0,get(){return Oc}});Ot(dp,up,{__proto__:null,enumerable:!0,get(){return Oc.pipeline}});Ot(hp,up,{__proto__:null,enumerable:!0,get(){return Oc.finished}});fe.Stream=fe;fe._isUint8Array=function(e){return e instanceof Uint8Array};fe._uint8ArrayToBuffer=function(e){return TE.from(e.buffer,e.byteOffset,e.byteLength)}});var Dc=D((Ev,ue)=>{"use strict";var he=Lc(),IE=Cc(),RE=he.Readable.destroy;ue.exports=he.Readable;ue.exports._uint8ArrayToBuffer=he._uint8ArrayToBuffer;ue.exports._isUint8Array=he._isUint8Array;ue.exports.isDisturbed=he.isDisturbed;ue.exports.isErrored=he.isErrored;ue.exports.isReadable=he.isReadable;ue.exports.Readable=he.Readable;ue.exports.Writable=he.Writable;ue.exports.Duplex=he.Duplex;ue.exports.Transform=he.Transform;ue.exports.PassThrough=he.PassThrough;ue.exports.addAbortSignal=he.addAbortSignal;ue.exports.finished=he.finished;ue.exports.destroy=he.destroy;ue.exports.destroy=RE;ue.exports.pipeline=he.pipeline;ue.exports.compose=he.compose;Object.defineProperty(he,"promises",{configurable:!0,enumerable:!0,get(){return IE}});ue.exports.Stream=he.Stream;ue.exports.default=ue.exports});var b2={};Li(b2,{AES_GCM_TAG_LENGTHS:()=>Ui,AesCtr:()=>tn,AesCtrAlgorithm:()=>yf,AesGcm:()=>rn,AesGcmAlgorithm:()=>wf,ConcatKdf:()=>mf,CryptoAlgorithm:()=>Le,EcdsaAlgorithm:()=>On,Ed25519:()=>Gt,EdDsaAlgorithm:()=>Pi,KEY_URI_PREFIX_JWK:()=>ts,LocalKeyManager:()=>ff,P256:()=>Ht,POLY1305_TAG_LENGTH:()=>m2,Pbkdf2:()=>bf,Secp256k1:()=>Vt,Secp256r1:()=>Ht,Sha256:()=>Jr,Sha2Algorithm:()=>_i,X25519:()=>gf,XChaCha20:()=>Af,XChaCha20Poly1305:()=>Sf,canonicalize:()=>ef,computeJwkThumbprint:()=>G,isEcPrivateJwk:()=>tt,isEcPublicJwk:()=>Zr,isOctPrivateJwk:()=>$t,isOkpPrivateJwk:()=>rt,isOkpPublicJwk:()=>Xr,isPrivateJwk:()=>tf,isPublicJwk:()=>h1,utils:()=>uf});var Ey=Oi(Kf(),1);function _y(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),s=o.charCodeAt(0);if(r[s]!==255)throw new TypeError(o+" is ambiguous");r[s]=i}var a=t.length,c=t.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var h=0,m=0,g=0,x=d.length;g!==x&&d[g]===0;)g++,h++;for(var w=(x-g)*u+1>>>0,T=new Uint8Array(w);g!==x;){for(var _=d[g],A=0,I=w-1;(_!==0||A<m)&&I!==-1;I--,A++)_+=256*T[I]>>>0,T[I]=_%a>>>0,_=_/a>>>0;if(_!==0)throw new Error("Non-zero carry");m=A,g++}for(var B=w-m;B!==w&&T[B]===0;)B++;for(var U=c.repeat(h);B<w;++B)U+=t.charAt(T[B]);return U}function p(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var h=0;if(d[h]!==" "){for(var m=0,g=0;d[h]===c;)m++,h++;for(var x=(d.length-h)*f+1>>>0,w=new Uint8Array(x);d[h];){var T=r[d.charCodeAt(h)];if(T===255)return;for(var _=0,A=x-1;(T!==0||_<g)&&A!==-1;A--,_++)T+=a*w[A]>>>0,w[A]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");g=_,h++}if(d[h]!==" "){for(var I=x-g;I!==x&&w[I]===0;)I++;for(var B=new Uint8Array(m+(x-I)),U=m;I!==x;)B[U++]=w[I++];return B}}}function y(d){var h=p(d);if(h)return h;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:y}}var vy=_y,Ay=vy,Nf=Ay;var v2=new Uint8Array(0);var Df=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},nn=t=>{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 ps=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")}},ys=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 Mf(this,e)}},ws=class{constructor(e){this.decoders=e}or(e){return Mf(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`)}},Mf=(t,e)=>new ws({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),ms=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new ps(e,r,n),this.decoder=new ys(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},qf=({name:t,prefix:e,encode:r,decode:n})=>new ms(t,e,r,n),bs=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:i}=Nf(r,e);return qf({prefix:t,name:e,encode:n,decode:o=>nn(i(o))})},Ty=(t,e,r,n)=>{let i={};for(let u=0;u<e.length;++u)i[e[u]]=u;let o=t.length;for(;t[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),a=0,c=0,f=0;for(let u=0;u<o;++u){let l=i[t[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,a+=r,a>=8&&(a-=8,s[f++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s},By=(t,e,r)=>{let n=e[e.length-1]==="=",i=(1<<r)-1,o="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,o+=e[i&a>>s];if(s&&(o+=e[i&a<<r-s]),n)for(;o.length*r&7;)o+="=";return o},_e=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>qf({prefix:e,name:t,encode(i){return By(i,n,r)},decode(i){return Ty(i,n,r,t)}});var Dn=_e({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),P2=_e({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),k2=_e({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),I2=_e({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),R2=_e({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),U2=_e({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),C2=_e({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),L2=_e({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),gs=_e({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Se=bs({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),N2=bs({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var q2=_e({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),j2=_e({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),it=_e({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),F2=_e({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function jf(t){return t.byteOffset!==0||t.byteLength!==t.buffer.byteLength}function Ff(t){return typeof t!="object"||t===null?!1:typeof t[Symbol.asyncIterator]=="function"}function Mn(t){let r=Object.prototype.toString.call(t).match(/\s([a-zA-Z0-9]+)/),[n,i]=r;return i}var qn=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 a(u){try{f(n.next(u))}catch(l){s(l)}}function c(u){try{f(n.throw(u))}catch(l){s(l)}}function f(u){u.done?o(u.value):i(u.value).then(a,c)}f((n=n.apply(t,e||[])).next())})},$f=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(a,c){s=t[o](s),i(a,c,s.done,s.value)})}}function i(o,s,a,c){Promise.resolve(c).then(function(f){o({value:f,done:a})},s)}},Ni=new TextEncoder,hr=new TextDecoder,q=class t{constructor(e,r){this.data=e,this.format=r}static arrayBuffer(e){return new t(e,"ArrayBuffer")}static asyncIterable(e){if(!Ff(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 Se.baseDecode(this.data).buffer;case"Base64Url":return it.baseDecode(this.data).buffer;case"BufferSource":{if(Mn(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return jf(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 qn(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 gs.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 Se.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return Se.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 it.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return it.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),r=Ni.encode(e);return it.baseEncode(r)}case"String":{let e=Ni.encode(this.data);return it.baseEncode(e)}case"Uint8Array":return it.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){var e,r,n,i;return qn(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let c=[];try{for(var o=!0,s=$f(this.data),a;a=yield s.next(),e=a.done,!e;o=!0){i=a.value,o=!1;let u=i;c.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(c)}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;n<this.data.length;n++)r+=e[this.data[n]];return r}default:throw new TypeError(`Conversion from ${this.format} to Hex is not supported.`)}}toMultibase(){switch(this.format){case"Base58Btc":return`z${this.data}`;default:throw new TypeError(`Conversion from ${this.format} to Multibase is not supported.`)}}toObject(){switch(this.format){case"Base64Url":{let e=it.baseDecode(this.data),r=hr.decode(e);return JSON.parse(r)}case"String":return JSON.parse(this.data);case"Uint8Array":{let e=hr.decode(this.data);return JSON.parse(e)}default:throw new TypeError(`Conversion from ${this.format} to Object is not supported.`)}}toObjectAsync(){return qn(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let e=yield this.toStringAsync();return JSON.parse(e)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Object is not supported.`)}})}toString(){switch(this.format){case"ArrayBuffer":return hr.decode(this.data);case"Base64Url":{let e=it.baseDecode(this.data);return hr.decode(e)}case"Object":return JSON.stringify(this.data);case"Uint8Array":return hr.decode(this.data);default:throw new TypeError(`Conversion from ${this.format} to String is not supported.`)}}toStringAsync(){var e,r,n,i;return qn(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let c="";try{for(var o=!0,s=$f(this.data),a;a=yield s.next(),e=a.done,!e;o=!0){i=a.value,o=!1;let f=i;typeof f=="string"?c+=f:c+=hr.decode(f,{stream:!0})}}catch(f){r={error:f}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(r)throw r.error}}return c+=hr.decode(void 0,{stream:!1}),c}default:throw new TypeError(`Asynchronous conversion from ${this.format} to String is not supported.`)}})}toUint8Array(){switch(this.format){case"ArrayBuffer":return new Uint8Array(this.data);case"Base32Z":return gs.baseDecode(this.data);case"Base58Btc":return Se.baseDecode(this.data);case"Base64Url":return it.baseDecode(this.data);case"BufferSource":{let e=Mn(this.data);if(e==="Uint8Array")return this.data;if(e==="ArrayBuffer")return new Uint8Array(this.data);if(ArrayBuffer.isView(this.data))return new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength);throw new TypeError(`${this.format} value is not of type: ArrayBuffer, DataView, or TypedArray.`)}case"Hex":{let e=new Uint8Array(this.data.length/2);for(let r=0;r<this.data.length;r+=2){let n=parseInt(this.data.substring(r,r+2),16);if(isNaN(n))throw new TypeError("Input is not a valid hexadecimal string.");e[r/2]=n}return e}case"Object":{let e=JSON.stringify(this.data);return Ni.encode(e)}case"String":return Ni.encode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Uint8Array is not supported.`)}}toUint8ArrayAsync(){return qn(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let e=yield this.toArrayBufferAsync();return new Uint8Array(e)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Uint8Array is not supported.`)}})}};var Et={};Li(Et,{decode:()=>on,encodeTo:()=>pr,encodingLength:()=>yr});var Py=Gf,Vf=128,ky=127,Iy=~ky,Ry=Math.pow(2,31);function Gf(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Ry;)e[r++]=t&255|Vf,t/=128;for(;t&Iy;)e[r++]=t&255|Vf,t>>>=7;return e[r]=t|0,Gf.bytes=r-n+1,e}var Uy=xs,Cy=128,Hf=127;function xs(t,n){var r=0,n=n||0,i=0,o=n,s,a=t.length;do{if(o>=a)throw xs.bytes=0,new RangeError("Could not decode varint");s=t[o++],r+=i<28?(s&Hf)<<i:(s&Hf)*Math.pow(2,i),i+=7}while(s>=Cy);return xs.bytes=o-n,r}var Ly=Math.pow(2,7),Oy=Math.pow(2,14),Ky=Math.pow(2,21),Ny=Math.pow(2,28),Dy=Math.pow(2,35),My=Math.pow(2,42),qy=Math.pow(2,49),jy=Math.pow(2,56),Fy=Math.pow(2,63),$y=function(t){return t<Ly?1:t<Oy?2:t<Ky?3:t<Ny?4:t<Dy?5:t<My?6:t<qy?7:t<jy?8:t<Fy?9:10},Vy={encode:Py,decode:Uy,encodingLength:$y},Hy=Vy,jn=Hy;var on=(t,e=0)=>[jn.decode(t,e),jn.decode.bytes],pr=(t,e,r=0)=>(jn.encode(t,e,r),e),yr=t=>jn.encodingLength(t);var Es=(t,e)=>{let r=e.byteLength,n=yr(t),i=n+yr(r),o=new Uint8Array(i+r);return pr(t,o,0),pr(r,o,n),o.set(e,i),new sn(t,r,e,o)},Jf=t=>{let e=nn(t),[r,n]=on(e),[i,o]=on(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new sn(r,i,s,e)},Wf=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Df(t.bytes,r.bytes)}},sn=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}};var zf=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return Jy(r,vs(t),e||Se.encoder);default:return Wy(r,vs(t),e||Dn.encoder)}};var Yf=new WeakMap,vs=t=>{let e=Yf.get(t);if(e==null){let r=new Map;return Yf.set(t,r),r}return e},As=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!==Fn)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==zy)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=Es(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&&Wf(e.multihash,n.multihash)}toString(e){return zf(this,e)}toJSON(){return{"/":zf(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||Zf(n,i,o.bytes))}else if(r[Yy]===!0){let{version:n,multihash:i,code:o}=r,s=Jf(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!==Fn)throw new Error(`Version 0 CID must use dag-pb (code: ${Fn}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let i=Zf(e,r,n.bytes);return new t(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Fn,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=nn(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 sn(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,p]=on(e.subarray(r));return r+=p,l},i=n(),o=Fn;if(i===18?(i=0,r=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=r,a=n(),c=n(),f=r+c,u=f-s;return{version:i,codec:o,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,r){let[n,i]=Gy(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 vs(o).set(n,e),o}},Gy=(t,e)=>{switch(t[0]){case"Q":{let r=e||Se;return[Se.prefix,r.decode(`${Se.prefix}${t}`)]}case Se.prefix:{let r=e||Se;return[Se.prefix,r.decode(t)]}case Dn.prefix:{let r=e||Dn;return[Dn.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)]}}},Jy=(t,e,r)=>{let{prefix:n}=r;if(n!==Se.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},Wy=(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},Fn=112,zy=18,Zf=(t,e,r)=>{let n=yr(t),i=n+yr(e),o=new Uint8Array(i+r.byteLength);return pr(t,o,0),pr(e,o,n),o.set(r,i),o},Yy=Symbol.for("@ipld/js-cid/CID");var ot=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=Et.encodingLength(n),a=new Uint8Array(s+i.byteLength);return a.set(i,s),Et.encodeTo(n,a),a}static getCodeFromData(e){let{prefixedData:r}=e,[n,i]=Et.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]=Et.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}}};ot.codeToName=new Map;ot.nameToCode=new Map;ot.registerCodec({code:237,name:"ed25519-pub"});ot.registerCodec({code:4864,name:"ed25519-priv"});ot.registerCodec({code:236,name:"x25519-pub"});ot.registerCodec({code:4866,name:"x25519-priv"});ot.registerCodec({code:231,name:"secp256k1-pub"});ot.registerCodec({code:4865,name:"secp256k1-priv"});function Ss(t){Object.keys(t).forEach(e=>{t[e]===void 0?delete t[e]:typeof t[e]=="object"&&Ss(t[e])})}var Ow=Oi(Il(),1),Ur=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 a(u){try{f(n.next(u))}catch(l){s(l)}}function c(u){try{f(n.throw(u))}catch(l){s(l)}}function f(u){u.done?o(u.value):i(u.value).then(a,c)}f((n=n.apply(t,e||[])).next())})};var yo=class{constructor(){this.store=new Map}clear(){return Ur(this,void 0,void 0,function*(){this.store.clear()})}close(){return Ur(this,void 0,void 0,function*(){})}delete(e){return Ur(this,void 0,void 0,function*(){return this.store.delete(e)})}get(e){return Ur(this,void 0,void 0,function*(){return this.store.get(e)})}has(e){return Ur(this,void 0,void 0,function*(){return this.store.has(e)})}list(){return Ur(this,void 0,void 0,function*(){return Array.from(this.store.values())})}set(e,r){return Ur(this,void 0,void 0,function*(){this.store.set(e,r)})}};var UE=Oi(Dc(),1);var CE=Oi(Dc(),1);function yp(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function LE(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function Mc(t,...e){if(!LE(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 wp(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");yp(t.outputLen),yp(t.blockLen)}function Rn(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 mp(t,e){Mc(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var Kt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function bp(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var Jo=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Xe=(t,e)=>t<<32-e|t>>>e,OE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!OE)throw new Error("Non little-endian hardware is not supported");function qc(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function Ei(t){if(typeof t=="string"&&(t=qc(t)),!bp(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}function Hr(...t){let e=0;for(let n=0;n<t.length;n++){let i=t[n];if(!bp(i))throw new Error("Uint8Array expected");e+=i.length}let r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let o=t[n];r.set(o,i),i+=o.length}return r}var Un=class{clone(){return this._cloneInto()}},Dv={}.toString;function Wo(t){let e=n=>t().update(Ei(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Gr(t=32){if(Kt&&typeof Kt.getRandomValues=="function")return Kt.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}function KE(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),a=Number(r&o),c=n?4:0,f=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+f,a,n)}var Cn=class extends Un{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=Jo(this.buffer)}update(e){Rn(this);let{view:r,buffer:n,blockLen:i}=this;e=Ei(e);let o=e.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let c=Jo(e);for(;i<=o-s;s+=i)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Rn(this),mp(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;r[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let l=s;l<i;l++)r[l]=0;KE(n,i-8,BigInt(this.length*8),o),this.process(n,0);let a=Jo(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],o)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:r,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%r&&e.buffer.set(n),e}};var NE=(t,e,r)=>t&e^~t&r,DE=(t,e,r)=>t&e^t&r^e&r,ME=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]),ar=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),cr=new Uint32Array(64),jc=class extends Cn{constructor(){super(64,32,8,!1),this.A=ar[0]|0,this.B=ar[1]|0,this.C=ar[2]|0,this.D=ar[3]|0,this.E=ar[4]|0,this.F=ar[5]|0,this.G=ar[6]|0,this.H=ar[7]|0}get(){let{A:e,B:r,C:n,D:i,E:o,F:s,G:a,H:c}=this;return[e,r,n,i,o,s,a,c]}set(e,r,n,i,o,s,a,c){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=a|0,this.H=c|0}process(e,r){for(let l=0;l<16;l++,r+=4)cr[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let p=cr[l-15],y=cr[l-2],d=Xe(p,7)^Xe(p,18)^p>>>3,h=Xe(y,17)^Xe(y,19)^y>>>10;cr[l]=h+cr[l-7]+d+cr[l-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let p=Xe(a,6)^Xe(a,11)^Xe(a,25),y=u+p+NE(a,c,f)+ME[l]+cr[l]|0,h=(Xe(n,2)^Xe(n,13)^Xe(n,22))+DE(n,i,o)|0;u=f,f=c,c=a,a=s+y|0,s=o,o=i,i=n,n=y+h|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,i,o,s,a,c,f,u)}roundClean(){cr.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Pe=Wo(()=>new jc);var Jr=class{static async digest({data:e}){return Pe(e)}};var Le=class{};var _i=class extends Le{async digest({algorithm:e,data:r}){switch(e){case"SHA-256":return await Jr.digest({data:r})}}};var Yo={};Li(Yo,{bitGet:()=>GE,bitLen:()=>HE,bitMask:()=>vi,bitSet:()=>JE,bytesToHex:()=>Dt,bytesToNumberBE:()=>Mt,bytesToNumberLE:()=>et,concatBytes:()=>jt,createHmacDrbg:()=>Vc,ensureBytes:()=>ie,equalBytes:()=>$E,hexToBytes:()=>Wr,hexToNumber:()=>$c,isBytes:()=>Qe,numberToBytesBE:()=>ke,numberToBytesLE:()=>qt,numberToHexUnpadded:()=>_p,numberToVarBytesBE:()=>FE,utf8ToBytes:()=>VE,validateObject:()=>$e});var Ep=BigInt(0),zo=BigInt(1),qE=BigInt(2);function Qe(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var jE=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Dt(t){if(!Qe(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=jE[t[r]];return e}function _p(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function $c(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return BigInt(t===""?"0":`0x${t}`)}var Nt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function gp(t){if(t>=Nt._0&&t<=Nt._9)return t-Nt._0;if(t>=Nt._A&&t<=Nt._F)return t-(Nt._A-10);if(t>=Nt._a&&t<=Nt._f)return t-(Nt._a-10)}function Wr(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;i<r;i++,o+=2){let s=gp(t.charCodeAt(o)),a=gp(t.charCodeAt(o+1));if(s===void 0||a===void 0){let c=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+o)}n[i]=s*16+a}return n}function Mt(t){return $c(Dt(t))}function et(t){if(!Qe(t))throw new Error("Uint8Array expected");return $c(Dt(Uint8Array.from(t).reverse()))}function ke(t,e){return Wr(t.toString(16).padStart(e*2,"0"))}function qt(t,e){return ke(t,e).reverse()}function FE(t){return Wr(_p(t))}function ie(t,e,r){let n;if(typeof e=="string")try{n=Wr(e)}catch(o){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${o}`)}else if(Qe(e))n=Uint8Array.from(e);else throw new Error(`${t} must be hex string or Uint8Array`);let i=n.length;if(typeof r=="number"&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function jt(...t){let e=0;for(let i=0;i<t.length;i++){let o=t[i];if(!Qe(o))throw new Error("Uint8Array expected");e+=o.length}let r=new Uint8Array(e),n=0;for(let i=0;i<t.length;i++){let o=t[i];r.set(o,n),n+=o.length}return r}function $E(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}function VE(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function HE(t){let e;for(e=0;t>Ep;t>>=zo,e+=1);return e}function GE(t,e){return t>>BigInt(e)&zo}var JE=(t,e,r)=>t|(r?zo:Ep)<<BigInt(e),vi=t=>(qE<<BigInt(t-1))-zo,Fc=t=>new Uint8Array(t),xp=t=>Uint8Array.from(t);function Vc(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=Fc(t),i=Fc(t),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...l)=>r(i,n,...l),c=(l=Fc())=>{i=a(xp([0]),l),n=a(),l.length!==0&&(i=a(xp([1]),l),n=a())},f=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l<e;){n=a();let y=n.slice();p.push(y),l+=n.length}return jt(...p)};return(l,p)=>{s(),c(l);let y;for(;!(y=p(f()));)c();return s(),y}}var WE={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"||Qe(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 $e(t,e,r={}){let n=(i,o,s)=>{let a=WE[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let c=t[i];if(!(s&&c===void 0)&&!a(c,t))throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), 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 pe=BigInt(0),se=BigInt(1),zr=BigInt(2),zE=BigInt(3),Hc=BigInt(4),vp=BigInt(5),Ap=BigInt(8),YE=BigInt(9),ZE=BigInt(16);function ee(t,e){let r=t%e;return r>=pe?r:e+r}function Gc(t,e,r){if(r<=pe||e<pe)throw new Error("Expected power/modulo > 0");if(r===se)return pe;let n=se;for(;e>pe;)e&se&&(n=n*t%r),t=t*t%r,e>>=se;return n}function oe(t,e,r){let n=t;for(;e-- >pe;)n*=n,n%=r;return n}function Zo(t,e){if(t===pe||e<=pe)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=ee(t,e),n=e,i=pe,o=se,s=se,a=pe;for(;r!==pe;){let f=n/r,u=n%r,l=i-s*f,p=o-a*f;n=r,r=u,i=s,o=a,s=l,a=p}if(n!==se)throw new Error("invert: does not exist");return ee(i,e)}function XE(t){let e=(t-se)/zr,r,n,i;for(r=t-se,n=0;r%zr===pe;r/=zr,n++);for(i=zr;i<t&&Gc(i,e,t)!==t-se;i++);if(n===1){let s=(t+se)/Hc;return function(c,f){let u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let o=(r+se)/zr;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,u=a.pow(a.mul(a.ONE,i),r),l=a.pow(c,o),p=a.pow(c,r);for(;!a.eql(p,a.ONE);){if(a.eql(p,a.ZERO))return a.ZERO;let y=1;for(let h=a.sqr(p);y<f&&!a.eql(h,a.ONE);y++)h=a.sqr(h);let d=a.pow(u,se<<BigInt(f-y-1));u=a.sqr(d),l=a.mul(l,d),p=a.mul(p,u),f=y}return l}}function QE(t){if(t%Hc===zE){let e=(t+se)/Hc;return function(n,i){let o=n.pow(i,e);if(!n.eql(n.sqr(o),i))throw new Error("Cannot find square root");return o}}if(t%Ap===vp){let e=(t-vp)/Ap;return function(n,i){let o=n.mul(i,zr),s=n.pow(o,e),a=n.mul(i,s),c=n.mul(n.mul(a,zr),s),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),i))throw new Error("Cannot find square root");return f}}return t%ZE,XE(t)}var Sp=(t,e)=>(ee(t,e)&se)===se,e1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Jc(t){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=e1.reduce((n,i)=>(n[i]="function",n),e);return $e(t,r)}function t1(t,e,r){if(r<pe)throw new Error("Expected power > 0");if(r===pe)return t.ONE;if(r===se)return e;let n=t.ONE,i=e;for(;r>pe;)r&se&&(n=t.mul(n,i)),i=t.sqr(i),r>>=se;return n}function r1(t,e){let r=new Array(e.length),n=e.reduce((o,s,a)=>t.is0(s)?o:(r[a]=o,t.mul(o,s)),t.ONE),i=t.inv(n);return e.reduceRight((o,s,a)=>t.is0(s)?o:(r[a]=t.mul(o,r[a]),t.mul(o,s)),i),r}function Wc(t,e){let r=e!==void 0?e:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Ln(t,e,r=!1,n={}){if(t<=pe)throw new Error(`Expected Field ORDER > 0, got ${t}`);let{nBitLength:i,nByteLength:o}=Wc(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let s=QE(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:vi(i),ZERO:pe,ONE:se,create:c=>ee(c,t),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return pe<=c&&c<t},is0:c=>c===pe,isOdd:c=>(c&se)===se,neg:c=>ee(-c,t),eql:(c,f)=>c===f,sqr:c=>ee(c*c,t),add:(c,f)=>ee(c+f,t),sub:(c,f)=>ee(c-f,t),mul:(c,f)=>ee(c*f,t),pow:(c,f)=>t1(a,c,f),div:(c,f)=>ee(c*Zo(f,t),t),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Zo(c,t),sqrt:n.sqrt||(c=>s(a,c)),invertBatch:c=>r1(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>r?qt(c,o):ke(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return r?et(c):Mt(c)}});return Object.freeze(a)}function Tp(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 Bp(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 zc(t){let e=Bp(t);return e+Math.ceil(e/2)}function Pp(t,e,r=!1){let n=t.length,i=Bp(e),o=zc(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let s=r?Mt(t):et(t),a=ee(s,e-se)+se;return r?qt(a,i):ke(a,i)}var i1=BigInt(0),Yc=BigInt(1);function Xo(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,a=i;for(;o>i1;)o&Yc&&(s=s.add(a)),a=a.double(),o>>=Yc;return s},precomputeWindow(i,o){let{windows:s,windowSize:a}=n(o),c=[],f=i,u=f;for(let l=0;l<s;l++){u=f,c.push(u);for(let p=1;p<a;p++)u=u.add(f),c.push(u);f=u.double()}return c},wNAF(i,o,s){let{windows:a,windowSize:c}=n(i),f=t.ZERO,u=t.BASE,l=BigInt(2**i-1),p=2**i,y=BigInt(i);for(let d=0;d<a;d++){let h=d*c,m=Number(s&l);s>>=y,m>c&&(m-=p,s+=Yc);let g=h,x=h+Math.abs(m)-1,w=d%2!==0,T=m<0;m===0?u=u.add(r(w,o[g])):f=f.add(r(T,o[x]))}return{p:f,f:u}},wNAFCached(i,o,s,a){let c=i._WINDOW_SIZE||1,f=o.get(i);return f||(f=this.precomputeWindow(i,c),c!==1&&o.set(i,a(f))),this.wNAF(c,f,s)}}}function Ai(t){return Jc(t.Fp),$e(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Wc(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function o1(t){let e=Ai(t);$e(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:s1,hexToBytes:a1}=Yo,Yr={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(t){let{Err:e}=Yr;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:s1(n),l:t.subarray(r+2)}},toSig(t){let{Err:e}=Yr,r=typeof t=="string"?a1(t):t;if(!Qe(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}=Yr._parseInt(r.subarray(2)),{d:s,l:a}=Yr._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){let e=f=>Number.parseInt(f[0],16)&8?"00"+f:f,r=f=>{let u=f.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,a=r(o),c=r(s);return`30${r(s+o+4)}02${c}${i}02${a}${n}`}},Ft=BigInt(0),Ve=BigInt(1),oA=BigInt(2),kp=BigInt(3),sA=BigInt(4);function c1(t){let e=o1(t),{Fp:r}=e,n=e.toBytes||((d,h,m)=>{let g=h.toAffine();return jt(Uint8Array.from([4]),r.toBytes(g.x),r.toBytes(g.y))}),i=e.fromBytes||(d=>{let h=d.subarray(1),m=r.fromBytes(h.subarray(0,r.BYTES)),g=r.fromBytes(h.subarray(r.BYTES,2*r.BYTES));return{x:m,y:g}});function o(d){let{a:h,b:m}=e,g=r.sqr(d),x=r.mul(g,d);return r.add(r.add(x,r.mul(d,h)),m)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(d){return typeof d=="bigint"&&Ft<d&&d<e.n}function a(d){if(!s(d))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(d){let{allowedPrivateKeyLengths:h,nByteLength:m,wrapPrivateKey:g,n:x}=e;if(h&&typeof d!="bigint"){if(Qe(d)&&(d=Dt(d)),typeof d!="string"||!h.includes(d.length))throw new Error("Invalid key");d=d.padStart(m*2,"0")}let w;try{w=typeof d=="bigint"?d:Mt(ie("private key",d,m))}catch{throw new Error(`private key must be ${m} bytes, hex or bigint, not ${typeof d}`)}return g&&(w=ee(w,x)),a(w),w}let f=new Map;function u(d){if(!(d instanceof l))throw new Error("ProjectivePoint expected")}class l{constructor(h,m,g){if(this.px=h,this.py=m,this.pz=g,h==null||!r.isValid(h))throw new Error("x required");if(m==null||!r.isValid(m))throw new Error("y required");if(g==null||!r.isValid(g))throw new Error("z required")}static fromAffine(h){let{x:m,y:g}=h||{};if(!h||!r.isValid(m)||!r.isValid(g))throw new Error("invalid affine point");if(h instanceof l)throw new Error("projective point not allowed");let x=w=>r.eql(w,r.ZERO);return x(m)&&x(g)?l.ZERO:new l(m,g,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let m=r.invertBatch(h.map(g=>g.pz));return h.map((g,x)=>g.toAffine(m[x])).map(l.fromAffine)}static fromHex(h){let m=l.fromAffine(i(ie("pointHex",h)));return m.assertValidity(),m}static fromPrivateKey(h){return l.BASE.multiply(c(h))}_setWindowSize(h){this._WINDOW_SIZE=h,f.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:h,y:m}=this.toAffine();if(!r.isValid(h)||!r.isValid(m))throw new Error("bad point: x or y not FE");let g=r.sqr(m),x=o(h);if(!r.eql(g,x))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:h}=this.toAffine();if(r.isOdd)return!r.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){u(h);let{px:m,py:g,pz:x}=this,{px:w,py:T,pz:_}=h,A=r.eql(r.mul(m,_),r.mul(w,x)),I=r.eql(r.mul(g,_),r.mul(T,x));return A&&I}negate(){return new l(this.px,r.neg(this.py),this.pz)}double(){let{a:h,b:m}=e,g=r.mul(m,kp),{px:x,py:w,pz:T}=this,_=r.ZERO,A=r.ZERO,I=r.ZERO,B=r.mul(x,x),U=r.mul(w,w),O=r.mul(T,T),C=r.mul(x,w);return C=r.add(C,C),I=r.mul(x,T),I=r.add(I,I),_=r.mul(h,I),A=r.mul(g,O),A=r.add(_,A),_=r.sub(U,A),A=r.add(U,A),A=r.mul(_,A),_=r.mul(C,_),I=r.mul(g,I),O=r.mul(h,O),C=r.sub(B,O),C=r.mul(h,C),C=r.add(C,I),I=r.add(B,B),B=r.add(I,B),B=r.add(B,O),B=r.mul(B,C),A=r.add(A,B),O=r.mul(w,T),O=r.add(O,O),B=r.mul(O,C),_=r.sub(_,B),I=r.mul(O,U),I=r.add(I,I),I=r.add(I,I),new l(_,A,I)}add(h){u(h);let{px:m,py:g,pz:x}=this,{px:w,py:T,pz:_}=h,A=r.ZERO,I=r.ZERO,B=r.ZERO,U=e.a,O=r.mul(e.b,kp),C=r.mul(m,w),M=r.mul(g,T),j=r.mul(x,_),z=r.add(m,g),v=r.add(w,T);z=r.mul(z,v),v=r.add(C,M),z=r.sub(z,v),v=r.add(m,x);let k=r.add(w,_);return v=r.mul(v,k),k=r.add(C,j),v=r.sub(v,k),k=r.add(g,x),A=r.add(T,_),k=r.mul(k,A),A=r.add(M,j),k=r.sub(k,A),B=r.mul(U,v),A=r.mul(O,j),B=r.add(A,B),A=r.sub(M,B),B=r.add(M,B),I=r.mul(A,B),M=r.add(C,C),M=r.add(M,C),j=r.mul(U,j),v=r.mul(O,v),M=r.add(M,j),j=r.sub(C,j),j=r.mul(U,j),v=r.add(v,j),C=r.mul(M,v),I=r.add(I,C),C=r.mul(k,v),A=r.mul(z,A),A=r.sub(A,C),C=r.mul(z,M),B=r.mul(k,B),B=r.add(B,C),new l(A,I,B)}subtract(h){return this.add(h.negate())}is0(){return this.equals(l.ZERO)}wNAF(h){return y.wNAFCached(this,f,h,m=>{let g=r.invertBatch(m.map(x=>x.pz));return m.map((x,w)=>x.toAffine(g[w])).map(l.fromAffine)})}multiplyUnsafe(h){let m=l.ZERO;if(h===Ft)return m;if(a(h),h===Ve)return this;let{endo:g}=e;if(!g)return y.unsafeLadder(this,h);let{k1neg:x,k1:w,k2neg:T,k2:_}=g.splitScalar(h),A=m,I=m,B=this;for(;w>Ft||_>Ft;)w&Ve&&(A=A.add(B)),_&Ve&&(I=I.add(B)),B=B.double(),w>>=Ve,_>>=Ve;return x&&(A=A.negate()),T&&(I=I.negate()),I=new l(r.mul(I.px,g.beta),I.py,I.pz),A.add(I)}multiply(h){a(h);let m=h,g,x,{endo:w}=e;if(w){let{k1neg:T,k1:_,k2neg:A,k2:I}=w.splitScalar(m),{p:B,f:U}=this.wNAF(_),{p:O,f:C}=this.wNAF(I);B=y.constTimeNegate(T,B),O=y.constTimeNegate(A,O),O=new l(r.mul(O.px,w.beta),O.py,O.pz),g=B.add(O),x=U.add(C)}else{let{p:T,f:_}=this.wNAF(m);g=T,x=_}return l.normalizeZ([g,x])[0]}multiplyAndAddUnsafe(h,m,g){let x=l.BASE,w=(_,A)=>A===Ft||A===Ve||!_.equals(x)?_.multiplyUnsafe(A):_.multiply(A),T=w(this,m).add(w(h,g));return T.is0()?void 0:T}toAffine(h){let{px:m,py:g,pz:x}=this,w=this.is0();h==null&&(h=w?r.ONE:r.inv(x));let T=r.mul(m,h),_=r.mul(g,h),A=r.mul(x,h);if(w)return{x:r.ZERO,y:r.ZERO};if(!r.eql(A,r.ONE))throw new Error("invZ was invalid");return{x:T,y:_}}isTorsionFree(){let{h,isTorsionFree:m}=e;if(h===Ve)return!0;if(m)return m(l,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:m}=e;return h===Ve?this:m?m(l,this):this.multiplyUnsafe(e.h)}toRawBytes(h=!0){return this.assertValidity(),n(l,this,h)}toHex(h=!0){return Dt(this.toRawBytes(h))}}l.BASE=new l(e.Gx,e.Gy,r.ONE),l.ZERO=new l(r.ZERO,r.ONE,r.ZERO);let p=e.nBitLength,y=Xo(l,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:s}}function f1(t){let e=Ai(t);return $e(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Ip(t){let e=f1(t),{Fp:r,n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(v){return Ft<v&&v<r.ORDER}function a(v){return ee(v,n)}function c(v){return Zo(v,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:p}=c1({...e,toBytes(v,k,K){let S=k.toAffine(),b=r.toBytes(S.x),P=jt;return K?P(Uint8Array.from([k.hasEvenY()?2:3]),b):P(Uint8Array.from([4]),b,r.toBytes(S.y))},fromBytes(v){let k=v.length,K=v[0],S=v.subarray(1);if(k===i&&(K===2||K===3)){let b=Mt(S);if(!s(b))throw new Error("Point is not on curve");let P=l(b),R=r.sqrt(P),L=(R&Ve)===Ve;return(K&1)===1!==L&&(R=r.neg(R)),{x:b,y:R}}else if(k===o&&K===4){let b=r.fromBytes(S.subarray(0,r.BYTES)),P=r.fromBytes(S.subarray(r.BYTES,2*r.BYTES));return{x:b,y:P}}else throw new Error(`Point of length ${k} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}}),y=v=>Dt(ke(v,e.nByteLength));function d(v){let k=n>>Ve;return v>k}function h(v){return d(v)?a(-v):v}let m=(v,k,K)=>Mt(v.slice(k,K));class g{constructor(k,K,S){this.r=k,this.s=K,this.recovery=S,this.assertValidity()}static fromCompact(k){let K=e.nByteLength;return k=ie("compactSignature",k,K*2),new g(m(k,0,K),m(k,K,2*K))}static fromDER(k){let{r:K,s:S}=Yr.toSig(ie("DER",k));return new g(K,S)}assertValidity(){if(!p(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!p(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(k){return new g(this.r,this.s,k)}recoverPublicKey(k){let{r:K,s:S,recovery:b}=this,P=I(ie("msgHash",k));if(b==null||![0,1,2,3].includes(b))throw new Error("recovery id invalid");let R=b===2||b===3?K+e.n:K;if(R>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let L=b&1?"03":"02",F=f.fromHex(L+y(R)),$=c(R),Y=a(-P*$),V=a(S*$),H=f.BASE.multiplyAndAddUnsafe(F,Y,V);if(!H)throw new Error("point at infinify");return H.assertValidity(),H}hasHighS(){return d(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Wr(this.toDERHex())}toDERHex(){return Yr.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Wr(this.toCompactHex())}toCompactHex(){return y(this.r)+y(this.s)}}let x={isValidPrivateKey(v){try{return u(v),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let v=zc(e.n);return Pp(e.randomBytes(v),e.n)},precompute(v=8,k=f.BASE){return k._setWindowSize(v),k.multiply(BigInt(3)),k}};function w(v,k=!0){return f.fromPrivateKey(v).toRawBytes(k)}function T(v){let k=Qe(v),K=typeof v=="string",S=(k||K)&&v.length;return k?S===i||S===o:K?S===2*i||S===2*o:v instanceof f}function _(v,k,K=!0){if(T(v))throw new Error("first arg must be private key");if(!T(k))throw new Error("second arg must be public key");return f.fromHex(k).multiply(u(v)).toRawBytes(K)}let A=e.bits2int||function(v){let k=Mt(v),K=v.length*8-e.nBitLength;return K>0?k>>BigInt(K):k},I=e.bits2int_modN||function(v){return a(A(v))},B=vi(e.nBitLength);function U(v){if(typeof v!="bigint")throw new Error("bigint expected");if(!(Ft<=v&&v<B))throw new Error(`bigint expected < 2^${e.nBitLength}`);return ke(v,e.nByteLength)}function O(v,k,K=C){if(["recovered","canonical"].some(te=>te in K))throw new Error("sign() legacy options not supported");let{hash:S,randomBytes:b}=e,{lowS:P,prehash:R,extraEntropy:L}=K;P==null&&(P=!0),v=ie("msgHash",v),R&&(v=ie("prehashed msgHash",S(v)));let F=I(v),$=u(k),Y=[U($),U(F)];if(L!=null){let te=L===!0?b(r.BYTES):L;Y.push(ie("extraEntropy",te))}let V=jt(...Y),H=F;function ne(te){let we=A(te);if(!p(we))return;let me=c(we),de=f.BASE.multiply(we).toAffine(),xe=a(de.x);if(xe===Ft)return;let xt=a(me*a(H+xe*$));if(xt===Ft)return;let dr=(de.x===xe?0:2)|Number(de.y&Ve),Nn=xt;return P&&d(xt)&&(Nn=h(xt),dr^=1),new g(xe,Nn,dr)}return{seed:V,k2sig:ne}}let C={lowS:e.lowS,prehash:!1},M={lowS:e.lowS,prehash:!1};function j(v,k,K=C){let{seed:S,k2sig:b}=O(v,k,K),P=e;return Vc(P.hash.outputLen,P.nByteLength,P.hmac)(S,b)}f.BASE._setWindowSize(8);function z(v,k,K,S=M){let b=v;if(k=ie("msgHash",k),K=ie("publicKey",K),"strict"in S)throw new Error("options.strict was renamed to lowS");let{lowS:P,prehash:R}=S,L,F;try{if(typeof b=="string"||Qe(b))try{L=g.fromDER(b)}catch(de){if(!(de instanceof Yr.Err))throw de;L=g.fromCompact(b)}else if(typeof b=="object"&&typeof b.r=="bigint"&&typeof b.s=="bigint"){let{r:de,s:xe}=b;L=new g(de,xe)}else throw new Error("PARSE");F=f.fromHex(K)}catch(de){if(de.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(P&&L.hasHighS())return!1;R&&(k=e.hash(k));let{r:$,s:Y}=L,V=I(k),H=c(Y),ne=a(V*H),te=a($*H),we=f.BASE.multiplyAndAddUnsafe(F,ne,te)?.toAffine();return we?a(we.x)===$:!1}return{CURVE:e,getPublicKey:w,getSharedSecret:_,sign:j,verify:z,ProjectivePoint:f,Signature:g,utils:x}}var Qo=class extends Un{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,wp(e);let n=Ei(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;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),o.fill(0)}update(e){return Rn(this),this.iHash.update(e),this}digestInto(e){Rn(this),Mc(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=o,e.blockLen=s,e.outputLen=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Zc=(t,e,r)=>new Qo(t,e).update(r).digest();Zc.create=(t,e)=>new Qo(t,e);function u1(t){return{hash:t,hmac:(e,...r)=>Zc(t,e,Hr(...r)),randomBytes:Gr}}function es(t,e){let r=n=>Ip({...t,...u1(n)});return Object.freeze({...r(e),create:r})}var Cp=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Rp=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),l1=BigInt(1),Xc=BigInt(2),Up=(t,e)=>(t+e/Xc)/e;function d1(t){let e=Cp,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=t*t*t%e,u=f*f*t%e,l=oe(u,r,e)*u%e,p=oe(l,r,e)*u%e,y=oe(p,Xc,e)*f%e,d=oe(y,i,e)*y%e,h=oe(d,o,e)*d%e,m=oe(h,a,e)*h%e,g=oe(m,c,e)*m%e,x=oe(g,a,e)*h%e,w=oe(x,r,e)*u%e,T=oe(w,s,e)*d%e,_=oe(T,n,e)*f%e,A=oe(_,Xc,e);if(!Qc.eql(Qc.sqr(A),t))throw new Error("Cannot find square root");return A}var Qc=Ln(Cp,void 0,void 0,{sqrt:d1}),Ie=es({a:BigInt(0),b:BigInt(7),Fp:Qc,n:Rp,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{let e=Rp,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-l1*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=Up(o*t,e),c=Up(-n*t,e),f=ee(t-a*r-c*i,e),u=ee(-a*n-c*o,e),l=f>s,p=u>s;if(l&&(f=e-f),p&&(u=e-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:l,k1:f,k2neg:p,k2:u}}}},Pe),bA=BigInt(0);var gA=Ie.ProjectivePoint;function ef(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 ts="urn:jwk:";async function G({jwk:t}){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}`);Ss(r);let n=ef(r),i=q.string(n).toUint8Array(),o=await Jr.digest({data:i});return q.uint8Array(o).toBase64Url()}function tt(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 Zr(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 $t(t){return!(!t||typeof t!="object"||!("kty"in t&&"k"in t)||t.kty!=="oct"||typeof t.k!="string")}function rt(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 Xr(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 tf(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}}function h1(t){if(!t||typeof t!="object")return!1;switch(t.kty){case"EC":case"OKP":return"x"in t&&!("d"in t);case"RSA":return"n"in t&&"e"in t&&!("d"in t);default:return!1}}var Vt=class t{static async adjustSignatureToLowS({signature:e}){let r=Ie.Signature.fromCompact(e);return r.hasHighS()?r.normalizeS().toCompactRawBytes():e}static async bytesToPrivateKey({privateKeyBytes:e}){let r=await t.getCurvePoint({keyBytes:e}),n={kty:"EC",crv:"secp256k1",d:q.uint8Array(e).toBase64Url(),x:q.uint8Array(r.x).toBase64Url(),y:q.uint8Array(r.y).toBase64Url()};return n.kid=await G({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:e}){let r=await t.getCurvePoint({keyBytes:e}),n={kty:"EC",crv:"secp256k1",x:q.uint8Array(r.x).toBase64Url(),y:q.uint8Array(r.y).toBase64Url()};return n.kid=await G({jwk:n}),n}static async compressPublicKey({publicKeyBytes:e}){return Ie.ProjectivePoint.fromHex(e).toRawBytes(!0)}static async computePublicKey({key:e}){let r=await t.privateKeyToBytes({privateKey:e}),n=await t.getCurvePoint({keyBytes:r}),i={kty:"EC",crv:"secp256k1",x:q.uint8Array(n.x).toBase64Url(),y:q.uint8Array(n.y).toBase64Url()};return i.kid=await G({jwk:i}),i}static async convertDerToCompactSignature({derSignature:e}){return Ie.Signature.fromDER(e).toCompactRawBytes()}static async decompressPublicKey({publicKeyBytes:e}){return Ie.ProjectivePoint.fromHex(e).toRawBytes(!1)}static async generateKey(){let e=Ie.utils.randomPrivateKey(),r=await t.bytesToPrivateKey({privateKeyBytes:e});return r.kid=await G({jwk:r}),r}static async getPublicKey({key:e}){if(!(tt(e)&&e.crv==="secp256k1"))throw new Error("Secp256k1: The provided key is not a secp256k1 private JWK.");let{d:r,...n}=e;return n.kid??=await G({jwk:n}),n}static async privateKeyToBytes({privateKey:e}){if(!tt(e))throw new Error("Secp256k1: The provided key is not a valid EC private key.");return q.base64Url(e.d).toUint8Array()}static async publicKeyToBytes({publicKey:e}){if(!(Zr(e)&&e.y))throw new Error("Secp256k1: The provided key is not a valid EC public key.");let r=new Uint8Array([4]),n=q.base64Url(e.x).toUint8Array(),i=q.base64Url(e.y).toUint8Array();return new Uint8Array([...r,...n,...i])}static async sharedSecret({privateKeyA:e,publicKeyB:r}){if("x"in e&&"x"in r&&e.x===r.x)throw new Error("Secp256k1: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=await t.privateKeyToBytes({privateKey:e}),i=await t.publicKeyToBytes({publicKey:r});return Ie.getSharedSecret(n,i,!0).slice(1)}static async sign({data:e,key:r}){let n=await t.privateKeyToBytes({privateKey:r}),i=Pe(e);return Ie.sign(i,n).toCompactRawBytes()}static async validatePrivateKey({privateKeyBytes:e}){return Ie.utils.isValidPrivateKey(e)}static async validatePublicKey({publicKeyBytes:e}){try{Ie.ProjectivePoint.fromHex(e).assertValidity()}catch{return!1}return!0}static async verify({key:e,signature:r,data:n}){let i=await t.publicKeyToBytes({publicKey:e}),o=Pe(n);return Ie.verify(r,o,i,{lowS:!1})}static async getCurvePoint({keyBytes:e}){e.byteLength===32&&(e=Ie.getPublicKey(e));let r=Ie.ProjectivePoint.fromHex(e),n=ke(r.x,32),i=ke(r.y,32);return{x:n,y:i}}};var Lp=Ln(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),p1=Lp.create(BigInt("-3")),y1=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),w1=es({a:p1,b:y1,Fp:Lp,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},Pe),Oe=w1;var Ht=class t{static async adjustSignatureToLowS({signature:e}){let r=Oe.Signature.fromCompact(e);return r.hasHighS()?r.normalizeS().toCompactRawBytes():e}static async bytesToPrivateKey({privateKeyBytes:e}){let r=await t.getCurvePoint({keyBytes:e}),n={kty:"EC",crv:"P-256",d:q.uint8Array(e).toBase64Url(),x:q.uint8Array(r.x).toBase64Url(),y:q.uint8Array(r.y).toBase64Url()};return n.kid=await G({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:e}){let r=await t.getCurvePoint({keyBytes:e}),n={kty:"EC",crv:"P-256",x:q.uint8Array(r.x).toBase64Url(),y:q.uint8Array(r.y).toBase64Url()};return n.kid=await G({jwk:n}),n}static async compressPublicKey({publicKeyBytes:e}){return Oe.ProjectivePoint.fromHex(e).toRawBytes(!0)}static async computePublicKey({key:e}){let r=await t.privateKeyToBytes({privateKey:e}),n=await t.getCurvePoint({keyBytes:r}),i={kty:"EC",crv:"P-256",x:q.uint8Array(n.x).toBase64Url(),y:q.uint8Array(n.y).toBase64Url()};return i.kid=await G({jwk:i}),i}static async convertDerToCompactSignature({derSignature:e}){return Oe.Signature.fromDER(e).toCompactRawBytes()}static async decompressPublicKey({publicKeyBytes:e}){return Oe.ProjectivePoint.fromHex(e).toRawBytes(!1)}static async generateKey(){let e=Oe.utils.randomPrivateKey(),r=await t.bytesToPrivateKey({privateKeyBytes:e});return r.kid=await G({jwk:r}),r}static async getPublicKey({key:e}){if(!(tt(e)&&e.crv==="P-256"))throw new Error("Secp256r1: The provided key is not a 'P-256' private JWK.");let{d:r,...n}=e;return n.kid??=await G({jwk:n}),n}static async privateKeyToBytes({privateKey:e}){if(!tt(e))throw new Error("Secp256r1: The provided key is not a valid EC private key.");return q.base64Url(e.d).toUint8Array()}static async publicKeyToBytes({publicKey:e}){if(!(Zr(e)&&e.y))throw new Error("Secp256r1: The provided key is not a valid EC public key.");let r=new Uint8Array([4]),n=q.base64Url(e.x).toUint8Array(),i=q.base64Url(e.y).toUint8Array();return new Uint8Array([...r,...n,...i])}static async sharedSecret({privateKeyA:e,publicKeyB:r}){if("x"in e&&"x"in r&&e.x===r.x)throw new Error("Secp256r1: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=await t.privateKeyToBytes({privateKey:e}),i=await t.publicKeyToBytes({publicKey:r});return Oe.getSharedSecret(n,i,!0).slice(1)}static async sign({data:e,key:r}){let n=await t.privateKeyToBytes({privateKey:r}),i=Pe(e);return Oe.sign(i,n).toCompactRawBytes()}static async validatePrivateKey({privateKeyBytes:e}){return Oe.utils.isValidPrivateKey(e)}static async validatePublicKey({publicKeyBytes:e}){try{Oe.ProjectivePoint.fromHex(e).assertValidity()}catch{return!1}return!0}static async verify({key:e,signature:r,data:n}){let i=await t.publicKeyToBytes({publicKey:e}),o=Pe(n);return Oe.verify(r,o,i,{lowS:!1})}static async getCurvePoint({keyBytes:e}){e.byteLength===32&&(e=Oe.getPublicKey(e));let r=Oe.ProjectivePoint.fromHex(e),n=ke(r.x,32),i=ke(r.y,32);return{x:n,y:i}}};var On=class extends Le{async computePublicKey({key:e}){if(!tt(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":{let r=await Vt.computePublicKey({key:e});return r.alg="ES256K",r}case"P-256":{let r=await Ht.computePublicKey({key:e});return r.alg="ES256",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}}async generateKey({algorithm:e}){switch(e){case"ES256K":case"secp256k1":{let r=await Vt.generateKey();return r.alg="ES256K",r}case"ES256":case"secp256r1":{let r=await Ht.generateKey();return r.alg="ES256",r}}}async getPublicKey({key:e}){if(!tt(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":{let r=await Vt.getPublicKey({key:e});return r.alg="ES256K",r}case"P-256":{let r=await Ht.getPublicKey({key:e});return r.alg="ES256",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}}async sign({key:e,data:r}){if(!tt(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) private key.");switch(e.crv){case"secp256k1":return await Vt.sign({key:e,data:r});case"P-256":return await Ht.sign({key:e,data:r});default:throw new Error(`Unsupported curve: ${e.crv}`)}}async verify({key:e,signature:r,data:n}){if(!Zr(e))throw new TypeError("Invalid key provided. Must be an elliptic curve (EC) public key.");switch(e.crv){case"secp256k1":return await Vt.verify({key:e,signature:r,data:n});case"P-256":return await Ht.verify({key:e,signature:r,data:n});default:throw new Error(`Unsupported curve: ${e.crv}`)}}};var rs=BigInt(4294967295),rf=BigInt(32);function Op(t,e=!1){return e?{h:Number(t&rs),l:Number(t>>rf&rs)}:{h:Number(t>>rf&rs)|0,l:Number(t&rs)|0}}function m1(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){let{h:o,l:s}=Op(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]}var b1=(t,e)=>BigInt(t>>>0)<<rf|BigInt(e>>>0),g1=(t,e,r)=>t>>>r,x1=(t,e,r)=>t<<32-r|e>>>r,E1=(t,e,r)=>t>>>r|e<<32-r,_1=(t,e,r)=>t<<32-r|e>>>r,v1=(t,e,r)=>t<<64-r|e>>>r-32,A1=(t,e,r)=>t>>>r-32|e<<64-r,S1=(t,e)=>e,T1=(t,e)=>t,B1=(t,e,r)=>t<<r|e>>>32-r,P1=(t,e,r)=>e<<r|t>>>32-r,k1=(t,e,r)=>e<<r-32|t>>>64-r,I1=(t,e,r)=>t<<r-32|e>>>64-r;function R1(t,e,r,n){let i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}var U1=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),C1=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,L1=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),O1=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,K1=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),N1=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;var D1={fromBig:Op,split:m1,toBig:b1,shrSH:g1,shrSL:x1,rotrSH:E1,rotrSL:_1,rotrBH:v1,rotrBL:A1,rotr32H:S1,rotr32L:T1,rotlSH:B1,rotlSL:P1,rotlBH:k1,rotlBL:I1,add:R1,add3L:U1,add3H:C1,add4L:L1,add4H:O1,add5H:N1,add5L:K1},J=D1;var[M1,q1]=J.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))),fr=new Uint32Array(80),ur=new Uint32Array(80),nf=class extends Cn{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:a,Dl:c,Eh:f,El:u,Fh:l,Fl:p,Gh:y,Gl:d,Hh:h,Hl:m}=this;return[e,r,n,i,o,s,a,c,f,u,l,p,y,d,h,m]}set(e,r,n,i,o,s,a,c,f,u,l,p,y,d,h,m){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=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=p|0,this.Gh=y|0,this.Gl=d|0,this.Hh=h|0,this.Hl=m|0}process(e,r){for(let w=0;w<16;w++,r+=4)fr[w]=e.getUint32(r),ur[w]=e.getUint32(r+=4);for(let w=16;w<80;w++){let T=fr[w-15]|0,_=ur[w-15]|0,A=J.rotrSH(T,_,1)^J.rotrSH(T,_,8)^J.shrSH(T,_,7),I=J.rotrSL(T,_,1)^J.rotrSL(T,_,8)^J.shrSL(T,_,7),B=fr[w-2]|0,U=ur[w-2]|0,O=J.rotrSH(B,U,19)^J.rotrBH(B,U,61)^J.shrSH(B,U,6),C=J.rotrSL(B,U,19)^J.rotrBL(B,U,61)^J.shrSL(B,U,6),M=J.add4L(I,C,ur[w-7],ur[w-16]),j=J.add4H(M,A,O,fr[w-7],fr[w-16]);fr[w]=j|0,ur[w]=M|0}let{Ah:n,Al:i,Bh:o,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:p,Fh:y,Fl:d,Gh:h,Gl:m,Hh:g,Hl:x}=this;for(let w=0;w<80;w++){let T=J.rotrSH(l,p,14)^J.rotrSH(l,p,18)^J.rotrBH(l,p,41),_=J.rotrSL(l,p,14)^J.rotrSL(l,p,18)^J.rotrBL(l,p,41),A=l&y^~l&h,I=p&d^~p&m,B=J.add5L(x,_,I,q1[w],ur[w]),U=J.add5H(B,g,T,A,M1[w],fr[w]),O=B|0,C=J.rotrSH(n,i,28)^J.rotrBH(n,i,34)^J.rotrBH(n,i,39),M=J.rotrSL(n,i,28)^J.rotrBL(n,i,34)^J.rotrBL(n,i,39),j=n&o^n&a^o&a,z=i&s^i&c^s&c;g=h|0,x=m|0,h=y|0,m=d|0,y=l|0,d=p|0,{h:l,l:p}=J.add(f|0,u|0,U|0,O|0),f=a|0,u=c|0,a=o|0,c=s|0,o=n|0,s=i|0;let v=J.add3L(O,M,z);n=J.add3H(v,U,C,j),i=v|0}({h:n,l:i}=J.add(this.Ah|0,this.Al|0,n|0,i|0)),{h:o,l:s}=J.add(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:c}=J.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=J.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:p}=J.add(this.Eh|0,this.El|0,l|0,p|0),{h:y,l:d}=J.add(this.Fh|0,this.Fl|0,y|0,d|0),{h,l:m}=J.add(this.Gh|0,this.Gl|0,h|0,m|0),{h:g,l:x}=J.add(this.Hh|0,this.Hl|0,g|0,x|0),this.set(n,i,o,s,a,c,f,u,l,p,y,d,h,m,g,x)}roundClean(){fr.fill(0),ur.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 of=Wo(()=>new nf);var nt=BigInt(0),Ke=BigInt(1),ns=BigInt(2),j1=BigInt(8),F1={zip215:!0};function $1(t){let e=Ai(t);return $e(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function is(t){let e=$1(t),{Fp:r,n,prehash:i,hash:o,randomBytes:s,nByteLength:a,h:c}=e,f=ns<<BigInt(a*8)-Ke,u=r.create,l=e.uvRatio||((S,b)=>{try{return{isValid:!0,value:r.sqrt(S*r.inv(b))}}catch{return{isValid:!1,value:nt}}}),p=e.adjustScalarBytes||(S=>S),y=e.domain||((S,b,P)=>{if(b.length||P)throw new Error("Contexts/pre-hash are not supported");return S}),d=S=>typeof S=="bigint"&&nt<S,h=(S,b)=>d(S)&&d(b)&&S<b,m=S=>S===nt||h(S,f);function g(S,b){if(h(S,b))return S;throw new Error(`Expected valid scalar < ${b}, got ${typeof S} ${S}`)}function x(S){return S===nt?S:g(S,n)}let w=new Map;function T(S){if(!(S instanceof _))throw new Error("ExtendedPoint expected")}class _{constructor(b,P,R,L){if(this.ex=b,this.ey=P,this.ez=R,this.et=L,!m(b))throw new Error("x required");if(!m(P))throw new Error("y required");if(!m(R))throw new Error("z required");if(!m(L))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(b){if(b instanceof _)throw new Error("extended point not allowed");let{x:P,y:R}=b||{};if(!m(P)||!m(R))throw new Error("invalid affine point");return new _(P,R,Ke,u(P*R))}static normalizeZ(b){let P=r.invertBatch(b.map(R=>R.ez));return b.map((R,L)=>R.toAffine(P[L])).map(_.fromAffine)}_setWindowSize(b){this._WINDOW_SIZE=b,w.delete(this)}assertValidity(){let{a:b,d:P}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:R,ey:L,ez:F,et:$}=this,Y=u(R*R),V=u(L*L),H=u(F*F),ne=u(H*H),te=u(Y*b),we=u(H*u(te+V)),me=u(ne+u(P*u(Y*V)));if(we!==me)throw new Error("bad point: equation left != right (1)");let de=u(R*L),xe=u(F*$);if(de!==xe)throw new Error("bad point: equation left != right (2)")}equals(b){T(b);let{ex:P,ey:R,ez:L}=this,{ex:F,ey:$,ez:Y}=b,V=u(P*Y),H=u(F*L),ne=u(R*Y),te=u($*L);return V===H&&ne===te}is0(){return this.equals(_.ZERO)}negate(){return new _(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:b}=e,{ex:P,ey:R,ez:L}=this,F=u(P*P),$=u(R*R),Y=u(ns*u(L*L)),V=u(b*F),H=P+R,ne=u(u(H*H)-F-$),te=V+$,we=te-Y,me=V-$,de=u(ne*we),xe=u(te*me),xt=u(ne*me),dr=u(we*te);return new _(de,xe,dr,xt)}add(b){T(b);let{a:P,d:R}=e,{ex:L,ey:F,ez:$,et:Y}=this,{ex:V,ey:H,ez:ne,et:te}=b;if(P===BigInt(-1)){let Bf=u((F-L)*(H+V)),Pf=u((F+L)*(H-V)),ls=u(Pf-Bf);if(ls===nt)return this.double();let kf=u($*ns*te),If=u(Y*ns*ne),Rf=If+kf,Uf=Pf+Bf,Cf=If-kf,fy=u(Rf*ls),uy=u(Uf*Cf),ly=u(Rf*Cf),dy=u(ls*Uf);return new _(fy,uy,dy,ly)}let we=u(L*V),me=u(F*H),de=u(Y*R*te),xe=u($*ne),xt=u((L+F)*(V+H)-we-me),dr=xe-de,Nn=xe+de,Tf=u(me-P*we),oy=u(xt*dr),sy=u(Nn*Tf),ay=u(xt*Tf),cy=u(dr*Nn);return new _(oy,sy,cy,ay)}subtract(b){return this.add(b.negate())}wNAF(b){return B.wNAFCached(this,w,b,_.normalizeZ)}multiply(b){let{p:P,f:R}=this.wNAF(g(b,n));return _.normalizeZ([P,R])[0]}multiplyUnsafe(b){let P=x(b);return P===nt?I:this.equals(I)||P===Ke?this:this.equals(A)?this.wNAF(P).p:B.unsafeLadder(this,P)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return B.unsafeLadder(this,n).is0()}toAffine(b){let{ex:P,ey:R,ez:L}=this,F=this.is0();b==null&&(b=F?j1:r.inv(L));let $=u(P*b),Y=u(R*b),V=u(L*b);if(F)return{x:nt,y:Ke};if(V!==Ke)throw new Error("invZ was invalid");return{x:$,y:Y}}clearCofactor(){let{h:b}=e;return b===Ke?this:this.multiplyUnsafe(b)}static fromHex(b,P=!1){let{d:R,a:L}=e,F=r.BYTES;b=ie("pointHex",b,F);let $=b.slice(),Y=b[F-1];$[F-1]=Y&-129;let V=et($);V===nt||(P?g(V,f):g(V,r.ORDER));let H=u(V*V),ne=u(H-Ke),te=u(R*H-L),{isValid:we,value:me}=l(ne,te);if(!we)throw new Error("Point.fromHex: invalid y coordinate");let de=(me&Ke)===Ke,xe=(Y&128)!==0;if(!P&&me===nt&&xe)throw new Error("Point.fromHex: x=0 and x_0=1");return xe!==de&&(me=u(-me)),_.fromAffine({x:me,y:V})}static fromPrivateKey(b){return C(b).point}toRawBytes(){let{x:b,y:P}=this.toAffine(),R=qt(P,r.BYTES);return R[R.length-1]|=b&Ke?128:0,R}toHex(){return Dt(this.toRawBytes())}}_.BASE=new _(e.Gx,e.Gy,Ke,u(e.Gx*e.Gy)),_.ZERO=new _(nt,Ke,Ke,nt);let{BASE:A,ZERO:I}=_,B=Xo(_,a*8);function U(S){return ee(S,n)}function O(S){return U(et(S))}function C(S){let b=a;S=ie("private key",S,b);let P=ie("hashed private key",o(S),2*b),R=p(P.slice(0,b)),L=P.slice(b,2*b),F=O(R),$=A.multiply(F),Y=$.toRawBytes();return{head:R,prefix:L,scalar:F,point:$,pointBytes:Y}}function M(S){return C(S).pointBytes}function j(S=new Uint8Array,...b){let P=jt(...b);return O(o(y(P,ie("context",S),!!i)))}function z(S,b,P={}){S=ie("message",S),i&&(S=i(S));let{prefix:R,scalar:L,pointBytes:F}=C(b),$=j(P.context,R,S),Y=A.multiply($).toRawBytes(),V=j(P.context,Y,F,S),H=U($+V*L);x(H);let ne=jt(Y,qt(H,r.BYTES));return ie("result",ne,a*2)}let v=F1;function k(S,b,P,R=v){let{context:L,zip215:F}=R,$=r.BYTES;S=ie("signature",S,2*$),b=ie("message",b),i&&(b=i(b));let Y=et(S.slice($,2*$)),V,H,ne;try{V=_.fromHex(P,F),H=_.fromHex(S.slice(0,$),F),ne=A.multiplyUnsafe(Y)}catch{return!1}if(!F&&V.isSmallOrder())return!1;let te=j(L,H.toRawBytes(),V.toRawBytes(),b);return H.add(V.multiplyUnsafe(te)).subtract(ne).clearCofactor().equals(_.ZERO)}return A._setWindowSize(8),{CURVE:e,getPublicKey:M,sign:z,verify:k,ExtendedPoint:_,utils:{getExtendedPublicKey:C,randomPrivateKey:()=>s(r.BYTES),precompute(S=8,b=_.BASE){return b._setWindowSize(S),b.multiply(BigInt(3)),b}}}}var Si=BigInt(0),sf=BigInt(1);function V1(t){return $e(t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...t})}function Kp(t){let e=V1(t),{P:r}=e,n=w=>ee(w,r),i=e.montgomeryBits,o=Math.ceil(i/8),s=e.nByteLength,a=e.adjustScalarBytes||(w=>w),c=e.powPminus2||(w=>Gc(w,r-BigInt(2),r));function f(w,T,_){let A=n(w*(T-_));return T=n(T-A),_=n(_+A),[T,_]}function u(w){if(typeof w=="bigint"&&Si<=w&&w<r)return w;throw new Error("Expected valid scalar 0 < scalar < CURVE.P")}let l=(e.a-BigInt(2))/BigInt(4);function p(w,T){let _=u(w),A=u(T),I=_,B=sf,U=Si,O=_,C=sf,M=Si,j;for(let v=BigInt(i-1);v>=Si;v--){let k=A>>v&sf;M^=k,j=f(M,B,O),B=j[0],O=j[1],j=f(M,U,C),U=j[0],C=j[1],M=k;let K=B+U,S=n(K*K),b=B-U,P=n(b*b),R=S-P,L=O+C,F=O-C,$=n(F*K),Y=n(L*b),V=$+Y,H=$-Y;O=n(V*V),C=n(I*n(H*H)),B=n(S*P),U=n(R*(S+n(l*R)))}j=f(M,B,O),B=j[0],O=j[1],j=f(M,U,C),U=j[0],C=j[1];let z=c(U);return n(B*z)}function y(w){return qt(n(w),o)}function d(w){let T=ie("u coordinate",w,o);return s===32&&(T[31]&=127),et(T)}function h(w){let T=ie("scalar",w),_=T.length;if(_!==o&&_!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${_}`);return et(a(T))}function m(w,T){let _=d(T),A=h(w),I=p(_,A);if(I===Si)throw new Error("Invalid private or public key received");return y(I)}let g=y(e.Gu);function x(w){return m(w,g)}return{scalarMult:m,scalarMultBase:x,getSharedSecret:(w,T)=>m(w,T),getPublicKey:w=>x(w),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:g}}var Ti=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Np=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),uS=BigInt(0),H1=BigInt(1),af=BigInt(2),G1=BigInt(5),Dp=BigInt(10),J1=BigInt(20),W1=BigInt(40),Mp=BigInt(80);function qp(t){let e=Ti,n=t*t%e*t%e,i=oe(n,af,e)*n%e,o=oe(i,H1,e)*t%e,s=oe(o,G1,e)*o%e,a=oe(s,Dp,e)*s%e,c=oe(a,J1,e)*a%e,f=oe(c,W1,e)*c%e,u=oe(f,Mp,e)*f%e,l=oe(u,Mp,e)*f%e,p=oe(l,Dp,e)*s%e;return{pow_p_5_8:oe(p,af,e)*t%e,b2:n}}function jp(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function z1(t,e){let r=Ti,n=ee(e*e*e,r),i=ee(n*n*e,r),o=qp(t*i).pow_p_5_8,s=ee(t*n*o,r),a=ee(e*s*s,r),c=s,f=ee(s*Np,r),u=a===t,l=a===ee(-t,r),p=a===ee(-t*Np,r);return u&&(s=c),(l||p)&&(s=f),Sp(s,r)&&(s=ee(-s,r)),{isValid:u||l,value:s}}var He=Ln(Ti,void 0,!0),Bi={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:He,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:of,randomBytes:Gr,adjustScalarBytes:jp,uvRatio:z1},lr=is(Bi);function Fp(t,e,r){if(e.length>255)throw new Error("Context is too big");return Hr(qc("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,e.length]),e,t)}var lS=is({...Bi,domain:Fp}),dS=is({...Bi,domain:Fp,prehash:of}),Qr=Kp({P:Ti,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:t=>{let e=Ti,{pow_p_5_8:r,b2:n}=qp(t);return ee(oe(r,BigInt(3),e)*n,e)},adjustScalarBytes:jp,randomBytes:Gr});function $p(t){let{y:e}=lr.ExtendedPoint.fromHex(t),r=BigInt(1);return He.toBytes(He.create((r+e)*He.inv(r-e)))}function Vp(t){let e=Bi.hash(t.subarray(0,32));return Bi.adjustScalarBytes(e).subarray(0,32)}var Y1=(He.ORDER+BigInt(3))/BigInt(8),hS=He.pow(af,Y1),pS=He.sqrt(He.neg(He.ONE)),yS=(He.ORDER-BigInt(5))/BigInt(8),wS=BigInt(486662);var mS=Tp(He,He.neg(BigInt(486664)));var bS=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),gS=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),xS=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),ES=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var _S=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Gt=class t{static async bytesToPrivateKey({privateKeyBytes:e}){let r=lr.getPublicKey(e),n={crv:"Ed25519",d:q.uint8Array(e).toBase64Url(),kty:"OKP",x:q.uint8Array(r).toBase64Url()};return n.kid=await G({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:e}){let r={kty:"OKP",crv:"Ed25519",x:q.uint8Array(e).toBase64Url()};return r.kid=await G({jwk:r}),r}static async computePublicKey({key:e}){let r=await t.privateKeyToBytes({privateKey:e}),n=lr.getPublicKey(r),i={kty:"OKP",crv:"Ed25519",x:q.uint8Array(n).toBase64Url()};return i.kid=await G({jwk:i}),i}static async convertPrivateKeyToX25519({privateKey:e}){let r=await t.privateKeyToBytes({privateKey:e}),n=Vp(r),i=Qr.getPublicKey(n),o={kty:"OKP",crv:"X25519",d:q.uint8Array(n).toBase64Url(),x:q.uint8Array(i).toBase64Url()};return o.kid=await G({jwk:o}),o}static async convertPublicKeyToX25519({publicKey:e}){let r=await t.publicKeyToBytes({publicKey:e});if(!await t.validatePublicKey({publicKeyBytes:r}))throw new Error("Ed25519: Invalid public key.");let i=$p(r),o={kty:"OKP",crv:"X25519",x:q.uint8Array(i).toBase64Url()};return o.kid=await G({jwk:o}),o}static async generateKey(){let e=lr.utils.randomPrivateKey(),r=await t.bytesToPrivateKey({privateKeyBytes:e});return r.kid=await G({jwk:r}),r}static async getPublicKey({key:e}){if(!(rt(e)&&e.crv==="Ed25519"))throw new Error("Ed25519: The provided key is not an Ed25519 private JWK.");let{d:r,...n}=e;return n.kid??=await G({jwk:n}),n}static async privateKeyToBytes({privateKey:e}){if(!rt(e))throw new Error("Ed25519: The provided key is not a valid OKP private key.");return q.base64Url(e.d).toUint8Array()}static async publicKeyToBytes({publicKey:e}){if(!Xr(e))throw new Error("Ed25519: The provided key is not a valid OKP public key.");return q.base64Url(e.x).toUint8Array()}static async sign({key:e,data:r}){let n=await t.privateKeyToBytes({privateKey:e});return lr.sign(r,n)}static async validatePublicKey({publicKeyBytes:e}){try{lr.ExtendedPoint.fromHex(e).assertValidity()}catch{return!1}return!0}static async verify({key:e,signature:r,data:n}){let i=await t.publicKeyToBytes({publicKey:e});return lr.verify(r,n,i)}};var Pi=class extends Le{async computePublicKey({key:e}){if(!rt(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":{let r=await Gt.computePublicKey({key:e});return r.alg="EdDSA",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}}async generateKey({algorithm:e}){switch(e){case"Ed25519":{let r=await Gt.generateKey();return r.alg="EdDSA",r}}}async getPublicKey({key:e}){if(!rt(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":{let r=await Gt.getPublicKey({key:e});return r.alg="EdDSA",r}default:throw new Error(`Unsupported curve: ${e.crv}`)}}async sign({key:e,data:r}){if(!rt(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) private key.");switch(e.crv){case"Ed25519":return await Gt.sign({key:e,data:r});default:throw new Error(`Unsupported curve: ${e.crv}`)}}async verify({key:e,signature:r,data:n}){if(!Xr(e))throw new TypeError("Invalid key provided. Must be an octet key pair (OKP) public key.");switch(e.crv){case"Ed25519":return await Gt.verify({key:e,signature:r,data:n});default:throw new Error(`Unsupported curve: ${e.crv}`)}}};var cf={Ed25519:{implementation:Pi,names:["Ed25519"]},secp256k1:{implementation:On,names:["ES256K","secp256k1"]},secp256r1:{implementation:On,names:["ES256","secp256r1"]},"SHA-256":{implementation:_i,names:["SHA-256"]}},ff=class{constructor(e){this._algorithmInstances=new Map;this._keyStore=e?.keyStore??new yo}async digest({algorithm:e,data:r}){return await this.getAlgorithm({algorithm:e}).digest({algorithm:e,data:r})}async exportKey({keyUri:e}){return await this.getPrivateKey({keyUri:e})}async generateKey({algorithm:e}){let n=await this.getAlgorithm({algorithm:e}).generateKey({algorithm:e});if(n?.kid===void 0)throw new Error("Generated key is missing a required property: kid");let i=`${ts}${n.kid}`;return await this._keyStore.set(i,n),i}async getKeyUri({key:e}){let r=await G({jwk:e});return`${ts}${r}`}async getPublicKey({keyUri:e}){let r=await this.getPrivateKey({keyUri:e}),n=this.getAlgorithmName({key:r});return await this.getAlgorithm({algorithm:n}).getPublicKey({key:r})}async importKey({key:e}){if(!tf(e))throw new TypeError("Invalid key provided. Must be a private key in JWK format.");let r=structuredClone(e);r.kid??=await G({jwk:r});let n=await this.getKeyUri({key:r});return await this._keyStore.set(n,r),n}async sign({keyUri:e,data:r}){let n=await this.getPrivateKey({keyUri:e}),i=this.getAlgorithmName({key:n});return this.getAlgorithm({algorithm:i}).sign({data:r,key:n})}async verify({key:e,signature:r,data:n}){let i=this.getAlgorithmName({key:e});return this.getAlgorithm({algorithm:i}).verify({key:e,signature:r,data:n})}getAlgorithm({algorithm:e}){let r=cf[e]?.implementation;if(!r)throw new Error(`Algorithm not supported: ${e}`);return this._algorithmInstances.has(r)||this._algorithmInstances.set(r,new r),this._algorithmInstances.get(r)}getAlgorithmName({key:e}){let r=e.alg,n=e.crv;for(let i in cf){let o=cf[i];if(r&&o.names.includes(r))return i;if(n&&o.names.includes(n))return i}throw new Error(`Unable to determine algorithm based on provided input: alg=${r}, crv=${n}`)}async getPrivateKey({keyUri:e}){let r=await this._keyStore.get(e);if(!r)throw new Error(`Key not found: ${e}`);return r}};var uf={};Li(uf,{checkRequiredProperty:()=>Z1,checkValidProperty:()=>X1,getJoseSignatureAlgorithmFromPublicKey:()=>Q1,isWebCryptoSupported:()=>e2,randomBytes:()=>t2,randomUuid:()=>r2});function Z1(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 X1(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 Q1(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 e2(){return!!(globalThis.crypto&&globalThis.crypto.subtle)}function t2(t){return Gr(t)}function r2(){return Kt.randomUUID()}var ki=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Jt=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));function Hp(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}var Gp=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),n2=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!n2)throw new Error("Non little-endian hardware is not supported");function os(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function ss(t){if(typeof t=="string")t=os(t);else if(Hp(t))t=t.slice();else throw new Error(`expected Uint8Array, got ${typeof t}`);return t}var i2=t=>Object.prototype.toString.call(t)==="[object Object]"&&t.constructor===Object;function Jp(t,e){if(e!==void 0&&(typeof e!="object"||!i2(e)))throw new Error("options must be object or undefined");return Object.assign(t,e)}function en(t,e){if(!Hp(t))throw new Error("Uint8Array expected");if(typeof e=="number"&&t.length!==e)throw new Error(`Uint8Array length ${e} expected`)}function Wp(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}var lf=(t,e)=>(Object.assign(e,t),e);function df(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),a=Number(r&o),c=n?4:0,f=n?0:4;t.setUint32(e+c,s,n),t.setUint32(e+f,a,n)}function Ii(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`wrong positive integer: ${t}`)}function hf(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function o2(t){return t!=null&&typeof t=="object"&&(t instanceof Uint8Array||t.constructor.name==="Uint8Array")}function Kn(t,...e){if(!o2(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 pf(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 zp(t,e){Kn(t);let r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}function Ge(){if(ki&&typeof ki.subtle=="object"&&ki.subtle!=null)return ki.subtle;throw new Error("crypto.subtle must be defined")}var Ri=128,Yp=[128,192,256],as=Ri,tn=class{static async bytesToPrivateKey({privateKeyBytes:e}){let r={k:q.uint8Array(e).toBase64Url(),kty:"oct"};return r.kid=await G({jwk:r}),r}static async decrypt({key:e,data:r,counter:n,length:i}){if(n.byteLength!==Ri/8)throw new TypeError(`The counter must be ${Ri} bits in length`);if(i===0||i>as)throw new TypeError(`The 'length' property must be in the range 1 to ${as}`);let o=Ge(),s=await o.importKey("jwk",e,{name:"AES-CTR"},!0,["decrypt"]),a=await o.decrypt({name:"AES-CTR",counter:n,length:i},s,r);return new Uint8Array(a)}static async encrypt({key:e,data:r,counter:n,length:i}){if(n.byteLength!==Ri/8)throw new TypeError(`The counter must be ${Ri} bits in length`);if(i===0||i>as)throw new TypeError(`The 'length' property must be in the range 1 to ${as}`);let o=Ge(),s=await o.importKey("jwk",e,{name:"AES-CTR"},!0,["encrypt","decrypt"]),a=await o.encrypt({name:"AES-CTR",counter:n,length:i},s,r);return new Uint8Array(a)}static async generateKey({length:e}){if(!Yp.includes(e))throw new RangeError(`The key length is invalid: Must be ${Yp.join(", ")} bits`);let r=Ge(),n=await r.generateKey({name:"AES-CTR",length:e},!0,["encrypt"]),{ext:i,key_ops:o,...s}=await r.exportKey("jwk",n);return s.kid=await G({jwk:s}),s}static async privateKeyToBytes({privateKey:e}){if(!$t(e))throw new Error("AesCtr: The provided key is not a valid oct private key.");return q.base64Url(e.k).toUint8Array()}};var yf=class extends Le{async decrypt(e){return tn.decrypt(e)}async encrypt(e){return tn.encrypt(e)}async generateKey({algorithm:e}){let r={A128CTR:128,A192CTR:192,A256CTR:256}[e],n=await tn.generateKey({length:r});return n.alg=e,n}};var cs=96,Zp=[128,192,256],Ui=[96,104,112,120,128],rn=class{static async bytesToPrivateKey({privateKeyBytes:e}){let r={k:q.uint8Array(e).toBase64Url(),kty:"oct"};return r.kid=await G({jwk:r}),r}static async decrypt({key:e,data:r,iv:n,additionalData:i,tagLength:o}){if(n.byteLength!==cs/8)throw new TypeError(`The initialization vector must be ${cs} bits in length`);if(o&&!Ui.includes(o))throw new RangeError(`The tag length is invalid: Must be ${Ui.join(", ")} bits`);let s=Ge(),a=await s.importKey("jwk",e,{name:"AES-GCM"},!0,["decrypt"]),c={name:"AES-GCM",iv:n,...o&&{tagLength:o},...i&&{additionalData:i}},f=await s.decrypt(c,a,r);return new Uint8Array(f)}static async encrypt({data:e,iv:r,key:n,additionalData:i,tagLength:o}){if(r.byteLength!==cs/8)throw new TypeError(`The initialization vector must be ${cs} bits in length`);if(o&&!Ui.includes(o))throw new RangeError(`The tag length is invalid: Must be ${Ui.join(", ")} bits`);let s=Ge(),a=await s.importKey("jwk",n,{name:"AES-GCM"},!0,["encrypt"]),c={name:"AES-GCM",iv:r,...o&&{tagLength:o},...i&&{additionalData:i}},f=await s.encrypt(c,a,e);return new Uint8Array(f)}static async generateKey({length:e}){if(!Zp.includes(e))throw new RangeError(`The key length is invalid: Must be ${Zp.join(", ")} bits`);let r=Ge(),n=await r.generateKey({name:"AES-GCM",length:e},!0,["encrypt"]),{ext:i,key_ops:o,...s}=await r.exportKey("jwk",n);return s.kid=await G({jwk:s}),s}static async privateKeyToBytes({privateKey:e}){if(!$t(e))throw new Error("AesGcm: The provided key is not a valid oct private key.");return q.base64Url(e.k).toUint8Array()}};var wf=class extends Le{async decrypt(e){return rn.decrypt(e)}async encrypt(e){return rn.encrypt(e)}async generateKey({algorithm:e}){let r={A128GCM:128,A192GCM:192,A256GCM:256}[e],n=await rn.generateKey({length:r});return n.alg=e,n}};var mf=class t{static async deriveKey({keyDataLen:e,fixedInfo:r,sharedSecret:n}){let o=Math.ceil(e/256);if(o!==1)throw new Error(`Concat KDF with ${o} rounds not supported.`);let s=new Uint8Array(4);new DataView(s.buffer).setUint32(0,o);let a=t.computeFixedInfo(r);return Pe(Hr(s,n,a)).slice(0,e/8)}static computeFixedInfo(e){let r=t.toDataLenData({data:e.algorithmId}),n=t.toDataLenData({data:e.partyUInfo}),i=t.toDataLenData({data:e.partyVInfo}),o=t.toDataLenData({data:e.suppPubInfo,variableLength:!1}),s=t.toDataLenData({data:e.suppPrivInfo});return Hr(r,n,i,o,s)}static toDataLenData({data:e,variableLength:r=!0}){let n,i=Mn(e);if(i==="Undefined")return new Uint8Array(0);if(r){let o=i==="Uint8Array"?e:new q(e,i).toUint8Array(),s=o.length;n=new Uint8Array(4+s),new DataView(n.buffer).setUint32(0,s),n.set(o,4)}else{if(typeof e!="number")throw TypeError("Fixed length input must be a number.");n=new Uint8Array(4),new DataView(n.buffer).setUint32(0,e)}return n}};var bf=class{static async deriveKey({hash:e,password:r,salt:n,iterations:i,length:o}){let s=await Kt.subtle.importKey("raw",r,{name:"PBKDF2"},!1,["deriveBits"]),a=await Kt.subtle.deriveBits({name:"PBKDF2",hash:e,salt:n,iterations:i},s,o);return new Uint8Array(a)}};var gf=class t{static async bytesToPrivateKey({privateKeyBytes:e}){let r=Qr.getPublicKey(e),n={kty:"OKP",crv:"X25519",d:q.uint8Array(e).toBase64Url(),x:q.uint8Array(r).toBase64Url()};return n.kid=await G({jwk:n}),n}static async bytesToPublicKey({publicKeyBytes:e}){let r={kty:"OKP",crv:"X25519",x:q.uint8Array(e).toBase64Url()};return r.kid=await G({jwk:r}),r}static async computePublicKey({key:e}){let r=await t.privateKeyToBytes({privateKey:e}),n=Qr.getPublicKey(r),i={kty:"OKP",crv:"X25519",x:q.uint8Array(n).toBase64Url()};return i.kid=await G({jwk:i}),i}static async generateKey(){let e=Qr.utils.randomPrivateKey(),r=await t.bytesToPrivateKey({privateKeyBytes:e});return r.kid=await G({jwk:r}),r}static async getPublicKey({key:e}){if(!(rt(e)&&e.crv==="X25519"))throw new Error("X25519: The provided key is not an X25519 private JWK.");let{d:r,...n}=e;return n.kid??=await G({jwk:n}),n}static async privateKeyToBytes({privateKey:e}){if(!rt(e))throw new Error("X25519: The provided key is not a valid OKP private key.");return q.base64Url(e.d).toUint8Array()}static async publicKeyToBytes({publicKey:e}){if(!Xr(e))throw new Error("X25519: The provided key is not a valid OKP public key.");return q.base64Url(e.x).toUint8Array()}static async sharedSecret({privateKeyA:e,publicKeyB:r}){if("x"in e&&"x"in r&&e.x===r.x)throw new Error("X25519: ECDH shared secret cannot be computed from a single key pair's public and private keys.");let n=await t.privateKeyToBytes({privateKey:e}),i=await t.publicKeyToBytes({publicKey:r});return Qr.getSharedSecret(n,i)}};var ge=(t,e)=>t[e++]&255|(t[e++]&255)<<8,xf=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=ss(e),en(e,32);let r=ge(e,0),n=ge(e,2),i=ge(e,4),o=ge(e,6),s=ge(e,8),a=ge(e,10),c=ge(e,12),f=ge(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|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|f<<8)&8191,this.r[9]=f>>>5&127;for(let u=0;u<8;u++)this.pad[u]=ge(e,16+2*u)}process(e,r,n=!1){let i=n?0:2048,{h:o,r:s}=this,a=s[0],c=s[1],f=s[2],u=s[3],l=s[4],p=s[5],y=s[6],d=s[7],h=s[8],m=s[9],g=ge(e,r+0),x=ge(e,r+2),w=ge(e,r+4),T=ge(e,r+6),_=ge(e,r+8),A=ge(e,r+10),I=ge(e,r+12),B=ge(e,r+14),U=o[0]+(g&8191),O=o[1]+((g>>>13|x<<3)&8191),C=o[2]+((x>>>10|w<<6)&8191),M=o[3]+((w>>>7|T<<9)&8191),j=o[4]+((T>>>4|_<<12)&8191),z=o[5]+(_>>>1&8191),v=o[6]+((_>>>14|A<<2)&8191),k=o[7]+((A>>>11|I<<5)&8191),K=o[8]+((I>>>8|B<<8)&8191),S=o[9]+(B>>>5|i),b=0,P=b+U*a+O*(5*m)+C*(5*h)+M*(5*d)+j*(5*y);b=P>>>13,P&=8191,P+=z*(5*p)+v*(5*l)+k*(5*u)+K*(5*f)+S*(5*c),b+=P>>>13,P&=8191;let R=b+U*c+O*a+C*(5*m)+M*(5*h)+j*(5*d);b=R>>>13,R&=8191,R+=z*(5*y)+v*(5*p)+k*(5*l)+K*(5*u)+S*(5*f),b+=R>>>13,R&=8191;let L=b+U*f+O*c+C*a+M*(5*m)+j*(5*h);b=L>>>13,L&=8191,L+=z*(5*d)+v*(5*y)+k*(5*p)+K*(5*l)+S*(5*u),b+=L>>>13,L&=8191;let F=b+U*u+O*f+C*c+M*a+j*(5*m);b=F>>>13,F&=8191,F+=z*(5*h)+v*(5*d)+k*(5*y)+K*(5*p)+S*(5*l),b+=F>>>13,F&=8191;let $=b+U*l+O*u+C*f+M*c+j*a;b=$>>>13,$&=8191,$+=z*(5*m)+v*(5*h)+k*(5*d)+K*(5*y)+S*(5*p),b+=$>>>13,$&=8191;let Y=b+U*p+O*l+C*u+M*f+j*c;b=Y>>>13,Y&=8191,Y+=z*a+v*(5*m)+k*(5*h)+K*(5*d)+S*(5*y),b+=Y>>>13,Y&=8191;let V=b+U*y+O*p+C*l+M*u+j*f;b=V>>>13,V&=8191,V+=z*c+v*a+k*(5*m)+K*(5*h)+S*(5*d),b+=V>>>13,V&=8191;let H=b+U*d+O*y+C*p+M*l+j*u;b=H>>>13,H&=8191,H+=z*f+v*c+k*a+K*(5*m)+S*(5*h),b+=H>>>13,H&=8191;let ne=b+U*h+O*d+C*y+M*p+j*l;b=ne>>>13,ne&=8191,ne+=z*u+v*f+k*c+K*a+S*(5*m),b+=ne>>>13,ne&=8191;let te=b+U*m+O*h+C*d+M*y+j*p;b=te>>>13,te&=8191,te+=z*l+v*u+k*f+K*c+S*a,b+=te>>>13,te&=8191,b=(b<<2)+b|0,b=b+P|0,P=b&8191,b=b>>>13,R+=b,o[0]=P,o[1]=R,o[2]=L,o[3]=F,o[4]=$,o[5]=Y,o[6]=V,o[7]=H,o[8]=ne,o[9]=te}finalize(){let{h:e,pad:r}=this,n=new Uint16Array(10),i=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=i,i=e[a]>>>13,e[a]&=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 a=1;a<10;a++)n[a]=e[a]+i,i=n[a]>>>13,n[a]&=8191;n[9]-=8192;let o=(i^1)-1;for(let a=0;a<10;a++)n[a]&=o;o=~o;for(let a=0;a<10;a++)e[a]=e[a]&o|n[a];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 a=1;a<8;a++)s=(e[a]+r[a]|0)+(s>>>16)|0,e[a]=s&65535}update(e){pf(this);let{buffer:r,blockLen:n}=this;e=ss(e);let i=e.length;for(let o=0;o<i;){let s=Math.min(n-this.pos,i-o);if(s===n){for(;n<=i-o;o+=n)this.process(e,o);continue}r.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(r,0,!1),this.pos=0)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(e){pf(this),zp(e,this),this.finished=!0;let{buffer:r,h:n}=this,{pos:i}=this;if(i){for(r[i++]=1;i<16;i++)r[i]=0;this.process(r,0,!0)}this.finalize();let o=0;for(let s=0;s<8;s++)e[o++]=n[s]>>>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 s2(t){let e=(n,i)=>t(i).update(ss(n)).digest(),r=t(new Uint8Array(32));return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=n=>t(n),e}var Xp=s2(t=>new xf(t));var a2=os("expand 16-byte k"),c2=os("expand 32-byte k"),f2=Jt(a2),u2=Jt(c2);function N(t,e){return t<<e|t>>>32-e}function Ef(t){return t.byteOffset%4===0}var fs=64,l2=16,ey=2**32-1,Qp=new Uint32Array;function d2(t,e,r,n,i,o,s,a){let c=i.length,f=new Uint8Array(fs),u=Jt(f),l=Ef(i)&&Ef(o),p=l?Jt(i):Qp,y=l?Jt(o):Qp;for(let d=0;d<c;s++){if(t(e,r,n,u,s,a),s>=ey)throw new Error("arx: counter overflow");let h=Math.min(fs,c-d);if(l&&h===fs){let m=d/4;if(d%4!==0)throw new Error("arx: invalid block position");for(let g=0,x;g<l2;g++)x=m+g,y[x]=p[x]^u[g];d+=fs;continue}for(let m=0,g;m<h;m++)g=d+m,o[g]=i[g]^f[m];d+=h}}function _f(t,e){let{allowShortKeys:r,extendNonceFn:n,counterLength:i,counterRight:o,rounds:s}=Jp({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return Ii(i),Ii(s),hf(o),hf(r),(a,c,f,u,l=0)=>{Kn(a),Kn(c),Kn(f);let p=f.length;if(u||(u=new Uint8Array(p)),Kn(u),Ii(l),l<0||l>=ey)throw new Error("arx: counter overflow");if(u.length<p)throw new Error(`arx: output (${u.length}) is shorter than data (${p})`);let y=[],d=a.length,h,m;if(d===32)h=a.slice(),y.push(h),m=u2;else if(d===16&&r)h=new Uint8Array(32),h.set(a),h.set(a,16),m=f2,y.push(h);else throw new Error(`arx: invalid 32-byte key, got length=${d}`);Ef(c)||(c=c.slice(),y.push(c));let g=Jt(h);if(n){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");n(m,g,Jt(c.subarray(0,16)),g),c=c.subarray(16)}let x=16-i;if(x!==c.length)throw new Error(`arx: nonce must be ${x} or 16 bytes`);if(x!==12){let T=new Uint8Array(12);T.set(c,o?0:12-c.length),c=T,y.push(c)}let w=Jt(c);for(d2(t,m,g,w,f,u,l,s);y.length>0;)y.pop().fill(0);return u}}function ny(t,e,r,n,i,o=20){let s=t[0],a=t[1],c=t[2],f=t[3],u=e[0],l=e[1],p=e[2],y=e[3],d=e[4],h=e[5],m=e[6],g=e[7],x=i,w=r[0],T=r[1],_=r[2],A=s,I=a,B=c,U=f,O=u,C=l,M=p,j=y,z=d,v=h,k=m,K=g,S=x,b=w,P=T,R=_;for(let F=0;F<o;F+=2)A=A+O|0,S=N(S^A,16),z=z+S|0,O=N(O^z,12),A=A+O|0,S=N(S^A,8),z=z+S|0,O=N(O^z,7),I=I+C|0,b=N(b^I,16),v=v+b|0,C=N(C^v,12),I=I+C|0,b=N(b^I,8),v=v+b|0,C=N(C^v,7),B=B+M|0,P=N(P^B,16),k=k+P|0,M=N(M^k,12),B=B+M|0,P=N(P^B,8),k=k+P|0,M=N(M^k,7),U=U+j|0,R=N(R^U,16),K=K+R|0,j=N(j^K,12),U=U+j|0,R=N(R^U,8),K=K+R|0,j=N(j^K,7),A=A+C|0,R=N(R^A,16),k=k+R|0,C=N(C^k,12),A=A+C|0,R=N(R^A,8),k=k+R|0,C=N(C^k,7),I=I+M|0,S=N(S^I,16),K=K+S|0,M=N(M^K,12),I=I+M|0,S=N(S^I,8),K=K+S|0,M=N(M^K,7),B=B+j|0,b=N(b^B,16),z=z+b|0,j=N(j^z,12),B=B+j|0,b=N(b^B,8),z=z+b|0,j=N(j^z,7),U=U+O|0,P=N(P^U,16),v=v+P|0,O=N(O^v,12),U=U+O|0,P=N(P^U,8),v=v+P|0,O=N(O^v,7);let L=0;n[L++]=s+A|0,n[L++]=a+I|0,n[L++]=c+B|0,n[L++]=f+U|0,n[L++]=u+O|0,n[L++]=l+C|0,n[L++]=p+M|0,n[L++]=y+j|0,n[L++]=d+z|0,n[L++]=h+v|0,n[L++]=m+k|0,n[L++]=g+K|0,n[L++]=x+S|0,n[L++]=w+b|0,n[L++]=T+P|0,n[L++]=_+R|0}function h2(t,e,r,n){let i=t[0],o=t[1],s=t[2],a=t[3],c=e[0],f=e[1],u=e[2],l=e[3],p=e[4],y=e[5],d=e[6],h=e[7],m=r[0],g=r[1],x=r[2],w=r[3];for(let _=0;_<20;_+=2)i=i+c|0,m=N(m^i,16),p=p+m|0,c=N(c^p,12),i=i+c|0,m=N(m^i,8),p=p+m|0,c=N(c^p,7),o=o+f|0,g=N(g^o,16),y=y+g|0,f=N(f^y,12),o=o+f|0,g=N(g^o,8),y=y+g|0,f=N(f^y,7),s=s+u|0,x=N(x^s,16),d=d+x|0,u=N(u^d,12),s=s+u|0,x=N(x^s,8),d=d+x|0,u=N(u^d,7),a=a+l|0,w=N(w^a,16),h=h+w|0,l=N(l^h,12),a=a+l|0,w=N(w^a,8),h=h+w|0,l=N(l^h,7),i=i+f|0,w=N(w^i,16),d=d+w|0,f=N(f^d,12),i=i+f|0,w=N(w^i,8),d=d+w|0,f=N(f^d,7),o=o+u|0,m=N(m^o,16),h=h+m|0,u=N(u^h,12),o=o+u|0,m=N(m^o,8),h=h+m|0,u=N(u^h,7),s=s+l|0,g=N(g^s,16),p=p+g|0,l=N(l^p,12),s=s+l|0,g=N(g^s,8),p=p+g|0,l=N(l^p,7),a=a+c|0,x=N(x^a,16),y=y+x|0,c=N(c^y,12),a=a+c|0,x=N(x^a,8),y=y+x|0,c=N(c^y,7);let T=0;n[T++]=i,n[T++]=o,n[T++]=s,n[T++]=a,n[T++]=m,n[T++]=g,n[T++]=x,n[T++]=w}var p2=_f(ny,{counterRight:!1,counterLength:4,allowShortKeys:!1}),us=_f(ny,{counterRight:!1,counterLength:8,extendNonceFn:h2,allowShortKeys:!1});var y2=new Uint8Array(16),ty=(t,e)=>{t.update(e);let r=e.length%16;r&&t.update(y2.subarray(r))},w2=new Uint8Array(32);function ry(t,e,r,n,i){let o=t(e,r,w2),s=Xp.create(o);i&&ty(s,i),ty(s,n);let a=new Uint8Array(16),c=Gp(a);df(c,0,BigInt(i?i.length:0),!0),df(c,8,BigInt(n.length),!0),s.update(a);let f=s.digest();return o.fill(0),f}var iy=t=>(e,r,n)=>(en(e,32),en(r),{encrypt:(o,s)=>{let a=o.length,c=a+16;s?en(s,c):s=new Uint8Array(c),t(e,r,o,s,1);let f=ry(t,e,r,s.subarray(0,-16),n);return s.set(f,a),s},decrypt:(o,s)=>{let a=o.length,c=a-16;if(a<16)throw new Error("encrypted data must be at least 16 bytes");s?en(s,c):s=new Uint8Array(c);let f=o.subarray(0,-16),u=o.subarray(-16),l=ry(t,e,r,f,n);if(!Wp(u,l))throw new Error("invalid tag");return t(e,r,f,s,1),s}}),I8=lf({blockSize:64,nonceLength:12,tagLength:16},iy(p2)),vf=lf({blockSize:64,nonceLength:24,tagLength:16},iy(us));var Af=class t{static async bytesToPrivateKey({privateKeyBytes:e}){let r={k:q.uint8Array(e).toBase64Url(),kty:"oct"};return r.kid=await G({jwk:r}),r}static async decrypt({data:e,key:r,nonce:n}){let i=await t.privateKeyToBytes({privateKey:r});return us(i,n,e)}static async encrypt({data:e,key:r,nonce:n}){let i=await t.privateKeyToBytes({privateKey:r});return us(i,n,e)}static async generateKey(){let e=Ge(),r=await e.generateKey({name:"AES-CTR",length:256},!0,["encrypt"]),{alg:n,ext:i,key_ops:o,...s}=await e.exportKey("jwk",r);return s.kid=await G({jwk:s}),s}static async privateKeyToBytes({privateKey:e}){if(!$t(e))throw new Error("XChaCha20: The provided key is not a valid oct private key.");return q.base64Url(e.k).toUint8Array()}};var m2=16,Sf=class t{static async bytesToPrivateKey({privateKeyBytes:e}){let r={k:q.uint8Array(e).toBase64Url(),kty:"oct"};return r.kid=await G({jwk:r}),r}static async decrypt({data:e,key:r,nonce:n,additionalData:i}){let o=await t.privateKeyToBytes({privateKey:r});return vf(o,n,i).decrypt(e)}static async encrypt({data:e,key:r,nonce:n,additionalData:i}){let o=await t.privateKeyToBytes({privateKey:r});return vf(o,n,i).encrypt(e)}static async generateKey(){let e=Ge(),r=await e.generateKey({name:"AES-CTR",length:256},!0,["encrypt"]),{alg:n,ext:i,key_ops:o,...s}=await e.exportKey("jwk",r);return s.kid=await G({jwk:s}),s}static async privateKeyToBytes({privateKey:e}){if(!$t(e))throw new Error("XChaCha20Poly1305: The provided key is not a valid oct private key.");return q.base64Url(e.k).toUint8Array()}};return by(b2);})();
/*! Bundled license information:
ieee754/index.js:
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
buffer/index.js:
(*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*)
queue-microtask/index.js:
(*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
run-parallel-limit/index.js:
(*! run-parallel-limit. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
safe-buffer/index.js:
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
@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) *)
*/
//# sourceMappingURL=browser.js.map