@enbox/dids 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.mjs +1 -1
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/methods/did-dht-dns.js +455 -0
- package/dist/esm/methods/did-dht-dns.js.map +1 -0
- package/dist/esm/methods/did-dht-pkarr.js +168 -0
- package/dist/esm/methods/did-dht-pkarr.js.map +1 -0
- package/dist/esm/methods/did-dht-types.js +116 -0
- package/dist/esm/methods/did-dht-types.js.map +1 -0
- package/dist/esm/methods/did-dht-utils.js +143 -0
- package/dist/esm/methods/did-dht-utils.js.map +1 -0
- package/dist/esm/methods/did-dht.js +65 -842
- package/dist/esm/methods/did-dht.js.map +1 -1
- package/dist/esm/methods/did-ion-utils.js +161 -0
- package/dist/esm/methods/did-ion-utils.js.map +1 -0
- package/dist/esm/methods/did-ion.js +4 -151
- package/dist/esm/methods/did-ion.js.map +1 -1
- package/dist/esm/methods/did-jwk.js.map +1 -1
- package/dist/esm/methods/did-key-utils.js +235 -0
- package/dist/esm/methods/did-key-utils.js.map +1 -0
- package/dist/esm/methods/did-key.js +6 -222
- package/dist/esm/methods/did-key.js.map +1 -1
- package/dist/esm/resolver/resolver-cache-memory.js +77 -0
- package/dist/esm/resolver/resolver-cache-memory.js.map +1 -0
- package/dist/esm/utils.js +25 -0
- package/dist/esm/utils.js.map +1 -1
- package/dist/types/bearer-did.d.ts +4 -4
- package/dist/types/bearer-did.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/methods/did-dht-dns.d.ts +114 -0
- package/dist/types/methods/did-dht-dns.d.ts.map +1 -0
- package/dist/types/methods/did-dht-pkarr.d.ts +56 -0
- package/dist/types/methods/did-dht-pkarr.d.ts.map +1 -0
- package/dist/types/methods/did-dht-types.d.ts +286 -0
- package/dist/types/methods/did-dht-types.d.ts.map +1 -0
- package/dist/types/methods/did-dht-utils.d.ts +54 -0
- package/dist/types/methods/did-dht-utils.d.ts.map +1 -0
- package/dist/types/methods/did-dht.d.ts +45 -460
- package/dist/types/methods/did-dht.d.ts.map +1 -1
- package/dist/types/methods/did-ion-utils.d.ts +86 -0
- package/dist/types/methods/did-ion-utils.d.ts.map +1 -0
- package/dist/types/methods/did-ion.d.ts +4 -84
- package/dist/types/methods/did-ion.d.ts.map +1 -1
- package/dist/types/methods/did-jwk.d.ts +4 -4
- package/dist/types/methods/did-jwk.d.ts.map +1 -1
- package/dist/types/methods/did-key-utils.d.ts +138 -0
- package/dist/types/methods/did-key-utils.d.ts.map +1 -0
- package/dist/types/methods/did-key.d.ts +6 -127
- package/dist/types/methods/did-key.d.ts.map +1 -1
- package/dist/types/methods/did-method.d.ts +3 -3
- package/dist/types/methods/did-method.d.ts.map +1 -1
- package/dist/types/resolver/resolver-cache-memory.d.ts +58 -0
- package/dist/types/resolver/resolver-cache-memory.d.ts.map +1 -0
- package/dist/types/utils.d.ts +19 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +4 -4
- package/package.json +11 -13
- package/src/bearer-did.ts +4 -4
- package/src/index.ts +2 -0
- package/src/methods/did-dht-dns.ts +516 -0
- package/src/methods/did-dht-pkarr.ts +192 -0
- package/src/methods/did-dht-types.ts +316 -0
- package/src/methods/did-dht-utils.ts +157 -0
- package/src/methods/did-dht.ts +125 -1131
- package/src/methods/did-ion-utils.ts +186 -0
- package/src/methods/did-ion.ts +16 -185
- package/src/methods/did-jwk.ts +4 -4
- package/src/methods/did-key-utils.ts +258 -0
- package/src/methods/did-key.ts +20 -272
- package/src/methods/did-method.ts +3 -3
- package/src/resolver/resolver-cache-memory.ts +84 -0
- package/src/utils.ts +27 -0
- package/dist/browser.js +0 -73
- package/dist/browser.js.map +0 -7
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ns=Object.create;var Er=Object.defineProperty;var is=Object.getOwnPropertyDescriptor;var os=Object.getOwnPropertyNames;var ss=Object.getPrototypeOf,cs=Object.prototype.hasOwnProperty;var v=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),us=(n,e)=>{for(var t in e)Er(n,t,{get:e[t],enumerable:!0})},as=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of os(e))!cs.call(n,i)&&i!==t&&Er(n,i,{get:()=>e[i],enumerable:!(r=is(e,i))||r.enumerable});return n};var u=(n,e,t)=>(t=n!=null?ns(ss(n)):{},as(e||!n||!n.__esModule?Er(t,"default",{value:n,enumerable:!0}):t,n));var zn=v(Dt=>{"use strict";var Ru=u(a());Dt.byteLength=hs;Dt.toByteArray=ls;Dt.fromByteArray=ms;var z=[],M=[],fs=typeof Uint8Array<"u"?Uint8Array:Array,Tr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(_e=0,Wn=Tr.length;_e<Wn;++_e)z[_e]=Tr[_e],M[Tr.charCodeAt(_e)]=_e;var _e,Wn;M[45]=62;M[95]=63;function Hn(n){var e=n.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=n.indexOf("=");t===-1&&(t=e);var r=t===e?0:4-t%4;return[t,r]}function hs(n){var e=Hn(n),t=e[0],r=e[1];return(t+r)*3/4-r}function ds(n,e,t){return(e+t)*3/4-t}function ls(n){var e,t=Hn(n),r=t[0],i=t[1],o=new fs(ds(n,r,i)),s=0,c=i>0?r-4:r,f;for(f=0;f<c;f+=4)e=M[n.charCodeAt(f)]<<18|M[n.charCodeAt(f+1)]<<12|M[n.charCodeAt(f+2)]<<6|M[n.charCodeAt(f+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=M[n.charCodeAt(f)]<<2|M[n.charCodeAt(f+1)]>>4,o[s++]=e&255),i===1&&(e=M[n.charCodeAt(f)]<<10|M[n.charCodeAt(f+1)]<<4|M[n.charCodeAt(f+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function ps(n){return z[n>>18&63]+z[n>>12&63]+z[n>>6&63]+z[n&63]}function ys(n,e,t){for(var r,i=[],o=e;o<t;o+=3)r=(n[o]<<16&16711680)+(n[o+1]<<8&65280)+(n[o+2]&255),i.push(ps(r));return i.join("")}function ms(n){for(var e,t=n.length,r=t%3,i=[],o=16383,s=0,c=t-r;s<c;s+=o)i.push(ys(n,s,s+o>c?c:s+o));return r===1?(e=n[t-1],i.push(z[e>>2]+z[e<<4&63]+"==")):r===2&&(e=(n[t-2]<<8)+n[t-1],i.push(z[e>>10]+z[e>>4&63]+z[e<<2&63]+"=")),i.join("")}});var Yn=v(_r=>{var Nu=u(a());_r.read=function(n,e,t,r,i){var o,s,c=i*8-r-1,f=(1<<c)-1,h=f>>1,l=-7,d=t?i-1:0,y=t?-1:1,w=n[e+d];for(d+=y,o=w&(1<<-l)-1,w>>=-l,l+=c;l>0;o=o*256+n[e+d],d+=y,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=s*256+n[e+d],d+=y,l-=8);if(o===0)o=1-h;else{if(o===f)return s?NaN:(w?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-h}return(w?-1:1)*s*Math.pow(2,o-r)};_r.write=function(n,e,t,r,i,o){var s,c,f,h=o*8-i-1,l=(1<<h)-1,d=l>>1,y=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=r?0:o-1,m=r?1:-1,b=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(f=Math.pow(2,-s))<1&&(s--,f*=2),s+d>=1?e+=y/f:e+=y*Math.pow(2,1-d),e*f>=2&&(s++,f/=2),s+d>=l?(c=0,s=l):s+d>=1?(c=(e*f-1)*Math.pow(2,i),s=s+d):(c=e*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;n[t+w]=c&255,w+=m,c/=256,i-=8);for(s=s<<i|c,h+=i;h>0;n[t+w]=s&255,w+=m,s/=256,h-=8);n[t+w-m]|=b*128}});var We=v(Ge=>{"use strict";var $u=u(a());var Ar=zn(),qe=Yn(),Xn=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Ge.Buffer=p;Ge.SlowBuffer=Es;Ge.INSPECT_MAX_BYTES=50;var Mt=2147483647;Ge.kMaxLength=Mt;p.TYPED_ARRAY_SUPPORT=ws();!p.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 ws(){try{let n=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(n,e),n.foo()===42}catch{return!1}}Object.defineProperty(p.prototype,"parent",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.buffer}});Object.defineProperty(p.prototype,"offset",{enumerable:!0,get:function(){if(p.isBuffer(this))return this.byteOffset}});function re(n){if(n>Mt)throw new RangeError('The value "'+n+'" is invalid for option "size"');let e=new Uint8Array(n);return Object.setPrototypeOf(e,p.prototype),e}function p(n,e,t){if(typeof n=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Kr(n)}return ti(n,e,t)}p.poolSize=8192;function ti(n,e,t){if(typeof n=="string")return xs(n,e);if(ArrayBuffer.isView(n))return vs(n);if(n==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);if(Y(n,ArrayBuffer)||n&&Y(n.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Y(n,SharedArrayBuffer)||n&&Y(n.buffer,SharedArrayBuffer)))return Sr(n,e,t);if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let r=n.valueOf&&n.valueOf();if(r!=null&&r!==n)return p.from(r,e,t);let i=bs(n);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof n[Symbol.toPrimitive]=="function")return p.from(n[Symbol.toPrimitive]("string"),e,t);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n)}p.from=function(n,e,t){return ti(n,e,t)};Object.setPrototypeOf(p.prototype,Uint8Array.prototype);Object.setPrototypeOf(p,Uint8Array);function ri(n){if(typeof n!="number")throw new TypeError('"size" argument must be of type number');if(n<0)throw new RangeError('The value "'+n+'" is invalid for option "size"')}function gs(n,e,t){return ri(n),n<=0?re(n):e!==void 0?typeof t=="string"?re(n).fill(e,t):re(n).fill(e):re(n)}p.alloc=function(n,e,t){return gs(n,e,t)};function Kr(n){return ri(n),re(n<0?0:Ir(n)|0)}p.allocUnsafe=function(n){return Kr(n)};p.allocUnsafeSlow=function(n){return Kr(n)};function xs(n,e){if((typeof e!="string"||e==="")&&(e="utf8"),!p.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=ni(n,e)|0,r=re(t),i=r.write(n,e);return i!==t&&(r=r.slice(0,i)),r}function Br(n){let e=n.length<0?0:Ir(n.length)|0,t=re(e);for(let r=0;r<e;r+=1)t[r]=n[r]&255;return t}function vs(n){if(Y(n,Uint8Array)){let e=new Uint8Array(n);return Sr(e.buffer,e.byteOffset,e.byteLength)}return Br(n)}function Sr(n,e,t){if(e<0||n.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(n.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let r;return e===void 0&&t===void 0?r=new Uint8Array(n):t===void 0?r=new Uint8Array(n,e):r=new Uint8Array(n,e,t),Object.setPrototypeOf(r,p.prototype),r}function bs(n){if(p.isBuffer(n)){let e=Ir(n.length)|0,t=re(e);return t.length===0||n.copy(t,0,0,e),t}if(n.length!==void 0)return typeof n.length!="number"||Ur(n.length)?re(0):Br(n);if(n.type==="Buffer"&&Array.isArray(n.data))return Br(n.data)}function Ir(n){if(n>=Mt)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Mt.toString(16)+" bytes");return n|0}function Es(n){return+n!=n&&(n=0),p.alloc(+n)}p.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==p.prototype};p.compare=function(e,t){if(Y(e,Uint8Array)&&(e=p.from(e,e.offset,e.byteLength)),Y(t,Uint8Array)&&(t=p.from(t,t.offset,t.byteLength)),!p.isBuffer(e)||!p.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let r=e.length,i=t.length;for(let o=0,s=Math.min(r,i);o<s;++o)if(e[o]!==t[o]){r=e[o],i=t[o];break}return r<i?-1:i<r?1:0};p.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}};p.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return p.alloc(0);let r;if(t===void 0)for(t=0,r=0;r<e.length;++r)t+=e[r].length;let i=p.allocUnsafe(t),o=0;for(r=0;r<e.length;++r){let s=e[r];if(Y(s,Uint8Array))o+s.length>i.length?(p.isBuffer(s)||(s=p.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(p.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function ni(n,e){if(p.isBuffer(n))return n.length;if(ArrayBuffer.isView(n)||Y(n,ArrayBuffer))return n.byteLength;if(typeof n!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof n);let t=n.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&t===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return kr(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return di(n).length;default:if(i)return r?-1:kr(n).length;e=(""+e).toLowerCase(),i=!0}}p.byteLength=ni;function Ts(n,e,t){let r=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(n||(n="utf8");;)switch(n){case"hex":return Cs(this,e,t);case"utf8":case"utf-8":return oi(this,e,t);case"ascii":return Os(this,e,t);case"latin1":case"binary":return Us(this,e,t);case"base64":return Ks(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ls(this,e,t);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),r=!0}}p.prototype._isBuffer=!0;function Ae(n,e,t){let r=n[e];n[e]=n[t],n[t]=r}p.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 t=0;t<e;t+=2)Ae(this,t,t+1);return this};p.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 t=0;t<e;t+=4)Ae(this,t,t+3),Ae(this,t+1,t+2);return this};p.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 t=0;t<e;t+=8)Ae(this,t,t+7),Ae(this,t+1,t+6),Ae(this,t+2,t+5),Ae(this,t+3,t+4);return this};p.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?oi(this,0,e):Ts.apply(this,arguments)};p.prototype.toLocaleString=p.prototype.toString;p.prototype.equals=function(e){if(!p.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:p.compare(this,e)===0};p.prototype.inspect=function(){let e="",t=Ge.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};Xn&&(p.prototype[Xn]=p.prototype.inspect);p.prototype.compare=function(e,t,r,i,o){if(Y(e,Uint8Array)&&(e=p.from(e,e.offset,e.byteLength)),!p.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(t===void 0&&(t=0),r===void 0&&(r=e?e.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),t<0||r>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&t>=r)return 0;if(i>=o)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,i>>>=0,o>>>=0,this===e)return 0;let s=o-i,c=r-t,f=Math.min(s,c),h=this.slice(i,o),l=e.slice(t,r);for(let d=0;d<f;++d)if(h[d]!==l[d]){s=h[d],c=l[d];break}return s<c?-1:c<s?1:0};function ii(n,e,t,r,i){if(n.length===0)return-1;if(typeof t=="string"?(r=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Ur(t)&&(t=i?0:n.length-1),t<0&&(t=n.length+t),t>=n.length){if(i)return-1;t=n.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof e=="string"&&(e=p.from(e,r)),p.isBuffer(e))return e.length===0?-1:Zn(n,e,t,r,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(n,e,t):Uint8Array.prototype.lastIndexOf.call(n,e,t):Zn(n,[e],t,r,i);throw new TypeError("val must be string, number or Buffer")}function Zn(n,e,t,r,i){let o=1,s=n.length,c=e.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(n.length<2||e.length<2)return-1;o=2,s/=2,c/=2,t/=2}function f(l,d){return o===1?l[d]:l.readUInt16BE(d*o)}let h;if(i){let l=-1;for(h=t;h<s;h++)if(f(n,h)===f(e,l===-1?0:h-l)){if(l===-1&&(l=h),h-l+1===c)return l*o}else l!==-1&&(h-=h-l),l=-1}else for(t+c>s&&(t=s-c),h=t;h>=0;h--){let l=!0;for(let d=0;d<c;d++)if(f(n,h+d)!==f(e,d)){l=!1;break}if(l)return h}return-1}p.prototype.includes=function(e,t,r){return this.indexOf(e,t,r)!==-1};p.prototype.indexOf=function(e,t,r){return ii(this,e,t,r,!0)};p.prototype.lastIndexOf=function(e,t,r){return ii(this,e,t,r,!1)};function _s(n,e,t,r){t=Number(t)||0;let i=n.length-t;r?(r=Number(r),r>i&&(r=i)):r=i;let o=e.length;r>o/2&&(r=o/2);let s;for(s=0;s<r;++s){let c=parseInt(e.substr(s*2,2),16);if(Ur(c))return s;n[t+s]=c}return s}function As(n,e,t,r){return Rt(kr(e,n.length-t),n,t,r)}function Bs(n,e,t,r){return Rt(Rs(e),n,t,r)}function Ss(n,e,t,r){return Rt(di(e),n,t,r)}function ks(n,e,t,r){return Rt(Fs(e,n.length-t),n,t,r)}p.prototype.write=function(e,t,r,i){if(t===void 0)i="utf8",r=this.length,t=0;else if(r===void 0&&typeof t=="string")i=t,r=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(r)?(r=r>>>0,i===void 0&&(i="utf8")):(i=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((r===void 0||r>o)&&(r=o),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return _s(this,e,t,r);case"utf8":case"utf-8":return As(this,e,t,r);case"ascii":case"latin1":case"binary":return Bs(this,e,t,r);case"base64":return Ss(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ks(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Ks(n,e,t){return e===0&&t===n.length?Ar.fromByteArray(n):Ar.fromByteArray(n.slice(e,t))}function oi(n,e,t){t=Math.min(n.length,t);let r=[],i=e;for(;i<t;){let o=n[i],s=null,c=o>239?4:o>223?3:o>191?2:1;if(i+c<=t){let f,h,l,d;switch(c){case 1:o<128&&(s=o);break;case 2:f=n[i+1],(f&192)===128&&(d=(o&31)<<6|f&63,d>127&&(s=d));break;case 3:f=n[i+1],h=n[i+2],(f&192)===128&&(h&192)===128&&(d=(o&15)<<12|(f&63)<<6|h&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:f=n[i+1],h=n[i+2],l=n[i+3],(f&192)===128&&(h&192)===128&&(l&192)===128&&(d=(o&15)<<18|(f&63)<<12|(h&63)<<6|l&63,d>65535&&d<1114112&&(s=d))}}s===null?(s=65533,c=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),i+=c}return Is(r)}var Qn=4096;function Is(n){let e=n.length;if(e<=Qn)return String.fromCharCode.apply(String,n);let t="",r=0;for(;r<e;)t+=String.fromCharCode.apply(String,n.slice(r,r+=Qn));return t}function Os(n,e,t){let r="";t=Math.min(n.length,t);for(let i=e;i<t;++i)r+=String.fromCharCode(n[i]&127);return r}function Us(n,e,t){let r="";t=Math.min(n.length,t);for(let i=e;i<t;++i)r+=String.fromCharCode(n[i]);return r}function Cs(n,e,t){let r=n.length;(!e||e<0)&&(e=0),(!t||t<0||t>r)&&(t=r);let i="";for(let o=e;o<t;++o)i+=Ns[n[o]];return i}function Ls(n,e,t){let r=n.slice(e,t),i="";for(let o=0;o<r.length-1;o+=2)i+=String.fromCharCode(r[o]+r[o+1]*256);return i}p.prototype.slice=function(e,t){let r=this.length;e=~~e,t=t===void 0?r:~~t,e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),t<e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,p.prototype),i};function _(n,e,t){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+e>t)throw new RangeError("Trying to access beyond buffer length")}p.prototype.readUintLE=p.prototype.readUIntLE=function(e,t,r){e=e>>>0,t=t>>>0,r||_(e,t,this.length);let i=this[e],o=1,s=0;for(;++s<t&&(o*=256);)i+=this[e+s]*o;return i};p.prototype.readUintBE=p.prototype.readUIntBE=function(e,t,r){e=e>>>0,t=t>>>0,r||_(e,t,this.length);let i=this[e+--t],o=1;for(;t>0&&(o*=256);)i+=this[e+--t]*o;return i};p.prototype.readUint8=p.prototype.readUInt8=function(e,t){return e=e>>>0,t||_(e,1,this.length),this[e]};p.prototype.readUint16LE=p.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||_(e,2,this.length),this[e]|this[e+1]<<8};p.prototype.readUint16BE=p.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||_(e,2,this.length),this[e]<<8|this[e+1]};p.prototype.readUint32LE=p.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||_(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};p.prototype.readUint32BE=p.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||_(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};p.prototype.readBigUInt64LE=de(function(e){e=e>>>0,Je(e,"offset");let t=this[e],r=this[e+7];(t===void 0||r===void 0)&&ut(e,this.length-8);let i=t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,o=this[++e]+this[++e]*2**8+this[++e]*2**16+r*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});p.prototype.readBigUInt64BE=de(function(e){e=e>>>0,Je(e,"offset");let t=this[e],r=this[e+7];(t===void 0||r===void 0)&&ut(e,this.length-8);let i=t*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+r;return(BigInt(i)<<BigInt(32))+BigInt(o)});p.prototype.readIntLE=function(e,t,r){e=e>>>0,t=t>>>0,r||_(e,t,this.length);let i=this[e],o=1,s=0;for(;++s<t&&(o*=256);)i+=this[e+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i};p.prototype.readIntBE=function(e,t,r){e=e>>>0,t=t>>>0,r||_(e,t,this.length);let i=t,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*t)),s};p.prototype.readInt8=function(e,t){return e=e>>>0,t||_(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};p.prototype.readInt16LE=function(e,t){e=e>>>0,t||_(e,2,this.length);let r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};p.prototype.readInt16BE=function(e,t){e=e>>>0,t||_(e,2,this.length);let r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};p.prototype.readInt32LE=function(e,t){return e=e>>>0,t||_(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};p.prototype.readInt32BE=function(e,t){return e=e>>>0,t||_(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};p.prototype.readBigInt64LE=de(function(e){e=e>>>0,Je(e,"offset");let t=this[e],r=this[e+7];(t===void 0||r===void 0)&&ut(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(r<<24);return(BigInt(i)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});p.prototype.readBigInt64BE=de(function(e){e=e>>>0,Je(e,"offset");let t=this[e],r=this[e+7];(t===void 0||r===void 0)&&ut(e,this.length-8);let i=(t<<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+r)});p.prototype.readFloatLE=function(e,t){return e=e>>>0,t||_(e,4,this.length),qe.read(this,e,!0,23,4)};p.prototype.readFloatBE=function(e,t){return e=e>>>0,t||_(e,4,this.length),qe.read(this,e,!1,23,4)};p.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||_(e,8,this.length),qe.read(this,e,!0,52,8)};p.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||_(e,8,this.length),qe.read(this,e,!1,52,8)};function k(n,e,t,r,i,o){if(!p.isBuffer(n))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(t+r>n.length)throw new RangeError("Index out of range")}p.prototype.writeUintLE=p.prototype.writeUIntLE=function(e,t,r,i){if(e=+e,t=t>>>0,r=r>>>0,!i){let c=Math.pow(2,8*r)-1;k(this,e,t,r,c,0)}let o=1,s=0;for(this[t]=e&255;++s<r&&(o*=256);)this[t+s]=e/o&255;return t+r};p.prototype.writeUintBE=p.prototype.writeUIntBE=function(e,t,r,i){if(e=+e,t=t>>>0,r=r>>>0,!i){let c=Math.pow(2,8*r)-1;k(this,e,t,r,c,0)}let o=r-1,s=1;for(this[t+o]=e&255;--o>=0&&(s*=256);)this[t+o]=e/s&255;return t+r};p.prototype.writeUint8=p.prototype.writeUInt8=function(e,t,r){return e=+e,t=t>>>0,r||k(this,e,t,1,255,0),this[t]=e&255,t+1};p.prototype.writeUint16LE=p.prototype.writeUInt16LE=function(e,t,r){return e=+e,t=t>>>0,r||k(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};p.prototype.writeUint16BE=p.prototype.writeUInt16BE=function(e,t,r){return e=+e,t=t>>>0,r||k(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};p.prototype.writeUint32LE=p.prototype.writeUInt32LE=function(e,t,r){return e=+e,t=t>>>0,r||k(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4};p.prototype.writeUint32BE=p.prototype.writeUInt32BE=function(e,t,r){return e=+e,t=t>>>0,r||k(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function si(n,e,t,r,i){hi(e,r,i,n,t,7);let o=Number(e&BigInt(4294967295));n[t++]=o,o=o>>8,n[t++]=o,o=o>>8,n[t++]=o,o=o>>8,n[t++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return n[t++]=s,s=s>>8,n[t++]=s,s=s>>8,n[t++]=s,s=s>>8,n[t++]=s,t}function ci(n,e,t,r,i){hi(e,r,i,n,t,7);let o=Number(e&BigInt(4294967295));n[t+7]=o,o=o>>8,n[t+6]=o,o=o>>8,n[t+5]=o,o=o>>8,n[t+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return n[t+3]=s,s=s>>8,n[t+2]=s,s=s>>8,n[t+1]=s,s=s>>8,n[t]=s,t+8}p.prototype.writeBigUInt64LE=de(function(e,t=0){return si(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});p.prototype.writeBigUInt64BE=de(function(e,t=0){return ci(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});p.prototype.writeIntLE=function(e,t,r,i){if(e=+e,t=t>>>0,!i){let f=Math.pow(2,8*r-1);k(this,e,t,r,f-1,-f)}let o=0,s=1,c=0;for(this[t]=e&255;++o<r&&(s*=256);)e<0&&c===0&&this[t+o-1]!==0&&(c=1),this[t+o]=(e/s>>0)-c&255;return t+r};p.prototype.writeIntBE=function(e,t,r,i){if(e=+e,t=t>>>0,!i){let f=Math.pow(2,8*r-1);k(this,e,t,r,f-1,-f)}let o=r-1,s=1,c=0;for(this[t+o]=e&255;--o>=0&&(s*=256);)e<0&&c===0&&this[t+o+1]!==0&&(c=1),this[t+o]=(e/s>>0)-c&255;return t+r};p.prototype.writeInt8=function(e,t,r){return e=+e,t=t>>>0,r||k(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};p.prototype.writeInt16LE=function(e,t,r){return e=+e,t=t>>>0,r||k(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};p.prototype.writeInt16BE=function(e,t,r){return e=+e,t=t>>>0,r||k(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};p.prototype.writeInt32LE=function(e,t,r){return e=+e,t=t>>>0,r||k(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4};p.prototype.writeInt32BE=function(e,t,r){return e=+e,t=t>>>0,r||k(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};p.prototype.writeBigInt64LE=de(function(e,t=0){return si(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});p.prototype.writeBigInt64BE=de(function(e,t=0){return ci(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ui(n,e,t,r,i,o){if(t+r>n.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function ai(n,e,t,r,i){return e=+e,t=t>>>0,i||ui(n,e,t,4,34028234663852886e22,-34028234663852886e22),qe.write(n,e,t,r,23,4),t+4}p.prototype.writeFloatLE=function(e,t,r){return ai(this,e,t,!0,r)};p.prototype.writeFloatBE=function(e,t,r){return ai(this,e,t,!1,r)};function fi(n,e,t,r,i){return e=+e,t=t>>>0,i||ui(n,e,t,8,17976931348623157e292,-17976931348623157e292),qe.write(n,e,t,r,52,8),t+8}p.prototype.writeDoubleLE=function(e,t,r){return fi(this,e,t,!0,r)};p.prototype.writeDoubleBE=function(e,t,r){return fi(this,e,t,!1,r)};p.prototype.copy=function(e,t,r,i){if(!p.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),!i&&i!==0&&(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<r&&(i=r),i===r||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=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-t<i-r&&(i=e.length-t+r);let o=i-r;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,r,i):Uint8Array.prototype.set.call(e,this.subarray(r,i),t),o};p.prototype.fill=function(e,t,r,i){if(typeof e=="string"){if(typeof t=="string"?(i=t,t=0,r=this.length):typeof r=="string"&&(i=r,r=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!p.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(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;t=t>>>0,r=r===void 0?this.length:r>>>0,e||(e=0);let o;if(typeof e=="number")for(o=t;o<r;++o)this[o]=e;else{let s=p.isBuffer(e)?e:p.from(e,i),c=s.length;if(c===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<r-t;++o)this[o+t]=s[o%c]}return this};var $e={};function Or(n,e,t){$e[n]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${n}]`,this.stack,delete this.name}get code(){return n}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${n}]: ${this.message}`}}}Or("ERR_BUFFER_OUT_OF_BOUNDS",function(n){return n?`${n} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Or("ERR_INVALID_ARG_TYPE",function(n,e){return`The "${n}" argument must be of type number. Received type ${typeof e}`},TypeError);Or("ERR_OUT_OF_RANGE",function(n,e,t){let r=`The value of "${n}" is out of range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=ei(String(t)):typeof t=="bigint"&&(i=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=ei(i)),i+="n"),r+=` It must be ${e}. Received ${i}`,r},RangeError);function ei(n){let e="",t=n.length,r=n[0]==="-"?1:0;for(;t>=r+4;t-=3)e=`_${n.slice(t-3,t)}${e}`;return`${n.slice(0,t)}${e}`}function Ps(n,e,t){Je(e,"offset"),(n[e]===void 0||n[e+t]===void 0)&&ut(e,n.length-(t+1))}function hi(n,e,t,r,i,o){if(n>t||n<e){let s=typeof e=="bigint"?"n":"",c;throw o>3?e===0||e===BigInt(0)?c=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:c=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:c=`>= ${e}${s} and <= ${t}${s}`,new $e.ERR_OUT_OF_RANGE("value",c,n)}Ps(r,i,o)}function Je(n,e){if(typeof n!="number")throw new $e.ERR_INVALID_ARG_TYPE(e,"number",n)}function ut(n,e,t){throw Math.floor(n)!==n?(Je(n,t),new $e.ERR_OUT_OF_RANGE(t||"offset","an integer",n)):e<0?new $e.ERR_BUFFER_OUT_OF_BOUNDS:new $e.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,n)}var Ds=/[^+/0-9A-Za-z-_]/g;function Ms(n){if(n=n.split("=")[0],n=n.trim().replace(Ds,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function kr(n,e){e=e||1/0;let t,r=n.length,i=null,o=[];for(let s=0;s<r;++s){if(t=n.charCodeAt(s),t>55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=t;continue}if(t<56320){(e-=3)>-1&&o.push(239,191,189),i=t;continue}t=(i-55296<<10|t-56320)+65536}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,t<128){if((e-=1)<0)break;o.push(t)}else if(t<2048){if((e-=2)<0)break;o.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;o.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;o.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return o}function Rs(n){let e=[];for(let t=0;t<n.length;++t)e.push(n.charCodeAt(t)&255);return e}function Fs(n,e){let t,r,i,o=[];for(let s=0;s<n.length&&!((e-=2)<0);++s)t=n.charCodeAt(s),r=t>>8,i=t%256,o.push(i),o.push(r);return o}function di(n){return Ar.toByteArray(Ms(n))}function Rt(n,e,t,r){let i;for(i=0;i<r&&!(i+t>=e.length||i>=n.length);++i)e[i+t]=n[i];return i}function Y(n,e){return n instanceof e||n!=null&&n.constructor!=null&&n.constructor.name!=null&&n.constructor.name===e.name}function Ur(n){return n!==n}var Ns=function(){let n="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let r=t*16;for(let i=0;i<16;++i)e[r+i]=n[t]+n[i]}return e}();function de(n){return typeof BigInt>"u"?Vs:n}function Vs(){throw new Error("BigInt not supported")}});var a=v(()=>{"use strict";var li=We().Buffer,{Buffer:js}=We();li.prototype.writeBigUInt64BE=js.prototype.writeBigUInt64BE;globalThis.Buffer=li});var yi=v((Hu,pi)=>{var zu=u(a()),$s=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ft=()=>$s.now(),qs=n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),Lr=n=>n===1/0||qs(n),Pr=class n{constructor({max:e=1/0,ttl:t,updateAgeOnGet:r=!1,checkAgeOnGet:i=!1,noUpdateTTL:o=!1,dispose:s,noDisposeOnSet:c=!1}={}){if(this.expirations=Object.create(null),this.data=new Map,this.expirationMap=new Map,t!==void 0&&!Lr(t))throw new TypeError("ttl must be positive integer or Infinity if set");if(!Lr(e))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=t,this.max=e,this.updateAgeOnGet=!!r,this.checkAgeOnGet=!!i,this.noUpdateTTL=!!o,this.noDisposeOnSet=!!c,s!==void 0){if(typeof s!="function")throw new TypeError("dispose must be function if set");this.dispose=s}this.timer=void 0,this.timerExpiration=void 0}setTimer(e,t){if(this.timerExpiration<e)return;this.timer&&clearTimeout(this.timer);let r=setTimeout(()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let i in this.expirations){this.setTimer(i,i-Ft());break}},t);r.unref&&r.unref(),this.timerExpiration=e,this.timer=r}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!==n.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(let[t,r]of e)this.dispose(r,t,"delete")}setTTL(e,t=this.ttl){let r=this.expirationMap.get(e);if(r!==void 0){let i=this.expirations[r];!i||i.length<=1?delete this.expirations[r]:this.expirations[r]=i.filter(o=>o!==e)}if(t!==1/0){let i=Math.floor(Ft()+t);this.expirationMap.set(e,i),this.expirations[i]||(this.expirations[i]=[],this.setTimer(i,t)),this.expirations[i].push(e)}else this.expirationMap.set(e,1/0)}set(e,t,{ttl:r=this.ttl,noUpdateTTL:i=this.noUpdateTTL,noDisposeOnSet:o=this.noDisposeOnSet}={}){if(!Lr(r))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(e)){i||this.setTTL(e,r);let s=this.data.get(e);s!==t&&(this.data.set(e,t),o||this.dispose(s,e,"set"))}else this.setTTL(e,r),this.data.set(e,t);for(;this.size>this.max;)this.purgeToCapacity();return this}has(e){return this.data.has(e)}getRemainingTTL(e){let t=this.expirationMap.get(e);return t===1/0?t:t!==void 0?Math.max(0,Math.ceil(t-Ft())):0}get(e,{updateAgeOnGet:t=this.updateAgeOnGet,ttl:r=this.ttl,checkAgeOnGet:i=this.checkAgeOnGet}={}){let o=this.data.get(e);if(i&&this.getRemainingTTL(e)===0){this.delete(e);return}return t&&this.setTTL(e,r),o}dispose(e,t){}delete(e){let t=this.expirationMap.get(e);if(t!==void 0){let r=this.data.get(e);this.data.delete(e),this.expirationMap.delete(e);let i=this.expirations[t];return i&&(i.length<=1?delete this.expirations[t]:this.expirations[t]=i.filter(o=>o!==e)),this.dispose(r,e,"delete"),this.size===0&&this.cancelTimer(),!0}return!1}purgeToCapacity(){for(let e in this.expirations){let t=this.expirations[e];if(this.size-t.length>=this.max){delete this.expirations[e];let r=[];for(let i of t)r.push([i,this.data.get(i)]),this.data.delete(i),this.expirationMap.delete(i);for(let[i,o]of r)this.dispose(o,i,"evict")}else{let r=this.size-this.max,i=[];for(let o of t.splice(0,r))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(Ft());for(let t in this.expirations){if(t==="Infinity"||t>e)return;let r=[...this.expirations[t]||[]],i=[];delete this.expirations[t];for(let o of r)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 t of this.expirations[e])yield[t,this.data.get(t)]}*keys(){for(let e in this.expirations)for(let t of this.expirations[e])yield t}*values(){for(let e in this.expirations)for(let t of this.expirations[e])yield this.data.get(t)}[Symbol.iterator](){return this.entries()}};pi.exports=Pr});var Ui=v(Oi=>{"use strict";var wf=u(a());Oi.supports=function(...e){let t=e.reduce((r,i)=>Object.assign(r,i),{});return Object.assign(t,{snapshots:t.snapshots||!1,permanence:t.permanence||!1,seek:t.seek||!1,clear:t.clear||!1,getMany:t.getMany||!1,keyIterator:t.keyIterator||!1,valueIterator:t.valueIterator||!1,iteratorNextv:t.iteratorNextv||!1,iteratorAll:t.iteratorAll||!1,status:t.status||!1,createIfMissing:t.createIfMissing||!1,errorIfExists:t.errorIfExists||!1,deferredOpen:t.deferredOpen||!1,promises:t.promises||!1,streams:t.streams||!1,encodings:Object.assign({},t.encodings),events:Object.assign({},t.events),additionalMethods:Object.assign({},t.additionalMethods)})}});var j=v((xf,Ci)=>{"use strict";var vf=u(a());Ci.exports=class extends Error{constructor(e,t){super(e||""),typeof t=="object"&&t!==null&&(t.code&&(this.code=String(t.code)),t.expected&&(this.expected=!0),t.transient&&(this.transient=!0),t.cause&&(this.cause=t.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}});var Yr=v((bf,Li)=>{"use strict";var Ef=u(a()),zr=null;Li.exports=function(){return zr===null&&(zr={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),zr}});var Qr=v(Pi=>{"use strict";var _f=u(a()),Xr=j(),Tc=new Set(["buffer","view","utf8"]),Zr=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"||!Tc.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 Xr(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new Xr(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new Xr(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};Pi.Encoding=Zr});var nn=v(jt=>{"use strict";var Bf=u(a()),{Buffer:tn}=We()||{},{Encoding:rn}=Qr(),_c=Yr(),pt=class extends rn{constructor(e){super({...e,format:"buffer"})}createViewTranscoder(){return new yt({encode:this.encode,decode:e=>this.decode(tn.from(e.buffer,e.byteOffset,e.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},yt=class extends rn{constructor(e){super({...e,format:"view"})}createBufferTranscoder(){return new pt({encode:e=>{let t=this.encode(e);return tn.from(t.buffer,t.byteOffset,t.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},en=class extends rn{constructor(e){super({...e,format:"utf8"})}createBufferTranscoder(){return new pt({encode:e=>tn.from(this.encode(e),"utf8"),decode:e=>this.decode(e.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:e,textDecoder:t}=_c();return new yt({encode:r=>e.encode(this.encode(r)),decode:r=>this.decode(t.decode(r)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};jt.BufferFormat=pt;jt.ViewFormat=yt;jt.UTF8Format=en});var Fi=v(Ke=>{"use strict";var kf=u(a()),{Buffer:A}=We()||{Buffer:{isBuffer:()=>!1}},{textEncoder:Mi,textDecoder:Di}=Yr()(),{BufferFormat:mt,ViewFormat:on,UTF8Format:Ri}=nn(),$t=n=>n;Ke.utf8=new Ri({encode:function(n){return A.isBuffer(n)?n.toString("utf8"):ArrayBuffer.isView(n)?Di.decode(n):String(n)},decode:$t,name:"utf8",createViewTranscoder(){return new on({encode:function(n){return ArrayBuffer.isView(n)?n:Mi.encode(n)},decode:function(n){return Di.decode(n)},name:`${this.name}+view`})},createBufferTranscoder(){return new mt({encode:function(n){return A.isBuffer(n)?n:ArrayBuffer.isView(n)?A.from(n.buffer,n.byteOffset,n.byteLength):A.from(String(n),"utf8")},decode:function(n){return n.toString("utf8")},name:`${this.name}+buffer`})}});Ke.json=new Ri({encode:JSON.stringify,decode:JSON.parse,name:"json"});Ke.buffer=new mt({encode:function(n){return A.isBuffer(n)?n:ArrayBuffer.isView(n)?A.from(n.buffer,n.byteOffset,n.byteLength):A.from(String(n),"utf8")},decode:$t,name:"buffer",createViewTranscoder(){return new on({encode:function(n){return ArrayBuffer.isView(n)?n:A.from(String(n),"utf8")},decode:function(n){return A.from(n.buffer,n.byteOffset,n.byteLength)},name:`${this.name}+view`})}});Ke.view=new on({encode:function(n){return ArrayBuffer.isView(n)?n:Mi.encode(n)},decode:$t,name:"view",createBufferTranscoder(){return new mt({encode:function(n){return A.isBuffer(n)?n:ArrayBuffer.isView(n)?A.from(n.buffer,n.byteOffset,n.byteLength):A.from(String(n),"utf8")},decode:$t,name:`${this.name}+buffer`})}});Ke.hex=new mt({encode:function(n){return A.isBuffer(n)?n:A.from(String(n),"hex")},decode:function(n){return n.toString("hex")},name:"hex"});Ke.base64=new mt({encode:function(n){return A.isBuffer(n)?n:A.from(String(n),"base64")},decode:function(n){return n.toString("base64")},name:"base64"})});var ji=v(Vi=>{"use strict";var If=u(a()),Ni=j(),Jt=Fi(),{Encoding:Ac}=Qr(),{BufferFormat:Bc,ViewFormat:Sc,UTF8Format:kc}=nn(),wt=Symbol("formats"),qt=Symbol("encodings"),Kc=new Set(["buffer","view","utf8"]),sn=class{constructor(e){if(Array.isArray(e)){if(!e.every(t=>Kc.has(t)))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}else throw new TypeError("The first argument 'formats' must be an array");this[qt]=new Map,this[wt]=new Set(e);for(let t in Jt)try{this.encoding(t)}catch(r){if(r.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw r}}encodings(){return Array.from(new Set(this[qt].values()))}encoding(e){let t=this[qt].get(e);if(t===void 0){if(typeof e=="string"&&e!==""){if(t=Cc[e],!t)throw new Ni(`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");t=Ic(e)}let{name:r,format:i}=t;if(!this[wt].has(i))if(this[wt].has("view"))t=t.createViewTranscoder();else if(this[wt].has("buffer"))t=t.createBufferTranscoder();else if(this[wt].has("utf8"))t=t.createUTF8Transcoder();else throw new Ni(`Encoding '${r}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[e,r,t.name,t.commonName])this[qt].set(o,t)}return t}};Vi.Transcoder=sn;function Ic(n){if(n instanceof Ac)return n;let e="type"in n&&typeof n.type=="string"?n.type:void 0,t=n.name||e||`anonymous-${Lc++}`;switch(Oc(n)){case"view":return new Sc({...n,name:t});case"utf8":return new kc({...n,name:t});case"buffer":return new Bc({...n,name:t});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function Oc(n){return"format"in n&&n.format!==void 0?n.format:"buffer"in n&&typeof n.buffer=="boolean"?n.buffer?"buffer":"utf8":"code"in n&&Number.isInteger(n.code)?"view":"buffer"}var Uc={binary:Jt.buffer,"utf-8":Jt.utf8},Cc={...Jt,...Uc},Lc=0});var Qi=v((Of,cn)=>{"use strict";var Uf=u(a()),Xe=typeof Reflect=="object"?Reflect:null,$i=Xe&&typeof Xe.apply=="function"?Xe.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)},Gt;Xe&&typeof Xe.ownKeys=="function"?Gt=Xe.ownKeys:Object.getOwnPropertySymbols?Gt=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Gt=function(e){return Object.getOwnPropertyNames(e)};function Pc(n){console&&console.warn&&console.warn(n)}var Ji=Number.isNaN||function(e){return e!==e};function E(){E.init.call(this)}cn.exports=E;cn.exports.once=Fc;E.EventEmitter=E;E.prototype._events=void 0;E.prototype._eventsCount=0;E.prototype._maxListeners=void 0;var qi=10;function Wt(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(E,"defaultMaxListeners",{enumerable:!0,get:function(){return qi},set:function(n){if(typeof n!="number"||n<0||Ji(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");qi=n}});E.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};E.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ji(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 Gi(n){return n._maxListeners===void 0?E.defaultMaxListeners:n._maxListeners}E.prototype.getMaxListeners=function(){return Gi(this)};E.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);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(t.length>0&&(s=t[0]),s instanceof Error)throw s;var c=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw c.context=s,c}var f=o[e];if(f===void 0)return!1;if(typeof f=="function")$i(f,this,t);else for(var h=f.length,l=Xi(f,h),r=0;r<h;++r)$i(l[r],this,t);return!0};function Wi(n,e,t,r){var i,o,s;if(Wt(t),o=n._events,o===void 0?(o=n._events=Object.create(null),n._eventsCount=0):(o.newListener!==void 0&&(n.emit("newListener",e,t.listener?t.listener:t),o=n._events),s=o[e]),s===void 0)s=o[e]=t,++n._eventsCount;else if(typeof s=="function"?s=o[e]=r?[t,s]:[s,t]:r?s.unshift(t):s.push(t),i=Gi(n),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=n,c.type=e,c.count=s.length,Pc(c)}return n}E.prototype.addListener=function(e,t){return Wi(this,e,t,!1)};E.prototype.on=E.prototype.addListener;E.prototype.prependListener=function(e,t){return Wi(this,e,t,!0)};function Dc(){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 Hi(n,e,t){var r={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},i=Dc.bind(r);return i.listener=t,r.wrapFn=i,i}E.prototype.once=function(e,t){return Wt(t),this.on(e,Hi(this,e,t)),this};E.prototype.prependOnceListener=function(e,t){return Wt(t),this.prependListener(e,Hi(this,e,t)),this};E.prototype.removeListener=function(e,t){var r,i,o,s,c;if(Wt(t),i=this._events,i===void 0)return this;if(r=i[e],r===void 0)return this;if(r===t||r.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,r.listener||t));else if(typeof r!="function"){for(o=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){c=r[s].listener,o=s;break}if(o<0)return this;o===0?r.shift():Mc(r,o),r.length===1&&(i[e]=r[0]),i.removeListener!==void 0&&this.emit("removeListener",e,c||t)}return this};E.prototype.off=E.prototype.removeListener;E.prototype.removeAllListeners=function(e){var t,r,i;if(r=this._events,r===void 0)return this;if(r.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):r[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete r[e]),this;if(arguments.length===0){var o=Object.keys(r),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(t=r[e],typeof t=="function")this.removeListener(e,t);else if(t!==void 0)for(i=t.length-1;i>=0;i--)this.removeListener(e,t[i]);return this};function zi(n,e,t){var r=n._events;if(r===void 0)return[];var i=r[e];return i===void 0?[]:typeof i=="function"?t?[i.listener||i]:[i]:t?Rc(i):Xi(i,i.length)}E.prototype.listeners=function(e){return zi(this,e,!0)};E.prototype.rawListeners=function(e){return zi(this,e,!1)};E.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):Yi.call(n,e)};E.prototype.listenerCount=Yi;function Yi(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}E.prototype.eventNames=function(){return this._eventsCount>0?Gt(this._events):[]};function Xi(n,e){for(var t=new Array(e),r=0;r<e;++r)t[r]=n[r];return t}function Mc(n,e){for(;e+1<n.length;e++)n[e]=n[e+1];n.pop()}function Rc(n){for(var e=new Array(n.length),t=0;t<e.length;++t)e[t]=n[t].listener||n[t];return e}function Fc(n,e){return new Promise(function(t,r){function i(s){n.removeListener(e,o),r(s)}function o(){typeof n.removeListener=="function"&&n.removeListener("error",i),t([].slice.call(arguments))}Zi(n,e,o,{once:!0}),e!=="error"&&Nc(n,i,{once:!0})})}function Nc(n,e,t){typeof n.on=="function"&&Zi(n,"error",e,t)}function Zi(n,e,t,r){if(typeof n.on=="function")r.once?n.once(e,t):n.on(e,t);else if(typeof n.addEventListener=="function")n.addEventListener(e,function i(o){r.once&&n.removeEventListener(e,i),t(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof n)}});var to=v((Cf,eo)=>{var Lf=u(a());eo.exports=typeof queueMicrotask=="function"?queueMicrotask:n=>Promise.resolve().then(n)});var gt=v(un=>{"use strict";var Df=u(a()),ro=to();un.fromCallback=function(n,e){if(n===void 0){var t=new Promise(function(r,i){n=function(o,s){o?i(o):r(s)}});n[e!==void 0?e:"promise"]=t}else if(typeof n!="function")throw new TypeError("Callback must be a function");return n};un.fromPromise=function(n,e){if(e===void 0)return n;n.then(function(t){ro(()=>e(null,t))}).catch(function(t){ro(()=>e(t))})}});var Ht=v(an=>{"use strict";var Rf=u(a());an.getCallback=function(n,e){return typeof n=="function"?n:e};an.getOptions=function(n,e){return typeof n=="object"&&n!==null?n:e!==void 0?e:{}}});var ge=v(Zt=>{"use strict";var Nf=u(a()),{fromCallback:fn}=gt(),U=j(),{getOptions:hn,getCallback:no}=Ht(),Ie=Symbol("promise"),Ze=Symbol("callback"),Z=Symbol("working"),Oe=Symbol("handleOne"),ie=Symbol("handleMany"),dn=Symbol("autoClose"),me=Symbol("finishWork"),Q=Symbol("returnMany"),le=Symbol("closing"),xt=Symbol("handleClose"),zt=Symbol("closed"),vt=Symbol("closeCallbacks"),ye=Symbol("keyEncoding"),Ue=Symbol("valueEncoding"),ln=Symbol("abortOnClose"),Yt=Symbol("legacy"),pn=Symbol("keys"),yn=Symbol("values"),pe=Symbol("limit"),R=Symbol("count"),Xt=Object.freeze({}),Vc=()=>{},io=!1,bt=class{constructor(e,t,r){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 t!="object"||t===null)throw new TypeError("The second argument must be an options object");this[zt]=!1,this[vt]=[],this[Z]=!1,this[le]=!1,this[dn]=!1,this[Ze]=null,this[Oe]=this[Oe].bind(this),this[ie]=this[ie].bind(this),this[xt]=this[xt].bind(this),this[ye]=t[ye],this[Ue]=t[Ue],this[Yt]=r,this[pe]=Number.isInteger(t.limit)&&t.limit>=0?t.limit:1/0,this[R]=0,this[ln]=!!t.abortOnClose,this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get count(){return this[R]}get limit(){return this[pe]}next(e){let t;if(e===void 0)t=new Promise((r,i)=>{e=(o,s,c)=>{o?i(o):this[Yt]?s===void 0&&c===void 0?r():r([s,c]):r(s)}});else if(typeof e!="function")throw new TypeError("Callback must be a function");return this[le]?this.nextTick(e,new U("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Z]?this.nextTick(e,new U("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[Z]=!0,this[Ze]=e,this[R]>=this[pe]?this.nextTick(this[Oe],null):this._next(this[Oe])),t}_next(e){this.nextTick(e)}nextv(e,t,r){return r=no(t,r),r=fn(r,Ie),t=hn(t,Xt),Number.isInteger(e)?(this[le]?this.nextTick(r,new U("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Z]?this.nextTick(r,new U("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(e<1&&(e=1),this[pe]<1/0&&(e=Math.min(e,this[pe]-this[R])),this[Z]=!0,this[Ze]=r,e<=0?this.nextTick(this[ie],null,[]):this._nextv(e,t,this[ie])),r[Ie]):(this.nextTick(r,new TypeError("The first argument 'size' must be an integer")),r[Ie])}_nextv(e,t,r){let i=[],o=(s,c,f)=>{if(s)return r(s);if(this[Yt]?c===void 0&&f===void 0:c===void 0)return r(null,i);i.push(this[Yt]?[c,f]:c),i.length===e?r(null,i):this._next(o)};this._next(o)}all(e,t){return t=no(e,t),t=fn(t,Ie),e=hn(e,Xt),this[le]?this.nextTick(t,new U("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Z]?this.nextTick(t,new U("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[Z]=!0,this[Ze]=t,this[dn]=!0,this[R]>=this[pe]?this.nextTick(this[ie],null,[]):this._all(e,this[ie])),t[Ie]}_all(e,t){let r=this[R],i=[],o=()=>{let c=this[pe]<1/0?Math.min(1e3,this[pe]-r):1e3;c<=0?this.nextTick(t,null,i):this._nextv(c,Xt,s)},s=(c,f)=>{c?t(c):f.length===0?t(null,i):(i.push.apply(i,f),r+=f.length,o())};o()}[me](){let e=this[Ze];return this[ln]&&e===null?Vc:(this[Z]=!1,this[Ze]=null,this[le]&&this._close(this[xt]),e)}[Q](e,t,r){this[dn]?this.close(e.bind(null,t,r)):e(t,r)}seek(e,t){if(t=hn(t,Xt),!this[le]){if(this[Z])throw new U("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let r=this.db.keyEncoding(t.keyEncoding||this[ye]),i=r.format;t.keyEncoding!==i&&(t={...t,keyEncoding:i});let o=this.db.prefixKey(r.encode(e),i);this._seek(o,t)}}}_seek(e,t){throw new U("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(e){return e=fn(e,Ie),this[zt]?this.nextTick(e):this[le]?this[vt].push(e):(this[le]=!0,this[vt].push(e),this[Z]?this[ln]&&this[me]()(new U("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[xt])),e[Ie]}_close(e){this.nextTick(e)}[xt](){this[zt]=!0,this.db.detachResource(this);let e=this[vt];this[vt]=[];for(let t of e)t()}async*[Symbol.asyncIterator](){try{let e;for(;(e=await this.next())!==void 0;)yield e}finally{this[zt]||await this.close()}}},Qe=class extends bt{constructor(e,t){super(e,t,!0),this[pn]=t.keys!==!1,this[yn]=t.values!==!1}[Oe](e,t,r){let i=this[me]();if(e)return i(e);try{t=this[pn]&&t!==void 0?this[ye].decode(t):void 0,r=this[yn]&&r!==void 0?this[Ue].decode(r):void 0}catch(o){return i(new we("entry",o))}t===void 0&&r===void 0||this[R]++,i(null,t,r)}[ie](e,t){let r=this[me]();if(e)return this[Q](r,e);try{for(let i of t){let o=i[0],s=i[1];i[0]=this[pn]&&o!==void 0?this[ye].decode(o):void 0,i[1]=this[yn]&&s!==void 0?this[Ue].decode(s):void 0}}catch(i){return this[Q](r,new we("entries",i))}this[R]+=t.length,this[Q](r,null,t)}end(e){return!io&&typeof console<"u"&&(io=!0,console.warn(new U("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)}},mn=class extends bt{constructor(e,t){super(e,t,!1)}[Oe](e,t){let r=this[me]();if(e)return r(e);try{t=t!==void 0?this[ye].decode(t):void 0}catch(i){return r(new we("key",i))}t!==void 0&&this[R]++,r(null,t)}[ie](e,t){let r=this[me]();if(e)return this[Q](r,e);try{for(let i=0;i<t.length;i++){let o=t[i];t[i]=o!==void 0?this[ye].decode(o):void 0}}catch(i){return this[Q](r,new we("keys",i))}this[R]+=t.length,this[Q](r,null,t)}},wn=class extends bt{constructor(e,t){super(e,t,!1)}[Oe](e,t){let r=this[me]();if(e)return r(e);try{t=t!==void 0?this[Ue].decode(t):void 0}catch(i){return r(new we("value",i))}t!==void 0&&this[R]++,r(null,t)}[ie](e,t){let r=this[me]();if(e)return this[Q](r,e);try{for(let i=0;i<t.length;i++){let o=t[i];t[i]=o!==void 0?this[Ue].decode(o):void 0}}catch(i){return this[Q](r,new we("values",i))}this[R]+=t.length,this[Q](r,null,t)}},we=class extends U{constructor(e,t){super(`Iterator could not decode ${e}`,{code:"LEVEL_DECODE_ERROR",cause:t})}};for(let n of["_ended property","_nexting property","_end method"])Object.defineProperty(Qe.prototype,n.split(" ")[0],{get(){throw new U(`The ${n} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new U(`The ${n} has been removed`,{code:"LEVEL_LEGACY"})}});Qe.keyEncoding=ye;Qe.valueEncoding=Ue;Zt.AbstractIterator=Qe;Zt.AbstractKeyIterator=mn;Zt.AbstractValueIterator=wn});var oo=v(gn=>{"use strict";var jf=u(a()),{AbstractKeyIterator:jc,AbstractValueIterator:$c}=ge(),Ce=Symbol("iterator"),Et=Symbol("callback"),et=Symbol("handleOne"),Le=Symbol("handleMany"),Tt=class extends jc{constructor(e,t){super(e,t),this[Ce]=e.iterator({...t,keys:!0,values:!1}),this[et]=this[et].bind(this),this[Le]=this[Le].bind(this)}},Qt=class extends $c{constructor(e,t){super(e,t),this[Ce]=e.iterator({...t,keys:!1,values:!0}),this[et]=this[et].bind(this),this[Le]=this[Le].bind(this)}};for(let n of[Tt,Qt]){let e=n===Tt,t=e?r=>r[0]:r=>r[1];n.prototype._next=function(r){this[Et]=r,this[Ce].next(this[et])},n.prototype[et]=function(r,i,o){let s=this[Et];r?s(r):s(null,e?i:o)},n.prototype._nextv=function(r,i,o){this[Et]=o,this[Ce].nextv(r,i,this[Le])},n.prototype._all=function(r,i){this[Et]=i,this[Ce].all(r,this[Le])},n.prototype[Le]=function(r,i){let o=this[Et];r?o(r):o(null,i.map(t))},n.prototype._seek=function(r,i){this[Ce].seek(r,i)},n.prototype._close=function(r){this[Ce].close(r)}}gn.DefaultKeyIterator=Tt;gn.DefaultValueIterator=Qt});var so=v(or=>{"use strict";var qf=u(a()),{AbstractIterator:qc,AbstractKeyIterator:Jc,AbstractValueIterator:Gc}=ge(),xn=j(),I=Symbol("nut"),nr=Symbol("undefer"),ir=Symbol("factory"),er=class extends qc{constructor(e,t){super(e,t),this[I]=null,this[ir]=()=>e.iterator(t),this.db.defer(()=>this[nr]())}},tr=class extends Jc{constructor(e,t){super(e,t),this[I]=null,this[ir]=()=>e.keys(t),this.db.defer(()=>this[nr]())}},rr=class extends Gc{constructor(e,t){super(e,t),this[I]=null,this[ir]=()=>e.values(t),this.db.defer(()=>this[nr]())}};for(let n of[er,tr,rr])n.prototype[nr]=function(){this.db.status==="open"&&(this[I]=this[ir]())},n.prototype._next=function(e){this[I]!==null?this[I].next(e):this.db.status==="opening"?this.db.defer(()=>this._next(e)):this.nextTick(e,new xn("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},n.prototype._nextv=function(e,t,r){this[I]!==null?this[I].nextv(e,t,r):this.db.status==="opening"?this.db.defer(()=>this._nextv(e,t,r)):this.nextTick(r,new xn("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},n.prototype._all=function(e,t){this[I]!==null?this[I].all(t):this.db.status==="opening"?this.db.defer(()=>this._all(e,t)):this.nextTick(t,new xn("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},n.prototype._seek=function(e,t){this[I]!==null?this[I]._seek(e,t):this.db.status==="opening"&&this.db.defer(()=>this._seek(e,t))},n.prototype._close=function(e){this[I]!==null?this[I].close(e):this.db.status==="opening"?this.db.defer(()=>this._close(e)):this.nextTick(e)};or.DeferredIterator=er;or.DeferredKeyIterator=tr;or.DeferredValueIterator=rr});var bn=v(uo=>{"use strict";var Gf=u(a()),{fromCallback:co}=gt(),sr=j(),{getCallback:Wc,getOptions:Hc}=Ht(),cr=Symbol("promise"),F=Symbol("status"),tt=Symbol("operations"),_t=Symbol("finishClose"),rt=Symbol("closeCallbacks"),vn=class{constructor(e){if(typeof e!="object"||e===null){let t=e===null?"null":typeof e;throw new TypeError(`The first argument must be an abstract-level database, received ${t}`)}this[tt]=[],this[rt]=[],this[F]="open",this[_t]=this[_t].bind(this),this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get length(){return this[tt].length}put(e,t,r){if(this[F]!=="open")throw new sr("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(t);if(i)throw i;let o=r&&r.sublevel!=null?r.sublevel:this.db,s=r,c=o.keyEncoding(r&&r.keyEncoding),f=o.valueEncoding(r&&r.valueEncoding),h=c.format;r={...r,keyEncoding:h,valueEncoding:f.format},o!==this.db&&(r.sublevel=null);let l=o.prefixKey(c.encode(e),h),d=f.encode(t);return this._put(l,d,r),this[tt].push({...s,type:"put",key:e,value:t}),this}_put(e,t,r){}del(e,t){if(this[F]!=="open")throw new sr("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let r=this.db._checkKey(e);if(r)throw r;let i=t&&t.sublevel!=null?t.sublevel:this.db,o=t,s=i.keyEncoding(t&&t.keyEncoding),c=s.format;return t={...t,keyEncoding:c},i!==this.db&&(t.sublevel=null),this._del(i.prefixKey(s.encode(e),c),t),this[tt].push({...o,type:"del",key:e}),this}_del(e,t){}clear(){if(this[F]!=="open")throw new sr("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[tt]=[],this}_clear(){}write(e,t){return t=Wc(e,t),t=co(t,cr),e=Hc(e),this[F]!=="open"?this.nextTick(t,new sr("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(t):(this[F]="writing",this._write(e,r=>{this[F]="closing",this[rt].push(()=>t(r)),r||this.db.emit("batch",this[tt]),this._close(this[_t])})),t[cr]}_write(e,t){}close(e){return e=co(e,cr),this[F]==="closing"?this[rt].push(e):this[F]==="closed"?this.nextTick(e):(this[rt].push(e),this[F]!=="writing"&&(this[F]="closing",this._close(this[_t]))),e[cr]}_close(e){this.nextTick(e)}[_t](){this[F]="closed",this.db.detachResource(this);let e=this[rt];this[rt]=[];for(let t of e)t()}};uo.AbstractChainedBatch=vn});var fo=v(ao=>{"use strict";var Hf=u(a()),{AbstractChainedBatch:zc}=bn(),Yc=j(),nt=Symbol("encoded"),En=class extends zc{constructor(e){super(e),this[nt]=[]}_put(e,t,r){this[nt].push({...r,type:"put",key:e,value:t})}_del(e,t){this[nt].push({...t,type:"del",key:e})}_clear(){this[nt]=[]}_write(e,t){this.db.status==="opening"?this.db.defer(()=>this._write(e,t)):this.db.status==="open"?this[nt].length===0?this.nextTick(t):this.db._batch(this[nt],e,t):this.nextTick(t,new Yc("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};ao.DefaultChainedBatch=En});var po=v((zf,lo)=>{"use strict";var Yf=u(a()),ho=j(),Xc=Object.prototype.hasOwnProperty,Zc=new Set(["lt","lte","gt","gte"]);lo.exports=function(n,e){let t={};for(let r in n)if(Xc.call(n,r)&&!(r==="keyEncoding"||r==="valueEncoding")){if(r==="start"||r==="end")throw new ho(`The legacy range option '${r}' has been removed`,{code:"LEVEL_LEGACY"});if(r==="encoding")throw new ho("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});Zc.has(r)?t[r]=e.encode(n[r]):t[r]=n[r]}return t.reverse=!!t.reverse,t.limit=Number.isInteger(t.limit)&&t.limit>=0?t.limit:-1,t}});var Tn=v((Xf,mo)=>{var Zf=u(a());var yo;mo.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):n=>(yo||(yo=Promise.resolve())).then(n).catch(e=>setTimeout(()=>{throw e},0))});var xo=v((Qf,go)=>{"use strict";var eh=u(a()),wo=Tn();go.exports=function(n,...e){e.length===0?wo(n):wo(()=>n(...e))}});var vo=v(ur=>{"use strict";var rh=u(a()),{AbstractIterator:Qc,AbstractKeyIterator:eu,AbstractValueIterator:tu}=ge(),it=Symbol("unfix"),$=Symbol("iterator"),Pe=Symbol("handleOne"),xe=Symbol("handleMany"),oe=Symbol("callback"),At=class extends Qc{constructor(e,t,r,i){super(e,t),this[$]=r,this[it]=i,this[Pe]=this[Pe].bind(this),this[xe]=this[xe].bind(this),this[oe]=null}[Pe](e,t,r){let i=this[oe];if(e)return i(e);t!==void 0&&(t=this[it](t)),i(e,t,r)}[xe](e,t){let r=this[oe];if(e)return r(e);for(let i of t){let o=i[0];o!==void 0&&(i[0]=this[it](o))}r(e,t)}},Bt=class extends eu{constructor(e,t,r,i){super(e,t),this[$]=r,this[it]=i,this[Pe]=this[Pe].bind(this),this[xe]=this[xe].bind(this),this[oe]=null}[Pe](e,t){let r=this[oe];if(e)return r(e);t!==void 0&&(t=this[it](t)),r(e,t)}[xe](e,t){let r=this[oe];if(e)return r(e);for(let i=0;i<t.length;i++){let o=t[i];o!==void 0&&(t[i]=this[it](o))}r(e,t)}},St=class extends tu{constructor(e,t,r){super(e,t),this[$]=r}};for(let n of[At,Bt])n.prototype._next=function(e){this[oe]=e,this[$].next(this[Pe])},n.prototype._nextv=function(e,t,r){this[oe]=r,this[$].nextv(e,t,this[xe])},n.prototype._all=function(e,t){this[oe]=t,this[$].all(e,this[xe])};for(let n of[St])n.prototype._next=function(e){this[$].next(e)},n.prototype._nextv=function(e,t,r){this[$].nextv(e,t,r)},n.prototype._all=function(e,t){this[$].all(e,t)};for(let n of[At,Bt,St])n.prototype._seek=function(e,t){this[$].seek(e,t)},n.prototype._close=function(e){this[$].close(e)};ur.AbstractSublevelIterator=At;ur.AbstractSublevelKeyIterator=Bt;ur.AbstractSublevelValueIterator=St});var _o=v((nh,To)=>{"use strict";var ih=u(a()),_n=j(),{Buffer:Sn}=We()||{},{AbstractSublevelIterator:ru,AbstractSublevelKeyIterator:nu,AbstractSublevelValueIterator:iu}=vo(),se=Symbol("prefix"),bo=Symbol("upperBound"),kt=Symbol("prefixRange"),C=Symbol("parent"),An=Symbol("unfix"),Eo=new TextEncoder,ou={separator:"!"};To.exports=function({AbstractLevel:n}){class e extends n{static defaults(r){if(typeof r=="string")throw new _n("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(r&&r.open)throw new _n("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return r==null?ou:r.separator?r:{...r,separator:"!"}}constructor(r,i,o){let{separator:s,manifest:c,...f}=e.defaults(o);i=cu(i,s);let h=s.charCodeAt(0)+1,l=r[C]||r;if(!Eo.encode(i).every(w=>w>h&&w<127))throw new _n(`Prefix must use bytes > ${h} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(su(l,c),f);let d=(r.prefix||"")+s+i+s,y=d.slice(0,-1)+String.fromCharCode(h);this[C]=l,this[se]=new ar(d),this[bo]=new ar(y),this[An]=new kn,this.nextTick=l.nextTick}prefixKey(r,i){if(i==="utf8")return this[se].utf8+r;if(r.byteLength===0)return this[se][i];if(i==="view"){let o=this[se].view,s=new Uint8Array(o.byteLength+r.byteLength);return s.set(o,0),s.set(r,o.byteLength),s}else{let o=this[se].buffer;return Sn.concat([o,r],o.byteLength+r.byteLength)}}[kt](r,i){r.gte!==void 0?r.gte=this.prefixKey(r.gte,i):r.gt!==void 0?r.gt=this.prefixKey(r.gt,i):r.gte=this[se][i],r.lte!==void 0?r.lte=this.prefixKey(r.lte,i):r.lt!==void 0?r.lt=this.prefixKey(r.lt,i):r.lte=this[bo][i]}get prefix(){return this[se].utf8}get db(){return this[C]}_open(r,i){this[C].open({passive:!0},i)}_put(r,i,o,s){this[C].put(r,i,o,s)}_get(r,i,o){this[C].get(r,i,o)}_getMany(r,i,o){this[C].getMany(r,i,o)}_del(r,i,o){this[C].del(r,i,o)}_batch(r,i,o){this[C].batch(r,i,o)}_clear(r,i){this[kt](r,r.keyEncoding),this[C].clear(r,i)}_iterator(r){this[kt](r,r.keyEncoding);let i=this[C].iterator(r),o=this[An].get(this[se].utf8.length,r.keyEncoding);return new ru(this,r,i,o)}_keys(r){this[kt](r,r.keyEncoding);let i=this[C].keys(r),o=this[An].get(this[se].utf8.length,r.keyEncoding);return new nu(this,r,i,o)}_values(r){this[kt](r,r.keyEncoding);let i=this[C].values(r);return new iu(this,r,i)}}return{AbstractSublevel:e}};var su=function(n,e){return{...n.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...e,encodings:{utf8:Bn(n,"utf8"),buffer:Bn(n,"buffer"),view:Bn(n,"view")}}},Bn=function(n,e){return n.supports.encodings[e]?n.keyEncoding(e).name===e:!1},ar=class{constructor(e){this.utf8=e,this.view=Eo.encode(e),this.buffer=Sn?Sn.from(this.view.buffer,0,this.view.byteLength):{}}},kn=class{constructor(){this.cache=new Map}get(e,t){let r=this.cache.get(t);return r===void 0&&(t==="view"?r=(function(i,o){return o.subarray(i)}).bind(null,e):r=(function(i,o){return o.slice(i)}).bind(null,e),this.cache.set(t,r)),r}},cu=function(n,e){let t=0,r=n.length;for(;t<r&&n[t]===e;)t++;for(;r>t&&n[r-1]===e;)r--;return n.slice(t,r)}});var Cn=v(Un=>{"use strict";var sh=u(a()),{supports:uu}=Ui(),{Transcoder:au}=ji(),{EventEmitter:fu}=Qi(),{fromCallback:ve}=gt(),q=j(),{AbstractIterator:De}=ge(),{DefaultKeyIterator:hu,DefaultValueIterator:du}=oo(),{DeferredIterator:lu,DeferredKeyIterator:pu,DeferredValueIterator:yu}=so(),{DefaultChainedBatch:Ao}=fo(),{getCallback:Me,getOptions:be}=Ht(),fr=po(),g=Symbol("promise"),ce=Symbol("landed"),Re=Symbol("resources"),Kn=Symbol("closeResources"),Kt=Symbol("operations"),It=Symbol("undefer"),hr=Symbol("deferOpen"),Bo=Symbol("options"),x=Symbol("status"),Fe=Symbol("defaultOptions"),ot=Symbol("transcoder"),dr=Symbol("keyEncoding"),In=Symbol("valueEncoding"),mu=()=>{},Ot=class extends fu{constructor(e,t){if(super(),typeof e!="object"||e===null)throw new TypeError("The first argument 'manifest' must be an object");t=be(t);let{keyEncoding:r,valueEncoding:i,passive:o,...s}=t;this[Re]=new Set,this[Kt]=[],this[hr]=!0,this[Bo]=s,this[x]="opening",this.supports=uu(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[ot]=new au(wu(this)),this[dr]=this[ot].encoding(r||"utf8"),this[In]=this[ot].encoding(i||"utf8");for(let c of this[ot].encodings())this.supports.encodings[c.commonName]||(this.supports.encodings[c.commonName]=!0);this[Fe]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[dr].commonName,valueEncoding:this[In].commonName}),key:Object.freeze({keyEncoding:this[dr].commonName})},this.nextTick(()=>{this[hr]&&this.open({passive:!1},mu)})}get status(){return this[x]}keyEncoding(e){return this[ot].encoding(e??this[dr])}valueEncoding(e){return this[ot].encoding(e??this[In])}open(e,t){t=Me(e,t),t=ve(t,g),e={...this[Bo],...be(e)},e.createIfMissing=e.createIfMissing!==!1,e.errorIfExists=!!e.errorIfExists;let r=i=>{this[x]==="closing"||this[x]==="opening"?this.once(ce,i?()=>r(i):r):this[x]!=="open"?t(new q("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):t()};return e.passive?this[x]==="opening"?this.once(ce,r):this.nextTick(r):this[x]==="closed"||this[hr]?(this[hr]=!1,this[x]="opening",this.emit("opening"),this._open(e,i=>{if(i){this[x]="closed",this[Kn](()=>{this.emit(ce),r(i)}),this[It]();return}this[x]="open",this[It](),this.emit(ce),this[x]==="open"&&this.emit("open"),this[x]==="open"&&this.emit("ready"),r()})):this[x]==="open"?this.nextTick(r):this.once(ce,()=>this.open(e,t)),t[g]}_open(e,t){this.nextTick(t)}close(e){e=ve(e,g);let t=r=>{this[x]==="opening"||this[x]==="closing"?this.once(ce,r?t(r):t):this[x]!=="closed"?e(new q("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:r})):e()};if(this[x]==="open"){this[x]="closing",this.emit("closing");let r=i=>{this[x]="open",this[It](),this.emit(ce),t(i)};this[Kn](()=>{this._close(i=>{if(i)return r(i);this[x]="closed",this[It](),this.emit(ce),this[x]==="closed"&&this.emit("closed"),t()})})}else this[x]==="closed"?this.nextTick(t):this.once(ce,()=>this.close(e));return e[g]}[Kn](e){if(this[Re].size===0)return this.nextTick(e);let t=this[Re].size,r=!0,i=()=>{--t===0&&(r?this.nextTick(e):e())};for(let o of this[Re])o.close(i);r=!1,this[Re].clear()}_close(e){this.nextTick(e)}get(e,t,r){if(r=Me(t,r),r=ve(r,g),t=be(t,this[Fe].entry),this[x]==="opening")return this.defer(()=>this.get(e,t,r)),r[g];if(st(this,r))return r[g];let i=this._checkKey(e);if(i)return this.nextTick(r,i),r[g];let o=this.keyEncoding(t.keyEncoding),s=this.valueEncoding(t.valueEncoding),c=o.format,f=s.format;return(t.keyEncoding!==c||t.valueEncoding!==f)&&(t=Object.assign({},t,{keyEncoding:c,valueEncoding:f})),this._get(this.prefixKey(o.encode(e),c),t,(h,l)=>{if(h)return(h.code==="LEVEL_NOT_FOUND"||h.notFound||/NotFound/i.test(h))&&(h.code||(h.code="LEVEL_NOT_FOUND"),h.notFound||(h.notFound=!0),h.status||(h.status=404)),r(h);try{l=s.decode(l)}catch(d){return r(new q("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:d}))}r(null,l)}),r[g]}_get(e,t,r){this.nextTick(r,new Error("NotFound"))}getMany(e,t,r){if(r=Me(t,r),r=ve(r,g),t=be(t,this[Fe].entry),this[x]==="opening")return this.defer(()=>this.getMany(e,t,r)),r[g];if(st(this,r))return r[g];if(!Array.isArray(e))return this.nextTick(r,new TypeError("The first argument 'keys' must be an array")),r[g];if(e.length===0)return this.nextTick(r,null,[]),r[g];let i=this.keyEncoding(t.keyEncoding),o=this.valueEncoding(t.valueEncoding),s=i.format,c=o.format;(t.keyEncoding!==s||t.valueEncoding!==c)&&(t=Object.assign({},t,{keyEncoding:s,valueEncoding:c}));let f=new Array(e.length);for(let h=0;h<e.length;h++){let l=e[h],d=this._checkKey(l);if(d)return this.nextTick(r,d),r[g];f[h]=this.prefixKey(i.encode(l),s)}return this._getMany(f,t,(h,l)=>{if(h)return r(h);try{for(let d=0;d<l.length;d++)l[d]!==void 0&&(l[d]=o.decode(l[d]))}catch(d){return r(new q(`Could not decode one or more of ${l.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:d}))}r(null,l)}),r[g]}_getMany(e,t,r){this.nextTick(r,null,new Array(e.length).fill(void 0))}put(e,t,r,i){if(i=Me(r,i),i=ve(i,g),r=be(r,this[Fe].entry),this[x]==="opening")return this.defer(()=>this.put(e,t,r,i)),i[g];if(st(this,i))return i[g];let o=this._checkKey(e)||this._checkValue(t);if(o)return this.nextTick(i,o),i[g];let s=this.keyEncoding(r.keyEncoding),c=this.valueEncoding(r.valueEncoding),f=s.format,h=c.format;(r.keyEncoding!==f||r.valueEncoding!==h)&&(r=Object.assign({},r,{keyEncoding:f,valueEncoding:h}));let l=this.prefixKey(s.encode(e),f),d=c.encode(t);return this._put(l,d,r,y=>{if(y)return i(y);this.emit("put",e,t),i()}),i[g]}_put(e,t,r,i){this.nextTick(i)}del(e,t,r){if(r=Me(t,r),r=ve(r,g),t=be(t,this[Fe].key),this[x]==="opening")return this.defer(()=>this.del(e,t,r)),r[g];if(st(this,r))return r[g];let i=this._checkKey(e);if(i)return this.nextTick(r,i),r[g];let o=this.keyEncoding(t.keyEncoding),s=o.format;return t.keyEncoding!==s&&(t=Object.assign({},t,{keyEncoding:s})),this._del(this.prefixKey(o.encode(e),s),t,c=>{if(c)return r(c);this.emit("del",e),r()}),r[g]}_del(e,t,r){this.nextTick(r)}batch(e,t,r){if(!arguments.length){if(this[x]==="opening")return new Ao(this);if(this[x]!=="open")throw new q("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof e=="function"?r=e:r=Me(t,r),r=ve(r,g),t=be(t,this[Fe].empty),this[x]==="opening")return this.defer(()=>this.batch(e,t,r)),r[g];if(st(this,r))return r[g];if(!Array.isArray(e))return this.nextTick(r,new TypeError("The first argument 'operations' must be an array")),r[g];if(e.length===0)return this.nextTick(r),r[g];let i=new Array(e.length),{keyEncoding:o,valueEncoding:s,...c}=t;for(let f=0;f<e.length;f++){if(typeof e[f]!="object"||e[f]===null)return this.nextTick(r,new TypeError("A batch operation must be an object")),r[g];let h=Object.assign({},e[f]);if(h.type!=="put"&&h.type!=="del")return this.nextTick(r,new TypeError("A batch operation must have a type property that is 'put' or 'del'")),r[g];let l=this._checkKey(h.key);if(l)return this.nextTick(r,l),r[g];let d=h.sublevel!=null?h.sublevel:this,y=d.keyEncoding(h.keyEncoding||o),w=y.format;if(h.key=d.prefixKey(y.encode(h.key),w),h.keyEncoding=w,h.type==="put"){let m=this._checkValue(h.value);if(m)return this.nextTick(r,m),r[g];let b=d.valueEncoding(h.valueEncoding||s);h.value=b.encode(h.value),h.valueEncoding=b.format}d!==this&&(h.sublevel=null),i[f]=h}return this._batch(i,c,f=>{if(f)return r(f);this.emit("batch",e),r()}),r[g]}_batch(e,t,r){this.nextTick(r)}sublevel(e,t){return this._sublevel(e,On.defaults(t))}_sublevel(e,t){return new On(this,e,t)}prefixKey(e,t){return e}clear(e,t){if(t=Me(e,t),t=ve(t,g),e=be(e,this[Fe].empty),this[x]==="opening")return this.defer(()=>this.clear(e,t)),t[g];if(st(this,t))return t[g];let r=e,i=this.keyEncoding(e.keyEncoding);return e=fr(e,i),e.keyEncoding=i.format,e.limit===0?this.nextTick(t):this._clear(e,o=>{if(o)return t(o);this.emit("clear",r),t()}),t[g]}_clear(e,t){this.nextTick(t)}iterator(e){let t=this.keyEncoding(e&&e.keyEncoding),r=this.valueEncoding(e&&e.valueEncoding);if(e=fr(e,t),e.keys=e.keys!==!1,e.values=e.values!==!1,e[De.keyEncoding]=t,e[De.valueEncoding]=r,e.keyEncoding=t.format,e.valueEncoding=r.format,this[x]==="opening")return new lu(this,e);if(this[x]!=="open")throw new q("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(e)}_iterator(e){return new De(this,e)}keys(e){let t=this.keyEncoding(e&&e.keyEncoding),r=this.valueEncoding(e&&e.valueEncoding);if(e=fr(e,t),e[De.keyEncoding]=t,e[De.valueEncoding]=r,e.keyEncoding=t.format,e.valueEncoding=r.format,this[x]==="opening")return new pu(this,e);if(this[x]!=="open")throw new q("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(e)}_keys(e){return new hu(this,e)}values(e){let t=this.keyEncoding(e&&e.keyEncoding),r=this.valueEncoding(e&&e.valueEncoding);if(e=fr(e,t),e[De.keyEncoding]=t,e[De.valueEncoding]=r,e.keyEncoding=t.format,e.valueEncoding=r.format,this[x]==="opening")return new yu(this,e);if(this[x]!=="open")throw new q("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(e)}_values(e){return new du(this,e)}defer(e){if(typeof e!="function")throw new TypeError("The first argument must be a function");this[Kt].push(e)}[It](){if(this[Kt].length===0)return;let e=this[Kt];this[Kt]=[];for(let t of e)t()}attachResource(e){if(typeof e!="object"||e===null||typeof e.close!="function")throw new TypeError("The first argument must be a resource object");this[Re].add(e)}detachResource(e){this[Re].delete(e)}_chainedBatch(){return new Ao(this)}_checkKey(e){if(e==null)return new q("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(e){if(e==null)return new q("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};Ot.prototype.nextTick=xo();var{AbstractSublevel:On}=_o()({AbstractLevel:Ot});Un.AbstractLevel=Ot;Un.AbstractSublevel=On;var st=function(n,e){return n[x]!=="open"?(n.nextTick(e,new q("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},wu=function(n){return Object.keys(n.supports.encodings).filter(e=>!!n.supports.encodings[e])}});var Ln=v(Ne=>{"use strict";var uh=u(a());Ne.AbstractLevel=Cn().AbstractLevel;Ne.AbstractSublevel=Cn().AbstractSublevel;Ne.AbstractIterator=ge().AbstractIterator;Ne.AbstractKeyIterator=ge().AbstractKeyIterator;Ne.AbstractValueIterator=ge().AbstractValueIterator;Ne.AbstractChainedBatch=bn().AbstractChainedBatch});var ko=v((ah,So)=>{var fh=u(a());So.exports=xu;var gu=Tn();function xu(n,e,t){if(typeof e!="number")throw new Error("second argument must be a Number");let r,i,o,s,c,f=!0,h;Array.isArray(n)?(r=[],o=i=n.length):(s=Object.keys(n),r={},o=i=s.length);function l(y){function w(){t&&t(y,r),t=null}f?gu(w):w()}function d(y,w,m){if(r[y]=m,w&&(c=!0),--o===0||w)l(w);else if(!c&&h<i){let b;s?(b=s[h],h+=1,n[b](function(N,B){d(b,N,B)})):(b=h,h+=1,n[b](function(N,B){d(b,N,B)}))}}h=e,o?s?s.some(function(y,w){return n[y](function(m,b){d(y,m,b)}),w===e-1}):n.some(function(y,w){return y(function(m,b){d(w,m,b)}),w===e-1}):l(null),f=!1}});var Pn=v((hh,Ko)=>{"use strict";var dh=u(a());Ko.exports=function(e){let t=e.gte!==void 0?e.gte:e.gt!==void 0?e.gt:void 0,r=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 t!==void 0&&r!==void 0?IDBKeyRange.bound(t,r,i,o):t!==void 0?IDBKeyRange.lowerBound(t,i):r!==void 0?IDBKeyRange.upperBound(r,o):null}});var Dn=v((lh,Io)=>{"use strict";var ph=u(a()),vu=new TextEncoder;Io.exports=function(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):vu.encode(n)}});var Po=v(Lo=>{"use strict";var mh=u(a()),{AbstractIterator:bu}=Ln(),Oo=Pn(),lr=Dn(),ee=Symbol("cache"),ue=Symbol("finished"),L=Symbol("options"),ae=Symbol("currentOptions"),Ve=Symbol("position"),Mn=Symbol("location"),ct=Symbol("first"),Uo={},Rn=class extends bu{constructor(e,t,r){super(e,r),this[ee]=[],this[ue]=this.limit===0,this[L]=r,this[ae]={...r},this[Ve]=void 0,this[Mn]=t,this[ct]=!0}_nextv(e,t,r){if(this[ct]=!1,this[ue])return this.nextTick(r,null,[]);if(this[ee].length>0)return e=Math.min(e,this[ee].length),this.nextTick(r,null,this[ee].splice(0,e));this[Ve]!==void 0&&(this[L].reverse?(this[ae].lt=this[Ve],this[ae].lte=void 0):(this[ae].gt=this[Ve],this[ae].gte=void 0));let i;try{i=Oo(this[ae])}catch{return this[ue]=!0,this.nextTick(r,null,[])}let o=this.db.db.transaction([this[Mn]],"readonly"),s=o.objectStore(this[Mn]),c=[];if(this[L].reverse){let f=!this[L].values&&s.openKeyCursor?"openKeyCursor":"openCursor";s[f](i,"prev").onsuccess=h=>{let l=h.target.result;if(l){let{key:d,value:y}=l;this[Ve]=d,c.push([this[L].keys&&d!==void 0?lr(d):void 0,this[L].values&&y!==void 0?lr(y):void 0]),c.length<e?l.continue():Co(o)}else this[ue]=!0}}else{let f,h,l=()=>{if(f===void 0||h===void 0)return;let d=Math.max(f.length,h.length);d===0||e===1/0?this[ue]=!0:this[Ve]=f[d-1],c.length=d;for(let y=0;y<d;y++){let w=f[y],m=h[y];c[y]=[this[L].keys&&w!==void 0?lr(w):void 0,this[L].values&&m!==void 0?lr(m):void 0]}Co(o)};this[L].keys||e<1/0?s.getAllKeys(i,e<1/0?e:void 0).onsuccess=d=>{f=d.target.result,l()}:(f=[],this.nextTick(l)),this[L].values?s.getAll(i,e<1/0?e:void 0).onsuccess=d=>{h=d.target.result,l()}:(h=[],this.nextTick(l))}o.onabort=()=>{r(o.error||new Error("aborted by user")),r=null},o.oncomplete=()=>{r(null,c),r=null}}_next(e){if(this[ee].length>0){let[t,r]=this[ee].shift();this.nextTick(e,null,t,r)}else if(this[ue])this.nextTick(e);else{let t=Math.min(100,this.limit-this.count);this[ct]&&(this[ct]=!1,t=1),this._nextv(t,Uo,(r,i)=>{if(r)return e(r);this[ee]=i,this._next(e)})}}_all(e,t){this[ct]=!1;let r=this[ee].splice(0,this[ee].length),i=this.limit-this.count-r.length;if(i<=0)return this.nextTick(t,null,r);this._nextv(i,Uo,(o,s)=>{if(o)return t(o);r.length>0&&(s=r.concat(s)),t(null,s)})}_seek(e,t){this[ct]=!0,this[ee]=[],this[ue]=!1,this[Ve]=void 0,this[ae]={...this[L]};let r;try{r=Oo(this[L])}catch{this[ue]=!0;return}r!==null&&!r.includes(e)?this[ue]=!0:this[L].reverse?this[ae].lte=e:this[ae].gte=e}};Lo.Iterator=Rn;function Co(n){typeof n.commit=="function"&&n.commit()}});var Mo=v((wh,Do)=>{"use strict";var gh=u(a());Do.exports=function(e,t,r,i,o){if(i.limit===0)return e.nextTick(o);let s=e.db.transaction([t],"readwrite"),c=s.objectStore(t),f=0;s.oncomplete=function(){o()},s.onabort=function(){o(s.error||new Error("aborted by user"))};let h=c.openKeyCursor?"openKeyCursor":"openCursor",l=i.reverse?"prev":"next";c[h](r,l).onsuccess=function(d){let y=d.target.result;y&&(c.delete(y.key).onsuccess=function(){(i.limit<=0||++f<i.limit)&&y.continue()})}}});var $o=v(jo=>{"use strict";var vh=u(a()),{AbstractLevel:Eu}=Ln(),Ro=j(),Tu=ko(),{fromCallback:_u}=gt(),{Iterator:Au}=Po(),Fo=Dn(),Bu=Mo(),Su=Pn(),Vo="level-js-",Ut=Symbol("idb"),Fn=Symbol("namePrefix"),fe=Symbol("location"),Nn=Symbol("version"),je=Symbol("store"),Ct=Symbol("onComplete"),No=Symbol("promise"),pr=class extends Eu{constructor(e,t,r){if(typeof t=="function"||typeof r=="function")throw new Ro("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});let{prefix:i,version:o,...s}=t||{};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[fe]=e,this[Fn]=i??Vo,this[Nn]=parseInt(o||1,10),this[Ut]=null}get location(){return this[fe]}get namePrefix(){return this[Fn]}get version(){return this[Nn]}get db(){return this[Ut]}get type(){return"browser-level"}_open(e,t){let r=indexedDB.open(this[Fn]+this[fe],this[Nn]);r.onerror=function(){t(r.error||new Error("unknown error"))},r.onsuccess=()=>{this[Ut]=r.result,t()},r.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[fe])||o.createObjectStore(this[fe])}}[je](e){return this[Ut].transaction([this[fe]],e).objectStore(this[fe])}[Ct](e,t){let r=e.transaction;r.onabort=function(){t(r.error||new Error("aborted by user"))},r.oncomplete=function(){t(null,e.result)}}_get(e,t,r){let i=this[je]("readonly"),o;try{o=i.get(e)}catch(s){return this.nextTick(r,s)}this[Ct](o,function(s,c){if(s)return r(s);if(c===void 0)return r(new Ro("Entry not found",{code:"LEVEL_NOT_FOUND"}));r(null,Fo(c))})}_getMany(e,t,r){let i=this[je]("readonly"),o=e.map(s=>c=>{let f;try{f=i.get(s)}catch(h){return c(h)}f.onsuccess=()=>{let h=f.result;c(null,h===void 0?h:Fo(h))},f.onerror=h=>{h.stopPropagation(),c(f.error)}});Tu(o,16,r)}_del(e,t,r){let i=this[je]("readwrite"),o;try{o=i.delete(e)}catch(s){return this.nextTick(r,s)}this[Ct](o,r)}_put(e,t,r,i){let o=this[je]("readwrite"),s;try{s=o.put(t,e)}catch(c){return this.nextTick(i,c)}this[Ct](s,i)}_iterator(e){return new Au(this,this[fe],e)}_batch(e,t,r){let i=this[je]("readwrite"),o=i.transaction,s=0,c;o.onabort=function(){r(c||o.error||new Error("aborted by user"))},o.oncomplete=function(){r()};function f(){let h=e[s++],l=h.key,d;try{d=h.type==="del"?i.delete(l):i.put(h.value,l)}catch(y){c=y,o.abort();return}s<e.length?d.onsuccess=f:typeof o.commit=="function"&&o.commit()}f()}_clear(e,t){let r,i;try{r=Su(e)}catch{return this.nextTick(t)}if(e.limit>=0)return Bu(this,this[fe],r,e,t);try{let o=this[je]("readwrite");i=r?o.delete(r):o.clear()}catch(o){return this.nextTick(t,o)}this[Ct](i,t)}_close(e){this[Ut].close(),this.nextTick(e)}};pr.destroy=function(n,e,t){typeof e=="function"&&(t=e,e=Vo),t=_u(t,No);let r=indexedDB.deleteDatabase(e+n);return r.onsuccess=function(){t()},r.onerror=function(i){t(i)},t[No]};jo.BrowserLevel=pr});var Jo=v(qo=>{var Eh=u(a());qo.Level=$o().BrowserLevel});var Vp=u(a(),1);var Yl=u(a(),1);var Wu=u(a(),1);var Cr;(function(n){n.AlgorithmNotSupported="algorithmNotSupported",n.EncodingError="encodingError",n.InvalidJwe="invalidJwe",n.InvalidJwk="invalidJwk",n.OperationNotSupported="operationNotSupported"})(Cr||(Cr={}));var Qd=u(a(),1);var Kh=u(a(),1);var Xu=u(a(),1),Js=u(yi(),1);var Ca=u(a(),1);var ya=u(a(),1);var oa=u(a(),1);var Qu=u(a(),1),Zu=new Uint8Array(0);function mi(n,e){if(n===e)return!0;if(n.byteLength!==e.byteLength)return!1;for(let t=0;t<n.byteLength;t++)if(n[t]!==e[t])return!1;return!0}function He(n){if(n instanceof Uint8Array&&n.constructor.name==="Uint8Array")return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")}var ta=u(a(),1);function Ws(n,e){if(n.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<n.length;i++){var o=n.charAt(i),s=o.charCodeAt(0);if(t[s]!==255)throw new TypeError(o+" is ambiguous");t[s]=i}var c=n.length,f=n.charAt(0),h=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function d(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var b=0,N=0,B=0,G=m.length;B!==G&&m[B]===0;)B++,b++;for(var W=(G-B)*l+1>>>0,D=new Uint8Array(W);B!==G;){for(var H=m[B],he=0,V=W-1;(H!==0||he<N)&&V!==-1;V--,he++)H+=256*D[V]>>>0,D[V]=H%c>>>0,H=H/c>>>0;if(H!==0)throw new Error("Non-zero carry");N=he,B++}for(var te=W-N;te!==W&&D[te]===0;)te++;for(var Pt=f.repeat(b);te<W;++te)Pt+=n.charAt(D[te]);return Pt}function y(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var b=0;if(m[b]!==" "){for(var N=0,B=0;m[b]===f;)N++,b++;for(var G=(m.length-b)*h+1>>>0,W=new Uint8Array(G);m[b];){var D=t[m.charCodeAt(b)];if(D===255)return;for(var H=0,he=G-1;(D!==0||H<B)&&he!==-1;he--,H++)D+=c*W[he]>>>0,W[he]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");B=H,b++}if(m[b]!==" "){for(var V=G-B;V!==G&&W[V]===0;)V++;for(var te=new Uint8Array(N+(G-V)),Pt=N;V!==G;)te[Pt++]=W[V++];return te}}}function w(m){var b=y(m);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:y,decode:w}}var Hs=Ws,zs=Hs,wi=zs;var Dr=class{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Mr=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}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 gi(this,e)}},Rr=class{decoders;constructor(e){this.decoders=e}or(e){return gi(this,e)}decode(e){let t=e[0],r=this.decoders[t];if(r!=null)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function gi(n,e){return new Rr({...n.decoders??{[n.prefix]:n},...e.decoders??{[e.prefix]:e}})}var Fr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,i){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=i,this.encoder=new Dr(e,t,r),this.decoder=new Mr(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function xi({name:n,prefix:e,encode:t,decode:r}){return new Fr(n,e,t,r)}function Nr({name:n,prefix:e,alphabet:t}){let{encode:r,decode:i}=wi(t,n);return xi({prefix:e,name:n,encode:r,decode:o=>He(i(o))})}function Ys(n,e,t,r){let i={};for(let l=0;l<e.length;++l)i[e[l]]=l;let o=n.length;for(;n[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),c=0,f=0,h=0;for(let l=0;l<o;++l){let d=i[n[l]];if(d===void 0)throw new SyntaxError(`Non-${r} character`);f=f<<t|d,c+=t,c>=8&&(c-=8,s[h++]=255&f>>c)}if(c>=t||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return s}function Xs(n,e,t){let r=e[e.length-1]==="=",i=(1<<t)-1,o="",s=0,c=0;for(let f=0;f<n.length;++f)for(c=c<<8|n[f],s+=8;s>t;)s-=t,o+=e[i&c>>s];if(s!==0&&(o+=e[i&c<<t-s]),r)for(;o.length*t&7;)o+="=";return o}function S({name:n,prefix:e,bitsPerChar:t,alphabet:r}){return xi({prefix:e,name:n,encode(i){return Xs(i,r,t)},decode(i){return Ys(i,r,t,n)}})}var at=S({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ca=S({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ua=S({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),aa=S({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),fa=S({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ha=S({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),da=S({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),la=S({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Vr=S({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var xa=u(a(),1);var K=Nr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),wa=Nr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Aa=u(a(),1);var ba=S({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ea=S({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),X=S({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ta=S({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Sa=u(a(),1);function vi(n){return n.byteOffset!==0||n.byteLength!==n.buffer.byteLength}function bi(n){return typeof n!="object"||n===null?!1:typeof n[Symbol.asyncIterator]=="function"}function Nt(n){let t=Object.prototype.toString.call(n).match(/\s([a-zA-Z0-9]+)/),[r,i]=t;return i}var ft=function(n,e,t,r){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function c(l){try{h(r.next(l))}catch(d){s(d)}}function f(l){try{h(r.throw(l))}catch(d){s(d)}}function h(l){l.done?o(l.value):i(l.value).then(c,f)}h((r=r.apply(n,e||[])).next())})},Ei=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=n[Symbol.asyncIterator],t;return e?e.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(o){t[o]=n[o]&&function(s){return new Promise(function(c,f){s=n[o](s),i(c,f,s.done,s.value)})}}function i(o,s,c,f){Promise.resolve(f).then(function(h){o({value:h,done:c})},s)}},Vt=new TextEncoder,Be=new TextDecoder,T=class n{constructor(e,t){this.data=e,this.format=t}static arrayBuffer(e){return new n(e,"ArrayBuffer")}static asyncIterable(e){if(!bi(e))throw new TypeError("Input must be of type AsyncIterable.");return new n(e,"AsyncIterable")}static base32Z(e){return new n(e,"Base32Z")}static base58Btc(e){return new n(e,"Base58Btc")}static base64Url(e){return new n(e,"Base64Url")}static bufferSource(e){return new n(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 n(e,"Hex")}static multibase(e){return new n(e,"Multibase")}static object(e){return new n(e,"Object")}static string(e){return new n(e,"String")}static uint8Array(e){return new n(e,"Uint8Array")}toArrayBuffer(){switch(this.format){case"Base58Btc":return K.baseDecode(this.data).buffer;case"Base64Url":return X.baseDecode(this.data).buffer;case"BufferSource":{if(Nt(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return vi(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 ft(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 Vr.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 K.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return K.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 X.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return X.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),t=Vt.encode(e);return X.baseEncode(t)}case"String":{let e=Vt.encode(this.data);return X.baseEncode(e)}case"Uint8Array":return X.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return ft(this,void 0,void 0,function*(){var e,t,r,i;switch(this.format){case"AsyncIterable":{let f=[];try{for(var o=!0,s=Ei(this.data),c;c=yield s.next(),e=c.done,!e;o=!0){i=c.value,o=!1;let l=i;f.push(l)}}catch(l){t={error:l}}finally{try{!o&&!e&&(r=s.return)&&(yield r.call(s))}finally{if(t)throw t.error}}return new Blob(f)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Blob is not supported.`)}})}toHex(){let e=Array.from({length:256},(t,r)=>r.toString(16).padStart(2,"0"));switch(this.format){case"ArrayBuffer":{let t=this.toUint8Array();return n.uint8Array(t).toHex()}case"Base64Url":{let t=this.toUint8Array();return n.uint8Array(t).toHex()}case"Uint8Array":{let t="";for(let r=0;r<this.data.length;r++)t+=e[this.data[r]];return t}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=X.baseDecode(this.data),t=Be.decode(e);return JSON.parse(t)}case"String":return JSON.parse(this.data);case"Uint8Array":{let e=Be.decode(this.data);return JSON.parse(e)}default:throw new TypeError(`Conversion from ${this.format} to Object is not supported.`)}}toObjectAsync(){return ft(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 Be.decode(this.data);case"Base64Url":{let e=X.baseDecode(this.data);return Be.decode(e)}case"Object":return JSON.stringify(this.data);case"Uint8Array":return Be.decode(this.data);default:throw new TypeError(`Conversion from ${this.format} to String is not supported.`)}}toStringAsync(){return ft(this,void 0,void 0,function*(){var e,t,r,i;switch(this.format){case"AsyncIterable":{let f="";try{for(var o=!0,s=Ei(this.data),c;c=yield s.next(),e=c.done,!e;o=!0){i=c.value,o=!1;let h=i;typeof h=="string"?f+=h:f+=Be.decode(h,{stream:!0})}}catch(h){t={error:h}}finally{try{!o&&!e&&(r=s.return)&&(yield r.call(s))}finally{if(t)throw t.error}}return f+=Be.decode(void 0,{stream:!1}),f}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 Vr.baseDecode(this.data);case"Base58Btc":return K.baseDecode(this.data);case"Base64Url":return X.baseDecode(this.data);case"BufferSource":{let e=Nt(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 t=0;t<this.data.length;t+=2){let r=parseInt(this.data.substring(t,t+2),16);if(isNaN(r))throw new TypeError("Input is not a valid hexadecimal string.");e[t/2]=r}return e}case"Object":{let e=JSON.stringify(this.data);return Vt.encode(e)}case"String":return Vt.encode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Uint8Array is not supported.`)}}toUint8ArrayAsync(){return ft(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 Pa=u(a(),1),ht;(function(n){n.Debug="debug",n.Silent="silent"})(ht||(ht={}));var jr=class{constructor(){this.logLevel=ht.Silent}setLogLevel(e){this.logLevel=e}log(e){this.info(e)}info(e){this.logLevel!==ht.Silent&&console.info(e)}error(e){this.logLevel!==ht.Silent&&console.error(e)}},Zs=new jr;typeof window<"u"&&(window.web5logger=Zs);var lf=u(a(),1);var af=u(a(),1);var Wa=u(a(),1);var Va=u(a(),1);var ne={};us(ne,{decode:()=>ze,encodeTo:()=>Se,encodingLength:()=>ke});var Fa=u(a(),1);var Ma=u(a(),1),Qs=Ai,Ti=128,ec=127,tc=~ec,rc=Math.pow(2,31);function Ai(n,e,t){e=e||[],t=t||0;for(var r=t;n>=rc;)e[t++]=n&255|Ti,n/=128;for(;n&tc;)e[t++]=n&255|Ti,n>>>=7;return e[t]=n|0,Ai.bytes=t-r+1,e}var nc=$r,ic=128,_i=127;function $r(n,r){var t=0,r=r||0,i=0,o=r,s,c=n.length;do{if(o>=c)throw $r.bytes=0,new RangeError("Could not decode varint");s=n[o++],t+=i<28?(s&_i)<<i:(s&_i)*Math.pow(2,i),i+=7}while(s>=ic);return $r.bytes=o-r,t}var oc=Math.pow(2,7),sc=Math.pow(2,14),cc=Math.pow(2,21),uc=Math.pow(2,28),ac=Math.pow(2,35),fc=Math.pow(2,42),hc=Math.pow(2,49),dc=Math.pow(2,56),lc=Math.pow(2,63),pc=function(n){return n<oc?1:n<sc?2:n<cc?3:n<uc?4:n<ac?5:n<fc?6:n<hc?7:n<dc?8:n<lc?9:10},yc={encode:Qs,decode:nc,encodingLength:pc},mc=yc,dt=mc;function ze(n,e=0){return[dt.decode(n,e),dt.decode.bytes]}function Se(n,e,t=0){return dt.encode(n,e,t),e}function ke(n){return dt.encodingLength(n)}function qr(n,e){let t=e.byteLength,r=ke(n),i=r+ke(t),o=new Uint8Array(i+t);return Se(n,o,0),Se(t,o,r),o.set(e,i),new Ye(n,t,e,o)}function Bi(n){let e=He(n),[t,r]=ze(e),[i,o]=ze(e.subarray(r)),s=e.subarray(r+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Ye(t,i,s,e)}function Si(n,e){if(n===e)return!0;{let t=e;return n.code===t.code&&n.size===t.size&&t.bytes instanceof Uint8Array&&mi(n.bytes,t.bytes)}}var Ye=class{code;size;digest;bytes;constructor(e,t,r,i){this.code=e,this.size=t,this.digest=r,this.bytes=i}};var ja=u(a(),1);function ki(n,e){let{bytes:t,version:r}=n;switch(r){case 0:return gc(t,Gr(n),e??K.encoder);default:return xc(t,Gr(n),e??at.encoder)}}var Ki=new WeakMap;function Gr(n){let e=Ki.get(n);if(e==null){let t=new Map;return Ki.set(n,t),t}return e}var Wr=class n{code;version;multihash;bytes;"/";constructor(e,t,r,i){this.code=t,this.version=e,this.multihash=r,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:t}=this;if(e!==lt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==vc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return n.createV0(t)}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:t}=this.multihash,r=qr(e,t);return n.createV1(this.code,r)}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 n.equals(this,e)}static equals(e,t){let r=t;return r!=null&&e.code===r.code&&e.version===r.version&&Si(e.multihash,r.multihash)}toString(e){return ki(this,e)}toJSON(){return{"/":ki(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof n)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:r,code:i,multihash:o,bytes:s}=t;return new n(r,i,o,s??Ii(r,i,o.bytes))}else if(t[bc]===!0){let{version:r,multihash:i,code:o}=t,s=Bi(i);return n.create(r,o,s)}else return null}static create(e,t,r){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==lt)throw new Error(`Version 0 CID must use dag-pb (code: ${lt}) block encoding`);return new n(e,t,r,r.bytes)}case 1:{let i=Ii(e,t,r.bytes);return new n(e,t,r,i)}default:throw new Error("Invalid version")}}static createV0(e){return n.create(0,lt,e)}static createV1(e,t){return n.create(1,e,t)}static decode(e){let[t,r]=n.decodeFirst(e);if(r.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=n.inspectBytes(e),r=t.size-t.multihashSize,i=He(e.subarray(r,r+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=i.subarray(t.multihashSize-t.digestSize),s=new Ye(t.multihashCode,t.digestSize,o,i);return[t.version===0?n.createV0(s):n.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,r=()=>{let[d,y]=ze(e.subarray(t));return t+=y,d},i=r(),o=lt;if(i===18?(i=0,t=0):o=r(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=t,c=r(),f=r(),h=t+f,l=h-s;return{version:i,codec:o,multihashCode:c,digestSize:f,multihashSize:l,size:h}}static parse(e,t){let[r,i]=wc(e,t),o=n.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Gr(o).set(r,e),o}};function wc(n,e){switch(n[0]){case"Q":{let t=e??K;return[K.prefix,t.decode(`${K.prefix}${n}`)]}case K.prefix:{let t=e??K;return[K.prefix,t.decode(n)]}case at.prefix:{let t=e??at;return[at.prefix,t.decode(n)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[n[0],e.decode(n)]}}}function gc(n,e,t){let{prefix:r}=t;if(r!==K.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(r);if(i==null){let o=t.encode(n).slice(1);return e.set(r,o),o}else return i}function xc(n,e,t){let{prefix:r}=t,i=e.get(r);if(i==null){let o=t.encode(n);return e.set(r,o),o}else return i}var lt=112,vc=18;function Ii(n,e,t){let r=ke(n),i=r+ke(e),o=new Uint8Array(i+t.byteLength);return Se(n,o,0),Se(e,o,r),o.set(t,i),o}var bc=Symbol.for("@ipld/js-cid/CID");var za=u(a(),1);var ef=u(a(),1);var Ya=u(a(),1);var Xa=u(a(),1);var Za=u(a(),1);var Qa=u(a(),1);var O=class n{static addPrefix(e){var t;let{code:r,data:i,name:o}=e;if(!(o?!r:r))throw new Error("Either 'name' or 'code' must be defined, but not both.");if(r=n.codeToName.has(r)?r:n.nameToCode.get(o),r===void 0)throw new Error(`Unsupported multicodec: ${(t=e.name)!==null&&t!==void 0?t:e.code}`);let s=ne.encodingLength(r),c=new Uint8Array(s+i.byteLength);return c.set(i,s),ne.encodeTo(r,c),c}static getCodeFromData(e){let{prefixedData:t}=e,[r,i]=ne.decode(t);return r}static getCodeFromName(e){let{name:t}=e,r=n.nameToCode.get(t);if(r===void 0)throw new Error(`Unsupported multicodec: ${t}`);return r}static getNameFromCode(e){let{code:t}=e,r=n.codeToName.get(t);if(r===void 0)throw new Error(`Unsupported multicodec: ${t}`);return r}static registerCodec(e){n.codeToName.set(e.code,e.name),n.nameToCode.set(e.name,e.code)}static removePrefix(e){let{prefixedData:t}=e,[r,i]=ne.decode(t),o=n.codeToName.get(r);if(o===void 0)throw new Error(`Unsupported multicodec: ${r}`);return{code:r,data:t.slice(i),name:o}}};O.codeToName=new Map;O.nameToCode=new Map;O.registerCodec({code:237,name:"ed25519-pub"});O.registerCodec({code:4864,name:"ed25519-priv"});O.registerCodec({code:236,name:"x25519-pub"});O.registerCodec({code:4866,name:"x25519-priv"});O.registerCodec({code:231,name:"secp256k1-pub"});O.registerCodec({code:4865,name:"secp256k1-priv"});var yf=u(a(),1);function Hr(n){Object.keys(n).forEach(e=>{n[e]===void 0?delete n[e]:typeof n[e]=="object"&&Hr(n[e])})}var _h=u(a(),1),ku=u(Jo(),1);var Sh=u(a(),1);var Bd=u(a(),1);var Fh=u(a(),1);var pd=u(a(),1);var ed=u(a(),1);var Yh=u(a(),1);var Vh=u(a(),1);function Ku(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function Vn(n,...e){if(!Ku(n))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(n.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${n.length}`)}function jn(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function Go(n,e){Vn(n);let t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var Gh=u(a(),1);var mr=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),J=(n,e)=>n<<32-e|n>>>e;var $h=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Iu(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function $n(n){return typeof n=="string"&&(n=Iu(n)),Vn(n),n}var yr=class{clone(){return this._cloneInto()}},qh={}.toString;function Wo(n){let e=r=>n().update($n(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function Ou(n,e,t,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(e,t,r);let i=BigInt(32),o=BigInt(4294967295),s=Number(t>>i&o),c=Number(t&o),f=r?4:0,h=r?0:4;n.setUint32(e+f,s,r),n.setUint32(e+h,c,r)}var Ho=(n,e,t)=>n&e^~n&t,zo=(n,e,t)=>n&e^n&t^e&t,wr=class extends yr{constructor(e,t,r,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=mr(this.buffer)}update(e){jn(this);let{view:t,buffer:r,blockLen:i}=this;e=$n(e);let o=e.length;for(let s=0;s<o;){let c=Math.min(i-this.pos,o-s);if(c===i){let f=mr(e);for(;i<=o-s;s+=i)this.process(f,s);continue}r.set(e.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){jn(this),Go(e,this),this.finished=!0;let{buffer:t,view:r,blockLen:i,isLE:o}=this,{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(r,0),s=0);for(let d=s;d<i;d++)t[d]=0;Ou(r,i-8,BigInt(this.length*8),o),this.process(r,0);let c=mr(e),f=this.outputLen;if(f%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let h=f/4,l=this.get();if(h>l.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<h;d++)c.setUint32(4*d,l[d],o)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:r,length:i,finished:o,destroyed:s,pos:c}=this;return e.length=i,e.pos=c,e.finished=o,e.destroyed=s,i%t&&e.buffer.set(r),e}};var Uu=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]),Ee=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Te=new Uint32Array(64),qn=class extends wr{constructor(){super(64,32,8,!1),this.A=Ee[0]|0,this.B=Ee[1]|0,this.C=Ee[2]|0,this.D=Ee[3]|0,this.E=Ee[4]|0,this.F=Ee[5]|0,this.G=Ee[6]|0,this.H=Ee[7]|0}get(){let{A:e,B:t,C:r,D:i,E:o,F:s,G:c,H:f}=this;return[e,t,r,i,o,s,c,f]}set(e,t,r,i,o,s,c,f){this.A=e|0,this.B=t|0,this.C=r|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=c|0,this.H=f|0}process(e,t){for(let d=0;d<16;d++,t+=4)Te[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){let y=Te[d-15],w=Te[d-2],m=J(y,7)^J(y,18)^y>>>3,b=J(w,17)^J(w,19)^w>>>10;Te[d]=b+Te[d-7]+m+Te[d-16]|0}let{A:r,B:i,C:o,D:s,E:c,F:f,G:h,H:l}=this;for(let d=0;d<64;d++){let y=J(c,6)^J(c,11)^J(c,25),w=l+y+Ho(c,f,h)+Uu[d]+Te[d]|0,b=(J(r,2)^J(r,13)^J(r,22))+zo(r,i,o)|0;l=h,h=f,f=c,c=s+w|0,s=o,o=i,i=r,r=w+b|0}r=r+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,c=c+this.E|0,f=f+this.F|0,h=h+this.G|0,l=l+this.H|0,this.set(r,i,o,s,c,f,h,l)}roundClean(){Te.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Yo=Wo(()=>new qn);var fd=u(a(),1);var rd=u(a(),1);function Xo(n){let e=r=>{if(r!==null&&typeof r=="object"&&!Array.isArray(r)){let i=Object.keys(r).sort(),o={};for(let s of i)o[s]=e(r[s]);return o}return r},t=e(n);return JSON.stringify(t)}var od=u(a(),1);var Cu=function(n,e,t,r){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function c(l){try{h(r.next(l))}catch(d){s(d)}}function f(l){try{h(r.throw(l))}catch(d){s(d)}}function h(l){l.done?o(l.value):i(l.value).then(c,f)}h((r=r.apply(n,e||[])).next())})},Lt=class{static digest(e){return Cu(this,arguments,void 0,function*({data:t}){return Yo(t)})}};var Lu=function(n,e,t,r){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function c(l){try{h(r.next(l))}catch(d){s(d)}}function f(l){try{h(r.throw(l))}catch(d){s(d)}}function h(l){l.done?o(l.value):i(l.value).then(c,f)}h((r=r.apply(n,e||[])).next())})};function P(n){return Lu(this,arguments,void 0,function*({jwk:e}){let t=e.kty,r;if(t==="EC")r={crv:e.crv,kty:e.kty,x:e.x,y:e.y};else if(t==="oct")r={k:e.k,kty:e.kty};else if(t==="OKP")r={crv:e.crv,kty:e.kty,x:e.x};else if(t==="RSA")r={e:e.e,kty:e.kty,n:e.n};else throw new Error(`Unsupported key type: ${t}`);Hr(r);let i=Xo(r),o=T.string(i).toUint8Array(),s=yield Lt.digest({data:o});return T.uint8Array(s).toBase64Url()})}var gd=u(a(),1);var Dd=u(a(),1);var Id=u(a(),1);var Nd=u(a(),1);var tl=u(a(),1);var fl=u(a(),1);var ol=u(a(),1);var xl=u(a(),1);var pl=u(a(),1);var vl=u(a(),1);var bl=u(a(),1);var El=u(a(),1);var kl=u(a(),1);var Ol=u(a(),1);var Ll=u(a(),1);var Dl=u(a(),1);var Nl=u(a(),1);var ql=u(a(),1);var Hl=u(a(),1);var Ap=u(a(),1),vr=(o=>(o.authentication="authentication",o.assertionMethod="assertionMethod",o.keyAgreement="keyAgreement",o.capabilityInvocation="capabilityInvocation",o.capabilityDelegation="capabilityDelegation",o))(vr||{});var Sp=u(a(),1),br=class n extends Error{constructor(t,r){super(`${t}: ${r}`);this.code=t;this.name="DidError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,n)}};function Jn(n){if(typeof n=="string"&&n.length!==0)return n.split("#").pop()}function Cp({didDocument:n,id:e,type:t}){return n?.service?.filter(r=>!(e&&r.id!==e||t&&r.type!==t))??[]}async function Lp({didDocument:n,publicKeyJwk:e,publicKeyMultibase:t}){let r=rs({didDocument:n});for(let i of r)if(e&&i.publicKeyJwk){if(await P({jwk:e})===await P({jwk:i.publicKeyJwk}))return i}else if(t&&i.publicKeyMultibase&&t===i.publicKeyMultibase)return i;return null}function rs({didDocument:n}){if(!n)throw new TypeError("Required parameter missing: 'didDocument'");let e=[];return e.push(...n.verificationMethod?.filter(Gn)??[]),Object.keys(vr).forEach(t=>{e.push(...n[t]?.filter(Gn)??[])}),e}function Pp({didDocument:n}){let t=rs({didDocument:n}).map(r=>r.type);return[...new Set(t)]}function Dp({didDocument:n,methodId:e}){let t=[];return Object.keys(vr).forEach(r=>{if(Array.isArray(n[r])){let i=n[r],o=Jn(e);i.some(c=>{let f=Jn(c)===o,h=Gn(c)&&Jn(c.id)===o;return f||h})&&t.push(r)}}),t}function Pu(n){return!n||typeof n!="object"||n===null?!1:"id"in n&&"type"in n&&"serviceEndpoint"in n}function Mp(n){if(!Pu(n)||n.type!=="DecentralizedWebNode"||!("enc"in n&&"sig"in n))return!1;let e=t=>typeof t=="string"||Array.isArray(t)&&t.every(r=>typeof r=="string");return e(n.enc)&&e(n.sig)}function Gn(n){return!(!n||typeof n!="object"||n===null||!("id"in n&&"type"in n&&"controller"in n)||typeof n.id!="string"||typeof n.type!="string"||typeof n.controller!="string")}function Rp({keyBytes:n,multicodecCode:e,multicodecName:t}){let r=O.addPrefix({code:e,data:n,name:t}),i=T.uint8Array(r).toBase58Btc();return T.base58Btc(i).toMultibase()}function Fp({multibaseKeyId:n}){try{let e=T.multibase(n).toBase58Btc(),t=T.base58Btc(e).toUint8Array(),{code:r,data:i,name:o}=O.removePrefix({prefixedData:t});return{keyBytes:i,multicodecCode:r,multicodecName:o}}catch{throw new br("invalidDid",`Invalid multibase identifier: ${n}`)}}export{Jn as extractDidFragment,Cp as getServices,Lp as getVerificationMethodByKey,Pp as getVerificationMethodTypes,rs as getVerificationMethods,Dp as getVerificationRelationshipsById,Pu as isDidService,Gn as isDidVerificationMethod,Mp as isDwnDidService,Rp as keyBytesToMultibaseId,Fp as multibaseIdToKeyBytes};
|
|
1
|
+
var Ho=Object.create;var br=Object.defineProperty;var Wo=Object.getOwnPropertyDescriptor;var zo=Object.getOwnPropertyNames;var Xo=Object.getPrototypeOf,Yo=Object.prototype.hasOwnProperty;var x=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports),Zo=(n,t)=>{for(var e in t)br(n,e,{get:t[e],enumerable:!0})},Qo=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of zo(t))!Yo.call(n,i)&&i!==e&&br(n,i,{get:()=>t[i],enumerable:!(r=Wo(t,i))||r.enumerable});return n};var Hn=(n,t,e)=>(e=n!=null?Ho(Xo(n)):{},Qo(t||!n||!n.__esModule?br(e,"default",{value:n,enumerable:!0}):e,n));var zn=x((Tu,Wn)=>{var ts=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Le=()=>ts.now(),es=n=>n&&n===Math.floor(n)&&n>0&&isFinite(n),Er=n=>n===1/0||es(n),Tr=class n{constructor({max:t=1/0,ttl:e,updateAgeOnGet:r=!1,checkAgeOnGet:i=!1,noUpdateTTL:o=!1,dispose:s,noDisposeOnSet:c=!1}={}){if(this.expirations=Object.create(null),this.data=new Map,this.expirationMap=new Map,e!==void 0&&!Er(e))throw new TypeError("ttl must be positive integer or Infinity if set");if(!Er(t))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=e,this.max=t,this.updateAgeOnGet=!!r,this.checkAgeOnGet=!!i,this.noUpdateTTL=!!o,this.noDisposeOnSet=!!c,s!==void 0){if(typeof s!="function")throw new TypeError("dispose must be function if set");this.dispose=s}this.timer=void 0,this.timerExpiration=void 0}setTimer(t,e){if(this.timerExpiration<t)return;this.timer&&clearTimeout(this.timer);let r=setTimeout(()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let i in this.expirations){this.setTimer(i,i-Le());break}},e);r.unref&&r.unref(),this.timerExpiration=t,this.timer=r}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 t=this.dispose!==n.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(let[e,r]of t)this.dispose(r,e,"delete")}setTTL(t,e=this.ttl){let r=this.expirationMap.get(t);if(r!==void 0){let i=this.expirations[r];!i||i.length<=1?delete this.expirations[r]:this.expirations[r]=i.filter(o=>o!==t)}if(e!==1/0){let i=Math.floor(Le()+e);this.expirationMap.set(t,i),this.expirations[i]||(this.expirations[i]=[],this.setTimer(i,e)),this.expirations[i].push(t)}else this.expirationMap.set(t,1/0)}set(t,e,{ttl:r=this.ttl,noUpdateTTL:i=this.noUpdateTTL,noDisposeOnSet:o=this.noDisposeOnSet}={}){if(!Er(r))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(t)){i||this.setTTL(t,r);let s=this.data.get(t);s!==e&&(this.data.set(t,e),o||this.dispose(s,t,"set"))}else this.setTTL(t,r),this.data.set(t,e);for(;this.size>this.max;)this.purgeToCapacity();return this}has(t){return this.data.has(t)}getRemainingTTL(t){let e=this.expirationMap.get(t);return e===1/0?e:e!==void 0?Math.max(0,Math.ceil(e-Le())):0}get(t,{updateAgeOnGet:e=this.updateAgeOnGet,ttl:r=this.ttl,checkAgeOnGet:i=this.checkAgeOnGet}={}){let o=this.data.get(t);if(i&&this.getRemainingTTL(t)===0){this.delete(t);return}return e&&this.setTTL(t,r),o}dispose(t,e){}delete(t){let e=this.expirationMap.get(t);if(e!==void 0){let r=this.data.get(t);this.data.delete(t),this.expirationMap.delete(t);let i=this.expirations[e];return i&&(i.length<=1?delete this.expirations[e]:this.expirations[e]=i.filter(o=>o!==t)),this.dispose(r,t,"delete"),this.size===0&&this.cancelTimer(),!0}return!1}purgeToCapacity(){for(let t in this.expirations){let e=this.expirations[t];if(this.size-e.length>=this.max){delete this.expirations[t];let r=[];for(let i of e)r.push([i,this.data.get(i)]),this.data.delete(i),this.expirationMap.delete(i);for(let[i,o]of r)this.dispose(o,i,"evict")}else{let r=this.size-this.max,i=[];for(let o of e.splice(0,r))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 t=Math.ceil(Le());for(let e in this.expirations){if(e==="Infinity"||e>t)return;let r=[...this.expirations[e]||[]],i=[];delete this.expirations[e];for(let o of r)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 t in this.expirations)for(let e of this.expirations[t])yield[e,this.data.get(e)]}*keys(){for(let t in this.expirations)for(let e of this.expirations[t])yield e}*values(){for(let t in this.expirations)for(let e of this.expirations[t])yield this.data.get(e)}[Symbol.iterator](){return this.entries()}};Wn.exports=Tr});var di=x(hi=>{"use strict";hi.supports=function(...t){let e=t.reduce((r,i)=>Object.assign(r,i),{});return Object.assign(e,{snapshots:e.snapshots||!1,permanence:e.permanence||!1,seek:e.seek||!1,clear:e.clear||!1,getMany:e.getMany||!1,keyIterator:e.keyIterator||!1,valueIterator:e.valueIterator||!1,iteratorNextv:e.iteratorNextv||!1,iteratorAll:e.iteratorAll||!1,status:e.status||!1,createIfMissing:e.createIfMissing||!1,errorIfExists:e.errorIfExists||!1,deferredOpen:e.deferredOpen||!1,promises:e.promises||!1,streams:e.streams||!1,encodings:Object.assign({},e.encodings),events:Object.assign({},e.events),additionalMethods:Object.assign({},e.additionalMethods)})}});var V=x((ba,li)=>{"use strict";li.exports=class extends Error{constructor(t,e){super(t||""),typeof e=="object"&&e!==null&&(e.code&&(this.code=String(e.code)),e.expected&&(this.expected=!0),e.transient&&(this.transient=!0),e.cause&&(this.cause=e.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}});var mi=x(Ne=>{"use strict";Ne.byteLength=Ds;Ne.toByteArray=Ms;Ne.fromByteArray=Rs;var z=[],L=[],Ps=typeof Uint8Array<"u"?Uint8Array:Array,Mr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Kt=0,pi=Mr.length;Kt<pi;++Kt)z[Kt]=Mr[Kt],L[Mr.charCodeAt(Kt)]=Kt;var Kt,pi;L[45]=62;L[95]=63;function yi(n){var t=n.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=n.indexOf("=");e===-1&&(e=t);var r=e===t?0:4-e%4;return[e,r]}function Ds(n){var t=yi(n),e=t[0],r=t[1];return(e+r)*3/4-r}function Ls(n,t,e){return(t+e)*3/4-e}function Ms(n){var t,e=yi(n),r=e[0],i=e[1],o=new Ps(Ls(n,r,i)),s=0,c=i>0?r-4:r,u;for(u=0;u<c;u+=4)t=L[n.charCodeAt(u)]<<18|L[n.charCodeAt(u+1)]<<12|L[n.charCodeAt(u+2)]<<6|L[n.charCodeAt(u+3)],o[s++]=t>>16&255,o[s++]=t>>8&255,o[s++]=t&255;return i===2&&(t=L[n.charCodeAt(u)]<<2|L[n.charCodeAt(u+1)]>>4,o[s++]=t&255),i===1&&(t=L[n.charCodeAt(u)]<<10|L[n.charCodeAt(u+1)]<<4|L[n.charCodeAt(u+2)]>>2,o[s++]=t>>8&255,o[s++]=t&255),o}function Fs(n){return z[n>>18&63]+z[n>>12&63]+z[n>>6&63]+z[n&63]}function Ns(n,t,e){for(var r,i=[],o=t;o<e;o+=3)r=(n[o]<<16&16711680)+(n[o+1]<<8&65280)+(n[o+2]&255),i.push(Fs(r));return i.join("")}function Rs(n){for(var t,e=n.length,r=e%3,i=[],o=16383,s=0,c=e-r;s<c;s+=o)i.push(Ns(n,s,s+o>c?c:s+o));return r===1?(t=n[e-1],i.push(z[t>>2]+z[t<<4&63]+"==")):r===2&&(t=(n[e-2]<<8)+n[e-1],i.push(z[t>>10]+z[t>>4&63]+z[t<<2&63]+"=")),i.join("")}});var wi=x(Fr=>{Fr.read=function(n,t,e,r,i){var o,s,c=i*8-r-1,u=(1<<c)-1,a=u>>1,h=-7,f=e?i-1:0,l=e?-1:1,p=n[t+f];for(f+=l,o=p&(1<<-h)-1,p>>=-h,h+=c;h>0;o=o*256+n[t+f],f+=l,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;h>0;s=s*256+n[t+f],f+=l,h-=8);if(o===0)o=1-a;else{if(o===u)return s?NaN:(p?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-a}return(p?-1:1)*s*Math.pow(2,o-r)};Fr.write=function(n,t,e,r,i,o){var s,c,u,a=o*8-i-1,h=(1<<a)-1,f=h>>1,l=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,y=r?1:-1,g=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+f>=1?t+=l/u:t+=l*Math.pow(2,1-f),t*u>=2&&(s++,u/=2),s+f>=h?(c=0,s=h):s+f>=1?(c=(t*u-1)*Math.pow(2,i),s=s+f):(c=t*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;n[e+p]=c&255,p+=y,c/=256,i-=8);for(s=s<<i|c,a+=i;a>0;n[e+p]=s&255,p+=y,s/=256,a-=8);n[e+p-y]|=g*128}});var je=x(Xt=>{"use strict";var Nr=mi(),Wt=wi(),gi=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Xt.Buffer=d;Xt.SlowBuffer=Gs;Xt.INSPECT_MAX_BYTES=50;var Re=2147483647;Xt.kMaxLength=Re;d.TYPED_ARRAY_SUPPORT=Vs();!d.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function Vs(){try{let n=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(n,t),n.foo()===42}catch{return!1}}Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.buffer}});Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){if(d.isBuffer(this))return this.byteOffset}});function rt(n){if(n>Re)throw new RangeError('The value "'+n+'" is invalid for option "size"');let t=new Uint8Array(n);return Object.setPrototypeOf(t,d.prototype),t}function d(n,t,e){if(typeof n=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return $r(n)}return Ei(n,t,e)}d.poolSize=8192;function Ei(n,t,e){if(typeof n=="string")return $s(n,t);if(ArrayBuffer.isView(n))return qs(n);if(n==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n);if(X(n,ArrayBuffer)||n&&X(n.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(X(n,SharedArrayBuffer)||n&&X(n.buffer,SharedArrayBuffer)))return Vr(n,t,e);if(typeof n=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let r=n.valueOf&&n.valueOf();if(r!=null&&r!==n)return d.from(r,t,e);let i=Js(n);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof n[Symbol.toPrimitive]=="function")return d.from(n[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof n)}d.from=function(n,t,e){return Ei(n,t,e)};Object.setPrototypeOf(d.prototype,Uint8Array.prototype);Object.setPrototypeOf(d,Uint8Array);function Ti(n){if(typeof n!="number")throw new TypeError('"size" argument must be of type number');if(n<0)throw new RangeError('The value "'+n+'" is invalid for option "size"')}function js(n,t,e){return Ti(n),n<=0?rt(n):t!==void 0?typeof e=="string"?rt(n).fill(t,e):rt(n).fill(t):rt(n)}d.alloc=function(n,t,e){return js(n,t,e)};function $r(n){return Ti(n),rt(n<0?0:qr(n)|0)}d.allocUnsafe=function(n){return $r(n)};d.allocUnsafeSlow=function(n){return $r(n)};function $s(n,t){if((typeof t!="string"||t==="")&&(t="utf8"),!d.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=Ai(n,t)|0,r=rt(e),i=r.write(n,t);return i!==e&&(r=r.slice(0,i)),r}function Rr(n){let t=n.length<0?0:qr(n.length)|0,e=rt(t);for(let r=0;r<t;r+=1)e[r]=n[r]&255;return e}function qs(n){if(X(n,Uint8Array)){let t=new Uint8Array(n);return Vr(t.buffer,t.byteOffset,t.byteLength)}return Rr(n)}function Vr(n,t,e){if(t<0||n.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(n.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let r;return t===void 0&&e===void 0?r=new Uint8Array(n):e===void 0?r=new Uint8Array(n,t):r=new Uint8Array(n,t,e),Object.setPrototypeOf(r,d.prototype),r}function Js(n){if(d.isBuffer(n)){let t=qr(n.length)|0,e=rt(t);return e.length===0||n.copy(e,0,0,t),e}if(n.length!==void 0)return typeof n.length!="number"||Gr(n.length)?rt(0):Rr(n);if(n.type==="Buffer"&&Array.isArray(n.data))return Rr(n.data)}function qr(n){if(n>=Re)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Re.toString(16)+" bytes");return n|0}function Gs(n){return+n!=n&&(n=0),d.alloc(+n)}d.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==d.prototype};d.compare=function(t,e){if(X(t,Uint8Array)&&(t=d.from(t,t.offset,t.byteLength)),X(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),!d.isBuffer(t)||!d.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,i=e.length;for(let o=0,s=Math.min(r,i);o<s;++o)if(t[o]!==e[o]){r=t[o],i=e[o];break}return r<i?-1:i<r?1:0};d.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};d.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return d.alloc(0);let r;if(e===void 0)for(e=0,r=0;r<t.length;++r)e+=t[r].length;let i=d.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){let s=t[r];if(X(s,Uint8Array))o+s.length>i.length?(d.isBuffer(s)||(s=d.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(d.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function Ai(n,t){if(d.isBuffer(n))return n.length;if(ArrayBuffer.isView(n)||X(n,ArrayBuffer))return n.byteLength;if(typeof n!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof n);let e=n.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&e===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":return jr(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Ui(n).length;default:if(i)return r?-1:jr(n).length;t=(""+t).toLowerCase(),i=!0}}d.byteLength=Ai;function Hs(n,t,e){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(n||(n="utf8");;)switch(n){case"hex":return nc(this,t,e);case"utf8":case"utf-8":return Bi(this,t,e);case"ascii":return ec(this,t,e);case"latin1":case"binary":return rc(this,t,e);case"base64":return Qs(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ic(this,t,e);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),r=!0}}d.prototype._isBuffer=!0;function St(n,t,e){let r=n[t];n[t]=n[e],n[e]=r}d.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)St(this,e,e+1);return this};d.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)St(this,e,e+3),St(this,e+1,e+2);return this};d.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)St(this,e,e+7),St(this,e+1,e+6),St(this,e+2,e+5),St(this,e+3,e+4);return this};d.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?Bi(this,0,t):Hs.apply(this,arguments)};d.prototype.toLocaleString=d.prototype.toString;d.prototype.equals=function(t){if(!d.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:d.compare(this,t)===0};d.prototype.inspect=function(){let t="",e=Xt.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"};gi&&(d.prototype[gi]=d.prototype.inspect);d.prototype.compare=function(t,e,r,i,o){if(X(t,Uint8Array)&&(t=d.from(t,t.offset,t.byteLength)),!d.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),r===void 0&&(r=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),e<0||r>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&e>=r)return 0;if(i>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,i>>>=0,o>>>=0,this===t)return 0;let s=o-i,c=r-e,u=Math.min(s,c),a=this.slice(i,o),h=t.slice(e,r);for(let f=0;f<u;++f)if(a[f]!==h[f]){s=a[f],c=h[f];break}return s<c?-1:c<s?1:0};function _i(n,t,e,r,i){if(n.length===0)return-1;if(typeof e=="string"?(r=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,Gr(e)&&(e=i?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(i)return-1;e=n.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=d.from(t,r)),d.isBuffer(t))return t.length===0?-1:xi(n,t,e,r,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):xi(n,[t],e,r,i);throw new TypeError("val must be string, number or Buffer")}function xi(n,t,e,r,i){let o=1,s=n.length,c=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(n.length<2||t.length<2)return-1;o=2,s/=2,c/=2,e/=2}function u(h,f){return o===1?h[f]:h.readUInt16BE(f*o)}let a;if(i){let h=-1;for(a=e;a<s;a++)if(u(n,a)===u(t,h===-1?0:a-h)){if(h===-1&&(h=a),a-h+1===c)return h*o}else h!==-1&&(a-=a-h),h=-1}else for(e+c>s&&(e=s-c),a=e;a>=0;a--){let h=!0;for(let f=0;f<c;f++)if(u(n,a+f)!==u(t,f)){h=!1;break}if(h)return a}return-1}d.prototype.includes=function(t,e,r){return this.indexOf(t,e,r)!==-1};d.prototype.indexOf=function(t,e,r){return _i(this,t,e,r,!0)};d.prototype.lastIndexOf=function(t,e,r){return _i(this,t,e,r,!1)};function Ws(n,t,e,r){e=Number(e)||0;let i=n.length-e;r?(r=Number(r),r>i&&(r=i)):r=i;let o=t.length;r>o/2&&(r=o/2);let s;for(s=0;s<r;++s){let c=parseInt(t.substr(s*2,2),16);if(Gr(c))return s;n[e+s]=c}return s}function zs(n,t,e,r){return Ve(jr(t,n.length-e),n,e,r)}function Xs(n,t,e,r){return Ve(uc(t),n,e,r)}function Ys(n,t,e,r){return Ve(Ui(t),n,e,r)}function Zs(n,t,e,r){return Ve(ac(t,n.length-e),n,e,r)}d.prototype.write=function(t,e,r,i){if(e===void 0)i="utf8",r=this.length,e=0;else if(r===void 0&&typeof e=="string")i=e,r=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(r)?(r=r>>>0,i===void 0&&(i="utf8")):(i=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-e;if((r===void 0||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return Ws(this,t,e,r);case"utf8":case"utf-8":return zs(this,t,e,r);case"ascii":case"latin1":case"binary":return Xs(this,t,e,r);case"base64":return Ys(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Zs(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Qs(n,t,e){return t===0&&e===n.length?Nr.fromByteArray(n):Nr.fromByteArray(n.slice(t,e))}function Bi(n,t,e){e=Math.min(n.length,e);let r=[],i=t;for(;i<e;){let o=n[i],s=null,c=o>239?4:o>223?3:o>191?2:1;if(i+c<=e){let u,a,h,f;switch(c){case 1:o<128&&(s=o);break;case 2:u=n[i+1],(u&192)===128&&(f=(o&31)<<6|u&63,f>127&&(s=f));break;case 3:u=n[i+1],a=n[i+2],(u&192)===128&&(a&192)===128&&(f=(o&15)<<12|(u&63)<<6|a&63,f>2047&&(f<55296||f>57343)&&(s=f));break;case 4:u=n[i+1],a=n[i+2],h=n[i+3],(u&192)===128&&(a&192)===128&&(h&192)===128&&(f=(o&15)<<18|(u&63)<<12|(a&63)<<6|h&63,f>65535&&f<1114112&&(s=f))}}s===null?(s=65533,c=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),i+=c}return tc(r)}var vi=4096;function tc(n){let t=n.length;if(t<=vi)return String.fromCharCode.apply(String,n);let e="",r=0;for(;r<t;)e+=String.fromCharCode.apply(String,n.slice(r,r+=vi));return e}function ec(n,t,e){let r="";e=Math.min(n.length,e);for(let i=t;i<e;++i)r+=String.fromCharCode(n[i]&127);return r}function rc(n,t,e){let r="";e=Math.min(n.length,e);for(let i=t;i<e;++i)r+=String.fromCharCode(n[i]);return r}function nc(n,t,e){let r=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>r)&&(e=r);let i="";for(let o=t;o<e;++o)i+=fc[n[o]];return i}function ic(n,t,e){let r=n.slice(t,e),i="";for(let o=0;o<r.length-1;o+=2)i+=String.fromCharCode(r[o]+r[o+1]*256);return i}d.prototype.slice=function(t,e){let r=this.length;t=~~t,e=e===void 0?r:~~e,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),e<t&&(e=t);let i=this.subarray(t,e);return Object.setPrototypeOf(i,d.prototype),i};function b(n,t,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>e)throw new RangeError("Trying to access beyond buffer length")}d.prototype.readUintLE=d.prototype.readUIntLE=function(t,e,r){t=t>>>0,e=e>>>0,r||b(t,e,this.length);let i=this[t],o=1,s=0;for(;++s<e&&(o*=256);)i+=this[t+s]*o;return i};d.prototype.readUintBE=d.prototype.readUIntBE=function(t,e,r){t=t>>>0,e=e>>>0,r||b(t,e,this.length);let i=this[t+--e],o=1;for(;e>0&&(o*=256);)i+=this[t+--e]*o;return i};d.prototype.readUint8=d.prototype.readUInt8=function(t,e){return t=t>>>0,e||b(t,1,this.length),this[t]};d.prototype.readUint16LE=d.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||b(t,2,this.length),this[t]|this[t+1]<<8};d.prototype.readUint16BE=d.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||b(t,2,this.length),this[t]<<8|this[t+1]};d.prototype.readUint32LE=d.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||b(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};d.prototype.readUint32BE=d.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||b(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};d.prototype.readBigUInt64LE=ht(function(t){t=t>>>0,zt(t,"offset");let e=this[t],r=this[t+7];(e===void 0||r===void 0)&&de(t,this.length-8);let i=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,o=this[++t]+this[++t]*2**8+this[++t]*2**16+r*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});d.prototype.readBigUInt64BE=ht(function(t){t=t>>>0,zt(t,"offset");let e=this[t],r=this[t+7];(e===void 0||r===void 0)&&de(t,this.length-8);let i=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],o=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+r;return(BigInt(i)<<BigInt(32))+BigInt(o)});d.prototype.readIntLE=function(t,e,r){t=t>>>0,e=e>>>0,r||b(t,e,this.length);let i=this[t],o=1,s=0;for(;++s<e&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i};d.prototype.readIntBE=function(t,e,r){t=t>>>0,e=e>>>0,r||b(t,e,this.length);let i=e,o=1,s=this[t+--i];for(;i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*e)),s};d.prototype.readInt8=function(t,e){return t=t>>>0,e||b(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};d.prototype.readInt16LE=function(t,e){t=t>>>0,e||b(t,2,this.length);let r=this[t]|this[t+1]<<8;return r&32768?r|4294901760:r};d.prototype.readInt16BE=function(t,e){t=t>>>0,e||b(t,2,this.length);let r=this[t+1]|this[t]<<8;return r&32768?r|4294901760:r};d.prototype.readInt32LE=function(t,e){return t=t>>>0,e||b(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};d.prototype.readInt32BE=function(t,e){return t=t>>>0,e||b(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};d.prototype.readBigInt64LE=ht(function(t){t=t>>>0,zt(t,"offset");let e=this[t],r=this[t+7];(e===void 0||r===void 0)&&de(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(r<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)});d.prototype.readBigInt64BE=ht(function(t){t=t>>>0,zt(t,"offset");let e=this[t],r=this[t+7];(e===void 0||r===void 0)&&de(t,this.length-8);let i=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+r)});d.prototype.readFloatLE=function(t,e){return t=t>>>0,e||b(t,4,this.length),Wt.read(this,t,!0,23,4)};d.prototype.readFloatBE=function(t,e){return t=t>>>0,e||b(t,4,this.length),Wt.read(this,t,!1,23,4)};d.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||b(t,8,this.length),Wt.read(this,t,!0,52,8)};d.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||b(t,8,this.length),Wt.read(this,t,!1,52,8)};function S(n,t,e,r,i,o){if(!d.isBuffer(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(e+r>n.length)throw new RangeError("Index out of range")}d.prototype.writeUintLE=d.prototype.writeUIntLE=function(t,e,r,i){if(t=+t,e=e>>>0,r=r>>>0,!i){let c=Math.pow(2,8*r)-1;S(this,t,e,r,c,0)}let o=1,s=0;for(this[e]=t&255;++s<r&&(o*=256);)this[e+s]=t/o&255;return e+r};d.prototype.writeUintBE=d.prototype.writeUIntBE=function(t,e,r,i){if(t=+t,e=e>>>0,r=r>>>0,!i){let c=Math.pow(2,8*r)-1;S(this,t,e,r,c,0)}let o=r-1,s=1;for(this[e+o]=t&255;--o>=0&&(s*=256);)this[e+o]=t/s&255;return e+r};d.prototype.writeUint8=d.prototype.writeUInt8=function(t,e,r){return t=+t,e=e>>>0,r||S(this,t,e,1,255,0),this[e]=t&255,e+1};d.prototype.writeUint16LE=d.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=e>>>0,r||S(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2};d.prototype.writeUint16BE=d.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=e>>>0,r||S(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2};d.prototype.writeUint32LE=d.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=e>>>0,r||S(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4};d.prototype.writeUint32BE=d.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=e>>>0,r||S(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function Ki(n,t,e,r,i){Ci(t,r,i,n,e,7);let o=Number(t&BigInt(4294967295));n[e++]=o,o=o>>8,n[e++]=o,o=o>>8,n[e++]=o,o=o>>8,n[e++]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return n[e++]=s,s=s>>8,n[e++]=s,s=s>>8,n[e++]=s,s=s>>8,n[e++]=s,e}function Si(n,t,e,r,i){Ci(t,r,i,n,e,7);let o=Number(t&BigInt(4294967295));n[e+7]=o,o=o>>8,n[e+6]=o,o=o>>8,n[e+5]=o,o=o>>8,n[e+4]=o;let s=Number(t>>BigInt(32)&BigInt(4294967295));return n[e+3]=s,s=s>>8,n[e+2]=s,s=s>>8,n[e+1]=s,s=s>>8,n[e]=s,e+8}d.prototype.writeBigUInt64LE=ht(function(t,e=0){return Ki(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});d.prototype.writeBigUInt64BE=ht(function(t,e=0){return Si(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))});d.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e=e>>>0,!i){let u=Math.pow(2,8*r-1);S(this,t,e,r,u-1,-u)}let o=0,s=1,c=0;for(this[e]=t&255;++o<r&&(s*=256);)t<0&&c===0&&this[e+o-1]!==0&&(c=1),this[e+o]=(t/s>>0)-c&255;return e+r};d.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e=e>>>0,!i){let u=Math.pow(2,8*r-1);S(this,t,e,r,u-1,-u)}let o=r-1,s=1,c=0;for(this[e+o]=t&255;--o>=0&&(s*=256);)t<0&&c===0&&this[e+o+1]!==0&&(c=1),this[e+o]=(t/s>>0)-c&255;return e+r};d.prototype.writeInt8=function(t,e,r){return t=+t,e=e>>>0,r||S(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1};d.prototype.writeInt16LE=function(t,e,r){return t=+t,e=e>>>0,r||S(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2};d.prototype.writeInt16BE=function(t,e,r){return t=+t,e=e>>>0,r||S(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2};d.prototype.writeInt32LE=function(t,e,r){return t=+t,e=e>>>0,r||S(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4};d.prototype.writeInt32BE=function(t,e,r){return t=+t,e=e>>>0,r||S(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};d.prototype.writeBigInt64LE=ht(function(t,e=0){return Ki(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});d.prototype.writeBigInt64BE=ht(function(t,e=0){return Si(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ki(n,t,e,r,i,o){if(e+r>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Oi(n,t,e,r,i){return t=+t,e=e>>>0,i||ki(n,t,e,4,34028234663852886e22,-34028234663852886e22),Wt.write(n,t,e,r,23,4),e+4}d.prototype.writeFloatLE=function(t,e,r){return Oi(this,t,e,!0,r)};d.prototype.writeFloatBE=function(t,e,r){return Oi(this,t,e,!1,r)};function Ii(n,t,e,r,i){return t=+t,e=e>>>0,i||ki(n,t,e,8,17976931348623157e292,-17976931348623157e292),Wt.write(n,t,e,r,52,8),e+8}d.prototype.writeDoubleLE=function(t,e,r){return Ii(this,t,e,!0,r)};d.prototype.writeDoubleBE=function(t,e,r){return Ii(this,t,e,!1,r)};d.prototype.copy=function(t,e,r,i){if(!d.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===r||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=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),t.length-e<i-r&&(i=t.length-e+r);let o=i-r;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,r,i):Uint8Array.prototype.set.call(t,this.subarray(r,i),e),o};d.prototype.fill=function(t,e,r,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,r=this.length):typeof r=="string"&&(i=r,r=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!d.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(t.length===1){let s=t.charCodeAt(0);(i==="utf8"&&s<128||i==="latin1")&&(t=s)}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;e=e>>>0,r=r===void 0?this.length:r>>>0,t||(t=0);let o;if(typeof t=="number")for(o=e;o<r;++o)this[o]=t;else{let s=d.isBuffer(t)?t:d.from(t,i),c=s.length;if(c===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(o=0;o<r-e;++o)this[o+e]=s[o%c]}return this};var Ht={};function Jr(n,t,e){Ht[n]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${n}]`,this.stack,delete this.name}get code(){return n}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${n}]: ${this.message}`}}}Jr("ERR_BUFFER_OUT_OF_BOUNDS",function(n){return n?`${n} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Jr("ERR_INVALID_ARG_TYPE",function(n,t){return`The "${n}" argument must be of type number. Received type ${typeof t}`},TypeError);Jr("ERR_OUT_OF_RANGE",function(n,t,e){let r=`The value of "${n}" is out of range.`,i=e;return Number.isInteger(e)&&Math.abs(e)>2**32?i=bi(String(e)):typeof e=="bigint"&&(i=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(i=bi(i)),i+="n"),r+=` It must be ${t}. Received ${i}`,r},RangeError);function bi(n){let t="",e=n.length,r=n[0]==="-"?1:0;for(;e>=r+4;e-=3)t=`_${n.slice(e-3,e)}${t}`;return`${n.slice(0,e)}${t}`}function oc(n,t,e){zt(t,"offset"),(n[t]===void 0||n[t+e]===void 0)&&de(t,n.length-(e+1))}function Ci(n,t,e,r,i,o){if(n>e||n<t){let s=typeof t=="bigint"?"n":"",c;throw o>3?t===0||t===BigInt(0)?c=`>= 0${s} and < 2${s} ** ${(o+1)*8}${s}`:c=`>= -(2${s} ** ${(o+1)*8-1}${s}) and < 2 ** ${(o+1)*8-1}${s}`:c=`>= ${t}${s} and <= ${e}${s}`,new Ht.ERR_OUT_OF_RANGE("value",c,n)}oc(r,i,o)}function zt(n,t){if(typeof n!="number")throw new Ht.ERR_INVALID_ARG_TYPE(t,"number",n)}function de(n,t,e){throw Math.floor(n)!==n?(zt(n,e),new Ht.ERR_OUT_OF_RANGE(e||"offset","an integer",n)):t<0?new Ht.ERR_BUFFER_OUT_OF_BOUNDS:new Ht.ERR_OUT_OF_RANGE(e||"offset",`>= ${e?1:0} and <= ${t}`,n)}var sc=/[^+/0-9A-Za-z-_]/g;function cc(n){if(n=n.split("=")[0],n=n.trim().replace(sc,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function jr(n,t){t=t||1/0;let e,r=n.length,i=null,o=[];for(let s=0;s<r;++s){if(e=n.charCodeAt(s),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&o.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;o.push(e)}else if(e<2048){if((t-=2)<0)break;o.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;o.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return o}function uc(n){let t=[];for(let e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function ac(n,t){let e,r,i,o=[];for(let s=0;s<n.length&&!((t-=2)<0);++s)e=n.charCodeAt(s),r=e>>8,i=e%256,o.push(i),o.push(r);return o}function Ui(n){return Nr.toByteArray(cc(n))}function Ve(n,t,e,r){let i;for(i=0;i<r&&!(i+e>=t.length||i>=n.length);++i)t[i+e]=n[i];return i}function X(n,t){return n instanceof t||n!=null&&n.constructor!=null&&n.constructor.name!=null&&n.constructor.name===t.name}function Gr(n){return n!==n}var fc=function(){let n="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){let r=e*16;for(let i=0;i<16;++i)t[r+i]=n[e]+n[i]}return t}();function ht(n){return typeof BigInt>"u"?hc:n}function hc(){throw new Error("BigInt not supported")}});var Wr=x((Ba,Pi)=>{"use strict";var Hr=null;Pi.exports=function(){return Hr===null&&(Hr={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),Hr}});var Yr=x(Di=>{"use strict";var zr=V(),dc=new Set(["buffer","view","utf8"]),Xr=class{constructor(t){if(this.encode=t.encode||this.encode,this.decode=t.decode||this.decode,this.name=t.name||this.name,this.format=t.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"||!dc.has(this.format))throw new TypeError("The 'format' property must be one of 'buffer', 'view', 'utf8'");t.createViewTranscoder&&(this.createViewTranscoder=t.createViewTranscoder),t.createBufferTranscoder&&(this.createBufferTranscoder=t.createBufferTranscoder),t.createUTF8Transcoder&&(this.createUTF8Transcoder=t.createUTF8Transcoder)}get commonName(){return this.name.split("+")[0]}createBufferTranscoder(){throw new zr(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new zr(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new zr(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};Di.Encoding=Xr});var en=x($e=>{"use strict";var{Buffer:Qr}=je()||{},{Encoding:tn}=Yr(),lc=Wr(),le=class extends tn{constructor(t){super({...t,format:"buffer"})}createViewTranscoder(){return new pe({encode:this.encode,decode:t=>this.decode(Qr.from(t.buffer,t.byteOffset,t.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},pe=class extends tn{constructor(t){super({...t,format:"view"})}createBufferTranscoder(){return new le({encode:t=>{let e=this.encode(t);return Qr.from(e.buffer,e.byteOffset,e.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},Zr=class extends tn{constructor(t){super({...t,format:"utf8"})}createBufferTranscoder(){return new le({encode:t=>Qr.from(this.encode(t),"utf8"),decode:t=>this.decode(t.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:t,textDecoder:e}=lc();return new pe({encode:r=>t.encode(this.encode(r)),decode:r=>this.decode(e.decode(r)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};$e.BufferFormat=le;$e.ViewFormat=pe;$e.UTF8Format=Zr});var Ni=x(kt=>{"use strict";var{Buffer:E}=je()||{Buffer:{isBuffer:()=>!1}},{textEncoder:Mi,textDecoder:Li}=Wr()(),{BufferFormat:ye,ViewFormat:rn,UTF8Format:Fi}=en(),qe=n=>n;kt.utf8=new Fi({encode:function(n){return E.isBuffer(n)?n.toString("utf8"):ArrayBuffer.isView(n)?Li.decode(n):String(n)},decode:qe,name:"utf8",createViewTranscoder(){return new rn({encode:function(n){return ArrayBuffer.isView(n)?n:Mi.encode(n)},decode:function(n){return Li.decode(n)},name:`${this.name}+view`})},createBufferTranscoder(){return new ye({encode:function(n){return E.isBuffer(n)?n:ArrayBuffer.isView(n)?E.from(n.buffer,n.byteOffset,n.byteLength):E.from(String(n),"utf8")},decode:function(n){return n.toString("utf8")},name:`${this.name}+buffer`})}});kt.json=new Fi({encode:JSON.stringify,decode:JSON.parse,name:"json"});kt.buffer=new ye({encode:function(n){return E.isBuffer(n)?n:ArrayBuffer.isView(n)?E.from(n.buffer,n.byteOffset,n.byteLength):E.from(String(n),"utf8")},decode:qe,name:"buffer",createViewTranscoder(){return new rn({encode:function(n){return ArrayBuffer.isView(n)?n:E.from(String(n),"utf8")},decode:function(n){return E.from(n.buffer,n.byteOffset,n.byteLength)},name:`${this.name}+view`})}});kt.view=new rn({encode:function(n){return ArrayBuffer.isView(n)?n:Mi.encode(n)},decode:qe,name:"view",createBufferTranscoder(){return new ye({encode:function(n){return E.isBuffer(n)?n:ArrayBuffer.isView(n)?E.from(n.buffer,n.byteOffset,n.byteLength):E.from(String(n),"utf8")},decode:qe,name:`${this.name}+buffer`})}});kt.hex=new ye({encode:function(n){return E.isBuffer(n)?n:E.from(String(n),"hex")},decode:function(n){return n.toString("hex")},name:"hex"});kt.base64=new ye({encode:function(n){return E.isBuffer(n)?n:E.from(String(n),"base64")},decode:function(n){return n.toString("base64")},name:"base64"})});var ji=x(Vi=>{"use strict";var Ri=V(),Ge=Ni(),{Encoding:pc}=Yr(),{BufferFormat:yc,ViewFormat:mc,UTF8Format:wc}=en(),me=Symbol("formats"),Je=Symbol("encodings"),gc=new Set(["buffer","view","utf8"]),nn=class{constructor(t){if(Array.isArray(t)){if(!t.every(e=>gc.has(e)))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}else throw new TypeError("The first argument 'formats' must be an array");this[Je]=new Map,this[me]=new Set(t);for(let e in Ge)try{this.encoding(e)}catch(r){if(r.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw r}}encodings(){return Array.from(new Set(this[Je].values()))}encoding(t){let e=this[Je].get(t);if(e===void 0){if(typeof t=="string"&&t!==""){if(e=Ec[t],!e)throw new Ri(`Encoding '${t}' is not found`,{code:"LEVEL_ENCODING_NOT_FOUND"})}else{if(typeof t!="object"||t===null)throw new TypeError("First argument 'encoding' must be a string or object");e=xc(t)}let{name:r,format:i}=e;if(!this[me].has(i))if(this[me].has("view"))e=e.createViewTranscoder();else if(this[me].has("buffer"))e=e.createBufferTranscoder();else if(this[me].has("utf8"))e=e.createUTF8Transcoder();else throw new Ri(`Encoding '${r}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[t,r,e.name,e.commonName])this[Je].set(o,e)}return e}};Vi.Transcoder=nn;function xc(n){if(n instanceof pc)return n;let t="type"in n&&typeof n.type=="string"?n.type:void 0,e=n.name||t||`anonymous-${Tc++}`;switch(vc(n)){case"view":return new mc({...n,name:e});case"utf8":return new wc({...n,name:e});case"buffer":return new yc({...n,name:e});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function vc(n){return"format"in n&&n.format!==void 0?n.format:"buffer"in n&&typeof n.buffer=="boolean"?n.buffer?"buffer":"utf8":"code"in n&&Number.isInteger(n.code)?"view":"buffer"}var bc={binary:Ge.buffer,"utf-8":Ge.utf8},Ec={...Ge,...bc},Tc=0});var qi=x((Ia,on)=>{"use strict";var Ac=Object.prototype.hasOwnProperty,B="~";function we(){}Object.create&&(we.prototype=Object.create(null),new we().__proto__||(B=!1));function _c(n,t,e){this.fn=n,this.context=t,this.once=e||!1}function $i(n,t,e,r,i){if(typeof e!="function")throw new TypeError("The listener must be a function");var o=new _c(e,r||n,i),s=B?B+t:t;return n._events[s]?n._events[s].fn?n._events[s]=[n._events[s],o]:n._events[s].push(o):(n._events[s]=o,n._eventsCount++),n}function He(n,t){--n._eventsCount===0?n._events=new we:delete n._events[t]}function T(){this._events=new we,this._eventsCount=0}T.prototype.eventNames=function(){var t=[],e,r;if(this._eventsCount===0)return t;for(r in e=this._events)Ac.call(e,r)&&t.push(B?r.slice(1):r);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};T.prototype.listeners=function(t){var e=B?B+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,s=new Array(o);i<o;i++)s[i]=r[i].fn;return s};T.prototype.listenerCount=function(t){var e=B?B+t:t,r=this._events[e];return r?r.fn?1:r.length:0};T.prototype.emit=function(t,e,r,i,o,s){var c=B?B+t:t;if(!this._events[c])return!1;var u=this._events[c],a=arguments.length,h,f;if(u.fn){switch(u.once&&this.removeListener(t,u.fn,void 0,!0),a){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,e),!0;case 3:return u.fn.call(u.context,e,r),!0;case 4:return u.fn.call(u.context,e,r,i),!0;case 5:return u.fn.call(u.context,e,r,i,o),!0;case 6:return u.fn.call(u.context,e,r,i,o,s),!0}for(f=1,h=new Array(a-1);f<a;f++)h[f-1]=arguments[f];u.fn.apply(u.context,h)}else{var l=u.length,p;for(f=0;f<l;f++)switch(u[f].once&&this.removeListener(t,u[f].fn,void 0,!0),a){case 1:u[f].fn.call(u[f].context);break;case 2:u[f].fn.call(u[f].context,e);break;case 3:u[f].fn.call(u[f].context,e,r);break;case 4:u[f].fn.call(u[f].context,e,r,i);break;default:if(!h)for(p=1,h=new Array(a-1);p<a;p++)h[p-1]=arguments[p];u[f].fn.apply(u[f].context,h)}}return!0};T.prototype.on=function(t,e,r){return $i(this,t,e,r,!1)};T.prototype.once=function(t,e,r){return $i(this,t,e,r,!0)};T.prototype.removeListener=function(t,e,r,i){var o=B?B+t:t;if(!this._events[o])return this;if(!e)return He(this,o),this;var s=this._events[o];if(s.fn)s.fn===e&&(!i||s.once)&&(!r||s.context===r)&&He(this,o);else{for(var c=0,u=[],a=s.length;c<a;c++)(s[c].fn!==e||i&&!s[c].once||r&&s[c].context!==r)&&u.push(s[c]);u.length?this._events[o]=u.length===1?u[0]:u:He(this,o)}return this};T.prototype.removeAllListeners=function(t){var e;return t?(e=B?B+t:t,this._events[e]&&He(this,e)):(this._events=new we,this._eventsCount=0),this};T.prototype.off=T.prototype.removeListener;T.prototype.addListener=T.prototype.on;T.prefixed=B;T.EventEmitter=T;typeof on<"u"&&(on.exports=T)});var Gi=x((Ca,Ji)=>{Ji.exports=typeof queueMicrotask=="function"?queueMicrotask:n=>Promise.resolve().then(n)});var ge=x(sn=>{"use strict";var Hi=Gi();sn.fromCallback=function(n,t){if(n===void 0){var e=new Promise(function(r,i){n=function(o,s){o?i(o):r(s)}});n[t!==void 0?t:"promise"]=e}else if(typeof n!="function")throw new TypeError("Callback must be a function");return n};sn.fromPromise=function(n,t){if(t===void 0)return n;n.then(function(e){Hi(()=>t(null,e))}).catch(function(e){Hi(()=>t(e))})}});var We=x(cn=>{"use strict";cn.getCallback=function(n,t){return typeof n=="function"?n:t};cn.getOptions=function(n,t){return typeof n=="object"&&n!==null?n:t!==void 0?t:{}}});var wt=x(Ze=>{"use strict";var{fromCallback:un}=ge(),I=V(),{getOptions:an,getCallback:Wi}=We(),Ot=Symbol("promise"),Yt=Symbol("callback"),Y=Symbol("working"),It=Symbol("handleOne"),nt=Symbol("handleMany"),fn=Symbol("autoClose"),yt=Symbol("finishWork"),Z=Symbol("returnMany"),dt=Symbol("closing"),xe=Symbol("handleClose"),ze=Symbol("closed"),ve=Symbol("closeCallbacks"),pt=Symbol("keyEncoding"),Ct=Symbol("valueEncoding"),hn=Symbol("abortOnClose"),Xe=Symbol("legacy"),dn=Symbol("keys"),ln=Symbol("values"),lt=Symbol("limit"),M=Symbol("count"),Ye=Object.freeze({}),Bc=()=>{},zi=!1,be=class{constructor(t,e,r){if(typeof t!="object"||t===null){let i=t===null?"null":typeof t;throw new TypeError(`The first argument must be an abstract-level database, received ${i}`)}if(typeof e!="object"||e===null)throw new TypeError("The second argument must be an options object");this[ze]=!1,this[ve]=[],this[Y]=!1,this[dt]=!1,this[fn]=!1,this[Yt]=null,this[It]=this[It].bind(this),this[nt]=this[nt].bind(this),this[xe]=this[xe].bind(this),this[pt]=e[pt],this[Ct]=e[Ct],this[Xe]=r,this[lt]=Number.isInteger(e.limit)&&e.limit>=0?e.limit:1/0,this[M]=0,this[hn]=!!e.abortOnClose,this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get count(){return this[M]}get limit(){return this[lt]}next(t){let e;if(t===void 0)e=new Promise((r,i)=>{t=(o,s,c)=>{o?i(o):this[Xe]?s===void 0&&c===void 0?r():r([s,c]):r(s)}});else if(typeof t!="function")throw new TypeError("Callback must be a function");return this[dt]?this.nextTick(t,new I("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Y]?this.nextTick(t,new I("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[Y]=!0,this[Yt]=t,this[M]>=this[lt]?this.nextTick(this[It],null):this._next(this[It])),e}_next(t){this.nextTick(t)}nextv(t,e,r){return r=Wi(e,r),r=un(r,Ot),e=an(e,Ye),Number.isInteger(t)?(this[dt]?this.nextTick(r,new I("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Y]?this.nextTick(r,new I("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(t<1&&(t=1),this[lt]<1/0&&(t=Math.min(t,this[lt]-this[M])),this[Y]=!0,this[Yt]=r,t<=0?this.nextTick(this[nt],null,[]):this._nextv(t,e,this[nt])),r[Ot]):(this.nextTick(r,new TypeError("The first argument 'size' must be an integer")),r[Ot])}_nextv(t,e,r){let i=[],o=(s,c,u)=>{if(s)return r(s);if(this[Xe]?c===void 0&&u===void 0:c===void 0)return r(null,i);i.push(this[Xe]?[c,u]:c),i.length===t?r(null,i):this._next(o)};this._next(o)}all(t,e){return e=Wi(t,e),e=un(e,Ot),t=an(t,Ye),this[dt]?this.nextTick(e,new I("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[Y]?this.nextTick(e,new I("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[Y]=!0,this[Yt]=e,this[fn]=!0,this[M]>=this[lt]?this.nextTick(this[nt],null,[]):this._all(t,this[nt])),e[Ot]}_all(t,e){let r=this[M],i=[],o=()=>{let c=this[lt]<1/0?Math.min(1e3,this[lt]-r):1e3;c<=0?this.nextTick(e,null,i):this._nextv(c,Ye,s)},s=(c,u)=>{c?e(c):u.length===0?e(null,i):(i.push.apply(i,u),r+=u.length,o())};o()}[yt](){let t=this[Yt];return this[hn]&&t===null?Bc:(this[Y]=!1,this[Yt]=null,this[dt]&&this._close(this[xe]),t)}[Z](t,e,r){this[fn]?this.close(t.bind(null,e,r)):t(e,r)}seek(t,e){if(e=an(e,Ye),!this[dt]){if(this[Y])throw new I("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let r=this.db.keyEncoding(e.keyEncoding||this[pt]),i=r.format;e.keyEncoding!==i&&(e={...e,keyEncoding:i});let o=this.db.prefixKey(r.encode(t),i);this._seek(o,e)}}}_seek(t,e){throw new I("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(t){return t=un(t,Ot),this[ze]?this.nextTick(t):this[dt]?this[ve].push(t):(this[dt]=!0,this[ve].push(t),this[Y]?this[hn]&&this[yt]()(new I("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[xe])),t[Ot]}_close(t){this.nextTick(t)}[xe](){this[ze]=!0,this.db.detachResource(this);let t=this[ve];this[ve]=[];for(let e of t)e()}async*[Symbol.asyncIterator](){try{let t;for(;(t=await this.next())!==void 0;)yield t}finally{this[ze]||await this.close()}}},Zt=class extends be{constructor(t,e){super(t,e,!0),this[dn]=e.keys!==!1,this[ln]=e.values!==!1}[It](t,e,r){let i=this[yt]();if(t)return i(t);try{e=this[dn]&&e!==void 0?this[pt].decode(e):void 0,r=this[ln]&&r!==void 0?this[Ct].decode(r):void 0}catch(o){return i(new mt("entry",o))}e===void 0&&r===void 0||this[M]++,i(null,e,r)}[nt](t,e){let r=this[yt]();if(t)return this[Z](r,t);try{for(let i of e){let o=i[0],s=i[1];i[0]=this[dn]&&o!==void 0?this[pt].decode(o):void 0,i[1]=this[ln]&&s!==void 0?this[Ct].decode(s):void 0}}catch(i){return this[Z](r,new mt("entries",i))}this[M]+=e.length,this[Z](r,null,e)}end(t){return!zi&&typeof console<"u"&&(zi=!0,console.warn(new I("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(t)}},pn=class extends be{constructor(t,e){super(t,e,!1)}[It](t,e){let r=this[yt]();if(t)return r(t);try{e=e!==void 0?this[pt].decode(e):void 0}catch(i){return r(new mt("key",i))}e!==void 0&&this[M]++,r(null,e)}[nt](t,e){let r=this[yt]();if(t)return this[Z](r,t);try{for(let i=0;i<e.length;i++){let o=e[i];e[i]=o!==void 0?this[pt].decode(o):void 0}}catch(i){return this[Z](r,new mt("keys",i))}this[M]+=e.length,this[Z](r,null,e)}},yn=class extends be{constructor(t,e){super(t,e,!1)}[It](t,e){let r=this[yt]();if(t)return r(t);try{e=e!==void 0?this[Ct].decode(e):void 0}catch(i){return r(new mt("value",i))}e!==void 0&&this[M]++,r(null,e)}[nt](t,e){let r=this[yt]();if(t)return this[Z](r,t);try{for(let i=0;i<e.length;i++){let o=e[i];e[i]=o!==void 0?this[Ct].decode(o):void 0}}catch(i){return this[Z](r,new mt("values",i))}this[M]+=e.length,this[Z](r,null,e)}},mt=class extends I{constructor(t,e){super(`Iterator could not decode ${t}`,{code:"LEVEL_DECODE_ERROR",cause:e})}};for(let n of["_ended property","_nexting property","_end method"])Object.defineProperty(Zt.prototype,n.split(" ")[0],{get(){throw new I(`The ${n} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new I(`The ${n} has been removed`,{code:"LEVEL_LEGACY"})}});Zt.keyEncoding=pt;Zt.valueEncoding=Ct;Ze.AbstractIterator=Zt;Ze.AbstractKeyIterator=pn;Ze.AbstractValueIterator=yn});var Xi=x(mn=>{"use strict";var{AbstractKeyIterator:Kc,AbstractValueIterator:Sc}=wt(),Ut=Symbol("iterator"),Ee=Symbol("callback"),Qt=Symbol("handleOne"),Pt=Symbol("handleMany"),Te=class extends Kc{constructor(t,e){super(t,e),this[Ut]=t.iterator({...e,keys:!0,values:!1}),this[Qt]=this[Qt].bind(this),this[Pt]=this[Pt].bind(this)}},Qe=class extends Sc{constructor(t,e){super(t,e),this[Ut]=t.iterator({...e,keys:!1,values:!0}),this[Qt]=this[Qt].bind(this),this[Pt]=this[Pt].bind(this)}};for(let n of[Te,Qe]){let t=n===Te,e=t?r=>r[0]:r=>r[1];n.prototype._next=function(r){this[Ee]=r,this[Ut].next(this[Qt])},n.prototype[Qt]=function(r,i,o){let s=this[Ee];r?s(r):s(null,t?i:o)},n.prototype._nextv=function(r,i,o){this[Ee]=o,this[Ut].nextv(r,i,this[Pt])},n.prototype._all=function(r,i){this[Ee]=i,this[Ut].all(r,this[Pt])},n.prototype[Pt]=function(r,i){let o=this[Ee];r?o(r):o(null,i.map(e))},n.prototype._seek=function(r,i){this[Ut].seek(r,i)},n.prototype._close=function(r){this[Ut].close(r)}}mn.DefaultKeyIterator=Te;mn.DefaultValueIterator=Qe});var Yi=x(or=>{"use strict";var{AbstractIterator:kc,AbstractKeyIterator:Oc,AbstractValueIterator:Ic}=wt(),wn=V(),k=Symbol("nut"),nr=Symbol("undefer"),ir=Symbol("factory"),tr=class extends kc{constructor(t,e){super(t,e),this[k]=null,this[ir]=()=>t.iterator(e),this.db.defer(()=>this[nr]())}},er=class extends Oc{constructor(t,e){super(t,e),this[k]=null,this[ir]=()=>t.keys(e),this.db.defer(()=>this[nr]())}},rr=class extends Ic{constructor(t,e){super(t,e),this[k]=null,this[ir]=()=>t.values(e),this.db.defer(()=>this[nr]())}};for(let n of[tr,er,rr])n.prototype[nr]=function(){this.db.status==="open"&&(this[k]=this[ir]())},n.prototype._next=function(t){this[k]!==null?this[k].next(t):this.db.status==="opening"?this.db.defer(()=>this._next(t)):this.nextTick(t,new wn("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},n.prototype._nextv=function(t,e,r){this[k]!==null?this[k].nextv(t,e,r):this.db.status==="opening"?this.db.defer(()=>this._nextv(t,e,r)):this.nextTick(r,new wn("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},n.prototype._all=function(t,e){this[k]!==null?this[k].all(e):this.db.status==="opening"?this.db.defer(()=>this._all(t,e)):this.nextTick(e,new wn("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},n.prototype._seek=function(t,e){this[k]!==null?this[k]._seek(t,e):this.db.status==="opening"&&this.db.defer(()=>this._seek(t,e))},n.prototype._close=function(t){this[k]!==null?this[k].close(t):this.db.status==="opening"?this.db.defer(()=>this._close(t)):this.nextTick(t)};or.DeferredIterator=tr;or.DeferredKeyIterator=er;or.DeferredValueIterator=rr});var xn=x(Qi=>{"use strict";var{fromCallback:Zi}=ge(),sr=V(),{getCallback:Cc,getOptions:Uc}=We(),cr=Symbol("promise"),F=Symbol("status"),te=Symbol("operations"),Ae=Symbol("finishClose"),ee=Symbol("closeCallbacks"),gn=class{constructor(t){if(typeof t!="object"||t===null){let e=t===null?"null":typeof t;throw new TypeError(`The first argument must be an abstract-level database, received ${e}`)}this[te]=[],this[ee]=[],this[F]="open",this[Ae]=this[Ae].bind(this),this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get length(){return this[te].length}put(t,e,r){if(this[F]!=="open")throw new sr("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let i=this.db._checkKey(t)||this.db._checkValue(e);if(i)throw i;let o=r&&r.sublevel!=null?r.sublevel:this.db,s=r,c=o.keyEncoding(r&&r.keyEncoding),u=o.valueEncoding(r&&r.valueEncoding),a=c.format;r={...r,keyEncoding:a,valueEncoding:u.format},o!==this.db&&(r.sublevel=null);let h=o.prefixKey(c.encode(t),a),f=u.encode(e);return this._put(h,f,r),this[te].push({...s,type:"put",key:t,value:e}),this}_put(t,e,r){}del(t,e){if(this[F]!=="open")throw new sr("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let r=this.db._checkKey(t);if(r)throw r;let i=e&&e.sublevel!=null?e.sublevel:this.db,o=e,s=i.keyEncoding(e&&e.keyEncoding),c=s.format;return e={...e,keyEncoding:c},i!==this.db&&(e.sublevel=null),this._del(i.prefixKey(s.encode(t),c),e),this[te].push({...o,type:"del",key:t}),this}_del(t,e){}clear(){if(this[F]!=="open")throw new sr("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[te]=[],this}_clear(){}write(t,e){return e=Cc(t,e),e=Zi(e,cr),t=Uc(t),this[F]!=="open"?this.nextTick(e,new sr("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(e):(this[F]="writing",this._write(t,r=>{this[F]="closing",this[ee].push(()=>e(r)),r||this.db.emit("batch",this[te]),this._close(this[Ae])})),e[cr]}_write(t,e){}close(t){return t=Zi(t,cr),this[F]==="closing"?this[ee].push(t):this[F]==="closed"?this.nextTick(t):(this[ee].push(t),this[F]!=="writing"&&(this[F]="closing",this._close(this[Ae]))),t[cr]}_close(t){this.nextTick(t)}[Ae](){this[F]="closed",this.db.detachResource(this);let t=this[ee];this[ee]=[];for(let e of t)e()}};Qi.AbstractChainedBatch=gn});var eo=x(to=>{"use strict";var{AbstractChainedBatch:Pc}=xn(),Dc=V(),re=Symbol("encoded"),vn=class extends Pc{constructor(t){super(t),this[re]=[]}_put(t,e,r){this[re].push({...r,type:"put",key:t,value:e})}_del(t,e){this[re].push({...e,type:"del",key:t})}_clear(){this[re]=[]}_write(t,e){this.db.status==="opening"?this.db.defer(()=>this._write(t,e)):this.db.status==="open"?this[re].length===0?this.nextTick(e):this.db._batch(this[re],t,e):this.nextTick(e,new Dc("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};to.DefaultChainedBatch=vn});var io=x((Ra,no)=>{"use strict";var ro=V(),Lc=Object.prototype.hasOwnProperty,Mc=new Set(["lt","lte","gt","gte"]);no.exports=function(n,t){let e={};for(let r in n)if(Lc.call(n,r)&&!(r==="keyEncoding"||r==="valueEncoding")){if(r==="start"||r==="end")throw new ro(`The legacy range option '${r}' has been removed`,{code:"LEVEL_LEGACY"});if(r==="encoding")throw new ro("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});Mc.has(r)?e[r]=t.encode(n[r]):e[r]=n[r]}return e.reverse=!!e.reverse,e.limit=Number.isInteger(e.limit)&&e.limit>=0?e.limit:-1,e}});var bn=x((Va,so)=>{var oo;so.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):n=>(oo||(oo=Promise.resolve())).then(n).catch(t=>setTimeout(()=>{throw t},0))});var ao=x((ja,uo)=>{"use strict";var co=bn();uo.exports=function(n,...t){t.length===0?co(n):co(()=>n(...t))}});var fo=x(ur=>{"use strict";var{AbstractIterator:Fc,AbstractKeyIterator:Nc,AbstractValueIterator:Rc}=wt(),ne=Symbol("unfix"),j=Symbol("iterator"),Dt=Symbol("handleOne"),gt=Symbol("handleMany"),it=Symbol("callback"),_e=class extends Fc{constructor(t,e,r,i){super(t,e),this[j]=r,this[ne]=i,this[Dt]=this[Dt].bind(this),this[gt]=this[gt].bind(this),this[it]=null}[Dt](t,e,r){let i=this[it];if(t)return i(t);e!==void 0&&(e=this[ne](e)),i(t,e,r)}[gt](t,e){let r=this[it];if(t)return r(t);for(let i of e){let o=i[0];o!==void 0&&(i[0]=this[ne](o))}r(t,e)}},Be=class extends Nc{constructor(t,e,r,i){super(t,e),this[j]=r,this[ne]=i,this[Dt]=this[Dt].bind(this),this[gt]=this[gt].bind(this),this[it]=null}[Dt](t,e){let r=this[it];if(t)return r(t);e!==void 0&&(e=this[ne](e)),r(t,e)}[gt](t,e){let r=this[it];if(t)return r(t);for(let i=0;i<e.length;i++){let o=e[i];o!==void 0&&(e[i]=this[ne](o))}r(t,e)}},Ke=class extends Rc{constructor(t,e,r){super(t,e),this[j]=r}};for(let n of[_e,Be])n.prototype._next=function(t){this[it]=t,this[j].next(this[Dt])},n.prototype._nextv=function(t,e,r){this[it]=r,this[j].nextv(t,e,this[gt])},n.prototype._all=function(t,e){this[it]=e,this[j].all(t,this[gt])};for(let n of[Ke])n.prototype._next=function(t){this[j].next(t)},n.prototype._nextv=function(t,e,r){this[j].nextv(t,e,r)},n.prototype._all=function(t,e){this[j].all(t,e)};for(let n of[_e,Be,Ke])n.prototype._seek=function(t,e){this[j].seek(t,e)},n.prototype._close=function(t){this[j].close(t)};ur.AbstractSublevelIterator=_e;ur.AbstractSublevelKeyIterator=Be;ur.AbstractSublevelValueIterator=Ke});var yo=x((qa,po)=>{"use strict";var En=V(),{Buffer:_n}=je()||{},{AbstractSublevelIterator:Vc,AbstractSublevelKeyIterator:jc,AbstractSublevelValueIterator:$c}=fo(),ot=Symbol("prefix"),ho=Symbol("upperBound"),Se=Symbol("prefixRange"),C=Symbol("parent"),Tn=Symbol("unfix"),lo=new TextEncoder,qc={separator:"!"};po.exports=function({AbstractLevel:n}){class t extends n{static defaults(r){if(typeof r=="string")throw new En("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(r&&r.open)throw new En("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return r==null?qc:r.separator?r:{...r,separator:"!"}}constructor(r,i,o){let{separator:s,manifest:c,...u}=t.defaults(o);i=Gc(i,s);let a=s.charCodeAt(0)+1,h=r[C]||r;if(!lo.encode(i).every(p=>p>a&&p<127))throw new En(`Prefix must use bytes > ${a} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(Jc(h,c),u);let f=(r.prefix||"")+s+i+s,l=f.slice(0,-1)+String.fromCharCode(a);this[C]=h,this[ot]=new ar(f),this[ho]=new ar(l),this[Tn]=new Bn,this.nextTick=h.nextTick}prefixKey(r,i){if(i==="utf8")return this[ot].utf8+r;if(r.byteLength===0)return this[ot][i];if(i==="view"){let o=this[ot].view,s=new Uint8Array(o.byteLength+r.byteLength);return s.set(o,0),s.set(r,o.byteLength),s}else{let o=this[ot].buffer;return _n.concat([o,r],o.byteLength+r.byteLength)}}[Se](r,i){r.gte!==void 0?r.gte=this.prefixKey(r.gte,i):r.gt!==void 0?r.gt=this.prefixKey(r.gt,i):r.gte=this[ot][i],r.lte!==void 0?r.lte=this.prefixKey(r.lte,i):r.lt!==void 0?r.lt=this.prefixKey(r.lt,i):r.lte=this[ho][i]}get prefix(){return this[ot].utf8}get db(){return this[C]}_open(r,i){this[C].open({passive:!0},i)}_put(r,i,o,s){this[C].put(r,i,o,s)}_get(r,i,o){this[C].get(r,i,o)}_getMany(r,i,o){this[C].getMany(r,i,o)}_del(r,i,o){this[C].del(r,i,o)}_batch(r,i,o){this[C].batch(r,i,o)}_clear(r,i){this[Se](r,r.keyEncoding),this[C].clear(r,i)}_iterator(r){this[Se](r,r.keyEncoding);let i=this[C].iterator(r),o=this[Tn].get(this[ot].utf8.length,r.keyEncoding);return new Vc(this,r,i,o)}_keys(r){this[Se](r,r.keyEncoding);let i=this[C].keys(r),o=this[Tn].get(this[ot].utf8.length,r.keyEncoding);return new jc(this,r,i,o)}_values(r){this[Se](r,r.keyEncoding);let i=this[C].values(r);return new $c(this,r,i)}}return{AbstractSublevel:t}};var Jc=function(n,t){return{...n.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...t,encodings:{utf8:An(n,"utf8"),buffer:An(n,"buffer"),view:An(n,"view")}}},An=function(n,t){return n.supports.encodings[t]?n.keyEncoding(t).name===t:!1},ar=class{constructor(t){this.utf8=t,this.view=lo.encode(t),this.buffer=_n?_n.from(this.view.buffer,0,this.view.byteLength):{}}},Bn=class{constructor(){this.cache=new Map}get(t,e){let r=this.cache.get(e);return r===void 0&&(e==="view"?r=(function(i,o){return o.subarray(i)}).bind(null,t):r=(function(i,o){return o.slice(i)}).bind(null,t),this.cache.set(e,r)),r}},Gc=function(n,t){let e=0,r=n.length;for(;e<r&&n[e]===t;)e++;for(;r>e&&n[r-1]===t;)r--;return n.slice(e,r)}});var In=x(On=>{"use strict";var{supports:Hc}=di(),{Transcoder:Wc}=ji(),{EventEmitter:zc}=qi(),{fromCallback:xt}=ge(),$=V(),{AbstractIterator:Lt}=wt(),{DefaultKeyIterator:Xc,DefaultValueIterator:Yc}=Xi(),{DeferredIterator:Zc,DeferredKeyIterator:Qc,DeferredValueIterator:tu}=Yi(),{DefaultChainedBatch:mo}=eo(),{getCallback:Mt,getOptions:vt}=We(),fr=io(),m=Symbol("promise"),st=Symbol("landed"),Ft=Symbol("resources"),Kn=Symbol("closeResources"),ke=Symbol("operations"),Oe=Symbol("undefer"),hr=Symbol("deferOpen"),wo=Symbol("options"),w=Symbol("status"),Nt=Symbol("defaultOptions"),ie=Symbol("transcoder"),dr=Symbol("keyEncoding"),Sn=Symbol("valueEncoding"),eu=()=>{},Ie=class extends zc{constructor(t,e){if(super(),typeof t!="object"||t===null)throw new TypeError("The first argument 'manifest' must be an object");e=vt(e);let{keyEncoding:r,valueEncoding:i,passive:o,...s}=e;this[Ft]=new Set,this[ke]=[],this[hr]=!0,this[wo]=s,this[w]="opening",this.supports=Hc(t,{status:!0,promises:!0,clear:!0,getMany:!0,deferredOpen:!0,snapshots:t.snapshots!==!1,permanence:t.permanence!==!1,keyIterator:!0,valueIterator:!0,iteratorNextv:!0,iteratorAll:!0,encodings:t.encodings||{},events:Object.assign({},t.events,{opening:!0,open:!0,closing:!0,closed:!0,put:!0,del:!0,batch:!0,clear:!0})}),this[ie]=new Wc(ru(this)),this[dr]=this[ie].encoding(r||"utf8"),this[Sn]=this[ie].encoding(i||"utf8");for(let c of this[ie].encodings())this.supports.encodings[c.commonName]||(this.supports.encodings[c.commonName]=!0);this[Nt]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[dr].commonName,valueEncoding:this[Sn].commonName}),key:Object.freeze({keyEncoding:this[dr].commonName})},this.nextTick(()=>{this[hr]&&this.open({passive:!1},eu)})}get status(){return this[w]}keyEncoding(t){return this[ie].encoding(t??this[dr])}valueEncoding(t){return this[ie].encoding(t??this[Sn])}open(t,e){e=Mt(t,e),e=xt(e,m),t={...this[wo],...vt(t)},t.createIfMissing=t.createIfMissing!==!1,t.errorIfExists=!!t.errorIfExists;let r=i=>{this[w]==="closing"||this[w]==="opening"?this.once(st,i?()=>r(i):r):this[w]!=="open"?e(new $("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):e()};return t.passive?this[w]==="opening"?this.once(st,r):this.nextTick(r):this[w]==="closed"||this[hr]?(this[hr]=!1,this[w]="opening",this.emit("opening"),this._open(t,i=>{if(i){this[w]="closed",this[Kn](()=>{this.emit(st),r(i)}),this[Oe]();return}this[w]="open",this[Oe](),this.emit(st),this[w]==="open"&&this.emit("open"),this[w]==="open"&&this.emit("ready"),r()})):this[w]==="open"?this.nextTick(r):this.once(st,()=>this.open(t,e)),e[m]}_open(t,e){this.nextTick(e)}close(t){t=xt(t,m);let e=r=>{this[w]==="opening"||this[w]==="closing"?this.once(st,r?e(r):e):this[w]!=="closed"?t(new $("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:r})):t()};if(this[w]==="open"){this[w]="closing",this.emit("closing");let r=i=>{this[w]="open",this[Oe](),this.emit(st),e(i)};this[Kn](()=>{this._close(i=>{if(i)return r(i);this[w]="closed",this[Oe](),this.emit(st),this[w]==="closed"&&this.emit("closed"),e()})})}else this[w]==="closed"?this.nextTick(e):this.once(st,()=>this.close(t));return t[m]}[Kn](t){if(this[Ft].size===0)return this.nextTick(t);let e=this[Ft].size,r=!0,i=()=>{--e===0&&(r?this.nextTick(t):t())};for(let o of this[Ft])o.close(i);r=!1,this[Ft].clear()}_close(t){this.nextTick(t)}get(t,e,r){if(r=Mt(e,r),r=xt(r,m),e=vt(e,this[Nt].entry),this[w]==="opening")return this.defer(()=>this.get(t,e,r)),r[m];if(oe(this,r))return r[m];let i=this._checkKey(t);if(i)return this.nextTick(r,i),r[m];let o=this.keyEncoding(e.keyEncoding),s=this.valueEncoding(e.valueEncoding),c=o.format,u=s.format;return(e.keyEncoding!==c||e.valueEncoding!==u)&&(e=Object.assign({},e,{keyEncoding:c,valueEncoding:u})),this._get(this.prefixKey(o.encode(t),c),e,(a,h)=>{if(a)return(a.code==="LEVEL_NOT_FOUND"||a.notFound||/NotFound/i.test(a))&&(a.code||(a.code="LEVEL_NOT_FOUND"),a.notFound||(a.notFound=!0),a.status||(a.status=404)),r(a);try{h=s.decode(h)}catch(f){return r(new $("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:f}))}r(null,h)}),r[m]}_get(t,e,r){this.nextTick(r,new Error("NotFound"))}getMany(t,e,r){if(r=Mt(e,r),r=xt(r,m),e=vt(e,this[Nt].entry),this[w]==="opening")return this.defer(()=>this.getMany(t,e,r)),r[m];if(oe(this,r))return r[m];if(!Array.isArray(t))return this.nextTick(r,new TypeError("The first argument 'keys' must be an array")),r[m];if(t.length===0)return this.nextTick(r,null,[]),r[m];let i=this.keyEncoding(e.keyEncoding),o=this.valueEncoding(e.valueEncoding),s=i.format,c=o.format;(e.keyEncoding!==s||e.valueEncoding!==c)&&(e=Object.assign({},e,{keyEncoding:s,valueEncoding:c}));let u=new Array(t.length);for(let a=0;a<t.length;a++){let h=t[a],f=this._checkKey(h);if(f)return this.nextTick(r,f),r[m];u[a]=this.prefixKey(i.encode(h),s)}return this._getMany(u,e,(a,h)=>{if(a)return r(a);try{for(let f=0;f<h.length;f++)h[f]!==void 0&&(h[f]=o.decode(h[f]))}catch(f){return r(new $(`Could not decode one or more of ${h.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:f}))}r(null,h)}),r[m]}_getMany(t,e,r){this.nextTick(r,null,new Array(t.length).fill(void 0))}put(t,e,r,i){if(i=Mt(r,i),i=xt(i,m),r=vt(r,this[Nt].entry),this[w]==="opening")return this.defer(()=>this.put(t,e,r,i)),i[m];if(oe(this,i))return i[m];let o=this._checkKey(t)||this._checkValue(e);if(o)return this.nextTick(i,o),i[m];let s=this.keyEncoding(r.keyEncoding),c=this.valueEncoding(r.valueEncoding),u=s.format,a=c.format;(r.keyEncoding!==u||r.valueEncoding!==a)&&(r=Object.assign({},r,{keyEncoding:u,valueEncoding:a}));let h=this.prefixKey(s.encode(t),u),f=c.encode(e);return this._put(h,f,r,l=>{if(l)return i(l);this.emit("put",t,e),i()}),i[m]}_put(t,e,r,i){this.nextTick(i)}del(t,e,r){if(r=Mt(e,r),r=xt(r,m),e=vt(e,this[Nt].key),this[w]==="opening")return this.defer(()=>this.del(t,e,r)),r[m];if(oe(this,r))return r[m];let i=this._checkKey(t);if(i)return this.nextTick(r,i),r[m];let o=this.keyEncoding(e.keyEncoding),s=o.format;return e.keyEncoding!==s&&(e=Object.assign({},e,{keyEncoding:s})),this._del(this.prefixKey(o.encode(t),s),e,c=>{if(c)return r(c);this.emit("del",t),r()}),r[m]}_del(t,e,r){this.nextTick(r)}batch(t,e,r){if(!arguments.length){if(this[w]==="opening")return new mo(this);if(this[w]!=="open")throw new $("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof t=="function"?r=t:r=Mt(e,r),r=xt(r,m),e=vt(e,this[Nt].empty),this[w]==="opening")return this.defer(()=>this.batch(t,e,r)),r[m];if(oe(this,r))return r[m];if(!Array.isArray(t))return this.nextTick(r,new TypeError("The first argument 'operations' must be an array")),r[m];if(t.length===0)return this.nextTick(r),r[m];let i=new Array(t.length),{keyEncoding:o,valueEncoding:s,...c}=e;for(let u=0;u<t.length;u++){if(typeof t[u]!="object"||t[u]===null)return this.nextTick(r,new TypeError("A batch operation must be an object")),r[m];let a=Object.assign({},t[u]);if(a.type!=="put"&&a.type!=="del")return this.nextTick(r,new TypeError("A batch operation must have a type property that is 'put' or 'del'")),r[m];let h=this._checkKey(a.key);if(h)return this.nextTick(r,h),r[m];let f=a.sublevel!=null?a.sublevel:this,l=f.keyEncoding(a.keyEncoding||o),p=l.format;if(a.key=f.prefixKey(l.encode(a.key),p),a.keyEncoding=p,a.type==="put"){let y=this._checkValue(a.value);if(y)return this.nextTick(r,y),r[m];let g=f.valueEncoding(a.valueEncoding||s);a.value=g.encode(a.value),a.valueEncoding=g.format}f!==this&&(a.sublevel=null),i[u]=a}return this._batch(i,c,u=>{if(u)return r(u);this.emit("batch",t),r()}),r[m]}_batch(t,e,r){this.nextTick(r)}sublevel(t,e){return this._sublevel(t,kn.defaults(e))}_sublevel(t,e){return new kn(this,t,e)}prefixKey(t,e){return t}clear(t,e){if(e=Mt(t,e),e=xt(e,m),t=vt(t,this[Nt].empty),this[w]==="opening")return this.defer(()=>this.clear(t,e)),e[m];if(oe(this,e))return e[m];let r=t,i=this.keyEncoding(t.keyEncoding);return t=fr(t,i),t.keyEncoding=i.format,t.limit===0?this.nextTick(e):this._clear(t,o=>{if(o)return e(o);this.emit("clear",r),e()}),e[m]}_clear(t,e){this.nextTick(e)}iterator(t){let e=this.keyEncoding(t&&t.keyEncoding),r=this.valueEncoding(t&&t.valueEncoding);if(t=fr(t,e),t.keys=t.keys!==!1,t.values=t.values!==!1,t[Lt.keyEncoding]=e,t[Lt.valueEncoding]=r,t.keyEncoding=e.format,t.valueEncoding=r.format,this[w]==="opening")return new Zc(this,t);if(this[w]!=="open")throw new $("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(t)}_iterator(t){return new Lt(this,t)}keys(t){let e=this.keyEncoding(t&&t.keyEncoding),r=this.valueEncoding(t&&t.valueEncoding);if(t=fr(t,e),t[Lt.keyEncoding]=e,t[Lt.valueEncoding]=r,t.keyEncoding=e.format,t.valueEncoding=r.format,this[w]==="opening")return new Qc(this,t);if(this[w]!=="open")throw new $("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(t)}_keys(t){return new Xc(this,t)}values(t){let e=this.keyEncoding(t&&t.keyEncoding),r=this.valueEncoding(t&&t.valueEncoding);if(t=fr(t,e),t[Lt.keyEncoding]=e,t[Lt.valueEncoding]=r,t.keyEncoding=e.format,t.valueEncoding=r.format,this[w]==="opening")return new tu(this,t);if(this[w]!=="open")throw new $("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(t)}_values(t){return new Yc(this,t)}defer(t){if(typeof t!="function")throw new TypeError("The first argument must be a function");this[ke].push(t)}[Oe](){if(this[ke].length===0)return;let t=this[ke];this[ke]=[];for(let e of t)e()}attachResource(t){if(typeof t!="object"||t===null||typeof t.close!="function")throw new TypeError("The first argument must be a resource object");this[Ft].add(t)}detachResource(t){this[Ft].delete(t)}_chainedBatch(){return new mo(this)}_checkKey(t){if(t==null)return new $("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(t){if(t==null)return new $("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};Ie.prototype.nextTick=ao();var{AbstractSublevel:kn}=yo()({AbstractLevel:Ie});On.AbstractLevel=Ie;On.AbstractSublevel=kn;var oe=function(n,t){return n[w]!=="open"?(n.nextTick(t,new $("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},ru=function(n){return Object.keys(n.supports.encodings).filter(t=>!!n.supports.encodings[t])}});var Cn=x(Rt=>{"use strict";Rt.AbstractLevel=In().AbstractLevel;Rt.AbstractSublevel=In().AbstractSublevel;Rt.AbstractIterator=wt().AbstractIterator;Rt.AbstractKeyIterator=wt().AbstractKeyIterator;Rt.AbstractValueIterator=wt().AbstractValueIterator;Rt.AbstractChainedBatch=xn().AbstractChainedBatch});var xo=x((Ha,go)=>{go.exports=iu;var nu=bn();function iu(n,t,e){if(typeof t!="number")throw new Error("second argument must be a Number");let r,i,o,s,c,u=!0,a;Array.isArray(n)?(r=[],o=i=n.length):(s=Object.keys(n),r={},o=i=s.length);function h(l){function p(){e&&e(l,r),e=null}u?nu(p):p()}function f(l,p,y){if(r[l]=y,p&&(c=!0),--o===0||p)h(p);else if(!c&&a<i){let g;s?(g=s[a],a+=1,n[g](function(N,A){f(g,N,A)})):(g=a,a+=1,n[g](function(N,A){f(g,N,A)}))}}a=t,o?s?s.some(function(l,p){return n[l](function(y,g){f(l,y,g)}),p===t-1}):n.some(function(l,p){return l(function(y,g){f(p,y,g)}),p===t-1}):h(null),u=!1}});var Un=x((Wa,vo)=>{"use strict";vo.exports=function(t){let e=t.gte!==void 0?t.gte:t.gt!==void 0?t.gt:void 0,r=t.lte!==void 0?t.lte:t.lt!==void 0?t.lt:void 0,i=t.gte===void 0,o=t.lte===void 0;return e!==void 0&&r!==void 0?IDBKeyRange.bound(e,r,i,o):e!==void 0?IDBKeyRange.lowerBound(e,i):r!==void 0?IDBKeyRange.upperBound(r,o):null}});var Pn=x((za,bo)=>{"use strict";var ou=new TextEncoder;bo.exports=function(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):ou.encode(n)}});var Bo=x(_o=>{"use strict";var{AbstractIterator:su}=Cn(),Eo=Un(),lr=Pn(),Q=Symbol("cache"),ct=Symbol("finished"),U=Symbol("options"),ut=Symbol("currentOptions"),Vt=Symbol("position"),Dn=Symbol("location"),se=Symbol("first"),To={},Ln=class extends su{constructor(t,e,r){super(t,r),this[Q]=[],this[ct]=this.limit===0,this[U]=r,this[ut]={...r},this[Vt]=void 0,this[Dn]=e,this[se]=!0}_nextv(t,e,r){if(this[se]=!1,this[ct])return this.nextTick(r,null,[]);if(this[Q].length>0)return t=Math.min(t,this[Q].length),this.nextTick(r,null,this[Q].splice(0,t));this[Vt]!==void 0&&(this[U].reverse?(this[ut].lt=this[Vt],this[ut].lte=void 0):(this[ut].gt=this[Vt],this[ut].gte=void 0));let i;try{i=Eo(this[ut])}catch{return this[ct]=!0,this.nextTick(r,null,[])}let o=this.db.db.transaction([this[Dn]],"readonly"),s=o.objectStore(this[Dn]),c=[];if(this[U].reverse){let u=!this[U].values&&s.openKeyCursor?"openKeyCursor":"openCursor";s[u](i,"prev").onsuccess=a=>{let h=a.target.result;if(h){let{key:f,value:l}=h;this[Vt]=f,c.push([this[U].keys&&f!==void 0?lr(f):void 0,this[U].values&&l!==void 0?lr(l):void 0]),c.length<t?h.continue():Ao(o)}else this[ct]=!0}}else{let u,a,h=()=>{if(u===void 0||a===void 0)return;let f=Math.max(u.length,a.length);f===0||t===1/0?this[ct]=!0:this[Vt]=u[f-1],c.length=f;for(let l=0;l<f;l++){let p=u[l],y=a[l];c[l]=[this[U].keys&&p!==void 0?lr(p):void 0,this[U].values&&y!==void 0?lr(y):void 0]}Ao(o)};this[U].keys||t<1/0?s.getAllKeys(i,t<1/0?t:void 0).onsuccess=f=>{u=f.target.result,h()}:(u=[],this.nextTick(h)),this[U].values?s.getAll(i,t<1/0?t:void 0).onsuccess=f=>{a=f.target.result,h()}:(a=[],this.nextTick(h))}o.onabort=()=>{r(o.error||new Error("aborted by user")),r=null},o.oncomplete=()=>{r(null,c),r=null}}_next(t){if(this[Q].length>0){let[e,r]=this[Q].shift();this.nextTick(t,null,e,r)}else if(this[ct])this.nextTick(t);else{let e=Math.min(100,this.limit-this.count);this[se]&&(this[se]=!1,e=1),this._nextv(e,To,(r,i)=>{if(r)return t(r);this[Q]=i,this._next(t)})}}_all(t,e){this[se]=!1;let r=this[Q].splice(0,this[Q].length),i=this.limit-this.count-r.length;if(i<=0)return this.nextTick(e,null,r);this._nextv(i,To,(o,s)=>{if(o)return e(o);r.length>0&&(s=r.concat(s)),e(null,s)})}_seek(t,e){this[se]=!0,this[Q]=[],this[ct]=!1,this[Vt]=void 0,this[ut]={...this[U]};let r;try{r=Eo(this[U])}catch{this[ct]=!0;return}r!==null&&!r.includes(t)?this[ct]=!0:this[U].reverse?this[ut].lte=t:this[ut].gte=t}};_o.Iterator=Ln;function Ao(n){typeof n.commit=="function"&&n.commit()}});var So=x((Ya,Ko)=>{"use strict";Ko.exports=function(t,e,r,i,o){if(i.limit===0)return t.nextTick(o);let s=t.db.transaction([e],"readwrite"),c=s.objectStore(e),u=0;s.oncomplete=function(){o()},s.onabort=function(){o(s.error||new Error("aborted by user"))};let a=c.openKeyCursor?"openKeyCursor":"openCursor",h=i.reverse?"prev":"next";c[a](r,h).onsuccess=function(f){let l=f.target.result;l&&(c.delete(l.key).onsuccess=function(){(i.limit<=0||++u<i.limit)&&l.continue()})}}});var Po=x(Uo=>{"use strict";var{AbstractLevel:cu}=Cn(),ko=V(),uu=xo(),{fromCallback:au}=ge(),{Iterator:fu}=Bo(),Oo=Pn(),hu=So(),du=Un(),Co="level-js-",Ce=Symbol("idb"),Mn=Symbol("namePrefix"),at=Symbol("location"),Fn=Symbol("version"),jt=Symbol("store"),Ue=Symbol("onComplete"),Io=Symbol("promise"),pr=class extends cu{constructor(t,e,r){if(typeof e=="function"||typeof r=="function")throw new ko("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});let{prefix:i,version:o,...s}=e||{};if(super({encodings:{view:!0},snapshots:!1,createIfMissing:!1,errorIfExists:!1,seek:!0},s),typeof t!="string")throw new Error("constructor requires a location string argument");this[at]=t,this[Mn]=i??Co,this[Fn]=parseInt(o||1,10),this[Ce]=null}get location(){return this[at]}get namePrefix(){return this[Mn]}get version(){return this[Fn]}get db(){return this[Ce]}get type(){return"browser-level"}_open(t,e){let r=indexedDB.open(this[Mn]+this[at],this[Fn]);r.onerror=function(){e(r.error||new Error("unknown error"))},r.onsuccess=()=>{this[Ce]=r.result,e()},r.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[at])||o.createObjectStore(this[at])}}[jt](t){return this[Ce].transaction([this[at]],t).objectStore(this[at])}[Ue](t,e){let r=t.transaction;r.onabort=function(){e(r.error||new Error("aborted by user"))},r.oncomplete=function(){e(null,t.result)}}_get(t,e,r){let i=this[jt]("readonly"),o;try{o=i.get(t)}catch(s){return this.nextTick(r,s)}this[Ue](o,function(s,c){if(s)return r(s);if(c===void 0)return r(new ko("Entry not found",{code:"LEVEL_NOT_FOUND"}));r(null,Oo(c))})}_getMany(t,e,r){let i=this[jt]("readonly"),o=t.map(s=>c=>{let u;try{u=i.get(s)}catch(a){return c(a)}u.onsuccess=()=>{let a=u.result;c(null,a===void 0?a:Oo(a))},u.onerror=a=>{a.stopPropagation(),c(u.error)}});uu(o,16,r)}_del(t,e,r){let i=this[jt]("readwrite"),o;try{o=i.delete(t)}catch(s){return this.nextTick(r,s)}this[Ue](o,r)}_put(t,e,r,i){let o=this[jt]("readwrite"),s;try{s=o.put(e,t)}catch(c){return this.nextTick(i,c)}this[Ue](s,i)}_iterator(t){return new fu(this,this[at],t)}_batch(t,e,r){let i=this[jt]("readwrite"),o=i.transaction,s=0,c;o.onabort=function(){r(c||o.error||new Error("aborted by user"))},o.oncomplete=function(){r()};function u(){let a=t[s++],h=a.key,f;try{f=a.type==="del"?i.delete(h):i.put(a.value,h)}catch(l){c=l,o.abort();return}s<t.length?f.onsuccess=u:typeof o.commit=="function"&&o.commit()}u()}_clear(t,e){let r,i;try{r=du(t)}catch{return this.nextTick(e)}if(t.limit>=0)return hu(this,this[at],r,t,e);try{let o=this[jt]("readwrite");i=r?o.delete(r):o.clear()}catch(o){return this.nextTick(e,o)}this[Ue](i,e)}_close(t){this[Ce].close(),this.nextTick(t)}};pr.destroy=function(n,t,e){typeof t=="function"&&(e=t,t=Co),e=au(e,Io);let r=indexedDB.deleteDatabase(t+n);return r.onsuccess=function(){e()},r.onerror=function(i){e(i)},e[Io]};Uo.BrowserLevel=pr});var Lo=x(Do=>{Do.Level=Po().BrowserLevel});var $t;(function(n){n.AlgorithmNotSupported="algorithmNotSupported",n.EncodingError="encodingError",n.InvalidJwe="invalidJwe",n.InvalidJwk="invalidJwk",n.OperationNotSupported="operationNotSupported"})($t||($t={}));var rs=Hn(zn(),1);var _u=new Uint8Array(0);function Xn(n,t){if(n===t)return!0;if(n.byteLength!==t.byteLength)return!1;for(let e=0;e<n.byteLength;e++)if(n[e]!==t[e])return!1;return!0}function qt(n){if(n instanceof Uint8Array&&n.constructor.name==="Uint8Array")return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")}function is(n,t){if(n.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var i=0;i<n.length;i++){var o=n.charAt(i),s=o.charCodeAt(0);if(e[s]!==255)throw new TypeError(o+" is ambiguous");e[s]=i}var c=n.length,u=n.charAt(0),a=Math.log(c)/Math.log(256),h=Math.log(256)/Math.log(c);function f(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var g=0,N=0,A=0,J=y.length;A!==J&&y[A]===0;)A++,g++;for(var G=(J-A)*h+1>>>0,D=new Uint8Array(G);A!==J;){for(var H=y[A],ft=0,R=G-1;(H!==0||ft<N)&&R!==-1;R--,ft++)H+=256*D[R]>>>0,D[R]=H%c>>>0,H=H/c>>>0;if(H!==0)throw new Error("Non-zero carry");N=ft,A++}for(var tt=G-N;tt!==G&&D[tt]===0;)tt++;for(var De=u.repeat(g);tt<G;++tt)De+=n.charAt(D[tt]);return De}function l(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;var g=0;if(y[g]!==" "){for(var N=0,A=0;y[g]===u;)N++,g++;for(var J=(y.length-g)*a+1>>>0,G=new Uint8Array(J);y[g];){var D=e[y.charCodeAt(g)];if(D===255)return;for(var H=0,ft=J-1;(D!==0||H<A)&&ft!==-1;ft--,H++)D+=c*G[ft]>>>0,G[ft]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");A=H,g++}if(y[g]!==" "){for(var R=J-A;R!==J&&G[R]===0;)R++;for(var tt=new Uint8Array(N+(J-R)),De=N;R!==J;)tt[De++]=G[R++];return tt}}}function p(y){var g=l(y);if(g)return g;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:l,decode:p}}var os=is,ss=os,Yn=ss;var Ar=class{name;prefix;baseEncode;constructor(t,e,r){this.name=t,this.prefix=e,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},_r=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,r){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=r}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Zn(this,t)}},Br=class{decoders;constructor(t){this.decoders=t}or(t){return Zn(this,t)}decode(t){let e=t[0],r=this.decoders[e];if(r!=null)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Zn(n,t){return new Br({...n.decoders??{[n.prefix]:n},...t.decoders??{[t.prefix]:t}})}var Kr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,r,i){this.name=t,this.prefix=e,this.baseEncode=r,this.baseDecode=i,this.encoder=new Ar(t,e,r),this.decoder=new _r(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Qn({name:n,prefix:t,encode:e,decode:r}){return new Kr(n,t,e,r)}function Sr({name:n,prefix:t,alphabet:e}){let{encode:r,decode:i}=Yn(e,n);return Qn({prefix:t,name:n,encode:r,decode:o=>qt(i(o))})}function cs(n,t,e,r){let i={};for(let h=0;h<t.length;++h)i[t[h]]=h;let o=n.length;for(;n[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),c=0,u=0,a=0;for(let h=0;h<o;++h){let f=i[n[h]];if(f===void 0)throw new SyntaxError(`Non-${r} character`);u=u<<e|f,c+=e,c>=8&&(c-=8,s[a++]=255&u>>c)}if(c>=e||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s}function us(n,t,e){let r=t[t.length-1]==="=",i=(1<<e)-1,o="",s=0,c=0;for(let u=0;u<n.length;++u)for(c=c<<8|n[u],s+=8;s>e;)s-=e,o+=t[i&c>>s];if(s!==0&&(o+=t[i&c<<e-s]),r)for(;o.length*e&7;)o+="=";return o}function _({name:n,prefix:t,bitsPerChar:e,alphabet:r}){return Qn({prefix:t,name:n,encode(i){return us(i,r,e)},decode(i){return cs(i,r,e,n)}})}var ce=_({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Iu=_({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Cu=_({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Uu=_({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Pu=_({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Du=_({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Lu=_({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Mu=_({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),kr=_({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var K=Sr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ru=Sr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var $u=_({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qu=_({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),W=_({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ju=_({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function ti(n){return n.byteOffset!==0||n.byteLength!==n.buffer.byteLength}function ei(n){return typeof n!="object"||n===null?!1:typeof n[Symbol.asyncIterator]=="function"}function Me(n){let e=Object.prototype.toString.call(n).match(/\s([a-zA-Z0-9]+)/),[r,i]=e;return i}var ue=function(n,t,e,r){function i(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function c(h){try{a(r.next(h))}catch(f){s(f)}}function u(h){try{a(r.throw(h))}catch(f){s(f)}}function a(h){h.done?o(h.value):i(h.value).then(c,u)}a((r=r.apply(n,t||[])).next())})},ri=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=n[Symbol.asyncIterator],e;return t?t.call(n):(n=typeof __values=="function"?__values(n):n[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(o){e[o]=n[o]&&function(s){return new Promise(function(c,u){s=n[o](s),i(c,u,s.done,s.value)})}}function i(o,s,c,u){Promise.resolve(u).then(function(a){o({value:a,done:c})},s)}},Fe=new TextEncoder,At=new TextDecoder,v=class n{constructor(t,e){this.data=t,this.format=e}static arrayBuffer(t){return new n(t,"ArrayBuffer")}static asyncIterable(t){if(!ei(t))throw new TypeError("Input must be of type AsyncIterable.");return new n(t,"AsyncIterable")}static base32Z(t){return new n(t,"Base32Z")}static base58Btc(t){return new n(t,"Base58Btc")}static base64Url(t){return new n(t,"Base64Url")}static bufferSource(t){return new n(t,"BufferSource")}static hex(t){if(typeof t!="string")throw new TypeError("Hex input must be a string.");if(t.length%2!==0)throw new TypeError("Hex input must have an even number of characters.");return new n(t,"Hex")}static multibase(t){return new n(t,"Multibase")}static object(t){return new n(t,"Object")}static string(t){return new n(t,"String")}static uint8Array(t){return new n(t,"Uint8Array")}toArrayBuffer(){switch(this.format){case"Base58Btc":return K.baseDecode(this.data).buffer;case"Base64Url":return W.baseDecode(this.data).buffer;case"BufferSource":{if(Me(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return ti(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 ue(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 kr.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Z is not supported.`)}}toBase58Btc(){switch(this.format){case"ArrayBuffer":{let t=new Uint8Array(this.data);return K.baseEncode(t)}case"Multibase":return this.data.substring(1);case"Uint8Array":return K.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base58Btc is not supported.`)}}toBase64Url(){switch(this.format){case"ArrayBuffer":{let t=new Uint8Array(this.data);return W.baseEncode(t)}case"BufferSource":{let t=this.toUint8Array();return W.baseEncode(t)}case"Object":{let t=JSON.stringify(this.data),e=Fe.encode(t);return W.baseEncode(e)}case"String":{let t=Fe.encode(this.data);return W.baseEncode(t)}case"Uint8Array":return W.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return ue(this,void 0,void 0,function*(){var t,e,r,i;switch(this.format){case"AsyncIterable":{let u=[];try{for(var o=!0,s=ri(this.data),c;c=yield s.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let h=i;u.push(h)}}catch(h){e={error:h}}finally{try{!o&&!t&&(r=s.return)&&(yield r.call(s))}finally{if(e)throw e.error}}return new Blob(u)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Blob is not supported.`)}})}toHex(){let t=Array.from({length:256},(e,r)=>r.toString(16).padStart(2,"0"));switch(this.format){case"ArrayBuffer":{let e=this.toUint8Array();return n.uint8Array(e).toHex()}case"Base64Url":{let e=this.toUint8Array();return n.uint8Array(e).toHex()}case"Uint8Array":{let e="";for(let r=0;r<this.data.length;r++)e+=t[this.data[r]];return e}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 t=W.baseDecode(this.data),e=At.decode(t);return JSON.parse(e)}case"String":return JSON.parse(this.data);case"Uint8Array":{let t=At.decode(this.data);return JSON.parse(t)}default:throw new TypeError(`Conversion from ${this.format} to Object is not supported.`)}}toObjectAsync(){return ue(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let t=yield this.toStringAsync();return JSON.parse(t)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Object is not supported.`)}})}toString(){switch(this.format){case"ArrayBuffer":return At.decode(this.data);case"Base64Url":{let t=W.baseDecode(this.data);return At.decode(t)}case"Object":return JSON.stringify(this.data);case"Uint8Array":return At.decode(this.data);default:throw new TypeError(`Conversion from ${this.format} to String is not supported.`)}}toStringAsync(){return ue(this,void 0,void 0,function*(){var t,e,r,i;switch(this.format){case"AsyncIterable":{let u="";try{for(var o=!0,s=ri(this.data),c;c=yield s.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let a=i;typeof a=="string"?u+=a:u+=At.decode(a,{stream:!0})}}catch(a){e={error:a}}finally{try{!o&&!t&&(r=s.return)&&(yield r.call(s))}finally{if(e)throw e.error}}return u+=At.decode(void 0,{stream:!1}),u}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 kr.baseDecode(this.data);case"Base58Btc":return K.baseDecode(this.data);case"Base64Url":return W.baseDecode(this.data);case"BufferSource":{let t=Me(this.data);if(t==="Uint8Array")return this.data;if(t==="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 t=new Uint8Array(this.data.length/2);for(let e=0;e<this.data.length;e+=2){let r=parseInt(this.data.substring(e,e+2),16);if(isNaN(r))throw new TypeError("Input is not a valid hexadecimal string.");t[e/2]=r}return t}case"Object":{let t=JSON.stringify(this.data);return Fe.encode(t)}case"String":return Fe.encode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Uint8Array is not supported.`)}}toUint8ArrayAsync(){return ue(this,void 0,void 0,function*(){switch(this.format){case"AsyncIterable":{let t=yield this.toArrayBufferAsync();return new Uint8Array(t)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Uint8Array is not supported.`)}})}};var ae;(function(n){n.Debug="debug",n.Silent="silent"})(ae||(ae={}));var Or=class{constructor(){this.logLevel=ae.Silent}setLogLevel(t){this.logLevel=t}log(t){this.info(t)}info(t){this.logLevel!==ae.Silent&&console.info(t)}error(t){this.logLevel!==ae.Silent&&console.error(t)}},as=new Or;typeof window<"u"&&(window.web5logger=as);var et={};Zo(et,{decode:()=>Jt,encodeTo:()=>_t,encodingLength:()=>Bt});var fs=oi,ni=128,hs=127,ds=~hs,ls=Math.pow(2,31);function oi(n,t,e){t=t||[],e=e||0;for(var r=e;n>=ls;)t[e++]=n&255|ni,n/=128;for(;n&ds;)t[e++]=n&255|ni,n>>>=7;return t[e]=n|0,oi.bytes=e-r+1,t}var ps=Ir,ys=128,ii=127;function Ir(n,r){var e=0,r=r||0,i=0,o=r,s,c=n.length;do{if(o>=c)throw Ir.bytes=0,new RangeError("Could not decode varint");s=n[o++],e+=i<28?(s&ii)<<i:(s&ii)*Math.pow(2,i),i+=7}while(s>=ys);return Ir.bytes=o-r,e}var ms=Math.pow(2,7),ws=Math.pow(2,14),gs=Math.pow(2,21),xs=Math.pow(2,28),vs=Math.pow(2,35),bs=Math.pow(2,42),Es=Math.pow(2,49),Ts=Math.pow(2,56),As=Math.pow(2,63),_s=function(n){return n<ms?1:n<ws?2:n<gs?3:n<xs?4:n<vs?5:n<bs?6:n<Es?7:n<Ts?8:n<As?9:10},Bs={encode:fs,decode:ps,encodingLength:_s},Ks=Bs,fe=Ks;function Jt(n,t=0){return[fe.decode(n,t),fe.decode.bytes]}function _t(n,t,e=0){return fe.encode(n,t,e),t}function Bt(n){return fe.encodingLength(n)}function Cr(n,t){let e=t.byteLength,r=Bt(n),i=r+Bt(e),o=new Uint8Array(i+e);return _t(n,o,0),_t(e,o,r),o.set(t,i),new Gt(n,e,t,o)}function si(n){let t=qt(n),[e,r]=Jt(t),[i,o]=Jt(t.subarray(r)),s=t.subarray(r+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Gt(e,i,s,t)}function ci(n,t){if(n===t)return!0;{let e=t;return n.code===e.code&&n.size===e.size&&e.bytes instanceof Uint8Array&&Xn(n.bytes,e.bytes)}}var Gt=class{code;size;digest;bytes;constructor(t,e,r,i){this.code=t,this.size=e,this.digest=r,this.bytes=i}};function ui(n,t){let{bytes:e,version:r}=n;switch(r){case 0:return ks(e,Pr(n),t??K.encoder);default:return Os(e,Pr(n),t??ce.encoder)}}var ai=new WeakMap;function Pr(n){let t=ai.get(n);if(t==null){let e=new Map;return ai.set(n,e),e}return t}var Dr=class n{code;version;multihash;bytes;"/";constructor(t,e,r,i){this.code=e,this.version=t,this.multihash=r,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:t,multihash:e}=this;if(t!==he)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Is)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return n.createV0(e)}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:t,digest:e}=this.multihash,r=Cr(t,e);return n.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return n.equals(this,t)}static equals(t,e){let r=e;return r!=null&&t.code===r.code&&t.version===r.version&&ci(t.multihash,r.multihash)}toString(t){return ui(this,t)}toJSON(){return{"/":ui(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof n)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:r,code:i,multihash:o,bytes:s}=e;return new n(r,i,o,s??fi(r,i,o.bytes))}else if(e[Cs]===!0){let{version:r,multihash:i,code:o}=e,s=si(i);return n.create(r,o,s)}else return null}static create(t,e,r){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==he)throw new Error(`Version 0 CID must use dag-pb (code: ${he}) block encoding`);return new n(t,e,r,r.bytes)}case 1:{let i=fi(t,e,r.bytes);return new n(t,e,r,i)}default:throw new Error("Invalid version")}}static createV0(t){return n.create(0,he,t)}static createV1(t,e){return n.create(1,t,e)}static decode(t){let[e,r]=n.decodeFirst(t);if(r.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=n.inspectBytes(t),r=e.size-e.multihashSize,i=qt(t.subarray(r,r+e.multihashSize));if(i.byteLength!==e.multihashSize)throw new Error("Incorrect length");let o=i.subarray(e.multihashSize-e.digestSize),s=new Gt(e.multihashCode,e.digestSize,o,i);return[e.version===0?n.createV0(s):n.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,r=()=>{let[f,l]=Jt(t.subarray(e));return e+=l,f},i=r(),o=he;if(i===18?(i=0,e=0):o=r(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=e,c=r(),u=r(),a=e+u,h=a-s;return{version:i,codec:o,multihashCode:c,digestSize:u,multihashSize:h,size:a}}static parse(t,e){let[r,i]=Ss(t,e),o=n.decode(i);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Pr(o).set(r,t),o}};function Ss(n,t){switch(n[0]){case"Q":{let e=t??K;return[K.prefix,e.decode(`${K.prefix}${n}`)]}case K.prefix:{let e=t??K;return[K.prefix,e.decode(n)]}case ce.prefix:{let e=t??ce;return[ce.prefix,e.decode(n)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[n[0],t.decode(n)]}}}function ks(n,t,e){let{prefix:r}=e;if(r!==K.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let i=t.get(r);if(i==null){let o=e.encode(n).slice(1);return t.set(r,o),o}else return i}function Os(n,t,e){let{prefix:r}=e,i=t.get(r);if(i==null){let o=e.encode(n);return t.set(r,o),o}else return i}var he=112,Is=18;function fi(n,t,e){let r=Bt(n),i=r+Bt(t),o=new Uint8Array(i+e.byteLength);return _t(n,o,0),_t(t,o,r),o.set(e,i),o}var Cs=Symbol.for("@ipld/js-cid/CID");var O=class n{static addPrefix(t){var e;let{code:r,data:i,name:o}=t;if(!(o?!r:r))throw new Error("Either 'name' or 'code' must be defined, but not both.");if(r=n.codeToName.has(r)?r:n.nameToCode.get(o),r===void 0)throw new Error(`Unsupported multicodec: ${(e=t.name)!==null&&e!==void 0?e:t.code}`);let s=et.encodingLength(r),c=new Uint8Array(s+i.byteLength);return c.set(i,s),et.encodeTo(r,c),c}static getCodeFromData(t){let{prefixedData:e}=t,[r,i]=et.decode(e);return r}static getCodeFromName(t){let{name:e}=t,r=n.nameToCode.get(e);if(r===void 0)throw new Error(`Unsupported multicodec: ${e}`);return r}static getNameFromCode(t){let{code:e}=t,r=n.codeToName.get(e);if(r===void 0)throw new Error(`Unsupported multicodec: ${e}`);return r}static registerCodec(t){n.codeToName.set(t.code,t.name),n.nameToCode.set(t.name,t.code)}static removePrefix(t){let{prefixedData:e}=t,[r,i]=et.decode(e),o=n.codeToName.get(r);if(o===void 0)throw new Error(`Unsupported multicodec: ${r}`);return{code:r,data:e.slice(i),name:o}}};O.codeToName=new Map;O.nameToCode=new Map;O.registerCodec({code:237,name:"ed25519-pub"});O.registerCodec({code:4864,name:"ed25519-priv"});O.registerCodec({code:236,name:"x25519-pub"});O.registerCodec({code:4866,name:"x25519-priv"});O.registerCodec({code:231,name:"secp256k1-pub"});O.registerCodec({code:4865,name:"secp256k1-priv"});function Lr(n){Object.keys(n).forEach(t=>{n[t]===void 0?delete n[t]:typeof n[t]=="object"&&Lr(n[t])})}var lu=Hn(Lo(),1);function pu(n){return n instanceof Uint8Array||n!=null&&typeof n=="object"&&n.constructor.name==="Uint8Array"}function Nn(n,...t){if(!pu(n))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(n.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${n.length}`)}function Rn(n,t=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(t&&n.finished)throw new Error("Hash#digest() has already been called")}function Mo(n,t){Nn(n);let e=t.outputLen;if(n.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var mr=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),q=(n,t)=>n<<32-t|n>>>t;var mf=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function yu(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function Vn(n){return typeof n=="string"&&(n=yu(n)),Nn(n),n}var yr=class{clone(){return this._cloneInto()}},wf={}.toString;function Fo(n){let t=r=>n().update(Vn(r)).digest(),e=n();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>n(),t}function mu(n,t,e,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(t,e,r);let i=BigInt(32),o=BigInt(4294967295),s=Number(e>>i&o),c=Number(e&o),u=r?4:0,a=r?0:4;n.setUint32(t+u,s,r),n.setUint32(t+a,c,r)}var No=(n,t,e)=>n&t^~n&e,Ro=(n,t,e)=>n&t^n&e^t&e,wr=class extends yr{constructor(t,e,r,i){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=mr(this.buffer)}update(t){Rn(this);let{view:e,buffer:r,blockLen:i}=this;t=Vn(t);let o=t.length;for(let s=0;s<o;){let c=Math.min(i-this.pos,o-s);if(c===i){let u=mr(t);for(;i<=o-s;s+=i)this.process(u,s);continue}r.set(t.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Rn(this),Mo(t,this),this.finished=!0;let{buffer:e,view:r,blockLen:i,isLE:o}=this,{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(r,0),s=0);for(let f=s;f<i;f++)e[f]=0;mu(r,i-8,BigInt(this.length*8),o),this.process(r,0);let c=mr(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let a=u/4,h=this.get();if(a>h.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<a;f++)c.setUint32(4*f,h[f],o)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:r,length:i,finished:o,destroyed:s,pos:c}=this;return t.length=i,t.pos=c,t.finished=o,t.destroyed=s,i%e&&t.buffer.set(r),t}};var wu=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]),bt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Et=new Uint32Array(64),jn=class extends wr{constructor(){super(64,32,8,!1),this.A=bt[0]|0,this.B=bt[1]|0,this.C=bt[2]|0,this.D=bt[3]|0,this.E=bt[4]|0,this.F=bt[5]|0,this.G=bt[6]|0,this.H=bt[7]|0}get(){let{A:t,B:e,C:r,D:i,E:o,F:s,G:c,H:u}=this;return[t,e,r,i,o,s,c,u]}set(t,e,r,i,o,s,c,u){this.A=t|0,this.B=e|0,this.C=r|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=c|0,this.H=u|0}process(t,e){for(let f=0;f<16;f++,e+=4)Et[f]=t.getUint32(e,!1);for(let f=16;f<64;f++){let l=Et[f-15],p=Et[f-2],y=q(l,7)^q(l,18)^l>>>3,g=q(p,17)^q(p,19)^p>>>10;Et[f]=g+Et[f-7]+y+Et[f-16]|0}let{A:r,B:i,C:o,D:s,E:c,F:u,G:a,H:h}=this;for(let f=0;f<64;f++){let l=q(c,6)^q(c,11)^q(c,25),p=h+l+No(c,u,a)+wu[f]+Et[f]|0,g=(q(r,2)^q(r,13)^q(r,22))+Ro(r,i,o)|0;h=a,a=u,u=c,c=s+p|0,s=o,o=i,i=r,r=p+g|0}r=r+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,c=c+this.E|0,u=u+this.F|0,a=a+this.G|0,h=h+this.H|0,this.set(r,i,o,s,c,u,a,h)}roundClean(){Et.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Vo=Fo(()=>new jn);function jo(n){let t=r=>{if(r!==null&&typeof r=="object"&&!Array.isArray(r)){let i=Object.keys(r).sort(),o={};for(let s of i)o[s]=t(r[s]);return o}return r},e=t(n);return JSON.stringify(e)}var gu=function(n,t,e,r){function i(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function c(h){try{a(r.next(h))}catch(f){s(f)}}function u(h){try{a(r.throw(h))}catch(f){s(f)}}function a(h){h.done?o(h.value):i(h.value).then(c,u)}a((r=r.apply(n,t||[])).next())})},Pe=class{static digest(t){return gu(this,arguments,void 0,function*({data:e}){return Vo(e)})}};var xu=function(n,t,e,r){function i(o){return o instanceof e?o:new e(function(s){s(o)})}return new(e||(e=Promise))(function(o,s){function c(h){try{a(r.next(h))}catch(f){s(f)}}function u(h){try{a(r.throw(h))}catch(f){s(f)}}function a(h){h.done?o(h.value):i(h.value).then(c,u)}a((r=r.apply(n,t||[])).next())})};function P(n){return xu(this,arguments,void 0,function*({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}`);Lr(r);let i=jo(r),o=v.string(i).toUint8Array(),s=yield Pe.digest({data:o});return v.uint8Array(s).toBase64Url()})}var xr=(o=>(o.authentication="authentication",o.assertionMethod="assertionMethod",o.keyAgreement="keyAgreement",o.capabilityInvocation="capabilityInvocation",o.capabilityDelegation="capabilityDelegation",o))(xr||{});var vr=class n extends Error{constructor(e,r){super(`${e}: ${r}`);this.code=e;this.name="DidError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,n)}};function Jn(n){if(typeof n=="string"&&n.length!==0)return n.split("#").pop()}function rl({didDocument:n,id:t,type:e}){return n?.service?.filter(r=>!(t&&r.id!==t||e&&r.type!==e))??[]}async function nl({didDocument:n,publicKeyJwk:t,publicKeyMultibase:e}){let r=Go({didDocument:n});for(let i of r)if(t&&i.publicKeyJwk){if(await P({jwk:t})===await P({jwk:i.publicKeyJwk}))return i}else if(e&&i.publicKeyMultibase&&e===i.publicKeyMultibase)return i;return null}function Go({didDocument:n}){if(!n)throw new TypeError("Required parameter missing: 'didDocument'");let t=[];return t.push(...n.verificationMethod?.filter(Gn)??[]),Object.keys(xr).forEach(e=>{t.push(...n[e]?.filter(Gn)??[])}),t}function il({didDocument:n}){let e=Go({didDocument:n}).map(r=>r.type);return[...new Set(e)]}function ol({didDocument:n,methodId:t}){let e=[];return Object.keys(xr).forEach(r=>{if(Array.isArray(n[r])){let i=n[r],o=Jn(t);i.some(c=>{let u=Jn(c)===o,a=Gn(c)&&Jn(c.id)===o;return u||a})&&e.push(r)}}),e}function vu(n){return!n||typeof n!="object"||n===null?!1:"id"in n&&"type"in n&&"serviceEndpoint"in n}function sl(n){if(!vu(n)||n.type!=="DecentralizedWebNode"||!("enc"in n&&"sig"in n))return!1;let t=e=>typeof e=="string"||Array.isArray(e)&&e.every(r=>typeof r=="string");return t(n.enc)&&t(n.sig)}function Gn(n){return!(!n||typeof n!="object"||n===null||!("id"in n&&"type"in n&&"controller"in n)||typeof n.id!="string"||typeof n.type!="string"||typeof n.controller!="string")}function cl(n){return!(!n||typeof n!="object"||n===null)&&"uri"in n&&"document"in n&&"metadata"in n&&(!("keyManager"in n)||n.keyManager===void 0)}function ul({keyBytes:n,multicodecCode:t,multicodecName:e}){let r=O.addPrefix({code:t,data:n,name:e}),i=v.uint8Array(r).toBase58Btc();return v.base58Btc(i).toMultibase()}function al({multibaseKeyId:n}){try{let t=v.multibase(n).toBase58Btc(),e=v.base58Btc(t).toUint8Array(),{code:r,data:i,name:o}=O.removePrefix({prefixedData:e});return{keyBytes:i,multicodecCode:r,multicodecName:o}}catch{throw new vr("invalidDid",`Invalid multibase identifier: ${n}`)}}export{Jn as extractDidFragment,rl as getServices,nl as getVerificationMethodByKey,il as getVerificationMethodTypes,Go as getVerificationMethods,ol as getVerificationRelationshipsById,vu as isDidService,Gn as isDidVerificationMethod,sl as isDwnDidService,cl as isPortableDid,ul as keyBytesToMultibaseId,al as multibaseIdToKeyBytes};
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
ieee754/index.js:
|