datastore-core
Advanced tools
Comparing version 9.2.0 to 9.2.1
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.DatastoreCore = factory()}(typeof self !== 'undefined' ? self : this, function () { | ||
"use strict";var DatastoreCore=(()=>{var Xe=Object.create;var pt=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Qe=Object.getOwnPropertyNames;var Ze=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty;var mt=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),v=(r,t)=>{for(var e in t)pt(r,e,{get:t[e],enumerable:!0})},ce=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Qe(t))!Ye.call(r,o)&&o!==e&&pt(r,o,{get:()=>t[o],enumerable:!(n=He(t,o))||n.enumerable});return r};var ue=(r,t,e)=>(e=r!=null?Xe(Ze(r)):{},ce(t||!r||!r.__esModule?pt(e,"default",{value:r,enumerable:!0}):e,r)),qe=r=>ce(pt({},"__esModule",{value:!0}),r);var he=mt((Xn,fe)=>{"use strict";function le(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function tr(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return le(r,e)}catch{e.message=r.message,e.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),le(new o,e)}}fe.exports=tr});var Ve=mt((Ls,je)=>{var ot=1e3,st=ot*60,it=st*60,W=it*24,Nn=W*7,_n=W*365.25;je.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return Tn(r);if(e==="number"&&isFinite(r))return t.long?Bn(r):On(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Tn(r){if(r=String(r),!(r.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(r);if(t){var e=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return e*_n;case"weeks":case"week":case"w":return e*Nn;case"days":case"day":case"d":return e*W;case"hours":case"hour":case"hrs":case"hr":case"h":return e*it;case"minutes":case"minute":case"mins":case"min":case"m":return e*st;case"seconds":case"second":case"secs":case"sec":case"s":return e*ot;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function On(r){var t=Math.abs(r);return t>=W?Math.round(r/W)+"d":t>=it?Math.round(r/it)+"h":t>=st?Math.round(r/st)+"m":t>=ot?Math.round(r/ot)+"s":r+"ms"}function Bn(r){var t=Math.abs(r);return t>=W?Dt(r,t,W,"day"):t>=it?Dt(r,t,it,"hour"):t>=st?Dt(r,t,st,"minute"):t>=ot?Dt(r,t,ot,"second"):r+" ms"}function Dt(r,t,e,n){var o=t>=e*1.5;return Math.round(r/e)+" "+n+(o?"s":"")}});var We=mt((zs,Ke)=>{function Ln(r){e.debug=e,e.default=e,e.coerce=g,e.disable=s,e.enable=o,e.enabled=i,e.humanize=Ve(),e.destroy=N,Object.keys(r).forEach(c=>{e[c]=r[c]}),e.names=[],e.skips=[],e.formatters={};function t(c){let l=0;for(let d=0;d<c.length;d++)l=(l<<5)-l+c.charCodeAt(d),l|=0;return e.colors[Math.abs(l)%e.colors.length]}e.selectColor=t;function e(c){let l,d=null,B,f;function u(...p){if(!u.enabled)return;let y=u,w=Number(new Date),F=w-(l||w);y.diff=F,y.prev=l,y.curr=w,l=w,p[0]=e.coerce(p[0]),typeof p[0]!="string"&&p.unshift("%O");let x=0;p[0]=p[0].replace(/%([a-zA-Z%])/g,(k,E)=>{if(k==="%%")return"%";x++;let M=e.formatters[E];if(typeof M=="function"){let J=p[x];k=M.call(y,J),p.splice(x,1),x--}return k}),e.formatArgs.call(y,p),(y.log||e.log).apply(y,p)}return u.namespace=c,u.useColors=e.useColors(),u.color=e.selectColor(c),u.extend=n,u.destroy=e.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(B!==e.namespaces&&(B=e.namespaces,f=e.enabled(c)),f),set:p=>{d=p}}),typeof e.init=="function"&&e.init(u),u}function n(c,l){let d=e(this.namespace+(typeof l>"u"?":":l)+c);return d.log=this.log,d}function o(c){e.save(c),e.namespaces=c,e.names=[],e.skips=[];let l,d=(typeof c=="string"?c:"").split(/[\s,]+/),B=d.length;for(l=0;l<B;l++)d[l]&&(c=d[l].replace(/\*/g,".*?"),c[0]==="-"?e.skips.push(new RegExp("^"+c.slice(1)+"$")):e.names.push(new RegExp("^"+c+"$")))}function s(){let c=[...e.names.map(a),...e.skips.map(a).map(l=>"-"+l)].join(",");return e.enable(""),c}function i(c){if(c[c.length-1]==="*")return!0;let l,d;for(l=0,d=e.skips.length;l<d;l++)if(e.skips[l].test(c))return!1;for(l=0,d=e.names.length;l<d;l++)if(e.names[l].test(c))return!0;return!1}function a(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function g(c){return c instanceof Error?c.stack||c.message:c}function N(){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 e.enable(e.load()),e}Ke.exports=Ln});var Je=mt((S,Nt)=>{S.formatArgs=Rn;S.save=Pn;S.load=$n;S.useColors=zn;S.storage=jn();S.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`."))}})();S.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 zn(){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 Rn(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Nt.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(e++,o==="%c"&&(n=e))}),r.splice(n,0,t)}S.log=console.debug||console.log||(()=>{});function Pn(r){try{r?S.storage.setItem("debug",r):S.storage.removeItem("debug")}catch{}}function $n(){let r;try{r=S.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function jn(){try{return localStorage}catch{}}Nt.exports=We()(S);var{formatters:Vn}=Nt.exports;Vn.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Jn={};v(Jn,{BaseDatastore:()=>C,Errors:()=>j,KeyTransformDatastore:()=>R,MemoryDatastore:()=>kt,MountDatastore:()=>It,NamespaceDatastore:()=>Tt,ShardingDatastore:()=>nt,TieredDatastore:()=>_t,shard:()=>se});var j={};v(j,{abortedError:()=>rr,dbDeleteFailedError:()=>at,dbOpenFailedError:()=>Ot,dbReadFailedError:()=>er,dbWriteFailedError:()=>ct,notFoundError:()=>$});var P=ue(he(),1);function Ot(r){return r=r??new Error("Cannot open database"),(0,P.default)(r,"ERR_DB_OPEN_FAILED")}function at(r){return r=r??new Error("Delete failed"),(0,P.default)(r,"ERR_DB_DELETE_FAILED")}function ct(r){return r=r??new Error("Write failed"),(0,P.default)(r,"ERR_DB_WRITE_FAILED")}function er(r){return r=r??new Error("Read failed"),(0,P.default)(r,"ERR_DB_READ_FAILED")}function $(r){return r=r??new Error("Not Found"),(0,P.default)(r,"ERR_NOT_FOUND")}function rr(r){return r=r??new Error("Aborted"),(0,P.default)(r,"ERR_ABORTED")}var se={};v(se,{NextToLast:()=>Et,PREFIX:()=>xt,Prefix:()=>vt,SHARDING_FN:()=>St,ShardBase:()=>Z,Suffix:()=>Ct,parseShardFun:()=>Re,readShardFun:()=>At});var de=(r=21)=>crypto.getRandomValues(new Uint8Array(r)).reduce((t,e)=>(e&=63,e<36?t+=e.toString(36):e<62?t+=(e-26).toString(36).toUpperCase():e>62?t+="-":t+="_",t),"");var Pt={};v(Pt,{identity:()=>cr});function nr(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,g=r.charAt(0),N=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function l(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var u=0,p=0,y=0,w=f.length;y!==w&&f[y]===0;)y++,u++;for(var F=(w-y)*c+1>>>0,x=new Uint8Array(F);y!==w;){for(var D=f[y],k=0,E=F-1;(D!==0||k<p)&&E!==-1;E--,k++)D+=256*x[E]>>>0,x[E]=D%a>>>0,D=D/a>>>0;if(D!==0)throw new Error("Non-zero carry");p=k,y++}for(var M=F-p;M!==F&&x[M]===0;)M++;for(var J=g.repeat(u);M<F;++M)J+=r.charAt(x[M]);return J}function d(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var u=0;if(f[u]!==" "){for(var p=0,y=0;f[u]===g;)p++,u++;for(var w=(f.length-u)*N+1>>>0,F=new Uint8Array(w);f[u];){var x=e[f.charCodeAt(u)];if(x===255)return;for(var D=0,k=w-1;(x!==0||D<y)&&k!==-1;k--,D++)x+=a*F[k]>>>0,F[k]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");y=D,u++}if(f[u]!==" "){for(var E=w-y;E!==w&&F[E]===0;)E++;for(var M=new Uint8Array(p+(w-E)),J=p;E!==w;)M[J++]=F[E++];return M}}}function B(f){var u=d(f);if(u)return u;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:d,decode:B}}var or=nr,sr=or,pe=sr;var Zn=new Uint8Array(0);var me=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])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 ye=r=>new TextEncoder().encode(r),be=r=>new TextDecoder().decode(r);var Bt=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Lt=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=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)}},zt=class{constructor(t){this.decoders=t}or(t){return we(this,t)}decode(t){let e=t[0],n=this.decoders[e];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=(r,t)=>new zt({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Rt=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Bt(t,e,n),this.decoder=new Lt(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},G=({name:r,prefix:t,encode:e,decode:n})=>new Rt(r,t,e,n),L=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=pe(e,t);return G({prefix:r,name:t,encode:n,decode:s=>_(o(s))})},ir=(r,t,e,n)=>{let o={};for(let c=0;c<t.length;++c)o[t[c]]=c;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),a=0,g=0,N=0;for(let c=0;c<s;++c){let l=o[r[c]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);g=g<<e|l,a+=e,a>=8&&(a-=8,i[N++]=255&g>>a)}if(a>=e||255&g<<8-a)throw new SyntaxError("Unexpected end of data");return i},ar=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let g=0;g<r.length;++g)for(a=a<<8|r[g],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i&&(s+=t[o&a<<e-i]),n)for(;s.length*e&7;)s+="=";return s},m=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>G({prefix:t,name:r,encode(o){return ar(o,n,e)},decode(o){return ir(o,n,e,r)}});var cr=G({prefix:"\0",name:"identity",encode:r=>be(r),decode:r=>ye(r)});var $t={};v($t,{base2:()=>ur});var ur=m({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var jt={};v(jt,{base8:()=>lr});var lr=m({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Vt={};v(Vt,{base10:()=>fr});var fr=L({prefix:"9",name:"base10",alphabet:"0123456789"});var Kt={};v(Kt,{base16:()=>hr,base16upper:()=>dr});var hr=m({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),dr=m({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Wt={};v(Wt,{base32:()=>z,base32hex:()=>br,base32hexpad:()=>wr,base32hexpadupper:()=>xr,base32hexupper:()=>gr,base32pad:()=>mr,base32padupper:()=>yr,base32upper:()=>pr,base32z:()=>vr});var z=m({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pr=m({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mr=m({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yr=m({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),br=m({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),gr=m({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),wr=m({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),xr=m({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vr=m({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Jt={};v(Jt,{base36:()=>Cr,base36upper:()=>Er});var Cr=L({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Er=L({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Gt={};v(Gt,{base58btc:()=>U,base58flickr:()=>Sr});var U=L({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Sr=L({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ht={};v(Ht,{base64:()=>Xt,base64pad:()=>Ar,base64url:()=>Fr,base64urlpad:()=>kr});var Xt=m({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ar=m({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Fr=m({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),kr=m({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Qt={};v(Qt,{base256emoji:()=>Nr});var xe=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Mr=xe.reduce((r,t,e)=>(r[e]=t,r),[]),Ur=xe.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Ir(r){return r.reduce((t,e)=>(t+=Mr[e],t),"")}function Dr(r){let t=[];for(let e of r){let n=Ur[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Nr=G({prefix:"\u{1F680}",name:"base256emoji",encode:Ir,decode:Dr});var te={};v(te,{sha256:()=>Zr,sha512:()=>Yr});var _r=Ee,ve=128,Tr=127,Or=~Tr,Br=Math.pow(2,31);function Ee(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Br;)t[e++]=r&255|ve,r/=128;for(;r⩔)t[e++]=r&255|ve,r>>>=7;return t[e]=r|0,Ee.bytes=e-n+1,t}var Lr=Zt,zr=128,Ce=127;function Zt(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Zt.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&Ce)<<o:(i&Ce)*Math.pow(2,o),o+=7}while(i>=zr);return Zt.bytes=s-n,e}var Rr=Math.pow(2,7),Pr=Math.pow(2,14),$r=Math.pow(2,21),jr=Math.pow(2,28),Vr=Math.pow(2,35),Kr=Math.pow(2,42),Wr=Math.pow(2,49),Jr=Math.pow(2,56),Gr=Math.pow(2,63),Xr=function(r){return r<Rr?1:r<Pr?2:r<$r?3:r<jr?4:r<Vr?5:r<Kr?6:r<Wr?7:r<Jr?8:r<Gr?9:10},Hr={encode:_r,decode:Lr,encodingLength:Xr},Qr=Hr,ut=Qr;var lt=(r,t=0)=>[ut.decode(r,t),ut.decode.bytes],X=(r,t,e=0)=>(ut.encode(r,t,e),t),H=r=>ut.encodingLength(r);var V=(r,t)=>{let e=t.byteLength,n=H(r),o=n+H(e),s=new Uint8Array(o+e);return X(r,s,0),X(e,s,n),s.set(t,o),new Q(r,e,t,s)},Se=r=>{let t=_(r),[e,n]=lt(t),[o,s]=lt(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Q(e,o,i,t)},Ae=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&me(r.bytes,e.bytes)}},Q=class{constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var qt=({name:r,code:t,encode:e})=>new Yt(r,t,e),Yt=class{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?V(this.code,e):e.then(n=>V(this.code,n))}else throw Error("Unknown type, must be binary type")}};var ke=r=>async t=>new Uint8Array(await crypto.subtle.digest(r,t)),Zr=qt({name:"sha2-256",code:18,encode:ke("SHA-256")}),Yr=qt({name:"sha2-512",code:19,encode:ke("SHA-512")});var ee={};v(ee,{identity:()=>en});var Me=0,qr="identity",Ue=_,tn=r=>V(Me,Ue(r)),en={code:Me,name:qr,encode:Ue,digest:tn};var wo=new TextEncoder,xo=new TextDecoder;var Ie=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return sn(e,re(r),t||U.encoder);default:return an(e,re(r),t||z.encoder)}};var De=new WeakMap,re=r=>{let t=De.get(r);if(t==null){let e=new Map;return De.set(r,e),e}return t},b=class{constructor(t,e,n,o){this.code=e,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:e}=this;if(t!==ht)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==cn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return b.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=V(t,e);return b.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 b.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&Ae(t.multihash,n.multihash)}toString(t){return Ie(this,t)}toJSON(){return{"/":Ie(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 e=t;if(e instanceof b)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new b(n,o,s,i||Ne(n,o,s.bytes))}else if(e[un]===!0){let{version:n,multihash:o,code:s}=e,i=Se(o);return b.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="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(e!==ht)throw new Error(`Version 0 CID must use dag-pb (code: ${ht}) block encoding`);return new b(t,e,n,n.bytes)}case 1:{let o=Ne(t,e,n.bytes);return new b(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return b.create(0,ht,t)}static createV1(t,e){return b.create(1,t,e)}static decode(t){let[e,n]=b.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=b.inspectBytes(t),n=e.size-e.multihashSize,o=_(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new Q(e.multihashCode,e.digestSize,s,o);return[e.version===0?b.createV0(i):b.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,d]=lt(t.subarray(e));return e+=d,l},o=n(),s=ht;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),g=n(),N=e+g,c=N-i;return{version:o,codec:s,multihashCode:a,digestSize:g,multihashSize:c,size:N}}static parse(t,e){let[n,o]=on(t,e),s=b.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return re(s).set(n,t),s}},on=(r,t)=>{switch(r[0]){case"Q":{let e=t||U;return[U.prefix,e.decode(`${U.prefix}${r}`)]}case U.prefix:{let e=t||U;return[U.prefix,e.decode(r)]}case z.prefix:{let e=t||z;return[z.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},sn=(r,t,e)=>{let{prefix:n}=e;if(n!==U.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o},an=(r,t,e)=>{let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o},ht=112,cn=18,Ne=(r,t,e)=>{let n=H(r),o=n+H(t),s=new Uint8Array(o+e.byteLength);return X(r,s,0),X(t,s,n),s.set(e,o),s},un=Symbol.for("@ipld/js-cid/CID");var ne={...Pt,...$t,...jt,...Vt,...Kt,...Wt,...Jt,...Gt,...Ht,...Qt},Io={...te,...ee};function bt(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function _e(r=0){return globalThis.Buffer?.allocUnsafe!=null?bt(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Oe(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Te=Oe("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),oe=Oe("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=_e(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ln={utf8:Te,"utf-8":Te,hex:ne.base16,latin1:oe,ascii:oe,binary:oe,...ne},gt=ln;function Be(r,t="utf8"){let e=gt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?bt(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function Le(r,t="utf8"){let e=gt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}var T="/",ze=new TextEncoder().encode(T),wt=ze[0],h=class{_buf;constructor(t,e){if(typeof t=="string")this._buf=Be(t);else if(t instanceof Uint8Array)this._buf=t;else throw new Error("Invalid key, should be String of Uint8Array");if(e==null&&(e=!0),e&&this.clean(),this._buf.byteLength===0||this._buf[0]!==wt)throw new Error("Invalid key")}toString(t="utf8"){return Le(this._buf,t)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(t){return new h(t.join(T))}static random(){return new h(de().replace(/-/g,""))}static asKey(t){return t instanceof Uint8Array||typeof t=="string"?new h(t):typeof t.uint8Array=="function"?new h(t.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=ze),this._buf[0]!==wt){let t=new Uint8Array(this._buf.byteLength+1);t.fill(wt,0,1),t.set(this._buf,1),this._buf=t}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===wt;)this._buf=this._buf.subarray(0,-1)}less(t){let e=this.list(),n=t.list();for(let o=0;o<e.length;o++){if(n.length<o+1)return!1;let s=e[o],i=n[o];if(s<i)return!0;if(s>i)return!1}return e.length<n.length}reverse(){return h.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let t=this.namespaces();return t[t.length-1]}list(){return this.toString().split(T).slice(1)}type(){return fn(this.baseNamespace())}name(){return hn(this.baseNamespace())}instance(t){return new h(this.toString()+":"+t)}path(){let t=this.parent().toString();return t.endsWith(T)||(t+=T),t+=this.type(),new h(t)}parent(){let t=this.list();return t.length===1?new h(T):new h(t.slice(0,-1).join(T))}child(t){return this.toString()===T?t:t.toString()===T?this:new h(this.toString()+t.toString(),!1)}isAncestorOf(t){return t.toString()===this.toString()?!1:t.toString().startsWith(this.toString())}isDecendantOf(t){return t.toString()===this.toString()?!1:this.toString().startsWith(t.toString())}isTopLevel(){return this.list().length===1}concat(...t){return h.withNamespaces([...this.namespaces(),...dn(t.map(e=>e.namespaces()))])}};function fn(r){let t=r.split(":");return t.length<2?"":t.slice(0,-1).join(":")}function hn(r){let t=r.split(":");return t[t.length-1]}function dn(r){return[].concat(...r)}var xt="/repo/flatfs/shard/",St="SHARDING",Z=class{param;name;_padding;constructor(t){this.param=t,this.name="base",this._padding=""}fun(t){return"implement me"}toString(){return`${xt}v1/${this.name}/${this.param}`}},vt=class extends Z{constructor(t){super(t),this._padding="".padStart(t,"_"),this.name="prefix"}fun(t){return(t+this._padding).slice(0,this.param)}},Ct=class extends Z{constructor(t){super(t),this._padding="".padStart(t,"_"),this.name="suffix"}fun(t){let e=this._padding+t;return e.slice(e.length-this.param)}},Et=class extends Z{constructor(t){super(t),this._padding="".padStart(t+1,"_"),this.name="next-to-last"}fun(t){let e=this._padding+t,n=e.length-this.param-1;return e.slice(n,n+this.param)}};function Re(r){if(r=r.trim(),r.length===0)throw new Error("empty shard string");if(!r.startsWith(xt))throw new Error(`invalid or no path prefix: ${r}`);let t=r.slice(xt.length).split("/"),e=t[0];if(e!=="v1")throw new Error(`expect 'v1' version, got '${e}'`);let n=t[1];if(t[2]==null||t[2]==="")throw new Error("missing param");let o=parseInt(t[2],10);switch(n){case"prefix":return new vt(o);case"suffix":return new Ct(o);case"next-to-last":return new Et(o);default:throw new Error(`unkown sharding function: ${n}`)}}var At=async(r,t)=>{let e=new h(r).child(new h(St)),o=await(typeof t.getRaw=="function"?t.getRaw.bind(t):t.get.bind(t))(e);return Re(new TextDecoder().decode(o??"").trim())};function pn(r){return r[Symbol.asyncIterator]!=null}function mn(r){if(pn(r))return(async()=>{for await(let t of r);})();for(let t of r);}var Y=mn;function yn(r){let[t,e]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[e](){return this}}}var Ft=yn;function bn(r){return r[Symbol.asyncIterator]!=null}function gn(r,t){if(bn(r))return async function*(){for await(let a of r)await t(a)&&(yield a)}();let e=Ft(r),{value:n,done:o}=e.next();if(o===!0)return function*(){}();let s=t(n);if(typeof s.then=="function")return async function*(){await s&&(yield n);for await(let a of e)await t(a)&&(yield a)}();let i=t;return function*(){s===!0&&(yield n);for(let a of e)i(a)&&(yield a)}()}var I=gn;function wn(r){return r[Symbol.asyncIterator]!=null}function xn(r){if(wn(r))return(async()=>{let e=[];for await(let n of r)e.push(n);return e})();let t=[];for(let e of r)t.push(e);return t}var ie=xn;function vn(r){return r[Symbol.asyncIterator]!=null}function Cn(r,t){return vn(r)?async function*(){yield*(await ie(r)).sort(t)}():function*(){yield*ie(r).sort(t)}()}var q=Cn;function En(r){return r[Symbol.asyncIterator]!=null}function Sn(r,t){return En(r)?async function*(){let e=0;if(!(t<1)){for await(let n of r)if(yield n,e++,e===t)return}}():function*(){let e=0;if(!(t<1)){for(let n of r)if(yield n,e++,e===t)return}}()}var tt=Sn;var C=class{put(t,e,n){return Promise.reject(new Error(".put is not implemented"))}get(t,e){return Promise.reject(new Error(".get is not implemented"))}has(t,e){return Promise.reject(new Error(".has is not implemented"))}delete(t,e){return Promise.reject(new Error(".delete is not implemented"))}async*putMany(t,e={}){for await(let{key:n,value:o}of t)await this.put(n,o,e),yield n}async*getMany(t,e={}){for await(let n of t)yield{key:n,value:await this.get(n,e)}}async*deleteMany(t,e={}){for await(let n of t)await this.delete(n,e),yield n}batch(){let t=[],e=[];return{put(n,o){t.push({key:n,value:o})},delete(n){e.push(n)},commit:async n=>{await Y(this.putMany(t,n)),t=[],await Y(this.deleteMany(e,n)),e=[]}}}async*_all(t,e){throw new Error("._all is not implemented")}async*_allKeys(t,e){throw new Error("._allKeys is not implemented")}query(t,e){let n=this._all(t,e);if(t.prefix!=null){let o=t.prefix;n=I(n,s=>s.key.toString().startsWith(o))}if(Array.isArray(t.filters)&&(n=t.filters.reduce((o,s)=>I(o,s),n)),Array.isArray(t.orders)&&(n=t.orders.reduce((o,s)=>q(o,s),n)),t.offset!=null){let o=0,s=t.offset;n=I(n,()=>o++>=s)}return t.limit!=null&&(n=tt(n,t.limit)),n}queryKeys(t,e){let n=this._allKeys(t,e);if(t.prefix!=null){let o=t.prefix;n=I(n,s=>s.toString().startsWith(o))}if(Array.isArray(t.filters)&&(n=t.filters.reduce((o,s)=>I(o,s),n)),Array.isArray(t.orders)&&(n=t.orders.reduce((o,s)=>q(o,s),n)),t.offset!=null){let o=t.offset,s=0;n=I(n,()=>s++>=o)}return t.limit!=null&&(n=tt(n,t.limit)),n}};var kt=class extends C{data;constructor(){super(),this.data=new Map}put(t,e){return this.data.set(t.toString(),e),t}get(t){let e=this.data.get(t.toString());if(e==null)throw $();return e}has(t){return this.data.has(t.toString())}delete(t){this.data.delete(t.toString())}*_all(){for(let[t,e]of this.data.entries())yield{key:new h(t),value:e}}*_allKeys(){for(let t of this.data.keys())yield new h(t)}};function An(r){return r[Symbol.asyncIterator]!=null}function Fn(r,t){if(An(r))return async function*(){for await(let a of r)yield t(a)}();let e=Ft(r),{value:n,done:o}=e.next();if(o===!0)return function*(){}();let s=t(n);if(typeof s.then=="function")return async function*(){yield await s;for await(let a of e)yield t(a)}();let i=t;return function*(){yield s;for(let a of e)yield i(a)}()}var O=Fn;var Mt=class{constructor(t){if(!(t>0)||t-1&t)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},et=class{constructor(t={}){this.hwm=t.splitLimit??16,this.head=new Mt(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new Mt(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};function K(r={}){return kn(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function kn(r,t){t=t??{};let e=t.onEnd,n=new et,o,s,i,a=async()=>n.isEmpty()?i?{done:!0}:await new Promise((u,p)=>{s=y=>{s=null,n.push(y);try{u(r(n))}catch(w){p(w)}return o}}):r(n),g=u=>s!=null?s(u):(n.push(u),o),N=u=>(n=new et,s!=null?s({error:u}):(n.push({error:u}),o)),c=u=>{if(i)return o;if(t?.objectMode!==!0&&u?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return g({done:!1,value:u})},l=u=>i?o:(i=!0,u!=null?N(u):g({done:!0})),d=()=>(n=new et,l(),{done:!0}),B=u=>(l(u),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:a,return:d,throw:B,push:c,end:l,get readableLength(){return n.size}},e==null)return o;let f=o;return o={[Symbol.asyncIterator](){return this},next(){return f.next()},throw(u){return f.throw(u),e!=null&&(e(u),e=void 0),{done:!0}},return(){return f.return(),e!=null&&(e(),e=void 0),{done:!0}},push:c,end(u){return f.end(u),e!=null&&(e(u),e=void 0),o},get readableLength(){return f.readableLength}},o}function Mn(r){return r[Symbol.asyncIterator]!=null}function Un(...r){let t=[];for(let e of r)Mn(e)||t.push(e);return t.length===r.length?function*(){for(let e of t)yield*e}():async function*(){let e=K({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let o of n)e.push(o)})),e.end()}catch(n){e.end(n)}}),yield*e}()}var dt=Un;function Ut(r,...t){if(r==null)throw new Error("Empty pipeline");if(ae(r)){let n=r;r=()=>n.source}else if($e(r)||Pe(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&ae(e[e.length-1])&&(e[e.length-1]=e[e.length-1].sink),e.length>2)for(let n=1;n<e.length-1;n++)ae(e[n])&&(e[n]=Dn(e[n]));return In(...e)}var In=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},Pe=r=>r?.[Symbol.asyncIterator]!=null,$e=r=>r?.[Symbol.iterator]!=null,ae=r=>r==null?!1:r.sink!=null&&r.source!=null,Dn=r=>t=>{let e=r.sink(t);if(e?.then!=null){let n=K({objectMode:!0});e.then(()=>{n.end()},i=>{n.end(i)});let o,s=r.source;if(Pe(s))o=async function*(){yield*s,n.end()};else if($e(s))o=function*(){yield*s,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return dt(n,o())}return r.source};var R=class extends C{child;transform;constructor(t,e){super(),this.child=t,this.transform=e}async put(t,e,n){return await this.child.put(this.transform.convert(t),e,n),t}async get(t,e){return this.child.get(this.transform.convert(t),e)}async has(t,e){return this.child.has(this.transform.convert(t),e)}async delete(t,e){await this.child.delete(this.transform.convert(t),e)}async*putMany(t,e={}){let n=this.transform,o=this.child;yield*Ut(t,async function*(s){yield*O(s,({key:i,value:a})=>({key:n.convert(i),value:a}))},async function*(s){yield*o.putMany(s,e)},async function*(s){yield*O(s,i=>n.invert(i))})}async*getMany(t,e={}){let n=this.transform,o=this.child;yield*Ut(t,async function*(s){yield*O(s,i=>n.convert(i))},async function*(s){yield*o.getMany(s,e)},async function*(s){yield*O(s,({key:i,value:a})=>({key:n.invert(i),value:a}))})}async*deleteMany(t,e={}){let n=this.transform,o=this.child;yield*Ut(t,async function*(s){yield*O(s,i=>n.convert(i))},async function*(s){yield*o.deleteMany(s,e)},async function*(s){yield*O(s,i=>n.invert(i))})}batch(){let t=this.child.batch();return{put:(e,n)=>{t.put(this.transform.convert(e),n)},delete:e=>{t.delete(this.transform.convert(e))},commit:async e=>{await t.commit(e)}}}query(t,e){let n={...t};n.filters=(n.filters??[]).map(s=>({key:i,value:a})=>s({key:this.transform.convert(i),value:a}));let{prefix:o}=t;return o!=null&&o!=="/"&&(delete n.prefix,n.filters.push(({key:s})=>this.transform.invert(s).toString().startsWith(o))),n.orders!=null&&(n.orders=n.orders.map(s=>(i,a)=>s({key:this.transform.invert(i.key),value:i.value},{key:this.transform.invert(a.key),value:a.value}))),O(this.child.query(n,e),({key:s,value:i})=>({key:this.transform.invert(s),value:i}))}queryKeys(t,e){let n={...t};n.filters=(n.filters??[]).map(s=>i=>s(this.transform.convert(i)));let{prefix:o}=t;return o!=null&&o!=="/"&&(delete n.prefix,n.filters.push(s=>this.transform.invert(s).toString().startsWith(o))),n.orders!=null&&(n.orders=n.orders.map(s=>(i,a)=>s(this.transform.invert(i),this.transform.invert(a)))),O(this.child.queryKeys(n,e),s=>this.transform.invert(s))}};var rt=new h(St),nt=class extends C{child;shard;constructor(t,e){super(),this.child=new R(t,{convert:this._convertKey.bind(this),invert:this._invertKey.bind(this)}),this.shard=e}async open(){this.shard=await nt.create(this.child,this.shard)}_convertKey(t){let e=t.toString();return e===rt.toString()?t:new h(this.shard.fun(e)).child(t)}_invertKey(t){return t.toString()===rt.toString()?t:h.withNamespaces(t.list().slice(1))}static async create(t,e){if(!await t.has(rt)){if(e==null)throw Ot(Error("Shard is required when datastore doesn't have a shard key already."));await t.put(rt,new TextEncoder().encode(e.toString()+` | ||
`))}e==null&&(e=await At("/",t));let o=await At("/",t),s=o.toString(),i=e.toString();if(s!==i)throw new Error(`specified fun ${i} does not match repo shard fun ${s}`);return o}async put(t,e,n){return await this.child.put(t,e,n),t}async get(t,e){return this.child.get(t,e)}async has(t,e){return this.child.has(t,e)}async delete(t,e){await this.child.delete(t,e)}async*putMany(t,e={}){yield*this.child.putMany(t,e)}async*getMany(t,e={}){yield*this.child.getMany(t,e)}async*deleteMany(t,e={}){yield*this.child.deleteMany(t,e)}batch(){return this.child.batch()}query(t,e){let o={...t,filters:[({key:s})=>s.toString()!==rt.toString()].concat(t.filters??[])};return this.child.query(o,e)}queryKeys(t,e){let o={...t,filters:[s=>s.toString()!==rt.toString()].concat(t.filters??[])};return this.child.queryKeys(o,e)}};var It=class extends C{mounts;constructor(t){super(),this.mounts=t.slice()}_lookup(t){for(let e of this.mounts)if(e.prefix.toString()===t.toString()||e.prefix.isAncestorOf(t))return{datastore:e.datastore,mountpoint:e.prefix}}async put(t,e,n){let o=this._lookup(t);if(o==null)throw ct(new Error("No datastore mounted for this key"));return await o.datastore.put(t,e,n),t}async get(t,e={}){let n=this._lookup(t);if(n==null)throw $(new Error("No datastore mounted for this key"));return n.datastore.get(t,e)}async has(t,e){let n=this._lookup(t);return n==null?Promise.resolve(!1):n.datastore.has(t,e)}async delete(t,e){let n=this._lookup(t);if(n==null)throw at(new Error("No datastore mounted for this key"));await n.datastore.delete(t,e)}batch(){let t={},e=n=>{let o=this._lookup(n);if(o==null)throw new Error("No datastore mounted for this key");let s=o.mountpoint.toString();return t[s]==null&&(t[s]=o.datastore.batch()),{batch:t[s]}};return{put:(n,o)=>{e(n).batch.put(n,o)},delete:n=>{e(n).batch.delete(n)},commit:async n=>{await Promise.all(Object.keys(t).map(async o=>{await t[o].commit(n)}))}}}query(t,e){let n=this.mounts.map(s=>s.datastore.query({prefix:t.prefix,filters:t.filters},e)),o=dt(...n);if(t.filters!=null&&t.filters.forEach(s=>{o=I(o,s)}),t.orders!=null&&t.orders.forEach(s=>{o=q(o,s)}),t.offset!=null){let s=0,i=t.offset;o=I(o,()=>s++>=i)}return t.limit!=null&&(o=tt(o,t.limit)),o}queryKeys(t,e){let n=this.mounts.map(s=>s.datastore.queryKeys({prefix:t.prefix,filters:t.filters},e)),o=dt(...n);if(t.filters!=null&&t.filters.forEach(s=>{o=I(o,s)}),t.orders!=null&&t.orders.forEach(s=>{o=q(o,s)}),t.offset!=null){let s=0,i=t.offset;o=I(o,()=>s++>=i)}return t.limit!=null&&(o=tt(o,t.limit)),o}};var A=ue(Je(),1);A.default.formatters.b=r=>r==null?"undefined":U.baseEncode(r);A.default.formatters.t=r=>r==null?"undefined":z.baseEncode(r);A.default.formatters.m=r=>r==null?"undefined":Xt.baseEncode(r);A.default.formatters.p=r=>r==null?"undefined":r.toString();A.default.formatters.c=r=>r==null?"undefined":r.toString();A.default.formatters.k=r=>r==null?"undefined":r.toString();A.default.formatters.a=r=>r==null?"undefined":r.toString();function Kn(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t}function Ge(r){let t=Kn(`${r}:trace`);return A.default.enabled(`${r}:trace`)&&A.default.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=(0,A.default)(`${r}:trace`)),Object.assign((0,A.default)(r),{error:(0,A.default)(`${r}:error`),trace:t})}var Wn=Ge("datastore:core:tiered"),_t=class extends C{stores;constructor(t){super(),this.stores=t.slice()}async put(t,e,n){try{return await Promise.all(this.stores.map(async o=>{await o.put(t,e,n)})),t}catch(o){throw ct(o)}}async get(t,e){for(let n of this.stores)try{let o=await n.get(t,e);if(o!=null)return o}catch(o){Wn.error(o)}throw $()}async has(t,e){for(let n of this.stores)if(await n.has(t,e))return!0;return!1}async delete(t,e){try{await Promise.all(this.stores.map(async n=>{await n.delete(t,e)}))}catch(n){throw at(n)}}async*putMany(t,e={}){let n,o=this.stores.map(s=>{let i=K({objectMode:!0});return Y(s.putMany(i,e)).catch(a=>{n=a}),i});try{for await(let s of t){if(n!=null)throw n;o.forEach(i=>i.push(s)),yield s.key}}finally{o.forEach(s=>s.end())}}async*deleteMany(t,e={}){let n,o=this.stores.map(s=>{let i=K({objectMode:!0});return Y(s.deleteMany(i,e)).catch(a=>{n=a}),i});try{for await(let s of t){if(n!=null)throw n;o.forEach(i=>i.push(s)),yield s}}finally{o.forEach(s=>s.end())}}batch(){let t=this.stores.map(e=>e.batch());return{put:(e,n)=>{t.forEach(o=>{o.put(e,n)})},delete:e=>{t.forEach(n=>{n.delete(e)})},commit:async e=>{for(let n of t)await n.commit(e)}}}query(t,e){return this.stores[this.stores.length-1].query(t,e)}queryKeys(t,e){return this.stores[this.stores.length-1].queryKeys(t,e)}};var Tt=class extends R{constructor(t,e){super(t,{convert(n){return e.child(n)},invert(n){if(e.toString()==="/")return n;if(!e.isAncestorOf(n))throw new Error(`Expected prefix: (${e.toString()}) in key: ${n.toString()}`);return new h(n.toString().slice(e.toString().length),!1)}})}};return qe(Jn);})(); | ||
"use strict";var DatastoreCore=(()=>{var cr=Object.create;var me=Object.defineProperty;var fr=Object.getOwnPropertyDescriptor;var ur=Object.getOwnPropertyNames;var lr=Object.getPrototypeOf,hr=Object.prototype.hasOwnProperty;var ye=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),U=(r,e)=>{for(var t in e)me(r,t,{get:e[t],enumerable:!0})},mt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ur(e))!hr.call(r,o)&&o!==t&&me(r,o,{get:()=>e[o],enumerable:!(n=fr(e,o))||n.enumerable});return r};var yt=(r,e,t)=>(t=r!=null?cr(lr(r)):{},mt(e||!r||!r.__esModule?me(t,"default",{value:r,enumerable:!0}):t,r)),dr=r=>mt(me({},"__esModule",{value:!0}),r);var gt=ye((mo,wt)=>{"use strict";function bt(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function pr(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 bt(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),bt(new o,t)}}wt.exports=pr});var qt=ye((si,Qt)=>{var se=1e3,ie=se*60,ae=ie*60,W=ae*24,Gn=W*7,Xn=W*365.25;Qt.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return Qn(r);if(t==="number"&&isFinite(r))return e.long?Zn(r):qn(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Qn(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*Xn;case"weeks":case"week":case"w":return t*Gn;case"days":case"day":case"d":return t*W;case"hours":case"hour":case"hrs":case"hr":case"h":return t*ae;case"minutes":case"minute":case"mins":case"min":case"m":return t*ie;case"seconds":case"second":case"secs":case"sec":case"s":return t*se;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function qn(r){var e=Math.abs(r);return e>=W?Math.round(r/W)+"d":e>=ae?Math.round(r/ae)+"h":e>=ie?Math.round(r/ie)+"m":e>=se?Math.round(r/se)+"s":r+"ms"}function Zn(r){var e=Math.abs(r);return e>=W?Te(r,e,W,"day"):e>=ae?Te(r,e,ae,"hour"):e>=ie?Te(r,e,ie,"minute"):e>=se?Te(r,e,se,"second"):r+" ms"}function Te(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var Ht=ye((ii,Zt)=>{function Hn(r){t.debug=t,t.default=t,t.coerce=b,t.disable=s,t.enable=o,t.enabled=i,t.humanize=qt(),t.destroy=F,Object.keys(r).forEach(c=>{t[c]=r[c]}),t.names=[],t.skips=[],t.formatters={};function e(c){let h=0;for(let p=0;p<c.length;p++)h=(h<<5)-h+c.charCodeAt(p),h|=0;return t.colors[Math.abs(h)%t.colors.length]}t.selectColor=e;function t(c){let h,p=null,O,f;function l(...u){if(!l.enabled)return;let d=l,m=Number(new Date),w=m-(h||m);d.diff=w,d.prev=h,d.curr=m,h=m,u[0]=t.coerce(u[0]),typeof u[0]!="string"&&u.unshift("%O");let y=0;u[0]=u[0].replace(/%([a-zA-Z%])/g,(S,x)=>{if(S==="%%")return"%";y++;let E=t.formatters[x];if(typeof E=="function"){let T=u[y];S=E.call(d,T),u.splice(y,1),y--}return S}),t.formatArgs.call(d,u),(d.log||t.log).apply(d,u)}return l.namespace=c,l.useColors=t.useColors(),l.color=t.selectColor(c),l.extend=n,l.destroy=t.destroy,Object.defineProperty(l,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(O!==t.namespaces&&(O=t.namespaces,f=t.enabled(c)),f),set:u=>{p=u}}),typeof t.init=="function"&&t.init(l),l}function n(c,h){let p=t(this.namespace+(typeof h>"u"?":":h)+c);return p.log=this.log,p}function o(c){t.save(c),t.namespaces=c,t.names=[],t.skips=[];let h,p=(typeof c=="string"?c:"").split(/[\s,]+/),O=p.length;for(h=0;h<O;h++)p[h]&&(c=p[h].replace(/\*/g,".*?"),c[0]==="-"?t.skips.push(new RegExp("^"+c.slice(1)+"$")):t.names.push(new RegExp("^"+c+"$")))}function s(){let c=[...t.names.map(a),...t.skips.map(a).map(h=>"-"+h)].join(",");return t.enable(""),c}function i(c){if(c[c.length-1]==="*")return!0;let h,p;for(h=0,p=t.skips.length;h<p;h++)if(t.skips[h].test(c))return!1;for(h=0,p=t.names.length;h<p;h++)if(t.names[h].test(c))return!0;return!1}function a(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function b(c){return c instanceof Error?c.stack||c.message:c}function F(){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}Zt.exports=Hn});var Yt=ye((D,Oe)=>{D.formatArgs=eo;D.save=to;D.load=ro;D.useColors=Yn;D.storage=no();D.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`."))}})();D.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 Yn(){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 eo(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Oe.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)}D.log=console.debug||console.log||(()=>{});function to(r){try{r?D.storage.setItem("debug",r):D.storage.removeItem("debug")}catch{}}function ro(){let r;try{r=D.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function no(){try{return localStorage}catch{}}Oe.exports=Ht()(D);var{formatters:oo}=Oe.exports;oo.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var ho={};U(ho,{BaseDatastore:()=>M,Errors:()=>V,KeyTransformDatastore:()=>L,MemoryDatastore:()=>ke,MountDatastore:()=>Ne,NamespaceDatastore:()=>ze,ShardingDatastore:()=>oe,TieredDatastore:()=>_e,shard:()=>it});var V={};U(V,{abortedError:()=>yr,dbDeleteFailedError:()=>ce,dbOpenFailedError:()=>Be,dbReadFailedError:()=>mr,dbWriteFailedError:()=>fe,notFoundError:()=>$});var j=yt(gt(),1);function Be(r){return r=r??new Error("Cannot open database"),(0,j.default)(r,"ERR_DB_OPEN_FAILED")}function ce(r){return r=r??new Error("Delete failed"),(0,j.default)(r,"ERR_DB_DELETE_FAILED")}function fe(r){return r=r??new Error("Write failed"),(0,j.default)(r,"ERR_DB_WRITE_FAILED")}function mr(r){return r=r??new Error("Read failed"),(0,j.default)(r,"ERR_DB_READ_FAILED")}function $(r){return r=r??new Error("Not Found"),(0,j.default)(r,"ERR_NOT_FOUND")}function yr(r){return r=r??new Error("Aborted"),(0,j.default)(r,"ERR_ABORTED")}var it={};U(it,{NextToLast:()=>Se,PREFIX:()=>ve,Prefix:()=>Ee,SHARDING_FN:()=>Ae,ShardBase:()=>H,Suffix:()=>Ce,parseShardFun:()=>Wt,readShardFun:()=>Fe});var xt=(r=21)=>crypto.getRandomValues(new Uint8Array(r)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");function be(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}var $e={};U($e,{identity:()=>Er});function br(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 a=r.length,b=r.charAt(0),F=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function h(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var l=0,u=0,d=0,m=f.length;d!==m&&f[d]===0;)d++,l++;for(var w=(m-d)*c+1>>>0,y=new Uint8Array(w);d!==m;){for(var v=f[d],S=0,x=w-1;(v!==0||S<u)&&x!==-1;x--,S++)v+=256*y[x]>>>0,y[x]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");u=S,d++}for(var E=w-u;E!==w&&y[E]===0;)E++;for(var T=b.repeat(l);E<w;++E)T+=r.charAt(y[E]);return T}function p(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var l=0;if(f[l]!==" "){for(var u=0,d=0;f[l]===b;)u++,l++;for(var m=(f.length-l)*F+1>>>0,w=new Uint8Array(m);f[l];){var y=t[f.charCodeAt(l)];if(y===255)return;for(var v=0,S=m-1;(y!==0||v<d)&&S!==-1;S--,v++)y+=a*w[S]>>>0,w[S]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");d=v,l++}if(f[l]!==" "){for(var x=m-d;x!==m&&w[x]===0;)x++;for(var E=new Uint8Array(u+(m-x)),T=u;x!==m;)E[T++]=w[x++];return E}}}function O(f){var l=p(f);if(l)return l;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:p,decode:O}}var wr=br,gr=wr,vt=gr;var go=new Uint8Array(0);var Et=(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},z=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 Ct=r=>new TextEncoder().encode(r),St=r=>new TextDecoder().decode(r);var Pe=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")}},Re=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 Ft(this,e)}},Le=class{constructor(e){this.decoders=e}or(e){return Ft(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`)}},Ft=(r,e)=>new Le({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),je=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Pe(e,t,n),this.decoder=new Re(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},G=({name:r,prefix:e,encode:t,decode:n})=>new je(r,e,t,n),R=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=vt(t,e);return G({prefix:r,name:e,encode:n,decode:s=>z(o(s))})},xr=(r,e,t,n)=>{let o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,b=0,F=0;for(let c=0;c<s;++c){let h=o[r[c]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);b=b<<t|h,a+=t,a>=8&&(a-=8,i[F++]=255&b>>a)}if(a>=t||255&b<<8-a)throw new SyntaxError("Unexpected end of data");return i},vr=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let b=0;b<r.length;++b)for(a=a<<8|r[b],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s},C=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>G({prefix:e,name:r,encode(o){return vr(o,n,t)},decode(o){return xr(o,n,t,r)}});var Er=G({prefix:"\0",name:"identity",encode:r=>St(r),decode:r=>Ct(r)});var Ve={};U(Ve,{base2:()=>Cr});var Cr=C({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ke={};U(Ke,{base8:()=>Sr});var Sr=C({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Je={};U(Je,{base10:()=>Ar});var Ar=R({prefix:"9",name:"base10",alphabet:"0123456789"});var We={};U(We,{base16:()=>Fr,base16upper:()=>Ur});var Fr=C({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ur=C({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ge={};U(Ge,{base32:()=>X,base32hex:()=>Ir,base32hexpad:()=>Tr,base32hexpadupper:()=>Or,base32hexupper:()=>Nr,base32pad:()=>Mr,base32padupper:()=>Dr,base32upper:()=>kr,base32z:()=>_r});var X=C({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),kr=C({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Mr=C({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Dr=C({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ir=C({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Nr=C({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Tr=C({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Or=C({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),_r=C({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Xe={};U(Xe,{base36:()=>zr,base36upper:()=>Br});var zr=R({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Br=R({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Qe={};U(Qe,{base58btc:()=>_,base58flickr:()=>Pr});var _=R({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Pr=R({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var qe={};U(qe,{base64:()=>Rr,base64pad:()=>Lr,base64url:()=>jr,base64urlpad:()=>$r});var Rr=C({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Lr=C({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),jr=C({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$r=C({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ze={};U(Ze,{base256emoji:()=>Gr});var Ut=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Vr=Ut.reduce((r,e,t)=>(r[t]=e,r),[]),Kr=Ut.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Jr(r){return r.reduce((e,t)=>(e+=Vr[t],e),"")}function Wr(r){let e=[];for(let t of r){let n=Kr[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var Gr=G({prefix:"\u{1F680}",name:"base256emoji",encode:Jr,decode:Wr});var tt={};U(tt,{sha256:()=>dn,sha512:()=>pn});var Xr=Dt,kt=128,Qr=127,qr=~Qr,Zr=Math.pow(2,31);function Dt(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Zr;)e[t++]=r&255|kt,r/=128;for(;r&qr;)e[t++]=r&255|kt,r>>>=7;return e[t]=r|0,Dt.bytes=t-n+1,e}var Hr=He,Yr=128,Mt=127;function He(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw He.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Mt)<<o:(i&Mt)*Math.pow(2,o),o+=7}while(i>=Yr);return He.bytes=s-n,t}var en=Math.pow(2,7),tn=Math.pow(2,14),rn=Math.pow(2,21),nn=Math.pow(2,28),on=Math.pow(2,35),sn=Math.pow(2,42),an=Math.pow(2,49),cn=Math.pow(2,56),fn=Math.pow(2,63),un=function(r){return r<en?1:r<tn?2:r<rn?3:r<nn?4:r<on?5:r<sn?6:r<an?7:r<cn?8:r<fn?9:10},ln={encode:Xr,decode:Hr,encodingLength:un},hn=ln,ue=hn;var le=(r,e=0)=>[ue.decode(r,e),ue.decode.bytes],Q=(r,e,t=0)=>(ue.encode(r,e,t),e),q=r=>ue.encodingLength(r);var K=(r,e)=>{let t=e.byteLength,n=q(r),o=n+q(t),s=new Uint8Array(o+t);return Q(r,s,0),Q(t,s,n),s.set(e,o),new Z(r,t,e,s)},It=r=>{let e=z(r),[t,n]=le(e),[o,s]=le(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Z(t,o,i,e)},Nt=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Et(r.bytes,t.bytes)}},Z=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var et=({name:r,code:e,encode:t})=>new Ye(r,e,t),Ye=class{constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?K(this.code,t):t.then(n=>K(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Ot=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),dn=et({name:"sha2-256",code:18,encode:Ot("SHA-256")}),pn=et({name:"sha2-512",code:19,encode:Ot("SHA-512")});var rt={};U(rt,{identity:()=>bn});var _t=0,mn="identity",zt=z,yn=r=>K(_t,zt(r)),bn={code:_t,name:mn,encode:zt,digest:yn};var Lo=new TextEncoder,jo=new TextDecoder;var Bt=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return vn(t,nt(r),e||_.encoder);default:return En(t,nt(r),e||X.encoder)}};var Pt=new WeakMap,nt=r=>{let e=Pt.get(r);if(e==null){let t=new Map;return Pt.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!==de)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Cn)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=K(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&&Nt(e.multihash,n.multihash)}toString(e){return Bt(this,e)}toJSON(){return{"/":Bt(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||Rt(n,o,s.bytes))}else if(t[Sn]===!0){let{version:n,multihash:o,code:s}=t,i=It(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!==de)throw new Error(`Version 0 CID must use dag-pb (code: ${de}) block encoding`);return new A(e,t,n,n.bytes)}case 1:{let o=Rt(e,t,n.bytes);return new A(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return A.create(0,de,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=z(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 Z(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,p]=le(e.subarray(t));return t+=p,h},o=n(),s=de;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),b=n(),F=t+b,c=F-i;return{version:o,codec:s,multihashCode:a,digestSize:b,multihashSize:c,size:F}}static parse(e,t){let[n,o]=xn(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 nt(s).set(n,e),s}},xn=(r,e)=>{switch(r[0]){case"Q":{let t=e||_;return[_.prefix,t.decode(`${_.prefix}${r}`)]}case _.prefix:{let t=e||_;return[_.prefix,t.decode(r)]}case X.prefix:{let t=e||X;return[X.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)]}}},vn=(r,e,t)=>{let{prefix:n}=t;if(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},En=(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},de=112,Cn=18,Rt=(r,e,t)=>{let n=q(r),o=n+q(e),s=new Uint8Array(o+t.byteLength);return Q(r,s,0),Q(e,s,n),s.set(t,o),s},Sn=Symbol.for("@ipld/js-cid/CID");var ot={...$e,...Ve,...Ke,...Je,...We,...Ge,...Xe,...Qe,...qe,...Ze},Zo={...tt,...rt};function Lt(r=0){return globalThis.Buffer?.allocUnsafe!=null?be(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function $t(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var jt=$t("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),st=$t("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=Lt(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),An={utf8:jt,"utf-8":jt,hex:ot.base16,latin1:st,ascii:st,binary:st,...ot},ge=An;function Vt(r,e="utf8"){let t=ge[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?be(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function Kt(r,e="utf8"){let t=ge[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var B="/",Jt=new TextEncoder().encode(B),xe=Jt[0],g=class{_buf;constructor(e,t){if(typeof e=="string")this._buf=Vt(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(t==null&&(t=!0),t&&this.clean(),this._buf.byteLength===0||this._buf[0]!==xe)throw new Error("Invalid key")}toString(e="utf8"){return Kt(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new g(e.join(B))}static random(){return new g(xt().replace(/-/g,""))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new g(e):typeof e.uint8Array=="function"?new g(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=Jt),this._buf[0]!==xe){let e=new Uint8Array(this._buf.byteLength+1);e.fill(xe,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===xe;)this._buf=this._buf.subarray(0,-1)}less(e){let t=this.list(),n=e.list();for(let o=0;o<t.length;o++){if(n.length<o+1)return!1;let s=t[o],i=n[o];if(s<i)return!0;if(s>i)return!1}return t.length<n.length}reverse(){return g.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(B).slice(1)}type(){return Fn(this.baseNamespace())}name(){return Un(this.baseNamespace())}instance(e){return new g(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(B)||(e+=B),e+=this.type(),new g(e)}parent(){let e=this.list();return e.length===1?new g(B):new g(e.slice(0,-1).join(B))}child(e){return this.toString()===B?e:e.toString()===B?this:new g(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return g.withNamespaces([...this.namespaces(),...kn(e.map(t=>t.namespaces()))])}};function Fn(r){let e=r.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function Un(r){let e=r.split(":");return e[e.length-1]}function kn(r){return[].concat(...r)}var ve="/repo/flatfs/shard/",Ae="SHARDING",H=class{param;name;_padding;constructor(e){this.param=e,this.name="base",this._padding=""}fun(e){return"implement me"}toString(){return`${ve}v1/${this.name}/${this.param}`}},Ee=class extends H{constructor(e){super(e),this._padding="".padStart(e,"_"),this.name="prefix"}fun(e){return(e+this._padding).slice(0,this.param)}},Ce=class extends H{constructor(e){super(e),this._padding="".padStart(e,"_"),this.name="suffix"}fun(e){let t=this._padding+e;return t.slice(t.length-this.param)}},Se=class extends H{constructor(e){super(e),this._padding="".padStart(e+1,"_"),this.name="next-to-last"}fun(e){let t=this._padding+e,n=t.length-this.param-1;return t.slice(n,n+this.param)}};function Wt(r){if(r=r.trim(),r.length===0)throw new Error("empty shard string");if(!r.startsWith(ve))throw new Error(`invalid or no path prefix: ${r}`);let e=r.slice(ve.length).split("/"),t=e[0];if(t!=="v1")throw new Error(`expect 'v1' version, got '${t}'`);let n=e[1];if(e[2]==null||e[2]==="")throw new Error("missing param");let o=parseInt(e[2],10);switch(n){case"prefix":return new Ee(o);case"suffix":return new Ce(o);case"next-to-last":return new Se(o);default:throw new Error(`unkown sharding function: ${n}`)}}var Fe=async(r,e)=>{let t=new g(r).child(new g(Ae)),o=await(typeof e.getRaw=="function"?e.getRaw.bind(e):e.get.bind(e))(t);return Wt(new TextDecoder().decode(o??"").trim())};function Mn(r){return r[Symbol.asyncIterator]!=null}function Dn(r){if(Mn(r))return(async()=>{for await(let e of r);})();for(let e of r);}var Y=Dn;function In(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var Ue=In;function Nn(r){return r[Symbol.asyncIterator]!=null}function Tn(r,e){if(Nn(r))return async function*(){for await(let a of r)await e(a)&&(yield a)}();let t=Ue(r),{value:n,done:o}=t.next();if(o===!0)return function*(){}();let s=e(n);if(typeof s.then=="function")return async function*(){await s&&(yield n);for await(let a of t)await e(a)&&(yield a)}();let i=e;return function*(){s===!0&&(yield n);for(let a of t)i(a)&&(yield a)}()}var N=Tn;function On(r){return r[Symbol.asyncIterator]!=null}function _n(r){if(On(r))return(async()=>{let t=[];for await(let n of r)t.push(n);return t})();let e=[];for(let t of r)e.push(t);return e}var at=_n;function zn(r){return r[Symbol.asyncIterator]!=null}function Bn(r,e){return zn(r)?async function*(){yield*(await at(r)).sort(e)}():function*(){yield*at(r).sort(e)}()}var ee=Bn;function Pn(r){return r[Symbol.asyncIterator]!=null}function Rn(r,e){return Pn(r)?async function*(){let t=0;if(!(e<1)){for await(let n of r)if(yield n,t++,t===e)return}}():function*(){let t=0;if(!(e<1)){for(let n of r)if(yield n,t++,t===e)return}}()}var te=Rn;var M=class{put(e,t,n){return Promise.reject(new Error(".put is not implemented"))}get(e,t){return Promise.reject(new Error(".get is not implemented"))}has(e,t){return Promise.reject(new Error(".has is not implemented"))}delete(e,t){return Promise.reject(new Error(".delete is not implemented"))}async*putMany(e,t={}){for await(let{key:n,value:o}of e)await this.put(n,o,t),yield n}async*getMany(e,t={}){for await(let n of e)yield{key:n,value:await this.get(n,t)}}async*deleteMany(e,t={}){for await(let n of e)await this.delete(n,t),yield n}batch(){let e=[],t=[];return{put(n,o){e.push({key:n,value:o})},delete(n){t.push(n)},commit:async n=>{await Y(this.putMany(e,n)),e=[],await Y(this.deleteMany(t,n)),t=[]}}}async*_all(e,t){throw new Error("._all is not implemented")}async*_allKeys(e,t){throw new Error("._allKeys is not implemented")}query(e,t){let n=this._all(e,t);if(e.prefix!=null){let o=e.prefix;n=N(n,s=>s.key.toString().startsWith(o))}if(Array.isArray(e.filters)&&(n=e.filters.reduce((o,s)=>N(o,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((o,s)=>ee(o,s),n)),e.offset!=null){let o=0,s=e.offset;n=N(n,()=>o++>=s)}return e.limit!=null&&(n=te(n,e.limit)),n}queryKeys(e,t){let n=this._allKeys(e,t);if(e.prefix!=null){let o=e.prefix;n=N(n,s=>s.toString().startsWith(o))}if(Array.isArray(e.filters)&&(n=e.filters.reduce((o,s)=>N(o,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((o,s)=>ee(o,s),n)),e.offset!=null){let o=e.offset,s=0;n=N(n,()=>s++>=o)}return e.limit!=null&&(n=te(n,e.limit)),n}};var ke=class extends M{data;constructor(){super(),this.data=new Map}put(e,t){return this.data.set(e.toString(),t),e}get(e){let t=this.data.get(e.toString());if(t==null)throw $();return t}has(e){return this.data.has(e.toString())}delete(e){this.data.delete(e.toString())}*_all(){for(let[e,t]of this.data.entries())yield{key:new g(e),value:t}}*_allKeys(){for(let e of this.data.keys())yield new g(e)}};function Ln(r){return r[Symbol.asyncIterator]!=null}function jn(r,e){if(Ln(r))return async function*(){for await(let a of r)yield e(a)}();let t=Ue(r),{value:n,done:o}=t.next();if(o===!0)return function*(){}();let s=e(n);if(typeof s.then=="function")return async function*(){yield await s;for await(let a of t)yield e(a)}();let i=e;return function*(){yield s;for(let a of t)yield i(a)}()}var P=jn;function Me(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var De=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},re=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new De(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new De(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var ct=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function J(r={}){return $n(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function $n(r,e){e=e??{};let t=e.onEnd,n=new re,o,s,i,a=Me(),b=async()=>{try{return n.isEmpty()?i?{done:!0}:await new Promise((u,d)=>{s=m=>{s=null,n.push(m);try{u(r(n))}catch(w){d(w)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=Me()})}},F=u=>s!=null?s(u):(n.push(u),o),c=u=>(n=new re,s!=null?s({error:u}):(n.push({error:u}),o)),h=u=>{if(i)return o;if(e?.objectMode!==!0&&u?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return F({done:!1,value:u})},p=u=>i?o:(i=!0,u!=null?c(u):F({done:!0})),O=()=>(n=new re,p(),{done:!0}),f=u=>(p(u),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:b,return:O,throw:f,push:h,end:p,get readableLength(){return n.size},onEmpty:async u=>{let d=u?.signal;if(d?.throwIfAborted(),n.isEmpty())return;let m,w;d!=null&&(m=new Promise((y,v)=>{w=()=>{v(new ct)},d.addEventListener("abort",w)}));try{await Promise.race([a.promise,m])}finally{w!=null&&d!=null&&d?.removeEventListener("abort",w)}}},t==null)return o;let l=o;return o={[Symbol.asyncIterator](){return this},next(){return l.next()},throw(u){return l.throw(u),t!=null&&(t(u),t=void 0),{done:!0}},return(){return l.return(),t!=null&&(t(),t=void 0),{done:!0}},push:h,end(u){return l.end(u),t!=null&&(t(u),t=void 0),o},get readableLength(){return l.readableLength}},o}function Vn(r){return r[Symbol.asyncIterator]!=null}function Kn(...r){let e=[];for(let t of r)Vn(t)||e.push(t);return e.length===r.length?function*(){for(let t of e)yield*t}():async function*(){let t=J({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let o of n)t.push(o)})),t.end()}catch(n){t.end(n)}}),yield*t}()}var pe=Kn;function Ie(r,...e){if(r==null)throw new Error("Empty pipeline");if(ft(r)){let n=r;r=()=>n.source}else if(Xt(r)||Gt(r)){let n=r;r=()=>n}let t=[r,...e];if(t.length>1&&ft(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let n=1;n<t.length-1;n++)ft(t[n])&&(t[n]=Wn(t[n]));return Jn(...t)}var Jn=(...r)=>{let e;for(;r.length>0;)e=r.shift()(e);return e},Gt=r=>r?.[Symbol.asyncIterator]!=null,Xt=r=>r?.[Symbol.iterator]!=null,ft=r=>r==null?!1:r.sink!=null&&r.source!=null,Wn=r=>e=>{let t=r.sink(e);if(t?.then!=null){let n=J({objectMode:!0});t.then(()=>{n.end()},i=>{n.end(i)});let o,s=r.source;if(Gt(s))o=async function*(){yield*s,n.end()};else if(Xt(s))o=function*(){yield*s,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return pe(n,o())}return r.source};var L=class extends M{child;transform;constructor(e,t){super(),this.child=e,this.transform=t}async put(e,t,n){return await this.child.put(this.transform.convert(e),t,n),e}async get(e,t){return this.child.get(this.transform.convert(e),t)}async has(e,t){return this.child.has(this.transform.convert(e),t)}async delete(e,t){await this.child.delete(this.transform.convert(e),t)}async*putMany(e,t={}){let n=this.transform,o=this.child;yield*Ie(e,async function*(s){yield*P(s,({key:i,value:a})=>({key:n.convert(i),value:a}))},async function*(s){yield*o.putMany(s,t)},async function*(s){yield*P(s,i=>n.invert(i))})}async*getMany(e,t={}){let n=this.transform,o=this.child;yield*Ie(e,async function*(s){yield*P(s,i=>n.convert(i))},async function*(s){yield*o.getMany(s,t)},async function*(s){yield*P(s,({key:i,value:a})=>({key:n.invert(i),value:a}))})}async*deleteMany(e,t={}){let n=this.transform,o=this.child;yield*Ie(e,async function*(s){yield*P(s,i=>n.convert(i))},async function*(s){yield*o.deleteMany(s,t)},async function*(s){yield*P(s,i=>n.invert(i))})}batch(){let e=this.child.batch();return{put:(t,n)=>{e.put(this.transform.convert(t),n)},delete:t=>{e.delete(this.transform.convert(t))},commit:async t=>{await e.commit(t)}}}query(e,t){let n={...e};n.filters=(n.filters??[]).map(s=>({key:i,value:a})=>s({key:this.transform.convert(i),value:a}));let{prefix:o}=e;return o!=null&&o!=="/"&&(delete n.prefix,n.filters.push(({key:s})=>this.transform.invert(s).toString().startsWith(o))),n.orders!=null&&(n.orders=n.orders.map(s=>(i,a)=>s({key:this.transform.invert(i.key),value:i.value},{key:this.transform.invert(a.key),value:a.value}))),P(this.child.query(n,t),({key:s,value:i})=>({key:this.transform.invert(s),value:i}))}queryKeys(e,t){let n={...e};n.filters=(n.filters??[]).map(s=>i=>s(this.transform.convert(i)));let{prefix:o}=e;return o!=null&&o!=="/"&&(delete n.prefix,n.filters.push(s=>this.transform.invert(s).toString().startsWith(o))),n.orders!=null&&(n.orders=n.orders.map(s=>(i,a)=>s(this.transform.invert(i),this.transform.invert(a)))),P(this.child.queryKeys(n,t),s=>this.transform.invert(s))}};var ne=new g(Ae),oe=class extends M{child;shard;constructor(e,t){super(),this.child=new L(e,{convert:this._convertKey.bind(this),invert:this._invertKey.bind(this)}),this.shard=t}async open(){this.shard=await oe.create(this.child,this.shard)}_convertKey(e){let t=e.toString();return t===ne.toString()?e:new g(this.shard.fun(t)).child(e)}_invertKey(e){return e.toString()===ne.toString()?e:g.withNamespaces(e.list().slice(1))}static async create(e,t){if(!await e.has(ne)){if(t==null)throw Be(Error("Shard is required when datastore doesn't have a shard key already."));await e.put(ne,new TextEncoder().encode(t.toString()+` | ||
`))}t==null&&(t=await Fe("/",e));let o=await Fe("/",e),s=o.toString(),i=t.toString();if(s!==i)throw new Error(`specified fun ${i} does not match repo shard fun ${s}`);return o}async put(e,t,n){return await this.child.put(e,t,n),e}async get(e,t){return this.child.get(e,t)}async has(e,t){return this.child.has(e,t)}async delete(e,t){await this.child.delete(e,t)}async*putMany(e,t={}){yield*this.child.putMany(e,t)}async*getMany(e,t={}){yield*this.child.getMany(e,t)}async*deleteMany(e,t={}){yield*this.child.deleteMany(e,t)}batch(){return this.child.batch()}query(e,t){let o={...e,filters:[({key:s})=>s.toString()!==ne.toString()].concat(e.filters??[])};return this.child.query(o,t)}queryKeys(e,t){let o={...e,filters:[s=>s.toString()!==ne.toString()].concat(e.filters??[])};return this.child.queryKeys(o,t)}};var Ne=class extends M{mounts;constructor(e){super(),this.mounts=e.slice()}_lookup(e){for(let t of this.mounts)if(t.prefix.toString()===e.toString()||t.prefix.isAncestorOf(e))return{datastore:t.datastore,mountpoint:t.prefix}}async put(e,t,n){let o=this._lookup(e);if(o==null)throw fe(new Error("No datastore mounted for this key"));return await o.datastore.put(e,t,n),e}async get(e,t={}){let n=this._lookup(e);if(n==null)throw $(new Error("No datastore mounted for this key"));return n.datastore.get(e,t)}async has(e,t){let n=this._lookup(e);return n==null?Promise.resolve(!1):n.datastore.has(e,t)}async delete(e,t){let n=this._lookup(e);if(n==null)throw ce(new Error("No datastore mounted for this key"));await n.datastore.delete(e,t)}batch(){let e={},t=n=>{let o=this._lookup(n);if(o==null)throw new Error("No datastore mounted for this key");let s=o.mountpoint.toString();return e[s]==null&&(e[s]=o.datastore.batch()),{batch:e[s]}};return{put:(n,o)=>{t(n).batch.put(n,o)},delete:n=>{t(n).batch.delete(n)},commit:async n=>{await Promise.all(Object.keys(e).map(async o=>{await e[o].commit(n)}))}}}query(e,t){let n=this.mounts.map(s=>s.datastore.query({prefix:e.prefix,filters:e.filters},t)),o=pe(...n);if(e.filters!=null&&e.filters.forEach(s=>{o=N(o,s)}),e.orders!=null&&e.orders.forEach(s=>{o=ee(o,s)}),e.offset!=null){let s=0,i=e.offset;o=N(o,()=>s++>=i)}return e.limit!=null&&(o=te(o,e.limit)),o}queryKeys(e,t){let n=this.mounts.map(s=>s.datastore.queryKeys({prefix:e.prefix,filters:e.filters},t)),o=pe(...n);if(e.filters!=null&&e.filters.forEach(s=>{o=N(o,s)}),e.orders!=null&&e.orders.forEach(s=>{o=ee(o,s)}),e.offset!=null){let s=0,i=e.offset;o=N(o,()=>s++>=i)}return e.limit!=null&&(o=te(o,e.limit)),o}};var I=yt(Yt(),1);function so(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 a=r.length,b=r.charAt(0),F=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function h(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var l=0,u=0,d=0,m=f.length;d!==m&&f[d]===0;)d++,l++;for(var w=(m-d)*c+1>>>0,y=new Uint8Array(w);d!==m;){for(var v=f[d],S=0,x=w-1;(v!==0||S<u)&&x!==-1;x--,S++)v+=256*y[x]>>>0,y[x]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");u=S,d++}for(var E=w-u;E!==w&&y[E]===0;)E++;for(var T=b.repeat(l);E<w;++E)T+=r.charAt(y[E]);return T}function p(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var l=0;if(f[l]!==" "){for(var u=0,d=0;f[l]===b;)u++,l++;for(var m=(f.length-l)*F+1>>>0,w=new Uint8Array(m);f[l];){var y=t[f.charCodeAt(l)];if(y===255)return;for(var v=0,S=m-1;(y!==0||v<d)&&S!==-1;S--,v++)y+=a*w[S]>>>0,w[S]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");d=v,l++}if(f[l]!==" "){for(var x=m-d;x!==m&&w[x]===0;)x++;for(var E=new Uint8Array(u+(m-x)),T=u;x!==m;)E[T++]=w[x++];return E}}}function O(f){var l=p(f);if(l)return l;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:p,decode:O}}var io=so,ao=io,er=ao;var ci=new Uint8Array(0);var tr=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 ut=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")}},lt=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 rr(this,e)}},ht=class{constructor(e){this.decoders=e}or(e){return rr(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`)}},rr=(r,e)=>new ht({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),dt=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new ut(e,t,n),this.decoder=new lt(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},nr=({name:r,prefix:e,encode:t,decode:n})=>new dt(r,e,t,n),pt=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=er(t,e);return nr({prefix:r,name:e,encode:n,decode:s=>tr(o(s))})},co=(r,e,t,n)=>{let o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,b=0,F=0;for(let c=0;c<s;++c){let h=o[r[c]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);b=b<<t|h,a+=t,a>=8&&(a-=8,i[F++]=255&b>>a)}if(a>=t||255&b<<8-a)throw new SyntaxError("Unexpected end of data");return i},fo=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let b=0;b<r.length;++b)for(a=a<<8|r[b],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s},k=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>nr({prefix:e,name:r,encode(o){return fo(o,n,t)},decode(o){return co(o,n,t,r)}});var or=k({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pi=k({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mi=k({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yi=k({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bi=k({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wi=k({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),gi=k({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),xi=k({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vi=k({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var sr=pt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Si=pt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ir=k({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ui=k({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ki=k({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Mi=k({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});I.default.formatters.b=r=>r==null?"undefined":sr.baseEncode(r);I.default.formatters.t=r=>r==null?"undefined":or.baseEncode(r);I.default.formatters.m=r=>r==null?"undefined":ir.baseEncode(r);I.default.formatters.p=r=>r==null?"undefined":r.toString();I.default.formatters.c=r=>r==null?"undefined":r.toString();I.default.formatters.k=r=>r==null?"undefined":r.toString();I.default.formatters.a=r=>r==null?"undefined":r.toString();function uo(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 ar(r){let e=uo(`${r}:trace`);return I.default.enabled(`${r}:trace`)&&I.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,I.default)(`${r}:trace`)),Object.assign((0,I.default)(r),{error:(0,I.default)(`${r}:error`),trace:e})}var lo=ar("datastore:core:tiered"),_e=class extends M{stores;constructor(e){super(),this.stores=e.slice()}async put(e,t,n){try{return await Promise.all(this.stores.map(async o=>{await o.put(e,t,n)})),e}catch(o){throw fe(o)}}async get(e,t){for(let n of this.stores)try{let o=await n.get(e,t);if(o!=null)return o}catch(o){lo.error(o)}throw $()}async has(e,t){for(let n of this.stores)if(await n.has(e,t))return!0;return!1}async delete(e,t){try{await Promise.all(this.stores.map(async n=>{await n.delete(e,t)}))}catch(n){throw ce(n)}}async*putMany(e,t={}){let n,o=this.stores.map(s=>{let i=J({objectMode:!0});return Y(s.putMany(i,t)).catch(a=>{n=a}),i});try{for await(let s of e){if(n!=null)throw n;o.forEach(i=>i.push(s)),yield s.key}}finally{o.forEach(s=>s.end())}}async*deleteMany(e,t={}){let n,o=this.stores.map(s=>{let i=J({objectMode:!0});return Y(s.deleteMany(i,t)).catch(a=>{n=a}),i});try{for await(let s of e){if(n!=null)throw n;o.forEach(i=>i.push(s)),yield s}}finally{o.forEach(s=>s.end())}}batch(){let e=this.stores.map(t=>t.batch());return{put:(t,n)=>{e.forEach(o=>{o.put(t,n)})},delete:t=>{e.forEach(n=>{n.delete(t)})},commit:async t=>{for(let n of e)await n.commit(t)}}}query(e,t){return this.stores[this.stores.length-1].query(e,t)}queryKeys(e,t){return this.stores[this.stores.length-1].queryKeys(e,t)}};var ze=class extends L{constructor(e,t){super(e,{convert(n){return t.child(n)},invert(n){if(t.toString()==="/")return n;if(!t.isAncestorOf(n))throw new Error(`Expected prefix: (${t.toString()}) in key: ${n.toString()}`);return new g(n.toString().slice(t.toString().length),!1)}})}};return dr(ho);})(); | ||
return DatastoreCore})); |
{ | ||
"name": "datastore-core", | ||
"version": "9.2.0", | ||
"version": "9.2.1", | ||
"description": "Wrapper implementation for interface-datastore", | ||
@@ -201,3 +201,3 @@ "author": "Friedel Ziegelmayer <dignifiedquire@gmail.com>", | ||
"dependencies": { | ||
"@libp2p/logger": "^2.0.0", | ||
"@libp2p/logger": "^3.0.0", | ||
"err-code": "^3.0.1", | ||
@@ -204,0 +204,0 @@ "interface-store": "^5.0.0", |
167709
31135
2158
+ Added@libp2p/interface@0.1.6(transitive)
+ Added@libp2p/logger@3.1.0(transitive)
+ Addedabortable-iterator@5.1.0(transitive)
+ Addedget-iterator@2.0.1(transitive)
+ Addedrace-signal@1.1.0(transitive)
- Removed@libp2p/interface-peer-id@2.0.2(transitive)
- Removed@libp2p/logger@2.1.1(transitive)
- Removedmultiformats@11.0.2(transitive)
Updated@libp2p/logger@^3.0.0