Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blockstore-idb

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blockstore-idb - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

2

dist/index.min.js
(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 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);})();
"use strict";var BlockstoreIdb=(()=>{var et=Object.create;var Q=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var nt=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty;var X=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),be=(e,t)=>{for(var r in t)Q(e,r,{get:t[r],enumerable:!0})},ye=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of rt(t))!ot.call(e,o)&&o!==r&&Q(e,o,{get:()=>t[o],enumerable:!(n=tt(t,o))||n.enumerable});return e};var we=(e,t,r)=>(r=e!=null?et(nt(e)):{},ye(t||!e||!e.__esModule?Q(r,"default",{value:e,enumerable:!0}):r,e)),st=e=>ye(Q({},"__esModule",{value:!0}),e);var Ce=X((lr,xe)=>{"use strict";function ge(e,t){for(let r in t)Object.defineProperty(e,r,{value:t[r],enumerable:!0,configurable:!0});return e}function it(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 ge(e,r)}catch{r.message=e.message,r.stack=e.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(e)),ge(new o,r)}}xe.exports=it});var je=X((Wr,Re)=>{var V=1e3,$=V*60,_=$*60,O=_*24,jt=O*7,Vt=O*365.25;Re.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return $t(e);if(r==="number"&&isFinite(e))return t.long?qt(e):_t(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function $t(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*Vt;case"weeks":case"week":case"w":return r*jt;case"days":case"day":case"d":return r*O;case"hours":case"hour":case"hrs":case"hr":case"h":return r*_;case"minutes":case"minute":case"mins":case"min":case"m":return r*$;case"seconds":case"second":case"secs":case"sec":case"s":return r*V;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function _t(e){var t=Math.abs(e);return t>=O?Math.round(e/O)+"d":t>=_?Math.round(e/_)+"h":t>=$?Math.round(e/$)+"m":t>=V?Math.round(e/V)+"s":e+"ms"}function qt(e){var t=Math.abs(e);return t>=O?H(e,t,O,"day"):t>=_?H(e,t,_,"hour"):t>=$?H(e,t,$,"minute"):t>=V?H(e,t,V,"second"):e+" ms"}function H(e,t,r,n){var o=t>=r*1.5;return Math.round(e/r)+" "+n+(o?"s":"")}});var $e=X((Kr,Ve)=>{function Jt(e){r.debug=r,r.default=r,r.coerce=d,r.disable=s,r.enable=o,r.enabled=a,r.humanize=je(),r.destroy=y,Object.keys(e).forEach(i=>{r[i]=e[i]}),r.names=[],r.skips=[],r.formatters={};function t(i){let c=0;for(let h=0;h<i.length;h++)c=(c<<5)-c+i.charCodeAt(h),c|=0;return r.colors[Math.abs(c)%r.colors.length]}r.selectColor=t;function r(i){let c,h=null,P,l;function f(...p){if(!f.enabled)return;let m=f,w=Number(new Date),v=w-(c||w);m.diff=v,m.prev=c,m.curr=w,c=w,p[0]=r.coerce(p[0]),typeof p[0]!="string"&&p.unshift("%O");let b=0;p[0]=p[0].replace(/%([a-zA-Z%])/g,(F,x)=>{if(F==="%%")return"%";b++;let A=r.formatters[x];if(typeof A=="function"){let N=p[b];F=A.call(m,N),p.splice(b,1),b--}return F}),r.formatArgs.call(m,p),(m.log||r.log).apply(m,p)}return f.namespace=i,f.useColors=r.useColors(),f.color=r.selectColor(i),f.extend=n,f.destroy=r.destroy,Object.defineProperty(f,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(P!==r.namespaces&&(P=r.namespaces,l=r.enabled(i)),l),set:p=>{h=p}}),typeof r.init=="function"&&r.init(f),f}function n(i,c){let h=r(this.namespace+(typeof c>"u"?":":c)+i);return h.log=this.log,h}function o(i){r.save(i),r.namespaces=i,r.names=[],r.skips=[];let c,h=(typeof i=="string"?i:"").split(/[\s,]+/),P=h.length;for(c=0;c<P;c++)h[c]&&(i=h[c].replace(/\*/g,".*?"),i[0]==="-"?r.skips.push(new RegExp("^"+i.slice(1)+"$")):r.names.push(new RegExp("^"+i+"$")))}function s(){let i=[...r.names.map(u),...r.skips.map(u).map(c=>"-"+c)].join(",");return r.enable(""),i}function a(i){if(i[i.length-1]==="*")return!0;let c,h;for(c=0,h=r.skips.length;c<h;c++)if(r.skips[c].test(i))return!1;for(c=0,h=r.names.length;c<h;c++)if(r.names[c].test(i))return!0;return!1}function u(i){return i.toString().substring(2,i.toString().length-2).replace(/\.\*\?$/,"*")}function d(i){return i instanceof Error?i.stack||i.message:i}function y(){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}Ve.exports=Jt});var _e=X((C,Y)=>{C.formatArgs=Kt;C.save=Gt;C.load=Qt;C.useColors=Wt;C.storage=Xt();C.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`."))}})();C.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 Wt(){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 Kt(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Y.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)}C.log=console.debug||console.log||(()=>{});function Gt(e){try{e?C.storage.setItem("debug",e):C.storage.removeItem("debug")}catch{}}function Qt(){let e;try{e=C.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function Xt(){try{return localStorage}catch{}}Y.exports=$e()(C);var{formatters:Zt}=Y.exports;Zt.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var ur={};be(ur,{IDBBlockstore:()=>me});var T={};be(T,{abortedError:()=>lt,closeFailedError:()=>ct,deleteFailedError:()=>ve,getFailedError:()=>ut,hasFailedError:()=>dt,notFoundError:()=>Z,openFailedError:()=>at,putFailedError:()=>Ee});var M=we(Ce(),1);function at(e){return e=e??new Error("Open failed"),(0,M.default)(e,"ERR_OPEN_FAILED")}function ct(e){return e=e??new Error("Close failed"),(0,M.default)(e,"ERR_CLOSE_FAILED")}function Ee(e){return e=e??new Error("Put failed"),(0,M.default)(e,"ERR_PUT_FAILED")}function ut(e){return e=e??new Error("Get failed"),(0,M.default)(e,"ERR_GET_FAILED")}function ve(e){return e=e??new Error("Delete failed"),(0,M.default)(e,"ERR_DELETE_FAILED")}function dt(e){return e=e??new Error("Has failed"),(0,M.default)(e,"ERR_HAS_FAILED")}function Z(e){return e=e??new Error("Not Found"),(0,M.default)(e,"ERR_NOT_FOUND")}function lt(e){return e=e??new Error("Aborted"),(0,M.default)(e,"ERR_ABORTED")}var k=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 ft(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),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");r[a]=o}var u=e.length,d=e.charAt(0),y=Math.log(u)/Math.log(256),i=Math.log(256)/Math.log(u);function c(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var f=0,p=0,m=0,w=l.length;m!==w&&l[m]===0;)m++,f++;for(var v=(w-m)*i+1>>>0,b=new Uint8Array(v);m!==w;){for(var S=l[m],F=0,x=v-1;(S!==0||F<p)&&x!==-1;x--,F++)S+=256*b[x]>>>0,b[x]=S%u>>>0,S=S/u>>>0;if(S!==0)throw new Error("Non-zero carry");p=F,m++}for(var A=v-p;A!==v&&b[A]===0;)A++;for(var N=d.repeat(f);A<v;++A)N+=e.charAt(b[A]);return N}function h(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var f=0;if(l[f]!==" "){for(var p=0,m=0;l[f]===d;)p++,f++;for(var w=(l.length-f)*y+1>>>0,v=new Uint8Array(w);l[f];){var b=r[l.charCodeAt(f)];if(b===255)return;for(var S=0,F=w-1;(b!==0||S<m)&&F!==-1;F--,S++)b+=u*v[F]>>>0,v[F]=b%256>>>0,b=b/256>>>0;if(b!==0)throw new Error("Non-zero carry");m=S,f++}if(l[f]!==" "){for(var x=w-m;x!==w&&v[x]===0;)x++;for(var A=new Uint8Array(p+(w-x)),N=p;x!==w;)A[N++]=v[x++];return A}}}function P(l){var f=h(l);if(f)return f;throw new Error(`Non-${t} character`)}return{encode:c,decodeUnsafe:h,decode:P}}var ht=ft,pt=ht,Fe=pt;var pr=new Uint8Array(0);var Ae=(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},B=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 te=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")}},re=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 Se(this,t)}},ne=class{constructor(t){this.decoders=t}or(t){return Se(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`)}},Se=(e,t)=>new ne({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}}),oe=class{constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new te(t,r,n),this.decoder=new re(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},De=({name:e,prefix:t,encode:r,decode:n})=>new oe(e,t,r,n),se=({prefix:e,name:t,alphabet:r})=>{let{encode:n,decode:o}=Fe(r,t);return De({prefix:e,name:t,encode:n,decode:s=>B(o(s))})},mt=(e,t,r,n)=>{let o={};for(let i=0;i<t.length;++i)o[t[i]]=i;let s=e.length;for(;e[s-1]==="=";)--s;let a=new Uint8Array(s*r/8|0),u=0,d=0,y=0;for(let i=0;i<s;++i){let c=o[e[i]];if(c===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|c,u+=r,u>=8&&(u-=8,a[y++]=255&d>>u)}if(u>=r||255&d<<8-u)throw new SyntaxError("Unexpected end of data");return a},bt=(e,t,r)=>{let n=t[t.length-1]==="=",o=(1<<r)-1,s="",a=0,u=0;for(let d=0;d<e.length;++d)for(u=u<<8|e[d],a+=8;a>r;)a-=r,s+=t[o&u>>a];if(a&&(s+=t[o&u<<r-a]),n)for(;s.length*r&7;)s+="=";return s},g=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>De({prefix:t,name:e,encode(o){return bt(o,n,r)},decode(o){return mt(o,n,r,e)}});var L=g({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ie=g({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),xr=g({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Cr=g({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Er=g({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),vr=g({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Fr=g({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ar=g({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Sr=g({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var D=se({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Mr=se({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var yt=Le,Me=128,wt=127,gt=~wt,xt=Math.pow(2,31);function Le(e,t,r){t=t||[],r=r||0;for(var n=r;e>=xt;)t[r++]=e&255|Me,e/=128;for(;e&gt;)t[r++]=e&255|Me,e>>>=7;return t[r]=e|0,Le.bytes=r-n+1,t}var Ct=ie,Et=128,ke=127;function ie(e,n){var r=0,n=n||0,o=0,s=n,a,u=e.length;do{if(s>=u)throw ie.bytes=0,new RangeError("Could not decode varint");a=e[s++],r+=o<28?(a&ke)<<o:(a&ke)*Math.pow(2,o),o+=7}while(a>=Et);return ie.bytes=s-n,r}var vt=Math.pow(2,7),Ft=Math.pow(2,14),At=Math.pow(2,21),St=Math.pow(2,28),Dt=Math.pow(2,35),It=Math.pow(2,42),Mt=Math.pow(2,49),kt=Math.pow(2,56),Lt=Math.pow(2,63),Bt=function(e){return e<vt?1:e<Ft?2:e<At?3:e<St?4:e<Dt?5:e<It?6:e<Mt?7:e<kt?8:e<Lt?9:10},Ot={encode:yt,decode:Ct,encodingLength:Bt},zt=Ot,q=zt;var J=(e,t=0)=>[q.decode(e,t),q.decode.bytes],U=(e,t,r=0)=>(q.encode(e,t,r),t),R=e=>q.encodingLength(e);var Oe=(e,t)=>{let r=t.byteLength,n=R(e),o=n+R(r),s=new Uint8Array(o+r);return U(e,s,0),U(r,s,n),s.set(t,o),new j(e,r,t,s)},W=e=>{let t=B(e),[r,n]=J(t),[o,s]=J(t.subarray(n)),a=t.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new j(r,o,a,t)},ze=(e,t)=>{if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Ae(e.bytes,r.bytes)}},j=class{constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};var Pe=(e,t)=>{let{bytes:r,version:n}=e;switch(n){case 0:return Nt(r,ce(e),t||D.encoder);default:return Tt(r,ce(e),t||L.encoder)}};var Ne=new WeakMap,ce=e=>{let t=Ne.get(e);if(t==null){let r=new Map;return Ne.set(e,r),r}return t},G=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!==K)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ut)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=Oe(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&&ze(t.multihash,n.multihash)}toString(t){return Pe(this,t)}toJSON(){return{"/":Pe(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:a}=r;return new e(n,o,s,a||Te(n,o,s.bytes))}else if(r[Rt]===!0){let{version:n,multihash:o,code:s}=r,a=W(o);return e.create(n,s,a)}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!==K)throw new Error(`Version 0 CID must use dag-pb (code: ${K}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Te(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,K,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=B(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),a=new j(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(a):e.createV1(r.codec,a),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[c,h]=J(t.subarray(r));return r+=h,c},o=n(),s=K;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,u=n(),d=n(),y=r+d,i=y-a;return{version:o,codec:s,multihashCode:u,digestSize:d,multihashSize:i,size:y}}static parse(t,r){let[n,o]=Pt(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 ce(s).set(n,t),s}},Pt=(e,t)=>{switch(e[0]){case"Q":{let r=t||D;return[D.prefix,r.decode(`${D.prefix}${e}`)]}case D.prefix:{let r=t||D;return[D.prefix,r.decode(e)]}case L.prefix:{let r=t||L;return[L.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)]}}},Nt=(e,t,r)=>{let{prefix:n}=r;if(n!==D.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},Tt=(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},K=112,Ut=18,Te=(e,t,r)=>{let n=R(e),o=n+R(t),s=new Uint8Array(o+r.byteLength);return U(e,s,0),U(t,s,n),s.set(r,o),s},Rt=Symbol.for("@ipld/js-cid/CID");var ue=85;var E=we(_e(),1);var qe=g({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Qr=g({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Xr=g({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Zr=g({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});E.default.formatters.b=e=>e==null?"undefined":D.baseEncode(e);E.default.formatters.t=e=>e==null?"undefined":L.baseEncode(e);E.default.formatters.m=e=>e==null?"undefined":qe.baseEncode(e);E.default.formatters.p=e=>e==null?"undefined":e.toString();E.default.formatters.c=e=>e==null?"undefined":e.toString();E.default.formatters.k=e=>e==null?"undefined":e.toString();E.default.formatters.a=e=>e==null?"undefined":e.toString();function Ht(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 Je(e){let t=Ht(`${e}:trace`);return E.default.enabled(`${e}:trace`)&&E.default.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=(0,E.default)(`${e}:trace`)),Object.assign((0,E.default)(e),{error:(0,E.default)(`${e}:error`),trace:t})}var Dn=Je("blockstore:core:tiered");var z={...T};var er=(e,t)=>t.some(r=>e instanceof r),We,Ke;function tr(){return We||(We=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function rr(){return Ke||(Ke=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Ge=new WeakMap,le=new WeakMap,Qe=new WeakMap,de=new WeakMap,he=new WeakMap;function nr(e){let t=new Promise((r,n)=>{let o=()=>{e.removeEventListener("success",s),e.removeEventListener("error",a)},s=()=>{r(I(e.result)),o()},a=()=>{n(e.error),o()};e.addEventListener("success",s),e.addEventListener("error",a)});return t.then(r=>{r instanceof IDBCursor&&Ge.set(r,e)}).catch(()=>{}),he.set(t,e),t}function or(e){if(le.has(e))return;let t=new Promise((r,n)=>{let o=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",a),e.removeEventListener("abort",a)},s=()=>{r(),o()},a=()=>{n(e.error||new DOMException("AbortError","AbortError")),o()};e.addEventListener("complete",s),e.addEventListener("error",a),e.addEventListener("abort",a)});le.set(e,t)}var fe={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return le.get(e);if(t==="objectStoreNames")return e.objectStoreNames||Qe.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 Xe(e){fe=e(fe)}function sr(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(t,...r){let n=e.call(ee(this),t,...r);return Qe.set(n,t.sort?t.sort():[t]),I(n)}:rr().includes(e)?function(...t){return e.apply(ee(this),t),I(Ge.get(this))}:function(...t){return I(e.apply(ee(this),t))}}function ir(e){return typeof e=="function"?sr(e):(e instanceof IDBTransaction&&or(e),er(e,tr())?new Proxy(e,fe):e)}function I(e){if(e instanceof IDBRequest)return nr(e);if(de.has(e))return de.get(e);let t=ir(e);return t!==e&&(de.set(e,t),he.set(t,e)),t}var ee=e=>he.get(e);function He(e,t,{blocked:r,upgrade:n,blocking:o,terminated:s}={}){let a=indexedDB.open(e,t),u=I(a);return n&&a.addEventListener("upgradeneeded",d=>{n(I(a.result),d.oldVersion,d.newVersion,I(a.transaction),d)}),r&&a.addEventListener("blocked",d=>r(d.oldVersion,d.newVersion,d)),u.then(d=>{s&&d.addEventListener("close",()=>s()),o&&d.addEventListener("versionchange",y=>o(y.oldVersion,y.newVersion,y))}).catch(()=>{}),u}function Ye(e,{blocked:t}={}){let r=indexedDB.deleteDatabase(e);return t&&r.addEventListener("blocked",n=>t(n.oldVersion,n)),I(r).then(()=>{})}var ar=["get","getKey","getAll","getAllKeys","count"],cr=["put","add","delete","clear"],pe=new Map;function Ze(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(pe.get(t))return pe.get(t);let r=t.replace(/FromIndex$/,""),n=t!==r,o=cr.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(o||ar.includes(r)))return;let s=async function(a,...u){let d=this.transaction(a,o?"readwrite":"readonly"),y=d.store;return n&&(y=y.index(u.shift())),(await Promise.all([y[r](...u),o&&d.done]))[0]};return pe.set(t,s),s}Xe(e=>({...e,get:(t,r,n)=>Ze(t,r)||e.get(t,r,n),has:(t,r)=>!!Ze(t,r)||e.has(t,r)}));var me=class extends k{location;version;db;base;constructor(t,r={}){super(),this.location=`${r.prefix??""}${t}`,this.version=r.version??1,this.base=r.base??Ie}#e(t){return`/${this.base.encoder.encode(t.multihash.bytes)}`}#t(t){return G.createV1(ue,W(this.base.decoder.decode(t.substring(1))))}async open(){try{let t=this.location;this.db=await He(t,this.version,{upgrade(r){r.createObjectStore(t)}})}catch(t){throw z.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 z.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 z.putFailedError(n)}if(r===void 0)throw z.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 z.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 z.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 Ye(this.location)}};return st(ur);})();
return BlockstoreIdb}));
{
"IDBBlockstore": "https://ipfs.github.io/js-stores/classes/IDBBlockstore.html",
"IDBDatastoreInit": "https://ipfs.github.io/js-stores/interfaces/IDBDatastoreInit.html"
".:IDBBlockstore": "https://ipfs.github.io/js-stores/classes/IDBBlockstore.html",
"IDBDatastoreInit": "https://ipfs.github.io/js-stores/interfaces/IDBDatastoreInit.html",
".:IDBDatastoreInit": "https://ipfs.github.io/js-stores/interfaces/IDBDatastoreInit.html"
}
{
"name": "blockstore-idb",
"version": "1.1.3",
"version": "1.1.4",
"description": "Blockstore implementation with IndexedDB backend",

@@ -22,6 +22,2 @@ "license": "Apache-2.0 OR MIT",

],
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
},
"type": "module",

@@ -155,6 +151,3 @@ "types": "./dist/src/index.d.ts",

"interface-blockstore-tests": "^6.0.0"
},
"typedoc": {
"entryPoint": "./src/index.ts"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc