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

datastore-core

Package Overview
Dependencies
Maintainers
4
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datastore-core - npm Package Compare versions

Comparing version 9.2.1 to 9.2.2

4

dist/index.min.js
(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 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);})();
"use strict";var DatastoreCore=(()=>{var cr=Object.create;var de=Object.defineProperty;var fr=Object.getOwnPropertyDescriptor;var ur=Object.getOwnPropertyNames;var lr=Object.getPrototypeOf,hr=Object.prototype.hasOwnProperty;var pe=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),A=(r,e)=>{for(var t in e)de(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&&de(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?de(t,"default",{value:r,enumerable:!0}):t,r)),dr=r=>mt(de({},"__esModule",{value:!0}),r);var gt=pe((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=pe((si,Qt)=>{var ne=1e3,oe=ne*60,se=oe*60,J=se*24,Gn=J*7,Xn=J*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*J;case"hours":case"hour":case"hrs":case"hr":case"h":return t*se;case"minutes":case"minute":case"mins":case"min":case"m":return t*oe;case"seconds":case"second":case"secs":case"sec":case"s":return t*ne;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function qn(r){var e=Math.abs(r);return e>=J?Math.round(r/J)+"d":e>=se?Math.round(r/se)+"h":e>=oe?Math.round(r/oe)+"m":e>=ne?Math.round(r/ne)+"s":r+"ms"}function Zn(r){var e=Math.abs(r);return e>=J?Te(r,e,J,"day"):e>=se?Te(r,e,se,"hour"):e>=oe?Te(r,e,oe,"minute"):e>=ne?Te(r,e,ne,"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=pe((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=S,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,T,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,(E,g)=>{if(E==="%%")return"%";y++;let v=t.formatters[g];if(typeof v=="function"){let N=u[y];E=v.call(d,N),u.splice(y,1),y--}return E}),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:(T!==t.namespaces&&(T=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,]+/),T=p.length;for(h=0;h<T;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 S(){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=pe((k,Oe)=>{k.formatArgs=eo;k.save=to;k.load=ro;k.useColors=Yn;k.storage=no();k.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`."))}})();k.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)}k.log=console.debug||console.log||(()=>{});function to(r){try{r?k.storage.setItem("debug",r):k.storage.removeItem("debug")}catch{}}function ro(){let r;try{r=k.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()(k);var{formatters:oo}=Oe.exports;oo.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var ho={};A(ho,{BaseDatastore:()=>D,Errors:()=>$,KeyTransformDatastore:()=>R,MemoryDatastore:()=>Ue,MountDatastore:()=>Ne,NamespaceDatastore:()=>ze,ShardingDatastore:()=>Me,TieredDatastore:()=>_e,shard:()=>it});var $={};A($,{abortedError:()=>yr,dbDeleteFailedError:()=>ie,dbOpenFailedError:()=>Be,dbReadFailedError:()=>mr,dbWriteFailedError:()=>ae,notFoundError:()=>j});var L=yt(gt(),1);function Be(r){return r=r??new Error("Cannot open database"),(0,L.default)(r,"ERR_DB_OPEN_FAILED")}function ie(r){return r=r??new Error("Delete failed"),(0,L.default)(r,"ERR_DB_DELETE_FAILED")}function ae(r){return r=r??new Error("Write failed"),(0,L.default)(r,"ERR_DB_WRITE_FAILED")}function mr(r){return r=r??new Error("Read failed"),(0,L.default)(r,"ERR_DB_READ_FAILED")}function j(r){return r=r??new Error("Not Found"),(0,L.default)(r,"ERR_NOT_FOUND")}function yr(r){return r=r??new Error("Aborted"),(0,L.default)(r,"ERR_ABORTED")}var it={};A(it,{NextToLast:()=>Ee,PREFIX:()=>xe,Prefix:()=>ve,SHARDING_FN:()=>Se,ShardBase:()=>Z,Suffix:()=>Ce,parseShardFun:()=>Wt,readShardFun:()=>Ae});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 me(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}var $e={};A($e,{identity:()=>Cr});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),S=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 x=f[d],E=0,g=w-1;(x!==0||E<u)&&g!==-1;g--,E++)x+=256*y[g]>>>0,y[g]=x%a>>>0,x=x/a>>>0;if(x!==0)throw new Error("Non-zero carry");u=E,d++}for(var v=w-u;v!==w&&y[v]===0;)v++;for(var N=b.repeat(l);v<w;++v)N+=r.charAt(y[v]);return N}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)*S+1>>>0,w=new Uint8Array(m);f[l];){var y=t[f.charCodeAt(l)];if(y===255)return;for(var x=0,E=m-1;(y!==0||x<d)&&E!==-1;E--,x++)y+=a*w[E]>>>0,w[E]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");d=x,l++}if(f[l]!==" "){for(var g=m-d;g!==m&&w[g]===0;)g++;for(var v=new Uint8Array(u+(m-g)),N=u;g!==m;)v[N++]=w[g++];return v}}}function T(f){var l=p(f);if(l)return l;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:p,decode:T}}var wr=br,gr=wr,vt=gr;var go=new Uint8Array(0);var Ct=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0},_=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var Et=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)}},W=({name:r,prefix:e,encode:t,decode:n})=>new je(r,e,t,n),P=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=vt(t,e);return W({prefix:r,name:e,encode:n,decode:s=>_(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,S=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[S++]=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})=>W({prefix:e,name:r,encode(o){return vr(o,n,t)},decode(o){return xr(o,n,t,r)}});var Cr=W({prefix:"\0",name:"identity",encode:r=>St(r),decode:r=>Et(r)});var Ke={};A(Ke,{base2:()=>Er});var Er=C({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ve={};A(Ve,{base8:()=>Sr});var Sr=C({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Je={};A(Je,{base10:()=>Ar});var Ar=P({prefix:"9",name:"base10",alphabet:"0123456789"});var We={};A(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={};A(Ge,{base32:()=>G,base32hex:()=>Mr,base32hexpad:()=>Tr,base32hexpadupper:()=>Or,base32hexupper:()=>Nr,base32pad:()=>kr,base32padupper:()=>Ir,base32upper:()=>Dr,base32z:()=>_r});var G=C({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Dr=C({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),kr=C({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ir=C({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Mr=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={};A(Xe,{base36:()=>zr,base36upper:()=>Br});var zr=P({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Br=P({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Qe={};A(Qe,{base58btc:()=>O,base58flickr:()=>Pr});var O=P({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Pr=P({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var qe={};A(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={};A(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}"),Kr=Ut.reduce((r,e,t)=>(r[t]=e,r),[]),Vr=Ut.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Jr(r){return r.reduce((e,t)=>(e+=Kr[t],e),"")}function Wr(r){let e=[];for(let t of r){let n=Vr[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var Gr=W({prefix:"\u{1F680}",name:"base256emoji",encode:Jr,decode:Wr});var tt={};A(tt,{sha256:()=>dn,sha512:()=>pn});var Xr=It,Dt=128,Qr=127,qr=~Qr,Zr=Math.pow(2,31);function It(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Zr;)e[t++]=r&255|Dt,r/=128;for(;r&qr;)e[t++]=r&255|Dt,r>>>=7;return e[t]=r|0,It.bytes=t-n+1,e}var Hr=He,Yr=128,kt=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&kt)<<o:(i&kt)*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,ce=hn;var fe=(r,e=0)=>[ce.decode(r,e),ce.decode.bytes],X=(r,e,t=0)=>(ce.encode(r,e,t),e),Q=r=>ce.encodingLength(r);var K=(r,e)=>{let t=e.byteLength,n=Q(r),o=n+Q(t),s=new Uint8Array(o+t);return X(r,s,0),X(t,s,n),s.set(e,o),new q(r,t,e,s)},Mt=r=>{let e=_(r),[t,n]=fe(e),[o,s]=fe(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new q(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&&Ct(r.bytes,t.bytes)}},q=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={};A(rt,{identity:()=>bn});var _t=0,mn="identity",zt=_,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||O.encoder);default:return Cn(t,nt(r),e||G.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},be=class r{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!==le)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==En)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=K(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n&&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 r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new r(n,o,s,i||Rt(n,o,s.bytes))}else if(t[Sn]===!0){let{version:n,multihash:o,code:s}=t,i=Mt(o);return r.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!==le)throw new Error(`Version 0 CID must use dag-pb (code: ${le}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=Rt(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,le,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=_(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new q(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[h,p]=fe(e.subarray(t));return t+=p,h},o=n(),s=le;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(),S=t+b,c=S-i;return{version:o,codec:s,multihashCode:a,digestSize:b,multihashSize:c,size:S}}static parse(e,t){let[n,o]=xn(e,t),s=r.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||O;return[O.prefix,t.decode(`${O.prefix}${r}`)]}case O.prefix:{let t=e||O;return[O.prefix,t.decode(r)]}case G.prefix:{let t=e||G;return[G.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!==O.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},Cn=(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},le=112,En=18,Rt=(r,e,t)=>{let n=Q(r),o=n+Q(e),s=new Uint8Array(o+t.byteLength);return X(r,s,0),X(e,s,n),s.set(t,o),s},Sn=Symbol.for("@ipld/js-cid/CID");var ot={...$e,...Ke,...Ve,...Je,...We,...Ge,...Xe,...Qe,...qe,...Ze},Zo={...tt,...rt};function Lt(r=0){return globalThis.Buffer?.allocUnsafe!=null?me(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},we=An;function Kt(r,e="utf8"){let t=we[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?me(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function Vt(r,e="utf8"){let t=we[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 z="/",Jt=new TextEncoder().encode(z),ge=Jt[0],F=class r{_buf;constructor(e,t){if(typeof e=="string")this._buf=Kt(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]!==ge)throw new Error("Invalid key")}toString(e="utf8"){return Vt(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new r(e.join(z))}static random(){return new r(xt().replace(/-/g,""))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new r(e):typeof e.uint8Array=="function"?new r(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=Jt),this._buf[0]!==ge){let e=new Uint8Array(this._buf.byteLength+1);e.fill(ge,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===ge;)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 r.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(z).slice(1)}type(){return Fn(this.baseNamespace())}name(){return Un(this.baseNamespace())}instance(e){return new r(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(z)||(e+=z),e+=this.type(),new r(e)}parent(){let e=this.list();return e.length===1?new r(z):new r(e.slice(0,-1).join(z))}child(e){return this.toString()===z?e:e.toString()===z?this:new r(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 r.withNamespaces([...this.namespaces(),...Dn(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 Dn(r){return[].concat(...r)}var xe="/repo/flatfs/shard/",Se="SHARDING",Z=class{param;name;_padding;constructor(e){this.param=e,this.name="base",this._padding=""}fun(e){return"implement me"}toString(){return`${xe}v1/${this.name}/${this.param}`}},ve=class extends Z{constructor(e){super(e),this._padding="".padStart(e,"_"),this.name="prefix"}fun(e){return(e+this._padding).slice(0,this.param)}},Ce=class extends Z{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)}},Ee=class extends Z{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(xe))throw new Error(`invalid or no path prefix: ${r}`);let e=r.slice(xe.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 ve(o);case"suffix":return new Ce(o);case"next-to-last":return new Ee(o);default:throw new Error(`unkown sharding function: ${n}`)}}var Ae=async(r,e)=>{let t=new F(r).child(new F(Se)),o=await(typeof e.getRaw=="function"?e.getRaw.bind(e):e.get.bind(e))(t);return Wt(new TextDecoder().decode(o??"").trim())};function kn(r){return r[Symbol.asyncIterator]!=null}function In(r){if(kn(r))return(async()=>{for await(let e of r);})();for(let e of r);}var H=In;function Mn(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 Fe=Mn;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=Fe(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 M=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 Y=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 ee=Rn;var D=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 H(this.putMany(e,n)),e=[],await H(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=M(n,s=>s.key.toString().startsWith(o))}if(Array.isArray(e.filters)&&(n=e.filters.reduce((o,s)=>M(o,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((o,s)=>Y(o,s),n)),e.offset!=null){let o=0,s=e.offset;n=M(n,()=>o++>=s)}return e.limit!=null&&(n=ee(n,e.limit)),n}queryKeys(e,t){let n=this._allKeys(e,t);if(e.prefix!=null){let o=e.prefix;n=M(n,s=>s.toString().startsWith(o))}if(Array.isArray(e.filters)&&(n=e.filters.reduce((o,s)=>M(o,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((o,s)=>Y(o,s),n)),e.offset!=null){let o=e.offset,s=0;n=M(n,()=>s++>=o)}return e.limit!=null&&(n=ee(n,e.limit)),n}};var Ue=class extends D{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 j();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 F(e),value:t}}*_allKeys(){for(let e of this.data.keys())yield new F(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=Fe(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 B=jn;function De(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var ke=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}},te=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new ke(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 ke(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 V(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 te,o,s,i,a=De(),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=De()})}},S=u=>s!=null?s(u):(n.push(u),o),c=u=>(n=new te,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 S({done:!1,value:u})},p=u=>i?o:(i=!0,u!=null?c(u):S({done:!0})),T=()=>(n=new te,p(),{done:!0}),f=u=>(p(u),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:b,return:T,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,x)=>{w=()=>{x(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 Kn(r){return r[Symbol.asyncIterator]!=null}function Vn(...r){let e=[];for(let t of r)Kn(t)||e.push(t);return e.length===r.length?function*(){for(let t of e)yield*t}():async function*(){let t=V({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 he=Vn;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=V({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 he(n,o())}return r.source};var R=class extends D{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*B(s,({key:i,value:a})=>({key:n.convert(i),value:a}))},async function*(s){yield*o.putMany(s,t)},async function*(s){yield*B(s,i=>n.invert(i))})}async*getMany(e,t={}){let n=this.transform,o=this.child;yield*Ie(e,async function*(s){yield*B(s,i=>n.convert(i))},async function*(s){yield*o.getMany(s,t)},async function*(s){yield*B(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*B(s,i=>n.convert(i))},async function*(s){yield*o.deleteMany(s,t)},async function*(s){yield*B(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}))),B(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)))),B(this.child.queryKeys(n,t),s=>this.transform.invert(s))}};var re=new F(Se),Me=class r extends D{child;shard;constructor(e,t){super(),this.child=new R(e,{convert:this._convertKey.bind(this),invert:this._invertKey.bind(this)}),this.shard=t}async open(){this.shard=await r.create(this.child,this.shard)}_convertKey(e){let t=e.toString();return t===re.toString()?e:new F(this.shard.fun(t)).child(e)}_invertKey(e){return e.toString()===re.toString()?e:F.withNamespaces(e.list().slice(1))}static async create(e,t){if(!await e.has(re)){if(t==null)throw Be(Error("Shard is required when datastore doesn't have a shard key already."));await e.put(re,new TextEncoder().encode(t.toString()+`
`))}t==null&&(t=await Ae("/",e));let o=await Ae("/",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()!==re.toString()].concat(e.filters??[])};return this.child.query(o,t)}queryKeys(e,t){let o={...e,filters:[s=>s.toString()!==re.toString()].concat(e.filters??[])};return this.child.queryKeys(o,t)}};var Ne=class extends D{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 ae(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 j(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 ie(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=he(...n);if(e.filters!=null&&e.filters.forEach(s=>{o=M(o,s)}),e.orders!=null&&e.orders.forEach(s=>{o=Y(o,s)}),e.offset!=null){let s=0,i=e.offset;o=M(o,()=>s++>=i)}return e.limit!=null&&(o=ee(o,e.limit)),o}queryKeys(e,t){let n=this.mounts.map(s=>s.datastore.queryKeys({prefix:e.prefix,filters:e.filters},t)),o=he(...n);if(e.filters!=null&&e.filters.forEach(s=>{o=M(o,s)}),e.orders!=null&&e.orders.forEach(s=>{o=Y(o,s)}),e.offset!=null){let s=0,i=e.offset;o=M(o,()=>s++>=i)}return e.limit!=null&&(o=ee(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),S=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 x=f[d],E=0,g=w-1;(x!==0||E<u)&&g!==-1;g--,E++)x+=256*y[g]>>>0,y[g]=x%a>>>0,x=x/a>>>0;if(x!==0)throw new Error("Non-zero carry");u=E,d++}for(var v=w-u;v!==w&&y[v]===0;)v++;for(var N=b.repeat(l);v<w;++v)N+=r.charAt(y[v]);return N}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)*S+1>>>0,w=new Uint8Array(m);f[l];){var y=t[f.charCodeAt(l)];if(y===255)return;for(var x=0,E=m-1;(y!==0||x<d)&&E!==-1;E--,x++)y+=a*w[E]>>>0,w[E]=y%256>>>0,y=y/256>>>0;if(y!==0)throw new Error("Non-zero carry");d=x,l++}if(f[l]!==" "){for(var g=m-d;g!==m&&w[g]===0;)g++;for(var v=new Uint8Array(u+(m-g)),N=u;g!==m;)v[N++]=w[g++];return v}}}function T(f){var l=p(f);if(l)return l;throw new Error(`Non-${e} character`)}return{encode:h,decodeUnsafe:p,decode:T}}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,S=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[S++]=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},U=({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=U({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pi=U({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mi=U({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yi=U({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bi=U({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wi=U({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),gi=U({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),xi=U({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vi=U({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=U({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ui=U({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Di=U({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ki=U({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 D{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 ae(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 j()}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 ie(n)}}async*putMany(e,t={}){let n,o=this.stores.map(s=>{let i=V({objectMode:!0});return H(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=V({objectMode:!0});return H(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 R{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 F(n.toString().slice(t.toString().length),!1)}})}};return dr(ho);})();
return DatastoreCore}));
{
"name": "datastore-core",
"version": "9.2.1",
"version": "9.2.2",
"description": "Wrapper implementation for interface-datastore",

@@ -216,3 +216,3 @@ "author": "Friedel Ziegelmayer <dignifiedquire@gmail.com>",

"devDependencies": {
"aegir": "^39.0.9",
"aegir": "^40.0.8",
"interface-datastore": "^8.0.0",

@@ -219,0 +219,0 @@ "interface-datastore-tests": "^5.0.0"

@@ -1,2 +0,1 @@

import * as Errors from './errors.js'

@@ -3,0 +2,0 @@ import * as shard from './shard.js'

@@ -1,2 +0,1 @@

export const replaceStartWith = (s: string, r: string): string => {

@@ -3,0 +2,0 @@ const matcher = new RegExp('^' + r)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc