@enbox/dids 0.0.8 → 0.0.9

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/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- var tu=Object.create;var hn=Object.defineProperty;var ru=Object.getOwnPropertyDescriptor;var nu=Object.getOwnPropertyNames;var iu=Object.getPrototypeOf,ou=Object.prototype.hasOwnProperty;var E=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),su=(r,e)=>{for(var t in e)hn(r,t,{get:e[t],enumerable:!0})},cu=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of nu(e))!ou.call(r,i)&&i!==t&&hn(r,i,{get:()=>e[i],enumerable:!(n=ru(e,i))||n.enumerable});return r};var Ji=(r,e,t)=>(t=r!=null?tu(iu(r)):{},cu(e||!r||!r.__esModule?hn(t,"default",{value:r,enumerable:!0}):t,r));var zi=E((sd,Gi)=>{var uu=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,lr=()=>uu.now(),au=r=>r&&r===Math.floor(r)&&r>0&&isFinite(r),ln=r=>r===1/0||au(r),pn=class r{constructor({max:e=1/0,ttl:t,updateAgeOnGet:n=!1,checkAgeOnGet:i=!1,noUpdateTTL:o=!1,dispose:s,noDisposeOnSet:c=!1}={}){if(this.expirations=Object.create(null),this.data=new Map,this.expirationMap=new Map,t!==void 0&&!ln(t))throw new TypeError("ttl must be positive integer or Infinity if set");if(!ln(e))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=t,this.max=e,this.updateAgeOnGet=!!n,this.checkAgeOnGet=!!i,this.noUpdateTTL=!!o,this.noDisposeOnSet=!!c,s!==void 0){if(typeof s!="function")throw new TypeError("dispose must be function if set");this.dispose=s}this.timer=void 0,this.timerExpiration=void 0}setTimer(e,t){if(this.timerExpiration<e)return;this.timer&&clearTimeout(this.timer);let n=setTimeout(()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let i in this.expirations){this.setTimer(i,i-lr());break}},t);n.unref&&n.unref(),this.timerExpiration=e,this.timer=n}cancelTimer(){this.timer&&(clearTimeout(this.timer),this.timerExpiration=void 0,this.timer=void 0)}cancelTimers(){return process.emitWarning('TTLCache.cancelTimers has been renamed to TTLCache.cancelTimer (no "s"), and will be removed in the next major version update'),this.cancelTimer()}clear(){let e=this.dispose!==r.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(let[t,n]of e)this.dispose(n,t,"delete")}setTTL(e,t=this.ttl){let n=this.expirationMap.get(e);if(n!==void 0){let i=this.expirations[n];!i||i.length<=1?delete this.expirations[n]:this.expirations[n]=i.filter(o=>o!==e)}if(t!==1/0){let i=Math.floor(lr()+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:n=this.ttl,noUpdateTTL:i=this.noUpdateTTL,noDisposeOnSet:o=this.noDisposeOnSet}={}){if(!ln(n))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(e)){i||this.setTTL(e,n);let s=this.data.get(e);s!==t&&(this.data.set(e,t),o||this.dispose(s,e,"set"))}else this.setTTL(e,n),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-lr())):0}get(e,{updateAgeOnGet:t=this.updateAgeOnGet,ttl:n=this.ttl,checkAgeOnGet:i=this.checkAgeOnGet}={}){let o=this.data.get(e);if(i&&this.getRemainingTTL(e)===0){this.delete(e);return}return t&&this.setTTL(e,n),o}dispose(e,t){}delete(e){let t=this.expirationMap.get(e);if(t!==void 0){let n=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(n,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 n=[];for(let i of t)n.push([i,this.data.get(i)]),this.data.delete(i),this.expirationMap.delete(i);for(let[i,o]of n)this.dispose(o,i,"evict")}else{let n=this.size-this.max,i=[];for(let o of t.splice(0,n))i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"evict");return}}}get size(){return this.data.size}purgeStale(){let e=Math.ceil(lr());for(let t in this.expirations){if(t==="Infinity"||t>e)return;let n=[...this.expirations[t]||[]],i=[];delete this.expirations[t];for(let o of n)i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"stale")}this.size===0&&this.cancelTimer()}*entries(){for(let e in this.expirations)for(let 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()}};Gi.exports=pn});var ho=E(fo=>{"use strict";fo.supports=function(...e){let t=e.reduce((n,i)=>Object.assign(n,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 re=E((ih,lo)=>{"use strict";lo.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 mo=E(mr=>{"use strict";mr.byteLength=ju;mr.toByteArray=Hu;mr.fromByteArray=zu;var de=[],W=[],Vu=typeof Uint8Array<"u"?Uint8Array:Array,kn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(We=0,po=kn.length;We<po;++We)de[We]=kn[We],W[kn.charCodeAt(We)]=We;var We,po;W[45]=62;W[95]=63;function yo(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function ju(r){var e=yo(r),t=e[0],n=e[1];return(t+n)*3/4-n}function qu(r,e,t){return(e+t)*3/4-t}function Hu(r){var e,t=yo(r),n=t[0],i=t[1],o=new Vu(qu(r,n,i)),s=0,c=i>0?n-4:n,u;for(u=0;u<c;u+=4)e=W[r.charCodeAt(u)]<<18|W[r.charCodeAt(u+1)]<<12|W[r.charCodeAt(u+2)]<<6|W[r.charCodeAt(u+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=W[r.charCodeAt(u)]<<2|W[r.charCodeAt(u+1)]>>4,o[s++]=e&255),i===1&&(e=W[r.charCodeAt(u)]<<10|W[r.charCodeAt(u+1)]<<4|W[r.charCodeAt(u+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function Ju(r){return de[r>>18&63]+de[r>>12&63]+de[r>>6&63]+de[r&63]}function Gu(r,e,t){for(var n,i=[],o=e;o<t;o+=3)n=(r[o]<<16&16711680)+(r[o+1]<<8&65280)+(r[o+2]&255),i.push(Ju(n));return i.join("")}function zu(r){for(var e,t=r.length,n=t%3,i=[],o=16383,s=0,c=t-n;s<c;s+=o)i.push(Gu(r,s,s+o>c?c:s+o));return n===1?(e=r[t-1],i.push(de[e>>2]+de[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(de[e>>10]+de[e>>4&63]+de[e<<2&63]+"=")),i.join("")}});var go=E(In=>{In.read=function(r,e,t,n,i){var o,s,c=i*8-n-1,u=(1<<c)-1,a=u>>1,d=-7,f=t?i-1:0,m=t?-1:1,g=r[e+f];for(f+=m,o=g&(1<<-d)-1,g>>=-d,d+=c;d>0;o=o*256+r[e+f],f+=m,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=n;d>0;s=s*256+r[e+f],f+=m,d-=8);if(o===0)o=1-a;else{if(o===u)return s?NaN:(g?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-a}return(g?-1:1)*s*Math.pow(2,o-n)};In.write=function(r,e,t,n,i,o){var s,c,u,a=o*8-i-1,d=(1<<a)-1,f=d>>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=n?0:o-1,w=n?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=d):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+f>=1?e+=m/u:e+=m*Math.pow(2,1-f),e*u>=2&&(s++,u/=2),s+f>=d?(c=0,s=d):s+f>=1?(c=(e*u-1)*Math.pow(2,i),s=s+f):(c=e*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;r[t+g]=c&255,g+=w,c/=256,i-=8);for(s=s<<i|c,a+=i;a>0;r[t+g]=s&255,g+=w,s/=256,a-=8);r[t+g-w]|=b*128}});var xr=E(wt=>{"use strict";var Un=mo(),mt=go(),wo=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;wt.Buffer=l;wt.SlowBuffer=ea;wt.INSPECT_MAX_BYTES=50;var gr=2147483647;wt.kMaxLength=gr;l.TYPED_ARRAY_SUPPORT=Wu();!l.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 Wu(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}});Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}});function be(r){if(r>gr)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,l.prototype),e}function l(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Pn(r)}return Eo(r,e,t)}l.poolSize=8192;function Eo(r,e,t){if(typeof r=="string")return Yu(r,e);if(ArrayBuffer.isView(r))return Zu(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(he(r,ArrayBuffer)||r&&he(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(he(r,SharedArrayBuffer)||r&&he(r.buffer,SharedArrayBuffer)))return Kn(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return l.from(n,e,t);let i=Qu(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return l.from(r[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 r)}l.from=function(r,e,t){return Eo(r,e,t)};Object.setPrototypeOf(l.prototype,Uint8Array.prototype);Object.setPrototypeOf(l,Uint8Array);function Ao(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function Xu(r,e,t){return Ao(r),r<=0?be(r):e!==void 0?typeof t=="string"?be(r).fill(e,t):be(r).fill(e):be(r)}l.alloc=function(r,e,t){return Xu(r,e,t)};function Pn(r){return Ao(r),be(r<0?0:Dn(r)|0)}l.allocUnsafe=function(r){return Pn(r)};l.allocUnsafeSlow=function(r){return Pn(r)};function Yu(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!l.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=_o(r,e)|0,n=be(t),i=n.write(r,e);return i!==t&&(n=n.slice(0,i)),n}function On(r){let e=r.length<0?0:Dn(r.length)|0,t=be(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function Zu(r){if(he(r,Uint8Array)){let e=new Uint8Array(r);return Kn(e.buffer,e.byteOffset,e.byteLength)}return On(r)}function Kn(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&t===void 0?n=new Uint8Array(r):t===void 0?n=new Uint8Array(r,e):n=new Uint8Array(r,e,t),Object.setPrototypeOf(n,l.prototype),n}function Qu(r){if(l.isBuffer(r)){let e=Dn(r.length)|0,t=be(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||Nn(r.length)?be(0):On(r);if(r.type==="Buffer"&&Array.isArray(r.data))return On(r.data)}function Dn(r){if(r>=gr)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+gr.toString(16)+" bytes");return r|0}function ea(r){return+r!=r&&(r=0),l.alloc(+r)}l.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==l.prototype};l.compare=function(e,t){if(he(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),he(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(e)||!l.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,i=t.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(e[o]!==t[o]){n=e[o],i=t[o];break}return n<i?-1:i<n?1:0};l.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}};l.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return l.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let i=l.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){let s=e[n];if(he(s,Uint8Array))o+s.length>i.length?(l.isBuffer(s)||(s=l.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(l.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function _o(r,e){if(l.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||he(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Cn(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Co(r).length;default:if(i)return n?-1:Cn(r).length;e=(""+e).toLowerCase(),i=!0}}l.byteLength=_o;function ta(r,e,t){let n=!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(r||(r="utf8");;)switch(r){case"hex":return da(this,e,t);case"utf8":case"utf-8":return Bo(this,e,t);case"ascii":return aa(this,e,t);case"latin1":case"binary":return fa(this,e,t);case"base64":return ca(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ha(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}l.prototype._isBuffer=!0;function Xe(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}l.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)Xe(this,t,t+1);return this};l.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)Xe(this,t,t+3),Xe(this,t+1,t+2);return this};l.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)Xe(this,t,t+7),Xe(this,t+1,t+6),Xe(this,t+2,t+5),Xe(this,t+3,t+4);return this};l.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Bo(this,0,e):ta.apply(this,arguments)};l.prototype.toLocaleString=l.prototype.toString;l.prototype.equals=function(e){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:l.compare(this,e)===0};l.prototype.inspect=function(){let e="",t=wt.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};wo&&(l.prototype[wo]=l.prototype.inspect);l.prototype.compare=function(e,t,n,i,o){if(he(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.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),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),t<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&t>=n)return 0;if(i>=o)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let s=o-i,c=n-t,u=Math.min(s,c),a=this.slice(i,o),d=e.slice(t,n);for(let f=0;f<u;++f)if(a[f]!==d[f]){s=a[f],c=d[f];break}return s<c?-1:c<s?1:0};function To(r,e,t,n,i){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Nn(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(i)return-1;t=r.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof e=="string"&&(e=l.from(e,n)),l.isBuffer(e))return e.length===0?-1:xo(r,e,t,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):xo(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}function xo(r,e,t,n,i){let o=1,s=r.length,c=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;o=2,s/=2,c/=2,t/=2}function u(d,f){return o===1?d[f]:d.readUInt16BE(f*o)}let a;if(i){let d=-1;for(a=t;a<s;a++)if(u(r,a)===u(e,d===-1?0:a-d)){if(d===-1&&(d=a),a-d+1===c)return d*o}else d!==-1&&(a-=a-d),d=-1}else for(t+c>s&&(t=s-c),a=t;a>=0;a--){let d=!0;for(let f=0;f<c;f++)if(u(r,a+f)!==u(e,f)){d=!1;break}if(d)return a}return-1}l.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};l.prototype.indexOf=function(e,t,n){return To(this,e,t,n,!0)};l.prototype.lastIndexOf=function(e,t,n){return To(this,e,t,n,!1)};function ra(r,e,t,n){t=Number(t)||0;let i=r.length-t;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let c=parseInt(e.substr(s*2,2),16);if(Nn(c))return s;r[t+s]=c}return s}function na(r,e,t,n){return wr(Cn(e,r.length-t),r,t,n)}function ia(r,e,t,n){return wr(ma(e),r,t,n)}function oa(r,e,t,n){return wr(Co(e),r,t,n)}function sa(r,e,t,n){return wr(ga(e,r.length-t),r,t,n)}l.prototype.write=function(e,t,n,i){if(t===void 0)i="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")i=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<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 ra(this,e,t,n);case"utf8":case"utf-8":return na(this,e,t,n);case"ascii":case"latin1":case"binary":return ia(this,e,t,n);case"base64":return oa(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return sa(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ca(r,e,t){return e===0&&t===r.length?Un.fromByteArray(r):Un.fromByteArray(r.slice(e,t))}function Bo(r,e,t){t=Math.min(r.length,t);let n=[],i=e;for(;i<t;){let o=r[i],s=null,c=o>239?4:o>223?3:o>191?2:1;if(i+c<=t){let u,a,d,f;switch(c){case 1:o<128&&(s=o);break;case 2:u=r[i+1],(u&192)===128&&(f=(o&31)<<6|u&63,f>127&&(s=f));break;case 3:u=r[i+1],a=r[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=r[i+1],a=r[i+2],d=r[i+3],(u&192)===128&&(a&192)===128&&(d&192)===128&&(f=(o&15)<<18|(u&63)<<12|(a&63)<<6|d&63,f>65535&&f<1114112&&(s=f))}}s===null?(s=65533,c=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=c}return ua(n)}var vo=4096;function ua(r){let e=r.length;if(e<=vo)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=vo));return t}function aa(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]&127);return n}function fa(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]);return n}function da(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let i="";for(let o=e;o<t;++o)i+=wa[r[o]];return i}function ha(r,e,t){let n=r.slice(e,t),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}l.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,l.prototype),i};function B(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUintLE=l.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||B(e,t,this.length);let i=this[e],o=1,s=0;for(;++s<t&&(o*=256);)i+=this[e+s]*o;return i};l.prototype.readUintBE=l.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||B(e,t,this.length);let i=this[e+--t],o=1;for(;t>0&&(o*=256);)i+=this[e+--t]*o;return i};l.prototype.readUint8=l.prototype.readUInt8=function(e,t){return e=e>>>0,t||B(e,1,this.length),this[e]};l.prototype.readUint16LE=l.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||B(e,2,this.length),this[e]|this[e+1]<<8};l.prototype.readUint16BE=l.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||B(e,2,this.length),this[e]<<8|this[e+1]};l.prototype.readUint32LE=l.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||B(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};l.prototype.readUint32BE=l.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||B(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};l.prototype.readBigUInt64LE=Oe(function(e){e=e>>>0,gt(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Lt(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+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});l.prototype.readBigUInt64BE=Oe(function(e){e=e>>>0,gt(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Lt(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+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});l.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||B(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};l.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||B(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};l.prototype.readInt8=function(e,t){return e=e>>>0,t||B(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};l.prototype.readInt16LE=function(e,t){e=e>>>0,t||B(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};l.prototype.readInt16BE=function(e,t){e=e>>>0,t||B(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};l.prototype.readInt32LE=function(e,t){return e=e>>>0,t||B(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};l.prototype.readInt32BE=function(e,t){return e=e>>>0,t||B(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};l.prototype.readBigInt64LE=Oe(function(e){e=e>>>0,gt(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Lt(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});l.prototype.readBigInt64BE=Oe(function(e){e=e>>>0,gt(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Lt(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+n)});l.prototype.readFloatLE=function(e,t){return e=e>>>0,t||B(e,4,this.length),mt.read(this,e,!0,23,4)};l.prototype.readFloatBE=function(e,t){return e=e>>>0,t||B(e,4,this.length),mt.read(this,e,!1,23,4)};l.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||B(e,8,this.length),mt.read(this,e,!0,52,8)};l.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||B(e,8,this.length),mt.read(this,e,!1,52,8)};function M(r,e,t,n,i,o){if(!l.isBuffer(r))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+n>r.length)throw new RangeError("Index out of range")}l.prototype.writeUintLE=l.prototype.writeUIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;M(this,e,t,n,c,0)}let o=1,s=0;for(this[t]=e&255;++s<n&&(o*=256);)this[t+s]=e/o&255;return t+n};l.prototype.writeUintBE=l.prototype.writeUIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;M(this,e,t,n,c,0)}let o=n-1,s=1;for(this[t+o]=e&255;--o>=0&&(s*=256);)this[t+o]=e/s&255;return t+n};l.prototype.writeUint8=l.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,255,0),this[t]=e&255,t+1};l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(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};l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(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 So(r,e,t,n,i){Ko(e,n,i,r,t,7);let o=Number(e&BigInt(4294967295));r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,t}function ko(r,e,t,n,i){Ko(e,n,i,r,t,7);let o=Number(e&BigInt(4294967295));r[t+7]=o,o=o>>8,r[t+6]=o,o=o>>8,r[t+5]=o,o=o>>8,r[t+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=s,s=s>>8,r[t+2]=s,s=s>>8,r[t+1]=s,s=s>>8,r[t]=s,t+8}l.prototype.writeBigUInt64LE=Oe(function(e,t=0){return So(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});l.prototype.writeBigUInt64BE=Oe(function(e,t=0){return ko(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});l.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let u=Math.pow(2,8*n-1);M(this,e,t,n,u-1,-u)}let o=0,s=1,c=0;for(this[t]=e&255;++o<n&&(s*=256);)e<0&&c===0&&this[t+o-1]!==0&&(c=1),this[t+o]=(e/s>>0)-c&255;return t+n};l.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let u=Math.pow(2,8*n-1);M(this,e,t,n,u-1,-u)}let o=n-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+n};l.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};l.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};l.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};l.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(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};l.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(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};l.prototype.writeBigInt64LE=Oe(function(e,t=0){return So(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});l.prototype.writeBigInt64BE=Oe(function(e,t=0){return ko(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Io(r,e,t,n,i,o){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Uo(r,e,t,n,i){return e=+e,t=t>>>0,i||Io(r,e,t,4,34028234663852886e22,-34028234663852886e22),mt.write(r,e,t,n,23,4),t+4}l.prototype.writeFloatLE=function(e,t,n){return Uo(this,e,t,!0,n)};l.prototype.writeFloatBE=function(e,t,n){return Uo(this,e,t,!1,n)};function Oo(r,e,t,n,i){return e=+e,t=t>>>0,i||Io(r,e,t,8,17976931348623157e292,-17976931348623157e292),mt.write(r,e,t,n,52,8),t+8}l.prototype.writeDoubleLE=function(e,t,n){return Oo(this,e,t,!0,n)};l.prototype.writeDoubleBE=function(e,t,n){return Oo(this,e,t,!1,n)};l.prototype.copy=function(e,t,n,i){if(!l.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-n&&(i=e.length-t+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),t),o};l.prototype.fill=function(e,t,n,i){if(typeof e=="string"){if(typeof t=="string"?(i=t,t=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!l.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<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=t;o<n;++o)this[o]=e;else{let s=l.isBuffer(e)?e:l.from(e,i),c=s.length;if(c===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-t;++o)this[o+t]=s[o%c]}return this};var yt={};function Mn(r,e,t){yt[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}Mn("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Mn("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);Mn("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=bo(String(t)):typeof t=="bigint"&&(i=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=bo(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function bo(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function la(r,e,t){gt(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&Lt(e,r.length-(t+1))}function Ko(r,e,t,n,i,o){if(r>t||r<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 yt.ERR_OUT_OF_RANGE("value",c,r)}la(n,i,o)}function gt(r,e){if(typeof r!="number")throw new yt.ERR_INVALID_ARG_TYPE(e,"number",r)}function Lt(r,e,t){throw Math.floor(r)!==r?(gt(r,t),new yt.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new yt.ERR_BUFFER_OUT_OF_BOUNDS:new yt.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var pa=/[^+/0-9A-Za-z-_]/g;function ya(r){if(r=r.split("=")[0],r=r.trim().replace(pa,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Cn(r,e){e=e||1/0;let t,n=r.length,i=null,o=[];for(let s=0;s<n;++s){if(t=r.charCodeAt(s),t>55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=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 ma(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function ga(r,e){let t,n,i,o=[];for(let s=0;s<r.length&&!((e-=2)<0);++s)t=r.charCodeAt(s),n=t>>8,i=t%256,o.push(i),o.push(n);return o}function Co(r){return Un.toByteArray(ya(r))}function wr(r,e,t,n){let i;for(i=0;i<n&&!(i+t>=e.length||i>=r.length);++i)e[i+t]=r[i];return i}function he(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function Nn(r){return r!==r}var wa=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let i=0;i<16;++i)e[n+i]=r[t]+r[i]}return e}();function Oe(r){return typeof BigInt>"u"?xa:r}function xa(){throw new Error("BigInt not supported")}});var Fn=E((ah,Po)=>{"use strict";var Ln=null;Po.exports=function(){return Ln===null&&(Ln={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),Ln}});var Vn=E(Do=>{"use strict";var Rn=re(),va=new Set(["buffer","view","utf8"]),$n=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"||!va.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 Rn(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new Rn(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new Rn(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};Do.Encoding=$n});var Jn=E(vr=>{"use strict";var{Buffer:qn}=xr()||{},{Encoding:Hn}=Vn(),ba=Fn(),Ft=class extends Hn{constructor(e){super({...e,format:"buffer"})}createViewTranscoder(){return new Rt({encode:this.encode,decode:e=>this.decode(qn.from(e.buffer,e.byteOffset,e.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},Rt=class extends Hn{constructor(e){super({...e,format:"view"})}createBufferTranscoder(){return new Ft({encode:e=>{let t=this.encode(e);return qn.from(t.buffer,t.byteOffset,t.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},jn=class extends Hn{constructor(e){super({...e,format:"utf8"})}createBufferTranscoder(){return new Ft({encode:e=>qn.from(this.encode(e),"utf8"),decode:e=>this.decode(e.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:e,textDecoder:t}=ba();return new Rt({encode:n=>e.encode(this.encode(n)),decode:n=>this.decode(t.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};vr.BufferFormat=Ft;vr.ViewFormat=Rt;vr.UTF8Format=jn});var Fo=E(Ye=>{"use strict";var{Buffer:I}=xr()||{Buffer:{isBuffer:()=>!1}},{textEncoder:No,textDecoder:Mo}=Fn()(),{BufferFormat:$t,ViewFormat:Gn,UTF8Format:Lo}=Jn(),br=r=>r;Ye.utf8=new Lo({encode:function(r){return I.isBuffer(r)?r.toString("utf8"):ArrayBuffer.isView(r)?Mo.decode(r):String(r)},decode:br,name:"utf8",createViewTranscoder(){return new Gn({encode:function(r){return ArrayBuffer.isView(r)?r:No.encode(r)},decode:function(r){return Mo.decode(r)},name:`${this.name}+view`})},createBufferTranscoder(){return new $t({encode:function(r){return I.isBuffer(r)?r:ArrayBuffer.isView(r)?I.from(r.buffer,r.byteOffset,r.byteLength):I.from(String(r),"utf8")},decode:function(r){return r.toString("utf8")},name:`${this.name}+buffer`})}});Ye.json=new Lo({encode:JSON.stringify,decode:JSON.parse,name:"json"});Ye.buffer=new $t({encode:function(r){return I.isBuffer(r)?r:ArrayBuffer.isView(r)?I.from(r.buffer,r.byteOffset,r.byteLength):I.from(String(r),"utf8")},decode:br,name:"buffer",createViewTranscoder(){return new Gn({encode:function(r){return ArrayBuffer.isView(r)?r:I.from(String(r),"utf8")},decode:function(r){return I.from(r.buffer,r.byteOffset,r.byteLength)},name:`${this.name}+view`})}});Ye.view=new Gn({encode:function(r){return ArrayBuffer.isView(r)?r:No.encode(r)},decode:br,name:"view",createBufferTranscoder(){return new $t({encode:function(r){return I.isBuffer(r)?r:ArrayBuffer.isView(r)?I.from(r.buffer,r.byteOffset,r.byteLength):I.from(String(r),"utf8")},decode:br,name:`${this.name}+buffer`})}});Ye.hex=new $t({encode:function(r){return I.isBuffer(r)?r:I.from(String(r),"hex")},decode:function(r){return r.toString("hex")},name:"hex"});Ye.base64=new $t({encode:function(r){return I.isBuffer(r)?r:I.from(String(r),"base64")},decode:function(r){return r.toString("base64")},name:"base64"})});var Vo=E($o=>{"use strict";var Ro=re(),Ar=Fo(),{Encoding:Ea}=Vn(),{BufferFormat:Aa,ViewFormat:_a,UTF8Format:Ta}=Jn(),Vt=Symbol("formats"),Er=Symbol("encodings"),Ba=new Set(["buffer","view","utf8"]),zn=class{constructor(e){if(Array.isArray(e)){if(!e.every(t=>Ba.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[Er]=new Map,this[Vt]=new Set(e);for(let t in Ar)try{this.encoding(t)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[Er].values()))}encoding(e){let t=this[Er].get(e);if(t===void 0){if(typeof e=="string"&&e!==""){if(t=Ua[e],!t)throw new Ro(`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=Sa(e)}let{name:n,format:i}=t;if(!this[Vt].has(i))if(this[Vt].has("view"))t=t.createViewTranscoder();else if(this[Vt].has("buffer"))t=t.createBufferTranscoder();else if(this[Vt].has("utf8"))t=t.createUTF8Transcoder();else throw new Ro(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[e,n,t.name,t.commonName])this[Er].set(o,t)}return t}};$o.Transcoder=zn;function Sa(r){if(r instanceof Ea)return r;let e="type"in r&&typeof r.type=="string"?r.type:void 0,t=r.name||e||`anonymous-${Oa++}`;switch(ka(r)){case"view":return new _a({...r,name:t});case"utf8":return new Ta({...r,name:t});case"buffer":return new Aa({...r,name:t});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function ka(r){return"format"in r&&r.format!==void 0?r.format:"buffer"in r&&typeof r.buffer=="boolean"?r.buffer?"buffer":"utf8":"code"in r&&Number.isInteger(r.code)?"view":"buffer"}var Ia={binary:Ar.buffer,"utf-8":Ar.utf8},Ua={...Ar,...Ia},Oa=0});var qo=E((ph,Wn)=>{"use strict";var Ka=Object.prototype.hasOwnProperty,P="~";function jt(){}Object.create&&(jt.prototype=Object.create(null),new jt().__proto__||(P=!1));function Ca(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function jo(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var o=new Ca(t,n||r,i),s=P?P+e:e;return r._events[s]?r._events[s].fn?r._events[s]=[r._events[s],o]:r._events[s].push(o):(r._events[s]=o,r._eventsCount++),r}function _r(r,e){--r._eventsCount===0?r._events=new jt:delete r._events[e]}function U(){this._events=new jt,this._eventsCount=0}U.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Ka.call(t,n)&&e.push(P?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};U.prototype.listeners=function(e){var t=P?P+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i<o;i++)s[i]=n[i].fn;return s};U.prototype.listenerCount=function(e){var t=P?P+e:e,n=this._events[t];return n?n.fn?1:n.length:0};U.prototype.emit=function(e,t,n,i,o,s){var c=P?P+e:e;if(!this._events[c])return!1;var u=this._events[c],a=arguments.length,d,f;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),a){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,i),!0;case 5:return u.fn.call(u.context,t,n,i,o),!0;case 6:return u.fn.call(u.context,t,n,i,o,s),!0}for(f=1,d=new Array(a-1);f<a;f++)d[f-1]=arguments[f];u.fn.apply(u.context,d)}else{var m=u.length,g;for(f=0;f<m;f++)switch(u[f].once&&this.removeListener(e,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,t);break;case 3:u[f].fn.call(u[f].context,t,n);break;case 4:u[f].fn.call(u[f].context,t,n,i);break;default:if(!d)for(g=1,d=new Array(a-1);g<a;g++)d[g-1]=arguments[g];u[f].fn.apply(u[f].context,d)}}return!0};U.prototype.on=function(e,t,n){return jo(this,e,t,n,!1)};U.prototype.once=function(e,t,n){return jo(this,e,t,n,!0)};U.prototype.removeListener=function(e,t,n,i){var o=P?P+e:e;if(!this._events[o])return this;if(!t)return _r(this,o),this;var s=this._events[o];if(s.fn)s.fn===t&&(!i||s.once)&&(!n||s.context===n)&&_r(this,o);else{for(var c=0,u=[],a=s.length;c<a;c++)(s[c].fn!==t||i&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[o]=u.length===1?u[0]:u:_r(this,o)}return this};U.prototype.removeAllListeners=function(e){var t;return e?(t=P?P+e:e,this._events[t]&&_r(this,t)):(this._events=new jt,this._eventsCount=0),this};U.prototype.off=U.prototype.removeListener;U.prototype.addListener=U.prototype.on;U.prefixed=P;U.EventEmitter=U;typeof Wn<"u"&&(Wn.exports=U)});var Jo=E((yh,Ho)=>{Ho.exports=typeof queueMicrotask=="function"?queueMicrotask:r=>Promise.resolve().then(r)});var qt=E(Xn=>{"use strict";var Go=Jo();Xn.fromCallback=function(r,e){if(r===void 0){var t=new Promise(function(n,i){r=function(o,s){o?i(o):n(s)}});r[e!==void 0?e:"promise"]=t}else if(typeof r!="function")throw new TypeError("Callback must be a function");return r};Xn.fromPromise=function(r,e){if(e===void 0)return r;r.then(function(t){Go(()=>e(null,t))}).catch(function(t){Go(()=>e(t))})}});var Tr=E(Yn=>{"use strict";Yn.getCallback=function(r,e){return typeof r=="function"?r:e};Yn.getOptions=function(r,e){return typeof r=="object"&&r!==null?r:e!==void 0?e:{}}});var Ne=E(Ir=>{"use strict";var{fromCallback:Zn}=qt(),F=re(),{getOptions:Qn,getCallback:zo}=Tr(),Ze=Symbol("promise"),xt=Symbol("callback"),le=Symbol("working"),Qe=Symbol("handleOne"),Ee=Symbol("handleMany"),ei=Symbol("autoClose"),De=Symbol("finishWork"),pe=Symbol("returnMany"),Ke=Symbol("closing"),Ht=Symbol("handleClose"),Br=Symbol("closed"),Jt=Symbol("closeCallbacks"),Pe=Symbol("keyEncoding"),et=Symbol("valueEncoding"),ti=Symbol("abortOnClose"),Sr=Symbol("legacy"),ri=Symbol("keys"),ni=Symbol("values"),Ce=Symbol("limit"),X=Symbol("count"),kr=Object.freeze({}),Pa=()=>{},Wo=!1,Gt=class{constructor(e,t,n){if(typeof e!="object"||e===null){let i=e===null?"null":typeof e;throw new TypeError(`The first argument must be an abstract-level database, received ${i}`)}if(typeof t!="object"||t===null)throw new TypeError("The second argument must be an options object");this[Br]=!1,this[Jt]=[],this[le]=!1,this[Ke]=!1,this[ei]=!1,this[xt]=null,this[Qe]=this[Qe].bind(this),this[Ee]=this[Ee].bind(this),this[Ht]=this[Ht].bind(this),this[Pe]=t[Pe],this[et]=t[et],this[Sr]=n,this[Ce]=Number.isInteger(t.limit)&&t.limit>=0?t.limit:1/0,this[X]=0,this[ti]=!!t.abortOnClose,this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get count(){return this[X]}get limit(){return this[Ce]}next(e){let t;if(e===void 0)t=new Promise((n,i)=>{e=(o,s,c)=>{o?i(o):this[Sr]?s===void 0&&c===void 0?n():n([s,c]):n(s)}});else if(typeof e!="function")throw new TypeError("Callback must be a function");return this[Ke]?this.nextTick(e,new F("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[le]?this.nextTick(e,new F("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[le]=!0,this[xt]=e,this[X]>=this[Ce]?this.nextTick(this[Qe],null):this._next(this[Qe])),t}_next(e){this.nextTick(e)}nextv(e,t,n){return n=zo(t,n),n=Zn(n,Ze),t=Qn(t,kr),Number.isInteger(e)?(this[Ke]?this.nextTick(n,new F("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[le]?this.nextTick(n,new F("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(e<1&&(e=1),this[Ce]<1/0&&(e=Math.min(e,this[Ce]-this[X])),this[le]=!0,this[xt]=n,e<=0?this.nextTick(this[Ee],null,[]):this._nextv(e,t,this[Ee])),n[Ze]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[Ze])}_nextv(e,t,n){let i=[],o=(s,c,u)=>{if(s)return n(s);if(this[Sr]?c===void 0&&u===void 0:c===void 0)return n(null,i);i.push(this[Sr]?[c,u]:c),i.length===e?n(null,i):this._next(o)};this._next(o)}all(e,t){return t=zo(e,t),t=Zn(t,Ze),e=Qn(e,kr),this[Ke]?this.nextTick(t,new F("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[le]?this.nextTick(t,new F("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[le]=!0,this[xt]=t,this[ei]=!0,this[X]>=this[Ce]?this.nextTick(this[Ee],null,[]):this._all(e,this[Ee])),t[Ze]}_all(e,t){let n=this[X],i=[],o=()=>{let c=this[Ce]<1/0?Math.min(1e3,this[Ce]-n):1e3;c<=0?this.nextTick(t,null,i):this._nextv(c,kr,s)},s=(c,u)=>{c?t(c):u.length===0?t(null,i):(i.push.apply(i,u),n+=u.length,o())};o()}[De](){let e=this[xt];return this[ti]&&e===null?Pa:(this[le]=!1,this[xt]=null,this[Ke]&&this._close(this[Ht]),e)}[pe](e,t,n){this[ei]?this.close(e.bind(null,t,n)):e(t,n)}seek(e,t){if(t=Qn(t,kr),!this[Ke]){if(this[le])throw new F("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let n=this.db.keyEncoding(t.keyEncoding||this[Pe]),i=n.format;t.keyEncoding!==i&&(t={...t,keyEncoding:i});let o=this.db.prefixKey(n.encode(e),i);this._seek(o,t)}}}_seek(e,t){throw new F("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(e){return e=Zn(e,Ze),this[Br]?this.nextTick(e):this[Ke]?this[Jt].push(e):(this[Ke]=!0,this[Jt].push(e),this[le]?this[ti]&&this[De]()(new F("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[Ht])),e[Ze]}_close(e){this.nextTick(e)}[Ht](){this[Br]=!0,this.db.detachResource(this);let e=this[Jt];this[Jt]=[];for(let t of e)t()}async*[Symbol.asyncIterator](){try{let e;for(;(e=await this.next())!==void 0;)yield e}finally{this[Br]||await this.close()}}},vt=class extends Gt{constructor(e,t){super(e,t,!0),this[ri]=t.keys!==!1,this[ni]=t.values!==!1}[Qe](e,t,n){let i=this[De]();if(e)return i(e);try{t=this[ri]&&t!==void 0?this[Pe].decode(t):void 0,n=this[ni]&&n!==void 0?this[et].decode(n):void 0}catch(o){return i(new Me("entry",o))}t===void 0&&n===void 0||this[X]++,i(null,t,n)}[Ee](e,t){let n=this[De]();if(e)return this[pe](n,e);try{for(let i of t){let o=i[0],s=i[1];i[0]=this[ri]&&o!==void 0?this[Pe].decode(o):void 0,i[1]=this[ni]&&s!==void 0?this[et].decode(s):void 0}}catch(i){return this[pe](n,new Me("entries",i))}this[X]+=t.length,this[pe](n,null,t)}end(e){return!Wo&&typeof console<"u"&&(Wo=!0,console.warn(new F("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)}},ii=class extends Gt{constructor(e,t){super(e,t,!1)}[Qe](e,t){let n=this[De]();if(e)return n(e);try{t=t!==void 0?this[Pe].decode(t):void 0}catch(i){return n(new Me("key",i))}t!==void 0&&this[X]++,n(null,t)}[Ee](e,t){let n=this[De]();if(e)return this[pe](n,e);try{for(let i=0;i<t.length;i++){let o=t[i];t[i]=o!==void 0?this[Pe].decode(o):void 0}}catch(i){return this[pe](n,new Me("keys",i))}this[X]+=t.length,this[pe](n,null,t)}},oi=class extends Gt{constructor(e,t){super(e,t,!1)}[Qe](e,t){let n=this[De]();if(e)return n(e);try{t=t!==void 0?this[et].decode(t):void 0}catch(i){return n(new Me("value",i))}t!==void 0&&this[X]++,n(null,t)}[Ee](e,t){let n=this[De]();if(e)return this[pe](n,e);try{for(let i=0;i<t.length;i++){let o=t[i];t[i]=o!==void 0?this[et].decode(o):void 0}}catch(i){return this[pe](n,new Me("values",i))}this[X]+=t.length,this[pe](n,null,t)}},Me=class extends F{constructor(e,t){super(`Iterator could not decode ${e}`,{code:"LEVEL_DECODE_ERROR",cause:t})}};for(let r of["_ended property","_nexting property","_end method"])Object.defineProperty(vt.prototype,r.split(" ")[0],{get(){throw new F(`The ${r} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new F(`The ${r} has been removed`,{code:"LEVEL_LEGACY"})}});vt.keyEncoding=Pe;vt.valueEncoding=et;Ir.AbstractIterator=vt;Ir.AbstractKeyIterator=ii;Ir.AbstractValueIterator=oi});var Xo=E(si=>{"use strict";var{AbstractKeyIterator:Da,AbstractValueIterator:Ma}=Ne(),tt=Symbol("iterator"),zt=Symbol("callback"),bt=Symbol("handleOne"),rt=Symbol("handleMany"),Wt=class extends Da{constructor(e,t){super(e,t),this[tt]=e.iterator({...t,keys:!0,values:!1}),this[bt]=this[bt].bind(this),this[rt]=this[rt].bind(this)}},Ur=class extends Ma{constructor(e,t){super(e,t),this[tt]=e.iterator({...t,keys:!1,values:!0}),this[bt]=this[bt].bind(this),this[rt]=this[rt].bind(this)}};for(let r of[Wt,Ur]){let e=r===Wt,t=e?n=>n[0]:n=>n[1];r.prototype._next=function(n){this[zt]=n,this[tt].next(this[bt])},r.prototype[bt]=function(n,i,o){let s=this[zt];n?s(n):s(null,e?i:o)},r.prototype._nextv=function(n,i,o){this[zt]=o,this[tt].nextv(n,i,this[rt])},r.prototype._all=function(n,i){this[zt]=i,this[tt].all(n,this[rt])},r.prototype[rt]=function(n,i){let o=this[zt];n?o(n):o(null,i.map(t))},r.prototype._seek=function(n,i){this[tt].seek(n,i)},r.prototype._close=function(n){this[tt].close(n)}}si.DefaultKeyIterator=Wt;si.DefaultValueIterator=Ur});var Yo=E(Mr=>{"use strict";var{AbstractIterator:Na,AbstractKeyIterator:La,AbstractValueIterator:Fa}=Ne(),ci=re(),N=Symbol("nut"),Pr=Symbol("undefer"),Dr=Symbol("factory"),Or=class extends Na{constructor(e,t){super(e,t),this[N]=null,this[Dr]=()=>e.iterator(t),this.db.defer(()=>this[Pr]())}},Kr=class extends La{constructor(e,t){super(e,t),this[N]=null,this[Dr]=()=>e.keys(t),this.db.defer(()=>this[Pr]())}},Cr=class extends Fa{constructor(e,t){super(e,t),this[N]=null,this[Dr]=()=>e.values(t),this.db.defer(()=>this[Pr]())}};for(let r of[Or,Kr,Cr])r.prototype[Pr]=function(){this.db.status==="open"&&(this[N]=this[Dr]())},r.prototype._next=function(e){this[N]!==null?this[N].next(e):this.db.status==="opening"?this.db.defer(()=>this._next(e)):this.nextTick(e,new ci("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._nextv=function(e,t,n){this[N]!==null?this[N].nextv(e,t,n):this.db.status==="opening"?this.db.defer(()=>this._nextv(e,t,n)):this.nextTick(n,new ci("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._all=function(e,t){this[N]!==null?this[N].all(t):this.db.status==="opening"?this.db.defer(()=>this._all(e,t)):this.nextTick(t,new ci("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._seek=function(e,t){this[N]!==null?this[N]._seek(e,t):this.db.status==="opening"&&this.db.defer(()=>this._seek(e,t))},r.prototype._close=function(e){this[N]!==null?this[N].close(e):this.db.status==="opening"?this.db.defer(()=>this._close(e)):this.nextTick(e)};Mr.DeferredIterator=Or;Mr.DeferredKeyIterator=Kr;Mr.DeferredValueIterator=Cr});var ai=E(Qo=>{"use strict";var{fromCallback:Zo}=qt(),Nr=re(),{getCallback:Ra,getOptions:$a}=Tr(),Lr=Symbol("promise"),Y=Symbol("status"),Et=Symbol("operations"),Xt=Symbol("finishClose"),At=Symbol("closeCallbacks"),ui=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[Et]=[],this[At]=[],this[Y]="open",this[Xt]=this[Xt].bind(this),this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get length(){return this[Et].length}put(e,t,n){if(this[Y]!=="open")throw new Nr("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=n&&n.sublevel!=null?n.sublevel:this.db,s=n,c=o.keyEncoding(n&&n.keyEncoding),u=o.valueEncoding(n&&n.valueEncoding),a=c.format;n={...n,keyEncoding:a,valueEncoding:u.format},o!==this.db&&(n.sublevel=null);let d=o.prefixKey(c.encode(e),a),f=u.encode(t);return this._put(d,f,n),this[Et].push({...s,type:"put",key:e,value:t}),this}_put(e,t,n){}del(e,t){if(this[Y]!=="open")throw new Nr("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let n=this.db._checkKey(e);if(n)throw n;let i=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[Et].push({...o,type:"del",key:e}),this}_del(e,t){}clear(){if(this[Y]!=="open")throw new Nr("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[Et]=[],this}_clear(){}write(e,t){return t=Ra(e,t),t=Zo(t,Lr),e=$a(e),this[Y]!=="open"?this.nextTick(t,new Nr("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(t):(this[Y]="writing",this._write(e,n=>{this[Y]="closing",this[At].push(()=>t(n)),n||this.db.emit("batch",this[Et]),this._close(this[Xt])})),t[Lr]}_write(e,t){}close(e){return e=Zo(e,Lr),this[Y]==="closing"?this[At].push(e):this[Y]==="closed"?this.nextTick(e):(this[At].push(e),this[Y]!=="writing"&&(this[Y]="closing",this._close(this[Xt]))),e[Lr]}_close(e){this.nextTick(e)}[Xt](){this[Y]="closed",this.db.detachResource(this);let e=this[At];this[At]=[];for(let t of e)t()}};Qo.AbstractChainedBatch=ui});var ts=E(es=>{"use strict";var{AbstractChainedBatch:Va}=ai(),ja=re(),_t=Symbol("encoded"),fi=class extends Va{constructor(e){super(e),this[_t]=[]}_put(e,t,n){this[_t].push({...n,type:"put",key:e,value:t})}_del(e,t){this[_t].push({...t,type:"del",key:e})}_clear(){this[_t]=[]}_write(e,t){this.db.status==="opening"?this.db.defer(()=>this._write(e,t)):this.db.status==="open"?this[_t].length===0?this.nextTick(t):this.db._batch(this[_t],e,t):this.nextTick(t,new ja("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};es.DefaultChainedBatch=fi});var is=E((Ah,ns)=>{"use strict";var rs=re(),qa=Object.prototype.hasOwnProperty,Ha=new Set(["lt","lte","gt","gte"]);ns.exports=function(r,e){let t={};for(let n in r)if(qa.call(r,n)&&!(n==="keyEncoding"||n==="valueEncoding")){if(n==="start"||n==="end")throw new rs(`The legacy range option '${n}' has been removed`,{code:"LEVEL_LEGACY"});if(n==="encoding")throw new rs("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});Ha.has(n)?t[n]=e.encode(r[n]):t[n]=r[n]}return t.reverse=!!t.reverse,t.limit=Number.isInteger(t.limit)&&t.limit>=0?t.limit:-1,t}});var di=E((_h,ss)=>{var os;ss.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):r=>(os||(os=Promise.resolve())).then(r).catch(e=>setTimeout(()=>{throw e},0))});var as=E((Th,us)=>{"use strict";var cs=di();us.exports=function(r,...e){e.length===0?cs(r):cs(()=>r(...e))}});var fs=E(Fr=>{"use strict";var{AbstractIterator:Ja,AbstractKeyIterator:Ga,AbstractValueIterator:za}=Ne(),Tt=Symbol("unfix"),ne=Symbol("iterator"),nt=Symbol("handleOne"),Le=Symbol("handleMany"),Ae=Symbol("callback"),Yt=class extends Ja{constructor(e,t,n,i){super(e,t),this[ne]=n,this[Tt]=i,this[nt]=this[nt].bind(this),this[Le]=this[Le].bind(this),this[Ae]=null}[nt](e,t,n){let i=this[Ae];if(e)return i(e);t!==void 0&&(t=this[Tt](t)),i(e,t,n)}[Le](e,t){let n=this[Ae];if(e)return n(e);for(let i of t){let o=i[0];o!==void 0&&(i[0]=this[Tt](o))}n(e,t)}},Zt=class extends Ga{constructor(e,t,n,i){super(e,t),this[ne]=n,this[Tt]=i,this[nt]=this[nt].bind(this),this[Le]=this[Le].bind(this),this[Ae]=null}[nt](e,t){let n=this[Ae];if(e)return n(e);t!==void 0&&(t=this[Tt](t)),n(e,t)}[Le](e,t){let n=this[Ae];if(e)return n(e);for(let i=0;i<t.length;i++){let o=t[i];o!==void 0&&(t[i]=this[Tt](o))}n(e,t)}},Qt=class extends za{constructor(e,t,n){super(e,t),this[ne]=n}};for(let r of[Yt,Zt])r.prototype._next=function(e){this[Ae]=e,this[ne].next(this[nt])},r.prototype._nextv=function(e,t,n){this[Ae]=n,this[ne].nextv(e,t,this[Le])},r.prototype._all=function(e,t){this[Ae]=t,this[ne].all(e,this[Le])};for(let r of[Qt])r.prototype._next=function(e){this[ne].next(e)},r.prototype._nextv=function(e,t,n){this[ne].nextv(e,t,n)},r.prototype._all=function(e,t){this[ne].all(e,t)};for(let r of[Yt,Zt,Qt])r.prototype._seek=function(e,t){this[ne].seek(e,t)},r.prototype._close=function(e){this[ne].close(e)};Fr.AbstractSublevelIterator=Yt;Fr.AbstractSublevelKeyIterator=Zt;Fr.AbstractSublevelValueIterator=Qt});var ps=E((Sh,ls)=>{"use strict";var hi=re(),{Buffer:yi}=xr()||{},{AbstractSublevelIterator:Wa,AbstractSublevelKeyIterator:Xa,AbstractSublevelValueIterator:Ya}=fs(),_e=Symbol("prefix"),ds=Symbol("upperBound"),er=Symbol("prefixRange"),R=Symbol("parent"),li=Symbol("unfix"),hs=new TextEncoder,Za={separator:"!"};ls.exports=function({AbstractLevel:r}){class e extends r{static defaults(n){if(typeof n=="string")throw new hi("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(n&&n.open)throw new hi("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return n==null?Za:n.separator?n:{...n,separator:"!"}}constructor(n,i,o){let{separator:s,manifest:c,...u}=e.defaults(o);i=ef(i,s);let a=s.charCodeAt(0)+1,d=n[R]||n;if(!hs.encode(i).every(g=>g>a&&g<127))throw new hi(`Prefix must use bytes > ${a} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(Qa(d,c),u);let f=(n.prefix||"")+s+i+s,m=f.slice(0,-1)+String.fromCharCode(a);this[R]=d,this[_e]=new Rr(f),this[ds]=new Rr(m),this[li]=new mi,this.nextTick=d.nextTick}prefixKey(n,i){if(i==="utf8")return this[_e].utf8+n;if(n.byteLength===0)return this[_e][i];if(i==="view"){let o=this[_e].view,s=new Uint8Array(o.byteLength+n.byteLength);return s.set(o,0),s.set(n,o.byteLength),s}else{let o=this[_e].buffer;return yi.concat([o,n],o.byteLength+n.byteLength)}}[er](n,i){n.gte!==void 0?n.gte=this.prefixKey(n.gte,i):n.gt!==void 0?n.gt=this.prefixKey(n.gt,i):n.gte=this[_e][i],n.lte!==void 0?n.lte=this.prefixKey(n.lte,i):n.lt!==void 0?n.lt=this.prefixKey(n.lt,i):n.lte=this[ds][i]}get prefix(){return this[_e].utf8}get db(){return this[R]}_open(n,i){this[R].open({passive:!0},i)}_put(n,i,o,s){this[R].put(n,i,o,s)}_get(n,i,o){this[R].get(n,i,o)}_getMany(n,i,o){this[R].getMany(n,i,o)}_del(n,i,o){this[R].del(n,i,o)}_batch(n,i,o){this[R].batch(n,i,o)}_clear(n,i){this[er](n,n.keyEncoding),this[R].clear(n,i)}_iterator(n){this[er](n,n.keyEncoding);let i=this[R].iterator(n),o=this[li].get(this[_e].utf8.length,n.keyEncoding);return new Wa(this,n,i,o)}_keys(n){this[er](n,n.keyEncoding);let i=this[R].keys(n),o=this[li].get(this[_e].utf8.length,n.keyEncoding);return new Xa(this,n,i,o)}_values(n){this[er](n,n.keyEncoding);let i=this[R].values(n);return new Ya(this,n,i)}}return{AbstractSublevel:e}};var Qa=function(r,e){return{...r.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...e,encodings:{utf8:pi(r,"utf8"),buffer:pi(r,"buffer"),view:pi(r,"view")}}},pi=function(r,e){return r.supports.encodings[e]?r.keyEncoding(e).name===e:!1},Rr=class{constructor(e){this.utf8=e,this.view=hs.encode(e),this.buffer=yi?yi.from(this.view.buffer,0,this.view.byteLength):{}}},mi=class{constructor(){this.cache=new Map}get(e,t){let n=this.cache.get(t);return n===void 0&&(t==="view"?n=(function(i,o){return o.subarray(i)}).bind(null,e):n=(function(i,o){return o.slice(i)}).bind(null,e),this.cache.set(t,n)),n}},ef=function(r,e){let t=0,n=r.length;for(;t<n&&r[t]===e;)t++;for(;n>t&&r[n-1]===e;)n--;return r.slice(t,n)}});var bi=E(vi=>{"use strict";var{supports:tf}=ho(),{Transcoder:rf}=Vo(),{EventEmitter:nf}=qo(),{fromCallback:Fe}=qt(),ie=re(),{AbstractIterator:it}=Ne(),{DefaultKeyIterator:of,DefaultValueIterator:sf}=Xo(),{DeferredIterator:cf,DeferredKeyIterator:uf,DeferredValueIterator:af}=Yo(),{DefaultChainedBatch:ys}=ts(),{getCallback:ot,getOptions:Re}=Tr(),$r=is(),x=Symbol("promise"),Te=Symbol("landed"),st=Symbol("resources"),gi=Symbol("closeResources"),tr=Symbol("operations"),rr=Symbol("undefer"),Vr=Symbol("deferOpen"),ms=Symbol("options"),v=Symbol("status"),ct=Symbol("defaultOptions"),Bt=Symbol("transcoder"),jr=Symbol("keyEncoding"),wi=Symbol("valueEncoding"),ff=()=>{},nr=class extends nf{constructor(e,t){if(super(),typeof e!="object"||e===null)throw new TypeError("The first argument 'manifest' must be an object");t=Re(t);let{keyEncoding:n,valueEncoding:i,passive:o,...s}=t;this[st]=new Set,this[tr]=[],this[Vr]=!0,this[ms]=s,this[v]="opening",this.supports=tf(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[Bt]=new rf(df(this)),this[jr]=this[Bt].encoding(n||"utf8"),this[wi]=this[Bt].encoding(i||"utf8");for(let c of this[Bt].encodings())this.supports.encodings[c.commonName]||(this.supports.encodings[c.commonName]=!0);this[ct]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[jr].commonName,valueEncoding:this[wi].commonName}),key:Object.freeze({keyEncoding:this[jr].commonName})},this.nextTick(()=>{this[Vr]&&this.open({passive:!1},ff)})}get status(){return this[v]}keyEncoding(e){return this[Bt].encoding(e??this[jr])}valueEncoding(e){return this[Bt].encoding(e??this[wi])}open(e,t){t=ot(e,t),t=Fe(t,x),e={...this[ms],...Re(e)},e.createIfMissing=e.createIfMissing!==!1,e.errorIfExists=!!e.errorIfExists;let n=i=>{this[v]==="closing"||this[v]==="opening"?this.once(Te,i?()=>n(i):n):this[v]!=="open"?t(new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):t()};return e.passive?this[v]==="opening"?this.once(Te,n):this.nextTick(n):this[v]==="closed"||this[Vr]?(this[Vr]=!1,this[v]="opening",this.emit("opening"),this._open(e,i=>{if(i){this[v]="closed",this[gi](()=>{this.emit(Te),n(i)}),this[rr]();return}this[v]="open",this[rr](),this.emit(Te),this[v]==="open"&&this.emit("open"),this[v]==="open"&&this.emit("ready"),n()})):this[v]==="open"?this.nextTick(n):this.once(Te,()=>this.open(e,t)),t[x]}_open(e,t){this.nextTick(t)}close(e){e=Fe(e,x);let t=n=>{this[v]==="opening"||this[v]==="closing"?this.once(Te,n?t(n):t):this[v]!=="closed"?e(new ie("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):e()};if(this[v]==="open"){this[v]="closing",this.emit("closing");let n=i=>{this[v]="open",this[rr](),this.emit(Te),t(i)};this[gi](()=>{this._close(i=>{if(i)return n(i);this[v]="closed",this[rr](),this.emit(Te),this[v]==="closed"&&this.emit("closed"),t()})})}else this[v]==="closed"?this.nextTick(t):this.once(Te,()=>this.close(e));return e[x]}[gi](e){if(this[st].size===0)return this.nextTick(e);let t=this[st].size,n=!0,i=()=>{--t===0&&(n?this.nextTick(e):e())};for(let o of this[st])o.close(i);n=!1,this[st].clear()}_close(e){this.nextTick(e)}get(e,t,n){if(n=ot(t,n),n=Fe(n,x),t=Re(t,this[ct].entry),this[v]==="opening")return this.defer(()=>this.get(e,t,n)),n[x];if(St(this,n))return n[x];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[x];let o=this.keyEncoding(t.keyEncoding),s=this.valueEncoding(t.valueEncoding),c=o.format,u=s.format;return(t.keyEncoding!==c||t.valueEncoding!==u)&&(t=Object.assign({},t,{keyEncoding:c,valueEncoding:u})),this._get(this.prefixKey(o.encode(e),c),t,(a,d)=>{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)),n(a);try{d=s.decode(d)}catch(f){return n(new ie("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:f}))}n(null,d)}),n[x]}_get(e,t,n){this.nextTick(n,new Error("NotFound"))}getMany(e,t,n){if(n=ot(t,n),n=Fe(n,x),t=Re(t,this[ct].entry),this[v]==="opening")return this.defer(()=>this.getMany(e,t,n)),n[x];if(St(this,n))return n[x];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[x];if(e.length===0)return this.nextTick(n,null,[]),n[x];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 u=new Array(e.length);for(let a=0;a<e.length;a++){let d=e[a],f=this._checkKey(d);if(f)return this.nextTick(n,f),n[x];u[a]=this.prefixKey(i.encode(d),s)}return this._getMany(u,t,(a,d)=>{if(a)return n(a);try{for(let f=0;f<d.length;f++)d[f]!==void 0&&(d[f]=o.decode(d[f]))}catch(f){return n(new ie(`Could not decode one or more of ${d.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:f}))}n(null,d)}),n[x]}_getMany(e,t,n){this.nextTick(n,null,new Array(e.length).fill(void 0))}put(e,t,n,i){if(i=ot(n,i),i=Fe(i,x),n=Re(n,this[ct].entry),this[v]==="opening")return this.defer(()=>this.put(e,t,n,i)),i[x];if(St(this,i))return i[x];let o=this._checkKey(e)||this._checkValue(t);if(o)return this.nextTick(i,o),i[x];let s=this.keyEncoding(n.keyEncoding),c=this.valueEncoding(n.valueEncoding),u=s.format,a=c.format;(n.keyEncoding!==u||n.valueEncoding!==a)&&(n=Object.assign({},n,{keyEncoding:u,valueEncoding:a}));let d=this.prefixKey(s.encode(e),u),f=c.encode(t);return this._put(d,f,n,m=>{if(m)return i(m);this.emit("put",e,t),i()}),i[x]}_put(e,t,n,i){this.nextTick(i)}del(e,t,n){if(n=ot(t,n),n=Fe(n,x),t=Re(t,this[ct].key),this[v]==="opening")return this.defer(()=>this.del(e,t,n)),n[x];if(St(this,n))return n[x];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[x];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 n(c);this.emit("del",e),n()}),n[x]}_del(e,t,n){this.nextTick(n)}batch(e,t,n){if(!arguments.length){if(this[v]==="opening")return new ys(this);if(this[v]!=="open")throw new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof e=="function"?n=e:n=ot(t,n),n=Fe(n,x),t=Re(t,this[ct].empty),this[v]==="opening")return this.defer(()=>this.batch(e,t,n)),n[x];if(St(this,n))return n[x];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[x];if(e.length===0)return this.nextTick(n),n[x];let i=new Array(e.length),{keyEncoding:o,valueEncoding:s,...c}=t;for(let u=0;u<e.length;u++){if(typeof e[u]!="object"||e[u]===null)return this.nextTick(n,new TypeError("A batch operation must be an object")),n[x];let a=Object.assign({},e[u]);if(a.type!=="put"&&a.type!=="del")return this.nextTick(n,new TypeError("A batch operation must have a type property that is 'put' or 'del'")),n[x];let d=this._checkKey(a.key);if(d)return this.nextTick(n,d),n[x];let f=a.sublevel!=null?a.sublevel:this,m=f.keyEncoding(a.keyEncoding||o),g=m.format;if(a.key=f.prefixKey(m.encode(a.key),g),a.keyEncoding=g,a.type==="put"){let w=this._checkValue(a.value);if(w)return this.nextTick(n,w),n[x];let b=f.valueEncoding(a.valueEncoding||s);a.value=b.encode(a.value),a.valueEncoding=b.format}f!==this&&(a.sublevel=null),i[u]=a}return this._batch(i,c,u=>{if(u)return n(u);this.emit("batch",e),n()}),n[x]}_batch(e,t,n){this.nextTick(n)}sublevel(e,t){return this._sublevel(e,xi.defaults(t))}_sublevel(e,t){return new xi(this,e,t)}prefixKey(e,t){return e}clear(e,t){if(t=ot(e,t),t=Fe(t,x),e=Re(e,this[ct].empty),this[v]==="opening")return this.defer(()=>this.clear(e,t)),t[x];if(St(this,t))return t[x];let n=e,i=this.keyEncoding(e.keyEncoding);return e=$r(e,i),e.keyEncoding=i.format,e.limit===0?this.nextTick(t):this._clear(e,o=>{if(o)return t(o);this.emit("clear",n),t()}),t[x]}_clear(e,t){this.nextTick(t)}iterator(e){let t=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=$r(e,t),e.keys=e.keys!==!1,e.values=e.values!==!1,e[it.keyEncoding]=t,e[it.valueEncoding]=n,e.keyEncoding=t.format,e.valueEncoding=n.format,this[v]==="opening")return new cf(this,e);if(this[v]!=="open")throw new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(e)}_iterator(e){return new it(this,e)}keys(e){let t=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=$r(e,t),e[it.keyEncoding]=t,e[it.valueEncoding]=n,e.keyEncoding=t.format,e.valueEncoding=n.format,this[v]==="opening")return new uf(this,e);if(this[v]!=="open")throw new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(e)}_keys(e){return new of(this,e)}values(e){let t=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=$r(e,t),e[it.keyEncoding]=t,e[it.valueEncoding]=n,e.keyEncoding=t.format,e.valueEncoding=n.format,this[v]==="opening")return new af(this,e);if(this[v]!=="open")throw new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(e)}_values(e){return new sf(this,e)}defer(e){if(typeof e!="function")throw new TypeError("The first argument must be a function");this[tr].push(e)}[rr](){if(this[tr].length===0)return;let e=this[tr];this[tr]=[];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[st].add(e)}detachResource(e){this[st].delete(e)}_chainedBatch(){return new ys(this)}_checkKey(e){if(e==null)return new ie("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(e){if(e==null)return new ie("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};nr.prototype.nextTick=as();var{AbstractSublevel:xi}=ps()({AbstractLevel:nr});vi.AbstractLevel=nr;vi.AbstractSublevel=xi;var St=function(r,e){return r[v]!=="open"?(r.nextTick(e,new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},df=function(r){return Object.keys(r.supports.encodings).filter(e=>!!r.supports.encodings[e])}});var Ei=E(ut=>{"use strict";ut.AbstractLevel=bi().AbstractLevel;ut.AbstractSublevel=bi().AbstractSublevel;ut.AbstractIterator=Ne().AbstractIterator;ut.AbstractKeyIterator=Ne().AbstractKeyIterator;ut.AbstractValueIterator=Ne().AbstractValueIterator;ut.AbstractChainedBatch=ai().AbstractChainedBatch});var ws=E((Uh,gs)=>{gs.exports=lf;var hf=di();function lf(r,e,t){if(typeof e!="number")throw new Error("second argument must be a Number");let n,i,o,s,c,u=!0,a;Array.isArray(r)?(n=[],o=i=r.length):(s=Object.keys(r),n={},o=i=s.length);function d(m){function g(){t&&t(m,n),t=null}u?hf(g):g()}function f(m,g,w){if(n[m]=w,g&&(c=!0),--o===0||g)d(g);else if(!c&&a<i){let b;s?(b=s[a],a+=1,r[b](function(ee,K){f(b,ee,K)})):(b=a,a+=1,r[b](function(ee,K){f(b,ee,K)}))}}a=e,o?s?s.some(function(m,g){return r[m](function(w,b){f(m,w,b)}),g===e-1}):r.some(function(m,g){return m(function(w,b){f(g,w,b)}),g===e-1}):d(null),u=!1}});var Ai=E((Oh,xs)=>{"use strict";xs.exports=function(e){let t=e.gte!==void 0?e.gte:e.gt!==void 0?e.gt:void 0,n=e.lte!==void 0?e.lte:e.lt!==void 0?e.lt:void 0,i=e.gte===void 0,o=e.lte===void 0;return t!==void 0&&n!==void 0?IDBKeyRange.bound(t,n,i,o):t!==void 0?IDBKeyRange.lowerBound(t,i):n!==void 0?IDBKeyRange.upperBound(n,o):null}});var _i=E((Kh,vs)=>{"use strict";var pf=new TextEncoder;vs.exports=function(r){return r instanceof Uint8Array?r:r instanceof ArrayBuffer?new Uint8Array(r):pf.encode(r)}});var Ts=E(_s=>{"use strict";var{AbstractIterator:yf}=Ei(),bs=Ai(),qr=_i(),ye=Symbol("cache"),Be=Symbol("finished"),$=Symbol("options"),Se=Symbol("currentOptions"),at=Symbol("position"),Ti=Symbol("location"),kt=Symbol("first"),Es={},Bi=class extends yf{constructor(e,t,n){super(e,n),this[ye]=[],this[Be]=this.limit===0,this[$]=n,this[Se]={...n},this[at]=void 0,this[Ti]=t,this[kt]=!0}_nextv(e,t,n){if(this[kt]=!1,this[Be])return this.nextTick(n,null,[]);if(this[ye].length>0)return e=Math.min(e,this[ye].length),this.nextTick(n,null,this[ye].splice(0,e));this[at]!==void 0&&(this[$].reverse?(this[Se].lt=this[at],this[Se].lte=void 0):(this[Se].gt=this[at],this[Se].gte=void 0));let i;try{i=bs(this[Se])}catch{return this[Be]=!0,this.nextTick(n,null,[])}let o=this.db.db.transaction([this[Ti]],"readonly"),s=o.objectStore(this[Ti]),c=[];if(this[$].reverse){let u=!this[$].values&&s.openKeyCursor?"openKeyCursor":"openCursor";s[u](i,"prev").onsuccess=a=>{let d=a.target.result;if(d){let{key:f,value:m}=d;this[at]=f,c.push([this[$].keys&&f!==void 0?qr(f):void 0,this[$].values&&m!==void 0?qr(m):void 0]),c.length<e?d.continue():As(o)}else this[Be]=!0}}else{let u,a,d=()=>{if(u===void 0||a===void 0)return;let f=Math.max(u.length,a.length);f===0||e===1/0?this[Be]=!0:this[at]=u[f-1],c.length=f;for(let m=0;m<f;m++){let g=u[m],w=a[m];c[m]=[this[$].keys&&g!==void 0?qr(g):void 0,this[$].values&&w!==void 0?qr(w):void 0]}As(o)};this[$].keys||e<1/0?s.getAllKeys(i,e<1/0?e:void 0).onsuccess=f=>{u=f.target.result,d()}:(u=[],this.nextTick(d)),this[$].values?s.getAll(i,e<1/0?e:void 0).onsuccess=f=>{a=f.target.result,d()}:(a=[],this.nextTick(d))}o.onabort=()=>{n(o.error||new Error("aborted by user")),n=null},o.oncomplete=()=>{n(null,c),n=null}}_next(e){if(this[ye].length>0){let[t,n]=this[ye].shift();this.nextTick(e,null,t,n)}else if(this[Be])this.nextTick(e);else{let t=Math.min(100,this.limit-this.count);this[kt]&&(this[kt]=!1,t=1),this._nextv(t,Es,(n,i)=>{if(n)return e(n);this[ye]=i,this._next(e)})}}_all(e,t){this[kt]=!1;let n=this[ye].splice(0,this[ye].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(t,null,n);this._nextv(i,Es,(o,s)=>{if(o)return t(o);n.length>0&&(s=n.concat(s)),t(null,s)})}_seek(e,t){this[kt]=!0,this[ye]=[],this[Be]=!1,this[at]=void 0,this[Se]={...this[$]};let n;try{n=bs(this[$])}catch{this[Be]=!0;return}n!==null&&!n.includes(e)?this[Be]=!0:this[$].reverse?this[Se].lte=e:this[Se].gte=e}};_s.Iterator=Bi;function As(r){typeof r.commit=="function"&&r.commit()}});var Ss=E((Ph,Bs)=>{"use strict";Bs.exports=function(e,t,n,i,o){if(i.limit===0)return e.nextTick(o);let s=e.db.transaction([t],"readwrite"),c=s.objectStore(t),u=0;s.oncomplete=function(){o()},s.onabort=function(){o(s.error||new Error("aborted by user"))};let a=c.openKeyCursor?"openKeyCursor":"openCursor",d=i.reverse?"prev":"next";c[a](n,d).onsuccess=function(f){let m=f.target.result;m&&(c.delete(m.key).onsuccess=function(){(i.limit<=0||++u<i.limit)&&m.continue()})}}});var Cs=E(Ks=>{"use strict";var{AbstractLevel:mf}=Ei(),ks=re(),gf=ws(),{fromCallback:wf}=qt(),{Iterator:xf}=Ts(),Is=_i(),vf=Ss(),bf=Ai(),Os="level-js-",ir=Symbol("idb"),Si=Symbol("namePrefix"),ke=Symbol("location"),ki=Symbol("version"),ft=Symbol("store"),or=Symbol("onComplete"),Us=Symbol("promise"),Hr=class extends mf{constructor(e,t,n){if(typeof t=="function"||typeof n=="function")throw new ks("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[ke]=e,this[Si]=i??Os,this[ki]=parseInt(o||1,10),this[ir]=null}get location(){return this[ke]}get namePrefix(){return this[Si]}get version(){return this[ki]}get db(){return this[ir]}get type(){return"browser-level"}_open(e,t){let n=indexedDB.open(this[Si]+this[ke],this[ki]);n.onerror=function(){t(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[ir]=n.result,t()},n.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[ke])||o.createObjectStore(this[ke])}}[ft](e){return this[ir].transaction([this[ke]],e).objectStore(this[ke])}[or](e,t){let n=e.transaction;n.onabort=function(){t(n.error||new Error("aborted by user"))},n.oncomplete=function(){t(null,e.result)}}_get(e,t,n){let i=this[ft]("readonly"),o;try{o=i.get(e)}catch(s){return this.nextTick(n,s)}this[or](o,function(s,c){if(s)return n(s);if(c===void 0)return n(new ks("Entry not found",{code:"LEVEL_NOT_FOUND"}));n(null,Is(c))})}_getMany(e,t,n){let i=this[ft]("readonly"),o=e.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:Is(a))},u.onerror=a=>{a.stopPropagation(),c(u.error)}});gf(o,16,n)}_del(e,t,n){let i=this[ft]("readwrite"),o;try{o=i.delete(e)}catch(s){return this.nextTick(n,s)}this[or](o,n)}_put(e,t,n,i){let o=this[ft]("readwrite"),s;try{s=o.put(t,e)}catch(c){return this.nextTick(i,c)}this[or](s,i)}_iterator(e){return new xf(this,this[ke],e)}_batch(e,t,n){let i=this[ft]("readwrite"),o=i.transaction,s=0,c;o.onabort=function(){n(c||o.error||new Error("aborted by user"))},o.oncomplete=function(){n()};function u(){let a=e[s++],d=a.key,f;try{f=a.type==="del"?i.delete(d):i.put(a.value,d)}catch(m){c=m,o.abort();return}s<e.length?f.onsuccess=u:typeof o.commit=="function"&&o.commit()}u()}_clear(e,t){let n,i;try{n=bf(e)}catch{return this.nextTick(t)}if(e.limit>=0)return vf(this,this[ke],n,e,t);try{let o=this[ft]("readwrite");i=n?o.delete(n):o.clear()}catch(o){return this.nextTick(t,o)}this[or](i,t)}_close(e){this[ir].close(),this.nextTick(e)}};Hr.destroy=function(r,e,t){typeof e=="function"&&(t=e,e=Os),t=wf(t,Us);let n=indexedDB.deleteDatabase(e+r);return n.onsuccess=function(){t()},n.onerror=function(i){t(i)},t[Us]};Ks.BrowserLevel=Hr});var Ds=E(Ps=>{Ps.Level=Cs().BrowserLevel});var xe;(function(r){r.AlgorithmNotSupported="algorithmNotSupported",r.EncodingError="encodingError",r.InvalidCoseSign1="invalidCoseSign1",r.InvalidEat="invalidEat",r.InvalidJwe="invalidJwe",r.InvalidJwk="invalidJwk",r.OperationNotSupported="operationNotSupported"})(xe||(xe={}));var fu=Ji(zi(),1);var ud=new Uint8Array(0);function Wi(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function ht(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function hu(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),s=o.charCodeAt(0);if(t[s]!==255)throw new TypeError(o+" is ambiguous");t[s]=i}var c=r.length,u=r.charAt(0),a=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function f(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var b=0,ee=0,K=0,ce=w.length;K!==ce&&w[K]===0;)K++,b++;for(var ue=(ce-K)*d+1>>>0,z=new Uint8Array(ue);K!==ce;){for(var ae=w[K],Ue=0,te=ue-1;(ae!==0||Ue<ee)&&te!==-1;te--,Ue++)ae+=256*z[te]>>>0,z[te]=ae%c>>>0,ae=ae/c>>>0;if(ae!==0)throw new Error("Non-zero carry");ee=Ue,K++}for(var we=ue-ee;we!==ue&&z[we]===0;)we++;for(var hr=u.repeat(b);we<ue;++we)hr+=r.charAt(z[we]);return hr}function m(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var b=0;if(w[b]!==" "){for(var ee=0,K=0;w[b]===u;)ee++,b++;for(var ce=(w.length-b)*a+1>>>0,ue=new Uint8Array(ce);w[b];){var z=t[w.charCodeAt(b)];if(z===255)return;for(var ae=0,Ue=ce-1;(z!==0||ae<K)&&Ue!==-1;Ue--,ae++)z+=c*ue[Ue]>>>0,ue[Ue]=z%256>>>0,z=z/256>>>0;if(z!==0)throw new Error("Non-zero carry");K=ae,b++}if(w[b]!==" "){for(var te=ce-K;te!==ce&&ue[te]===0;)te++;for(var we=new Uint8Array(ee+(ce-te)),hr=ee;te!==ce;)we[hr++]=ue[te++];return we}}}function g(w){var b=m(w);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:m,decode:g}}var lu=hu,pu=lu,Xi=pu;var yn=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},mn=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){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=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Yi(this,e)}},gn=class{decoders;constructor(e){this.decoders=e}or(e){return Yi(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Yi(r,e){return new gn({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var wn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new yn(e,t,n),this.decoder=new mn(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Zi({name:r,prefix:e,encode:t,decode:n}){return new wn(r,e,t,n)}function xn({name:r,prefix:e,alphabet:t}){let{encode:n,decode:i}=Xi(t,r);return Zi({prefix:e,name:r,encode:n,decode:o=>ht(i(o))})}function yu(r,e,t,n){let i={};for(let d=0;d<e.length;++d)i[e[d]]=d;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),c=0,u=0,a=0;for(let d=0;d<o;++d){let f=i[r[d]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<t|f,c+=t,c>=8&&(c-=8,s[a++]=255&u>>c)}if(c>=t||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s}function mu(r,e,t){let n=e[e.length-1]==="=",i=(1<<t)-1,o="",s=0,c=0;for(let u=0;u<r.length;++u)for(c=c<<8|r[u],s+=8;s>t;)s-=t,o+=e[i&c>>s];if(s!==0&&(o+=e[i&c<<t-s]),n)for(;o.length*t&7;)o+="=";return o}function C({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Zi({prefix:e,name:r,encode(i){return mu(i,n,t)},decode(i){return yu(i,n,t,r)}})}var Ct=C({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pd=C({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),yd=C({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),md=C({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),gd=C({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wd=C({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),xd=C({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),vd=C({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vn=C({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var D=xn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ad=xn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Bd=C({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Sd=C({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),fe=C({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),kd=C({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Qi(r){return r.byteOffset!==0||r.byteLength!==r.buffer.byteLength}function eo(r){return typeof r!="object"||r===null?!1:typeof r[Symbol.asyncIterator]=="function"}function pr(r){let t=Object.prototype.toString.call(r).match(/\s([a-zA-Z0-9]+)/),[n,i]=t;return i}var Pt=function(r,e,t,n){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function c(d){try{a(n.next(d))}catch(f){s(f)}}function u(d){try{a(n.throw(d))}catch(f){s(f)}}function a(d){d.done?o(d.value):i(d.value).then(c,u)}a((n=n.apply(r,e||[])).next())})},to=function(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof __values=="function"?__values(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=r[o]&&function(s){return new Promise(function(c,u){s=r[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)}},yr=new TextEncoder,Je=new TextDecoder,T=class r{constructor(e,t){this.data=e,this.format=t}static arrayBuffer(e){return new r(e,"ArrayBuffer")}static asyncIterable(e){if(!eo(e))throw new TypeError("Input must be of type AsyncIterable.");return new r(e,"AsyncIterable")}static base32Z(e){return new r(e,"Base32Z")}static base58Btc(e){return new r(e,"Base58Btc")}static base64Url(e){return new r(e,"Base64Url")}static bufferSource(e){return new r(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 r(e,"Hex")}static multibase(e){return new r(e,"Multibase")}static object(e){return new r(e,"Object")}static string(e){return new r(e,"String")}static uint8Array(e){return new r(e,"Uint8Array")}toArrayBuffer(){switch(this.format){case"Base58Btc":return D.baseDecode(this.data).buffer;case"Base64Url":return fe.baseDecode(this.data).buffer;case"BufferSource":{if(pr(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return Qi(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 Pt(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 vn.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 D.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return D.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 fe.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return fe.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),t=yr.encode(e);return fe.baseEncode(t)}case"String":{let e=yr.encode(this.data);return fe.baseEncode(e)}case"Uint8Array":return fe.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return Pt(this,void 0,void 0,function*(){var e,t,n,i;switch(this.format){case"AsyncIterable":{let u=[];try{for(var o=!0,s=to(this.data),c;c=yield s.next(),e=c.done,!e;o=!0){i=c.value,o=!1;let d=i;u.push(d)}}catch(d){t={error:d}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(t)throw t.error}}return new Blob(u)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Blob is not supported.`)}})}toHex(){let e=Array.from({length:256},(t,n)=>n.toString(16).padStart(2,"0"));switch(this.format){case"ArrayBuffer":{let t=this.toUint8Array();return r.uint8Array(t).toHex()}case"Base64Url":{let t=this.toUint8Array();return r.uint8Array(t).toHex()}case"Uint8Array":{let t="";for(let n=0;n<this.data.length;n++)t+=e[this.data[n]];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=fe.baseDecode(this.data),t=Je.decode(e);return JSON.parse(t)}case"String":return JSON.parse(this.data);case"Uint8Array":{let e=Je.decode(this.data);return JSON.parse(e)}default:throw new TypeError(`Conversion from ${this.format} to Object is not supported.`)}}toObjectAsync(){return Pt(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 Je.decode(this.data);case"Base64Url":{let e=fe.baseDecode(this.data);return Je.decode(e)}case"Object":return JSON.stringify(this.data);case"Uint8Array":return Je.decode(this.data);default:throw new TypeError(`Conversion from ${this.format} to String is not supported.`)}}toStringAsync(){return Pt(this,void 0,void 0,function*(){var e,t,n,i;switch(this.format){case"AsyncIterable":{let u="";try{for(var o=!0,s=to(this.data),c;c=yield s.next(),e=c.done,!e;o=!0){i=c.value,o=!1;let a=i;typeof a=="string"?u+=a:u+=Je.decode(a,{stream:!0})}}catch(a){t={error:a}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(t)throw t.error}}return u+=Je.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 vn.baseDecode(this.data);case"Base58Btc":return D.baseDecode(this.data);case"Base64Url":return fe.baseDecode(this.data);case"BufferSource":{let e=pr(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 n=parseInt(this.data.substring(t,t+2),16);if(isNaN(n))throw new TypeError("Input is not a valid hexadecimal string.");e[t/2]=n}return e}case"Object":{let e=JSON.stringify(this.data);return yr.encode(e)}case"String":return yr.encode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Uint8Array is not supported.`)}}toUint8ArrayAsync(){return Pt(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 Dt;(function(r){r.Debug="debug",r.Silent="silent"})(Dt||(Dt={}));var bn=class{constructor(){this.logLevel=Dt.Silent}setLogLevel(e){this.logLevel=e}log(e){this.info(e)}info(e){this.logLevel!==Dt.Silent&&console.info(e)}error(e){this.logLevel!==Dt.Silent&&console.error(e)}},gu=new bn;typeof window<"u"&&(window.web5logger=gu);var ve={};su(ve,{decode:()=>lt,encodeTo:()=>Ge,encodingLength:()=>ze});var wu=io,ro=128,xu=127,vu=~xu,bu=Math.pow(2,31);function io(r,e,t){e=e||[],t=t||0;for(var n=t;r>=bu;)e[t++]=r&255|ro,r/=128;for(;r&vu;)e[t++]=r&255|ro,r>>>=7;return e[t]=r|0,io.bytes=t-n+1,e}var Eu=En,Au=128,no=127;function En(r,n){var t=0,n=n||0,i=0,o=n,s,c=r.length;do{if(o>=c)throw En.bytes=0,new RangeError("Could not decode varint");s=r[o++],t+=i<28?(s&no)<<i:(s&no)*Math.pow(2,i),i+=7}while(s>=Au);return En.bytes=o-n,t}var _u=Math.pow(2,7),Tu=Math.pow(2,14),Bu=Math.pow(2,21),Su=Math.pow(2,28),ku=Math.pow(2,35),Iu=Math.pow(2,42),Uu=Math.pow(2,49),Ou=Math.pow(2,56),Ku=Math.pow(2,63),Cu=function(r){return r<_u?1:r<Tu?2:r<Bu?3:r<Su?4:r<ku?5:r<Iu?6:r<Uu?7:r<Ou?8:r<Ku?9:10},Pu={encode:wu,decode:Eu,encodingLength:Cu},Du=Pu,Mt=Du;function lt(r,e=0){return[Mt.decode(r,e),Mt.decode.bytes]}function Ge(r,e,t=0){return Mt.encode(r,e,t),e}function ze(r){return Mt.encodingLength(r)}function An(r,e){let t=e.byteLength,n=ze(r),i=n+ze(t),o=new Uint8Array(i+t);return Ge(r,o,0),Ge(t,o,n),o.set(e,i),new pt(r,t,e,o)}function oo(r){let e=ht(r),[t,n]=lt(e),[i,o]=lt(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new pt(t,i,s,e)}function so(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Wi(r.bytes,t.bytes)}}var pt=class{code;size;digest;bytes;constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};function co(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Nu(t,Tn(r),e??D.encoder);default:return Lu(t,Tn(r),e??Ct.encoder)}}var uo=new WeakMap;function Tn(r){let e=uo.get(r);if(e==null){let t=new Map;return uo.set(r,t),t}return e}var Bn=class r{code;version;multihash;bytes;"/";constructor(e,t,n,i){this.code=t,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Nt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Fu)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.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,n=An(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&so(e.multihash,n.multihash)}toString(e){return co(this,e)}toJSON(){return{"/":co(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 r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:i,multihash:o,bytes:s}=t;return new r(n,i,o,s??ao(n,i,o.bytes))}else if(t[Ru]===!0){let{version:n,multihash:i,code:o}=t,s=oo(i);return r.create(n,o,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Nt)throw new Error(`Version 0 CID must use dag-pb (code: ${Nt}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let i=ao(e,t,n.bytes);return new r(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Nt,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,i=ht(e.subarray(n,n+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=i.subarray(t.multihashSize-t.digestSize),s=new pt(t.multihashCode,t.digestSize,o,i);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[f,m]=lt(e.subarray(t));return t+=m,f},i=n(),o=Nt;if(i===18?(i=0,t=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=t,c=n(),u=n(),a=t+u,d=a-s;return{version:i,codec:o,multihashCode:c,digestSize:u,multihashSize:d,size:a}}static parse(e,t){let[n,i]=Mu(e,t),o=r.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Tn(o).set(n,e),o}};function Mu(r,e){switch(r[0]){case"Q":{let t=e??D;return[D.prefix,t.decode(`${D.prefix}${r}`)]}case D.prefix:{let t=e??D;return[D.prefix,t.decode(r)]}case Ct.prefix:{let t=e??Ct;return[Ct.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Nu(r,e,t){let{prefix:n}=t;if(n!==D.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(n);if(i==null){let o=t.encode(r).slice(1);return e.set(n,o),o}else return i}function Lu(r,e,t){let{prefix:n}=t,i=e.get(n);if(i==null){let o=t.encode(r);return e.set(n,o),o}else return i}var Nt=112,Fu=18;function ao(r,e,t){let n=ze(r),i=n+ze(e),o=new Uint8Array(i+t.byteLength);return Ge(r,o,0),Ge(e,o,n),o.set(t,i),o}var Ru=Symbol.for("@ipld/js-cid/CID");var L=class r{static addPrefix(e){var t;let{code:n,data:i,name:o}=e;if(!(o?!n:n))throw new Error("Either 'name' or 'code' must be defined, but not both.");if(n=r.codeToName.has(n)?n:r.nameToCode.get(o),n===void 0)throw new Error(`Unsupported multicodec: ${(t=e.name)!==null&&t!==void 0?t:e.code}`);let s=ve.encodingLength(n),c=new Uint8Array(s+i.byteLength);return c.set(i,s),ve.encodeTo(n,c),c}static getCodeFromData(e){let{prefixedData:t}=e,[n,i]=ve.decode(t);return n}static getCodeFromName(e){let{name:t}=e,n=r.nameToCode.get(t);if(n===void 0)throw new Error(`Unsupported multicodec: ${t}`);return n}static getNameFromCode(e){let{code:t}=e,n=r.codeToName.get(t);if(n===void 0)throw new Error(`Unsupported multicodec: ${t}`);return n}static registerCodec(e){r.codeToName.set(e.code,e.name),r.nameToCode.set(e.name,e.code)}static removePrefix(e){let{prefixedData:t}=e,[n,i]=ve.decode(t),o=r.codeToName.get(n);if(o===void 0)throw new Error(`Unsupported multicodec: ${n}`);return{code:n,data:t.slice(i),name:o}}};L.codeToName=new Map;L.nameToCode=new Map;L.registerCodec({code:237,name:"ed25519-pub"});L.registerCodec({code:4864,name:"ed25519-priv"});L.registerCodec({code:236,name:"x25519-pub"});L.registerCodec({code:4866,name:"x25519-priv"});L.registerCodec({code:231,name:"secp256k1-pub"});L.registerCodec({code:4865,name:"secp256k1-priv"});function Sn(r){Object.keys(r).forEach(e=>{r[e]===void 0?delete r[e]:typeof r[e]=="object"&&Sn(r[e])})}var Ef=Ji(Ds(),1);function Af(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Ii(r,...e){if(!Af(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${r.length}`)}function Ui(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function Ms(r,e){Ii(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var Gr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),oe=(r,e)=>r<<32-e|r>>>e;var Zh=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function _f(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Oi(r){return typeof r=="string"&&(r=_f(r)),Ii(r),r}var Jr=class{clone(){return this._cloneInto()}},Qh={}.toString;function Ns(r){let e=n=>r().update(Oi(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Tf(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(t>>i&o),c=Number(t&o),u=n?4:0,a=n?0:4;r.setUint32(e+u,s,n),r.setUint32(e+a,c,n)}var Ls=(r,e,t)=>r&e^~r&t,Fs=(r,e,t)=>r&e^r&t^e&t,zr=class extends Jr{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Gr(this.buffer)}update(e){Ui(this);let{view:t,buffer:n,blockLen:i}=this;e=Oi(e);let o=e.length;for(let s=0;s<o;){let c=Math.min(i-this.pos,o-s);if(c===i){let u=Gr(e);for(;i<=o-s;s+=i)this.process(u,s);continue}n.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){Ui(this),Ms(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let f=s;f<i;f++)t[f]=0;Tf(n,i-8,BigInt(this.length*8),o),this.process(n,0);let c=Gr(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let a=u/4,d=this.get();if(a>d.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<a;f++)c.setUint32(4*f,d[f],o)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,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(n),e}};var Bf=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]),$e=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ve=new Uint32Array(64),Ki=class extends zr{constructor(){super(64,32,8,!1),this.A=$e[0]|0,this.B=$e[1]|0,this.C=$e[2]|0,this.D=$e[3]|0,this.E=$e[4]|0,this.F=$e[5]|0,this.G=$e[6]|0,this.H=$e[7]|0}get(){let{A:e,B:t,C:n,D:i,E:o,F:s,G:c,H:u}=this;return[e,t,n,i,o,s,c,u]}set(e,t,n,i,o,s,c,u){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=c|0,this.H=u|0}process(e,t){for(let f=0;f<16;f++,t+=4)Ve[f]=e.getUint32(t,!1);for(let f=16;f<64;f++){let m=Ve[f-15],g=Ve[f-2],w=oe(m,7)^oe(m,18)^m>>>3,b=oe(g,17)^oe(g,19)^g>>>10;Ve[f]=b+Ve[f-7]+w+Ve[f-16]|0}let{A:n,B:i,C:o,D:s,E:c,F:u,G:a,H:d}=this;for(let f=0;f<64;f++){let m=oe(c,6)^oe(c,11)^oe(c,25),g=d+m+Ls(c,u,a)+Bf[f]+Ve[f]|0,b=(oe(n,2)^oe(n,13)^oe(n,22))+Fs(n,i,o)|0;d=a,a=u,u=c,c=s+g|0,s=o,o=i,i=n,n=g+b|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,c=c+this.E|0,u=u+this.F|0,a=a+this.G|0,d=d+this.H|0,this.set(n,i,o,s,c,u,a,d)}roundClean(){Ve.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Rs=Ns(()=>new Ki);function $s(r){let e=n=>{if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let i=Object.keys(n).sort(),o={};for(let s of i)o[s]=e(n[s]);return o}return n},t=e(r);return JSON.stringify(t)}var Sf=function(r,e,t,n){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function c(d){try{a(n.next(d))}catch(f){s(f)}}function u(d){try{a(n.throw(d))}catch(f){s(f)}}function a(d){d.done?o(d.value):i(d.value).then(c,u)}a((n=n.apply(r,e||[])).next())})},sr=class{static digest(e){return Sf(this,arguments,void 0,function*({data:t}){return Rs(t)})}};var kf=function(r,e,t,n){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function c(d){try{a(n.next(d))}catch(f){s(f)}}function u(d){try{a(n.throw(d))}catch(f){s(f)}}function a(d){d.done?o(d.value):i(d.value).then(c,u)}a((n=n.apply(r,e||[])).next())})};function V(r){return kf(this,arguments,void 0,function*({jwk:e}){let t=e.kty,n;if(t==="EC")n={crv:e.crv,kty:e.kty,x:e.x,y:e.y};else if(t==="oct")n={k:e.k,kty:e.kty};else if(t==="OKP")n={crv:e.crv,kty:e.kty,x:e.x};else if(t==="RSA")n={e:e.e,kty:e.kty,n:e.n};else throw new Error(`Unsupported key type: ${t}`);Sn(n);let i=$s(n),o=T.string(i).toUint8Array(),s=yield sr.digest({data:o});return T.uint8Array(s).toBase64Url()})}var Of=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Hs(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(e==="string"||e==="number"||e==="bigint"||e==="symbol")return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(r instanceof Uint8Array)return"Uint8Array";if(r.constructor===Object)return"Object";let t=Kf(r);return t||"Object"}function Kf(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(Of.includes(e))return e}var h=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}static equals(e,t){return e===t||e.major===t.major&&e.name===t.name}};h.uint=new h(0,"uint",!0);h.negint=new h(1,"negint",!0);h.bytes=new h(2,"bytes",!0);h.string=new h(3,"string",!0);h.array=new h(4,"array",!1);h.map=new h(5,"map",!1);h.tag=new h(6,"tag",!1);h.float=new h(7,"float",!0);h.false=new h(7,"false",!0);h.true=new h(7,"true",!0);h.null=new h(7,"null",!0);h.undefined=new h(7,"undefined",!0);h.break=new h(7,"break",!0);var y=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var cr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Cf=new TextEncoder;function Wr(r){return cr&&globalThis.Buffer.isBuffer(r)}function Xr(r){return r instanceof Uint8Array?Wr(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Pf=24,Df=200,Pi=cr?r=>r.length>=Pf?globalThis.Buffer.from(r):Js(r):r=>r.length>=Df?Cf.encode(r):Js(r),me=r=>Uint8Array.from(r),Gs=cr?(r,e,t)=>Wr(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),zs=cr?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),Xr(globalThis.Buffer.concat(r,e))):(r,e)=>{let t=new Uint8Array(e),n=0;for(let i of r)n+i.length>t.length&&(i=i.subarray(0,t.length-n)),t.set(i,n),n+=i.length;return t},Ws=cr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Yr(r,e){if(Wr(r)&&Wr(e))return r.compare(e);for(let t=0;t<r.length;t++)if(r[t]!==e[t])return r[t]<e[t]?-1:1;return 0}function Js(r){let e=[],t=0;for(let n=0;n<r.length;n++){let i=r.charCodeAt(n);i<128?e[t++]=i:i<2048?(e[t++]=i>>6|192,e[t++]=i&63|128):(i&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(i=65536+((i&1023)<<10)+(r.charCodeAt(++n)&1023),e[t++]=i>>18|240,e[t++]=i>>12&63|128,e[t++]=i>>6&63|128,e[t++]=i&63|128):(i>=55296&&i<=57343&&(i=65533),e[t++]=i>>12|224,e[t++]=i>>6&63|128,e[t++]=i&63|128)}return e}var Mf=256,ur=class{constructor(e=Mf){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let i=t.length-(this.maxCursor-this.cursor)-1;t.set(e,i)}else{if(t){let i=t.length-(this.maxCursor-this.cursor)-1;i<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,i),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=Ws(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=Gs(n,0,this.cursor)}else t=zs(this.chunks,this.cursor);return e&&this.reset(),t}},Zr=class{constructor(e){this.dest=e,this.cursor=0,this.chunks=[e]}reset(){this.cursor=0}push(e){if(this.cursor+e.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(e,this.cursor),this.cursor+=e.length}toBytes(e=!1){let t=this.dest.subarray(0,this.cursor);return e&&this.reset(),t}};var A="CBOR decode error:",Di="CBOR encode error:",ar=[];ar[23]=1;ar[24]=2;ar[25]=3;ar[26]=5;ar[27]=9;function Ie(r,e,t){if(r.length-e<t)throw new Error(`${A} not enough data for type`)}var S=[24,256,65536,4294967296,BigInt("18446744073709551616")];function j(r,e,t){Ie(r,e,1);let n=r[e];if(t.strict===!0&&n<S[0])throw new Error(`${A} integer encoded in more bytes than necessary (strict decode)`);return n}function q(r,e,t){Ie(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<S[1])throw new Error(`${A} integer encoded in more bytes than necessary (strict decode)`);return n}function H(r,e,t){Ie(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<S[2])throw new Error(`${A} integer encoded in more bytes than necessary (strict decode)`);return n}function J(r,e,t){Ie(r,e,8);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3],i=r[e+4]*16777216+(r[e+5]<<16)+(r[e+6]<<8)+r[e+7],o=(BigInt(n)<<BigInt(32))+BigInt(i);if(t.strict===!0&&o<S[3])throw new Error(`${A} integer encoded in more bytes than necessary (strict decode)`);if(o<=Number.MAX_SAFE_INTEGER)return Number(o);if(t.allowBigInt===!0)return o;throw new Error(`${A} integers outside of the safe integer range are not supported`)}function Xs(r,e,t,n){return new y(h.uint,j(r,e+1,n),2)}function Ys(r,e,t,n){return new y(h.uint,q(r,e+1,n),3)}function Zs(r,e,t,n){return new y(h.uint,H(r,e+1,n),5)}function Qs(r,e,t,n){return new y(h.uint,J(r,e+1,n),9)}function Z(r,e){return k(r,0,e.value)}function k(r,e,t){if(t<S[0]){let n=Number(t);r.push([e|n])}else if(t<S[1]){let n=Number(t);r.push([e|24,n])}else if(t<S[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<S[3]){let n=Number(t);r.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(n<S[4]){let i=[e|27,0,0,0,0,0,0,0],o=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));i[8]=o&255,o=o>>8,i[7]=o&255,o=o>>8,i[6]=o&255,o=o>>8,i[5]=o&255,i[4]=s&255,s=s>>8,i[3]=s&255,s=s>>8,i[2]=s&255,s=s>>8,i[1]=s&255,r.push(i)}else throw new Error(`${A} encountered BigInt larger than allowable range`)}}Z.encodedSize=function(e){return k.encodedSize(e.value)};k.encodedSize=function(e){return e<S[0]?1:e<S[1]?2:e<S[2]?3:e<S[3]?5:9};Z.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function ec(r,e,t,n){return new y(h.negint,-1-j(r,e+1,n),2)}function tc(r,e,t,n){return new y(h.negint,-1-q(r,e+1,n),3)}function rc(r,e,t,n){return new y(h.negint,-1-H(r,e+1,n),5)}var Mi=BigInt(-1),nc=BigInt(1);function ic(r,e,t,n){let i=J(r,e+1,n);if(typeof i!="bigint"){let o=-1-i;if(o>=Number.MIN_SAFE_INTEGER)return new y(h.negint,o,9)}if(n.allowBigInt!==!0)throw new Error(`${A} integers outside of the safe integer range are not supported`);return new y(h.negint,Mi-BigInt(i),9)}function Qr(r,e){let t=e.value,n=typeof t=="bigint"?t*Mi-nc:t*-1-1;k(r,e.type.majorEncoded,n)}Qr.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*Mi-nc:t*-1-1;return n<S[0]?1:n<S[1]?2:n<S[2]?3:n<S[3]?5:9};Qr.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function fr(r,e,t,n){Ie(r,e,t+n);let i=r.slice(e+t,e+t+n);return new y(h.bytes,i,t+n)}function oc(r,e,t,n){return fr(r,e,1,t)}function sc(r,e,t,n){return fr(r,e,2,j(r,e+1,n))}function cc(r,e,t,n){return fr(r,e,3,q(r,e+1,n))}function uc(r,e,t,n){return fr(r,e,5,H(r,e+1,n))}function ac(r,e,t,n){let i=J(r,e+1,n);if(typeof i=="bigint")throw new Error(`${A} 64-bit integer bytes lengths not supported`);return fr(r,e,9,i)}function en(r){return r.encodedBytes===void 0&&(r.encodedBytes=h.equals(r.type,h.string)?Pi(r.value):r.value),r.encodedBytes}function Ut(r,e){let t=en(e);k(r,e.type.majorEncoded,t.length),r.push(t)}Ut.encodedSize=function(e){let t=en(e);return k.encodedSize(t.length)+t.length};Ut.compareTokens=function(e,t){return Lf(en(e),en(t))};function Lf(r,e){return r.length<e.length?-1:r.length>e.length?1:Yr(r,e)}var fc=new TextDecoder,Rf=32;function $f(r,e,t){if(t-e<Rf){let i="";for(let o=e;o<t;o++){let s=r[o];if(s&128)return fc.decode(r.subarray(e,t));i+=String.fromCharCode(s)}return i}return fc.decode(r.subarray(e,t))}function dr(r,e,t,n,i){let o=t+n;Ie(r,e,o);let s=new y(h.string,$f(r,e+t,e+o),o);return i.retainStringBytes===!0&&(s.byteValue=r.slice(e+t,e+o)),s}function dc(r,e,t,n){return dr(r,e,1,t,n)}function hc(r,e,t,n){return dr(r,e,2,j(r,e+1,n),n)}function lc(r,e,t,n){return dr(r,e,3,q(r,e+1,n),n)}function pc(r,e,t,n){return dr(r,e,5,H(r,e+1,n),n)}function yc(r,e,t,n){let i=J(r,e+1,n);if(typeof i=="bigint")throw new Error(`${A} 64-bit integer string lengths not supported`);return dr(r,e,9,i,n)}var mc=Ut;function Ot(r,e,t,n){return new y(h.array,n,t)}function gc(r,e,t,n){return Ot(r,e,1,t)}function wc(r,e,t,n){return Ot(r,e,2,j(r,e+1,n))}function xc(r,e,t,n){return Ot(r,e,3,q(r,e+1,n))}function vc(r,e,t,n){return Ot(r,e,5,H(r,e+1,n))}function bc(r,e,t,n){let i=J(r,e+1,n);if(typeof i=="bigint")throw new Error(`${A} 64-bit integer array lengths not supported`);return Ot(r,e,9,i)}function Ec(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${A} indefinite length items not allowed`);return Ot(r,e,1,1/0)}function tn(r,e){k(r,h.array.majorEncoded,e.value)}tn.compareTokens=Z.compareTokens;tn.encodedSize=function(e){return k.encodedSize(e.value)};function Kt(r,e,t,n){return new y(h.map,n,t)}function Ac(r,e,t,n){return Kt(r,e,1,t)}function _c(r,e,t,n){return Kt(r,e,2,j(r,e+1,n))}function Tc(r,e,t,n){return Kt(r,e,3,q(r,e+1,n))}function Bc(r,e,t,n){return Kt(r,e,5,H(r,e+1,n))}function Sc(r,e,t,n){let i=J(r,e+1,n);if(typeof i=="bigint")throw new Error(`${A} 64-bit integer map lengths not supported`);return Kt(r,e,9,i)}function kc(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${A} indefinite length items not allowed`);return Kt(r,e,1,1/0)}function rn(r,e){k(r,h.map.majorEncoded,e.value)}rn.compareTokens=Z.compareTokens;rn.encodedSize=function(e){return k.encodedSize(e.value)};function Ic(r,e,t,n){return new y(h.tag,t,1)}function Uc(r,e,t,n){return new y(h.tag,j(r,e+1,n),2)}function Oc(r,e,t,n){return new y(h.tag,q(r,e+1,n),3)}function Kc(r,e,t,n){return new y(h.tag,H(r,e+1,n),5)}function Cc(r,e,t,n){return new y(h.tag,J(r,e+1,n),9)}function nn(r,e){k(r,h.tag.majorEncoded,e.value)}nn.compareTokens=Z.compareTokens;nn.encodedSize=function(e){return k.encodedSize(e.value)};var Ni=20,Li=21,Fi=22,Ri=23;function Pc(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${A} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new y(h.null,null,1):new y(h.undefined,void 0,1)}function Dc(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${A} indefinite length items not allowed`);return new y(h.break,void 0,1)}function $i(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${A} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${A} Infinity values are not supported`)}return new y(h.float,r,e)}function Mc(r,e,t,n){return $i(Vi(r,e+1),3,n)}function Nc(r,e,t,n){return $i(ji(r,e+1),5,n)}function Lc(r,e,t,n){return $i(Vc(r,e+1),9,n)}function on(r,e,t){let n=e.value;if(n===!1)r.push([h.float.majorEncoded|Ni]);else if(n===!0)r.push([h.float.majorEncoded|Li]);else if(n===null)r.push([h.float.majorEncoded|Fi]);else if(n===void 0)r.push([h.float.majorEncoded|Ri]);else{let i,o=!1;(!t||t.float64!==!0)&&(Rc(n),i=Vi(se,1),n===i||Number.isNaN(n)?(se[0]=249,r.push(se.slice(0,3)),o=!0):($c(n),i=ji(se,1),n===i&&(se[0]=250,r.push(se.slice(0,5)),o=!0))),o||(Jf(n),i=Vc(se,1),se[0]=251,r.push(se.slice(0,9)))}}on.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){Rc(n);let i=Vi(se,1);if(n===i||Number.isNaN(n))return 3;if($c(n),i=ji(se,1),n===i)return 5}return 9};var Fc=new ArrayBuffer(9),Q=new DataView(Fc,1),se=new Uint8Array(Fc,0);function Rc(r){if(r===1/0)Q.setUint16(0,31744,!1);else if(r===-1/0)Q.setUint16(0,64512,!1);else if(Number.isNaN(r))Q.setUint16(0,32256,!1);else{Q.setFloat32(0,r);let e=Q.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)Q.setUint16(0,31744,!1);else if(t===0)Q.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let i=t-127;i<-24?Q.setUint16(0,0):i<-14?Q.setUint16(0,(e&2147483648)>>16|1<<24+i,!1):Q.setUint16(0,(e&2147483648)>>16|i+15<<10|n>>13,!1)}}}function Vi(r,e){if(r.length-e<2)throw new Error(`${A} not enough data for float16`);let t=(r[e]<<8)+r[e+1];if(t===31744)return 1/0;if(t===64512)return-1/0;if(t===32256)return NaN;let n=t>>10&31,i=t&1023,o;return n===0?o=i*2**-24:n!==31?o=(i+1024)*2**(n-25):o=i===0?1/0:NaN,t&32768?-o:o}function $c(r){Q.setFloat32(0,r,!1)}function ji(r,e){if(r.length-e<4)throw new Error(`${A} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function Jf(r){Q.setFloat64(0,r,!1)}function Vc(r,e){if(r.length-e<8)throw new Error(`${A} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}on.compareTokens=Z.compareTokens;function _(r,e,t){throw new Error(`${A} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function sn(r){return()=>{throw new Error(`${A} ${r}`)}}var p=[];for(let r=0;r<=23;r++)p[r]=_;p[24]=Xs;p[25]=Ys;p[26]=Zs;p[27]=Qs;p[28]=_;p[29]=_;p[30]=_;p[31]=_;for(let r=32;r<=55;r++)p[r]=_;p[56]=ec;p[57]=tc;p[58]=rc;p[59]=ic;p[60]=_;p[61]=_;p[62]=_;p[63]=_;for(let r=64;r<=87;r++)p[r]=oc;p[88]=sc;p[89]=cc;p[90]=uc;p[91]=ac;p[92]=_;p[93]=_;p[94]=_;p[95]=sn("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)p[r]=dc;p[120]=hc;p[121]=lc;p[122]=pc;p[123]=yc;p[124]=_;p[125]=_;p[126]=_;p[127]=sn("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)p[r]=gc;p[152]=wc;p[153]=xc;p[154]=vc;p[155]=bc;p[156]=_;p[157]=_;p[158]=_;p[159]=Ec;for(let r=160;r<=183;r++)p[r]=Ac;p[184]=_c;p[185]=Tc;p[186]=Bc;p[187]=Sc;p[188]=_;p[189]=_;p[190]=_;p[191]=kc;for(let r=192;r<=215;r++)p[r]=Ic;p[216]=Uc;p[217]=Oc;p[218]=Kc;p[219]=Cc;p[220]=_;p[221]=_;p[222]=_;p[223]=_;for(let r=224;r<=243;r++)p[r]=sn("simple values are not supported");p[244]=_;p[245]=_;p[246]=_;p[247]=Pc;p[248]=sn("simple values are not supported");p[249]=Mc;p[250]=Nc;p[251]=Lc;p[252]=_;p[253]=_;p[254]=_;p[255]=Dc;var ge=[];for(let r=0;r<24;r++)ge[r]=new y(h.uint,r,1);for(let r=-1;r>=-24;r--)ge[31-r]=new y(h.negint,r,1);ge[64]=new y(h.bytes,new Uint8Array(0),1);ge[96]=new y(h.string,"",1);ge[128]=new y(h.array,0,1);ge[160]=new y(h.map,0,1);ge[244]=new y(h.false,!1,1);ge[245]=new y(h.true,!0,1);ge[246]=new y(h.null,null,1);function jc(r){switch(r.type){case h.false:return me([244]);case h.true:return me([245]);case h.null:return me([246]);case h.bytes:return r.value.length?void 0:me([64]);case h.string:return r.value===""?me([96]):void 0;case h.array:return r.value===0?me([128]):void 0;case h.map:return r.value===0?me([160]):void 0;case h.uint:return r.value<24?me([Number(r.value)]):void 0;case h.negint:if(r.value>=-24)return me([31-Number(r.value)])}}var Hc=Object.freeze({float64:!0,mapSorter:Zf,quickEncodeToken:jc});function zf(){let r=[];return r[h.uint.major]=Z,r[h.negint.major]=Qr,r[h.bytes.major]=Ut,r[h.string.major]=mc,r[h.array.major]=tn,r[h.map.major]=rn,r[h.tag.major]=nn,r[h.float.major]=on,r}var Wf=zf(),Xf=new ur,un=class r{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${Di} object contains circular references`);return new r(t,e)}},qe={null:new y(h.null,null),undefined:new y(h.undefined,void 0),true:new y(h.true,!0),false:new y(h.false,!1),emptyArray:new y(h.array,0),emptyMap:new y(h.map,0)},He={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new y(h.float,r):r>=0?new y(h.uint,r):new y(h.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new y(h.uint,r):new y(h.negint,r)},Uint8Array(r,e,t,n){return new y(h.bytes,r)},string(r,e,t,n){return new y(h.string,r)},boolean(r,e,t,n){return r?qe.true:qe.false},null(r,e,t,n){return qe.null},undefined(r,e,t,n){return qe.undefined},ArrayBuffer(r,e,t,n){return new y(h.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new y(h.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[qe.emptyArray,new y(h.break)]:qe.emptyArray;n=un.createCheck(n,r);let i=[],o=0;for(let s of r)i[o++]=cn(s,t,n);return t.addBreakTokens?[new y(h.array,r.length),i,new y(h.break)]:[new y(h.array,r.length),i]},Object(r,e,t,n){let i=e!=="Object",o=i?r.keys():Object.keys(r),s=i?r.size:o.length,c;if(s){c=new Array(s),n=un.createCheck(n,r);let u=!i&&t.ignoreUndefinedProperties,a=0;for(let d of o){let f=i?r.get(d):r[d];u&&f===void 0||(c[a++]=[cn(d,t,n),cn(f,t,n)])}a<s&&(c.length=a)}return c?.length?(Yf(c,t),t.addBreakTokens?[new y(h.map,c.length),c,new y(h.break)]:[new y(h.map,c.length),c]):t.addBreakTokens===!0?[qe.emptyMap,new y(h.break)]:qe.emptyMap}};He.Map=He.Object;He.Buffer=He.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))He[`${r}Array`]=He.DataView;function cn(r,e={},t){let n=Hs(r),i=e&&e.typeEncoders&&e.typeEncoders[n]||He[n];if(typeof i=="function"){let s=i(r,n,e,t);if(s!=null)return s}let o=He[n];if(!o)throw new Error(`${Di} unsupported type: ${n}`);return o(r,n,e,t)}function Yf(r,e){e.mapSorter&&r.sort(e.mapSorter)}function Zf(r,e){if(r[0]instanceof y&&e[0]instanceof y){let t=r[0],n=e[0];return t._keyBytes||(t._keyBytes=qc(t.value)),n._keyBytes||(n._keyBytes=qc(n.value)),Yr(t._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function qc(r){return Qf(r,Wf,Hc)}function Jc(r,e,t,n){if(Array.isArray(e))for(let i of e)Jc(r,i,t,n);else t[e.type.major](r,e,n)}var Xp=h.uint.majorEncoded,Yp=h.negint.majorEncoded,Zp=h.bytes.majorEncoded,Qp=h.string.majorEncoded,ey=h.array.majorEncoded,ty=h.float.majorEncoded|Ni,ry=h.float.majorEncoded|Li,ny=h.float.majorEncoded|Fi,iy=h.float.majorEncoded|Ri,oy=BigInt(-1),sy=BigInt(1);function Qf(r,e,t,n){let i=n instanceof Uint8Array,o=i?new Zr(n):Xf,s=cn(r,t);if(!Array.isArray(s)&&t.quickEncodeToken){let c=t.quickEncodeToken(s);if(c)return i?(o.push(c),o.toBytes()):c;let u=e[s.type.major];if(u.encodedSize){let a=u.encodedSize(s,t);if(i||(o=new ur(a)),u(o,s,t),o.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return i?o.toBytes():Xr(o.chunks[0])}}return o.reset(),Jc(o,s,e,t),o.toBytes(!0)}var hy=Symbol.for("DONE"),ly=Symbol.for("BREAK");var Gc;(function(r){r[r.OKP=1]="OKP",r[r.EC2=2]="EC2",r[r.Symmetric=4]="Symmetric"})(Gc||(Gc={}));var O;(function(r){r[r.P256=1]="P256",r[r.P384=2]="P384",r[r.P521=3]="P521",r[r.X25519=4]="X25519",r[r.X448=5]="X448",r[r.Ed25519=6]="Ed25519",r[r.Ed448=7]="Ed448",r[r.Secp256k1=8]="Secp256k1"})(O||(O={}));var G;(function(r){r[r.EdDSA=-8]="EdDSA",r[r.ES256=-7]="ES256",r[r.ES384=-35]="ES384",r[r.ES512=-36]="ES512",r[r.ES256K=-47]="ES256K"})(G||(G={}));var zc;(function(r){r[r.Kty=1]="Kty",r[r.Kid=2]="Kid",r[r.Alg=3]="Alg",r[r.KeyOps=4]="KeyOps",r[r.BaseIv=5]="BaseIv"})(zc||(zc={}));var Wc;(function(r){r[r.Crv=-1]="Crv",r[r.X=-2]="X",r[r.Y=-3]="Y",r[r.D=-4]="D"})(Wc||(Wc={}));var Sy={"P-256":O.P256,"P-384":O.P384,"P-521":O.P521,X25519:O.X25519,Ed25519:O.Ed25519,Ed448:O.Ed448,secp256k1:O.Secp256k1},ky={[O.P256]:"P-256",[O.P384]:"P-384",[O.P521]:"P-521",[O.X25519]:"X25519",[O.Ed25519]:"Ed25519",[O.Ed448]:"Ed448",[O.Secp256k1]:"secp256k1"},Iy={EdDSA:G.EdDSA,ES256:G.ES256,ES384:G.ES384,ES512:G.ES512,ES256K:G.ES256K},Uy={[G.EdDSA]:"EdDSA",[G.ES256]:"ES256",[G.ES384]:"ES384",[G.ES512]:"ES512",[G.ES256K]:"ES256K"};var Xc;(function(r){r[r.Alg=1]="Alg",r[r.Crit=2]="Crit",r[r.ContentType=3]="ContentType",r[r.Kid=4]="Kid"})(Xc||(Xc={}));var Yc;(function(r){r[r.Iss=1]="Iss",r[r.Sub=2]="Sub",r[r.Aud=3]="Aud",r[r.Exp=4]="Exp",r[r.Nbf=5]="Nbf",r[r.Iat=6]="Iat",r[r.Cti=7]="Cti",r[r.Nonce=10]="Nonce",r[r.Ueid=256]="Ueid",r[r.Sueids=257]="Sueids",r[r.Oemid=258]="Oemid",r[r.Hwmodel=259]="Hwmodel",r[r.Hwversion=260]="Hwversion",r[r.Secboot=262]="Secboot",r[r.Dbgstat=263]="Dbgstat",r[r.Location=264]="Location",r[r.Profile=265]="Profile",r[r.Submods=266]="Submods",r[r.Measres=272]="Measres",r[r.Intuse=268]="Intuse"})(Yc||(Yc={}));var Zc;(function(r){r[r.Enabled=0]="Enabled",r[r.Disabled=1]="Disabled",r[r.DisabledSinceBoot=2]="DisabledSinceBoot",r[r.DisabledPermanently=3]="DisabledPermanently",r[r.DisabledFullyAndPermanently=4]="DisabledFullyAndPermanently"})(Zc||(Zc={}));var Qc;(function(r){r[r.Unrestricted=1]="Unrestricted",r[r.Restricted=2]="Restricted",r[r.SecureRestricted=3]="SecureRestricted",r[r.Hardware=4]="Hardware"})(Qc||(Qc={}));var fn=(o=>(o.authentication="authentication",o.assertionMethod="assertionMethod",o.keyAgreement="keyAgreement",o.capabilityInvocation="capabilityInvocation",o.capabilityDelegation="capabilityDelegation",o))(fn||{});var dn=class r extends Error{constructor(t,n){super(`${t}: ${n}`);this.code=t;this.name="DidError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,r)}};function qi(r){if(typeof r=="string"&&r.length!==0)return r.split("#").pop()}function Eg({didDocument:r,id:e,type:t}){return r?.service?.filter(n=>!(e&&n.id!==e||t&&n.type!==t))??[]}async function Ag({didDocument:r,publicKeyJwk:e,publicKeyMultibase:t}){let n=eu({didDocument:r});for(let i of n)if(e&&i.publicKeyJwk){if(await V({jwk:e})===await V({jwk:i.publicKeyJwk}))return i}else if(t&&i.publicKeyMultibase&&t===i.publicKeyMultibase)return i;return null}function eu({didDocument:r}){if(!r)throw new TypeError("Required parameter missing: 'didDocument'");let e=[];return e.push(...r.verificationMethod?.filter(Hi)??[]),Object.keys(fn).forEach(t=>{e.push(...r[t]?.filter(Hi)??[])}),e}function _g({didDocument:r}){let t=eu({didDocument:r}).map(n=>n.type);return[...new Set(t)]}function Tg({didDocument:r,methodId:e}){let t=[];return Object.keys(fn).forEach(n=>{if(Array.isArray(r[n])){let i=r[n],o=qi(e);i.some(c=>{let u=qi(c)===o,a=Hi(c)&&qi(c.id)===o;return u||a})&&t.push(n)}}),t}function nd(r){return!r||typeof r!="object"||r===null?!1:"id"in r&&"type"in r&&"serviceEndpoint"in r}function Bg(r){if(!nd(r)||r.type!=="DecentralizedWebNode")return!1;let e=t=>typeof t=="string"||Array.isArray(t)&&t.every(n=>typeof n=="string");return!("enc"in r&&r.enc!==void 0&&!e(r.enc)||"sig"in r&&r.sig!==void 0&&!e(r.sig))}function Hi(r){return!(!r||typeof r!="object"||r===null||!("id"in r&&"type"in r&&"controller"in r)||typeof r.id!="string"||typeof r.type!="string"||typeof r.controller!="string")}function Sg(r){return!(!r||typeof r!="object"||r===null)&&"uri"in r&&"document"in r&&"metadata"in r&&(!("keyManager"in r)||r.keyManager===void 0)}function kg({keyBytes:r,multicodecCode:e,multicodecName:t}){let n=L.addPrefix({code:e,data:r,name:t}),i=T.uint8Array(n).toBase58Btc();return T.base58Btc(i).toMultibase()}function Ig({multibaseKeyId:r}){try{let e=T.multibase(r).toBase58Btc(),t=T.base58Btc(e).toUint8Array(),{code:n,data:i,name:o}=L.removePrefix({prefixedData:t});return{keyBytes:i,multicodecCode:n,multicodecName:o}}catch{throw new dn("invalidDid",`Invalid multibase identifier: ${r}`)}}export{qi as extractDidFragment,Eg as getServices,Ag as getVerificationMethodByKey,_g as getVerificationMethodTypes,eu as getVerificationMethods,Tg as getVerificationRelationshipsById,nd as isDidService,Hi as isDidVerificationMethod,Bg as isDwnDidService,Sg as isPortableDid,kg as keyBytesToMultibaseId,Ig as multibaseIdToKeyBytes};
1
+ var tu=Object.create;var hn=Object.defineProperty;var ru=Object.getOwnPropertyDescriptor;var nu=Object.getOwnPropertyNames;var iu=Object.getPrototypeOf,ou=Object.prototype.hasOwnProperty;var E=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),su=(r,e)=>{for(var t in e)hn(r,t,{get:e[t],enumerable:!0})},cu=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of nu(e))!ou.call(r,i)&&i!==t&&hn(r,i,{get:()=>e[i],enumerable:!(n=ru(e,i))||n.enumerable});return r};var Ji=(r,e,t)=>(t=r!=null?tu(iu(r)):{},cu(e||!r||!r.__esModule?hn(t,"default",{value:r,enumerable:!0}):t,r));var zi=E((sd,Gi)=>{var uu=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,lr=()=>uu.now(),au=r=>r&&r===Math.floor(r)&&r>0&&isFinite(r),ln=r=>r===1/0||au(r),pn=class r{constructor({max:e=1/0,ttl:t,updateAgeOnGet:n=!1,checkAgeOnGet:i=!1,noUpdateTTL:o=!1,dispose:s,noDisposeOnSet:c=!1}={}){if(this.expirations=Object.create(null),this.data=new Map,this.expirationMap=new Map,t!==void 0&&!ln(t))throw new TypeError("ttl must be positive integer or Infinity if set");if(!ln(e))throw new TypeError("max must be positive integer or Infinity");if(this.ttl=t,this.max=e,this.updateAgeOnGet=!!n,this.checkAgeOnGet=!!i,this.noUpdateTTL=!!o,this.noDisposeOnSet=!!c,s!==void 0){if(typeof s!="function")throw new TypeError("dispose must be function if set");this.dispose=s}this.timer=void 0,this.timerExpiration=void 0}setTimer(e,t){if(this.timerExpiration<e)return;this.timer&&clearTimeout(this.timer);let n=setTimeout(()=>{this.timer=void 0,this.timerExpiration=void 0,this.purgeStale();for(let i in this.expirations){this.setTimer(i,i-lr());break}},t);n.unref&&n.unref(),this.timerExpiration=e,this.timer=n}cancelTimer(){this.timer&&(clearTimeout(this.timer),this.timerExpiration=void 0,this.timer=void 0)}cancelTimers(){return process.emitWarning('TTLCache.cancelTimers has been renamed to TTLCache.cancelTimer (no "s"), and will be removed in the next major version update'),this.cancelTimer()}clear(){let e=this.dispose!==r.prototype.dispose?[...this]:[];this.data.clear(),this.expirationMap.clear(),this.cancelTimer(),this.expirations=Object.create(null);for(let[t,n]of e)this.dispose(n,t,"delete")}setTTL(e,t=this.ttl){let n=this.expirationMap.get(e);if(n!==void 0){let i=this.expirations[n];!i||i.length<=1?delete this.expirations[n]:this.expirations[n]=i.filter(o=>o!==e)}if(t!==1/0){let i=Math.floor(lr()+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:n=this.ttl,noUpdateTTL:i=this.noUpdateTTL,noDisposeOnSet:o=this.noDisposeOnSet}={}){if(!ln(n))throw new TypeError("ttl must be positive integer or Infinity");if(this.expirationMap.has(e)){i||this.setTTL(e,n);let s=this.data.get(e);s!==t&&(this.data.set(e,t),o||this.dispose(s,e,"set"))}else this.setTTL(e,n),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-lr())):0}get(e,{updateAgeOnGet:t=this.updateAgeOnGet,ttl:n=this.ttl,checkAgeOnGet:i=this.checkAgeOnGet}={}){let o=this.data.get(e);if(i&&this.getRemainingTTL(e)===0){this.delete(e);return}return t&&this.setTTL(e,n),o}dispose(e,t){}delete(e){let t=this.expirationMap.get(e);if(t!==void 0){let n=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(n,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 n=[];for(let i of t)n.push([i,this.data.get(i)]),this.data.delete(i),this.expirationMap.delete(i);for(let[i,o]of n)this.dispose(o,i,"evict")}else{let n=this.size-this.max,i=[];for(let o of t.splice(0,n))i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"evict");return}}}get size(){return this.data.size}purgeStale(){let e=Math.ceil(lr());for(let t in this.expirations){if(t==="Infinity"||t>e)return;let n=[...this.expirations[t]||[]],i=[];delete this.expirations[t];for(let o of n)i.push([o,this.data.get(o)]),this.data.delete(o),this.expirationMap.delete(o);for(let[o,s]of i)this.dispose(s,o,"stale")}this.size===0&&this.cancelTimer()}*entries(){for(let e in this.expirations)for(let 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()}};Gi.exports=pn});var ho=E(fo=>{"use strict";fo.supports=function(...e){let t=e.reduce((n,i)=>Object.assign(n,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 re=E((ih,lo)=>{"use strict";lo.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 mo=E(mr=>{"use strict";mr.byteLength=ju;mr.toByteArray=Hu;mr.fromByteArray=zu;var de=[],W=[],Vu=typeof Uint8Array<"u"?Uint8Array:Array,kn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(We=0,po=kn.length;We<po;++We)de[We]=kn[We],W[kn.charCodeAt(We)]=We;var We,po;W[45]=62;W[95]=63;function yo(r){var e=r.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");t===-1&&(t=e);var n=t===e?0:4-t%4;return[t,n]}function ju(r){var e=yo(r),t=e[0],n=e[1];return(t+n)*3/4-n}function qu(r,e,t){return(e+t)*3/4-t}function Hu(r){var e,t=yo(r),n=t[0],i=t[1],o=new Vu(qu(r,n,i)),s=0,c=i>0?n-4:n,u;for(u=0;u<c;u+=4)e=W[r.charCodeAt(u)]<<18|W[r.charCodeAt(u+1)]<<12|W[r.charCodeAt(u+2)]<<6|W[r.charCodeAt(u+3)],o[s++]=e>>16&255,o[s++]=e>>8&255,o[s++]=e&255;return i===2&&(e=W[r.charCodeAt(u)]<<2|W[r.charCodeAt(u+1)]>>4,o[s++]=e&255),i===1&&(e=W[r.charCodeAt(u)]<<10|W[r.charCodeAt(u+1)]<<4|W[r.charCodeAt(u+2)]>>2,o[s++]=e>>8&255,o[s++]=e&255),o}function Ju(r){return de[r>>18&63]+de[r>>12&63]+de[r>>6&63]+de[r&63]}function Gu(r,e,t){for(var n,i=[],o=e;o<t;o+=3)n=(r[o]<<16&16711680)+(r[o+1]<<8&65280)+(r[o+2]&255),i.push(Ju(n));return i.join("")}function zu(r){for(var e,t=r.length,n=t%3,i=[],o=16383,s=0,c=t-n;s<c;s+=o)i.push(Gu(r,s,s+o>c?c:s+o));return n===1?(e=r[t-1],i.push(de[e>>2]+de[e<<4&63]+"==")):n===2&&(e=(r[t-2]<<8)+r[t-1],i.push(de[e>>10]+de[e>>4&63]+de[e<<2&63]+"=")),i.join("")}});var go=E(In=>{In.read=function(r,e,t,n,i){var o,s,c=i*8-n-1,u=(1<<c)-1,a=u>>1,d=-7,f=t?i-1:0,m=t?-1:1,g=r[e+f];for(f+=m,o=g&(1<<-d)-1,g>>=-d,d+=c;d>0;o=o*256+r[e+f],f+=m,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=n;d>0;s=s*256+r[e+f],f+=m,d-=8);if(o===0)o=1-a;else{if(o===u)return s?NaN:(g?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-a}return(g?-1:1)*s*Math.pow(2,o-n)};In.write=function(r,e,t,n,i,o){var s,c,u,a=o*8-i-1,d=(1<<a)-1,f=d>>1,m=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=n?0:o-1,w=n?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=d):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),s+f>=1?e+=m/u:e+=m*Math.pow(2,1-f),e*u>=2&&(s++,u/=2),s+f>=d?(c=0,s=d):s+f>=1?(c=(e*u-1)*Math.pow(2,i),s=s+f):(c=e*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;r[t+g]=c&255,g+=w,c/=256,i-=8);for(s=s<<i|c,a+=i;a>0;r[t+g]=s&255,g+=w,s/=256,a-=8);r[t+g-w]|=b*128}});var xr=E(wt=>{"use strict";var Un=mo(),mt=go(),wo=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;wt.Buffer=l;wt.SlowBuffer=ea;wt.INSPECT_MAX_BYTES=50;var gr=2147483647;wt.kMaxLength=gr;l.TYPED_ARRAY_SUPPORT=Wu();!l.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 Wu(){try{let r=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(r,e),r.foo()===42}catch{return!1}}Object.defineProperty(l.prototype,"parent",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.buffer}});Object.defineProperty(l.prototype,"offset",{enumerable:!0,get:function(){if(l.isBuffer(this))return this.byteOffset}});function be(r){if(r>gr)throw new RangeError('The value "'+r+'" is invalid for option "size"');let e=new Uint8Array(r);return Object.setPrototypeOf(e,l.prototype),e}function l(r,e,t){if(typeof r=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Pn(r)}return Eo(r,e,t)}l.poolSize=8192;function Eo(r,e,t){if(typeof r=="string")return Yu(r,e);if(ArrayBuffer.isView(r))return Zu(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(he(r,ArrayBuffer)||r&&he(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(he(r,SharedArrayBuffer)||r&&he(r.buffer,SharedArrayBuffer)))return Kn(r,e,t);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return l.from(n,e,t);let i=Qu(r);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return l.from(r[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 r)}l.from=function(r,e,t){return Eo(r,e,t)};Object.setPrototypeOf(l.prototype,Uint8Array.prototype);Object.setPrototypeOf(l,Uint8Array);function Ao(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function Xu(r,e,t){return Ao(r),r<=0?be(r):e!==void 0?typeof t=="string"?be(r).fill(e,t):be(r).fill(e):be(r)}l.alloc=function(r,e,t){return Xu(r,e,t)};function Pn(r){return Ao(r),be(r<0?0:Dn(r)|0)}l.allocUnsafe=function(r){return Pn(r)};l.allocUnsafeSlow=function(r){return Pn(r)};function Yu(r,e){if((typeof e!="string"||e==="")&&(e="utf8"),!l.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let t=_o(r,e)|0,n=be(t),i=n.write(r,e);return i!==t&&(n=n.slice(0,i)),n}function On(r){let e=r.length<0?0:Dn(r.length)|0,t=be(e);for(let n=0;n<e;n+=1)t[n]=r[n]&255;return t}function Zu(r){if(he(r,Uint8Array)){let e=new Uint8Array(r);return Kn(e.buffer,e.byteOffset,e.byteLength)}return On(r)}function Kn(r,e,t){if(e<0||r.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<e+(t||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&t===void 0?n=new Uint8Array(r):t===void 0?n=new Uint8Array(r,e):n=new Uint8Array(r,e,t),Object.setPrototypeOf(n,l.prototype),n}function Qu(r){if(l.isBuffer(r)){let e=Dn(r.length)|0,t=be(e);return t.length===0||r.copy(t,0,0,e),t}if(r.length!==void 0)return typeof r.length!="number"||Nn(r.length)?be(0):On(r);if(r.type==="Buffer"&&Array.isArray(r.data))return On(r.data)}function Dn(r){if(r>=gr)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+gr.toString(16)+" bytes");return r|0}function ea(r){return+r!=r&&(r=0),l.alloc(+r)}l.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==l.prototype};l.compare=function(e,t){if(he(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),he(t,Uint8Array)&&(t=l.from(t,t.offset,t.byteLength)),!l.isBuffer(e)||!l.isBuffer(t))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;let n=e.length,i=t.length;for(let o=0,s=Math.min(n,i);o<s;++o)if(e[o]!==t[o]){n=e[o],i=t[o];break}return n<i?-1:i<n?1:0};l.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}};l.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return l.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let i=l.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){let s=e[n];if(he(s,Uint8Array))o+s.length>i.length?(l.isBuffer(s)||(s=l.from(s)),s.copy(i,o)):Uint8Array.prototype.set.call(i,s,o);else if(l.isBuffer(s))s.copy(i,o);else throw new TypeError('"list" argument must be an Array of Buffers');o+=s.length}return i};function _o(r,e){if(l.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||he(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let t=r.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&t===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":return Cn(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Co(r).length;default:if(i)return n?-1:Cn(r).length;e=(""+e).toLowerCase(),i=!0}}l.byteLength=_o;function ta(r,e,t){let n=!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(r||(r="utf8");;)switch(r){case"hex":return da(this,e,t);case"utf8":case"utf-8":return Bo(this,e,t);case"ascii":return aa(this,e,t);case"latin1":case"binary":return fa(this,e,t);case"base64":return ca(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ha(this,e,t);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}l.prototype._isBuffer=!0;function Xe(r,e,t){let n=r[e];r[e]=r[t],r[t]=n}l.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)Xe(this,t,t+1);return this};l.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)Xe(this,t,t+3),Xe(this,t+1,t+2);return this};l.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)Xe(this,t,t+7),Xe(this,t+1,t+6),Xe(this,t+2,t+5),Xe(this,t+3,t+4);return this};l.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Bo(this,0,e):ta.apply(this,arguments)};l.prototype.toLocaleString=l.prototype.toString;l.prototype.equals=function(e){if(!l.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:l.compare(this,e)===0};l.prototype.inspect=function(){let e="",t=wt.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"};wo&&(l.prototype[wo]=l.prototype.inspect);l.prototype.compare=function(e,t,n,i,o){if(he(e,Uint8Array)&&(e=l.from(e,e.offset,e.byteLength)),!l.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),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),t<0||n>e.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&t>=n)return 0;if(i>=o)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,i>>>=0,o>>>=0,this===e)return 0;let s=o-i,c=n-t,u=Math.min(s,c),a=this.slice(i,o),d=e.slice(t,n);for(let f=0;f<u;++f)if(a[f]!==d[f]){s=a[f],c=d[f];break}return s<c?-1:c<s?1:0};function To(r,e,t,n,i){if(r.length===0)return-1;if(typeof t=="string"?(n=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,Nn(t)&&(t=i?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(i)return-1;t=r.length-1}else if(t<0)if(i)t=0;else return-1;if(typeof e=="string"&&(e=l.from(e,n)),l.isBuffer(e))return e.length===0?-1:xo(r,e,t,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):xo(r,[e],t,n,i);throw new TypeError("val must be string, number or Buffer")}function xo(r,e,t,n,i){let o=1,s=r.length,c=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||e.length<2)return-1;o=2,s/=2,c/=2,t/=2}function u(d,f){return o===1?d[f]:d.readUInt16BE(f*o)}let a;if(i){let d=-1;for(a=t;a<s;a++)if(u(r,a)===u(e,d===-1?0:a-d)){if(d===-1&&(d=a),a-d+1===c)return d*o}else d!==-1&&(a-=a-d),d=-1}else for(t+c>s&&(t=s-c),a=t;a>=0;a--){let d=!0;for(let f=0;f<c;f++)if(u(r,a+f)!==u(e,f)){d=!1;break}if(d)return a}return-1}l.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1};l.prototype.indexOf=function(e,t,n){return To(this,e,t,n,!0)};l.prototype.lastIndexOf=function(e,t,n){return To(this,e,t,n,!1)};function ra(r,e,t,n){t=Number(t)||0;let i=r.length-t;n?(n=Number(n),n>i&&(n=i)):n=i;let o=e.length;n>o/2&&(n=o/2);let s;for(s=0;s<n;++s){let c=parseInt(e.substr(s*2,2),16);if(Nn(c))return s;r[t+s]=c}return s}function na(r,e,t,n){return wr(Cn(e,r.length-t),r,t,n)}function ia(r,e,t,n){return wr(ma(e),r,t,n)}function oa(r,e,t,n){return wr(Co(e),r,t,n)}function sa(r,e,t,n){return wr(ga(e,r.length-t),r,t,n)}l.prototype.write=function(e,t,n,i){if(t===void 0)i="utf8",n=this.length,t=0;else if(n===void 0&&typeof t=="string")i=t,n=this.length,t=0;else if(isFinite(t))t=t>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let o=this.length-t;if((n===void 0||n>o)&&(n=o),e.length>0&&(n<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 ra(this,e,t,n);case"utf8":case"utf-8":return na(this,e,t,n);case"ascii":case"latin1":case"binary":return ia(this,e,t,n);case"base64":return oa(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return sa(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ca(r,e,t){return e===0&&t===r.length?Un.fromByteArray(r):Un.fromByteArray(r.slice(e,t))}function Bo(r,e,t){t=Math.min(r.length,t);let n=[],i=e;for(;i<t;){let o=r[i],s=null,c=o>239?4:o>223?3:o>191?2:1;if(i+c<=t){let u,a,d,f;switch(c){case 1:o<128&&(s=o);break;case 2:u=r[i+1],(u&192)===128&&(f=(o&31)<<6|u&63,f>127&&(s=f));break;case 3:u=r[i+1],a=r[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=r[i+1],a=r[i+2],d=r[i+3],(u&192)===128&&(a&192)===128&&(d&192)===128&&(f=(o&15)<<18|(u&63)<<12|(a&63)<<6|d&63,f>65535&&f<1114112&&(s=f))}}s===null?(s=65533,c=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=c}return ua(n)}var vo=4096;function ua(r){let e=r.length;if(e<=vo)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=vo));return t}function aa(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]&127);return n}function fa(r,e,t){let n="";t=Math.min(r.length,t);for(let i=e;i<t;++i)n+=String.fromCharCode(r[i]);return n}function da(r,e,t){let n=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>n)&&(t=n);let i="";for(let o=e;o<t;++o)i+=wa[r[o]];return i}function ha(r,e,t){let n=r.slice(e,t),i="";for(let o=0;o<n.length-1;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}l.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let i=this.subarray(e,t);return Object.setPrototypeOf(i,l.prototype),i};function B(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUintLE=l.prototype.readUIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||B(e,t,this.length);let i=this[e],o=1,s=0;for(;++s<t&&(o*=256);)i+=this[e+s]*o;return i};l.prototype.readUintBE=l.prototype.readUIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||B(e,t,this.length);let i=this[e+--t],o=1;for(;t>0&&(o*=256);)i+=this[e+--t]*o;return i};l.prototype.readUint8=l.prototype.readUInt8=function(e,t){return e=e>>>0,t||B(e,1,this.length),this[e]};l.prototype.readUint16LE=l.prototype.readUInt16LE=function(e,t){return e=e>>>0,t||B(e,2,this.length),this[e]|this[e+1]<<8};l.prototype.readUint16BE=l.prototype.readUInt16BE=function(e,t){return e=e>>>0,t||B(e,2,this.length),this[e]<<8|this[e+1]};l.prototype.readUint32LE=l.prototype.readUInt32LE=function(e,t){return e=e>>>0,t||B(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};l.prototype.readUint32BE=l.prototype.readUInt32BE=function(e,t){return e=e>>>0,t||B(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};l.prototype.readBigUInt64LE=Oe(function(e){e=e>>>0,gt(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Lt(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+n*2**24;return BigInt(i)+(BigInt(o)<<BigInt(32))});l.prototype.readBigUInt64BE=Oe(function(e){e=e>>>0,gt(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Lt(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+n;return(BigInt(i)<<BigInt(32))+BigInt(o)});l.prototype.readIntLE=function(e,t,n){e=e>>>0,t=t>>>0,n||B(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};l.prototype.readIntBE=function(e,t,n){e=e>>>0,t=t>>>0,n||B(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};l.prototype.readInt8=function(e,t){return e=e>>>0,t||B(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};l.prototype.readInt16LE=function(e,t){e=e>>>0,t||B(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};l.prototype.readInt16BE=function(e,t){e=e>>>0,t||B(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};l.prototype.readInt32LE=function(e,t){return e=e>>>0,t||B(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};l.prototype.readInt32BE=function(e,t){return e=e>>>0,t||B(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};l.prototype.readBigInt64LE=Oe(function(e){e=e>>>0,gt(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Lt(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(t+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});l.prototype.readBigInt64BE=Oe(function(e){e=e>>>0,gt(e,"offset");let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&Lt(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+n)});l.prototype.readFloatLE=function(e,t){return e=e>>>0,t||B(e,4,this.length),mt.read(this,e,!0,23,4)};l.prototype.readFloatBE=function(e,t){return e=e>>>0,t||B(e,4,this.length),mt.read(this,e,!1,23,4)};l.prototype.readDoubleLE=function(e,t){return e=e>>>0,t||B(e,8,this.length),mt.read(this,e,!0,52,8)};l.prototype.readDoubleBE=function(e,t){return e=e>>>0,t||B(e,8,this.length),mt.read(this,e,!1,52,8)};function M(r,e,t,n,i,o){if(!l.isBuffer(r))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+n>r.length)throw new RangeError("Index out of range")}l.prototype.writeUintLE=l.prototype.writeUIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;M(this,e,t,n,c,0)}let o=1,s=0;for(this[t]=e&255;++s<n&&(o*=256);)this[t+s]=e/o&255;return t+n};l.prototype.writeUintBE=l.prototype.writeUIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;M(this,e,t,n,c,0)}let o=n-1,s=1;for(this[t+o]=e&255;--o>=0&&(s*=256);)this[t+o]=e/s&255;return t+n};l.prototype.writeUint8=l.prototype.writeUInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,255,0),this[t]=e&255,t+1};l.prototype.writeUint16LE=l.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2};l.prototype.writeUint16BE=l.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2};l.prototype.writeUint32LE=l.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(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};l.prototype.writeUint32BE=l.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(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 So(r,e,t,n,i){Ko(e,n,i,r,t,7);let o=Number(e&BigInt(4294967295));r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o,o=o>>8,r[t++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,s=s>>8,r[t++]=s,t}function ko(r,e,t,n,i){Ko(e,n,i,r,t,7);let o=Number(e&BigInt(4294967295));r[t+7]=o,o=o>>8,r[t+6]=o,o=o>>8,r[t+5]=o,o=o>>8,r[t+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return r[t+3]=s,s=s>>8,r[t+2]=s,s=s>>8,r[t+1]=s,s=s>>8,r[t]=s,t+8}l.prototype.writeBigUInt64LE=Oe(function(e,t=0){return So(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});l.prototype.writeBigUInt64BE=Oe(function(e,t=0){return ko(this,e,t,BigInt(0),BigInt("0xffffffffffffffff"))});l.prototype.writeIntLE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let u=Math.pow(2,8*n-1);M(this,e,t,n,u-1,-u)}let o=0,s=1,c=0;for(this[t]=e&255;++o<n&&(s*=256);)e<0&&c===0&&this[t+o-1]!==0&&(c=1),this[t+o]=(e/s>>0)-c&255;return t+n};l.prototype.writeIntBE=function(e,t,n,i){if(e=+e,t=t>>>0,!i){let u=Math.pow(2,8*n-1);M(this,e,t,n,u-1,-u)}let o=n-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+n};l.prototype.writeInt8=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1};l.prototype.writeInt16LE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2};l.prototype.writeInt16BE=function(e,t,n){return e=+e,t=t>>>0,n||M(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2};l.prototype.writeInt32LE=function(e,t,n){return e=+e,t=t>>>0,n||M(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};l.prototype.writeInt32BE=function(e,t,n){return e=+e,t=t>>>0,n||M(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};l.prototype.writeBigInt64LE=Oe(function(e,t=0){return So(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});l.prototype.writeBigInt64BE=Oe(function(e,t=0){return ko(this,e,t,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Io(r,e,t,n,i,o){if(t+n>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Uo(r,e,t,n,i){return e=+e,t=t>>>0,i||Io(r,e,t,4,34028234663852886e22,-34028234663852886e22),mt.write(r,e,t,n,23,4),t+4}l.prototype.writeFloatLE=function(e,t,n){return Uo(this,e,t,!0,n)};l.prototype.writeFloatBE=function(e,t,n){return Uo(this,e,t,!1,n)};function Oo(r,e,t,n,i){return e=+e,t=t>>>0,i||Io(r,e,t,8,17976931348623157e292,-17976931348623157e292),mt.write(r,e,t,n,52,8),t+8}l.prototype.writeDoubleLE=function(e,t,n){return Oo(this,e,t,!0,n)};l.prototype.writeDoubleBE=function(e,t,n){return Oo(this,e,t,!1,n)};l.prototype.copy=function(e,t,n,i){if(!l.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-n&&(i=e.length-t+n);let o=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(t,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),t),o};l.prototype.fill=function(e,t,n,i){if(typeof e=="string"){if(typeof t=="string"?(i=t,t=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!l.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<n)throw new RangeError("Out of range index");if(n<=t)return this;t=t>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let o;if(typeof e=="number")for(o=t;o<n;++o)this[o]=e;else{let s=l.isBuffer(e)?e:l.from(e,i),c=s.length;if(c===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(o=0;o<n-t;++o)this[o+t]=s[o%c]}return this};var yt={};function Mn(r,e,t){yt[r]=class extends t{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${r}]`,this.stack,delete this.name}get code(){return r}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${r}]: ${this.message}`}}}Mn("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Mn("ERR_INVALID_ARG_TYPE",function(r,e){return`The "${r}" argument must be of type number. Received type ${typeof e}`},TypeError);Mn("ERR_OUT_OF_RANGE",function(r,e,t){let n=`The value of "${r}" is out of range.`,i=t;return Number.isInteger(t)&&Math.abs(t)>2**32?i=bo(String(t)):typeof t=="bigint"&&(i=String(t),(t>BigInt(2)**BigInt(32)||t<-(BigInt(2)**BigInt(32)))&&(i=bo(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function bo(r){let e="",t=r.length,n=r[0]==="-"?1:0;for(;t>=n+4;t-=3)e=`_${r.slice(t-3,t)}${e}`;return`${r.slice(0,t)}${e}`}function la(r,e,t){gt(e,"offset"),(r[e]===void 0||r[e+t]===void 0)&&Lt(e,r.length-(t+1))}function Ko(r,e,t,n,i,o){if(r>t||r<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 yt.ERR_OUT_OF_RANGE("value",c,r)}la(n,i,o)}function gt(r,e){if(typeof r!="number")throw new yt.ERR_INVALID_ARG_TYPE(e,"number",r)}function Lt(r,e,t){throw Math.floor(r)!==r?(gt(r,t),new yt.ERR_OUT_OF_RANGE(t||"offset","an integer",r)):e<0?new yt.ERR_BUFFER_OUT_OF_BOUNDS:new yt.ERR_OUT_OF_RANGE(t||"offset",`>= ${t?1:0} and <= ${e}`,r)}var pa=/[^+/0-9A-Za-z-_]/g;function ya(r){if(r=r.split("=")[0],r=r.trim().replace(pa,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Cn(r,e){e=e||1/0;let t,n=r.length,i=null,o=[];for(let s=0;s<n;++s){if(t=r.charCodeAt(s),t>55295&&t<57344){if(!i){if(t>56319){(e-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=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 ma(r){let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function ga(r,e){let t,n,i,o=[];for(let s=0;s<r.length&&!((e-=2)<0);++s)t=r.charCodeAt(s),n=t>>8,i=t%256,o.push(i),o.push(n);return o}function Co(r){return Un.toByteArray(ya(r))}function wr(r,e,t,n){let i;for(i=0;i<n&&!(i+t>=e.length||i>=r.length);++i)e[i+t]=r[i];return i}function he(r,e){return r instanceof e||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===e.name}function Nn(r){return r!==r}var wa=function(){let r="0123456789abcdef",e=new Array(256);for(let t=0;t<16;++t){let n=t*16;for(let i=0;i<16;++i)e[n+i]=r[t]+r[i]}return e}();function Oe(r){return typeof BigInt>"u"?xa:r}function xa(){throw new Error("BigInt not supported")}});var Fn=E((ah,Po)=>{"use strict";var Ln=null;Po.exports=function(){return Ln===null&&(Ln={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),Ln}});var Vn=E(Do=>{"use strict";var Rn=re(),va=new Set(["buffer","view","utf8"]),$n=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"||!va.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 Rn(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new Rn(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new Rn(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}};Do.Encoding=$n});var Jn=E(vr=>{"use strict";var{Buffer:qn}=xr()||{},{Encoding:Hn}=Vn(),ba=Fn(),Ft=class extends Hn{constructor(e){super({...e,format:"buffer"})}createViewTranscoder(){return new Rt({encode:this.encode,decode:e=>this.decode(qn.from(e.buffer,e.byteOffset,e.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}},Rt=class extends Hn{constructor(e){super({...e,format:"view"})}createBufferTranscoder(){return new Ft({encode:e=>{let t=this.encode(e);return qn.from(t.buffer,t.byteOffset,t.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}},jn=class extends Hn{constructor(e){super({...e,format:"utf8"})}createBufferTranscoder(){return new Ft({encode:e=>qn.from(this.encode(e),"utf8"),decode:e=>this.decode(e.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){let{textEncoder:e,textDecoder:t}=ba();return new Rt({encode:n=>e.encode(this.encode(n)),decode:n=>this.decode(t.decode(n)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}};vr.BufferFormat=Ft;vr.ViewFormat=Rt;vr.UTF8Format=jn});var Fo=E(Ye=>{"use strict";var{Buffer:I}=xr()||{Buffer:{isBuffer:()=>!1}},{textEncoder:No,textDecoder:Mo}=Fn()(),{BufferFormat:$t,ViewFormat:Gn,UTF8Format:Lo}=Jn(),br=r=>r;Ye.utf8=new Lo({encode:function(r){return I.isBuffer(r)?r.toString("utf8"):ArrayBuffer.isView(r)?Mo.decode(r):String(r)},decode:br,name:"utf8",createViewTranscoder(){return new Gn({encode:function(r){return ArrayBuffer.isView(r)?r:No.encode(r)},decode:function(r){return Mo.decode(r)},name:`${this.name}+view`})},createBufferTranscoder(){return new $t({encode:function(r){return I.isBuffer(r)?r:ArrayBuffer.isView(r)?I.from(r.buffer,r.byteOffset,r.byteLength):I.from(String(r),"utf8")},decode:function(r){return r.toString("utf8")},name:`${this.name}+buffer`})}});Ye.json=new Lo({encode:JSON.stringify,decode:JSON.parse,name:"json"});Ye.buffer=new $t({encode:function(r){return I.isBuffer(r)?r:ArrayBuffer.isView(r)?I.from(r.buffer,r.byteOffset,r.byteLength):I.from(String(r),"utf8")},decode:br,name:"buffer",createViewTranscoder(){return new Gn({encode:function(r){return ArrayBuffer.isView(r)?r:I.from(String(r),"utf8")},decode:function(r){return I.from(r.buffer,r.byteOffset,r.byteLength)},name:`${this.name}+view`})}});Ye.view=new Gn({encode:function(r){return ArrayBuffer.isView(r)?r:No.encode(r)},decode:br,name:"view",createBufferTranscoder(){return new $t({encode:function(r){return I.isBuffer(r)?r:ArrayBuffer.isView(r)?I.from(r.buffer,r.byteOffset,r.byteLength):I.from(String(r),"utf8")},decode:br,name:`${this.name}+buffer`})}});Ye.hex=new $t({encode:function(r){return I.isBuffer(r)?r:I.from(String(r),"hex")},decode:function(r){return r.toString("hex")},name:"hex"});Ye.base64=new $t({encode:function(r){return I.isBuffer(r)?r:I.from(String(r),"base64")},decode:function(r){return r.toString("base64")},name:"base64"})});var Vo=E($o=>{"use strict";var Ro=re(),Ar=Fo(),{Encoding:Ea}=Vn(),{BufferFormat:Aa,ViewFormat:_a,UTF8Format:Ta}=Jn(),Vt=Symbol("formats"),Er=Symbol("encodings"),Ba=new Set(["buffer","view","utf8"]),zn=class{constructor(e){if(Array.isArray(e)){if(!e.every(t=>Ba.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[Er]=new Map,this[Vt]=new Set(e);for(let t in Ar)try{this.encoding(t)}catch(n){if(n.code!=="LEVEL_ENCODING_NOT_SUPPORTED")throw n}}encodings(){return Array.from(new Set(this[Er].values()))}encoding(e){let t=this[Er].get(e);if(t===void 0){if(typeof e=="string"&&e!==""){if(t=Ua[e],!t)throw new Ro(`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=Sa(e)}let{name:n,format:i}=t;if(!this[Vt].has(i))if(this[Vt].has("view"))t=t.createViewTranscoder();else if(this[Vt].has("buffer"))t=t.createBufferTranscoder();else if(this[Vt].has("utf8"))t=t.createUTF8Transcoder();else throw new Ro(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});for(let o of[e,n,t.name,t.commonName])this[Er].set(o,t)}return t}};$o.Transcoder=zn;function Sa(r){if(r instanceof Ea)return r;let e="type"in r&&typeof r.type=="string"?r.type:void 0,t=r.name||e||`anonymous-${Oa++}`;switch(ka(r)){case"view":return new _a({...r,name:t});case"utf8":return new Ta({...r,name:t});case"buffer":return new Aa({...r,name:t});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}function ka(r){return"format"in r&&r.format!==void 0?r.format:"buffer"in r&&typeof r.buffer=="boolean"?r.buffer?"buffer":"utf8":"code"in r&&Number.isInteger(r.code)?"view":"buffer"}var Ia={binary:Ar.buffer,"utf-8":Ar.utf8},Ua={...Ar,...Ia},Oa=0});var qo=E((ph,Wn)=>{"use strict";var Ka=Object.prototype.hasOwnProperty,P="~";function jt(){}Object.create&&(jt.prototype=Object.create(null),new jt().__proto__||(P=!1));function Ca(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function jo(r,e,t,n,i){if(typeof t!="function")throw new TypeError("The listener must be a function");var o=new Ca(t,n||r,i),s=P?P+e:e;return r._events[s]?r._events[s].fn?r._events[s]=[r._events[s],o]:r._events[s].push(o):(r._events[s]=o,r._eventsCount++),r}function _r(r,e){--r._eventsCount===0?r._events=new jt:delete r._events[e]}function U(){this._events=new jt,this._eventsCount=0}U.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Ka.call(t,n)&&e.push(P?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};U.prototype.listeners=function(e){var t=P?P+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,o=n.length,s=new Array(o);i<o;i++)s[i]=n[i].fn;return s};U.prototype.listenerCount=function(e){var t=P?P+e:e,n=this._events[t];return n?n.fn?1:n.length:0};U.prototype.emit=function(e,t,n,i,o,s){var c=P?P+e:e;if(!this._events[c])return!1;var u=this._events[c],a=arguments.length,d,f;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),a){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,n),!0;case 4:return u.fn.call(u.context,t,n,i),!0;case 5:return u.fn.call(u.context,t,n,i,o),!0;case 6:return u.fn.call(u.context,t,n,i,o,s),!0}for(f=1,d=new Array(a-1);f<a;f++)d[f-1]=arguments[f];u.fn.apply(u.context,d)}else{var m=u.length,g;for(f=0;f<m;f++)switch(u[f].once&&this.removeListener(e,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,t);break;case 3:u[f].fn.call(u[f].context,t,n);break;case 4:u[f].fn.call(u[f].context,t,n,i);break;default:if(!d)for(g=1,d=new Array(a-1);g<a;g++)d[g-1]=arguments[g];u[f].fn.apply(u[f].context,d)}}return!0};U.prototype.on=function(e,t,n){return jo(this,e,t,n,!1)};U.prototype.once=function(e,t,n){return jo(this,e,t,n,!0)};U.prototype.removeListener=function(e,t,n,i){var o=P?P+e:e;if(!this._events[o])return this;if(!t)return _r(this,o),this;var s=this._events[o];if(s.fn)s.fn===t&&(!i||s.once)&&(!n||s.context===n)&&_r(this,o);else{for(var c=0,u=[],a=s.length;c<a;c++)(s[c].fn!==t||i&&!s[c].once||n&&s[c].context!==n)&&u.push(s[c]);u.length?this._events[o]=u.length===1?u[0]:u:_r(this,o)}return this};U.prototype.removeAllListeners=function(e){var t;return e?(t=P?P+e:e,this._events[t]&&_r(this,t)):(this._events=new jt,this._eventsCount=0),this};U.prototype.off=U.prototype.removeListener;U.prototype.addListener=U.prototype.on;U.prefixed=P;U.EventEmitter=U;typeof Wn<"u"&&(Wn.exports=U)});var Jo=E((yh,Ho)=>{Ho.exports=typeof queueMicrotask=="function"?queueMicrotask:r=>Promise.resolve().then(r)});var qt=E(Xn=>{"use strict";var Go=Jo();Xn.fromCallback=function(r,e){if(r===void 0){var t=new Promise(function(n,i){r=function(o,s){o?i(o):n(s)}});r[e!==void 0?e:"promise"]=t}else if(typeof r!="function")throw new TypeError("Callback must be a function");return r};Xn.fromPromise=function(r,e){if(e===void 0)return r;r.then(function(t){Go(()=>e(null,t))}).catch(function(t){Go(()=>e(t))})}});var Tr=E(Yn=>{"use strict";Yn.getCallback=function(r,e){return typeof r=="function"?r:e};Yn.getOptions=function(r,e){return typeof r=="object"&&r!==null?r:e!==void 0?e:{}}});var Ne=E(Ir=>{"use strict";var{fromCallback:Zn}=qt(),F=re(),{getOptions:Qn,getCallback:zo}=Tr(),Ze=Symbol("promise"),xt=Symbol("callback"),le=Symbol("working"),Qe=Symbol("handleOne"),Ee=Symbol("handleMany"),ei=Symbol("autoClose"),De=Symbol("finishWork"),pe=Symbol("returnMany"),Ke=Symbol("closing"),Ht=Symbol("handleClose"),Br=Symbol("closed"),Jt=Symbol("closeCallbacks"),Pe=Symbol("keyEncoding"),et=Symbol("valueEncoding"),ti=Symbol("abortOnClose"),Sr=Symbol("legacy"),ri=Symbol("keys"),ni=Symbol("values"),Ce=Symbol("limit"),X=Symbol("count"),kr=Object.freeze({}),Pa=()=>{},Wo=!1,Gt=class{constructor(e,t,n){if(typeof e!="object"||e===null){let i=e===null?"null":typeof e;throw new TypeError(`The first argument must be an abstract-level database, received ${i}`)}if(typeof t!="object"||t===null)throw new TypeError("The second argument must be an options object");this[Br]=!1,this[Jt]=[],this[le]=!1,this[Ke]=!1,this[ei]=!1,this[xt]=null,this[Qe]=this[Qe].bind(this),this[Ee]=this[Ee].bind(this),this[Ht]=this[Ht].bind(this),this[Pe]=t[Pe],this[et]=t[et],this[Sr]=n,this[Ce]=Number.isInteger(t.limit)&&t.limit>=0?t.limit:1/0,this[X]=0,this[ti]=!!t.abortOnClose,this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get count(){return this[X]}get limit(){return this[Ce]}next(e){let t;if(e===void 0)t=new Promise((n,i)=>{e=(o,s,c)=>{o?i(o):this[Sr]?s===void 0&&c===void 0?n():n([s,c]):n(s)}});else if(typeof e!="function")throw new TypeError("Callback must be a function");return this[Ke]?this.nextTick(e,new F("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[le]?this.nextTick(e,new F("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[le]=!0,this[xt]=e,this[X]>=this[Ce]?this.nextTick(this[Qe],null):this._next(this[Qe])),t}_next(e){this.nextTick(e)}nextv(e,t,n){return n=zo(t,n),n=Zn(n,Ze),t=Qn(t,kr),Number.isInteger(e)?(this[Ke]?this.nextTick(n,new F("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[le]?this.nextTick(n,new F("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(e<1&&(e=1),this[Ce]<1/0&&(e=Math.min(e,this[Ce]-this[X])),this[le]=!0,this[xt]=n,e<=0?this.nextTick(this[Ee],null,[]):this._nextv(e,t,this[Ee])),n[Ze]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[Ze])}_nextv(e,t,n){let i=[],o=(s,c,u)=>{if(s)return n(s);if(this[Sr]?c===void 0&&u===void 0:c===void 0)return n(null,i);i.push(this[Sr]?[c,u]:c),i.length===e?n(null,i):this._next(o)};this._next(o)}all(e,t){return t=zo(e,t),t=Zn(t,Ze),e=Qn(e,kr),this[Ke]?this.nextTick(t,new F("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[le]?this.nextTick(t,new F("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[le]=!0,this[xt]=t,this[ei]=!0,this[X]>=this[Ce]?this.nextTick(this[Ee],null,[]):this._all(e,this[Ee])),t[Ze]}_all(e,t){let n=this[X],i=[],o=()=>{let c=this[Ce]<1/0?Math.min(1e3,this[Ce]-n):1e3;c<=0?this.nextTick(t,null,i):this._nextv(c,kr,s)},s=(c,u)=>{c?t(c):u.length===0?t(null,i):(i.push.apply(i,u),n+=u.length,o())};o()}[De](){let e=this[xt];return this[ti]&&e===null?Pa:(this[le]=!1,this[xt]=null,this[Ke]&&this._close(this[Ht]),e)}[pe](e,t,n){this[ei]?this.close(e.bind(null,t,n)):e(t,n)}seek(e,t){if(t=Qn(t,kr),!this[Ke]){if(this[le])throw new F("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{let n=this.db.keyEncoding(t.keyEncoding||this[Pe]),i=n.format;t.keyEncoding!==i&&(t={...t,keyEncoding:i});let o=this.db.prefixKey(n.encode(e),i);this._seek(o,t)}}}_seek(e,t){throw new F("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(e){return e=Zn(e,Ze),this[Br]?this.nextTick(e):this[Ke]?this[Jt].push(e):(this[Ke]=!0,this[Jt].push(e),this[le]?this[ti]&&this[De]()(new F("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[Ht])),e[Ze]}_close(e){this.nextTick(e)}[Ht](){this[Br]=!0,this.db.detachResource(this);let e=this[Jt];this[Jt]=[];for(let t of e)t()}async*[Symbol.asyncIterator](){try{let e;for(;(e=await this.next())!==void 0;)yield e}finally{this[Br]||await this.close()}}},vt=class extends Gt{constructor(e,t){super(e,t,!0),this[ri]=t.keys!==!1,this[ni]=t.values!==!1}[Qe](e,t,n){let i=this[De]();if(e)return i(e);try{t=this[ri]&&t!==void 0?this[Pe].decode(t):void 0,n=this[ni]&&n!==void 0?this[et].decode(n):void 0}catch(o){return i(new Me("entry",o))}t===void 0&&n===void 0||this[X]++,i(null,t,n)}[Ee](e,t){let n=this[De]();if(e)return this[pe](n,e);try{for(let i of t){let o=i[0],s=i[1];i[0]=this[ri]&&o!==void 0?this[Pe].decode(o):void 0,i[1]=this[ni]&&s!==void 0?this[et].decode(s):void 0}}catch(i){return this[pe](n,new Me("entries",i))}this[X]+=t.length,this[pe](n,null,t)}end(e){return!Wo&&typeof console<"u"&&(Wo=!0,console.warn(new F("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)}},ii=class extends Gt{constructor(e,t){super(e,t,!1)}[Qe](e,t){let n=this[De]();if(e)return n(e);try{t=t!==void 0?this[Pe].decode(t):void 0}catch(i){return n(new Me("key",i))}t!==void 0&&this[X]++,n(null,t)}[Ee](e,t){let n=this[De]();if(e)return this[pe](n,e);try{for(let i=0;i<t.length;i++){let o=t[i];t[i]=o!==void 0?this[Pe].decode(o):void 0}}catch(i){return this[pe](n,new Me("keys",i))}this[X]+=t.length,this[pe](n,null,t)}},oi=class extends Gt{constructor(e,t){super(e,t,!1)}[Qe](e,t){let n=this[De]();if(e)return n(e);try{t=t!==void 0?this[et].decode(t):void 0}catch(i){return n(new Me("value",i))}t!==void 0&&this[X]++,n(null,t)}[Ee](e,t){let n=this[De]();if(e)return this[pe](n,e);try{for(let i=0;i<t.length;i++){let o=t[i];t[i]=o!==void 0?this[et].decode(o):void 0}}catch(i){return this[pe](n,new Me("values",i))}this[X]+=t.length,this[pe](n,null,t)}},Me=class extends F{constructor(e,t){super(`Iterator could not decode ${e}`,{code:"LEVEL_DECODE_ERROR",cause:t})}};for(let r of["_ended property","_nexting property","_end method"])Object.defineProperty(vt.prototype,r.split(" ")[0],{get(){throw new F(`The ${r} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new F(`The ${r} has been removed`,{code:"LEVEL_LEGACY"})}});vt.keyEncoding=Pe;vt.valueEncoding=et;Ir.AbstractIterator=vt;Ir.AbstractKeyIterator=ii;Ir.AbstractValueIterator=oi});var Xo=E(si=>{"use strict";var{AbstractKeyIterator:Da,AbstractValueIterator:Ma}=Ne(),tt=Symbol("iterator"),zt=Symbol("callback"),bt=Symbol("handleOne"),rt=Symbol("handleMany"),Wt=class extends Da{constructor(e,t){super(e,t),this[tt]=e.iterator({...t,keys:!0,values:!1}),this[bt]=this[bt].bind(this),this[rt]=this[rt].bind(this)}},Ur=class extends Ma{constructor(e,t){super(e,t),this[tt]=e.iterator({...t,keys:!1,values:!0}),this[bt]=this[bt].bind(this),this[rt]=this[rt].bind(this)}};for(let r of[Wt,Ur]){let e=r===Wt,t=e?n=>n[0]:n=>n[1];r.prototype._next=function(n){this[zt]=n,this[tt].next(this[bt])},r.prototype[bt]=function(n,i,o){let s=this[zt];n?s(n):s(null,e?i:o)},r.prototype._nextv=function(n,i,o){this[zt]=o,this[tt].nextv(n,i,this[rt])},r.prototype._all=function(n,i){this[zt]=i,this[tt].all(n,this[rt])},r.prototype[rt]=function(n,i){let o=this[zt];n?o(n):o(null,i.map(t))},r.prototype._seek=function(n,i){this[tt].seek(n,i)},r.prototype._close=function(n){this[tt].close(n)}}si.DefaultKeyIterator=Wt;si.DefaultValueIterator=Ur});var Yo=E(Mr=>{"use strict";var{AbstractIterator:Na,AbstractKeyIterator:La,AbstractValueIterator:Fa}=Ne(),ci=re(),N=Symbol("nut"),Pr=Symbol("undefer"),Dr=Symbol("factory"),Or=class extends Na{constructor(e,t){super(e,t),this[N]=null,this[Dr]=()=>e.iterator(t),this.db.defer(()=>this[Pr]())}},Kr=class extends La{constructor(e,t){super(e,t),this[N]=null,this[Dr]=()=>e.keys(t),this.db.defer(()=>this[Pr]())}},Cr=class extends Fa{constructor(e,t){super(e,t),this[N]=null,this[Dr]=()=>e.values(t),this.db.defer(()=>this[Pr]())}};for(let r of[Or,Kr,Cr])r.prototype[Pr]=function(){this.db.status==="open"&&(this[N]=this[Dr]())},r.prototype._next=function(e){this[N]!==null?this[N].next(e):this.db.status==="opening"?this.db.defer(()=>this._next(e)):this.nextTick(e,new ci("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._nextv=function(e,t,n){this[N]!==null?this[N].nextv(e,t,n):this.db.status==="opening"?this.db.defer(()=>this._nextv(e,t,n)):this.nextTick(n,new ci("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._all=function(e,t){this[N]!==null?this[N].all(t):this.db.status==="opening"?this.db.defer(()=>this._all(e,t)):this.nextTick(t,new ci("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},r.prototype._seek=function(e,t){this[N]!==null?this[N]._seek(e,t):this.db.status==="opening"&&this.db.defer(()=>this._seek(e,t))},r.prototype._close=function(e){this[N]!==null?this[N].close(e):this.db.status==="opening"?this.db.defer(()=>this._close(e)):this.nextTick(e)};Mr.DeferredIterator=Or;Mr.DeferredKeyIterator=Kr;Mr.DeferredValueIterator=Cr});var ai=E(Qo=>{"use strict";var{fromCallback:Zo}=qt(),Nr=re(),{getCallback:Ra,getOptions:$a}=Tr(),Lr=Symbol("promise"),Y=Symbol("status"),Et=Symbol("operations"),Xt=Symbol("finishClose"),At=Symbol("closeCallbacks"),ui=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[Et]=[],this[At]=[],this[Y]="open",this[Xt]=this[Xt].bind(this),this.db=e,this.db.attachResource(this),this.nextTick=e.nextTick}get length(){return this[Et].length}put(e,t,n){if(this[Y]!=="open")throw new Nr("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=n&&n.sublevel!=null?n.sublevel:this.db,s=n,c=o.keyEncoding(n&&n.keyEncoding),u=o.valueEncoding(n&&n.valueEncoding),a=c.format;n={...n,keyEncoding:a,valueEncoding:u.format},o!==this.db&&(n.sublevel=null);let d=o.prefixKey(c.encode(e),a),f=u.encode(t);return this._put(d,f,n),this[Et].push({...s,type:"put",key:e,value:t}),this}_put(e,t,n){}del(e,t){if(this[Y]!=="open")throw new Nr("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});let n=this.db._checkKey(e);if(n)throw n;let i=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[Et].push({...o,type:"del",key:e}),this}_del(e,t){}clear(){if(this[Y]!=="open")throw new Nr("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[Et]=[],this}_clear(){}write(e,t){return t=Ra(e,t),t=Zo(t,Lr),e=$a(e),this[Y]!=="open"?this.nextTick(t,new Nr("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):this.length===0?this.close(t):(this[Y]="writing",this._write(e,n=>{this[Y]="closing",this[At].push(()=>t(n)),n||this.db.emit("batch",this[Et]),this._close(this[Xt])})),t[Lr]}_write(e,t){}close(e){return e=Zo(e,Lr),this[Y]==="closing"?this[At].push(e):this[Y]==="closed"?this.nextTick(e):(this[At].push(e),this[Y]!=="writing"&&(this[Y]="closing",this._close(this[Xt]))),e[Lr]}_close(e){this.nextTick(e)}[Xt](){this[Y]="closed",this.db.detachResource(this);let e=this[At];this[At]=[];for(let t of e)t()}};Qo.AbstractChainedBatch=ui});var ts=E(es=>{"use strict";var{AbstractChainedBatch:Va}=ai(),ja=re(),_t=Symbol("encoded"),fi=class extends Va{constructor(e){super(e),this[_t]=[]}_put(e,t,n){this[_t].push({...n,type:"put",key:e,value:t})}_del(e,t){this[_t].push({...t,type:"del",key:e})}_clear(){this[_t]=[]}_write(e,t){this.db.status==="opening"?this.db.defer(()=>this._write(e,t)):this.db.status==="open"?this[_t].length===0?this.nextTick(t):this.db._batch(this[_t],e,t):this.nextTick(t,new ja("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}};es.DefaultChainedBatch=fi});var is=E((Ah,ns)=>{"use strict";var rs=re(),qa=Object.prototype.hasOwnProperty,Ha=new Set(["lt","lte","gt","gte"]);ns.exports=function(r,e){let t={};for(let n in r)if(qa.call(r,n)&&!(n==="keyEncoding"||n==="valueEncoding")){if(n==="start"||n==="end")throw new rs(`The legacy range option '${n}' has been removed`,{code:"LEVEL_LEGACY"});if(n==="encoding")throw new rs("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});Ha.has(n)?t[n]=e.encode(r[n]):t[n]=r[n]}return t.reverse=!!t.reverse,t.limit=Number.isInteger(t.limit)&&t.limit>=0?t.limit:-1,t}});var di=E((_h,ss)=>{var os;ss.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window<"u"?window:globalThis):r=>(os||(os=Promise.resolve())).then(r).catch(e=>setTimeout(()=>{throw e},0))});var as=E((Th,us)=>{"use strict";var cs=di();us.exports=function(r,...e){e.length===0?cs(r):cs(()=>r(...e))}});var fs=E(Fr=>{"use strict";var{AbstractIterator:Ja,AbstractKeyIterator:Ga,AbstractValueIterator:za}=Ne(),Tt=Symbol("unfix"),ne=Symbol("iterator"),nt=Symbol("handleOne"),Le=Symbol("handleMany"),Ae=Symbol("callback"),Yt=class extends Ja{constructor(e,t,n,i){super(e,t),this[ne]=n,this[Tt]=i,this[nt]=this[nt].bind(this),this[Le]=this[Le].bind(this),this[Ae]=null}[nt](e,t,n){let i=this[Ae];if(e)return i(e);t!==void 0&&(t=this[Tt](t)),i(e,t,n)}[Le](e,t){let n=this[Ae];if(e)return n(e);for(let i of t){let o=i[0];o!==void 0&&(i[0]=this[Tt](o))}n(e,t)}},Zt=class extends Ga{constructor(e,t,n,i){super(e,t),this[ne]=n,this[Tt]=i,this[nt]=this[nt].bind(this),this[Le]=this[Le].bind(this),this[Ae]=null}[nt](e,t){let n=this[Ae];if(e)return n(e);t!==void 0&&(t=this[Tt](t)),n(e,t)}[Le](e,t){let n=this[Ae];if(e)return n(e);for(let i=0;i<t.length;i++){let o=t[i];o!==void 0&&(t[i]=this[Tt](o))}n(e,t)}},Qt=class extends za{constructor(e,t,n){super(e,t),this[ne]=n}};for(let r of[Yt,Zt])r.prototype._next=function(e){this[Ae]=e,this[ne].next(this[nt])},r.prototype._nextv=function(e,t,n){this[Ae]=n,this[ne].nextv(e,t,this[Le])},r.prototype._all=function(e,t){this[Ae]=t,this[ne].all(e,this[Le])};for(let r of[Qt])r.prototype._next=function(e){this[ne].next(e)},r.prototype._nextv=function(e,t,n){this[ne].nextv(e,t,n)},r.prototype._all=function(e,t){this[ne].all(e,t)};for(let r of[Yt,Zt,Qt])r.prototype._seek=function(e,t){this[ne].seek(e,t)},r.prototype._close=function(e){this[ne].close(e)};Fr.AbstractSublevelIterator=Yt;Fr.AbstractSublevelKeyIterator=Zt;Fr.AbstractSublevelValueIterator=Qt});var ps=E((Sh,ls)=>{"use strict";var hi=re(),{Buffer:yi}=xr()||{},{AbstractSublevelIterator:Wa,AbstractSublevelKeyIterator:Xa,AbstractSublevelValueIterator:Ya}=fs(),_e=Symbol("prefix"),ds=Symbol("upperBound"),er=Symbol("prefixRange"),R=Symbol("parent"),li=Symbol("unfix"),hs=new TextEncoder,Za={separator:"!"};ls.exports=function({AbstractLevel:r}){class e extends r{static defaults(n){if(typeof n=="string")throw new hi("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(n&&n.open)throw new hi("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return n==null?Za:n.separator?n:{...n,separator:"!"}}constructor(n,i,o){let{separator:s,manifest:c,...u}=e.defaults(o);i=ef(i,s);let a=s.charCodeAt(0)+1,d=n[R]||n;if(!hs.encode(i).every(g=>g>a&&g<127))throw new hi(`Prefix must use bytes > ${a} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(Qa(d,c),u);let f=(n.prefix||"")+s+i+s,m=f.slice(0,-1)+String.fromCharCode(a);this[R]=d,this[_e]=new Rr(f),this[ds]=new Rr(m),this[li]=new mi,this.nextTick=d.nextTick}prefixKey(n,i){if(i==="utf8")return this[_e].utf8+n;if(n.byteLength===0)return this[_e][i];if(i==="view"){let o=this[_e].view,s=new Uint8Array(o.byteLength+n.byteLength);return s.set(o,0),s.set(n,o.byteLength),s}else{let o=this[_e].buffer;return yi.concat([o,n],o.byteLength+n.byteLength)}}[er](n,i){n.gte!==void 0?n.gte=this.prefixKey(n.gte,i):n.gt!==void 0?n.gt=this.prefixKey(n.gt,i):n.gte=this[_e][i],n.lte!==void 0?n.lte=this.prefixKey(n.lte,i):n.lt!==void 0?n.lt=this.prefixKey(n.lt,i):n.lte=this[ds][i]}get prefix(){return this[_e].utf8}get db(){return this[R]}_open(n,i){this[R].open({passive:!0},i)}_put(n,i,o,s){this[R].put(n,i,o,s)}_get(n,i,o){this[R].get(n,i,o)}_getMany(n,i,o){this[R].getMany(n,i,o)}_del(n,i,o){this[R].del(n,i,o)}_batch(n,i,o){this[R].batch(n,i,o)}_clear(n,i){this[er](n,n.keyEncoding),this[R].clear(n,i)}_iterator(n){this[er](n,n.keyEncoding);let i=this[R].iterator(n),o=this[li].get(this[_e].utf8.length,n.keyEncoding);return new Wa(this,n,i,o)}_keys(n){this[er](n,n.keyEncoding);let i=this[R].keys(n),o=this[li].get(this[_e].utf8.length,n.keyEncoding);return new Xa(this,n,i,o)}_values(n){this[er](n,n.keyEncoding);let i=this[R].values(n);return new Ya(this,n,i)}}return{AbstractSublevel:e}};var Qa=function(r,e){return{...r.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...e,encodings:{utf8:pi(r,"utf8"),buffer:pi(r,"buffer"),view:pi(r,"view")}}},pi=function(r,e){return r.supports.encodings[e]?r.keyEncoding(e).name===e:!1},Rr=class{constructor(e){this.utf8=e,this.view=hs.encode(e),this.buffer=yi?yi.from(this.view.buffer,0,this.view.byteLength):{}}},mi=class{constructor(){this.cache=new Map}get(e,t){let n=this.cache.get(t);return n===void 0&&(t==="view"?n=(function(i,o){return o.subarray(i)}).bind(null,e):n=(function(i,o){return o.slice(i)}).bind(null,e),this.cache.set(t,n)),n}},ef=function(r,e){let t=0,n=r.length;for(;t<n&&r[t]===e;)t++;for(;n>t&&r[n-1]===e;)n--;return r.slice(t,n)}});var bi=E(vi=>{"use strict";var{supports:tf}=ho(),{Transcoder:rf}=Vo(),{EventEmitter:nf}=qo(),{fromCallback:Fe}=qt(),ie=re(),{AbstractIterator:it}=Ne(),{DefaultKeyIterator:of,DefaultValueIterator:sf}=Xo(),{DeferredIterator:cf,DeferredKeyIterator:uf,DeferredValueIterator:af}=Yo(),{DefaultChainedBatch:ys}=ts(),{getCallback:ot,getOptions:Re}=Tr(),$r=is(),x=Symbol("promise"),Te=Symbol("landed"),st=Symbol("resources"),gi=Symbol("closeResources"),tr=Symbol("operations"),rr=Symbol("undefer"),Vr=Symbol("deferOpen"),ms=Symbol("options"),v=Symbol("status"),ct=Symbol("defaultOptions"),Bt=Symbol("transcoder"),jr=Symbol("keyEncoding"),wi=Symbol("valueEncoding"),ff=()=>{},nr=class extends nf{constructor(e,t){if(super(),typeof e!="object"||e===null)throw new TypeError("The first argument 'manifest' must be an object");t=Re(t);let{keyEncoding:n,valueEncoding:i,passive:o,...s}=t;this[st]=new Set,this[tr]=[],this[Vr]=!0,this[ms]=s,this[v]="opening",this.supports=tf(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[Bt]=new rf(df(this)),this[jr]=this[Bt].encoding(n||"utf8"),this[wi]=this[Bt].encoding(i||"utf8");for(let c of this[Bt].encodings())this.supports.encodings[c.commonName]||(this.supports.encodings[c.commonName]=!0);this[ct]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[jr].commonName,valueEncoding:this[wi].commonName}),key:Object.freeze({keyEncoding:this[jr].commonName})},this.nextTick(()=>{this[Vr]&&this.open({passive:!1},ff)})}get status(){return this[v]}keyEncoding(e){return this[Bt].encoding(e??this[jr])}valueEncoding(e){return this[Bt].encoding(e??this[wi])}open(e,t){t=ot(e,t),t=Fe(t,x),e={...this[ms],...Re(e)},e.createIfMissing=e.createIfMissing!==!1,e.errorIfExists=!!e.errorIfExists;let n=i=>{this[v]==="closing"||this[v]==="opening"?this.once(Te,i?()=>n(i):n):this[v]!=="open"?t(new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:i})):t()};return e.passive?this[v]==="opening"?this.once(Te,n):this.nextTick(n):this[v]==="closed"||this[Vr]?(this[Vr]=!1,this[v]="opening",this.emit("opening"),this._open(e,i=>{if(i){this[v]="closed",this[gi](()=>{this.emit(Te),n(i)}),this[rr]();return}this[v]="open",this[rr](),this.emit(Te),this[v]==="open"&&this.emit("open"),this[v]==="open"&&this.emit("ready"),n()})):this[v]==="open"?this.nextTick(n):this.once(Te,()=>this.open(e,t)),t[x]}_open(e,t){this.nextTick(t)}close(e){e=Fe(e,x);let t=n=>{this[v]==="opening"||this[v]==="closing"?this.once(Te,n?t(n):t):this[v]!=="closed"?e(new ie("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):e()};if(this[v]==="open"){this[v]="closing",this.emit("closing");let n=i=>{this[v]="open",this[rr](),this.emit(Te),t(i)};this[gi](()=>{this._close(i=>{if(i)return n(i);this[v]="closed",this[rr](),this.emit(Te),this[v]==="closed"&&this.emit("closed"),t()})})}else this[v]==="closed"?this.nextTick(t):this.once(Te,()=>this.close(e));return e[x]}[gi](e){if(this[st].size===0)return this.nextTick(e);let t=this[st].size,n=!0,i=()=>{--t===0&&(n?this.nextTick(e):e())};for(let o of this[st])o.close(i);n=!1,this[st].clear()}_close(e){this.nextTick(e)}get(e,t,n){if(n=ot(t,n),n=Fe(n,x),t=Re(t,this[ct].entry),this[v]==="opening")return this.defer(()=>this.get(e,t,n)),n[x];if(St(this,n))return n[x];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[x];let o=this.keyEncoding(t.keyEncoding),s=this.valueEncoding(t.valueEncoding),c=o.format,u=s.format;return(t.keyEncoding!==c||t.valueEncoding!==u)&&(t=Object.assign({},t,{keyEncoding:c,valueEncoding:u})),this._get(this.prefixKey(o.encode(e),c),t,(a,d)=>{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)),n(a);try{d=s.decode(d)}catch(f){return n(new ie("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:f}))}n(null,d)}),n[x]}_get(e,t,n){this.nextTick(n,new Error("NotFound"))}getMany(e,t,n){if(n=ot(t,n),n=Fe(n,x),t=Re(t,this[ct].entry),this[v]==="opening")return this.defer(()=>this.getMany(e,t,n)),n[x];if(St(this,n))return n[x];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[x];if(e.length===0)return this.nextTick(n,null,[]),n[x];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 u=new Array(e.length);for(let a=0;a<e.length;a++){let d=e[a],f=this._checkKey(d);if(f)return this.nextTick(n,f),n[x];u[a]=this.prefixKey(i.encode(d),s)}return this._getMany(u,t,(a,d)=>{if(a)return n(a);try{for(let f=0;f<d.length;f++)d[f]!==void 0&&(d[f]=o.decode(d[f]))}catch(f){return n(new ie(`Could not decode one or more of ${d.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:f}))}n(null,d)}),n[x]}_getMany(e,t,n){this.nextTick(n,null,new Array(e.length).fill(void 0))}put(e,t,n,i){if(i=ot(n,i),i=Fe(i,x),n=Re(n,this[ct].entry),this[v]==="opening")return this.defer(()=>this.put(e,t,n,i)),i[x];if(St(this,i))return i[x];let o=this._checkKey(e)||this._checkValue(t);if(o)return this.nextTick(i,o),i[x];let s=this.keyEncoding(n.keyEncoding),c=this.valueEncoding(n.valueEncoding),u=s.format,a=c.format;(n.keyEncoding!==u||n.valueEncoding!==a)&&(n=Object.assign({},n,{keyEncoding:u,valueEncoding:a}));let d=this.prefixKey(s.encode(e),u),f=c.encode(t);return this._put(d,f,n,m=>{if(m)return i(m);this.emit("put",e,t),i()}),i[x]}_put(e,t,n,i){this.nextTick(i)}del(e,t,n){if(n=ot(t,n),n=Fe(n,x),t=Re(t,this[ct].key),this[v]==="opening")return this.defer(()=>this.del(e,t,n)),n[x];if(St(this,n))return n[x];let i=this._checkKey(e);if(i)return this.nextTick(n,i),n[x];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 n(c);this.emit("del",e),n()}),n[x]}_del(e,t,n){this.nextTick(n)}batch(e,t,n){if(!arguments.length){if(this[v]==="opening")return new ys(this);if(this[v]!=="open")throw new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(typeof e=="function"?n=e:n=ot(t,n),n=Fe(n,x),t=Re(t,this[ct].empty),this[v]==="opening")return this.defer(()=>this.batch(e,t,n)),n[x];if(St(this,n))return n[x];if(!Array.isArray(e))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[x];if(e.length===0)return this.nextTick(n),n[x];let i=new Array(e.length),{keyEncoding:o,valueEncoding:s,...c}=t;for(let u=0;u<e.length;u++){if(typeof e[u]!="object"||e[u]===null)return this.nextTick(n,new TypeError("A batch operation must be an object")),n[x];let a=Object.assign({},e[u]);if(a.type!=="put"&&a.type!=="del")return this.nextTick(n,new TypeError("A batch operation must have a type property that is 'put' or 'del'")),n[x];let d=this._checkKey(a.key);if(d)return this.nextTick(n,d),n[x];let f=a.sublevel!=null?a.sublevel:this,m=f.keyEncoding(a.keyEncoding||o),g=m.format;if(a.key=f.prefixKey(m.encode(a.key),g),a.keyEncoding=g,a.type==="put"){let w=this._checkValue(a.value);if(w)return this.nextTick(n,w),n[x];let b=f.valueEncoding(a.valueEncoding||s);a.value=b.encode(a.value),a.valueEncoding=b.format}f!==this&&(a.sublevel=null),i[u]=a}return this._batch(i,c,u=>{if(u)return n(u);this.emit("batch",e),n()}),n[x]}_batch(e,t,n){this.nextTick(n)}sublevel(e,t){return this._sublevel(e,xi.defaults(t))}_sublevel(e,t){return new xi(this,e,t)}prefixKey(e,t){return e}clear(e,t){if(t=ot(e,t),t=Fe(t,x),e=Re(e,this[ct].empty),this[v]==="opening")return this.defer(()=>this.clear(e,t)),t[x];if(St(this,t))return t[x];let n=e,i=this.keyEncoding(e.keyEncoding);return e=$r(e,i),e.keyEncoding=i.format,e.limit===0?this.nextTick(t):this._clear(e,o=>{if(o)return t(o);this.emit("clear",n),t()}),t[x]}_clear(e,t){this.nextTick(t)}iterator(e){let t=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=$r(e,t),e.keys=e.keys!==!1,e.values=e.values!==!1,e[it.keyEncoding]=t,e[it.valueEncoding]=n,e.keyEncoding=t.format,e.valueEncoding=n.format,this[v]==="opening")return new cf(this,e);if(this[v]!=="open")throw new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(e)}_iterator(e){return new it(this,e)}keys(e){let t=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=$r(e,t),e[it.keyEncoding]=t,e[it.valueEncoding]=n,e.keyEncoding=t.format,e.valueEncoding=n.format,this[v]==="opening")return new uf(this,e);if(this[v]!=="open")throw new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(e)}_keys(e){return new of(this,e)}values(e){let t=this.keyEncoding(e&&e.keyEncoding),n=this.valueEncoding(e&&e.valueEncoding);if(e=$r(e,t),e[it.keyEncoding]=t,e[it.valueEncoding]=n,e.keyEncoding=t.format,e.valueEncoding=n.format,this[v]==="opening")return new af(this,e);if(this[v]!=="open")throw new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(e)}_values(e){return new sf(this,e)}defer(e){if(typeof e!="function")throw new TypeError("The first argument must be a function");this[tr].push(e)}[rr](){if(this[tr].length===0)return;let e=this[tr];this[tr]=[];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[st].add(e)}detachResource(e){this[st].delete(e)}_chainedBatch(){return new ys(this)}_checkKey(e){if(e==null)return new ie("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(e){if(e==null)return new ie("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}};nr.prototype.nextTick=as();var{AbstractSublevel:xi}=ps()({AbstractLevel:nr});vi.AbstractLevel=nr;vi.AbstractSublevel=xi;var St=function(r,e){return r[v]!=="open"?(r.nextTick(e,new ie("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0):!1},df=function(r){return Object.keys(r.supports.encodings).filter(e=>!!r.supports.encodings[e])}});var Ei=E(ut=>{"use strict";ut.AbstractLevel=bi().AbstractLevel;ut.AbstractSublevel=bi().AbstractSublevel;ut.AbstractIterator=Ne().AbstractIterator;ut.AbstractKeyIterator=Ne().AbstractKeyIterator;ut.AbstractValueIterator=Ne().AbstractValueIterator;ut.AbstractChainedBatch=ai().AbstractChainedBatch});var ws=E((Uh,gs)=>{gs.exports=lf;var hf=di();function lf(r,e,t){if(typeof e!="number")throw new Error("second argument must be a Number");let n,i,o,s,c,u=!0,a;Array.isArray(r)?(n=[],o=i=r.length):(s=Object.keys(r),n={},o=i=s.length);function d(m){function g(){t&&t(m,n),t=null}u?hf(g):g()}function f(m,g,w){if(n[m]=w,g&&(c=!0),--o===0||g)d(g);else if(!c&&a<i){let b;s?(b=s[a],a+=1,r[b](function(ee,K){f(b,ee,K)})):(b=a,a+=1,r[b](function(ee,K){f(b,ee,K)}))}}a=e,o?s?s.some(function(m,g){return r[m](function(w,b){f(m,w,b)}),g===e-1}):r.some(function(m,g){return m(function(w,b){f(g,w,b)}),g===e-1}):d(null),u=!1}});var Ai=E((Oh,xs)=>{"use strict";xs.exports=function(e){let t=e.gte!==void 0?e.gte:e.gt!==void 0?e.gt:void 0,n=e.lte!==void 0?e.lte:e.lt!==void 0?e.lt:void 0,i=e.gte===void 0,o=e.lte===void 0;return t!==void 0&&n!==void 0?IDBKeyRange.bound(t,n,i,o):t!==void 0?IDBKeyRange.lowerBound(t,i):n!==void 0?IDBKeyRange.upperBound(n,o):null}});var _i=E((Kh,vs)=>{"use strict";var pf=new TextEncoder;vs.exports=function(r){return r instanceof Uint8Array?r:r instanceof ArrayBuffer?new Uint8Array(r):pf.encode(r)}});var Ts=E(_s=>{"use strict";var{AbstractIterator:yf}=Ei(),bs=Ai(),qr=_i(),ye=Symbol("cache"),Be=Symbol("finished"),$=Symbol("options"),Se=Symbol("currentOptions"),at=Symbol("position"),Ti=Symbol("location"),kt=Symbol("first"),Es={},Bi=class extends yf{constructor(e,t,n){super(e,n),this[ye]=[],this[Be]=this.limit===0,this[$]=n,this[Se]={...n},this[at]=void 0,this[Ti]=t,this[kt]=!0}_nextv(e,t,n){if(this[kt]=!1,this[Be])return this.nextTick(n,null,[]);if(this[ye].length>0)return e=Math.min(e,this[ye].length),this.nextTick(n,null,this[ye].splice(0,e));this[at]!==void 0&&(this[$].reverse?(this[Se].lt=this[at],this[Se].lte=void 0):(this[Se].gt=this[at],this[Se].gte=void 0));let i;try{i=bs(this[Se])}catch{return this[Be]=!0,this.nextTick(n,null,[])}let o=this.db.db.transaction([this[Ti]],"readonly"),s=o.objectStore(this[Ti]),c=[];if(this[$].reverse){let u=!this[$].values&&s.openKeyCursor?"openKeyCursor":"openCursor";s[u](i,"prev").onsuccess=a=>{let d=a.target.result;if(d){let{key:f,value:m}=d;this[at]=f,c.push([this[$].keys&&f!==void 0?qr(f):void 0,this[$].values&&m!==void 0?qr(m):void 0]),c.length<e?d.continue():As(o)}else this[Be]=!0}}else{let u,a,d=()=>{if(u===void 0||a===void 0)return;let f=Math.max(u.length,a.length);f===0||e===1/0?this[Be]=!0:this[at]=u[f-1],c.length=f;for(let m=0;m<f;m++){let g=u[m],w=a[m];c[m]=[this[$].keys&&g!==void 0?qr(g):void 0,this[$].values&&w!==void 0?qr(w):void 0]}As(o)};this[$].keys||e<1/0?s.getAllKeys(i,e<1/0?e:void 0).onsuccess=f=>{u=f.target.result,d()}:(u=[],this.nextTick(d)),this[$].values?s.getAll(i,e<1/0?e:void 0).onsuccess=f=>{a=f.target.result,d()}:(a=[],this.nextTick(d))}o.onabort=()=>{n(o.error||new Error("aborted by user")),n=null},o.oncomplete=()=>{n(null,c),n=null}}_next(e){if(this[ye].length>0){let[t,n]=this[ye].shift();this.nextTick(e,null,t,n)}else if(this[Be])this.nextTick(e);else{let t=Math.min(100,this.limit-this.count);this[kt]&&(this[kt]=!1,t=1),this._nextv(t,Es,(n,i)=>{if(n)return e(n);this[ye]=i,this._next(e)})}}_all(e,t){this[kt]=!1;let n=this[ye].splice(0,this[ye].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(t,null,n);this._nextv(i,Es,(o,s)=>{if(o)return t(o);n.length>0&&(s=n.concat(s)),t(null,s)})}_seek(e,t){this[kt]=!0,this[ye]=[],this[Be]=!1,this[at]=void 0,this[Se]={...this[$]};let n;try{n=bs(this[$])}catch{this[Be]=!0;return}n!==null&&!n.includes(e)?this[Be]=!0:this[$].reverse?this[Se].lte=e:this[Se].gte=e}};_s.Iterator=Bi;function As(r){typeof r.commit=="function"&&r.commit()}});var Ss=E((Ph,Bs)=>{"use strict";Bs.exports=function(e,t,n,i,o){if(i.limit===0)return e.nextTick(o);let s=e.db.transaction([t],"readwrite"),c=s.objectStore(t),u=0;s.oncomplete=function(){o()},s.onabort=function(){o(s.error||new Error("aborted by user"))};let a=c.openKeyCursor?"openKeyCursor":"openCursor",d=i.reverse?"prev":"next";c[a](n,d).onsuccess=function(f){let m=f.target.result;m&&(c.delete(m.key).onsuccess=function(){(i.limit<=0||++u<i.limit)&&m.continue()})}}});var Cs=E(Ks=>{"use strict";var{AbstractLevel:mf}=Ei(),ks=re(),gf=ws(),{fromCallback:wf}=qt(),{Iterator:xf}=Ts(),Is=_i(),vf=Ss(),bf=Ai(),Os="level-js-",ir=Symbol("idb"),Si=Symbol("namePrefix"),ke=Symbol("location"),ki=Symbol("version"),ft=Symbol("store"),or=Symbol("onComplete"),Us=Symbol("promise"),Hr=class extends mf{constructor(e,t,n){if(typeof t=="function"||typeof n=="function")throw new ks("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[ke]=e,this[Si]=i??Os,this[ki]=parseInt(o||1,10),this[ir]=null}get location(){return this[ke]}get namePrefix(){return this[Si]}get version(){return this[ki]}get db(){return this[ir]}get type(){return"browser-level"}_open(e,t){let n=indexedDB.open(this[Si]+this[ke],this[ki]);n.onerror=function(){t(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[ir]=n.result,t()},n.onupgradeneeded=i=>{let o=i.target.result;o.objectStoreNames.contains(this[ke])||o.createObjectStore(this[ke])}}[ft](e){return this[ir].transaction([this[ke]],e).objectStore(this[ke])}[or](e,t){let n=e.transaction;n.onabort=function(){t(n.error||new Error("aborted by user"))},n.oncomplete=function(){t(null,e.result)}}_get(e,t,n){let i=this[ft]("readonly"),o;try{o=i.get(e)}catch(s){return this.nextTick(n,s)}this[or](o,function(s,c){if(s)return n(s);if(c===void 0)return n(new ks("Entry not found",{code:"LEVEL_NOT_FOUND"}));n(null,Is(c))})}_getMany(e,t,n){let i=this[ft]("readonly"),o=e.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:Is(a))},u.onerror=a=>{a.stopPropagation(),c(u.error)}});gf(o,16,n)}_del(e,t,n){let i=this[ft]("readwrite"),o;try{o=i.delete(e)}catch(s){return this.nextTick(n,s)}this[or](o,n)}_put(e,t,n,i){let o=this[ft]("readwrite"),s;try{s=o.put(t,e)}catch(c){return this.nextTick(i,c)}this[or](s,i)}_iterator(e){return new xf(this,this[ke],e)}_batch(e,t,n){let i=this[ft]("readwrite"),o=i.transaction,s=0,c;o.onabort=function(){n(c||o.error||new Error("aborted by user"))},o.oncomplete=function(){n()};function u(){let a=e[s++],d=a.key,f;try{f=a.type==="del"?i.delete(d):i.put(a.value,d)}catch(m){c=m,o.abort();return}s<e.length?f.onsuccess=u:typeof o.commit=="function"&&o.commit()}u()}_clear(e,t){let n,i;try{n=bf(e)}catch{return this.nextTick(t)}if(e.limit>=0)return vf(this,this[ke],n,e,t);try{let o=this[ft]("readwrite");i=n?o.delete(n):o.clear()}catch(o){return this.nextTick(t,o)}this[or](i,t)}_close(e){this[ir].close(),this.nextTick(e)}};Hr.destroy=function(r,e,t){typeof e=="function"&&(t=e,e=Os),t=wf(t,Us);let n=indexedDB.deleteDatabase(e+r);return n.onsuccess=function(){t()},n.onerror=function(i){t(i)},t[Us]};Ks.BrowserLevel=Hr});var Ds=E(Ps=>{Ps.Level=Cs().BrowserLevel});var xe;(function(r){r.AlgorithmNotSupported="algorithmNotSupported",r.EncodingError="encodingError",r.InvalidCoseSign1="invalidCoseSign1",r.InvalidEat="invalidEat",r.InvalidJwe="invalidJwe",r.InvalidJwk="invalidJwk",r.OperationNotSupported="operationNotSupported"})(xe||(xe={}));var fu=Ji(zi(),1);var ud=new Uint8Array(0);function Wi(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function ht(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function hu(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),s=o.charCodeAt(0);if(t[s]!==255)throw new TypeError(o+" is ambiguous");t[s]=i}var c=r.length,u=r.charAt(0),a=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function f(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var b=0,ee=0,K=0,ce=w.length;K!==ce&&w[K]===0;)K++,b++;for(var ue=(ce-K)*d+1>>>0,z=new Uint8Array(ue);K!==ce;){for(var ae=w[K],Ue=0,te=ue-1;(ae!==0||Ue<ee)&&te!==-1;te--,Ue++)ae+=256*z[te]>>>0,z[te]=ae%c>>>0,ae=ae/c>>>0;if(ae!==0)throw new Error("Non-zero carry");ee=Ue,K++}for(var we=ue-ee;we!==ue&&z[we]===0;)we++;for(var hr=u.repeat(b);we<ue;++we)hr+=r.charAt(z[we]);return hr}function m(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var b=0;if(w[b]!==" "){for(var ee=0,K=0;w[b]===u;)ee++,b++;for(var ce=(w.length-b)*a+1>>>0,ue=new Uint8Array(ce);w[b];){var z=t[w.charCodeAt(b)];if(z===255)return;for(var ae=0,Ue=ce-1;(z!==0||ae<K)&&Ue!==-1;Ue--,ae++)z+=c*ue[Ue]>>>0,ue[Ue]=z%256>>>0,z=z/256>>>0;if(z!==0)throw new Error("Non-zero carry");K=ae,b++}if(w[b]!==" "){for(var te=ce-K;te!==ce&&ue[te]===0;)te++;for(var we=new Uint8Array(ee+(ce-te)),hr=ee;te!==ce;)we[hr++]=ue[te++];return we}}}function g(w){var b=m(w);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:m,decode:g}}var lu=hu,pu=lu,Xi=pu;var yn=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},mn=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){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=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Yi(this,e)}},gn=class{decoders;constructor(e){this.decoders=e}or(e){return Yi(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Yi(r,e){return new gn({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var wn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new yn(e,t,n),this.decoder=new mn(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Zi({name:r,prefix:e,encode:t,decode:n}){return new wn(r,e,t,n)}function xn({name:r,prefix:e,alphabet:t}){let{encode:n,decode:i}=Xi(t,r);return Zi({prefix:e,name:r,encode:n,decode:o=>ht(i(o))})}function yu(r,e,t,n){let i={};for(let d=0;d<e.length;++d)i[e[d]]=d;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),c=0,u=0,a=0;for(let d=0;d<o;++d){let f=i[r[d]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<t|f,c+=t,c>=8&&(c-=8,s[a++]=255&u>>c)}if(c>=t||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s}function mu(r,e,t){let n=e[e.length-1]==="=",i=(1<<t)-1,o="",s=0,c=0;for(let u=0;u<r.length;++u)for(c=c<<8|r[u],s+=8;s>t;)s-=t,o+=e[i&c>>s];if(s!==0&&(o+=e[i&c<<t-s]),n)for(;o.length*t&7;)o+="=";return o}function C({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Zi({prefix:e,name:r,encode(i){return mu(i,n,t)},decode(i){return yu(i,n,t,r)}})}var Ct=C({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pd=C({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),yd=C({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),md=C({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),gd=C({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wd=C({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),xd=C({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),vd=C({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vn=C({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var D=xn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ad=xn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Bd=C({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Sd=C({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),fe=C({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),kd=C({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Qi(r){return r.byteOffset!==0||r.byteLength!==r.buffer.byteLength}function eo(r){return typeof r!="object"||r===null?!1:typeof r[Symbol.asyncIterator]=="function"}function pr(r){let t=Object.prototype.toString.call(r).match(/\s([a-zA-Z0-9]+)/),[n,i]=t;return i}var Pt=function(r,e,t,n){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function c(d){try{a(n.next(d))}catch(f){s(f)}}function u(d){try{a(n.throw(d))}catch(f){s(f)}}function a(d){d.done?o(d.value):i(d.value).then(c,u)}a((n=n.apply(r,e||[])).next())})},to=function(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof __values=="function"?__values(r):r[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=r[o]&&function(s){return new Promise(function(c,u){s=r[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)}},yr=new TextEncoder,Je=new TextDecoder,T=class r{constructor(e,t){this.data=e,this.format=t}static arrayBuffer(e){return new r(e,"ArrayBuffer")}static asyncIterable(e){if(!eo(e))throw new TypeError("Input must be of type AsyncIterable.");return new r(e,"AsyncIterable")}static base32Z(e){return new r(e,"Base32Z")}static base58Btc(e){return new r(e,"Base58Btc")}static base64Url(e){return new r(e,"Base64Url")}static bufferSource(e){return new r(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 r(e,"Hex")}static multibase(e){return new r(e,"Multibase")}static object(e){return new r(e,"Object")}static string(e){return new r(e,"String")}static uint8Array(e){return new r(e,"Uint8Array")}toArrayBuffer(){switch(this.format){case"Base58Btc":return D.baseDecode(this.data).buffer;case"Base64Url":return fe.baseDecode(this.data).buffer;case"BufferSource":{if(pr(this.data)==="ArrayBuffer")return this.data;if(ArrayBuffer.isView(this.data))return Qi(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 Pt(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 vn.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 D.baseEncode(e)}case"Multibase":return this.data.substring(1);case"Uint8Array":return D.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 fe.baseEncode(e)}case"BufferSource":{let e=this.toUint8Array();return fe.baseEncode(e)}case"Object":{let e=JSON.stringify(this.data),t=yr.encode(e);return fe.baseEncode(t)}case"String":{let e=yr.encode(this.data);return fe.baseEncode(e)}case"Uint8Array":return fe.baseEncode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Base64Url is not supported.`)}}toBlobAsync(){return Pt(this,void 0,void 0,function*(){var e,t,n,i;switch(this.format){case"AsyncIterable":{let u=[];try{for(var o=!0,s=to(this.data),c;c=yield s.next(),e=c.done,!e;o=!0){i=c.value,o=!1;let d=i;u.push(d)}}catch(d){t={error:d}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(t)throw t.error}}return new Blob(u)}default:throw new TypeError(`Asynchronous conversion from ${this.format} to Blob is not supported.`)}})}toHex(){let e=Array.from({length:256},(t,n)=>n.toString(16).padStart(2,"0"));switch(this.format){case"ArrayBuffer":{let t=this.toUint8Array();return r.uint8Array(t).toHex()}case"Base64Url":{let t=this.toUint8Array();return r.uint8Array(t).toHex()}case"Uint8Array":{let t="";for(let n=0;n<this.data.length;n++)t+=e[this.data[n]];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=fe.baseDecode(this.data),t=Je.decode(e);return JSON.parse(t)}case"String":return JSON.parse(this.data);case"Uint8Array":{let e=Je.decode(this.data);return JSON.parse(e)}default:throw new TypeError(`Conversion from ${this.format} to Object is not supported.`)}}toObjectAsync(){return Pt(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 Je.decode(this.data);case"Base64Url":{let e=fe.baseDecode(this.data);return Je.decode(e)}case"Object":return JSON.stringify(this.data);case"Uint8Array":return Je.decode(this.data);default:throw new TypeError(`Conversion from ${this.format} to String is not supported.`)}}toStringAsync(){return Pt(this,void 0,void 0,function*(){var e,t,n,i;switch(this.format){case"AsyncIterable":{let u="";try{for(var o=!0,s=to(this.data),c;c=yield s.next(),e=c.done,!e;o=!0){i=c.value,o=!1;let a=i;typeof a=="string"?u+=a:u+=Je.decode(a,{stream:!0})}}catch(a){t={error:a}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(t)throw t.error}}return u+=Je.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 vn.baseDecode(this.data);case"Base58Btc":return D.baseDecode(this.data);case"Base64Url":return fe.baseDecode(this.data);case"BufferSource":{let e=pr(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 n=parseInt(this.data.substring(t,t+2),16);if(isNaN(n))throw new TypeError("Input is not a valid hexadecimal string.");e[t/2]=n}return e}case"Object":{let e=JSON.stringify(this.data);return yr.encode(e)}case"String":return yr.encode(this.data);default:throw new TypeError(`Conversion from ${this.format} to Uint8Array is not supported.`)}}toUint8ArrayAsync(){return Pt(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 Dt;(function(r){r.Debug="debug",r.Silent="silent"})(Dt||(Dt={}));var bn=class{constructor(){this.logLevel=Dt.Silent}setLogLevel(e){this.logLevel=e}log(e){this.info(e)}info(e){this.logLevel!==Dt.Silent&&console.info(e)}error(e){this.logLevel!==Dt.Silent&&console.error(e)}},gu=new bn;typeof window<"u"&&(window.enboxLogger=gu);var ve={};su(ve,{decode:()=>lt,encodeTo:()=>Ge,encodingLength:()=>ze});var wu=io,ro=128,xu=127,vu=~xu,bu=Math.pow(2,31);function io(r,e,t){e=e||[],t=t||0;for(var n=t;r>=bu;)e[t++]=r&255|ro,r/=128;for(;r&vu;)e[t++]=r&255|ro,r>>>=7;return e[t]=r|0,io.bytes=t-n+1,e}var Eu=En,Au=128,no=127;function En(r,n){var t=0,n=n||0,i=0,o=n,s,c=r.length;do{if(o>=c)throw En.bytes=0,new RangeError("Could not decode varint");s=r[o++],t+=i<28?(s&no)<<i:(s&no)*Math.pow(2,i),i+=7}while(s>=Au);return En.bytes=o-n,t}var _u=Math.pow(2,7),Tu=Math.pow(2,14),Bu=Math.pow(2,21),Su=Math.pow(2,28),ku=Math.pow(2,35),Iu=Math.pow(2,42),Uu=Math.pow(2,49),Ou=Math.pow(2,56),Ku=Math.pow(2,63),Cu=function(r){return r<_u?1:r<Tu?2:r<Bu?3:r<Su?4:r<ku?5:r<Iu?6:r<Uu?7:r<Ou?8:r<Ku?9:10},Pu={encode:wu,decode:Eu,encodingLength:Cu},Du=Pu,Mt=Du;function lt(r,e=0){return[Mt.decode(r,e),Mt.decode.bytes]}function Ge(r,e,t=0){return Mt.encode(r,e,t),e}function ze(r){return Mt.encodingLength(r)}function An(r,e){let t=e.byteLength,n=ze(r),i=n+ze(t),o=new Uint8Array(i+t);return Ge(r,o,0),Ge(t,o,n),o.set(e,i),new pt(r,t,e,o)}function oo(r){let e=ht(r),[t,n]=lt(e),[i,o]=lt(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new pt(t,i,s,e)}function so(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Wi(r.bytes,t.bytes)}}var pt=class{code;size;digest;bytes;constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};function co(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Nu(t,Tn(r),e??D.encoder);default:return Lu(t,Tn(r),e??Ct.encoder)}}var uo=new WeakMap;function Tn(r){let e=uo.get(r);if(e==null){let t=new Map;return uo.set(r,t),t}return e}var Bn=class r{code;version;multihash;bytes;"/";constructor(e,t,n,i){this.code=t,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Nt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Fu)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.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,n=An(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&so(e.multihash,n.multihash)}toString(e){return co(this,e)}toJSON(){return{"/":co(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 r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:i,multihash:o,bytes:s}=t;return new r(n,i,o,s??ao(n,i,o.bytes))}else if(t[Ru]===!0){let{version:n,multihash:i,code:o}=t,s=oo(i);return r.create(n,o,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Nt)throw new Error(`Version 0 CID must use dag-pb (code: ${Nt}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let i=ao(e,t,n.bytes);return new r(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Nt,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,i=ht(e.subarray(n,n+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=i.subarray(t.multihashSize-t.digestSize),s=new pt(t.multihashCode,t.digestSize,o,i);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[f,m]=lt(e.subarray(t));return t+=m,f},i=n(),o=Nt;if(i===18?(i=0,t=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=t,c=n(),u=n(),a=t+u,d=a-s;return{version:i,codec:o,multihashCode:c,digestSize:u,multihashSize:d,size:a}}static parse(e,t){let[n,i]=Mu(e,t),o=r.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Tn(o).set(n,e),o}};function Mu(r,e){switch(r[0]){case"Q":{let t=e??D;return[D.prefix,t.decode(`${D.prefix}${r}`)]}case D.prefix:{let t=e??D;return[D.prefix,t.decode(r)]}case Ct.prefix:{let t=e??Ct;return[Ct.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Nu(r,e,t){let{prefix:n}=t;if(n!==D.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(n);if(i==null){let o=t.encode(r).slice(1);return e.set(n,o),o}else return i}function Lu(r,e,t){let{prefix:n}=t,i=e.get(n);if(i==null){let o=t.encode(r);return e.set(n,o),o}else return i}var Nt=112,Fu=18;function ao(r,e,t){let n=ze(r),i=n+ze(e),o=new Uint8Array(i+t.byteLength);return Ge(r,o,0),Ge(e,o,n),o.set(t,i),o}var Ru=Symbol.for("@ipld/js-cid/CID");var L=class r{static addPrefix(e){var t;let{code:n,data:i,name:o}=e;if(!(o?!n:n))throw new Error("Either 'name' or 'code' must be defined, but not both.");if(n=r.codeToName.has(n)?n:r.nameToCode.get(o),n===void 0)throw new Error(`Unsupported multicodec: ${(t=e.name)!==null&&t!==void 0?t:e.code}`);let s=ve.encodingLength(n),c=new Uint8Array(s+i.byteLength);return c.set(i,s),ve.encodeTo(n,c),c}static getCodeFromData(e){let{prefixedData:t}=e,[n,i]=ve.decode(t);return n}static getCodeFromName(e){let{name:t}=e,n=r.nameToCode.get(t);if(n===void 0)throw new Error(`Unsupported multicodec: ${t}`);return n}static getNameFromCode(e){let{code:t}=e,n=r.codeToName.get(t);if(n===void 0)throw new Error(`Unsupported multicodec: ${t}`);return n}static registerCodec(e){r.codeToName.set(e.code,e.name),r.nameToCode.set(e.name,e.code)}static removePrefix(e){let{prefixedData:t}=e,[n,i]=ve.decode(t),o=r.codeToName.get(n);if(o===void 0)throw new Error(`Unsupported multicodec: ${n}`);return{code:n,data:t.slice(i),name:o}}};L.codeToName=new Map;L.nameToCode=new Map;L.registerCodec({code:237,name:"ed25519-pub"});L.registerCodec({code:4864,name:"ed25519-priv"});L.registerCodec({code:236,name:"x25519-pub"});L.registerCodec({code:4866,name:"x25519-priv"});L.registerCodec({code:231,name:"secp256k1-pub"});L.registerCodec({code:4865,name:"secp256k1-priv"});function Sn(r){Object.keys(r).forEach(e=>{r[e]===void 0?delete r[e]:typeof r[e]=="object"&&Sn(r[e])})}var Ef=Ji(Ds(),1);function Af(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Ii(r,...e){if(!Af(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${r.length}`)}function Ui(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function Ms(r,e){Ii(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var Gr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),oe=(r,e)=>r<<32-e|r>>>e;var Zh=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function _f(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Oi(r){return typeof r=="string"&&(r=_f(r)),Ii(r),r}var Jr=class{clone(){return this._cloneInto()}},Qh={}.toString;function Ns(r){let e=n=>r().update(Oi(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Tf(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(t>>i&o),c=Number(t&o),u=n?4:0,a=n?0:4;r.setUint32(e+u,s,n),r.setUint32(e+a,c,n)}var Ls=(r,e,t)=>r&e^~r&t,Fs=(r,e,t)=>r&e^r&t^e&t,zr=class extends Jr{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Gr(this.buffer)}update(e){Ui(this);let{view:t,buffer:n,blockLen:i}=this;e=Oi(e);let o=e.length;for(let s=0;s<o;){let c=Math.min(i-this.pos,o-s);if(c===i){let u=Gr(e);for(;i<=o-s;s+=i)this.process(u,s);continue}n.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){Ui(this),Ms(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let f=s;f<i;f++)t[f]=0;Tf(n,i-8,BigInt(this.length*8),o),this.process(n,0);let c=Gr(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let a=u/4,d=this.get();if(a>d.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<a;f++)c.setUint32(4*f,d[f],o)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,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(n),e}};var Bf=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]),$e=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ve=new Uint32Array(64),Ki=class extends zr{constructor(){super(64,32,8,!1),this.A=$e[0]|0,this.B=$e[1]|0,this.C=$e[2]|0,this.D=$e[3]|0,this.E=$e[4]|0,this.F=$e[5]|0,this.G=$e[6]|0,this.H=$e[7]|0}get(){let{A:e,B:t,C:n,D:i,E:o,F:s,G:c,H:u}=this;return[e,t,n,i,o,s,c,u]}set(e,t,n,i,o,s,c,u){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=c|0,this.H=u|0}process(e,t){for(let f=0;f<16;f++,t+=4)Ve[f]=e.getUint32(t,!1);for(let f=16;f<64;f++){let m=Ve[f-15],g=Ve[f-2],w=oe(m,7)^oe(m,18)^m>>>3,b=oe(g,17)^oe(g,19)^g>>>10;Ve[f]=b+Ve[f-7]+w+Ve[f-16]|0}let{A:n,B:i,C:o,D:s,E:c,F:u,G:a,H:d}=this;for(let f=0;f<64;f++){let m=oe(c,6)^oe(c,11)^oe(c,25),g=d+m+Ls(c,u,a)+Bf[f]+Ve[f]|0,b=(oe(n,2)^oe(n,13)^oe(n,22))+Fs(n,i,o)|0;d=a,a=u,u=c,c=s+g|0,s=o,o=i,i=n,n=g+b|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,c=c+this.E|0,u=u+this.F|0,a=a+this.G|0,d=d+this.H|0,this.set(n,i,o,s,c,u,a,d)}roundClean(){Ve.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Rs=Ns(()=>new Ki);function $s(r){let e=n=>{if(n!==null&&typeof n=="object"&&!Array.isArray(n)){let i=Object.keys(n).sort(),o={};for(let s of i)o[s]=e(n[s]);return o}return n},t=e(r);return JSON.stringify(t)}var Sf=function(r,e,t,n){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function c(d){try{a(n.next(d))}catch(f){s(f)}}function u(d){try{a(n.throw(d))}catch(f){s(f)}}function a(d){d.done?o(d.value):i(d.value).then(c,u)}a((n=n.apply(r,e||[])).next())})},sr=class{static digest(e){return Sf(this,arguments,void 0,function*({data:t}){return Rs(t)})}};var kf=function(r,e,t,n){function i(o){return o instanceof t?o:new t(function(s){s(o)})}return new(t||(t=Promise))(function(o,s){function c(d){try{a(n.next(d))}catch(f){s(f)}}function u(d){try{a(n.throw(d))}catch(f){s(f)}}function a(d){d.done?o(d.value):i(d.value).then(c,u)}a((n=n.apply(r,e||[])).next())})};function V(r){return kf(this,arguments,void 0,function*({jwk:e}){let t=e.kty,n;if(t==="EC")n={crv:e.crv,kty:e.kty,x:e.x,y:e.y};else if(t==="oct")n={k:e.k,kty:e.kty};else if(t==="OKP")n={crv:e.crv,kty:e.kty,x:e.x};else if(t==="RSA")n={e:e.e,kty:e.kty,n:e.n};else throw new Error(`Unsupported key type: ${t}`);Sn(n);let i=$s(n),o=T.string(i).toUint8Array(),s=yield sr.digest({data:o});return T.uint8Array(s).toBase64Url()})}var Of=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Hs(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(e==="string"||e==="number"||e==="bigint"||e==="symbol")return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(r instanceof Uint8Array)return"Uint8Array";if(r.constructor===Object)return"Object";let t=Kf(r);return t||"Object"}function Kf(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(Of.includes(e))return e}var h=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}static equals(e,t){return e===t||e.major===t.major&&e.name===t.name}};h.uint=new h(0,"uint",!0);h.negint=new h(1,"negint",!0);h.bytes=new h(2,"bytes",!0);h.string=new h(3,"string",!0);h.array=new h(4,"array",!1);h.map=new h(5,"map",!1);h.tag=new h(6,"tag",!1);h.float=new h(7,"float",!0);h.false=new h(7,"false",!0);h.true=new h(7,"true",!0);h.null=new h(7,"null",!0);h.undefined=new h(7,"undefined",!0);h.break=new h(7,"break",!0);var y=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var cr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Cf=new TextEncoder;function Wr(r){return cr&&globalThis.Buffer.isBuffer(r)}function Xr(r){return r instanceof Uint8Array?Wr(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Pf=24,Df=200,Pi=cr?r=>r.length>=Pf?globalThis.Buffer.from(r):Js(r):r=>r.length>=Df?Cf.encode(r):Js(r),me=r=>Uint8Array.from(r),Gs=cr?(r,e,t)=>Wr(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),zs=cr?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),Xr(globalThis.Buffer.concat(r,e))):(r,e)=>{let t=new Uint8Array(e),n=0;for(let i of r)n+i.length>t.length&&(i=i.subarray(0,t.length-n)),t.set(i,n),n+=i.length;return t},Ws=cr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Yr(r,e){if(Wr(r)&&Wr(e))return r.compare(e);for(let t=0;t<r.length;t++)if(r[t]!==e[t])return r[t]<e[t]?-1:1;return 0}function Js(r){let e=[],t=0;for(let n=0;n<r.length;n++){let i=r.charCodeAt(n);i<128?e[t++]=i:i<2048?(e[t++]=i>>6|192,e[t++]=i&63|128):(i&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(i=65536+((i&1023)<<10)+(r.charCodeAt(++n)&1023),e[t++]=i>>18|240,e[t++]=i>>12&63|128,e[t++]=i>>6&63|128,e[t++]=i&63|128):(i>=55296&&i<=57343&&(i=65533),e[t++]=i>>12|224,e[t++]=i>>6&63|128,e[t++]=i&63|128)}return e}var Mf=256,ur=class{constructor(e=Mf){this.chunkSize=e,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let i=t.length-(this.maxCursor-this.cursor)-1;t.set(e,i)}else{if(t){let i=t.length-(this.maxCursor-this.cursor)-1;i<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,i),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=Ws(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=Gs(n,0,this.cursor)}else t=zs(this.chunks,this.cursor);return e&&this.reset(),t}},Zr=class{constructor(e){this.dest=e,this.cursor=0,this.chunks=[e]}reset(){this.cursor=0}push(e){if(this.cursor+e.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(e,this.cursor),this.cursor+=e.length}toBytes(e=!1){let t=this.dest.subarray(0,this.cursor);return e&&this.reset(),t}};var A="CBOR decode error:",Di="CBOR encode error:",ar=[];ar[23]=1;ar[24]=2;ar[25]=3;ar[26]=5;ar[27]=9;function Ie(r,e,t){if(r.length-e<t)throw new Error(`${A} not enough data for type`)}var S=[24,256,65536,4294967296,BigInt("18446744073709551616")];function j(r,e,t){Ie(r,e,1);let n=r[e];if(t.strict===!0&&n<S[0])throw new Error(`${A} integer encoded in more bytes than necessary (strict decode)`);return n}function q(r,e,t){Ie(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<S[1])throw new Error(`${A} integer encoded in more bytes than necessary (strict decode)`);return n}function H(r,e,t){Ie(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<S[2])throw new Error(`${A} integer encoded in more bytes than necessary (strict decode)`);return n}function J(r,e,t){Ie(r,e,8);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3],i=r[e+4]*16777216+(r[e+5]<<16)+(r[e+6]<<8)+r[e+7],o=(BigInt(n)<<BigInt(32))+BigInt(i);if(t.strict===!0&&o<S[3])throw new Error(`${A} integer encoded in more bytes than necessary (strict decode)`);if(o<=Number.MAX_SAFE_INTEGER)return Number(o);if(t.allowBigInt===!0)return o;throw new Error(`${A} integers outside of the safe integer range are not supported`)}function Xs(r,e,t,n){return new y(h.uint,j(r,e+1,n),2)}function Ys(r,e,t,n){return new y(h.uint,q(r,e+1,n),3)}function Zs(r,e,t,n){return new y(h.uint,H(r,e+1,n),5)}function Qs(r,e,t,n){return new y(h.uint,J(r,e+1,n),9)}function Z(r,e){return k(r,0,e.value)}function k(r,e,t){if(t<S[0]){let n=Number(t);r.push([e|n])}else if(t<S[1]){let n=Number(t);r.push([e|24,n])}else if(t<S[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<S[3]){let n=Number(t);r.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(n<S[4]){let i=[e|27,0,0,0,0,0,0,0],o=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));i[8]=o&255,o=o>>8,i[7]=o&255,o=o>>8,i[6]=o&255,o=o>>8,i[5]=o&255,i[4]=s&255,s=s>>8,i[3]=s&255,s=s>>8,i[2]=s&255,s=s>>8,i[1]=s&255,r.push(i)}else throw new Error(`${A} encountered BigInt larger than allowable range`)}}Z.encodedSize=function(e){return k.encodedSize(e.value)};k.encodedSize=function(e){return e<S[0]?1:e<S[1]?2:e<S[2]?3:e<S[3]?5:9};Z.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function ec(r,e,t,n){return new y(h.negint,-1-j(r,e+1,n),2)}function tc(r,e,t,n){return new y(h.negint,-1-q(r,e+1,n),3)}function rc(r,e,t,n){return new y(h.negint,-1-H(r,e+1,n),5)}var Mi=BigInt(-1),nc=BigInt(1);function ic(r,e,t,n){let i=J(r,e+1,n);if(typeof i!="bigint"){let o=-1-i;if(o>=Number.MIN_SAFE_INTEGER)return new y(h.negint,o,9)}if(n.allowBigInt!==!0)throw new Error(`${A} integers outside of the safe integer range are not supported`);return new y(h.negint,Mi-BigInt(i),9)}function Qr(r,e){let t=e.value,n=typeof t=="bigint"?t*Mi-nc:t*-1-1;k(r,e.type.majorEncoded,n)}Qr.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*Mi-nc:t*-1-1;return n<S[0]?1:n<S[1]?2:n<S[2]?3:n<S[3]?5:9};Qr.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function fr(r,e,t,n){Ie(r,e,t+n);let i=r.slice(e+t,e+t+n);return new y(h.bytes,i,t+n)}function oc(r,e,t,n){return fr(r,e,1,t)}function sc(r,e,t,n){return fr(r,e,2,j(r,e+1,n))}function cc(r,e,t,n){return fr(r,e,3,q(r,e+1,n))}function uc(r,e,t,n){return fr(r,e,5,H(r,e+1,n))}function ac(r,e,t,n){let i=J(r,e+1,n);if(typeof i=="bigint")throw new Error(`${A} 64-bit integer bytes lengths not supported`);return fr(r,e,9,i)}function en(r){return r.encodedBytes===void 0&&(r.encodedBytes=h.equals(r.type,h.string)?Pi(r.value):r.value),r.encodedBytes}function Ut(r,e){let t=en(e);k(r,e.type.majorEncoded,t.length),r.push(t)}Ut.encodedSize=function(e){let t=en(e);return k.encodedSize(t.length)+t.length};Ut.compareTokens=function(e,t){return Lf(en(e),en(t))};function Lf(r,e){return r.length<e.length?-1:r.length>e.length?1:Yr(r,e)}var fc=new TextDecoder,Rf=32;function $f(r,e,t){if(t-e<Rf){let i="";for(let o=e;o<t;o++){let s=r[o];if(s&128)return fc.decode(r.subarray(e,t));i+=String.fromCharCode(s)}return i}return fc.decode(r.subarray(e,t))}function dr(r,e,t,n,i){let o=t+n;Ie(r,e,o);let s=new y(h.string,$f(r,e+t,e+o),o);return i.retainStringBytes===!0&&(s.byteValue=r.slice(e+t,e+o)),s}function dc(r,e,t,n){return dr(r,e,1,t,n)}function hc(r,e,t,n){return dr(r,e,2,j(r,e+1,n),n)}function lc(r,e,t,n){return dr(r,e,3,q(r,e+1,n),n)}function pc(r,e,t,n){return dr(r,e,5,H(r,e+1,n),n)}function yc(r,e,t,n){let i=J(r,e+1,n);if(typeof i=="bigint")throw new Error(`${A} 64-bit integer string lengths not supported`);return dr(r,e,9,i,n)}var mc=Ut;function Ot(r,e,t,n){return new y(h.array,n,t)}function gc(r,e,t,n){return Ot(r,e,1,t)}function wc(r,e,t,n){return Ot(r,e,2,j(r,e+1,n))}function xc(r,e,t,n){return Ot(r,e,3,q(r,e+1,n))}function vc(r,e,t,n){return Ot(r,e,5,H(r,e+1,n))}function bc(r,e,t,n){let i=J(r,e+1,n);if(typeof i=="bigint")throw new Error(`${A} 64-bit integer array lengths not supported`);return Ot(r,e,9,i)}function Ec(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${A} indefinite length items not allowed`);return Ot(r,e,1,1/0)}function tn(r,e){k(r,h.array.majorEncoded,e.value)}tn.compareTokens=Z.compareTokens;tn.encodedSize=function(e){return k.encodedSize(e.value)};function Kt(r,e,t,n){return new y(h.map,n,t)}function Ac(r,e,t,n){return Kt(r,e,1,t)}function _c(r,e,t,n){return Kt(r,e,2,j(r,e+1,n))}function Tc(r,e,t,n){return Kt(r,e,3,q(r,e+1,n))}function Bc(r,e,t,n){return Kt(r,e,5,H(r,e+1,n))}function Sc(r,e,t,n){let i=J(r,e+1,n);if(typeof i=="bigint")throw new Error(`${A} 64-bit integer map lengths not supported`);return Kt(r,e,9,i)}function kc(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${A} indefinite length items not allowed`);return Kt(r,e,1,1/0)}function rn(r,e){k(r,h.map.majorEncoded,e.value)}rn.compareTokens=Z.compareTokens;rn.encodedSize=function(e){return k.encodedSize(e.value)};function Ic(r,e,t,n){return new y(h.tag,t,1)}function Uc(r,e,t,n){return new y(h.tag,j(r,e+1,n),2)}function Oc(r,e,t,n){return new y(h.tag,q(r,e+1,n),3)}function Kc(r,e,t,n){return new y(h.tag,H(r,e+1,n),5)}function Cc(r,e,t,n){return new y(h.tag,J(r,e+1,n),9)}function nn(r,e){k(r,h.tag.majorEncoded,e.value)}nn.compareTokens=Z.compareTokens;nn.encodedSize=function(e){return k.encodedSize(e.value)};var Ni=20,Li=21,Fi=22,Ri=23;function Pc(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${A} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new y(h.null,null,1):new y(h.undefined,void 0,1)}function Dc(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${A} indefinite length items not allowed`);return new y(h.break,void 0,1)}function $i(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${A} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${A} Infinity values are not supported`)}return new y(h.float,r,e)}function Mc(r,e,t,n){return $i(Vi(r,e+1),3,n)}function Nc(r,e,t,n){return $i(ji(r,e+1),5,n)}function Lc(r,e,t,n){return $i(Vc(r,e+1),9,n)}function on(r,e,t){let n=e.value;if(n===!1)r.push([h.float.majorEncoded|Ni]);else if(n===!0)r.push([h.float.majorEncoded|Li]);else if(n===null)r.push([h.float.majorEncoded|Fi]);else if(n===void 0)r.push([h.float.majorEncoded|Ri]);else{let i,o=!1;(!t||t.float64!==!0)&&(Rc(n),i=Vi(se,1),n===i||Number.isNaN(n)?(se[0]=249,r.push(se.slice(0,3)),o=!0):($c(n),i=ji(se,1),n===i&&(se[0]=250,r.push(se.slice(0,5)),o=!0))),o||(Jf(n),i=Vc(se,1),se[0]=251,r.push(se.slice(0,9)))}}on.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){Rc(n);let i=Vi(se,1);if(n===i||Number.isNaN(n))return 3;if($c(n),i=ji(se,1),n===i)return 5}return 9};var Fc=new ArrayBuffer(9),Q=new DataView(Fc,1),se=new Uint8Array(Fc,0);function Rc(r){if(r===1/0)Q.setUint16(0,31744,!1);else if(r===-1/0)Q.setUint16(0,64512,!1);else if(Number.isNaN(r))Q.setUint16(0,32256,!1);else{Q.setFloat32(0,r);let e=Q.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)Q.setUint16(0,31744,!1);else if(t===0)Q.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let i=t-127;i<-24?Q.setUint16(0,0):i<-14?Q.setUint16(0,(e&2147483648)>>16|1<<24+i,!1):Q.setUint16(0,(e&2147483648)>>16|i+15<<10|n>>13,!1)}}}function Vi(r,e){if(r.length-e<2)throw new Error(`${A} not enough data for float16`);let t=(r[e]<<8)+r[e+1];if(t===31744)return 1/0;if(t===64512)return-1/0;if(t===32256)return NaN;let n=t>>10&31,i=t&1023,o;return n===0?o=i*2**-24:n!==31?o=(i+1024)*2**(n-25):o=i===0?1/0:NaN,t&32768?-o:o}function $c(r){Q.setFloat32(0,r,!1)}function ji(r,e){if(r.length-e<4)throw new Error(`${A} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function Jf(r){Q.setFloat64(0,r,!1)}function Vc(r,e){if(r.length-e<8)throw new Error(`${A} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}on.compareTokens=Z.compareTokens;function _(r,e,t){throw new Error(`${A} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function sn(r){return()=>{throw new Error(`${A} ${r}`)}}var p=[];for(let r=0;r<=23;r++)p[r]=_;p[24]=Xs;p[25]=Ys;p[26]=Zs;p[27]=Qs;p[28]=_;p[29]=_;p[30]=_;p[31]=_;for(let r=32;r<=55;r++)p[r]=_;p[56]=ec;p[57]=tc;p[58]=rc;p[59]=ic;p[60]=_;p[61]=_;p[62]=_;p[63]=_;for(let r=64;r<=87;r++)p[r]=oc;p[88]=sc;p[89]=cc;p[90]=uc;p[91]=ac;p[92]=_;p[93]=_;p[94]=_;p[95]=sn("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)p[r]=dc;p[120]=hc;p[121]=lc;p[122]=pc;p[123]=yc;p[124]=_;p[125]=_;p[126]=_;p[127]=sn("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)p[r]=gc;p[152]=wc;p[153]=xc;p[154]=vc;p[155]=bc;p[156]=_;p[157]=_;p[158]=_;p[159]=Ec;for(let r=160;r<=183;r++)p[r]=Ac;p[184]=_c;p[185]=Tc;p[186]=Bc;p[187]=Sc;p[188]=_;p[189]=_;p[190]=_;p[191]=kc;for(let r=192;r<=215;r++)p[r]=Ic;p[216]=Uc;p[217]=Oc;p[218]=Kc;p[219]=Cc;p[220]=_;p[221]=_;p[222]=_;p[223]=_;for(let r=224;r<=243;r++)p[r]=sn("simple values are not supported");p[244]=_;p[245]=_;p[246]=_;p[247]=Pc;p[248]=sn("simple values are not supported");p[249]=Mc;p[250]=Nc;p[251]=Lc;p[252]=_;p[253]=_;p[254]=_;p[255]=Dc;var ge=[];for(let r=0;r<24;r++)ge[r]=new y(h.uint,r,1);for(let r=-1;r>=-24;r--)ge[31-r]=new y(h.negint,r,1);ge[64]=new y(h.bytes,new Uint8Array(0),1);ge[96]=new y(h.string,"",1);ge[128]=new y(h.array,0,1);ge[160]=new y(h.map,0,1);ge[244]=new y(h.false,!1,1);ge[245]=new y(h.true,!0,1);ge[246]=new y(h.null,null,1);function jc(r){switch(r.type){case h.false:return me([244]);case h.true:return me([245]);case h.null:return me([246]);case h.bytes:return r.value.length?void 0:me([64]);case h.string:return r.value===""?me([96]):void 0;case h.array:return r.value===0?me([128]):void 0;case h.map:return r.value===0?me([160]):void 0;case h.uint:return r.value<24?me([Number(r.value)]):void 0;case h.negint:if(r.value>=-24)return me([31-Number(r.value)])}}var Hc=Object.freeze({float64:!0,mapSorter:Zf,quickEncodeToken:jc});function zf(){let r=[];return r[h.uint.major]=Z,r[h.negint.major]=Qr,r[h.bytes.major]=Ut,r[h.string.major]=mc,r[h.array.major]=tn,r[h.map.major]=rn,r[h.tag.major]=nn,r[h.float.major]=on,r}var Wf=zf(),Xf=new ur,un=class r{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${Di} object contains circular references`);return new r(t,e)}},qe={null:new y(h.null,null),undefined:new y(h.undefined,void 0),true:new y(h.true,!0),false:new y(h.false,!1),emptyArray:new y(h.array,0),emptyMap:new y(h.map,0)},He={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new y(h.float,r):r>=0?new y(h.uint,r):new y(h.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new y(h.uint,r):new y(h.negint,r)},Uint8Array(r,e,t,n){return new y(h.bytes,r)},string(r,e,t,n){return new y(h.string,r)},boolean(r,e,t,n){return r?qe.true:qe.false},null(r,e,t,n){return qe.null},undefined(r,e,t,n){return qe.undefined},ArrayBuffer(r,e,t,n){return new y(h.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new y(h.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[qe.emptyArray,new y(h.break)]:qe.emptyArray;n=un.createCheck(n,r);let i=[],o=0;for(let s of r)i[o++]=cn(s,t,n);return t.addBreakTokens?[new y(h.array,r.length),i,new y(h.break)]:[new y(h.array,r.length),i]},Object(r,e,t,n){let i=e!=="Object",o=i?r.keys():Object.keys(r),s=i?r.size:o.length,c;if(s){c=new Array(s),n=un.createCheck(n,r);let u=!i&&t.ignoreUndefinedProperties,a=0;for(let d of o){let f=i?r.get(d):r[d];u&&f===void 0||(c[a++]=[cn(d,t,n),cn(f,t,n)])}a<s&&(c.length=a)}return c?.length?(Yf(c,t),t.addBreakTokens?[new y(h.map,c.length),c,new y(h.break)]:[new y(h.map,c.length),c]):t.addBreakTokens===!0?[qe.emptyMap,new y(h.break)]:qe.emptyMap}};He.Map=He.Object;He.Buffer=He.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))He[`${r}Array`]=He.DataView;function cn(r,e={},t){let n=Hs(r),i=e&&e.typeEncoders&&e.typeEncoders[n]||He[n];if(typeof i=="function"){let s=i(r,n,e,t);if(s!=null)return s}let o=He[n];if(!o)throw new Error(`${Di} unsupported type: ${n}`);return o(r,n,e,t)}function Yf(r,e){e.mapSorter&&r.sort(e.mapSorter)}function Zf(r,e){if(r[0]instanceof y&&e[0]instanceof y){let t=r[0],n=e[0];return t._keyBytes||(t._keyBytes=qc(t.value)),n._keyBytes||(n._keyBytes=qc(n.value)),Yr(t._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function qc(r){return Qf(r,Wf,Hc)}function Jc(r,e,t,n){if(Array.isArray(e))for(let i of e)Jc(r,i,t,n);else t[e.type.major](r,e,n)}var Xp=h.uint.majorEncoded,Yp=h.negint.majorEncoded,Zp=h.bytes.majorEncoded,Qp=h.string.majorEncoded,ey=h.array.majorEncoded,ty=h.float.majorEncoded|Ni,ry=h.float.majorEncoded|Li,ny=h.float.majorEncoded|Fi,iy=h.float.majorEncoded|Ri,oy=BigInt(-1),sy=BigInt(1);function Qf(r,e,t,n){let i=n instanceof Uint8Array,o=i?new Zr(n):Xf,s=cn(r,t);if(!Array.isArray(s)&&t.quickEncodeToken){let c=t.quickEncodeToken(s);if(c)return i?(o.push(c),o.toBytes()):c;let u=e[s.type.major];if(u.encodedSize){let a=u.encodedSize(s,t);if(i||(o=new ur(a)),u(o,s,t),o.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return i?o.toBytes():Xr(o.chunks[0])}}return o.reset(),Jc(o,s,e,t),o.toBytes(!0)}var hy=Symbol.for("DONE"),ly=Symbol.for("BREAK");var Gc;(function(r){r[r.OKP=1]="OKP",r[r.EC2=2]="EC2",r[r.Symmetric=4]="Symmetric"})(Gc||(Gc={}));var O;(function(r){r[r.P256=1]="P256",r[r.P384=2]="P384",r[r.P521=3]="P521",r[r.X25519=4]="X25519",r[r.X448=5]="X448",r[r.Ed25519=6]="Ed25519",r[r.Ed448=7]="Ed448",r[r.Secp256k1=8]="Secp256k1"})(O||(O={}));var G;(function(r){r[r.EdDSA=-8]="EdDSA",r[r.ES256=-7]="ES256",r[r.ES384=-35]="ES384",r[r.ES512=-36]="ES512",r[r.ES256K=-47]="ES256K"})(G||(G={}));var zc;(function(r){r[r.Kty=1]="Kty",r[r.Kid=2]="Kid",r[r.Alg=3]="Alg",r[r.KeyOps=4]="KeyOps",r[r.BaseIv=5]="BaseIv"})(zc||(zc={}));var Wc;(function(r){r[r.Crv=-1]="Crv",r[r.X=-2]="X",r[r.Y=-3]="Y",r[r.D=-4]="D"})(Wc||(Wc={}));var Sy={"P-256":O.P256,"P-384":O.P384,"P-521":O.P521,X25519:O.X25519,Ed25519:O.Ed25519,Ed448:O.Ed448,secp256k1:O.Secp256k1},ky={[O.P256]:"P-256",[O.P384]:"P-384",[O.P521]:"P-521",[O.X25519]:"X25519",[O.Ed25519]:"Ed25519",[O.Ed448]:"Ed448",[O.Secp256k1]:"secp256k1"},Iy={EdDSA:G.EdDSA,ES256:G.ES256,ES384:G.ES384,ES512:G.ES512,ES256K:G.ES256K},Uy={[G.EdDSA]:"EdDSA",[G.ES256]:"ES256",[G.ES384]:"ES384",[G.ES512]:"ES512",[G.ES256K]:"ES256K"};var Xc;(function(r){r[r.Alg=1]="Alg",r[r.Crit=2]="Crit",r[r.ContentType=3]="ContentType",r[r.Kid=4]="Kid"})(Xc||(Xc={}));var Yc;(function(r){r[r.Iss=1]="Iss",r[r.Sub=2]="Sub",r[r.Aud=3]="Aud",r[r.Exp=4]="Exp",r[r.Nbf=5]="Nbf",r[r.Iat=6]="Iat",r[r.Cti=7]="Cti",r[r.Nonce=10]="Nonce",r[r.Ueid=256]="Ueid",r[r.Sueids=257]="Sueids",r[r.Oemid=258]="Oemid",r[r.Hwmodel=259]="Hwmodel",r[r.Hwversion=260]="Hwversion",r[r.Secboot=262]="Secboot",r[r.Dbgstat=263]="Dbgstat",r[r.Location=264]="Location",r[r.Profile=265]="Profile",r[r.Submods=266]="Submods",r[r.Measres=272]="Measres",r[r.Intuse=268]="Intuse"})(Yc||(Yc={}));var Zc;(function(r){r[r.Enabled=0]="Enabled",r[r.Disabled=1]="Disabled",r[r.DisabledSinceBoot=2]="DisabledSinceBoot",r[r.DisabledPermanently=3]="DisabledPermanently",r[r.DisabledFullyAndPermanently=4]="DisabledFullyAndPermanently"})(Zc||(Zc={}));var Qc;(function(r){r[r.Unrestricted=1]="Unrestricted",r[r.Restricted=2]="Restricted",r[r.SecureRestricted=3]="SecureRestricted",r[r.Hardware=4]="Hardware"})(Qc||(Qc={}));var fn=(o=>(o.authentication="authentication",o.assertionMethod="assertionMethod",o.keyAgreement="keyAgreement",o.capabilityInvocation="capabilityInvocation",o.capabilityDelegation="capabilityDelegation",o))(fn||{});var dn=class r extends Error{constructor(t,n){super(`${t}: ${n}`);this.code=t;this.name="DidError",Object.setPrototypeOf(this,new.target.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,r)}};function qi(r){if(typeof r=="string"&&r.length!==0)return r.split("#").pop()}function Eg({didDocument:r,id:e,type:t}){return r?.service?.filter(n=>!(e&&n.id!==e||t&&n.type!==t))??[]}async function Ag({didDocument:r,publicKeyJwk:e,publicKeyMultibase:t}){let n=eu({didDocument:r});for(let i of n)if(e&&i.publicKeyJwk){if(await V({jwk:e})===await V({jwk:i.publicKeyJwk}))return i}else if(t&&i.publicKeyMultibase&&t===i.publicKeyMultibase)return i;return null}function eu({didDocument:r}){if(!r)throw new TypeError("Required parameter missing: 'didDocument'");let e=[];return e.push(...r.verificationMethod?.filter(Hi)??[]),Object.keys(fn).forEach(t=>{e.push(...r[t]?.filter(Hi)??[])}),e}function _g({didDocument:r}){let t=eu({didDocument:r}).map(n=>n.type);return[...new Set(t)]}function Tg({didDocument:r,methodId:e}){let t=[];return Object.keys(fn).forEach(n=>{if(Array.isArray(r[n])){let i=r[n],o=qi(e);i.some(c=>{let u=qi(c)===o,a=Hi(c)&&qi(c.id)===o;return u||a})&&t.push(n)}}),t}function nd(r){return!r||typeof r!="object"||r===null?!1:"id"in r&&"type"in r&&"serviceEndpoint"in r}function Bg(r){if(!nd(r)||r.type!=="DecentralizedWebNode")return!1;let e=t=>typeof t=="string"||Array.isArray(t)&&t.every(n=>typeof n=="string");return!("enc"in r&&r.enc!==void 0&&!e(r.enc)||"sig"in r&&r.sig!==void 0&&!e(r.sig))}function Hi(r){return!(!r||typeof r!="object"||r===null||!("id"in r&&"type"in r&&"controller"in r)||typeof r.id!="string"||typeof r.type!="string"||typeof r.controller!="string")}function Sg(r){return!(!r||typeof r!="object"||r===null)&&"uri"in r&&"document"in r&&"metadata"in r&&(!("keyManager"in r)||r.keyManager===void 0)}function kg({keyBytes:r,multicodecCode:e,multicodecName:t}){let n=L.addPrefix({code:e,data:r,name:t}),i=T.uint8Array(n).toBase58Btc();return T.base58Btc(i).toMultibase()}function Ig({multibaseKeyId:r}){try{let e=T.multibase(r).toBase58Btc(),t=T.base58Btc(e).toUint8Array(),{code:n,data:i,name:o}=L.removePrefix({prefixedData:t});return{keyBytes:i,multicodecCode:n,multicodecName:o}}catch{throw new dn("invalidDid",`Invalid multibase identifier: ${r}`)}}export{qi as extractDidFragment,Eg as getServices,Ag as getVerificationMethodByKey,_g as getVerificationMethodTypes,eu as getVerificationMethods,Tg as getVerificationRelationshipsById,nd as isDidService,Hi as isDidVerificationMethod,Bg as isDwnDidService,Sg as isPortableDid,kg as keyBytesToMultibaseId,Ig as multibaseIdToKeyBytes};
2
2
  /*! Bundled license information:
3
3
 
4
4
  ieee754/index.js: