blockstore-idb
Advanced tools
Comparing version 1.1.2 to 1.1.3
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.BlockstoreIdb = factory()}(typeof self !== 'undefined' ? self : this, function () { | ||
"use strict";var BlockstoreIdb=(()=>{var Jt=Object.create;var ie=Object.defineProperty;var _t=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var Kt=Object.getPrototypeOf,Qt=Object.prototype.hasOwnProperty;var ae=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Pe=(r,e)=>{for(var t in e)ie(r,t,{get:e[t],enumerable:!0})},Re=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Gt(e))!Qt.call(r,o)&&o!==t&&ie(r,o,{get:()=>e[o],enumerable:!(n=_t(e,o))||n.enumerable});return r};var $e=(r,e,t)=>(t=r!=null?Jt(Kt(r)):{},Re(e||!r||!r.__esModule?ie(t,"default",{value:r,enumerable:!0}):t,r)),Wt=r=>Re(ie({},"__esModule",{value:!0}),r);var Je=ae((Tn,qe)=>{"use strict";function je(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Xt(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return je(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),je(new o,t)}}qe.exports=Xt});var ct=ae((vo,at)=>{var K=1e3,Q=K*60,W=Q*60,P=W*24,kr=P*7,Ir=P*365.25;at.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return Br(r);if(t==="number"&&isFinite(r))return e.long?Or(r):Lr(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Br(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*Ir;case"weeks":case"week":case"w":return t*kr;case"days":case"day":case"d":return t*P;case"hours":case"hour":case"hrs":case"hr":case"h":return t*W;case"minutes":case"minute":case"mins":case"min":case"m":return t*Q;case"seconds":case"second":case"secs":case"sec":case"s":return t*K;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Lr(r){var e=Math.abs(r);return e>=P?Math.round(r/P)+"d":e>=W?Math.round(r/W)+"h":e>=Q?Math.round(r/Q)+"m":e>=K?Math.round(r/K)+"s":r+"ms"}function Or(r){var e=Math.abs(r);return e>=P?de(r,e,P,"day"):e>=W?de(r,e,W,"hour"):e>=Q?de(r,e,Q,"minute"):e>=K?de(r,e,K,"second"):r+" ms"}function de(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var ft=ae((Eo,dt)=>{function Nr(r){t.debug=t,t.default=t,t.coerce=f,t.disable=s,t.enable=o,t.enabled=i,t.humanize=ct(),t.destroy=C,Object.keys(r).forEach(d=>{t[d]=r[d]}),t.names=[],t.skips=[],t.formatters={};function e(d){let h=0;for(let x=0;x<d.length;x++)h=(h<<5)-h+d.charCodeAt(x),h|=0;return t.colors[Math.abs(h)%t.colors.length]}t.selectColor=e;function t(d){let h,x=null,k,a;function u(...m){if(!u.enabled)return;let l=u,b=Number(new Date),y=b-(h||b);l.diff=y,l.prev=h,l.curr=b,h=b,m[0]=t.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let p=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(E,w)=>{if(E==="%%")return"%";p++;let v=t.formatters[w];if(typeof v=="function"){let F=m[p];E=v.call(l,F),m.splice(p,1),p--}return E}),t.formatArgs.call(l,m),(l.log||t.log).apply(l,m)}return u.namespace=d,u.useColors=t.useColors(),u.color=t.selectColor(d),u.extend=n,u.destroy=t.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>x!==null?x:(k!==t.namespaces&&(k=t.namespaces,a=t.enabled(d)),a),set:m=>{x=m}}),typeof t.init=="function"&&t.init(u),u}function n(d,h){let x=t(this.namespace+(typeof h>"u"?":":h)+d);return x.log=this.log,x}function o(d){t.save(d),t.namespaces=d,t.names=[],t.skips=[];let h,x=(typeof d=="string"?d:"").split(/[\s,]+/),k=x.length;for(h=0;h<k;h++)x[h]&&(d=x[h].replace(/\*/g,".*?"),d[0]==="-"?t.skips.push(new RegExp("^"+d.slice(1)+"$")):t.names.push(new RegExp("^"+d+"$")))}function s(){let d=[...t.names.map(c),...t.skips.map(c).map(h=>"-"+h)].join(",");return t.enable(""),d}function i(d){if(d[d.length-1]==="*")return!0;let h,x;for(h=0,x=t.skips.length;h<x;h++)if(t.skips[h].test(d))return!1;for(h=0,x=t.names.length;h<x;h++)if(t.names[h].test(d))return!0;return!1}function c(d){return d.toString().substring(2,d.toString().length-2).replace(/\.\*\?$/,"*")}function f(d){return d instanceof Error?d.stack||d.message:d}function C(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}dt.exports=Nr});var ut=ae((M,fe)=>{M.formatArgs=Vr;M.save=Pr;M.load=Rr;M.useColors=Tr;M.storage=$r();M.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();M.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Tr(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Vr(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+fe.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}M.log=console.debug||console.log||(()=>{});function Pr(r){try{r?M.storage.setItem("debug",r):M.storage.removeItem("debug")}catch{}}function Rr(){let r;try{r=M.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function $r(){try{return localStorage}catch{}}fe.exports=ft()(M);var{formatters:jr}=fe.exports;jr.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var On={};Pe(On,{IDBBlockstore:()=>Ve});var j={};Pe(j,{abortedError:()=>tr,closeFailedError:()=>Ht,deleteFailedError:()=>Ge,getFailedError:()=>Yt,hasFailedError:()=>er,notFoundError:()=>ce,openFailedError:()=>Zt,putFailedError:()=>_e});var L=$e(Je(),1);function Zt(r){return r=r??new Error("Open failed"),(0,L.default)(r,"ERR_OPEN_FAILED")}function Ht(r){return r=r??new Error("Close failed"),(0,L.default)(r,"ERR_CLOSE_FAILED")}function _e(r){return r=r??new Error("Put failed"),(0,L.default)(r,"ERR_PUT_FAILED")}function Yt(r){return r=r??new Error("Get failed"),(0,L.default)(r,"ERR_GET_FAILED")}function Ge(r){return r=r??new Error("Delete failed"),(0,L.default)(r,"ERR_DELETE_FAILED")}function er(r){return r=r??new Error("Has failed"),(0,L.default)(r,"ERR_HAS_FAILED")}function ce(r){return r=r??new Error("Not Found"),(0,L.default)(r,"ERR_NOT_FOUND")}function tr(r){return r=r??new Error("Aborted"),(0,L.default)(r,"ERR_ABORTED")}var T=class{has(e,t){return Promise.reject(new Error(".has is not implemented"))}put(e,t,n){return Promise.reject(new Error(".put is not implemented"))}async*putMany(e,t){for await(let{cid:n,block:o}of e)await this.put(n,o,t),yield n}get(e,t){return Promise.reject(new Error(".get is not implemented"))}async*getMany(e,t){for await(let n of e)yield{cid:n,block:await this.get(n,t)}}async delete(e,t){await Promise.reject(new Error(".delete is not implemented"))}async*deleteMany(e,t){for await(let n of e)await this.delete(n,t),yield n}async*getAll(e){throw new Error(".getAll is not implemented")}};function rr(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 o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var c=r.length,f=r.charAt(0),C=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function h(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";for(var u=0,m=0,l=0,b=a.length;l!==b&&a[l]===0;)l++,u++;for(var y=(b-l)*d+1>>>0,p=new Uint8Array(y);l!==b;){for(var g=a[l],E=0,w=y-1;(g!==0||E<m)&&w!==-1;w--,E++)g+=256*p[w]>>>0,p[w]=g%c>>>0,g=g/c>>>0;if(g!==0)throw new Error("Non-zero carry");m=E,l++}for(var v=y-m;v!==y&&p[v]===0;)v++;for(var F=f.repeat(u);v<y;++v)F+=r.charAt(p[v]);return F}function x(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var u=0;if(a[u]!==" "){for(var m=0,l=0;a[u]===f;)m++,u++;for(var b=(a.length-u)*C+1>>>0,y=new Uint8Array(b);a[u];){var p=t[a.charCodeAt(u)];if(p===255)return;for(var g=0,E=b-1;(p!==0||g<l)&&E!==-1;E--,g++)p+=c*y[E]>>>0,y[E]=p%256>>>0,p=p/256>>>0;if(p!==0)throw new Error("Non-zero carry");l=g,u++}if(a[u]!==" "){for(var w=b-l;w!==b&&y[w]===0;)w++;for(var v=new Uint8Array(m+(b-w)),F=m;w!==b;)v[F++]=y[w++];return v}}}function k(a){var u=x(a);if(u)return u;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:x,decode:k}}var nr=rr,or=nr,Ke=or;var Rn=new Uint8Array(0);var Qe=(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},V=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")};var le=class{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")}},pe=class{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 We(this,e)}},be=class{constructor(e){this.decoders=e}or(e){return We(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},We=(r,e)=>new be({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),we=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new le(e,t,n),this.decoder=new pe(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Xe=({name:r,prefix:e,encode:t,decode:n})=>new we(r,e,t,n),me=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=Ke(t,e);return Xe({prefix:r,name:e,encode:n,decode:s=>V(o(s))})},sr=(r,e,t,n)=>{let o={};for(let d=0;d<e.length;++d)o[e[d]]=d;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),c=0,f=0,C=0;for(let d=0;d<s;++d){let h=o[r[d]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<t|h,c+=t,c>=8&&(c-=8,i[C++]=255&f>>c)}if(c>=t||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return i},ir=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,c=0;for(let f=0;f<r.length;++f)for(c=c<<8|r[f],i+=8;i>t;)i-=t,s+=e[o&c>>i];if(i&&(s+=e[o&c<<t-i]),n)for(;s.length*t&7;)s+="=";return s},I=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>Xe({prefix:e,name:r,encode(o){return ir(o,n,t)},decode(o){return sr(o,n,t,r)}});var q=I({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Gn=I({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Kn=I({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Qn=I({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Wn=I({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Xn=I({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Zn=I({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Hn=I({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Yn=I({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ar=Ye,Ze=128,cr=127,dr=~cr,fr=Math.pow(2,31);function Ye(r,e,t){e=e||[],t=t||0;for(var n=t;r>=fr;)e[t++]=r&255|Ze,r/=128;for(;r&dr;)e[t++]=r&255|Ze,r>>>=7;return e[t]=r|0,Ye.bytes=t-n+1,e}var ur=ye,hr=128,He=127;function ye(r,n){var t=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw ye.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&He)<<o:(i&He)*Math.pow(2,o),o+=7}while(i>=hr);return ye.bytes=s-n,t}var lr=Math.pow(2,7),pr=Math.pow(2,14),br=Math.pow(2,21),wr=Math.pow(2,28),mr=Math.pow(2,35),yr=Math.pow(2,42),gr=Math.pow(2,49),xr=Math.pow(2,56),vr=Math.pow(2,63),Er=function(r){return r<lr?1:r<pr?2:r<br?3:r<wr?4:r<mr?5:r<yr?6:r<gr?7:r<xr?8:r<vr?9:10},Cr={encode:ar,decode:ur,encodingLength:Er},Ar=Cr,Y=Ar;var ee=(r,e=0)=>[Y.decode(r,e),Y.decode.bytes],J=(r,e,t=0)=>(Y.encode(r,e,t),e),_=r=>Y.encodingLength(r);var tt=(r,e)=>{let t=e.byteLength,n=_(r),o=n+_(t),s=new Uint8Array(o+t);return J(r,s,0),J(t,s,n),s.set(e,o),new G(r,t,e,s)},ge=r=>{let e=V(r),[t,n]=ee(e),[o,s]=ee(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new G(t,o,i,e)},rt=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Qe(r.bytes,t.bytes)}},G=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var O=me({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),so=me({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ot=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Fr(t,xe(r),e||O.encoder);default:return Ur(t,xe(r),e||q.encoder)}};var st=new WeakMap,xe=r=>{let e=st.get(r);if(e==null){let t=new Map;return st.set(r,t),t}return e},S=class{constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}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!==te)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Mr)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return S.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=tt(e,t);return S.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 S.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&rt(e.multihash,n.multihash)}toString(e){return ot(this,e)}toJSON(){return{"/":ot(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof S)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new S(n,o,s,i||it(n,o,s.bytes))}else if(t[zr]===!0){let{version:n,multihash:o,code:s}=t,i=ge(o);return S.create(n,s,i)}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!==te)throw new Error(`Version 0 CID must use dag-pb (code: ${te}) block encoding`);return new S(e,t,n,n.bytes)}case 1:{let o=it(e,t,n.bytes);return new S(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return S.create(0,te,e)}static createV1(e,t){return S.create(1,e,t)}static decode(e){let[t,n]=S.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=S.inspectBytes(e),n=t.size-t.multihashSize,o=V(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new G(t.multihashCode,t.digestSize,s,o);return[t.version===0?S.createV0(i):S.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[h,x]=ee(e.subarray(t));return t+=x,h},o=n(),s=te;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,c=n(),f=n(),C=t+f,d=C-i;return{version:o,codec:s,multihashCode:c,digestSize:f,multihashSize:d,size:C}}static parse(e,t){let[n,o]=Sr(e,t),s=S.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return xe(s).set(n,e),s}},Sr=(r,e)=>{switch(r[0]){case"Q":{let t=e||O;return[O.prefix,t.decode(`${O.prefix}${r}`)]}case O.prefix:{let t=e||O;return[O.prefix,t.decode(r)]}case q.prefix:{let t=e||q;return[q.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)]}}},Fr=(r,e,t)=>{let{prefix:n}=t;if(n!==O.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},Ur=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},te=112,Mr=18,it=(r,e,t)=>{let n=_(r),o=n+_(e),s=new Uint8Array(o+t.byteLength);return J(r,s,0),J(e,s,n),s.set(t,o),s},zr=Symbol.for("@ipld/js-cid/CID");var z=$e(ut(),1);function qr(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 o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var c=r.length,f=r.charAt(0),C=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function h(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";for(var u=0,m=0,l=0,b=a.length;l!==b&&a[l]===0;)l++,u++;for(var y=(b-l)*d+1>>>0,p=new Uint8Array(y);l!==b;){for(var g=a[l],E=0,w=y-1;(g!==0||E<m)&&w!==-1;w--,E++)g+=256*p[w]>>>0,p[w]=g%c>>>0,g=g/c>>>0;if(g!==0)throw new Error("Non-zero carry");m=E,l++}for(var v=y-m;v!==y&&p[v]===0;)v++;for(var F=f.repeat(u);v<y;++v)F+=r.charAt(p[v]);return F}function x(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var u=0;if(a[u]!==" "){for(var m=0,l=0;a[u]===f;)m++,u++;for(var b=(a.length-u)*C+1>>>0,y=new Uint8Array(b);a[u];){var p=t[a.charCodeAt(u)];if(p===255)return;for(var g=0,E=b-1;(p!==0||g<l)&&E!==-1;E--,g++)p+=c*y[E]>>>0,y[E]=p%256>>>0,p=p/256>>>0;if(p!==0)throw new Error("Non-zero carry");l=g,u++}if(a[u]!==" "){for(var w=b-l;w!==b&&y[w]===0;)w++;for(var v=new Uint8Array(m+(b-w)),F=m;w!==b;)v[F++]=y[w++];return v}}}function k(a){var u=x(a);if(u)return u;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:x,decode:k}}var Jr=qr,_r=Jr,ht=_r;var Ao=new Uint8Array(0);var lt=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")};var ve=class{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")}},Ee=class{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 pt(this,e)}},Ce=class{constructor(e){this.decoders=e}or(e){return pt(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},pt=(r,e)=>new Ce({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),Ae=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new ve(e,t,n),this.decoder=new Ee(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},bt=({name:r,prefix:e,encode:t,decode:n})=>new Ae(r,e,t,n),Se=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=ht(t,e);return bt({prefix:r,name:e,encode:n,decode:s=>lt(o(s))})},Gr=(r,e,t,n)=>{let o={};for(let d=0;d<e.length;++d)o[e[d]]=d;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),c=0,f=0,C=0;for(let d=0;d<s;++d){let h=o[r[d]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<t|h,c+=t,c>=8&&(c-=8,i[C++]=255&f>>c)}if(c>=t||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return i},Kr=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,c=0;for(let f=0;f<r.length;++f)for(c=c<<8|r[f],i+=8;i>t;)i-=t,s+=e[o&c>>i];if(i&&(s+=e[o&c<<t-i]),n)for(;s.length*t&7;)s+="=";return s},U=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>bt({prefix:e,name:r,encode(o){return Kr(o,n,t)},decode(o){return Gr(o,n,t,r)}});var wt=U({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Do=U({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ko=U({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Io=U({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Bo=U({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Lo=U({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Oo=U({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),No=U({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),To=U({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var mt=Se({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ro=Se({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var yt=U({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qo=U({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Jo=U({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_o=U({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});z.default.formatters.b=r=>r==null?"undefined":mt.baseEncode(r);z.default.formatters.t=r=>r==null?"undefined":wt.baseEncode(r);z.default.formatters.m=r=>r==null?"undefined":yt.baseEncode(r);z.default.formatters.p=r=>r==null?"undefined":r.toString();z.default.formatters.c=r=>r==null?"undefined":r.toString();z.default.formatters.k=r=>r==null?"undefined":r.toString();z.default.formatters.a=r=>r==null?"undefined":r.toString();function Qr(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function gt(r){let e=Qr(`${r}:trace`);return z.default.enabled(`${r}:trace`)&&z.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,z.default)(`${r}:trace`)),Object.assign((0,z.default)(r),{error:(0,z.default)(`${r}:error`),trace:e})}var xs=gt("blockstore:core:tiered");var R={...j};var Xr=(r,e)=>e.some(t=>r instanceof t),xt,vt;function Zr(){return xt||(xt=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Hr(){return vt||(vt=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Et=new WeakMap,Ue=new WeakMap,Ct=new WeakMap,Fe=new WeakMap,ze=new WeakMap;function Yr(r){let e=new Promise((t,n)=>{let o=()=>{r.removeEventListener("success",s),r.removeEventListener("error",i)},s=()=>{t(D(r.result)),o()},i=()=>{n(r.error),o()};r.addEventListener("success",s),r.addEventListener("error",i)});return e.then(t=>{t instanceof IDBCursor&&Et.set(t,r)}).catch(()=>{}),ze.set(e,r),e}function en(r){if(Ue.has(r))return;let e=new Promise((t,n)=>{let o=()=>{r.removeEventListener("complete",s),r.removeEventListener("error",i),r.removeEventListener("abort",i)},s=()=>{t(),o()},i=()=>{n(r.error||new DOMException("AbortError","AbortError")),o()};r.addEventListener("complete",s),r.addEventListener("error",i),r.addEventListener("abort",i)});Ue.set(r,e)}var Me={get(r,e,t){if(r instanceof IDBTransaction){if(e==="done")return Ue.get(r);if(e==="objectStoreNames")return r.objectStoreNames||Ct.get(r);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return D(r[e])},set(r,e,t){return r[e]=t,!0},has(r,e){return r instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in r}};function At(r){Me=r(Me)}function tn(r){return r===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){let n=r.call(ue(this),e,...t);return Ct.set(n,e.sort?e.sort():[e]),D(n)}:Hr().includes(r)?function(...e){return r.apply(ue(this),e),D(Et.get(this))}:function(...e){return D(r.apply(ue(this),e))}}function rn(r){return typeof r=="function"?tn(r):(r instanceof IDBTransaction&&en(r),Xr(r,Zr())?new Proxy(r,Me):r)}function D(r){if(r instanceof IDBRequest)return Yr(r);if(Fe.has(r))return Fe.get(r);let e=rn(r);return e!==r&&(Fe.set(r,e),ze.set(e,r)),e}var ue=r=>ze.get(r);function Ft(r,e,{blocked:t,upgrade:n,blocking:o,terminated:s}={}){let i=indexedDB.open(r,e),c=D(i);return n&&i.addEventListener("upgradeneeded",f=>{n(D(i.result),f.oldVersion,f.newVersion,D(i.transaction),f)}),t&&i.addEventListener("blocked",f=>t(f.oldVersion,f.newVersion,f)),c.then(f=>{s&&f.addEventListener("close",()=>s()),o&&f.addEventListener("versionchange",C=>o(C.oldVersion,C.newVersion,C))}).catch(()=>{}),c}function Ut(r,{blocked:e}={}){let t=indexedDB.deleteDatabase(r);return e&&t.addEventListener("blocked",n=>e(n.oldVersion,n)),D(t).then(()=>{})}var nn=["get","getKey","getAll","getAllKeys","count"],on=["put","add","delete","clear"],De=new Map;function St(r,e){if(!(r instanceof IDBDatabase&&!(e in r)&&typeof e=="string"))return;if(De.get(e))return De.get(e);let t=e.replace(/FromIndex$/,""),n=e!==t,o=on.includes(t);if(!(t in(n?IDBIndex:IDBObjectStore).prototype)||!(o||nn.includes(t)))return;let s=async function(i,...c){let f=this.transaction(i,o?"readwrite":"readonly"),C=f.store;return n&&(C=C.index(c.shift())),(await Promise.all([C[t](...c),o&&f.done]))[0]};return De.set(e,s),s}At(r=>({...r,get:(e,t,n)=>St(e,t)||r.get(e,t,n),has:(e,t)=>!!St(e,t)||r.has(e,t)}));function sn(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 o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var c=r.length,f=r.charAt(0),C=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function h(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";for(var u=0,m=0,l=0,b=a.length;l!==b&&a[l]===0;)l++,u++;for(var y=(b-l)*d+1>>>0,p=new Uint8Array(y);l!==b;){for(var g=a[l],E=0,w=y-1;(g!==0||E<m)&&w!==-1;w--,E++)g+=256*p[w]>>>0,p[w]=g%c>>>0,g=g/c>>>0;if(g!==0)throw new Error("Non-zero carry");m=E,l++}for(var v=y-m;v!==y&&p[v]===0;)v++;for(var F=f.repeat(u);v<y;++v)F+=r.charAt(p[v]);return F}function x(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var u=0;if(a[u]!==" "){for(var m=0,l=0;a[u]===f;)m++,u++;for(var b=(a.length-u)*C+1>>>0,y=new Uint8Array(b);a[u];){var p=t[a.charCodeAt(u)];if(p===255)return;for(var g=0,E=b-1;(p!==0||g<l)&&E!==-1;E--,g++)p+=c*y[E]>>>0,y[E]=p%256>>>0,p=p/256>>>0;if(p!==0)throw new Error("Non-zero carry");l=g,u++}if(a[u]!==" "){for(var w=b-l;w!==b&&y[w]===0;)w++;for(var v=new Uint8Array(m+(b-w)),F=m;w!==b;)v[F++]=y[w++];return v}}}function k(a){var u=x(a);if(u)return u;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:x,decode:k}}var an=sn,cn=an,Mt=cn;var Os=new Uint8Array(0);var zt=(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},$=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")};var ke=class{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")}},Ie=class{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 Dt(this,e)}},Be=class{constructor(e){this.decoders=e}or(e){return Dt(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Dt=(r,e)=>new Be({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),Le=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new ke(e,t,n),this.decoder=new Ie(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},kt=({name:r,prefix:e,encode:t,decode:n})=>new Le(r,e,t,n),Oe=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=Mt(t,e);return kt({prefix:r,name:e,encode:n,decode:s=>$(o(s))})},dn=(r,e,t,n)=>{let o={};for(let d=0;d<e.length;++d)o[e[d]]=d;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),c=0,f=0,C=0;for(let d=0;d<s;++d){let h=o[r[d]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<t|h,c+=t,c>=8&&(c-=8,i[C++]=255&f>>c)}if(c>=t||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return i},fn=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,c=0;for(let f=0;f<r.length;++f)for(c=c<<8|r[f],i+=8;i>t;)i-=t,s+=e[o&c>>i];if(i&&(s+=e[o&c<<t-i]),n)for(;s.length*t&7;)s+="=";return s},B=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>kt({prefix:e,name:r,encode(o){return fn(o,n,t)},decode(o){return dn(o,n,t,r)}});var re=B({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),It=B({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),$s=B({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),js=B({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),qs=B({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Js=B({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),_s=B({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Gs=B({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ks=B({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var un=Ot,Bt=128,hn=127,ln=~hn,pn=Math.pow(2,31);function Ot(r,e,t){e=e||[],t=t||0;for(var n=t;r>=pn;)e[t++]=r&255|Bt,r/=128;for(;r&ln;)e[t++]=r&255|Bt,r>>>=7;return e[t]=r|0,Ot.bytes=t-n+1,e}var bn=Ne,wn=128,Lt=127;function Ne(r,n){var t=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw Ne.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Lt)<<o:(i&Lt)*Math.pow(2,o),o+=7}while(i>=wn);return Ne.bytes=s-n,t}var mn=Math.pow(2,7),yn=Math.pow(2,14),gn=Math.pow(2,21),xn=Math.pow(2,28),vn=Math.pow(2,35),En=Math.pow(2,42),Cn=Math.pow(2,49),An=Math.pow(2,56),Sn=Math.pow(2,63),Fn=function(r){return r<mn?1:r<yn?2:r<gn?3:r<xn?4:r<vn?5:r<En?6:r<Cn?7:r<An?8:r<Sn?9:10},Un={encode:un,decode:bn,encodingLength:Fn},Mn=Un,ne=Mn;var oe=(r,e=0)=>[ne.decode(r,e),ne.decode.bytes],X=(r,e,t=0)=>(ne.encode(r,e,t),e),Z=r=>ne.encodingLength(r);var Tt=(r,e)=>{let t=e.byteLength,n=Z(r),o=n+Z(t),s=new Uint8Array(o+t);return X(r,s,0),X(t,s,n),s.set(e,o),new H(r,t,e,s)},he=r=>{let e=$(r),[t,n]=oe(e),[o,s]=oe(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new H(t,o,i,e)},Vt=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&zt(r.bytes,t.bytes)}},H=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var N=Oe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ys=Oe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Rt=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Dn(t,Te(r),e||N.encoder);default:return kn(t,Te(r),e||re.encoder)}};var $t=new WeakMap,Te=r=>{let e=$t.get(r);if(e==null){let t=new Map;return $t.set(r,t),t}return e},A=class{constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}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!==se)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==In)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return A.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=Tt(e,t);return A.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 A.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Vt(e.multihash,n.multihash)}toString(e){return Rt(this,e)}toJSON(){return{"/":Rt(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof A)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new A(n,o,s,i||jt(n,o,s.bytes))}else if(t[Bn]===!0){let{version:n,multihash:o,code:s}=t,i=he(o);return A.create(n,s,i)}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!==se)throw new Error(`Version 0 CID must use dag-pb (code: ${se}) block encoding`);return new A(e,t,n,n.bytes)}case 1:{let o=jt(e,t,n.bytes);return new A(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return A.create(0,se,e)}static createV1(e,t){return A.create(1,e,t)}static decode(e){let[t,n]=A.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=A.inspectBytes(e),n=t.size-t.multihashSize,o=$(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new H(t.multihashCode,t.digestSize,s,o);return[t.version===0?A.createV0(i):A.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[h,x]=oe(e.subarray(t));return t+=x,h},o=n(),s=se;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,c=n(),f=n(),C=t+f,d=C-i;return{version:o,codec:s,multihashCode:c,digestSize:f,multihashSize:d,size:C}}static parse(e,t){let[n,o]=zn(e,t),s=A.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Te(s).set(n,e),s}},zn=(r,e)=>{switch(r[0]){case"Q":{let t=e||N;return[N.prefix,t.decode(`${N.prefix}${r}`)]}case N.prefix:{let t=e||N;return[N.prefix,t.decode(r)]}case re.prefix:{let t=e||re;return[re.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)]}}},Dn=(r,e,t)=>{let{prefix:n}=t;if(n!==N.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},kn=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},se=112,In=18,jt=(r,e,t)=>{let n=Z(r),o=n+Z(e),s=new Uint8Array(o+t.byteLength);return X(r,s,0),X(e,s,n),s.set(t,o),s},Bn=Symbol.for("@ipld/js-cid/CID");var qt=85;var Ve=class extends T{location;version;db;base;constructor(e,t={}){super(),this.location=`${t.prefix??""}${e}`,this.version=t.version??1,this.base=t.base??It}#e(e){return`/${this.base.encoder.encode(e.multihash.bytes)}`}#t(e){return A.createV1(qt,he(this.base.decoder.decode(e.substring(1))))}async open(){try{let e=this.location;this.db=await Ft(e,this.version,{upgrade(t){t.createObjectStore(e)}})}catch(e){throw R.openFailedError(e)}}async close(){this.db?.close()}async put(e,t){if(this.db==null)throw new Error("Blockstore needs to be opened.");try{return await this.db.put(this.location,t,this.#e(e)),e}catch(n){throw R.putFailedError(n)}}async get(e){if(this.db==null)throw new Error("Blockstore needs to be opened.");let t;try{t=await this.db.get(this.location,this.#e(e))}catch(n){throw R.putFailedError(n)}if(t===void 0)throw R.notFoundError();return t}async delete(e){if(this.db==null)throw new Error("Blockstore needs to be opened.");try{await this.db.delete(this.location,this.#e(e))}catch(t){throw R.putFailedError(t)}}async has(e){if(this.db==null)throw new Error("Blockstore needs to be opened.");try{return!!await this.db.getKey(this.location,this.#e(e))}catch(t){throw R.putFailedError(t)}}async*getAll(e){if(this.db==null)throw new Error("Blockstore needs to be opened.");for(let t of await this.db.getAllKeys(this.location)){let n=this.#t(t.toString()),o=await this.get(n);yield{cid:n,block:o}}}async destroy(){await Ut(this.location)}};return Wt(On);})(); | ||
"use strict";var BlockstoreIdb=(()=>{var Jt=Object.create;var oe=Object.defineProperty;var _t=Object.getOwnPropertyDescriptor;var Gt=Object.getOwnPropertyNames;var Kt=Object.getPrototypeOf,Qt=Object.prototype.hasOwnProperty;var se=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Pe=(e,t)=>{for(var r in t)oe(e,r,{get:t[r],enumerable:!0})},Re=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Gt(t))!Qt.call(e,o)&&o!==r&&oe(e,o,{get:()=>t[o],enumerable:!(n=_t(t,o))||n.enumerable});return e};var $e=(e,t,r)=>(r=e!=null?Jt(Kt(e)):{},Re(t||!e||!e.__esModule?oe(r,"default",{value:e,enumerable:!0}):r,e)),Wt=e=>Re(oe({},"__esModule",{value:!0}),e);var Je=se((Tn,qe)=>{"use strict";function je(e,t){for(let r in t)Object.defineProperty(e,r,{value:t[r],enumerable:!0,configurable:!0});return e}function Xt(e,t,r){if(!e||typeof e=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof t=="object"&&(r=t,t=""),t&&(r.code=t);try{return je(e,r)}catch{r.message=e.message,r.stack=e.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(e)),je(new o,r)}}qe.exports=Xt});var ct=se((vo,at)=>{var _=1e3,G=_*60,K=G*60,T=K*24,zr=T*7,kr=T*365.25;at.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return Br(e);if(r==="number"&&isFinite(e))return t.long?Or(e):Lr(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Br(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*kr;case"weeks":case"week":case"w":return r*zr;case"days":case"day":case"d":return r*T;case"hours":case"hour":case"hrs":case"hr":case"h":return r*K;case"minutes":case"minute":case"mins":case"min":case"m":return r*G;case"seconds":case"second":case"secs":case"sec":case"s":return r*_;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function Lr(e){var t=Math.abs(e);return t>=T?Math.round(e/T)+"d":t>=K?Math.round(e/K)+"h":t>=G?Math.round(e/G)+"m":t>=_?Math.round(e/_)+"s":e+"ms"}function Or(e){var t=Math.abs(e);return t>=T?ae(e,t,T,"day"):t>=K?ae(e,t,K,"hour"):t>=G?ae(e,t,G,"minute"):t>=_?ae(e,t,_,"second"):e+" ms"}function ae(e,t,r,n){var o=t>=r*1.5;return Math.round(e/r)+" "+n+(o?"s":"")}});var ft=se((Co,dt)=>{function Nr(e){r.debug=r,r.default=r,r.coerce=f,r.disable=s,r.enable=o,r.enabled=i,r.humanize=ct(),r.destroy=E,Object.keys(e).forEach(d=>{r[d]=e[d]}),r.names=[],r.skips=[],r.formatters={};function t(d){let h=0;for(let x=0;x<d.length;x++)h=(h<<5)-h+d.charCodeAt(x),h|=0;return r.colors[Math.abs(h)%r.colors.length]}r.selectColor=t;function r(d){let h,x=null,U,a;function u(...m){if(!u.enabled)return;let l=u,b=Number(new Date),y=b-(h||b);l.diff=y,l.prev=h,l.curr=b,h=b,m[0]=r.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let p=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(C,w)=>{if(C==="%%")return"%";p++;let v=r.formatters[w];if(typeof v=="function"){let A=m[p];C=v.call(l,A),m.splice(p,1),p--}return C}),r.formatArgs.call(l,m),(l.log||r.log).apply(l,m)}return u.namespace=d,u.useColors=r.useColors(),u.color=r.selectColor(d),u.extend=n,u.destroy=r.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>x!==null?x:(U!==r.namespaces&&(U=r.namespaces,a=r.enabled(d)),a),set:m=>{x=m}}),typeof r.init=="function"&&r.init(u),u}function n(d,h){let x=r(this.namespace+(typeof h>"u"?":":h)+d);return x.log=this.log,x}function o(d){r.save(d),r.namespaces=d,r.names=[],r.skips=[];let h,x=(typeof d=="string"?d:"").split(/[\s,]+/),U=x.length;for(h=0;h<U;h++)x[h]&&(d=x[h].replace(/\*/g,".*?"),d[0]==="-"?r.skips.push(new RegExp("^"+d.slice(1)+"$")):r.names.push(new RegExp("^"+d+"$")))}function s(){let d=[...r.names.map(c),...r.skips.map(c).map(h=>"-"+h)].join(",");return r.enable(""),d}function i(d){if(d[d.length-1]==="*")return!0;let h,x;for(h=0,x=r.skips.length;h<x;h++)if(r.skips[h].test(d))return!1;for(h=0,x=r.names.length;h<x;h++)if(r.names[h].test(d))return!0;return!1}function c(d){return d.toString().substring(2,d.toString().length-2).replace(/\.\*\?$/,"*")}function f(d){return d instanceof Error?d.stack||d.message:d}function E(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}dt.exports=Nr});var ut=se((F,ce)=>{F.formatArgs=Vr;F.save=Pr;F.load=Rr;F.useColors=Tr;F.storage=$r();F.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();F.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Tr(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Vr(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+ce.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}F.log=console.debug||console.log||(()=>{});function Pr(e){try{e?F.storage.setItem("debug",e):F.storage.removeItem("debug")}catch{}}function Rr(){let e;try{e=F.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function $r(){try{return localStorage}catch{}}ce.exports=ft()(F);var{formatters:jr}=ce.exports;jr.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var On={};Pe(On,{IDBBlockstore:()=>Ve});var R={};Pe(R,{abortedError:()=>tr,closeFailedError:()=>Ht,deleteFailedError:()=>Ge,getFailedError:()=>Yt,hasFailedError:()=>er,notFoundError:()=>ie,openFailedError:()=>Zt,putFailedError:()=>_e});var k=$e(Je(),1);function Zt(e){return e=e??new Error("Open failed"),(0,k.default)(e,"ERR_OPEN_FAILED")}function Ht(e){return e=e??new Error("Close failed"),(0,k.default)(e,"ERR_CLOSE_FAILED")}function _e(e){return e=e??new Error("Put failed"),(0,k.default)(e,"ERR_PUT_FAILED")}function Yt(e){return e=e??new Error("Get failed"),(0,k.default)(e,"ERR_GET_FAILED")}function Ge(e){return e=e??new Error("Delete failed"),(0,k.default)(e,"ERR_DELETE_FAILED")}function er(e){return e=e??new Error("Has failed"),(0,k.default)(e,"ERR_HAS_FAILED")}function ie(e){return e=e??new Error("Not Found"),(0,k.default)(e,"ERR_NOT_FOUND")}function tr(e){return e=e??new Error("Aborted"),(0,k.default)(e,"ERR_ABORTED")}var O=class{has(t,r){return Promise.reject(new Error(".has is not implemented"))}put(t,r,n){return Promise.reject(new Error(".put is not implemented"))}async*putMany(t,r){for await(let{cid:n,block:o}of t)await this.put(n,o,r),yield n}get(t,r){return Promise.reject(new Error(".get is not implemented"))}async*getMany(t,r){for await(let n of t)yield{cid:n,block:await this.get(n,r)}}async delete(t,r){await Promise.reject(new Error(".delete is not implemented"))}async*deleteMany(t,r){for await(let n of t)await this.delete(n,r),yield n}async*getAll(t){throw new Error(".getAll is not implemented")}};function rr(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var c=e.length,f=e.charAt(0),E=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function h(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";for(var u=0,m=0,l=0,b=a.length;l!==b&&a[l]===0;)l++,u++;for(var y=(b-l)*d+1>>>0,p=new Uint8Array(y);l!==b;){for(var g=a[l],C=0,w=y-1;(g!==0||C<m)&&w!==-1;w--,C++)g+=256*p[w]>>>0,p[w]=g%c>>>0,g=g/c>>>0;if(g!==0)throw new Error("Non-zero carry");m=C,l++}for(var v=y-m;v!==y&&p[v]===0;)v++;for(var A=f.repeat(u);v<y;++v)A+=e.charAt(p[v]);return A}function x(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var u=0;if(a[u]!==" "){for(var m=0,l=0;a[u]===f;)m++,u++;for(var b=(a.length-u)*E+1>>>0,y=new Uint8Array(b);a[u];){var p=r[a.charCodeAt(u)];if(p===255)return;for(var g=0,C=b-1;(p!==0||g<l)&&C!==-1;C--,g++)p+=c*y[C]>>>0,y[C]=p%256>>>0,p=p/256>>>0;if(p!==0)throw new Error("Non-zero carry");l=g,u++}if(a[u]!==" "){for(var w=b-l;w!==b&&y[w]===0;)w++;for(var v=new Uint8Array(m+(b-w)),A=m;w!==b;)v[A++]=y[w++];return v}}}function U(a){var u=x(a);if(u)return u;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:x,decode:U}}var nr=rr,or=nr,Ke=or;var Rn=new Uint8Array(0);var Qe=(e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0},N=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};var he=class{constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},le=class{constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return We(this,t)}},pe=class{constructor(t){this.decoders=t}or(t){return We(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},We=(e,t)=>new pe({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}}),be=class{constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new he(t,r,n),this.decoder=new le(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Xe=({name:e,prefix:t,encode:r,decode:n})=>new be(e,t,r,n),we=({prefix:e,name:t,alphabet:r})=>{let{encode:n,decode:o}=Ke(r,t);return Xe({prefix:e,name:t,encode:n,decode:s=>N(o(s))})},sr=(e,t,r,n)=>{let o={};for(let d=0;d<t.length;++d)o[t[d]]=d;let s=e.length;for(;e[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),c=0,f=0,E=0;for(let d=0;d<s;++d){let h=o[e[d]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<r|h,c+=r,c>=8&&(c-=8,i[E++]=255&f>>c)}if(c>=r||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return i},ir=(e,t,r)=>{let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,c=0;for(let f=0;f<e.length;++f)for(c=c<<8|e[f],i+=8;i>r;)i-=r,s+=t[o&c>>i];if(i&&(s+=t[o&c<<r-i]),n)for(;s.length*r&7;)s+="=";return s},M=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>Xe({prefix:t,name:e,encode(o){return ir(o,n,r)},decode(o){return sr(o,n,r,e)}});var $=M({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Gn=M({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Kn=M({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Qn=M({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Wn=M({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Xn=M({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Zn=M({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Hn=M({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Yn=M({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ar=Ye,Ze=128,cr=127,dr=~cr,fr=Math.pow(2,31);function Ye(e,t,r){t=t||[],r=r||0;for(var n=r;e>=fr;)t[r++]=e&255|Ze,e/=128;for(;e&dr;)t[r++]=e&255|Ze,e>>>=7;return t[r]=e|0,Ye.bytes=r-n+1,t}var ur=me,hr=128,He=127;function me(e,n){var r=0,n=n||0,o=0,s=n,i,c=e.length;do{if(s>=c)throw me.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&He)<<o:(i&He)*Math.pow(2,o),o+=7}while(i>=hr);return me.bytes=s-n,r}var lr=Math.pow(2,7),pr=Math.pow(2,14),br=Math.pow(2,21),wr=Math.pow(2,28),mr=Math.pow(2,35),yr=Math.pow(2,42),gr=Math.pow(2,49),xr=Math.pow(2,56),vr=Math.pow(2,63),Cr=function(e){return e<lr?1:e<pr?2:e<br?3:e<wr?4:e<mr?5:e<yr?6:e<gr?7:e<xr?8:e<vr?9:10},Er={encode:ar,decode:ur,encodingLength:Cr},Ar=Er,Z=Ar;var H=(e,t=0)=>[Z.decode(e,t),Z.decode.bytes],j=(e,t,r=0)=>(Z.encode(e,t,r),t),q=e=>Z.encodingLength(e);var tt=(e,t)=>{let r=t.byteLength,n=q(e),o=n+q(r),s=new Uint8Array(o+r);return j(e,s,0),j(r,s,n),s.set(t,o),new J(e,r,t,s)},ye=e=>{let t=N(e),[r,n]=H(t),[o,s]=H(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new J(r,o,i,t)},rt=(e,t)=>{if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Qe(e.bytes,r.bytes)}},J=class{constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};var B=we({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),so=we({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ot=(e,t)=>{let{bytes:r,version:n}=e;switch(n){case 0:return Fr(r,ge(e),t||B.encoder);default:return Dr(r,ge(e),t||$.encoder)}};var st=new WeakMap,ge=e=>{let t=st.get(e);if(t==null){let r=new Map;return st.set(e,r),r}return t},xe=class e{constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==Y)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ir)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=tt(t,r);return e.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(t){return e.equals(this,t)}static equals(t,r){let n=r;return n&&t.code===n.code&&t.version===n.version&&rt(t.multihash,n.multihash)}toString(t){return ot(this,t)}toJSON(){return{"/":ot(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new e(n,o,s,i||it(n,o,s.bytes))}else if(r[Ur]===!0){let{version:n,multihash:o,code:s}=r,i=ye(o);return e.create(n,s,i)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==Y)throw new Error(`Version 0 CID must use dag-pb (code: ${Y}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=it(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Y,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=N(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new J(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(i):e.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[h,x]=H(t.subarray(r));return r+=x,h},o=n(),s=Y;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,c=n(),f=n(),E=r+f,d=E-i;return{version:o,codec:s,multihashCode:c,digestSize:f,multihashSize:d,size:E}}static parse(t,r){let[n,o]=Sr(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ge(s).set(n,t),s}},Sr=(e,t)=>{switch(e[0]){case"Q":{let r=t||B;return[B.prefix,r.decode(`${B.prefix}${e}`)]}case B.prefix:{let r=t||B;return[B.prefix,r.decode(e)]}case $.prefix:{let r=t||$;return[$.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}},Fr=(e,t,r)=>{let{prefix:n}=r;if(n!==B.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o},Dr=(e,t,r)=>{let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o},Y=112,Ir=18,it=(e,t,r)=>{let n=q(e),o=n+q(t),s=new Uint8Array(o+r.byteLength);return j(e,s,0),j(t,s,n),s.set(r,o),s},Ur=Symbol.for("@ipld/js-cid/CID");var D=$e(ut(),1);function qr(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var c=e.length,f=e.charAt(0),E=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function h(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";for(var u=0,m=0,l=0,b=a.length;l!==b&&a[l]===0;)l++,u++;for(var y=(b-l)*d+1>>>0,p=new Uint8Array(y);l!==b;){for(var g=a[l],C=0,w=y-1;(g!==0||C<m)&&w!==-1;w--,C++)g+=256*p[w]>>>0,p[w]=g%c>>>0,g=g/c>>>0;if(g!==0)throw new Error("Non-zero carry");m=C,l++}for(var v=y-m;v!==y&&p[v]===0;)v++;for(var A=f.repeat(u);v<y;++v)A+=e.charAt(p[v]);return A}function x(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var u=0;if(a[u]!==" "){for(var m=0,l=0;a[u]===f;)m++,u++;for(var b=(a.length-u)*E+1>>>0,y=new Uint8Array(b);a[u];){var p=r[a.charCodeAt(u)];if(p===255)return;for(var g=0,C=b-1;(p!==0||g<l)&&C!==-1;C--,g++)p+=c*y[C]>>>0,y[C]=p%256>>>0,p=p/256>>>0;if(p!==0)throw new Error("Non-zero carry");l=g,u++}if(a[u]!==" "){for(var w=b-l;w!==b&&y[w]===0;)w++;for(var v=new Uint8Array(m+(b-w)),A=m;w!==b;)v[A++]=y[w++];return v}}}function U(a){var u=x(a);if(u)return u;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:x,decode:U}}var Jr=qr,_r=Jr,ht=_r;var Ao=new Uint8Array(0);var lt=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};var ve=class{constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Ce=class{constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return pt(this,t)}},Ee=class{constructor(t){this.decoders=t}or(t){return pt(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},pt=(e,t)=>new Ee({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}}),Ae=class{constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new ve(t,r,n),this.decoder=new Ce(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},bt=({name:e,prefix:t,encode:r,decode:n})=>new Ae(e,t,r,n),Se=({prefix:e,name:t,alphabet:r})=>{let{encode:n,decode:o}=ht(r,t);return bt({prefix:e,name:t,encode:n,decode:s=>lt(o(s))})},Gr=(e,t,r,n)=>{let o={};for(let d=0;d<t.length;++d)o[t[d]]=d;let s=e.length;for(;e[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),c=0,f=0,E=0;for(let d=0;d<s;++d){let h=o[e[d]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<r|h,c+=r,c>=8&&(c-=8,i[E++]=255&f>>c)}if(c>=r||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return i},Kr=(e,t,r)=>{let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,c=0;for(let f=0;f<e.length;++f)for(c=c<<8|e[f],i+=8;i>r;)i-=r,s+=t[o&c>>i];if(i&&(s+=t[o&c<<r-i]),n)for(;s.length*r&7;)s+="=";return s},S=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>bt({prefix:t,name:e,encode(o){return Kr(o,n,r)},decode(o){return Gr(o,n,r,e)}});var wt=S({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Mo=S({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),zo=S({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ko=S({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Bo=S({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Lo=S({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Oo=S({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),No=S({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),To=S({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var mt=Se({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ro=Se({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var yt=S({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qo=S({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Jo=S({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_o=S({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});D.default.formatters.b=e=>e==null?"undefined":mt.baseEncode(e);D.default.formatters.t=e=>e==null?"undefined":wt.baseEncode(e);D.default.formatters.m=e=>e==null?"undefined":yt.baseEncode(e);D.default.formatters.p=e=>e==null?"undefined":e.toString();D.default.formatters.c=e=>e==null?"undefined":e.toString();D.default.formatters.k=e=>e==null?"undefined":e.toString();D.default.formatters.a=e=>e==null?"undefined":e.toString();function Qr(e){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function gt(e){let t=Qr(`${e}:trace`);return D.default.enabled(`${e}:trace`)&&D.default.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=(0,D.default)(`${e}:trace`)),Object.assign((0,D.default)(e),{error:(0,D.default)(`${e}:error`),trace:t})}var xs=gt("blockstore:core:tiered");var V={...R};var Xr=(e,t)=>t.some(r=>e instanceof r),xt,vt;function Zr(){return xt||(xt=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Hr(){return vt||(vt=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Ct=new WeakMap,De=new WeakMap,Et=new WeakMap,Fe=new WeakMap,Ue=new WeakMap;function Yr(e){let t=new Promise((r,n)=>{let o=()=>{e.removeEventListener("success",s),e.removeEventListener("error",i)},s=()=>{r(I(e.result)),o()},i=()=>{n(e.error),o()};e.addEventListener("success",s),e.addEventListener("error",i)});return t.then(r=>{r instanceof IDBCursor&&Ct.set(r,e)}).catch(()=>{}),Ue.set(t,e),t}function en(e){if(De.has(e))return;let t=new Promise((r,n)=>{let o=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",i),e.removeEventListener("abort",i)},s=()=>{r(),o()},i=()=>{n(e.error||new DOMException("AbortError","AbortError")),o()};e.addEventListener("complete",s),e.addEventListener("error",i),e.addEventListener("abort",i)});De.set(e,t)}var Ie={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return De.get(e);if(t==="objectStoreNames")return e.objectStoreNames||Et.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return I(e[t])},set(e,t,r){return e[t]=r,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};function At(e){Ie=e(Ie)}function tn(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...r){let n=e.call(de(this),t,...r);return Et.set(n,t.sort?t.sort():[t]),I(n)}:Hr().includes(e)?function(...t){return e.apply(de(this),t),I(Ct.get(this))}:function(...t){return I(e.apply(de(this),t))}}function rn(e){return typeof e=="function"?tn(e):(e instanceof IDBTransaction&&en(e),Xr(e,Zr())?new Proxy(e,Ie):e)}function I(e){if(e instanceof IDBRequest)return Yr(e);if(Fe.has(e))return Fe.get(e);let t=rn(e);return t!==e&&(Fe.set(e,t),Ue.set(t,e)),t}var de=e=>Ue.get(e);function Ft(e,t,{blocked:r,upgrade:n,blocking:o,terminated:s}={}){let i=indexedDB.open(e,t),c=I(i);return n&&i.addEventListener("upgradeneeded",f=>{n(I(i.result),f.oldVersion,f.newVersion,I(i.transaction),f)}),r&&i.addEventListener("blocked",f=>r(f.oldVersion,f.newVersion,f)),c.then(f=>{s&&f.addEventListener("close",()=>s()),o&&f.addEventListener("versionchange",E=>o(E.oldVersion,E.newVersion,E))}).catch(()=>{}),c}function Dt(e,{blocked:t}={}){let r=indexedDB.deleteDatabase(e);return t&&r.addEventListener("blocked",n=>t(n.oldVersion,n)),I(r).then(()=>{})}var nn=["get","getKey","getAll","getAllKeys","count"],on=["put","add","delete","clear"],Me=new Map;function St(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(Me.get(t))return Me.get(t);let r=t.replace(/FromIndex$/,""),n=t!==r,o=on.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(o||nn.includes(r)))return;let s=async function(i,...c){let f=this.transaction(i,o?"readwrite":"readonly"),E=f.store;return n&&(E=E.index(c.shift())),(await Promise.all([E[r](...c),o&&f.done]))[0]};return Me.set(t,s),s}At(e=>({...e,get:(t,r,n)=>St(t,r)||e.get(t,r,n),has:(t,r)=>!!St(t,r)||e.has(t,r)}));function sn(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var c=e.length,f=e.charAt(0),E=Math.log(c)/Math.log(256),d=Math.log(256)/Math.log(c);function h(a){if(a instanceof Uint8Array||(ArrayBuffer.isView(a)?a=new Uint8Array(a.buffer,a.byteOffset,a.byteLength):Array.isArray(a)&&(a=Uint8Array.from(a))),!(a instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(a.length===0)return"";for(var u=0,m=0,l=0,b=a.length;l!==b&&a[l]===0;)l++,u++;for(var y=(b-l)*d+1>>>0,p=new Uint8Array(y);l!==b;){for(var g=a[l],C=0,w=y-1;(g!==0||C<m)&&w!==-1;w--,C++)g+=256*p[w]>>>0,p[w]=g%c>>>0,g=g/c>>>0;if(g!==0)throw new Error("Non-zero carry");m=C,l++}for(var v=y-m;v!==y&&p[v]===0;)v++;for(var A=f.repeat(u);v<y;++v)A+=e.charAt(p[v]);return A}function x(a){if(typeof a!="string")throw new TypeError("Expected String");if(a.length===0)return new Uint8Array;var u=0;if(a[u]!==" "){for(var m=0,l=0;a[u]===f;)m++,u++;for(var b=(a.length-u)*E+1>>>0,y=new Uint8Array(b);a[u];){var p=r[a.charCodeAt(u)];if(p===255)return;for(var g=0,C=b-1;(p!==0||g<l)&&C!==-1;C--,g++)p+=c*y[C]>>>0,y[C]=p%256>>>0,p=p/256>>>0;if(p!==0)throw new Error("Non-zero carry");l=g,u++}if(a[u]!==" "){for(var w=b-l;w!==b&&y[w]===0;)w++;for(var v=new Uint8Array(m+(b-w)),A=m;w!==b;)v[A++]=y[w++];return v}}}function U(a){var u=x(a);if(u)return u;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:x,decode:U}}var an=sn,cn=an,It=cn;var Os=new Uint8Array(0);var Ut=(e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0},P=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};var ze=class{constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},ke=class{constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Mt(this,t)}},Be=class{constructor(t){this.decoders=t}or(t){return Mt(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Mt=(e,t)=>new Be({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}}),Le=class{constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new ze(t,r,n),this.decoder=new ke(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},zt=({name:e,prefix:t,encode:r,decode:n})=>new Le(e,t,r,n),Oe=({prefix:e,name:t,alphabet:r})=>{let{encode:n,decode:o}=It(r,t);return zt({prefix:e,name:t,encode:n,decode:s=>P(o(s))})},dn=(e,t,r,n)=>{let o={};for(let d=0;d<t.length;++d)o[t[d]]=d;let s=e.length;for(;e[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),c=0,f=0,E=0;for(let d=0;d<s;++d){let h=o[e[d]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<r|h,c+=r,c>=8&&(c-=8,i[E++]=255&f>>c)}if(c>=r||255&f<<8-c)throw new SyntaxError("Unexpected end of data");return i},fn=(e,t,r)=>{let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,c=0;for(let f=0;f<e.length;++f)for(c=c<<8|e[f],i+=8;i>r;)i-=r,s+=t[o&c>>i];if(i&&(s+=t[o&c<<r-i]),n)for(;s.length*r&7;)s+="=";return s},z=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>zt({prefix:t,name:e,encode(o){return fn(o,n,r)},decode(o){return dn(o,n,r,e)}});var ee=z({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),kt=z({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),$s=z({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),js=z({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),qs=z({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Js=z({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),_s=z({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Gs=z({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ks=z({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var un=Ot,Bt=128,hn=127,ln=~hn,pn=Math.pow(2,31);function Ot(e,t,r){t=t||[],r=r||0;for(var n=r;e>=pn;)t[r++]=e&255|Bt,e/=128;for(;e&ln;)t[r++]=e&255|Bt,e>>>=7;return t[r]=e|0,Ot.bytes=r-n+1,t}var bn=Ne,wn=128,Lt=127;function Ne(e,n){var r=0,n=n||0,o=0,s=n,i,c=e.length;do{if(s>=c)throw Ne.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&Lt)<<o:(i&Lt)*Math.pow(2,o),o+=7}while(i>=wn);return Ne.bytes=s-n,r}var mn=Math.pow(2,7),yn=Math.pow(2,14),gn=Math.pow(2,21),xn=Math.pow(2,28),vn=Math.pow(2,35),Cn=Math.pow(2,42),En=Math.pow(2,49),An=Math.pow(2,56),Sn=Math.pow(2,63),Fn=function(e){return e<mn?1:e<yn?2:e<gn?3:e<xn?4:e<vn?5:e<Cn?6:e<En?7:e<An?8:e<Sn?9:10},Dn={encode:un,decode:bn,encodingLength:Fn},In=Dn,te=In;var re=(e,t=0)=>[te.decode(e,t),te.decode.bytes],Q=(e,t,r=0)=>(te.encode(e,t,r),t),W=e=>te.encodingLength(e);var Tt=(e,t)=>{let r=t.byteLength,n=W(e),o=n+W(r),s=new Uint8Array(o+r);return Q(e,s,0),Q(r,s,n),s.set(t,o),new X(e,r,t,s)},fe=e=>{let t=P(e),[r,n]=re(t),[o,s]=re(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new X(r,o,i,t)},Vt=(e,t)=>{if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Ut(e.bytes,r.bytes)}},X=class{constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};var L=Oe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ys=Oe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Rt=(e,t)=>{let{bytes:r,version:n}=e;switch(n){case 0:return Mn(r,Te(e),t||L.encoder);default:return zn(r,Te(e),t||ee.encoder)}};var $t=new WeakMap,Te=e=>{let t=$t.get(e);if(t==null){let r=new Map;return $t.set(e,r),r}return t},ue=class e{constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==ne)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==kn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=Tt(t,r);return e.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(t){return e.equals(this,t)}static equals(t,r){let n=r;return n&&t.code===n.code&&t.version===n.version&&Vt(t.multihash,n.multihash)}toString(t){return Rt(this,t)}toJSON(){return{"/":Rt(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new e(n,o,s,i||jt(n,o,s.bytes))}else if(r[Bn]===!0){let{version:n,multihash:o,code:s}=r,i=fe(o);return e.create(n,s,i)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==ne)throw new Error(`Version 0 CID must use dag-pb (code: ${ne}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=jt(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,ne,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=P(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new X(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(i):e.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[h,x]=re(t.subarray(r));return r+=x,h},o=n(),s=ne;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,c=n(),f=n(),E=r+f,d=E-i;return{version:o,codec:s,multihashCode:c,digestSize:f,multihashSize:d,size:E}}static parse(t,r){let[n,o]=Un(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Te(s).set(n,t),s}},Un=(e,t)=>{switch(e[0]){case"Q":{let r=t||L;return[L.prefix,r.decode(`${L.prefix}${e}`)]}case L.prefix:{let r=t||L;return[L.prefix,r.decode(e)]}case ee.prefix:{let r=t||ee;return[ee.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}},Mn=(e,t,r)=>{let{prefix:n}=r;if(n!==L.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o},zn=(e,t,r)=>{let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o},ne=112,kn=18,jt=(e,t,r)=>{let n=W(e),o=n+W(t),s=new Uint8Array(o+r.byteLength);return Q(e,s,0),Q(t,s,n),s.set(r,o),s},Bn=Symbol.for("@ipld/js-cid/CID");var qt=85;var Ve=class extends O{location;version;db;base;constructor(t,r={}){super(),this.location=`${r.prefix??""}${t}`,this.version=r.version??1,this.base=r.base??kt}#e(t){return`/${this.base.encoder.encode(t.multihash.bytes)}`}#t(t){return ue.createV1(qt,fe(this.base.decoder.decode(t.substring(1))))}async open(){try{let t=this.location;this.db=await Ft(t,this.version,{upgrade(r){r.createObjectStore(t)}})}catch(t){throw V.openFailedError(t)}}async close(){this.db?.close()}async put(t,r){if(this.db==null)throw new Error("Blockstore needs to be opened.");try{return await this.db.put(this.location,r,this.#e(t)),t}catch(n){throw V.putFailedError(n)}}async get(t){if(this.db==null)throw new Error("Blockstore needs to be opened.");let r;try{r=await this.db.get(this.location,this.#e(t))}catch(n){throw V.putFailedError(n)}if(r===void 0)throw V.notFoundError();return r}async delete(t){if(this.db==null)throw new Error("Blockstore needs to be opened.");try{await this.db.delete(this.location,this.#e(t))}catch(r){throw V.putFailedError(r)}}async has(t){if(this.db==null)throw new Error("Blockstore needs to be opened.");try{return!!await this.db.getKey(this.location,this.#e(t))}catch(r){throw V.putFailedError(r)}}async*getAll(t){if(this.db==null)throw new Error("Blockstore needs to be opened.");for(let r of await this.db.getAllKeys(this.location)){let n=this.#t(r.toString()),o=await this.get(n);yield{cid:n,block:o}}}async destroy(){await Dt(this.location)}};return Wt(On);})(); | ||
return BlockstoreIdb})); |
{ | ||
"name": "blockstore-idb", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Blockstore implementation with IndexedDB backend", | ||
@@ -152,3 +152,3 @@ "license": "Apache-2.0 OR MIT", | ||
"devDependencies": { | ||
"aegir": "^39.0.9", | ||
"aegir": "^40.0.8", | ||
"interface-blockstore-tests": "^6.0.0" | ||
@@ -155,0 +155,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60163