@helia/ipns 9.1.5-273e981b → 9.1.5-362f0b25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +3 -3
- package/package.json +2 -2
package/dist/index.min.js
CHANGED
|
@@ -10,7 +10,7 @@ ${t}`)}`:n!=null?`${n.split(`
|
|
|
10
10
|
${t}`)}`:r!=null?`${r}`:`${e.toString()}`}function ch(e){return e instanceof AggregateError||e?.name==="AggregateError"&&Array.isArray(e.errors)}function Vc(e,t=""){if(ch(e)){let r=Oc(e,t);return e.errors.length>0?(t=`${t} `,r+=`
|
|
11
11
|
${t}${e.errors.map(n=>`${Vc(n,`${t}`)}`).join(`
|
|
12
12
|
${t}`)}`):r+=`
|
|
13
|
-
${t}[Error list was empty]`,r.trim()}return Oc(e,t)}St.formatters.e=e=>e==null?"undefined":Vc(e);function uh(e){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function Oe(e,t){let r=uh(`${e}:trace`);return St.enabled(`${e}:trace`)&&St.names.map(n=>n.toString()).find(n=>n.includes(":trace"))!=null&&(r=St(`${e}:trace`,t)),Object.assign(St(e,t),{error:St(`${e}:error`,t),trace:r,newScope:n=>Oe(`${e}:${n}`,t)})}function Mc(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var Qu=To(On(),1);var Mn=class extends Error{static name="SignatureCreationError";constructor(t="Record signature creation failed"){super(t),this.name="SignatureCreationError"}},Mt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},Vn=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},Me=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},Fn=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},zr=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},qn=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},Zr=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var lt;(function(e){let t;(function(o){o.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),(function(o){o.codec=()=>Fr(r)})(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=Gt((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),e.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let f=o.uint32();switch(f>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=e.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(f&7);break}}}return a})),n),e.encode=o=>Yt(o,e.codec()),e.decode=(o,i)=>Zt(o,e.codec(),i)})(lt||(lt={}));var fh=["string","number","bigint","symbol"],lh=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Fc(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(fh.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(dh(e))return"Buffer";let r=hh(e);return r||"Object"}function dh(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function hh(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(lh.includes(t))return t}var g=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};g.uint=new g(0,"uint",!0);g.negint=new g(1,"negint",!0);g.bytes=new g(2,"bytes",!0);g.string=new g(3,"string",!0);g.array=new g(4,"array",!1);g.map=new g(5,"map",!1);g.tag=new g(6,"tag",!1);g.float=new g(7,"float",!0);g.false=new g(7,"false",!0);g.true=new g(7,"true",!0);g.null=new g(7,"null",!0);g.undefined=new g(7,"undefined",!0);g.break=new g(7,"break",!0);var R=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var ar=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",ph=new TextDecoder,mh=new TextEncoder;function Hn(e){return ar&&globalThis.Buffer.isBuffer(e)}function ns(e){return e instanceof Uint8Array?Hn(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var zc=ar?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Hc(e,t,r):(e,t,r)=>r-t>64?ph.decode(e.subarray(t,r)):Hc(e,t,r),Zc=ar?e=>e.length>64?globalThis.Buffer.from(e):qc(e):e=>e.length>64?mh.encode(e):qc(e),Xt=e=>Uint8Array.from(e),cr=ar?(e,t,r)=>Hn(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Yc=ar?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),ns(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Gc=ar?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function $n(e,t){if(Hn(e)&&Hn(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function qc(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function Hc(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=r){let a,c,f,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=e[t+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=e[t+1],c=e[t+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=e[t+1],c=e[t+2],f=e[t+3],(a&192)===128&&(c&192)===128&&(f&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|f&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=s}return yh(n)}var $c=4096;function yh(e){let t=e.length;if(t<=$c)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=$c));return r}var gh=256,Yr=class{constructor(t=gh){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=Gc(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=cr(n,0,this.cursor)}else r=Yc(this.chunks,this.cursor);return t&&this.reset(),r}};var F="CBOR decode error:",os="CBOR encode error:",Gr=[];Gr[23]=1;Gr[24]=2;Gr[25]=3;Gr[26]=5;Gr[27]=9;function ae(e,t,r){if(e.length-t<r)throw new Error(`${F} not enough data for type`)}var ct=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Tt(e,t,r){ae(e,t,1);let n=e[t];if(r.strict===!0&&n<ct[0])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Bt(e,t,r){ae(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<ct[1])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Ct(e,t,r){ae(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<ct[2])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function _t(e,t,r){ae(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<ct[3])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${F} integers outside of the safe integer range are not supported`)}function jc(e,t,r,n){return new R(g.uint,Tt(e,t+1,n),2)}function Xc(e,t,r,n){return new R(g.uint,Bt(e,t+1,n),3)}function Wc(e,t,r,n){return new R(g.uint,Ct(e,t+1,n),5)}function Jc(e,t,r,n){return new R(g.uint,_t(e,t+1,n),9)}function Rt(e,t){return dt(e,0,t.value)}function dt(e,t,r){if(r<ct[0]){let n=Number(r);e.push([t|n])}else if(r<ct[1]){let n=Number(r);e.push([t|24,n])}else if(r<ct[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<ct[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<ct[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${F} encountered BigInt larger than allowable range`)}}Rt.encodedSize=function(t){return dt.encodedSize(t.value)};dt.encodedSize=function(t){return t<ct[0]?1:t<ct[1]?2:t<ct[2]?3:t<ct[3]?5:9};Rt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Qc(e,t,r,n){return new R(g.negint,-1-Tt(e,t+1,n),2)}function tu(e,t,r,n){return new R(g.negint,-1-Bt(e,t+1,n),3)}function eu(e,t,r,n){return new R(g.negint,-1-Ct(e,t+1,n),5)}var is=BigInt(-1),ru=BigInt(1);function nu(e,t,r,n){let o=_t(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new R(g.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${F} integers outside of the safe integer range are not supported`);return new R(g.negint,is-BigInt(o),9)}function zn(e,t){let r=t.value,n=typeof r=="bigint"?r*is-ru:r*-1-1;dt(e,t.type.majorEncoded,n)}zn.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*is-ru:r*-1-1;return n<ct[0]?1:n<ct[1]?2:n<ct[2]?3:n<ct[3]?5:9};zn.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function jr(e,t,r,n){ae(e,t,r+n);let o=cr(e,t+r,t+r+n);return new R(g.bytes,o,r+n)}function ou(e,t,r,n){return jr(e,t,1,r)}function iu(e,t,r,n){return jr(e,t,2,Tt(e,t+1,n))}function su(e,t,r,n){return jr(e,t,3,Bt(e,t+1,n))}function au(e,t,r,n){return jr(e,t,5,Ct(e,t+1,n))}function cu(e,t,r,n){let o=_t(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer bytes lengths not supported`);return jr(e,t,9,o)}function Zn(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===g.string?Zc(e.value):e.value),e.encodedBytes}function ur(e,t){let r=Zn(t);dt(e,t.type.majorEncoded,r.length),e.push(r)}ur.encodedSize=function(t){let r=Zn(t);return dt.encodedSize(r.length)+r.length};ur.compareTokens=function(t,r){return xh(Zn(t),Zn(r))};function xh(e,t){return e.length<t.length?-1:e.length>t.length?1:$n(e,t)}function Xr(e,t,r,n,o){let i=r+n;ae(e,t,i);let s=new R(g.string,zc(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=cr(e,t+r,t+i)),s}function uu(e,t,r,n){return Xr(e,t,1,r,n)}function fu(e,t,r,n){return Xr(e,t,2,Tt(e,t+1,n),n)}function lu(e,t,r,n){return Xr(e,t,3,Bt(e,t+1,n),n)}function du(e,t,r,n){return Xr(e,t,5,Ct(e,t+1,n),n)}function hu(e,t,r,n){let o=_t(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer string lengths not supported`);return Xr(e,t,9,o,n)}var pu=ur;function fr(e,t,r,n){return new R(g.array,n,r)}function mu(e,t,r,n){return fr(e,t,1,r)}function yu(e,t,r,n){return fr(e,t,2,Tt(e,t+1,n))}function gu(e,t,r,n){return fr(e,t,3,Bt(e,t+1,n))}function bu(e,t,r,n){return fr(e,t,5,Ct(e,t+1,n))}function xu(e,t,r,n){let o=_t(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer array lengths not supported`);return fr(e,t,9,o)}function wu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return fr(e,t,1,1/0)}function Yn(e,t){dt(e,g.array.majorEncoded,t.value)}Yn.compareTokens=Rt.compareTokens;Yn.encodedSize=function(t){return dt.encodedSize(t.value)};function lr(e,t,r,n){return new R(g.map,n,r)}function Eu(e,t,r,n){return lr(e,t,1,r)}function Su(e,t,r,n){return lr(e,t,2,Tt(e,t+1,n))}function vu(e,t,r,n){return lr(e,t,3,Bt(e,t+1,n))}function Au(e,t,r,n){return lr(e,t,5,Ct(e,t+1,n))}function Iu(e,t,r,n){let o=_t(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer map lengths not supported`);return lr(e,t,9,o)}function Tu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return lr(e,t,1,1/0)}function Gn(e,t){dt(e,g.map.majorEncoded,t.value)}Gn.compareTokens=Rt.compareTokens;Gn.encodedSize=function(t){return dt.encodedSize(t.value)};function Bu(e,t,r,n){return new R(g.tag,r,1)}function Cu(e,t,r,n){return new R(g.tag,Tt(e,t+1,n),2)}function _u(e,t,r,n){return new R(g.tag,Bt(e,t+1,n),3)}function Lu(e,t,r,n){return new R(g.tag,Ct(e,t+1,n),5)}function Du(e,t,r,n){return new R(g.tag,_t(e,t+1,n),9)}function jn(e,t){dt(e,g.tag.majorEncoded,t.value)}jn.compareTokens=Rt.compareTokens;jn.encodedSize=function(t){return dt.encodedSize(t.value)};var Ih=20,Th=21,Bh=22,Ch=23;function Ru(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${F} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new R(g.null,null,1):new R(g.undefined,void 0,1)}function Uu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return new R(g.break,void 0,1)}function ss(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${F} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${F} Infinity values are not supported`)}return new R(g.float,e,t)}function Nu(e,t,r,n){return ss(as(e,t+1),3,n)}function ku(e,t,r,n){return ss(cs(e,t+1),5,n)}function Ku(e,t,r,n){return ss(Vu(e,t+1),9,n)}function Xn(e,t,r){let n=t.value;if(n===!1)e.push([g.float.majorEncoded|Ih]);else if(n===!0)e.push([g.float.majorEncoded|Th]);else if(n===null)e.push([g.float.majorEncoded|Bh]);else if(n===void 0)e.push([g.float.majorEncoded|Ch]);else{let o,i=!1;(!r||r.float64!==!0)&&(Ou(n),o=as(Vt,1),n===o||Number.isNaN(n)?(Vt[0]=249,e.push(Vt.slice(0,3)),i=!0):(Mu(n),o=cs(Vt,1),n===o&&(Vt[0]=250,e.push(Vt.slice(0,5)),i=!0))),i||(_h(n),o=Vu(Vt,1),Vt[0]=251,e.push(Vt.slice(0,9)))}}Xn.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Ou(n);let o=as(Vt,1);if(n===o||Number.isNaN(n))return 3;if(Mu(n),o=cs(Vt,1),n===o)return 5}return 9};var Pu=new ArrayBuffer(9),Ut=new DataView(Pu,1),Vt=new Uint8Array(Pu,0);function Ou(e){if(e===1/0)Ut.setUint16(0,31744,!1);else if(e===-1/0)Ut.setUint16(0,64512,!1);else if(Number.isNaN(e))Ut.setUint16(0,32256,!1);else{Ut.setFloat32(0,e);let t=Ut.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Ut.setUint16(0,31744,!1);else if(r===0)Ut.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Ut.setUint16(0,0):o<-14?Ut.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Ut.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function as(e,t){if(e.length-t<2)throw new Error(`${F} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function Mu(e){Ut.setFloat32(0,e,!1)}function cs(e,t){if(e.length-t<4)throw new Error(`${F} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function _h(e){Ut.setFloat64(0,e,!1)}function Vu(e,t){if(e.length-t<8)throw new Error(`${F} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Xn.compareTokens=Rt.compareTokens;function Z(e,t,r){throw new Error(`${F} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Wn(e){return()=>{throw new Error(`${F} ${e}`)}}var C=[];for(let e=0;e<=23;e++)C[e]=Z;C[24]=jc;C[25]=Xc;C[26]=Wc;C[27]=Jc;C[28]=Z;C[29]=Z;C[30]=Z;C[31]=Z;for(let e=32;e<=55;e++)C[e]=Z;C[56]=Qc;C[57]=tu;C[58]=eu;C[59]=nu;C[60]=Z;C[61]=Z;C[62]=Z;C[63]=Z;for(let e=64;e<=87;e++)C[e]=ou;C[88]=iu;C[89]=su;C[90]=au;C[91]=cu;C[92]=Z;C[93]=Z;C[94]=Z;C[95]=Wn("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)C[e]=uu;C[120]=fu;C[121]=lu;C[122]=du;C[123]=hu;C[124]=Z;C[125]=Z;C[126]=Z;C[127]=Wn("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)C[e]=mu;C[152]=yu;C[153]=gu;C[154]=bu;C[155]=xu;C[156]=Z;C[157]=Z;C[158]=Z;C[159]=wu;for(let e=160;e<=183;e++)C[e]=Eu;C[184]=Su;C[185]=vu;C[186]=Au;C[187]=Iu;C[188]=Z;C[189]=Z;C[190]=Z;C[191]=Tu;for(let e=192;e<=215;e++)C[e]=Bu;C[216]=Cu;C[217]=_u;C[218]=Lu;C[219]=Du;C[220]=Z;C[221]=Z;C[222]=Z;C[223]=Z;for(let e=224;e<=243;e++)C[e]=Wn("simple values are not supported");C[244]=Z;C[245]=Z;C[246]=Z;C[247]=Ru;C[248]=Wn("simple values are not supported");C[249]=Nu;C[250]=ku;C[251]=Ku;C[252]=Z;C[253]=Z;C[254]=Z;C[255]=Uu;var Ft=[];for(let e=0;e<24;e++)Ft[e]=new R(g.uint,e,1);for(let e=-1;e>=-24;e--)Ft[31-e]=new R(g.negint,e,1);Ft[64]=new R(g.bytes,new Uint8Array(0),1);Ft[96]=new R(g.string,"",1);Ft[128]=new R(g.array,0,1);Ft[160]=new R(g.map,0,1);Ft[244]=new R(g.false,!1,1);Ft[245]=new R(g.true,!0,1);Ft[246]=new R(g.null,null,1);function us(e){switch(e.type){case g.false:return Xt([244]);case g.true:return Xt([245]);case g.null:return Xt([246]);case g.bytes:return e.value.length?void 0:Xt([64]);case g.string:return e.value===""?Xt([96]):void 0;case g.array:return e.value===0?Xt([128]):void 0;case g.map:return e.value===0?Xt([160]):void 0;case g.uint:return e.value<24?Xt([Number(e.value)]):void 0;case g.negint:if(e.value>=-24)return Xt([31-Number(e.value)])}}var Dh={float64:!1,mapSorter:Nh,quickEncodeToken:us},qu=Object.freeze({float64:!0,mapSorter:kh,quickEncodeToken:us});function Rh(){let e=[];return e[g.uint.major]=Rt,e[g.negint.major]=zn,e[g.bytes.major]=ur,e[g.string.major]=pu,e[g.array.major]=Yn,e[g.map.major]=Gn,e[g.tag.major]=jn,e[g.float.major]=Xn,e}var ls=Rh(),fs=new Yr,Qn=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${os} object contains circular references`);return new e(r,t)}},Ee={null:new R(g.null,null),undefined:new R(g.undefined,void 0),true:new R(g.true,!0),false:new R(g.false,!1),emptyArray:new R(g.array,0),emptyMap:new R(g.map,0)},Se={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new R(g.float,e):e>=0?new R(g.uint,e):new R(g.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new R(g.uint,e):new R(g.negint,e)},Uint8Array(e,t,r,n){return new R(g.bytes,e)},string(e,t,r,n){return new R(g.string,e)},boolean(e,t,r,n){return e?Ee.true:Ee.false},null(e,t,r,n){return Ee.null},undefined(e,t,r,n){return Ee.undefined},ArrayBuffer(e,t,r,n){return new R(g.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new R(g.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[Ee.emptyArray,new R(g.break)]:Ee.emptyArray;n=Qn.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=Jn(s,r,n);return r.addBreakTokens?[new R(g.array,e.length),o,new R(g.break)]:[new R(g.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length;if(!s)return r.addBreakTokens===!0?[Ee.emptyMap,new R(g.break)]:Ee.emptyMap;n=Qn.createCheck(n,e);let a=[],c=0;for(let f of i)a[c++]=[Jn(f,r,n),Jn(o?e.get(f):e[f],r,n)];return Uh(a,r),r.addBreakTokens?[new R(g.map,s),a,new R(g.break)]:[new R(g.map,s),a]}};Se.Map=Se.Object;Se.Buffer=Se.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Se[`${e}Array`]=Se.DataView;function Jn(e,t={},r){let n=Fc(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Se[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Se[n];if(!i)throw new Error(`${os} unsupported type: ${n}`);return i(e,n,t,r)}function Uh(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Nh(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=ls[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function kh(e,t){if(e[0]instanceof R&&t[0]instanceof R){let r=e[0],n=t[0];return r._keyBytes||(r._keyBytes=Fu(r.value)),n._keyBytes||(n._keyBytes=Fu(n.value)),$n(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function Fu(e){return $u(e,ls,qu)}function Hu(e,t,r,n){if(Array.isArray(t))for(let o of t)Hu(e,o,r,n);else r[t.type.major](e,t,n)}function $u(e,t,r){let n=Jn(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,r),a=new Yr(s);if(i(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return ns(a.chunks[0])}}return fs.reset(),Hu(fs,n,t,r),fs.toBytes(!0)}function ds(e,t){return t=Object.assign({},Dh,t),$u(e,ls,t)}var Kh={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},to=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=Ft[t];if(r===void 0){let n=C[t];if(!n)throw new Error(`${F} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},Wr=Symbol.for("DONE"),eo=Symbol.for("BREAK");function Ph(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=dr(t,r);if(i===eo){if(e.value===1/0)break;throw new Error(`${F} got unexpected break to lengthed array`)}if(i===Wr)throw new Error(`${F} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function Oh(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<e.value;s++){let a=dr(t,r);if(a===eo){if(e.value===1/0)break;throw new Error(`${F} got unexpected break to lengthed map`)}if(a===Wr)throw new Error(`${F} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${F} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${F} found repeat map key "${a}"`);let c=dr(t,r);if(c===Wr)throw new Error(`${F} found map but not enough entries (got ${s} [no value], expected ${e.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function dr(e,t){if(e.done())return Wr;let r=e.next();if(r.type===g.break)return eo;if(r.type.terminal)return r.value;if(r.type===g.array)return Ph(r,e,t);if(r.type===g.map)return Oh(r,e,t);if(r.type===g.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=dr(e,t);return t.tags[r.value](n)}throw new Error(`${F} tag not supported (${r.value})`)}throw new Error("unsupported")}function zu(e,t){if(!(e instanceof Uint8Array))throw new Error(`${F} data to decode must be a Uint8Array`);t=Object.assign({},Kh,t);let r=t.tokenizer||new to(e,t),n=dr(r,t);if(n===Wr)throw new Error(`${F} did not find any content to decode`);if(n===eo)throw new Error(`${F} got unexpected break`);return[n,e.subarray(r.pos())]}function hs(e,t){let[r,n]=zu(e,t);if(n.length>0)throw new Error(`${F} too many terminals, data makes no sense`);return r}var Vh=Oe("ipns:utils"),Zu=$("/ipns/"),Fh=114,qh=0,Hh=18;function Yu(e){let t;if(e.pubKey!=null)try{t=kc(e.pubKey)}catch(r){throw Vh.error(r),r}if(t!=null)return t}function Gu(e,t,r){let n=$(t);return le([e,r,n])}function no(e){let t=$("ipns-signature:");return le([t,e])}function Jr(e){return"signatureV1"in e?lt.encode({value:$(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:$(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):lt.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function Lt(e){let t=lt.decode(e);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new Mt("Missing data or signatureV2");let r=Wu(t.data),n=$h(r.Value),o=Y(r.Validity);if(t.value!=null&&t.signatureV1!=null)return zh(t),{value:n,validityType:lt.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:lt.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function ve(e){return le([Zu,e.bytes])}function ju(e){let t=Ye(e.slice(Zu.length));if(!ro(t,qh)&&!ro(t,Hh))throw new un("Multihash in IPNS key was not identity or sha2-256");return t}function Xu(e,t,r,n,o){let i;if(t===lt.ValidityType.EOL)i=0;else throw new Me("The validity type is unsupported");return ds({Value:e,Validity:r,ValidityType:i,Sequence:n,TTL:o})}function Wu(e){let t=hs(e);if(t.ValidityType===0)t.ValidityType=lt.ValidityType.EOL;else throw new Me("The validity type is unsupported");return Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),t}function $h(e){let t=Y(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${it.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${it.parse(t).toV1().toString()}`}catch{}throw new zr("Value must be a valid content path starting with /")}function Ju(e){if(e!=null){let t=Gh(e);if(t!=null)return t.code===Fh?`/ipns/${t.toString(Nt)}`:`/ipfs/${t.toV1().toString()}`;if(Zh(e))return`/ipns/${Nt.encode(e.bytes)}`;let r=e.toString().trim();if(r.startsWith("/")&&r.length>1)return r}throw new zr("Value must be a valid content path starting with /")}function zh(e){if(e.data==null)throw new qn("Record data is missing");let t=Wu(e.data);if(!rt(t.Value,e.value??new Uint8Array(0)))throw new Mt('Field "value" did not match between protobuf and CBOR');if(!rt(t.Validity,e.validity??new Uint8Array(0)))throw new Mt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Mt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Mt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Mt('Field "ttl" did not match between protobuf and CBOR')}function Zh(e){return e.bytes instanceof Uint8Array}function Yh(e){return typeof e?.toCID=="function"}function Gh(e){if(Yh(e))return e.toCID();try{return it.parse(e)}catch{}return it.asCID(e)}function ro(e,t){return e.code===t}var oo=Oe("ipns:validator"),jh=1024*10;async function Xh(e,t){let r=Lt(t),n;try{let o=no(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw oo.error("record signature verification failed"),new Mt("Record signature verification failed");if(r.validityType===lt.ValidityType.EOL){if(Qu.default.fromString(r.validity).toDate().getTime()<Date.now())throw oo.error("record has expired"),new Vn("record has expired")}else if(r.validityType!=null)throw oo.error("the validity type is unsupported"),new Me("The validity type is unsupported");oo("ipns record for %s is valid",r.value)}async function Qr(e,t){if(t.byteLength>jh)throw new Fn("The record is too large");let r=ju(e),n;ro(r,0)&&(n=Kc(r));let o=Lt(t),i=Yu(o)??n;if(i==null)throw new Zr("Could not extract public key from IPNS record or routing key");let s=ve(i.toMultihash());if(!rt(s,e))throw new Zr("Embedded public key did not match routing key");await Xh(i,t)}var tf=To(On(),1);var Wh=Oe("ipns"),ef=300*1e9,Jh="/ipns/",hx=Jh.length,rf={v1Compatible:!0,ttlNs:ef};async function io(e,t,r,n,o=rf){let i=new tf.default(Date.now()+Number(n)),s=lt.ValidityType.EOL,a=BigInt(o.ttlNs??ef);return Qh(e,t,r,s,i.toString(),a,o)}var Qh=async(e,t,r,n,o,i,s=rf)=>{r=BigInt(r);let a=$(o),c=Ju(t),f=$(c),u=Xu(f,n,a,r,i),l=no(u),b=await e.sign(l),S;if(e.type==="RSA"&&(S=de(e.publicKey)),s.v1Compatible===!0){let w=await t0(e,f,n,a),T={value:c,signatureV1:w,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:b,data:u};return S!=null&&(T.pubKey=S),T}else{let w={value:c,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:b,data:u};return S!=null&&(w.pubKey=S),w}},t0=async(e,t,r,n)=>{try{let o=Gu(t,r,n);return await e.sign(o)}catch(o){throw Wh.error("record signature creation failed",o),new Mn("Record signature creation failed")}};var ps=To(On(),1);function so(e,t){let r=t.map((n,o)=>({record:Lt(n),index:o}));return r.sort((n,o)=>{let i=n.record.sequence,s=o.record.sequence;if(i>s)return-1;if(i<s)return 1;if(n.record.validityType===lt.ValidityType.EOL&&o.record.validityType===lt.ValidityType.EOL){let a=ps.default.fromString(n.record.validity).toDate(),c=ps.default.fromString(o.record.validity).toDate();if(a.getTime()>c.getTime())return-1;if(a.getTime()<c.getTime())return 1}return 0}),r[0].index}var hr=BigInt(6e4)*5000000n,nf=5;var ao=class extends Error{static name="RecordsFailedValidationError";constructor(t="Records failed validation"){super(t),this.name="RecordsFailedValidationError"}},co=class extends Error{static name="UnsupportedMultibasePrefixError";constructor(t="Unsupported multibase prefix"){super(t),this.name="UnsupportedMultibasePrefixError"}},uo=class extends Error{static name="UnsupportedMultihashCodecError";constructor(t="Unsupported multihash codec"){super(t),this.name="UnsupportedMultihashCodecError"}},fo=class extends Error{static name="InvalidValueError";constructor(t="Invalid value"){super(t),this.name="InvalidValueError"}};var tn=class extends Error{static name="RecordNotFoundError";name="RecordNotFoundError"};var ce="/",of=new TextEncoder().encode(ce),lo=of[0],pr=class e{_buf;constructor(t,r){if(typeof t=="string")this._buf=$(t);else if(t instanceof Uint8Array)this._buf=t;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==lo)throw new Error("Invalid key")}toString(t="utf8"){return Y(this._buf,t)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(t){return new e(t.join(ce))}static random(){return new e(Math.random().toString().substring(2))}static asKey(t){return t instanceof Uint8Array||typeof t=="string"?new e(t):typeof t.uint8Array=="function"?new e(t.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=of),this._buf[0]!==lo){let t=new Uint8Array(this._buf.byteLength+1);t.fill(lo,0,1),t.set(this._buf,1),this._buf=t}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===lo;)this._buf=this._buf.subarray(0,-1)}less(t){let r=this.list(),n=t.list();for(let o=0;o<r.length;o++){if(n.length<o+1)return!1;let i=r[o],s=n[o];if(i<s)return!0;if(i>s)return!1}return r.length<n.length}reverse(){return e.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let t=this.namespaces();return t[t.length-1]}list(){return this.toString().split(ce).slice(1)}type(){return e0(this.baseNamespace())}name(){return r0(this.baseNamespace())}instance(t){return new e(this.toString()+":"+t)}path(){let t=this.parent().toString();return t.endsWith(ce)||(t+=ce),t+=this.type(),new e(t)}parent(){let t=this.list();return t.length===1?new e(ce):new e(t.slice(0,-1).join(ce))}child(t){return this.toString()===ce?t:t.toString()===ce?this:new e(this.toString()+t.toString(),!1)}isAncestorOf(t){return t.toString()===this.toString()?!1:t.toString().startsWith(this.toString())}isDecendantOf(t){return t.toString()===this.toString()?!1:this.toString().startsWith(t.toString())}isTopLevel(){return this.list().length===1}concat(...t){return e.withNamespaces([...this.namespaces(),...n0(t.map(r=>r.namespaces()))])}};function e0(e){let t=e.split(":");return t.length<2?"":t.slice(0,-1).join(":")}function r0(e){let t=e.split(":");return t[t.length-1]}function n0(e){return[].concat(...e)}var i0=114,ms=0,ys=18;function gs(e,t){return e.code===t}var ho="/dht/record/",s0="/ipns/metadata/";function en(e){return new pr(ho+Y(e,"base32"),!1)}function po(e){return new pr(s0+Y(e,"base32"),!1)}function sf(e,t){let r=Date.now(),n=t.getTime()+1728e5,o=new Date(e.validity).getTime();return n-r<864e5||o-r<864e5}function a0(e){return e?.asCID===e}function af(e){if(!a0(e))return!1;if(e.code!==i0)throw new tt(`CID codec ${e.code} was not libp2p-key`);if(e.multihash.code!==ms&&e.multihash.code!==ys)throw new tt(`Multihash algorithm codec ${e.multihash.code} was not Identity or SHA256 hash`);return!0}var cf={[Nt.prefix]:Nt,[j.prefix]:j},mr=class{routers;localStore;log;constructor(t,r){this.log=t.logger.forComponent("helia:ipns"),this.localStore=r.localStore,this.routers=r.routers}async resolve(t,r={}){let n=Bs(t)||fn(t)?t.toMultihash():af(t)?t.multihash:t,o=ve(n),i=await this.#e(o,r);return{...await this.#t(i.value,r),record:i}}async#t(t,r={}){let n=t.split("/");try{let o=n[1];if(o==="ipns"){let i=n[2],s=i.substring(0,1),a;if(s==="1"||s==="Q")a=j.decode(`z${i}`);else if(cf[s]!=null)a=cf[s].decode(i);else throw new co(`Unsupported multibase prefix "${s}"`);let c;try{c=Ye(a)}catch{c=it.decode(a).multihash}if(!gs(c,ms)&&!gs(c,ys))throw new uo(`Unsupported multihash codec "${c.code}"`);let{cid:f}=await this.resolve(c,r),u=n.slice(3).join("/");return{cid:f,path:u===""?void 0:u}}else if(o==="ipfs"){let i=it.parse(n[2]),s=n.slice(3).join("/");return{cid:i,path:s===""?void 0:s}}}catch(o){this.log.error("error parsing ipfs path - %e",o)}throw this.log.error("invalid ipfs path %s",t),new fo("Invalid value")}async#e(t,r={}){let n=[];if(await this.localStore.has(t,r))if(this.log("record is present in the cache"),r.nocache!==!0)try{let{record:c,created:f}=await this.localStore.get(t,r);this.log("record retrieved from cache"),await Qr(t,c),this.log("record was valid");let u=Lt(c),l=Number((u.ttl??hr)/1000000n);if(f.getTime()+l>Date.now())return this.log("record TTL was valid"),u;if(r.offline===!0)return this.log("record TTL has been reached but we are resolving offline-only, returning record"),u;this.log("record TTL has been reached, searching routing for updates"),n.push(c)}catch(c){this.log("cached record was invalid - %e",c),await this.localStore.delete(t,r)}else this.log("ignoring local cache due to nocache=true option");if(r.offline===!0)throw new tn("Record was not present in the cache or has expired");this.log("did not have record locally");let i=0,s=[];if(await Promise.all(this.routers.map(async c=>{let f;try{f=await c.get(t,{...r,validate:!1})}catch(u){this.log.error("error finding IPNS record using router %s - %e",c.toString(),u),s.push(u);return}try{await Qr(t,f),n.push(f)}catch(u){i++,this.log.error("error validating IPNS record from router %s - %e",c.toString(),u)}})),n.length===0)throw i>0?new ao(`${i>1?`${i} records`:"Record"} found for routing key ${i>1?"were":"was"} invalid`):new tn("Could not find record for routing key");let a=n[so(t,n)];return await this.localStore.put(t,a,r),Lt(a)}};var vt=class extends Event{type;detail;constructor(t,r){super(t),this.type=t,this.detail=r}};var mo=class{routers;localStore;keychain;constructor(t,r){this.keychain=t.libp2p.services.keychain,this.localStore=r.localStore,this.routers=r.routers}async publish(t,r,n={}){try{let o=await this.#t(t),i=1n,s=ve(o.publicKey.toMultihash());if(await this.localStore.has(s,n)){let{record:l}=await this.localStore.get(s,n);i=Lt(l).sequence+1n}fn(r)&&(r=r.toCID());let a=n.ttl!=null?BigInt(n.ttl)*1000000n:hr,c=n.lifetime??1728e5,f=await io(o,r,i,c,{...n,ttlNs:a}),u=Jr(f);return n.offline===!0?await this.localStore.put(s,u,{...n,metadata:{keyName:t,lifetime:c}}):await Promise.all(this.routers.map(async l=>{await l.put(s,u,{...n,metadata:{keyName:t,lifetime:c}})})),{record:f,publicKey:o.publicKey}}catch(o){throw n.onProgress?.(new vt("ipns:publish:error",o)),o}}async#t(t){try{return await this.keychain.exportKey(t)}catch{let n=await Nc("Ed25519");return await this.keychain.importKey(t,n),n}}async unpublish(t,r){let{publicKey:n}=await this.keychain.exportKey(t),o=n.toMultihash(),i=ve(o);await this.localStore.delete(i,r)}};function yr(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var yo=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||(t-1&t)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},gr=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new yo(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let r=this.head;this.head=r.next=new yo(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var bs=class extends Error{type;code;constructor(t,r){super(t??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function uf(e={}){return u0(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},e)}function u0(e,t){t=t??{};let r=t.onEnd,n=new gr,o,i,s,a=yr(),c=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((E,x)=>{i=B=>{i=null,n.push(B);try{E(e(n))}catch(v){x(v)}return o}}):e(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=yr()})}},f=E=>i!=null?i(E):(n.push(E),o),u=E=>(n=new gr,i!=null?i({error:E}):(n.push({error:E}),o)),l=E=>{if(s)return o;if(t?.objectMode!==!0&&E?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return f({done:!1,value:E})},b=E=>s?o:(s=!0,E!=null?u(E):f({done:!0})),S=()=>(n=new gr,b(),{done:!0}),w=E=>(b(E),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:S,throw:w,push:l,end:b,get readableLength(){return n.size},onEmpty:async E=>{let x=E?.signal;if(x?.throwIfAborted(),n.isEmpty())return;let B,v;x!=null&&(B=new Promise((U,P)=>{v=()=>{P(new bs)},x.addEventListener("abort",v)}));try{await Promise.race([a.promise,B])}finally{v!=null&&x!=null&&x?.removeEventListener("abort",v)}}},r==null)return o;let T=o;return o={[Symbol.asyncIterator](){return this},next(){return T.next()},throw(E){return T.throw(E),r!=null&&(r(E),r=void 0),{done:!0}},return(){return T.return(),r!=null&&(r(),r=void 0),{done:!0}},push:l,end(E){return T.end(E),r!=null&&(r(E),r=void 0),o},get readableLength(){return T.readableLength},onEmpty:E=>T.onEmpty(E)},o}var xs=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},ws=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},ff=e=>globalThis.DOMException===void 0?new ws(e):new DOMException(e),lf=e=>{let t=e.reason===void 0?ff("This operation was aborted."):e.reason;return t instanceof Error?t:ff(t)};function Es(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,s,a,f=new Promise((u,l)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:S}=t;S.aborted&&l(lf(S)),a=()=>{l(lf(S))},S.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){e.then(u,l);return}let b=new xs;s=i.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(S){l(S)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?u():o instanceof Error?l(o):(b.message=o??`Promise timed out after ${r} milliseconds`,l(b))},r),(async()=>{try{u(await e)}catch(S){l(S)}})()}).finally(()=>{f.clear(),a&&t.signal&&t.signal.removeEventListener("abort",a)});return f.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},f}var f0=e=>{let t=e.addEventListener||e.on||e.addListener,r=e.removeEventListener||e.off||e.removeListener;if(!t||!r)throw new TypeError("Emitter is not compatible");return{addListener:t.bind(e),removeListener:r.bind(e)}};function l0(e,t,r){let n,o=new Promise((i,s)=>{if(r={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...r},!(r.count>=0&&(r.count===Number.POSITIVE_INFINITY||Number.isInteger(r.count))))throw new TypeError("The `count` option should be at least 0 or more");r.signal?.throwIfAborted();let a=[t].flat(),c=[],{addListener:f,removeListener:u}=f0(e),l=async(...S)=>{let w=r.multiArgs?S:S[0];if(r.filter)try{if(!await r.filter(w))return}catch(T){n(),s(T);return}c.push(w),r.count===c.length&&(n(),i(c))},b=(...S)=>{n(),s(r.rejectionMultiArgs?S:S[0])};n=()=>{for(let S of a)u(S,l);for(let S of r.rejectionEvents)a.includes(S)||u(S,b)};for(let S of a)f(S,l);for(let S of r.rejectionEvents)a.includes(S)||f(S,b);r.signal&&r.signal.addEventListener("abort",()=>{b(r.signal.reason)},{once:!0}),r.resolveImmediately&&i(c)});if(o.cancel=n,typeof r.timeout=="number"){let i=Es(o,{milliseconds:r.timeout});return i.cancel=()=>{n(),i.clear()},i}return o}function go(e,t,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=l0(e,t,r),o=n.then(i=>i[0]);return o.cancel=n.cancel,o}function rn(e,t){let r,n=function(){let o=function(){r=void 0,e()};clearTimeout(r),r=setTimeout(o,t)};return n.start=()=>{},n.stop=()=>{clearTimeout(r)},n}var bo=class extends Error{static name="QueueFullError";constructor(t="The queue was full"){super(t),this.name="QueueFullError"}};function d0(e){return e.reason}async function df(e,t,r){if(t==null)return e;let n=r?.translateError??d0;if(t.aborted)return e.catch(()=>{}),Promise.reject(n(t));let o;try{return await Promise.race([e,new Promise((i,s)=>{o=()=>{s(n(t))},t.addEventListener("abort",o)})])}finally{o!=null&&t.removeEventListener("abort",o)}}var xo=class{deferred;signal;constructor(t){this.signal=t,this.deferred=yr(),this.onAbort=this.onAbort.bind(this),this.signal?.addEventListener("abort",this.onAbort)}onAbort(){this.deferred.reject(this.signal?.reason??new Wt)}cleanup(){this.signal?.removeEventListener("abort",this.onAbort)}};function h0(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}var wo=class{id;fn;options;recipients;status;timeline;controller;constructor(t,r){this.id=h0(),this.status="queued",this.fn=t,this.options=r,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,this.controller.signal,this.onAbort=this.onAbort.bind(this)}abort(t){this.controller.abort(t)}onAbort(){this.recipients.reduce((r,n)=>r&&n.signal?.aborted===!0,!0)&&(this.controller.abort(new Wt),this.cleanup())}async join(t={}){let r=new xo(t.signal);return this.recipients.push(r),t.signal?.addEventListener("abort",this.onAbort),r.deferred.promise}async run(){this.status="running",this.timeline.started=Date.now();try{this.controller.signal.throwIfAborted();let t=await df(this.fn({...this.options??{},signal:this.controller.signal}),this.controller.signal);this.recipients.forEach(r=>{r.deferred.resolve(t)}),this.status="complete"}catch(t){this.recipients.forEach(r=>{r.deferred.reject(t)}),this.status="errored"}finally{this.timeline.finished=Date.now(),this.cleanup()}}cleanup(){this.recipients.forEach(t=>{t.cleanup(),t.signal?.removeEventListener("abort",this.onAbort)})}};var Eo=class extends ln{concurrency;maxSize;queue;pending;sort;paused;constructor(t={}){super(),this.concurrency=t.concurrency??Number.POSITIVE_INFINITY,this.maxSize=t.maxSize??Number.POSITIVE_INFINITY,this.pending=0,this.paused=!1,t.metricName!=null&&t.metrics?.registerMetricGroup(t.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})}),this.sort=t.sort,this.queue=[],this.emitEmpty=rn(this.emitEmpty.bind(this),1),this.emitIdle=rn(this.emitIdle.bind(this),1)}emitEmpty(){this.size===0&&this.safeDispatchEvent("empty")}emitIdle(){this.running===0&&this.safeDispatchEvent("idle")}pause(){this.paused=!0}resume(){this.paused&&(this.paused=!1,this.tryToStartAnother())}tryToStartAnother(){if(this.paused)return!1;if(this.size===0)return this.emitEmpty(),this.running===0&&this.emitIdle(),!1;if(this.pending<this.concurrency){let t;for(let r of this.queue)if(r.status==="queued"){t=r;break}return t==null?!1:(this.safeDispatchEvent("active"),this.pending++,t.run().finally(()=>{for(let r=0;r<this.queue.length;r++)if(this.queue[r]===t){this.queue.splice(r,1);break}this.pending--,this.tryToStartAnother(),this.safeDispatchEvent("next")}),!0)}return!1}enqueue(t){this.queue.push(t),this.sort!=null&&this.queue.sort(this.sort)}async add(t,r){if(r?.signal?.throwIfAborted(),this.size===this.maxSize)throw new bo;let n=new wo(t,r);return this.enqueue(n),this.safeDispatchEvent("add"),this.tryToStartAnother(),n.join(r).then(o=>(this.safeDispatchEvent("completed",{detail:o}),this.safeDispatchEvent("success",{detail:{job:n,result:o}}),o)).catch(o=>{if(n.status==="queued"){for(let i=0;i<this.queue.length;i++)if(this.queue[i]===n){this.queue.splice(i,1);break}}throw this.safeDispatchEvent("failure",{detail:{job:n,error:o}}),o})}clear(){this.queue.splice(0,this.queue.length)}abort(){this.queue.forEach(t=>{t.abort(new Wt)}),this.clear()}async onEmpty(t){this.size!==0&&await go(this,"empty",t)}async onSizeLessThan(t,r){this.size<t||await go(this,"next",{...r,filter:()=>this.size<t})}async onIdle(t){this.pending===0&&this.size===0||await go(this,"idle",t)}get size(){return this.queue.length}get queued(){return this.queue.length-this.pending}get running(){return this.pending}async*toGenerator(t){t?.signal?.throwIfAborted();let r=uf({objectMode:!0}),n=c=>{c!=null?this.abort():this.clear(),r.end(c)},o=c=>{c.detail!=null&&r.push(c.detail)},i=c=>{n(c.detail.error)},s=()=>{n()},a=()=>{n(new Wt("Queue aborted"))};this.addEventListener("completed",o),this.addEventListener("failure",i),this.addEventListener("idle",s),t?.signal?.addEventListener("abort",a);try{yield*r}finally{this.removeEventListener("completed",o),this.removeEventListener("failure",i),this.removeEventListener("idle",s),t?.signal?.removeEventListener("abort",a),n()}}};function hf(e){let t=new globalThis.AbortController;function r(){t.abort();for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}for(let i of e){if(i?.aborted===!0){r();break}i?.addEventListener!=null&&i.addEventListener("abort",r)}function n(){for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}let o=t.signal;return o.clear=n,o}function pf(e,t,r){let n,o,i=!1;function s(){let f={signal:o.signal};if(r?.timeout!=null){let u=hf([o.signal,AbortSignal.timeout(r.timeout)]);f.signal=u}i=!0,Promise.resolve().then(async()=>{await e(f)}).catch(()=>{}).finally(()=>{i=!1,!o.signal.aborted&&(n=setTimeout(s,t))})}let a=rn(s,r?.debounce??100),c=!1;return{setInterval:f=>{t!==f&&(t=f,n!=null&&(clearTimeout(n),n=setTimeout(s,t)))},setTimeout:f=>{r??={},r.timeout=f},run:()=>{i||(clearTimeout(n),a())},start:()=>{c||(c=!0,o=new AbortController,o.signal,r?.runImmediately===!0?queueMicrotask(()=>{s()}):n=setTimeout(s,t))},stop:()=>{clearTimeout(n),o?.abort(),c=!1}}}var So=class{routers;localStore;republishTask;log;keychain;started=!1;republishConcurrency;constructor(t,r){this.log=t.logger.forComponent("helia:ipns"),this.localStore=r.localStore,this.keychain=t.libp2p.services.keychain,this.republishConcurrency=r.republishConcurrency||nf,this.started=t.libp2p.status==="started",this.routers=r.routers??[],this.republishTask=pf(this.#t.bind(this),r.republishInterval??36e5,{runImmediately:!0}),this.started&&this.republishTask.start()}start(){this.started||(this.started=!0,this.republishTask.start())}stop(){this.started&&(this.started=!1,this.republishTask.stop())}async#t(t={}){if(!this.started)return;this.log("starting ipns republish records loop");let r=new Eo({concurrency:this.republishConcurrency});try{let n=[];for await(let{routingKey:o,record:i,metadata:s,created:a}of this.localStore.list(t)){if(s==null){this.log(`no metadata found for record ${o.toString()}, skipping`);continue}let c;try{c=Lt(i)}catch(b){this.log.error("error unmarshaling record - %e",b);continue}if(!sf(c,a)){this.log.trace(`skipping record ${o.toString()}within republish threshold`);continue}let f=c.sequence+1n,u=c.ttl??hr,l;try{l=await this.keychain.exportKey(s.keyName)}catch(b){this.log.error("missing key %s, skipping republishing record - %e",s.keyName,b);continue}try{let b=await io(l,c.value,f,s.lifetime,{...t,ttlNs:u});n.push({routingKey:o,record:b})}catch(b){this.log.error("error creating updated IPNS record for %s - %e",o,b);continue}}this.log(`found ${n.length} records to republish`);for(let{routingKey:o,record:i}of n)r.add(async()=>{try{let s=Jr(i);await Promise.all(this.routers.map(a=>a.put(o,s,t)))}catch(s){this.log.error("error republishing record - %e",s)}},t)}catch(n){this.log.error("error during republish - %e",n)}await r.onIdle(t)}};var nn;(function(e){let t;e.codec=()=>(t==null&&(t=Gt((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.key!=null&&r.key.byteLength>0&&(n.uint32(10),n.bytes(r.key)),r.value!=null&&r.value.byteLength>0&&(n.uint32(18),n.bytes(r.value)),r.timeReceived!=null&&r.timeReceived!==""&&(n.uint32(42),n.string(r.timeReceived)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={key:Dt(0),value:Dt(0),timeReceived:""},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.key=r.bytes();break}case 2:{i.value=r.bytes();break}case 5:{i.timeReceived=r.string();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>Yt(r,e.codec()),e.decode=(r,n)=>Zt(r,e.codec(),n)})(nn||(nn={}));function mf(e){let t=e.getUTCFullYear(),r=String(e.getUTCMonth()+1).padStart(2,"0"),n=String(e.getUTCDate()).padStart(2,"0"),o=String(e.getUTCHours()).padStart(2,"0"),i=String(e.getUTCMinutes()).padStart(2,"0"),s=String(e.getUTCSeconds()).padStart(2,"0"),a=e.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${t}-${r}-${n}T${o}:${i}:${s}.${c}Z`}function yf(e){let t=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),r=String(e).trim().match(t);if(r==null)throw new Error("Invalid format");let n=parseInt(r[1],10),o=parseInt(r[2],10)-1,i=parseInt(r[3],10),s=parseInt(r[4],10),a=parseInt(r[5],10),c=parseInt(r[6],10),f=parseInt(r[7].slice(0,-6),10);return new Date(Date.UTC(n,o,i,s,a,c,f))}var Ae=class e{key;value;timeReceived;constructor(t,r,n){if(!(t instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(r instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=t,this.value=r,this.timeReceived=n}serialize(){return nn.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:mf(this.timeReceived)}}static deserialize(t){let r=nn.decode(t);return new e(r.key,r.value,new Date(r.timeReceived))}static fromDeserialized(t){let r=yf(t.timeReceived);if(t.key==null)throw new Error("key missing from deserialized object");if(t.value==null)throw new Error("value missing from deserialized object");return new e(t.key,t.value,r)}};var gf;(function(e){e[e.SEND_QUERY=0]="SEND_QUERY",e[e.PEER_RESPONSE=1]="PEER_RESPONSE",e[e.FINAL_PEER=2]="FINAL_PEER",e[e.QUERY_ERROR=3]="QUERY_ERROR",e[e.PROVIDER=4]="PROVIDER",e[e.VALUE=5]="VALUE",e[e.ADD_PEER=6]="ADD_PEER",e[e.DIAL_PEER=7]="DIAL_PEER",e[e.PATH_ENDED=8]="PATH_ENDED"})(gf||(gf={}));var on;(function(e){let t;e.codec=()=>(t==null&&(t=Gt((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.keyName!=null&&r.keyName!==""&&(n.uint32(10),n.string(r.keyName)),r.lifetime!=null&&r.lifetime!==0&&(n.uint32(16),n.uint32(r.lifetime)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={keyName:"",lifetime:0},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.keyName=r.string();break}case 2:{i.lifetime=r.uint32();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>Yt(r,e.codec()),e.decode=(r,n)=>Zt(r,e.codec(),n)})(on||(on={}));function vo(e,t){return{async put(r,n,o={}){try{let i=en(r);try{let c=await e.get(i),f=Ae.deserialize(c);if(rt(f.value,n))return}catch(c){if(c.name!=="NotFoundError")throw c}let s=new Ae(r,n,new Date);o.onProgress?.(new vt("ipns:routing:datastore:put"));let a=e.batch();a.put(i,s.serialize()),o.metadata!=null&&a.put(po(r),on.encode(o.metadata)),await a.commit(o)}catch(i){throw o.onProgress?.(new vt("ipns:routing:datastore:error",i)),i}},async get(r,n={}){try{let o=en(r);n.onProgress?.(new vt("ipns:routing:datastore:get"));let i=await e.get(o,n),s=Ae.deserialize(i);return{record:s.value,created:s.timeReceived}}catch(o){throw n.onProgress?.(new vt("ipns:routing:datastore:error",o)),o}},async has(r,n={}){let o=en(r);return e.has(o,n)},async delete(r,n){let o=en(r),i=e.batch();i.delete(o),i.delete(po(r)),await i.commit(n)},async*list(r={}){try{r.onProgress?.(new vt("ipns:routing:datastore:list"));for await(let{key:n,value:o}of e.query({prefix:ho},r))try{let i=Ae.deserialize(o),a=n.toString().substring(ho.length),c=$(a,"base32"),f=po(c),u;try{let l=await e.get(f,r);u=on.decode(l)}catch(l){t.error("Error deserializing metadata for %s - %e",a,l)}yield{routingKey:c,metadata:u,record:i.value,created:i.timeReceived}}catch(i){t.error("Error deserializing record - %e",i)}}catch(n){throw r.onProgress?.(new vt("ipns:routing:datastore:error",n)),n}}}}var Ss=class{routing;constructor(t){this.routing=t}async put(t,r,n={}){try{await this.routing.put(t,r,n)}catch(o){throw n.onProgress?.(new vt("ipns:routing:helia:error",o)),o}}async get(t,r={}){try{return await this.routing.get(t,r)}catch(n){throw r.onProgress?.(new vt("ipns:routing:helia:error",n)),n}}toString(){return"HeliaRouting()"}};function sn(e){return new Ss(e)}var vs=class{localStore;constructor(t){this.localStore=t}async put(t,r,n){await this.localStore.put(t,r,n)}async get(t,r){let{record:n}=await this.localStore.get(t,r);return n}toString(){return"LocalStoreRouting()"}};function Ao(e){return new vs(e)}var Io=class{routers;publisher;republisher;resolver;localStore;started;constructor(t,r={}){this.localStore=vo(t.datastore,t.logger.forComponent("helia:ipns:local-store")),this.started=t.libp2p.status==="started",this.routers=[Ao(this.localStore),sn(t.routing),...r.routers??[]],this.publisher=new mo(t,{...r,routers:this.routers,localStore:this.localStore}),this.republisher=new So(t,{...r,routers:this.routers,localStore:this.localStore}),this.resolver=new mr(t,{...r,routers:this.routers,localStore:this.localStore}),t.events.addEventListener("start",this.start.bind(this)),t.events.addEventListener("stop",this.stop.bind(this)),this.started&&this.republisher.start()}start(){this.started||(this.started=!0,this.republisher.start())}stop(){this.started&&(this.started=!1,this.republisher.stop())}async publish(t,r,n={}){return this.publisher.publish(t,r,n)}async resolve(t,r={}){return this.resolver.resolve(t,r)}async unpublish(t,r){return this.publisher.unpublish(t,r)}};function y0(e,t={}){return new Io(e,t)}function g0(e,t={}){let r=vo(e.datastore,e.logger.forComponent("helia:ipns:local-store")),n=[Ao(r),sn(e.routing),...t.routers??[]];return new mr(e,{routers:n,localStore:r})}return Af(b0);})();
|
|
13
|
+
${t}[Error list was empty]`,r.trim()}return Oc(e,t)}St.formatters.e=e=>e==null?"undefined":Vc(e);function uh(e){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function Oe(e,t){let r=uh(`${e}:trace`);return St.enabled(`${e}:trace`)&&St.names.map(n=>n.toString()).find(n=>n.includes(":trace"))!=null&&(r=St(`${e}:trace`,t)),Object.assign(St(e,t),{error:St(`${e}:error`,t),trace:r,newScope:n=>Oe(`${e}:${n}`,t)})}function Mc(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var Qu=To(On(),1);var Mn=class extends Error{static name="SignatureCreationError";constructor(t="Record signature creation failed"){super(t),this.name="SignatureCreationError"}},Mt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},Vn=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},Me=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},Fn=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},zr=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},qn=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},Zr=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var lt;(function(e){let t;(function(o){o.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),(function(o){o.codec=()=>Fr(r)})(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=Gt((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),e.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let f=o.uint32();switch(f>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=e.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(f&7);break}}}return a})),n),e.encode=o=>Yt(o,e.codec()),e.decode=(o,i)=>Zt(o,e.codec(),i)})(lt||(lt={}));var fh=["string","number","bigint","symbol"],lh=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Fc(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(fh.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(dh(e))return"Buffer";let r=hh(e);return r||"Object"}function dh(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function hh(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(lh.includes(t))return t}var g=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};g.uint=new g(0,"uint",!0);g.negint=new g(1,"negint",!0);g.bytes=new g(2,"bytes",!0);g.string=new g(3,"string",!0);g.array=new g(4,"array",!1);g.map=new g(5,"map",!1);g.tag=new g(6,"tag",!1);g.float=new g(7,"float",!0);g.false=new g(7,"false",!0);g.true=new g(7,"true",!0);g.null=new g(7,"null",!0);g.undefined=new g(7,"undefined",!0);g.break=new g(7,"break",!0);var R=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var ar=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",ph=new TextDecoder,mh=new TextEncoder;function Hn(e){return ar&&globalThis.Buffer.isBuffer(e)}function ns(e){return e instanceof Uint8Array?Hn(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var zc=ar?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Hc(e,t,r):(e,t,r)=>r-t>64?ph.decode(e.subarray(t,r)):Hc(e,t,r),Zc=ar?e=>e.length>64?globalThis.Buffer.from(e):qc(e):e=>e.length>64?mh.encode(e):qc(e),Xt=e=>Uint8Array.from(e),cr=ar?(e,t,r)=>Hn(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Yc=ar?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),ns(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Gc=ar?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function $n(e,t){if(Hn(e)&&Hn(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function qc(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function Hc(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=r){let a,c,f,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=e[t+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=e[t+1],c=e[t+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=e[t+1],c=e[t+2],f=e[t+3],(a&192)===128&&(c&192)===128&&(f&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|f&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=s}return yh(n)}var $c=4096;function yh(e){let t=e.length;if(t<=$c)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=$c));return r}var gh=256,Yr=class{constructor(t=gh){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=Gc(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=cr(n,0,this.cursor)}else r=Yc(this.chunks,this.cursor);return t&&this.reset(),r}};var F="CBOR decode error:",os="CBOR encode error:",Gr=[];Gr[23]=1;Gr[24]=2;Gr[25]=3;Gr[26]=5;Gr[27]=9;function ae(e,t,r){if(e.length-t<r)throw new Error(`${F} not enough data for type`)}var ct=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Tt(e,t,r){ae(e,t,1);let n=e[t];if(r.strict===!0&&n<ct[0])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Bt(e,t,r){ae(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<ct[1])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function Ct(e,t,r){ae(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<ct[2])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);return n}function _t(e,t,r){ae(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<ct[3])throw new Error(`${F} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${F} integers outside of the safe integer range are not supported`)}function jc(e,t,r,n){return new R(g.uint,Tt(e,t+1,n),2)}function Xc(e,t,r,n){return new R(g.uint,Bt(e,t+1,n),3)}function Wc(e,t,r,n){return new R(g.uint,Ct(e,t+1,n),5)}function Jc(e,t,r,n){return new R(g.uint,_t(e,t+1,n),9)}function Rt(e,t){return dt(e,0,t.value)}function dt(e,t,r){if(r<ct[0]){let n=Number(r);e.push([t|n])}else if(r<ct[1]){let n=Number(r);e.push([t|24,n])}else if(r<ct[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<ct[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<ct[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${F} encountered BigInt larger than allowable range`)}}Rt.encodedSize=function(t){return dt.encodedSize(t.value)};dt.encodedSize=function(t){return t<ct[0]?1:t<ct[1]?2:t<ct[2]?3:t<ct[3]?5:9};Rt.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Qc(e,t,r,n){return new R(g.negint,-1-Tt(e,t+1,n),2)}function tu(e,t,r,n){return new R(g.negint,-1-Bt(e,t+1,n),3)}function eu(e,t,r,n){return new R(g.negint,-1-Ct(e,t+1,n),5)}var is=BigInt(-1),ru=BigInt(1);function nu(e,t,r,n){let o=_t(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new R(g.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${F} integers outside of the safe integer range are not supported`);return new R(g.negint,is-BigInt(o),9)}function zn(e,t){let r=t.value,n=typeof r=="bigint"?r*is-ru:r*-1-1;dt(e,t.type.majorEncoded,n)}zn.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*is-ru:r*-1-1;return n<ct[0]?1:n<ct[1]?2:n<ct[2]?3:n<ct[3]?5:9};zn.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function jr(e,t,r,n){ae(e,t,r+n);let o=cr(e,t+r,t+r+n);return new R(g.bytes,o,r+n)}function ou(e,t,r,n){return jr(e,t,1,r)}function iu(e,t,r,n){return jr(e,t,2,Tt(e,t+1,n))}function su(e,t,r,n){return jr(e,t,3,Bt(e,t+1,n))}function au(e,t,r,n){return jr(e,t,5,Ct(e,t+1,n))}function cu(e,t,r,n){let o=_t(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer bytes lengths not supported`);return jr(e,t,9,o)}function Zn(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===g.string?Zc(e.value):e.value),e.encodedBytes}function ur(e,t){let r=Zn(t);dt(e,t.type.majorEncoded,r.length),e.push(r)}ur.encodedSize=function(t){let r=Zn(t);return dt.encodedSize(r.length)+r.length};ur.compareTokens=function(t,r){return xh(Zn(t),Zn(r))};function xh(e,t){return e.length<t.length?-1:e.length>t.length?1:$n(e,t)}function Xr(e,t,r,n,o){let i=r+n;ae(e,t,i);let s=new R(g.string,zc(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=cr(e,t+r,t+i)),s}function uu(e,t,r,n){return Xr(e,t,1,r,n)}function fu(e,t,r,n){return Xr(e,t,2,Tt(e,t+1,n),n)}function lu(e,t,r,n){return Xr(e,t,3,Bt(e,t+1,n),n)}function du(e,t,r,n){return Xr(e,t,5,Ct(e,t+1,n),n)}function hu(e,t,r,n){let o=_t(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer string lengths not supported`);return Xr(e,t,9,o,n)}var pu=ur;function fr(e,t,r,n){return new R(g.array,n,r)}function mu(e,t,r,n){return fr(e,t,1,r)}function yu(e,t,r,n){return fr(e,t,2,Tt(e,t+1,n))}function gu(e,t,r,n){return fr(e,t,3,Bt(e,t+1,n))}function bu(e,t,r,n){return fr(e,t,5,Ct(e,t+1,n))}function xu(e,t,r,n){let o=_t(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer array lengths not supported`);return fr(e,t,9,o)}function wu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return fr(e,t,1,1/0)}function Yn(e,t){dt(e,g.array.majorEncoded,t.value)}Yn.compareTokens=Rt.compareTokens;Yn.encodedSize=function(t){return dt.encodedSize(t.value)};function lr(e,t,r,n){return new R(g.map,n,r)}function Eu(e,t,r,n){return lr(e,t,1,r)}function Su(e,t,r,n){return lr(e,t,2,Tt(e,t+1,n))}function vu(e,t,r,n){return lr(e,t,3,Bt(e,t+1,n))}function Au(e,t,r,n){return lr(e,t,5,Ct(e,t+1,n))}function Iu(e,t,r,n){let o=_t(e,t+1,n);if(typeof o=="bigint")throw new Error(`${F} 64-bit integer map lengths not supported`);return lr(e,t,9,o)}function Tu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return lr(e,t,1,1/0)}function Gn(e,t){dt(e,g.map.majorEncoded,t.value)}Gn.compareTokens=Rt.compareTokens;Gn.encodedSize=function(t){return dt.encodedSize(t.value)};function Bu(e,t,r,n){return new R(g.tag,r,1)}function Cu(e,t,r,n){return new R(g.tag,Tt(e,t+1,n),2)}function _u(e,t,r,n){return new R(g.tag,Bt(e,t+1,n),3)}function Lu(e,t,r,n){return new R(g.tag,Ct(e,t+1,n),5)}function Du(e,t,r,n){return new R(g.tag,_t(e,t+1,n),9)}function jn(e,t){dt(e,g.tag.majorEncoded,t.value)}jn.compareTokens=Rt.compareTokens;jn.encodedSize=function(t){return dt.encodedSize(t.value)};var Ih=20,Th=21,Bh=22,Ch=23;function Ru(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${F} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new R(g.null,null,1):new R(g.undefined,void 0,1)}function Uu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${F} indefinite length items not allowed`);return new R(g.break,void 0,1)}function ss(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${F} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${F} Infinity values are not supported`)}return new R(g.float,e,t)}function Nu(e,t,r,n){return ss(as(e,t+1),3,n)}function ku(e,t,r,n){return ss(cs(e,t+1),5,n)}function Ku(e,t,r,n){return ss(Vu(e,t+1),9,n)}function Xn(e,t,r){let n=t.value;if(n===!1)e.push([g.float.majorEncoded|Ih]);else if(n===!0)e.push([g.float.majorEncoded|Th]);else if(n===null)e.push([g.float.majorEncoded|Bh]);else if(n===void 0)e.push([g.float.majorEncoded|Ch]);else{let o,i=!1;(!r||r.float64!==!0)&&(Ou(n),o=as(Vt,1),n===o||Number.isNaN(n)?(Vt[0]=249,e.push(Vt.slice(0,3)),i=!0):(Mu(n),o=cs(Vt,1),n===o&&(Vt[0]=250,e.push(Vt.slice(0,5)),i=!0))),i||(_h(n),o=Vu(Vt,1),Vt[0]=251,e.push(Vt.slice(0,9)))}}Xn.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Ou(n);let o=as(Vt,1);if(n===o||Number.isNaN(n))return 3;if(Mu(n),o=cs(Vt,1),n===o)return 5}return 9};var Pu=new ArrayBuffer(9),Ut=new DataView(Pu,1),Vt=new Uint8Array(Pu,0);function Ou(e){if(e===1/0)Ut.setUint16(0,31744,!1);else if(e===-1/0)Ut.setUint16(0,64512,!1);else if(Number.isNaN(e))Ut.setUint16(0,32256,!1);else{Ut.setFloat32(0,e);let t=Ut.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Ut.setUint16(0,31744,!1);else if(r===0)Ut.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Ut.setUint16(0,0):o<-14?Ut.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Ut.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function as(e,t){if(e.length-t<2)throw new Error(`${F} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function Mu(e){Ut.setFloat32(0,e,!1)}function cs(e,t){if(e.length-t<4)throw new Error(`${F} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function _h(e){Ut.setFloat64(0,e,!1)}function Vu(e,t){if(e.length-t<8)throw new Error(`${F} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Xn.compareTokens=Rt.compareTokens;function Z(e,t,r){throw new Error(`${F} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Wn(e){return()=>{throw new Error(`${F} ${e}`)}}var C=[];for(let e=0;e<=23;e++)C[e]=Z;C[24]=jc;C[25]=Xc;C[26]=Wc;C[27]=Jc;C[28]=Z;C[29]=Z;C[30]=Z;C[31]=Z;for(let e=32;e<=55;e++)C[e]=Z;C[56]=Qc;C[57]=tu;C[58]=eu;C[59]=nu;C[60]=Z;C[61]=Z;C[62]=Z;C[63]=Z;for(let e=64;e<=87;e++)C[e]=ou;C[88]=iu;C[89]=su;C[90]=au;C[91]=cu;C[92]=Z;C[93]=Z;C[94]=Z;C[95]=Wn("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)C[e]=uu;C[120]=fu;C[121]=lu;C[122]=du;C[123]=hu;C[124]=Z;C[125]=Z;C[126]=Z;C[127]=Wn("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)C[e]=mu;C[152]=yu;C[153]=gu;C[154]=bu;C[155]=xu;C[156]=Z;C[157]=Z;C[158]=Z;C[159]=wu;for(let e=160;e<=183;e++)C[e]=Eu;C[184]=Su;C[185]=vu;C[186]=Au;C[187]=Iu;C[188]=Z;C[189]=Z;C[190]=Z;C[191]=Tu;for(let e=192;e<=215;e++)C[e]=Bu;C[216]=Cu;C[217]=_u;C[218]=Lu;C[219]=Du;C[220]=Z;C[221]=Z;C[222]=Z;C[223]=Z;for(let e=224;e<=243;e++)C[e]=Wn("simple values are not supported");C[244]=Z;C[245]=Z;C[246]=Z;C[247]=Ru;C[248]=Wn("simple values are not supported");C[249]=Nu;C[250]=ku;C[251]=Ku;C[252]=Z;C[253]=Z;C[254]=Z;C[255]=Uu;var Ft=[];for(let e=0;e<24;e++)Ft[e]=new R(g.uint,e,1);for(let e=-1;e>=-24;e--)Ft[31-e]=new R(g.negint,e,1);Ft[64]=new R(g.bytes,new Uint8Array(0),1);Ft[96]=new R(g.string,"",1);Ft[128]=new R(g.array,0,1);Ft[160]=new R(g.map,0,1);Ft[244]=new R(g.false,!1,1);Ft[245]=new R(g.true,!0,1);Ft[246]=new R(g.null,null,1);function us(e){switch(e.type){case g.false:return Xt([244]);case g.true:return Xt([245]);case g.null:return Xt([246]);case g.bytes:return e.value.length?void 0:Xt([64]);case g.string:return e.value===""?Xt([96]):void 0;case g.array:return e.value===0?Xt([128]):void 0;case g.map:return e.value===0?Xt([160]):void 0;case g.uint:return e.value<24?Xt([Number(e.value)]):void 0;case g.negint:if(e.value>=-24)return Xt([31-Number(e.value)])}}var Dh={float64:!1,mapSorter:Nh,quickEncodeToken:us},qu=Object.freeze({float64:!0,mapSorter:kh,quickEncodeToken:us});function Rh(){let e=[];return e[g.uint.major]=Rt,e[g.negint.major]=zn,e[g.bytes.major]=ur,e[g.string.major]=pu,e[g.array.major]=Yn,e[g.map.major]=Gn,e[g.tag.major]=jn,e[g.float.major]=Xn,e}var ls=Rh(),fs=new Yr,Qn=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${os} object contains circular references`);return new e(r,t)}},Ee={null:new R(g.null,null),undefined:new R(g.undefined,void 0),true:new R(g.true,!0),false:new R(g.false,!1),emptyArray:new R(g.array,0),emptyMap:new R(g.map,0)},Se={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new R(g.float,e):e>=0?new R(g.uint,e):new R(g.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new R(g.uint,e):new R(g.negint,e)},Uint8Array(e,t,r,n){return new R(g.bytes,e)},string(e,t,r,n){return new R(g.string,e)},boolean(e,t,r,n){return e?Ee.true:Ee.false},null(e,t,r,n){return Ee.null},undefined(e,t,r,n){return Ee.undefined},ArrayBuffer(e,t,r,n){return new R(g.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new R(g.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[Ee.emptyArray,new R(g.break)]:Ee.emptyArray;n=Qn.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=Jn(s,r,n);return r.addBreakTokens?[new R(g.array,e.length),o,new R(g.break)]:[new R(g.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length;if(!s)return r.addBreakTokens===!0?[Ee.emptyMap,new R(g.break)]:Ee.emptyMap;n=Qn.createCheck(n,e);let a=[],c=0;for(let f of i)a[c++]=[Jn(f,r,n),Jn(o?e.get(f):e[f],r,n)];return Uh(a,r),r.addBreakTokens?[new R(g.map,s),a,new R(g.break)]:[new R(g.map,s),a]}};Se.Map=Se.Object;Se.Buffer=Se.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Se[`${e}Array`]=Se.DataView;function Jn(e,t={},r){let n=Fc(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Se[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=Se[n];if(!i)throw new Error(`${os} unsupported type: ${n}`);return i(e,n,t,r)}function Uh(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Nh(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=ls[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function kh(e,t){if(e[0]instanceof R&&t[0]instanceof R){let r=e[0],n=t[0];return r._keyBytes||(r._keyBytes=Fu(r.value)),n._keyBytes||(n._keyBytes=Fu(n.value)),$n(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function Fu(e){return $u(e,ls,qu)}function Hu(e,t,r,n){if(Array.isArray(t))for(let o of t)Hu(e,o,r,n);else r[t.type.major](e,t,n)}function $u(e,t,r){let n=Jn(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let s=i.encodedSize(n,r),a=new Yr(s);if(i(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return ns(a.chunks[0])}}return fs.reset(),Hu(fs,n,t,r),fs.toBytes(!0)}function ds(e,t){return t=Object.assign({},Dh,t),$u(e,ls,t)}var Kh={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},to=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=Ft[t];if(r===void 0){let n=C[t];if(!n)throw new Error(`${F} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},Wr=Symbol.for("DONE"),eo=Symbol.for("BREAK");function Ph(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=dr(t,r);if(i===eo){if(e.value===1/0)break;throw new Error(`${F} got unexpected break to lengthed array`)}if(i===Wr)throw new Error(`${F} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function Oh(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<e.value;s++){let a=dr(t,r);if(a===eo){if(e.value===1/0)break;throw new Error(`${F} got unexpected break to lengthed map`)}if(a===Wr)throw new Error(`${F} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${F} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${F} found repeat map key "${a}"`);let c=dr(t,r);if(c===Wr)throw new Error(`${F} found map but not enough entries (got ${s} [no value], expected ${e.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function dr(e,t){if(e.done())return Wr;let r=e.next();if(r.type===g.break)return eo;if(r.type.terminal)return r.value;if(r.type===g.array)return Ph(r,e,t);if(r.type===g.map)return Oh(r,e,t);if(r.type===g.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=dr(e,t);return t.tags[r.value](n)}throw new Error(`${F} tag not supported (${r.value})`)}throw new Error("unsupported")}function zu(e,t){if(!(e instanceof Uint8Array))throw new Error(`${F} data to decode must be a Uint8Array`);t=Object.assign({},Kh,t);let r=t.tokenizer||new to(e,t),n=dr(r,t);if(n===Wr)throw new Error(`${F} did not find any content to decode`);if(n===eo)throw new Error(`${F} got unexpected break`);return[n,e.subarray(r.pos())]}function hs(e,t){let[r,n]=zu(e,t);if(n.length>0)throw new Error(`${F} too many terminals, data makes no sense`);return r}var Vh=Oe("ipns:utils"),Zu=$("/ipns/"),Fh=114,qh=0,Hh=18;function Yu(e){let t;if(e.pubKey!=null)try{t=kc(e.pubKey)}catch(r){throw Vh.error(r),r}if(t!=null)return t}function Gu(e,t,r){let n=$(t);return le([e,r,n])}function no(e){let t=$("ipns-signature:");return le([t,e])}function Jr(e){return"signatureV1"in e?lt.encode({value:$(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:$(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):lt.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function Lt(e){let t=lt.decode(e);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new Mt("Missing data or signatureV2");let r=Wu(t.data),n=$h(r.Value),o=Y(r.Validity);if(t.value!=null&&t.signatureV1!=null)return zh(t),{value:n,validityType:lt.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:lt.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function ve(e){return le([Zu,e.bytes])}function ju(e){let t=Ye(e.slice(Zu.length));if(!ro(t,qh)&&!ro(t,Hh))throw new un("Multihash in IPNS key was not identity or sha2-256");return t}function Xu(e,t,r,n,o){let i;if(t===lt.ValidityType.EOL)i=0;else throw new Me("The validity type is unsupported");return ds({Value:e,Validity:r,ValidityType:i,Sequence:n,TTL:o})}function Wu(e){let t=hs(e);if(t.ValidityType===0)t.ValidityType=lt.ValidityType.EOL;else throw new Me("The validity type is unsupported");return Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),t}function $h(e){let t=Y(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${it.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${it.parse(t).toV1().toString()}`}catch{}throw new zr("Value must be a valid content path starting with /")}function Ju(e){if(e!=null){let t=Gh(e);if(t!=null)return t.code===Fh?`/ipns/${t.toString(Nt)}`:`/ipfs/${t.toV1().toString()}`;if(Zh(e))return`/ipns/${Nt.encode(e.bytes)}`;let r=e.toString().trim();if(r.startsWith("/")&&r.length>1)return r}throw new zr("Value must be a valid content path starting with /")}function zh(e){if(e.data==null)throw new qn("Record data is missing");let t=Wu(e.data);if(!rt(t.Value,e.value??new Uint8Array(0)))throw new Mt('Field "value" did not match between protobuf and CBOR');if(!rt(t.Validity,e.validity??new Uint8Array(0)))throw new Mt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Mt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Mt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Mt('Field "ttl" did not match between protobuf and CBOR')}function Zh(e){return e.bytes instanceof Uint8Array}function Yh(e){return typeof e?.toCID=="function"}function Gh(e){if(Yh(e))return e.toCID();try{return it.parse(e)}catch{}return it.asCID(e)}function ro(e,t){return e.code===t}var oo=Oe("ipns:validator"),jh=1024*10;async function Xh(e,t){let r=Lt(t),n;try{let o=no(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw oo.error("record signature verification failed"),new Mt("Record signature verification failed");if(r.validityType===lt.ValidityType.EOL){if(Qu.default.fromString(r.validity).toDate().getTime()<Date.now())throw oo.error("record has expired"),new Vn("record has expired")}else if(r.validityType!=null)throw oo.error("the validity type is unsupported"),new Me("The validity type is unsupported");oo("ipns record for %s is valid",r.value)}async function Qr(e,t){if(t.byteLength>jh)throw new Fn("The record is too large");let r=ju(e),n;ro(r,0)&&(n=Kc(r));let o=Lt(t),i=Yu(o)??n;if(i==null)throw new Zr("Could not extract public key from IPNS record or routing key");let s=ve(i.toMultihash());if(!rt(s,e))throw new Zr("Embedded public key did not match routing key");await Xh(i,t)}var tf=To(On(),1);var Wh=Oe("ipns"),ef=300*1e9,Jh="/ipns/",hx=Jh.length,rf={v1Compatible:!0,ttlNs:ef};async function io(e,t,r,n,o=rf){let i=new tf.default(Date.now()+Number(n)),s=lt.ValidityType.EOL,a=BigInt(o.ttlNs??ef);return Qh(e,t,r,s,i.toString(),a,o)}var Qh=async(e,t,r,n,o,i,s=rf)=>{r=BigInt(r);let a=$(o),c=Ju(t),f=$(c),u=Xu(f,n,a,r,i),l=no(u),b=await e.sign(l),S;if(e.type==="RSA"&&(S=de(e.publicKey)),s.v1Compatible===!0){let w=await t0(e,f,n,a),T={value:c,signatureV1:w,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:b,data:u};return S!=null&&(T.pubKey=S),T}else{let w={value:c,validity:o,validityType:n,sequence:r,ttl:i,signatureV2:b,data:u};return S!=null&&(w.pubKey=S),w}},t0=async(e,t,r,n)=>{try{let o=Gu(t,r,n);return await e.sign(o)}catch(o){throw Wh.error("record signature creation failed",o),new Mn("Record signature creation failed")}};var ps=To(On(),1);function so(e,t){let r=t.map((n,o)=>({record:Lt(n),index:o}));return r.sort((n,o)=>{let i=n.record.sequence,s=o.record.sequence;if(i>s)return-1;if(i<s)return 1;if(n.record.validityType===lt.ValidityType.EOL&&o.record.validityType===lt.ValidityType.EOL){let a=ps.default.fromString(n.record.validity).toDate(),c=ps.default.fromString(o.record.validity).toDate();if(a.getTime()>c.getTime())return-1;if(a.getTime()<c.getTime())return 1}return 0}),r[0].index}var hr=BigInt(6e4)*5000000n,nf=5;var ao=class extends Error{static name="RecordsFailedValidationError";constructor(t="Records failed validation"){super(t),this.name="RecordsFailedValidationError"}},co=class extends Error{static name="UnsupportedMultibasePrefixError";constructor(t="Unsupported multibase prefix"){super(t),this.name="UnsupportedMultibasePrefixError"}},uo=class extends Error{static name="UnsupportedMultihashCodecError";constructor(t="Unsupported multihash codec"){super(t),this.name="UnsupportedMultihashCodecError"}},fo=class extends Error{static name="InvalidValueError";constructor(t="Invalid value"){super(t),this.name="InvalidValueError"}};var tn=class extends Error{static name="RecordNotFoundError";name="RecordNotFoundError"};var ce="/",of=new TextEncoder().encode(ce),lo=of[0],pr=class e{_buf;constructor(t,r){if(typeof t=="string")this._buf=$(t);else if(t instanceof Uint8Array)this._buf=t;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==lo)throw new Error("Invalid key")}toString(t="utf8"){return Y(this._buf,t)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(t){return new e(t.join(ce))}static random(){return new e(Math.random().toString().substring(2))}static asKey(t){return t instanceof Uint8Array||typeof t=="string"?new e(t):typeof t.uint8Array=="function"?new e(t.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=of),this._buf[0]!==lo){let t=new Uint8Array(this._buf.byteLength+1);t.fill(lo,0,1),t.set(this._buf,1),this._buf=t}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===lo;)this._buf=this._buf.subarray(0,-1)}less(t){let r=this.list(),n=t.list();for(let o=0;o<r.length;o++){if(n.length<o+1)return!1;let i=r[o],s=n[o];if(i<s)return!0;if(i>s)return!1}return r.length<n.length}reverse(){return e.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let t=this.namespaces();return t[t.length-1]}list(){return this.toString().split(ce).slice(1)}type(){return e0(this.baseNamespace())}name(){return r0(this.baseNamespace())}instance(t){return new e(this.toString()+":"+t)}path(){let t=this.parent().toString();return t.endsWith(ce)||(t+=ce),t+=this.type(),new e(t)}parent(){let t=this.list();return t.length===1?new e(ce):new e(t.slice(0,-1).join(ce))}child(t){return this.toString()===ce?t:t.toString()===ce?this:new e(this.toString()+t.toString(),!1)}isAncestorOf(t){return t.toString()===this.toString()?!1:t.toString().startsWith(this.toString())}isDecendantOf(t){return t.toString()===this.toString()?!1:this.toString().startsWith(t.toString())}isTopLevel(){return this.list().length===1}concat(...t){return e.withNamespaces([...this.namespaces(),...n0(t.map(r=>r.namespaces()))])}};function e0(e){let t=e.split(":");return t.length<2?"":t.slice(0,-1).join(":")}function r0(e){let t=e.split(":");return t[t.length-1]}function n0(e){return[].concat(...e)}var i0=114,ms=0,ys=18;function gs(e,t){return e.code===t}var ho="/dht/record/",s0="/ipns/metadata/";function en(e){return new pr(ho+Y(e,"base32"),!1)}function po(e){return new pr(s0+Y(e,"base32"),!1)}function sf(e,t){let r=Date.now(),n=t.getTime()+1728e5,o=new Date(e.validity).getTime();return n-r<864e5||o-r<864e5}function a0(e){return e?.asCID===e}function af(e){if(!a0(e))return!1;if(e.code!==i0)throw new tt(`CID codec ${e.code} was not libp2p-key`);if(e.multihash.code!==ms&&e.multihash.code!==ys)throw new tt(`Multihash algorithm codec ${e.multihash.code} was not Identity or SHA256 hash`);return!0}var cf={[Nt.prefix]:Nt,[j.prefix]:j},mr=class{routers;localStore;log;constructor(t,r){this.log=t.logger.forComponent("helia:ipns"),this.localStore=r.localStore,this.routers=r.routers}async resolve(t,r={}){let n=Bs(t)||fn(t)?t.toMultihash():af(t)?t.multihash:t,o=ve(n),i=await this.#e(o,r);return{...await this.#t(i.value,r),record:i}}async#t(t,r={}){let n=t.split("/");try{let o=n[1];if(o==="ipns"){let i=n[2],s=i.substring(0,1),a;if(s==="1"||s==="Q")a=j.decode(`z${i}`);else if(cf[s]!=null)a=cf[s].decode(i);else throw new co(`Unsupported multibase prefix "${s}"`);let c;try{c=Ye(a)}catch{c=it.decode(a).multihash}if(!gs(c,ms)&&!gs(c,ys))throw new uo(`Unsupported multihash codec "${c.code}"`);let{cid:f}=await this.resolve(c,r),u=n.slice(3).join("/");return{cid:f,path:u===""?void 0:u}}else if(o==="ipfs"){let i=it.parse(n[2]),s=n.slice(3).join("/");return{cid:i,path:s===""?void 0:s}}}catch(o){this.log.error("error parsing ipfs path - %e",o)}throw this.log.error("invalid ipfs path %s",t),new fo("Invalid value")}async#e(t,r={}){let n=[];if(await this.localStore.has(t,r))if(this.log("record is present in the cache"),r.nocache!==!0)try{let{record:c,created:f}=await this.localStore.get(t,r);this.log("record retrieved from cache"),await Qr(t,c),this.log("record was valid");let u=Lt(c),l=Number((u.ttl??hr)/1000000n);if(f.getTime()+l>Date.now())return this.log("record TTL was valid"),u;if(r.offline===!0)return this.log("record TTL has been reached but we are resolving offline-only, returning record"),u;this.log("record TTL has been reached, searching routing for updates"),n.push(c)}catch(c){this.log("cached record was invalid - %e",c),await this.localStore.delete(t,r)}else this.log("ignoring local cache due to nocache=true option");if(r.offline===!0)throw new tn("Record was not present in the cache or has expired");this.log("did not have record locally");let i=0,s=[];if(await Promise.all(this.routers.map(async c=>{let f;try{f=await c.get(t,{...r,validate:!1})}catch(u){this.log.error("error finding IPNS record using router %s - %e",c.toString(),u),s.push(u);return}try{await Qr(t,f),n.push(f)}catch(u){i++,this.log.error("error validating IPNS record from router %s - %e",c.toString(),u)}})),n.length===0)throw i>0?new ao(`${i>1?`${i} records`:"Record"} found for routing key ${i>1?"were":"was"} invalid`):new tn("Could not find record for routing key");let a=n[so(t,n)];return await this.localStore.put(t,a,r),Lt(a)}};var vt=class extends Event{type;detail;constructor(t,r){super(t),this.type=t,this.detail=r}};var mo=class{routers;localStore;keychain;constructor(t,r){this.keychain=t.libp2p.services.keychain,this.localStore=r.localStore,this.routers=r.routers}async publish(t,r,n={}){try{let o=await this.#t(t),i=1n,s=ve(o.publicKey.toMultihash());if(await this.localStore.has(s,n)){let{record:l}=await this.localStore.get(s,n);i=Lt(l).sequence+1n}fn(r)&&(r=r.toCID());let a=n.ttl!=null?BigInt(n.ttl)*1000000n:hr,c=n.lifetime??1728e5,f=await io(o,r,i,c,{...n,ttlNs:a}),u=Jr(f);return n.offline===!0?await this.localStore.put(s,u,{...n,metadata:{keyName:t,lifetime:c}}):await Promise.all(this.routers.map(async l=>{await l.put(s,u,{...n,metadata:{keyName:t,lifetime:c}})})),{record:f,publicKey:o.publicKey}}catch(o){throw n.onProgress?.(new vt("ipns:publish:error",o)),o}}async#t(t){try{return await this.keychain.exportKey(t)}catch{let n=await Nc("Ed25519");return await this.keychain.importKey(t,n),n}}async unpublish(t,r){let{publicKey:n}=await this.keychain.exportKey(t),o=n.toMultihash(),i=ve(o);await this.localStore.delete(i,r)}};function yr(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var yo=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||(t-1&t)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},gr=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new yo(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let r=this.head;this.head=r.next=new yo(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var bs=class extends Error{type;code;constructor(t,r){super(t??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function uf(e={}){return u0(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},e)}function u0(e,t){t=t??{};let r=t.onEnd,n=new gr,o,i,s,a=yr(),c=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((E,x)=>{i=B=>{i=null,n.push(B);try{E(e(n))}catch(v){x(v)}return o}}):e(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=yr()})}},f=E=>i!=null?i(E):(n.push(E),o),u=E=>(n=new gr,i!=null?i({error:E}):(n.push({error:E}),o)),l=E=>{if(s)return o;if(t?.objectMode!==!0&&E?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return f({done:!1,value:E})},b=E=>s?o:(s=!0,E!=null?u(E):f({done:!0})),S=()=>(n=new gr,b(),{done:!0}),w=E=>(b(E),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:S,throw:w,push:l,end:b,get readableLength(){return n.size},onEmpty:async E=>{let x=E?.signal;if(x?.throwIfAborted(),n.isEmpty())return;let B,v;x!=null&&(B=new Promise((U,P)=>{v=()=>{P(new bs)},x.addEventListener("abort",v)}));try{await Promise.race([a.promise,B])}finally{v!=null&&x!=null&&x?.removeEventListener("abort",v)}}},r==null)return o;let T=o;return o={[Symbol.asyncIterator](){return this},next(){return T.next()},throw(E){return T.throw(E),r!=null&&(r(E),r=void 0),{done:!0}},return(){return T.return(),r!=null&&(r(),r=void 0),{done:!0}},push:l,end(E){return T.end(E),r!=null&&(r(E),r=void 0),o},get readableLength(){return T.readableLength},onEmpty:E=>T.onEmpty(E)},o}var xs=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},ws=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},ff=e=>globalThis.DOMException===void 0?new ws(e):new DOMException(e),lf=e=>{let t=e.reason===void 0?ff("This operation was aborted."):e.reason;return t instanceof Error?t:ff(t)};function Es(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,s,a,f=new Promise((u,l)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:S}=t;S.aborted&&l(lf(S)),a=()=>{l(lf(S))},S.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){e.then(u,l);return}let b=new xs;s=i.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(S){l(S)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?u():o instanceof Error?l(o):(b.message=o??`Promise timed out after ${r} milliseconds`,l(b))},r),(async()=>{try{u(await e)}catch(S){l(S)}})()}).finally(()=>{f.clear(),a&&t.signal&&t.signal.removeEventListener("abort",a)});return f.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},f}var f0=e=>{let t=e.addEventListener||e.on||e.addListener,r=e.removeEventListener||e.off||e.removeListener;if(!t||!r)throw new TypeError("Emitter is not compatible");return{addListener:t.bind(e),removeListener:r.bind(e)}};function l0(e,t,r){let n,o=new Promise((i,s)=>{if(r={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...r},!(r.count>=0&&(r.count===Number.POSITIVE_INFINITY||Number.isInteger(r.count))))throw new TypeError("The `count` option should be at least 0 or more");r.signal?.throwIfAborted();let a=[t].flat(),c=[],{addListener:f,removeListener:u}=f0(e),l=async(...S)=>{let w=r.multiArgs?S:S[0];if(r.filter)try{if(!await r.filter(w))return}catch(T){n(),s(T);return}c.push(w),r.count===c.length&&(n(),i(c))},b=(...S)=>{n(),s(r.rejectionMultiArgs?S:S[0])};n=()=>{for(let S of a)u(S,l);for(let S of r.rejectionEvents)a.includes(S)||u(S,b)};for(let S of a)f(S,l);for(let S of r.rejectionEvents)a.includes(S)||f(S,b);r.signal&&r.signal.addEventListener("abort",()=>{b(r.signal.reason)},{once:!0}),r.resolveImmediately&&i(c)});if(o.cancel=n,typeof r.timeout=="number"){let i=Es(o,{milliseconds:r.timeout});return i.cancel=()=>{n(),i.clear()},i}return o}function go(e,t,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=l0(e,t,r),o=n.then(i=>i[0]);return o.cancel=n.cancel,o}function rn(e,t){let r,n=function(){let o=function(){r=void 0,e()};clearTimeout(r),r=setTimeout(o,t)};return n.start=()=>{},n.stop=()=>{clearTimeout(r)},n}var bo=class extends Error{static name="QueueFullError";constructor(t="The queue was full"){super(t),this.name="QueueFullError"}};function d0(e){return e.reason}async function df(e,t,r){if(t==null)return e;let n=r?.translateError??d0;if(t.aborted)return e.catch(()=>{}),Promise.reject(n(t));let o;try{return await Promise.race([e,new Promise((i,s)=>{o=()=>{s(n(t))},t.addEventListener("abort",o)})])}finally{o!=null&&t.removeEventListener("abort",o)}}var xo=class{deferred;signal;constructor(t){this.signal=t,this.deferred=yr(),this.onAbort=this.onAbort.bind(this),this.signal?.addEventListener("abort",this.onAbort)}onAbort(){this.deferred.reject(this.signal?.reason??new Wt)}cleanup(){this.signal?.removeEventListener("abort",this.onAbort)}};function h0(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}var wo=class{id;fn;options;recipients;status;timeline;controller;constructor(t,r){this.id=h0(),this.status="queued",this.fn=t,this.options=r,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,this.controller.signal,this.onAbort=this.onAbort.bind(this)}abort(t){this.controller.abort(t)}onAbort(){this.recipients.reduce((r,n)=>r&&n.signal?.aborted===!0,!0)&&(this.controller.abort(new Wt),this.cleanup())}async join(t={}){let r=new xo(t.signal);return this.recipients.push(r),t.signal?.addEventListener("abort",this.onAbort),r.deferred.promise}async run(){this.status="running",this.timeline.started=Date.now();try{this.controller.signal.throwIfAborted();let t=await df(this.fn({...this.options??{},signal:this.controller.signal}),this.controller.signal);this.recipients.forEach(r=>{r.deferred.resolve(t)}),this.status="complete"}catch(t){this.recipients.forEach(r=>{r.deferred.reject(t)}),this.status="errored"}finally{this.timeline.finished=Date.now(),this.cleanup()}}cleanup(){this.recipients.forEach(t=>{t.cleanup(),t.signal?.removeEventListener("abort",this.onAbort)})}};var Eo=class extends ln{concurrency;maxSize;queue;pending;sort;paused;constructor(t={}){super(),this.concurrency=t.concurrency??Number.POSITIVE_INFINITY,this.maxSize=t.maxSize??Number.POSITIVE_INFINITY,this.pending=0,this.paused=!1,t.metricName!=null&&t.metrics?.registerMetricGroup(t.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})}),this.sort=t.sort,this.queue=[],this.emitEmpty=rn(this.emitEmpty.bind(this),1),this.emitIdle=rn(this.emitIdle.bind(this),1)}emitEmpty(){this.size===0&&this.safeDispatchEvent("empty")}emitIdle(){this.running===0&&this.safeDispatchEvent("idle")}pause(){this.paused=!0}resume(){this.paused&&(this.paused=!1,this.tryToStartAnother())}tryToStartAnother(){if(this.paused)return!1;if(this.size===0)return this.emitEmpty(),this.running===0&&this.emitIdle(),!1;if(this.pending<this.concurrency){let t;for(let r of this.queue)if(r.status==="queued"){t=r;break}return t==null?!1:(this.safeDispatchEvent("active"),this.pending++,t.run().finally(()=>{for(let r=0;r<this.queue.length;r++)if(this.queue[r]===t){this.queue.splice(r,1);break}this.pending--,this.tryToStartAnother(),this.safeDispatchEvent("next")}),!0)}return!1}enqueue(t){this.queue.push(t),this.sort!=null&&this.queue.sort(this.sort)}async add(t,r){if(r?.signal?.throwIfAborted(),this.size===this.maxSize)throw new bo;let n=new wo(t,r);return this.enqueue(n),this.safeDispatchEvent("add"),this.tryToStartAnother(),n.join(r).then(o=>(this.safeDispatchEvent("completed",{detail:o}),this.safeDispatchEvent("success",{detail:{job:n,result:o}}),o)).catch(o=>{if(n.status==="queued"){for(let i=0;i<this.queue.length;i++)if(this.queue[i]===n){this.queue.splice(i,1);break}}throw this.safeDispatchEvent("failure",{detail:{job:n,error:o}}),o})}clear(){this.queue.splice(0,this.queue.length)}abort(){this.queue.forEach(t=>{t.abort(new Wt)}),this.clear()}async onEmpty(t){this.size!==0&&await go(this,"empty",t)}async onSizeLessThan(t,r){this.size<t||await go(this,"next",{...r,filter:()=>this.size<t})}async onIdle(t){this.pending===0&&this.size===0||await go(this,"idle",t)}get size(){return this.queue.length}get queued(){return this.queue.length-this.pending}get running(){return this.pending}async*toGenerator(t){t?.signal?.throwIfAborted();let r=uf({objectMode:!0}),n=c=>{c!=null?this.abort():this.clear(),r.end(c)},o=c=>{c.detail!=null&&r.push(c.detail)},i=c=>{n(c.detail.error)},s=()=>{n()},a=()=>{n(new Wt("Queue aborted"))};this.addEventListener("completed",o),this.addEventListener("failure",i),this.addEventListener("idle",s),t?.signal?.addEventListener("abort",a);try{yield*r}finally{this.removeEventListener("completed",o),this.removeEventListener("failure",i),this.removeEventListener("idle",s),t?.signal?.removeEventListener("abort",a),n()}}};function hf(e){let t=new globalThis.AbortController;function r(){let i=e.filter(s=>s?.aborted===!0).map(s=>s?.reason).pop();t.abort(i);for(let s of e)s?.removeEventListener!=null&&s.removeEventListener("abort",r)}for(let i of e){if(i?.aborted===!0){r();break}i?.addEventListener!=null&&i.addEventListener("abort",r)}function n(){for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}let o=t.signal;return o.clear=n,o}function pf(e,t,r){let n,o,i=!1;function s(){let f={signal:o.signal};if(r?.timeout!=null){let u=hf([o.signal,AbortSignal.timeout(r.timeout)]);f.signal=u}i=!0,Promise.resolve().then(async()=>{await e(f)}).catch(()=>{}).finally(()=>{i=!1,!o.signal.aborted&&(n=setTimeout(s,t))})}let a=rn(s,r?.debounce??100),c=!1;return{setInterval:f=>{t!==f&&(t=f,n!=null&&(clearTimeout(n),n=setTimeout(s,t)))},setTimeout:f=>{r??={},r.timeout=f},run:()=>{i||(clearTimeout(n),a())},start:()=>{c||(c=!0,o=new AbortController,o.signal,r?.runImmediately===!0?queueMicrotask(()=>{s()}):n=setTimeout(s,t))},stop:()=>{clearTimeout(n),o?.abort(),c=!1}}}var So=class{routers;localStore;republishTask;log;keychain;started=!1;republishConcurrency;constructor(t,r){this.log=t.logger.forComponent("helia:ipns"),this.localStore=r.localStore,this.keychain=t.libp2p.services.keychain,this.republishConcurrency=r.republishConcurrency||nf,this.started=t.libp2p.status==="started",this.routers=r.routers??[],this.republishTask=pf(this.#t.bind(this),r.republishInterval??36e5,{runImmediately:!0}),this.started&&this.republishTask.start()}start(){this.started||(this.started=!0,this.republishTask.start())}stop(){this.started&&(this.started=!1,this.republishTask.stop())}async#t(t={}){if(!this.started)return;this.log("starting ipns republish records loop");let r=new Eo({concurrency:this.republishConcurrency});try{let n=[];for await(let{routingKey:o,record:i,metadata:s,created:a}of this.localStore.list(t)){if(s==null){this.log(`no metadata found for record ${o.toString()}, skipping`);continue}let c;try{c=Lt(i)}catch(b){this.log.error("error unmarshaling record - %e",b);continue}if(!sf(c,a)){this.log.trace(`skipping record ${o.toString()}within republish threshold`);continue}let f=c.sequence+1n,u=c.ttl??hr,l;try{l=await this.keychain.exportKey(s.keyName)}catch(b){this.log.error("missing key %s, skipping republishing record - %e",s.keyName,b);continue}try{let b=await io(l,c.value,f,s.lifetime,{...t,ttlNs:u});n.push({routingKey:o,record:b})}catch(b){this.log.error("error creating updated IPNS record for %s - %e",o,b);continue}}this.log(`found ${n.length} records to republish`);for(let{routingKey:o,record:i}of n)r.add(async()=>{try{let s=Jr(i);await Promise.all(this.routers.map(a=>a.put(o,s,t)))}catch(s){this.log.error("error republishing record - %e",s)}},t)}catch(n){this.log.error("error during republish - %e",n)}await r.onIdle(t)}};var nn;(function(e){let t;e.codec=()=>(t==null&&(t=Gt((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.key!=null&&r.key.byteLength>0&&(n.uint32(10),n.bytes(r.key)),r.value!=null&&r.value.byteLength>0&&(n.uint32(18),n.bytes(r.value)),r.timeReceived!=null&&r.timeReceived!==""&&(n.uint32(42),n.string(r.timeReceived)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={key:Dt(0),value:Dt(0),timeReceived:""},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.key=r.bytes();break}case 2:{i.value=r.bytes();break}case 5:{i.timeReceived=r.string();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>Yt(r,e.codec()),e.decode=(r,n)=>Zt(r,e.codec(),n)})(nn||(nn={}));function mf(e){let t=e.getUTCFullYear(),r=String(e.getUTCMonth()+1).padStart(2,"0"),n=String(e.getUTCDate()).padStart(2,"0"),o=String(e.getUTCHours()).padStart(2,"0"),i=String(e.getUTCMinutes()).padStart(2,"0"),s=String(e.getUTCSeconds()).padStart(2,"0"),a=e.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${t}-${r}-${n}T${o}:${i}:${s}.${c}Z`}function yf(e){let t=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),r=String(e).trim().match(t);if(r==null)throw new Error("Invalid format");let n=parseInt(r[1],10),o=parseInt(r[2],10)-1,i=parseInt(r[3],10),s=parseInt(r[4],10),a=parseInt(r[5],10),c=parseInt(r[6],10),f=parseInt(r[7].slice(0,-6),10);return new Date(Date.UTC(n,o,i,s,a,c,f))}var Ae=class e{key;value;timeReceived;constructor(t,r,n){if(!(t instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(r instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=t,this.value=r,this.timeReceived=n}serialize(){return nn.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:mf(this.timeReceived)}}static deserialize(t){let r=nn.decode(t);return new e(r.key,r.value,new Date(r.timeReceived))}static fromDeserialized(t){let r=yf(t.timeReceived);if(t.key==null)throw new Error("key missing from deserialized object");if(t.value==null)throw new Error("value missing from deserialized object");return new e(t.key,t.value,r)}};var gf;(function(e){e[e.SEND_QUERY=0]="SEND_QUERY",e[e.PEER_RESPONSE=1]="PEER_RESPONSE",e[e.FINAL_PEER=2]="FINAL_PEER",e[e.QUERY_ERROR=3]="QUERY_ERROR",e[e.PROVIDER=4]="PROVIDER",e[e.VALUE=5]="VALUE",e[e.ADD_PEER=6]="ADD_PEER",e[e.DIAL_PEER=7]="DIAL_PEER",e[e.PATH_ENDED=8]="PATH_ENDED"})(gf||(gf={}));var on;(function(e){let t;e.codec=()=>(t==null&&(t=Gt((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.keyName!=null&&r.keyName!==""&&(n.uint32(10),n.string(r.keyName)),r.lifetime!=null&&r.lifetime!==0&&(n.uint32(16),n.uint32(r.lifetime)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={keyName:"",lifetime:0},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.keyName=r.string();break}case 2:{i.lifetime=r.uint32();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>Yt(r,e.codec()),e.decode=(r,n)=>Zt(r,e.codec(),n)})(on||(on={}));function vo(e,t){return{async put(r,n,o={}){try{let i=en(r);try{let c=await e.get(i),f=Ae.deserialize(c);if(rt(f.value,n))return}catch(c){if(c.name!=="NotFoundError")throw c}let s=new Ae(r,n,new Date);o.onProgress?.(new vt("ipns:routing:datastore:put"));let a=e.batch();a.put(i,s.serialize()),o.metadata!=null&&a.put(po(r),on.encode(o.metadata)),await a.commit(o)}catch(i){throw o.onProgress?.(new vt("ipns:routing:datastore:error",i)),i}},async get(r,n={}){try{let o=en(r);n.onProgress?.(new vt("ipns:routing:datastore:get"));let i=await e.get(o,n),s=Ae.deserialize(i);return{record:s.value,created:s.timeReceived}}catch(o){throw n.onProgress?.(new vt("ipns:routing:datastore:error",o)),o}},async has(r,n={}){let o=en(r);return e.has(o,n)},async delete(r,n){let o=en(r),i=e.batch();i.delete(o),i.delete(po(r)),await i.commit(n)},async*list(r={}){try{r.onProgress?.(new vt("ipns:routing:datastore:list"));for await(let{key:n,value:o}of e.query({prefix:ho},r))try{let i=Ae.deserialize(o),a=n.toString().substring(ho.length),c=$(a,"base32"),f=po(c),u;try{let l=await e.get(f,r);u=on.decode(l)}catch(l){t.error("Error deserializing metadata for %s - %e",a,l)}yield{routingKey:c,metadata:u,record:i.value,created:i.timeReceived}}catch(i){t.error("Error deserializing record - %e",i)}}catch(n){throw r.onProgress?.(new vt("ipns:routing:datastore:error",n)),n}}}}var Ss=class{routing;constructor(t){this.routing=t}async put(t,r,n={}){try{await this.routing.put(t,r,n)}catch(o){throw n.onProgress?.(new vt("ipns:routing:helia:error",o)),o}}async get(t,r={}){try{return await this.routing.get(t,r)}catch(n){throw r.onProgress?.(new vt("ipns:routing:helia:error",n)),n}}toString(){return"HeliaRouting()"}};function sn(e){return new Ss(e)}var vs=class{localStore;constructor(t){this.localStore=t}async put(t,r,n){await this.localStore.put(t,r,n)}async get(t,r){let{record:n}=await this.localStore.get(t,r);return n}toString(){return"LocalStoreRouting()"}};function Ao(e){return new vs(e)}var Io=class{routers;publisher;republisher;resolver;localStore;started;constructor(t,r={}){this.localStore=vo(t.datastore,t.logger.forComponent("helia:ipns:local-store")),this.started=t.libp2p.status==="started",this.routers=[Ao(this.localStore),sn(t.routing),...r.routers??[]],this.publisher=new mo(t,{...r,routers:this.routers,localStore:this.localStore}),this.republisher=new So(t,{...r,routers:this.routers,localStore:this.localStore}),this.resolver=new mr(t,{...r,routers:this.routers,localStore:this.localStore}),t.events.addEventListener("start",this.start.bind(this)),t.events.addEventListener("stop",this.stop.bind(this)),this.started&&this.republisher.start()}start(){this.started||(this.started=!0,this.republisher.start())}stop(){this.started&&(this.started=!1,this.republisher.stop())}async publish(t,r,n={}){return this.publisher.publish(t,r,n)}async resolve(t,r={}){return this.resolver.resolve(t,r)}async unpublish(t,r){return this.publisher.unpublish(t,r)}};function y0(e,t={}){return new Io(e,t)}function g0(e,t={}){let r=vo(e.datastore,e.logger.forComponent("helia:ipns:local-store")),n=[Ao(r),sn(e.routing),...t.routers??[]];return new mr(e,{routers:n,localStore:r})}return Af(b0);})();
|
|
14
14
|
/*! Bundled license information:
|
|
15
15
|
|
|
16
16
|
@noble/hashes/utils.js:
|