Message Statistics
0 Sent by Me
0 Received (Mine)
0 Received (Others)
diff --git a/dogfooding/index.html b/dogfooding/index.html index 8599298..4b47ead 100644 --- a/dogfooding/index.html +++ b/dogfooding/index.html @@ -1 +1 @@ -
>2]|=(192|n>>6)<
>2]|=(128|63&n)<
=57344?(i[r>>2]|=(224|n>>12)<
>2]|=(128|n>>6&63)<
>2]|=(128|63&n)<
>2]|=(240|n>>18)<
>2]|=(128|n>>12&63)<
>2]|=(128|n>>6&63)<
>2]|=(128|63&n)<
>2]|=e[l]<
=o){for(this.start=r-o,this.block=i[c],r=0;r191&&t<=223?(r=31&t,o=1):t<=239?(r=15&t,o=2):t<=247?(r=7&t,o=3):l(i,n);for(var a=0;a>>0,o[d]=u%256>>>0,u=u/256>>>0;if(0!==u)throw new Error("Non-zero carry");s=h,t++}if(" "!==e[t]){for(var p=i-s;p!==i&&0===o[p];)p++;for(var f=new Uint8Array(n+(i-p)),g=n;p!==i;)f[g++]=o[p++];return f}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,s=0,i=t.length;s!==i&&0===t[s];)s++,r++;for(var o=(i-s)*u+1>>>0,l=new Uint8Array(o);s!==i;){for(var h=t[s],d=0,p=o-1;(0!==h||d>>3){case 1:n.proof=e.bytes();break;case 2:n.merkleRoot=e.bytes();break;case 3:n.epoch=e.bytes();break;case 4:n.shareX=e.bytes();break;case 5:n.shareY=e.bytes();break;case 6:n.nullifier=e.bytes();break;case 7:n.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(jt||(jt={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),null!=e.meta&&(t.uint32(90),t.bytes(e.meta)),null!=e.rateLimitProof&&(t.uint32(170),jt.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={payload:f(0),contentTopic:""},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.payload=e.bytes();break;case 2:n.contentTopic=e.string();break;case 3:n.version=e.uint32();break;case 10:n.timestamp=e.sint64();break;case 11:n.meta=e.bytes();break;case 21:n.rateLimitProof=jt.codec().decode(e,e.uint32(),{limits:r.limits?.rateLimitProof});break;case 31:n.ephemeral=e.bool();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(zt||(zt={})),function(e){let t,r;!function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(10),t.string(e.contentTopic)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={contentTopic:""},s=null==t?e.len:e.pos+t;for(;e.pos>>3==1?n.contentTopic=e.string():e.skipType(7&t)}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(t=e.ContentFilter||(e.ContentFilter={})),e.codec=()=>(null==r&&(r=Er(((t,r,n={})=>{if(!1!==n.lengthDelimited&&r.fork(),null!=t.subscribe&&!1!==t.subscribe&&(r.uint32(8),r.bool(t.subscribe)),null!=t.topic&&""!==t.topic&&(r.uint32(18),r.string(t.topic)),null!=t.contentFilters)for(const n of t.contentFilters)r.uint32(26),e.ContentFilter.codec().encode(n,r);!1!==n.lengthDelimited&&r.ldelim()}),((t,r,n={})=>{const s={subscribe:!1,topic:"",contentFilters:[]},i=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:s.subscribe=t.bool();break;case 2:s.topic=t.string();break;case 3:if(null!=n.limits?.contentFilters&&s.contentFilters.length===n.limits.contentFilters)throw new Sr('Decode error - map field "contentFilters" had too many elements');s.contentFilters.push(e.ContentFilter.codec().decode(t,t.uint32(),{limits:n.limits?.contentFilters$}));break;default:t.skipType(7&r)}}return s}))),r),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(Ht||(Ht={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{if(!1!==r.lengthDelimited&&t.fork(),null!=e.messages)for(const r of e.messages)t.uint32(10),Wt.codec().encode(r,t);!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={messages:[]},s=null==t?e.len:e.pos+t;for(;e.pos>>3==1){if(null!=r.limits?.messages&&n.messages.length===r.limits.messages)throw new Sr('Decode error - map field "messages" had too many elements');n.messages.push(Wt.codec().decode(e,e.uint32(),{limits:r.limits?.messages$}))}else e.skipType(7&t)}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(Kt||(Kt={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.requestId&&""!==e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.request&&(t.uint32(18),Ht.codec().encode(e.request,t)),null!=e.push&&(t.uint32(26),Kt.codec().encode(e.push,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={requestId:""},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.requestId=e.string();break;case 2:n.request=Ht.codec().decode(e,e.uint32(),{limits:r.limits?.request});break;case 3:n.push=Kt.codec().decode(e,e.uint32(),{limits:r.limits?.push});break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(Vt||(Vt={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.proof&&e.proof.byteLength>0&&(t.uint32(10),t.bytes(e.proof)),null!=e.merkleRoot&&e.merkleRoot.byteLength>0&&(t.uint32(18),t.bytes(e.merkleRoot)),null!=e.epoch&&e.epoch.byteLength>0&&(t.uint32(26),t.bytes(e.epoch)),null!=e.shareX&&e.shareX.byteLength>0&&(t.uint32(34),t.bytes(e.shareX)),null!=e.shareY&&e.shareY.byteLength>0&&(t.uint32(42),t.bytes(e.shareY)),null!=e.nullifier&&e.nullifier.byteLength>0&&(t.uint32(50),t.bytes(e.nullifier)),null!=e.rlnIdentifier&&e.rlnIdentifier.byteLength>0&&(t.uint32(58),t.bytes(e.rlnIdentifier)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={proof:f(0),merkleRoot:f(0),epoch:f(0),shareX:f(0),shareY:f(0),nullifier:f(0),rlnIdentifier:f(0)},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.proof=e.bytes();break;case 2:n.merkleRoot=e.bytes();break;case 3:n.epoch=e.bytes();break;case 4:n.shareX=e.bytes();break;case 5:n.shareY=e.bytes();break;case 6:n.nullifier=e.bytes();break;case 7:n.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(Gt||(Gt={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),null!=e.meta&&(t.uint32(90),t.bytes(e.meta)),null!=e.rateLimitProof&&(t.uint32(170),Gt.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={payload:f(0),contentTopic:""},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.payload=e.bytes();break;case 2:n.contentTopic=e.string();break;case 3:n.version=e.uint32();break;case 10:n.timestamp=e.sint64();break;case 11:n.meta=e.bytes();break;case 21:n.rateLimitProof=Gt.codec().decode(e,e.uint32(),{limits:r.limits?.rateLimitProof});break;case 31:n.ephemeral=e.bool();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(Wt||(Wt={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={contentTopic:""},s=null==t?e.len:e.pos+t;for(;e.pos>>3==2?n.contentTopic=e.string():e.skipType(7&t)}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(Xt||(Xt={})),function(e){let t,r,n;!function(e){e.SUBSCRIBER_PING="SUBSCRIBER_PING",e.SUBSCRIBE="SUBSCRIBE",e.UNSUBSCRIBE="UNSUBSCRIBE",e.UNSUBSCRIBE_ALL="UNSUBSCRIBE_ALL"}(t=e.FilterSubscribeType||(e.FilterSubscribeType={})),function(e){e[e.SUBSCRIBER_PING=0]="SUBSCRIBER_PING",e[e.SUBSCRIBE=1]="SUBSCRIBE",e[e.UNSUBSCRIBE=2]="UNSUBSCRIBE",e[e.UNSUBSCRIBE_ALL=3]="UNSUBSCRIBE_ALL"}(r||(r={})),function(e){e.codec=()=>vr(r)}(t=e.FilterSubscribeType||(e.FilterSubscribeType={})),e.codec=()=>(null==n&&(n=Er(((t,n,s={})=>{if(!1!==s.lengthDelimited&&n.fork(),null!=t.requestId&&""!==t.requestId&&(n.uint32(10),n.string(t.requestId)),null!=t.filterSubscribeType&&0!==r[t.filterSubscribeType]&&(n.uint32(16),e.FilterSubscribeType.codec().encode(t.filterSubscribeType,n)),null!=t.pubsubTopic&&(n.uint32(82),n.string(t.pubsubTopic)),null!=t.contentTopics)for(const e of t.contentTopics)n.uint32(90),n.string(e);!1!==s.lengthDelimited&&n.ldelim()}),((r,n,s={})=>{const i={requestId:"",filterSubscribeType:t.SUBSCRIBER_PING,contentTopics:[]},o=null==n?r.len:r.pos+n;for(;r.pos>>3){case 1:n.requestId=e.string();break;case 10:n.statusCode=e.uint32();break;case 11:n.statusDesc=e.string();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(Qt||(Qt={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.wakuMessage&&(t.uint32(10),er.codec().encode(e.wakuMessage,t)),null!=e.pubsubTopic&&(t.uint32(18),t.string(e.pubsubTopic)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.wakuMessage=er.codec().decode(e,e.uint32(),{limits:r.limits?.wakuMessage});break;case 2:n.pubsubTopic=e.string();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(Zt||(Zt={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.proof&&e.proof.byteLength>0&&(t.uint32(10),t.bytes(e.proof)),null!=e.merkleRoot&&e.merkleRoot.byteLength>0&&(t.uint32(18),t.bytes(e.merkleRoot)),null!=e.epoch&&e.epoch.byteLength>0&&(t.uint32(26),t.bytes(e.epoch)),null!=e.shareX&&e.shareX.byteLength>0&&(t.uint32(34),t.bytes(e.shareX)),null!=e.shareY&&e.shareY.byteLength>0&&(t.uint32(42),t.bytes(e.shareY)),null!=e.nullifier&&e.nullifier.byteLength>0&&(t.uint32(50),t.bytes(e.nullifier)),null!=e.rlnIdentifier&&e.rlnIdentifier.byteLength>0&&(t.uint32(58),t.bytes(e.rlnIdentifier)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={proof:f(0),merkleRoot:f(0),epoch:f(0),shareX:f(0),shareY:f(0),nullifier:f(0),rlnIdentifier:f(0)},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.proof=e.bytes();break;case 2:n.merkleRoot=e.bytes();break;case 3:n.epoch=e.bytes();break;case 4:n.shareX=e.bytes();break;case 5:n.shareY=e.bytes();break;case 6:n.nullifier=e.bytes();break;case 7:n.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(Yt||(Yt={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),null!=e.meta&&(t.uint32(90),t.bytes(e.meta)),null!=e.rateLimitProof&&(t.uint32(170),Yt.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={payload:f(0),contentTopic:""},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.payload=e.bytes();break;case 2:n.contentTopic=e.string();break;case 3:n.version=e.uint32();break;case 10:n.timestamp=e.sint64();break;case 11:n.meta=e.bytes();break;case 21:n.rateLimitProof=Yt.codec().decode(e,e.uint32(),{limits:r.limits?.rateLimitProof});break;case 31:n.ephemeral=e.bool();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(er||(er={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.pubsubTopic&&""!==e.pubsubTopic&&(t.uint32(10),t.string(e.pubsubTopic)),null!=e.message&&(t.uint32(18),ir.codec().encode(e.message,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={pubsubTopic:""},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.pubsubTopic=e.string();break;case 2:n.message=ir.codec().decode(e,e.uint32(),{limits:r.limits?.message});break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(tr||(tr={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.isSuccess&&!1!==e.isSuccess&&(t.uint32(8),t.bool(e.isSuccess)),null!=e.info&&(t.uint32(18),t.string(e.info)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={isSuccess:!1},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.isSuccess=e.bool();break;case 2:n.info=e.string();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(rr||(rr={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.requestId&&""!==e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.request&&(t.uint32(18),tr.codec().encode(e.request,t)),null!=e.response&&(t.uint32(26),rr.codec().encode(e.response,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={requestId:""},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.requestId=e.string();break;case 2:n.request=tr.codec().decode(e,e.uint32(),{limits:r.limits?.request});break;case 3:n.response=rr.codec().decode(e,e.uint32(),{limits:r.limits?.response});break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(nr||(nr={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.proof&&e.proof.byteLength>0&&(t.uint32(10),t.bytes(e.proof)),null!=e.merkleRoot&&e.merkleRoot.byteLength>0&&(t.uint32(18),t.bytes(e.merkleRoot)),null!=e.epoch&&e.epoch.byteLength>0&&(t.uint32(26),t.bytes(e.epoch)),null!=e.shareX&&e.shareX.byteLength>0&&(t.uint32(34),t.bytes(e.shareX)),null!=e.shareY&&e.shareY.byteLength>0&&(t.uint32(42),t.bytes(e.shareY)),null!=e.nullifier&&e.nullifier.byteLength>0&&(t.uint32(50),t.bytes(e.nullifier)),null!=e.rlnIdentifier&&e.rlnIdentifier.byteLength>0&&(t.uint32(58),t.bytes(e.rlnIdentifier)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={proof:f(0),merkleRoot:f(0),epoch:f(0),shareX:f(0),shareY:f(0),nullifier:f(0),rlnIdentifier:f(0)},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.proof=e.bytes();break;case 2:n.merkleRoot=e.bytes();break;case 3:n.epoch=e.bytes();break;case 4:n.shareX=e.bytes();break;case 5:n.shareY=e.bytes();break;case 6:n.nullifier=e.bytes();break;case 7:n.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(sr||(sr={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),null!=e.meta&&(t.uint32(90),t.bytes(e.meta)),null!=e.rateLimitProof&&(t.uint32(170),sr.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={payload:f(0),contentTopic:""},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.payload=e.bytes();break;case 2:n.contentTopic=e.string();break;case 3:n.version=e.uint32();break;case 10:n.timestamp=e.sint64();break;case 11:n.meta=e.bytes();break;case 21:n.rateLimitProof=sr.codec().decode(e,e.uint32(),{limits:r.limits?.rateLimitProof});break;case 31:n.ephemeral=e.bool();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(ir||(ir={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.messageHash&&(t.uint32(10),t.bytes(e.messageHash)),null!=e.message&&(t.uint32(18),ur.codec().encode(e.message,t)),null!=e.pubsubTopic&&(t.uint32(26),t.string(e.pubsubTopic)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.messageHash=e.bytes();break;case 2:n.message=ur.codec().decode(e,e.uint32(),{limits:r.limits?.message});break;case 3:n.pubsubTopic=e.string();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(or||(or={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{if(!1!==r.lengthDelimited&&t.fork(),null!=e.requestId&&""!==e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.includeData&&!1!==e.includeData&&(t.uint32(16),t.bool(e.includeData)),null!=e.pubsubTopic&&(t.uint32(82),t.string(e.pubsubTopic)),null!=e.contentTopics)for(const r of e.contentTopics)t.uint32(90),t.string(r);if(null!=e.timeStart&&(t.uint32(96),t.sint64(e.timeStart)),null!=e.timeEnd&&(t.uint32(104),t.sint64(e.timeEnd)),null!=e.messageHashes)for(const r of e.messageHashes)t.uint32(162),t.bytes(r);null!=e.paginationCursor&&(t.uint32(410),t.bytes(e.paginationCursor)),null!=e.paginationForward&&!1!==e.paginationForward&&(t.uint32(416),t.bool(e.paginationForward)),null!=e.paginationLimit&&(t.uint32(424),t.uint64(e.paginationLimit)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={requestId:"",includeData:!1,contentTopics:[],messageHashes:[],paginationForward:!1},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.requestId=e.string();break;case 2:n.includeData=e.bool();break;case 10:n.pubsubTopic=e.string();break;case 11:if(null!=r.limits?.contentTopics&&n.contentTopics.length===r.limits.contentTopics)throw new Sr('Decode error - map field "contentTopics" had too many elements');n.contentTopics.push(e.string());break;case 12:n.timeStart=e.sint64();break;case 13:n.timeEnd=e.sint64();break;case 20:if(null!=r.limits?.messageHashes&&n.messageHashes.length===r.limits.messageHashes)throw new Sr('Decode error - map field "messageHashes" had too many elements');n.messageHashes.push(e.bytes());break;case 51:n.paginationCursor=e.bytes();break;case 52:n.paginationForward=e.bool();break;case 53:n.paginationLimit=e.uint64();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(ar||(ar={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{if(!1!==r.lengthDelimited&&t.fork(),null!=e.requestId&&""!==e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.statusCode&&(t.uint32(80),t.uint32(e.statusCode)),null!=e.statusDesc&&(t.uint32(90),t.string(e.statusDesc)),null!=e.messages)for(const r of e.messages)t.uint32(162),or.codec().encode(r,t);null!=e.paginationCursor&&(t.uint32(410),t.bytes(e.paginationCursor)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={requestId:"",messages:[]},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.requestId=e.string();break;case 10:n.statusCode=e.uint32();break;case 11:n.statusDesc=e.string();break;case 20:if(null!=r.limits?.messages&&n.messages.length===r.limits.messages)throw new Sr('Decode error - map field "messages" had too many elements');n.messages.push(or.codec().decode(e,e.uint32(),{limits:r.limits?.messages$}));break;case 51:n.paginationCursor=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(cr||(cr={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.proof&&e.proof.byteLength>0&&(t.uint32(10),t.bytes(e.proof)),null!=e.merkleRoot&&e.merkleRoot.byteLength>0&&(t.uint32(18),t.bytes(e.merkleRoot)),null!=e.epoch&&e.epoch.byteLength>0&&(t.uint32(26),t.bytes(e.epoch)),null!=e.shareX&&e.shareX.byteLength>0&&(t.uint32(34),t.bytes(e.shareX)),null!=e.shareY&&e.shareY.byteLength>0&&(t.uint32(42),t.bytes(e.shareY)),null!=e.nullifier&&e.nullifier.byteLength>0&&(t.uint32(50),t.bytes(e.nullifier)),null!=e.rlnIdentifier&&e.rlnIdentifier.byteLength>0&&(t.uint32(58),t.bytes(e.rlnIdentifier)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={proof:f(0),merkleRoot:f(0),epoch:f(0),shareX:f(0),shareY:f(0),nullifier:f(0),rlnIdentifier:f(0)},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.proof=e.bytes();break;case 2:n.merkleRoot=e.bytes();break;case 3:n.epoch=e.bytes();break;case 4:n.shareX=e.bytes();break;case 5:n.shareY=e.bytes();break;case 6:n.nullifier=e.bytes();break;case 7:n.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(lr||(lr={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),null!=e.meta&&(t.uint32(90),t.bytes(e.meta)),null!=e.rateLimitProof&&(t.uint32(170),lr.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={payload:f(0),contentTopic:""},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.payload=e.bytes();break;case 2:n.contentTopic=e.string();break;case 3:n.version=e.uint32();break;case 10:n.timestamp=e.sint64();break;case 11:n.meta=e.bytes();break;case 21:n.rateLimitProof=lr.codec().decode(e,e.uint32(),{limits:r.limits?.rateLimitProof});break;case 31:n.ephemeral=e.bool();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(ur||(ur={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.enr&&(t.uint32(10),t.bytes(e.enr)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={},s=null==t?e.len:e.pos+t;for(;e.pos>>3==1?n.enr=e.bytes():e.skipType(7&t)}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(hr||(hr={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.numPeers&&(t.uint32(8),t.uint64(e.numPeers)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={},s=null==t?e.len:e.pos+t;for(;e.pos>>3==1?n.numPeers=e.uint64():e.skipType(7&t)}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(dr||(dr={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{if(!1!==r.lengthDelimited&&t.fork(),null!=e.peerInfos)for(const r of e.peerInfos)t.uint32(10),hr.codec().encode(r,t);!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={peerInfos:[]},s=null==t?e.len:e.pos+t;for(;e.pos>>3==1){if(null!=r.limits?.peerInfos&&n.peerInfos.length===r.limits.peerInfos)throw new Sr('Decode error - map field "peerInfos" had too many elements');n.peerInfos.push(hr.codec().decode(e,e.uint32(),{limits:r.limits?.peerInfos$}))}else e.skipType(7&t)}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(pr||(pr={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.query&&(t.uint32(10),dr.codec().encode(e.query,t)),null!=e.response&&(t.uint32(18),pr.codec().encode(e.response,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.query=dr.codec().decode(e,e.uint32(),{limits:r.limits?.query});break;case 2:n.response=pr.codec().decode(e,e.uint32(),{limits:r.limits?.response});break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(fr||(fr={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{if(!1!==r.lengthDelimited&&t.fork(),null!=e.clusterId&&(t.uint32(8),t.uint32(e.clusterId)),null!=e.shards)for(const r of e.shards)t.uint32(16),t.uint32(r);!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={shards:[]},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.clusterId=e.uint32();break;case 2:if(null!=r.limits?.shards&&n.shards.length===r.limits.shards)throw new Sr('Decode error - map field "shards" had too many elements');n.shards.push(e.uint32());break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(gr||(gr={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{if(!1!==r.lengthDelimited&&t.fork(),null!=e.clusterId&&(t.uint32(8),t.uint32(e.clusterId)),null!=e.shards)for(const r of e.shards)t.uint32(16),t.uint32(r);!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={shards:[]},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.clusterId=e.uint32();break;case 2:if(null!=r.limits?.shards&&n.shards.length===r.limits.shards)throw new Sr('Decode error - map field "shards" had too many elements');n.shards.push(e.uint32());break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(mr||(mr={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.messageId&&""!==e.messageId&&(t.uint32(10),t.string(e.messageId)),null!=e.retrievalHint&&(t.uint32(18),t.bytes(e.retrievalHint)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={messageId:""},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.messageId=e.string();break;case 2:n.retrievalHint=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(yr||(yr={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{if(!1!==r.lengthDelimited&&t.fork(),null!=e.messageId&&""!==e.messageId&&(t.uint32(18),t.string(e.messageId)),null!=e.channelId&&""!==e.channelId&&(t.uint32(26),t.string(e.channelId)),null!=e.lamportTimestamp&&(t.uint32(80),t.int32(e.lamportTimestamp)),null!=e.causalHistory)for(const r of e.causalHistory)t.uint32(90),yr.codec().encode(r,t);null!=e.bloomFilter&&(t.uint32(98),t.bytes(e.bloomFilter)),null!=e.content&&(t.uint32(162),t.bytes(e.content)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={messageId:"",channelId:"",causalHistory:[]},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 2:n.messageId=e.string();break;case 3:n.channelId=e.string();break;case 10:n.lamportTimestamp=e.int32();break;case 11:if(null!=r.limits?.causalHistory&&n.causalHistory.length===r.limits.causalHistory)throw new Sr('Decode error - map field "causalHistory" had too many elements');n.causalHistory.push(yr.codec().decode(e,e.uint32(),{limits:r.limits?.causalHistory$}));break;case 12:n.bloomFilter=e.bytes();break;case 20:n.content=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(br||(br={}));function Cr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function _r(e,...t){if(!((r=e)instanceof Uint8Array||ArrayBuffer.isView(r)&&"Uint8Array"===r.constructor.name))throw new Error("Uint8Array expected");var r;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Tr(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Cr(e.outputLen),Cr(e.blockLen)}function Pr(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}const Lr="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function Rr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Nr(e,t){return e<<32-t|e>>>t}function Or(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),_r(e),e}"function"==typeof Uint8Array.from([]).toHex&&Uint8Array.fromHex;class Dr{clone(){return this._cloneInto()}}function Mr(e){const t=t=>e().update(Or(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Fr(e=32){if(Lr&&"function"==typeof Lr.getRandomValues)return Lr.getRandomValues(new Uint8Array(e));if(Lr&&"function"==typeof Lr.randomBytes)return Uint8Array.from(Lr.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function Br(e,t,r){return e&t^e&r^t&r}class Ur extends Dr{constructor(e,t,r,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.buffer=new Uint8Array(e),this.view=Rr(this.buffer)}update(e){Pr(this);const{view:t,buffer:r,blockLen:n}=this,s=(e=Or(e)).length;for(let i=0;in-i&&(this.process(r,0),i=0);for(let e=i;e=e.length)throw new Error("Unexpected end of data");n.push(t.getUint16(i))}}return{clusterId:r,shards:n}},gn=e=>{const{clusterId:t,shards:r}=e,n=r.length>=64?130:3+2*r.length,s=new ArrayBuffer(n),i=new DataView(s);if(i.setUint16(0,t),r.length>=64)for(const e of r){const t=Math.floor(e/8)+2,r=7-e%8;i.setUint8(t,i.getUint8(t)|1<0)throw new Un("Unexpected end of input")}():function*(){for(const t of e)r.append(t),yield*c();if(r.byteLength>0)throw new Un("Unexpected end of input")}()}function zn(){const e={};return e.promise=new Promise(((t,r)=>{e.resolve=t,e.reject=r})),e}qn.bytes=0,jn.fromReader=(e,t)=>{let r=1;return jn(async function*(){for(;;)try{const{done:t,value:n}=await e.next(r);if(!0===t)return;null!=n&&(yield n)}catch(e){if("ERR_UNDER_READ"===e.code)return{done:!0,value:null};throw e}finally{r=1}}(),{...t??{},onLength:e=>{r=e}})};class Hn{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){const e=this.buffer[this.btm];if(void 0!==e)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return void 0===this.buffer[this.btm]}}class Kn{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Hn(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return null!=e?.byteLength?e.byteLength:1}push(e){if(null!=e?.value&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){const t=this.head;this.head=t.next=new Hn(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(void 0===e&&null!=this.tail.next){const t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return null!=e?.value&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}}class Vn extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}}function Gn(e={}){return function(e,t){let r,n,s,i=(t=t??{}).onEnd,o=new Kn,a=zn();const c=e=>null!=n?n(e):(o.push(e),r),l=e=>{if(s)return r;if(!0!==t?.objectMode&&null==e?.byteLength)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return c({done:!1,value:e})},u=e=>s?r:(s=!0,null!=e?(e=>(o=new Kn,null!=n?n({error:e}):(o.push({error:e}),r)))(e):c({done:!0}));if(r={[Symbol.asyncIterator](){return this},next:async()=>{try{return o.isEmpty()?s?{done:!0}:await new Promise(((t,s)=>{n=i=>{n=null,o.push(i);try{t(e(o))}catch(e){s(e)}return r}})):e(o)}finally{o.isEmpty()&&queueMicrotask((()=>{a.resolve(),a=zn()}))}},return:()=>(o=new Kn,u(),{done:!0}),throw:e=>(u(e),{done:!0}),push:l,end:u,get readableLength(){return o.size},onEmpty:async e=>{const t=e?.signal;if(t?.throwIfAborted(),o.isEmpty())return;let r,n;null!=t&&(r=new Promise(((e,r)=>{n=()=>{r(new Vn)},t.addEventListener("abort",n)})));try{await Promise.race([a.promise,r])}finally{null!=n&&null!=t&&t?.removeEventListener("abort",n)}}},null==i)return r;const h=r;return r={[Symbol.asyncIterator](){return this},next:()=>h.next(),throw:e=>(h.throw(e),null!=i&&(i(e),i=void 0),{done:!0}),return:()=>(h.return(),null!=i&&(i(),i=void 0),{done:!0}),push:l,end:e=>(h.end(e),null!=i&&(i(e),i=void 0),r),get readableLength(){return h.readableLength},onEmpty:e=>h.onEmpty(e)},r}((e=>{const t=e.shift();if(null==t)return{done:!0};if(null!=t.error)throw t.error;return{done:!0===t.done,value:t.value}}),e)}class Wn extends Error{type;code;constructor(e,t,r){super(e??"The operation was aborted"),this.type="aborted",this.name=r??"AbortError",this.code=t??"ABORT_ERR"}}async function Xn(e,t,r){if(null==t)return e;if(t.aborted)return e.catch((()=>{})),Promise.reject(new Wn(r?.errorMessage,r?.errorCode,r?.errorName));let n;const s=new Wn(r?.errorMessage,r?.errorCode,r?.errorName);try{return await Promise.race([e,new Promise(((e,r)=>{n=()=>{r(s)},t.addEventListener("abort",n)}))])}finally{null!=n&&t.removeEventListener("abort",n)}}class Jn{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=zn(),this.haveNext=zn()}[Symbol.asyncIterator](){return this}async next(){if(null==this.nextResult&&await this.haveNext.promise,null==this.nextResult)throw new Error("HaveNext promise resolved but nextResult was undefined");const e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=zn(),e}async throw(e){return this.ended=!0,this.error=e,null!=e&&(this.haveNext.promise.catch((()=>{})),this.haveNext.reject(e)),{done:!0,value:void 0}}async return(){const e={done:!0,value:void 0};return this.ended=!0,this.nextResult=e,this.haveNext.resolve(),e}async push(e,t){await this._push(e,t)}async end(e,t){null!=e?await this.throw(e):await this._push(void 0,t)}async _push(e,t){if(null!=e&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;null!=this.nextResult;)await this.readNext.promise;null!=e?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=zn(),await Xn(this.readNext.promise,t?.signal,t)}}const Qn=function(...e){const t=[];for(const r of e)null==r[Symbol.asyncIterator]&&t.push(r);return t.length===e.length?function*(e){for(const t of e)yield*t}(t):async function*(e){const t=new Jn;(async function(e,t){try{await Promise.all(e.map((async e=>{for await(const r of e)await t.push(r)}))),await t.end()}catch(e){await t.end(e).catch((()=>{}))}})(e,t).catch((()=>{})),yield*t}(e)};function Zn(e,...t){if(null==e)throw new Error("Empty pipeline");if(rs(e)){const t=e;e=()=>t.source}else if(ts(e)||es(e)){const t=e;e=()=>t}const r=[e,...t];if(r.length>1&&rs(r[r.length-1])&&(r[r.length-1]=r[r.length-1].sink),r.length>2)for(let e=1;e=e.byteLength);){const n=$o(e,t);if(null===n)break;r.push(n)}return r}function zo(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);const t=function(e){let t=e.toString(16);t.length%2==1&&(t="0"+t);const r=new Rn;for(let e=0;e>>3){case 1:n.Type=jc.codec().decode(e);break;case 2:n.Data=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(Hc||(Hc={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),jc.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.Type=jc.codec().decode(e);break;case 2:n.Data=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(Kc||(Kc={}));class Vc extends Error{constructor(e="An error occurred while signing a message"){super(e),this.name="SigningError"}}class Gc extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}}class Wc extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}}const Xc={get(e=globalThis){const t=e.crypto;if(null==t?.subtle)throw new Wc("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};class Jc{type="RSA";jwk;_raw;_multihash;constructor(e,t){this.jwk=e,this._multihash=t}get raw(){return null==this._raw&&(this._raw=Yc(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return mt.createV1(114,this._multihash)}toString(){return Ee.encode(this.toMultihash().bytes).substring(1)}equals(e){return null!=e&&e.raw instanceof Uint8Array&&_n(this.raw,e.raw)}verify(e,t){return async function(e,t,r){const n=await Xc.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Xc.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}(this.jwk,t,e)}}class Qc{type="RSA";jwk;_raw;publicKey;constructor(e,t){this.jwk=e,this.publicKey=t}get raw(){return null==this._raw&&(this._raw=function(e){if(null==e.n||null==e.e||null==e.d||null==e.p||null==e.q||null==e.dp||null==e.dq||null==e.qi)throw new ho("JWK was missing components");return Vo([Ho(Uint8Array.from([0])),Ho(xt(e.n,"base64url")),Ho(xt(e.e,"base64url")),Ho(xt(e.d,"base64url")),Ho(xt(e.p,"base64url")),Ho(xt(e.q,"base64url")),Ho(xt(e.dp,"base64url")),Ho(xt(e.dq,"base64url")),Ho(xt(e.qi,"base64url"))]).subarray()}(this.jwk)),this._raw}equals(e){return null!=e&&e.raw instanceof Uint8Array&&_n(this.raw,e.raw)}sign(e){return async function(e,t){const r=await Xc.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Xc.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}(this.jwk,e)}}const Zc=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Yc(e){if(null==e.n||null==e.e)throw new ho("JWK was missing components");return Vo([Zc,Ko(Vo([Ho(xt(e.n,"base64url")),Ho(xt(e.e,"base64url"))]))]).subarray()}function el(e,t,r){const n=function(e){const t=$o(e[1],{offset:0});return{kty:"RSA",n:en(t[0],"base64url"),e:en(t[1],"base64url")}}(e);return null==r&&(r=nt(18,Hr(Hc.encode({Type:jc.RSA,Data:t})))),new Jc(n,r)}class tl extends Dr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Tr(e);const r=Or(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,s=new Uint8Array(n);s.set(r.length>n?e.create().update(r).digest():r);for(let e=0;e{const s=t.toAffine();return Ra(Uint8Array.from([4]),r.toBytes(s.x),r.toBytes(s.y))}),i=t.fromBytes||(e=>{const t=e.subarray(1);return{x:r.fromBytes(t.subarray(0,r.BYTES)),y:r.fromBytes(t.subarray(r.BYTES,2*r.BYTES))}});function o(e){const{a:n,b:s}=t,i=r.sqr(e),o=r.mul(i,e);return r.add(r.add(o,r.mul(e,n)),s)}if(!r.eql(r.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function a(e){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:s,n:i}=t;if(r&&"bigint"!=typeof e){if(ya(e)&&(e=Ia(e)),"string"!=typeof e||!r.includes(e.length))throw new Error("invalid private key");e=e.padStart(2*n,"0")}let o;try{o="bigint"==typeof e?e:Ca(La("private key",e,n))}catch(t){throw new Error("invalid private key, expected hex or "+n+" bytes, got "+typeof e)}return s&&(o=Xa(o,i)),Da("private key",o,al,i),o}function c(e){if(!(e instanceof h))throw new Error("ProjectivePoint expected")}const l=qa(((e,t)=>{const{px:n,py:s,pz:i}=e;if(r.eql(i,r.ONE))return{x:n,y:s};const o=e.is0();null==t&&(t=o?r.ONE:r.inv(i));const a=r.mul(n,t),c=r.mul(s,t),l=r.mul(i,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(l,r.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),u=qa((e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:n,y:s}=e.toAffine();if(!r.isValid(n)||!r.isValid(s))throw new Error("bad point: x or y not FE");const i=r.sqr(s),a=o(n);if(!r.eql(i,a))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class h{constructor(e,t,n){if(null==e||!r.isValid(e))throw new Error("x required");if(null==t||!r.isValid(t))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required");this.px=e,this.py=t,this.pz=n,Object.freeze(this)}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof h)throw new Error("projective point not allowed");const s=e=>r.eql(e,r.ZERO);return s(t)&&s(n)?h.ZERO:new h(t,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=r.invertBatch(e.map((e=>e.pz)));return e.map(((e,r)=>e.toAffine(t[r]))).map(h.fromAffine)}static fromHex(e){const t=h.fromAffine(i(La("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return h.BASE.multiply(a(e))}static msm(e,t){return fc(h,n,e,t)}_setWindowSize(e){p.setWindowSize(this,e)}assertValidity(){u(this)}hasEvenY(){const{y:e}=this.toAffine();if(r.isOdd)return!r.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){c(e);const{px:t,py:n,pz:s}=this,{px:i,py:o,pz:a}=e,l=r.eql(r.mul(t,a),r.mul(i,s)),u=r.eql(r.mul(n,a),r.mul(o,s));return l&&u}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){const{a:e,b:n}=t,s=r.mul(n,cl),{px:i,py:o,pz:a}=this;let c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(i,i),p=r.mul(o,o),f=r.mul(a,a),g=r.mul(i,o);return g=r.add(g,g),u=r.mul(i,a),u=r.add(u,u),c=r.mul(e,u),l=r.mul(s,f),l=r.add(c,l),c=r.sub(p,l),l=r.add(p,l),l=r.mul(c,l),c=r.mul(g,c),u=r.mul(s,u),f=r.mul(e,f),g=r.sub(d,f),g=r.mul(e,g),g=r.add(g,u),u=r.add(d,d),d=r.add(u,d),d=r.add(d,f),d=r.mul(d,g),l=r.add(l,d),f=r.mul(o,a),f=r.add(f,f),d=r.mul(f,g),c=r.sub(c,d),u=r.mul(f,p),u=r.add(u,u),u=r.add(u,u),new h(c,l,u)}add(e){c(e);const{px:n,py:s,pz:i}=this,{px:o,py:a,pz:l}=e;let u=r.ZERO,d=r.ZERO,p=r.ZERO;const f=t.a,g=r.mul(t.b,cl);let m=r.mul(n,o),y=r.mul(s,a),b=r.mul(i,l),w=r.add(n,s),v=r.add(o,a);w=r.mul(w,v),v=r.add(m,y),w=r.sub(w,v),v=r.add(n,i);let E=r.add(o,l);return v=r.mul(v,E),E=r.add(m,b),v=r.sub(v,E),E=r.add(s,i),u=r.add(a,l),E=r.mul(E,u),u=r.add(y,b),E=r.sub(E,u),p=r.mul(f,v),u=r.mul(g,b),p=r.add(u,p),u=r.sub(y,p),p=r.add(y,p),d=r.mul(u,p),y=r.add(m,m),y=r.add(y,m),b=r.mul(f,b),v=r.mul(g,v),y=r.add(y,b),b=r.sub(m,b),b=r.mul(f,b),v=r.add(v,b),m=r.mul(y,v),d=r.add(d,m),m=r.mul(E,v),u=r.mul(w,u),u=r.sub(u,m),m=r.mul(w,y),p=r.mul(E,p),p=r.add(p,m),new h(u,d,p)}subtract(e){return this.add(e.negate())}is0(){return this.equals(h.ZERO)}wNAF(e){return p.wNAFCached(this,e,h.normalizeZ)}multiplyUnsafe(e){const{endo:n,n:s}=t;Da("scalar",e,ol,s);const i=h.ZERO;if(e===ol)return i;if(this.is0()||e===al)return this;if(!n||p.hasPrecomputes(this))return p.wNAFCachedUnsafe(this,e,h.normalizeZ);let{k1neg:o,k1:a,k2neg:c,k2:l}=n.splitScalar(e),u=i,d=i,f=this;for(;a>ol||l>ol;)a&al&&(u=u.add(f)),l&al&&(d=d.add(f)),f=f.double(),a>>=al,l>>=al;return o&&(u=u.negate()),c&&(d=d.negate()),d=new h(r.mul(d.px,n.beta),d.py,d.pz),u.add(d)}multiply(e){const{endo:n,n:s}=t;let i,o;if(Da("scalar",e,al,s),n){const{k1neg:t,k1:s,k2neg:a,k2:c}=n.splitScalar(e);let{p:l,f:u}=this.wNAF(s),{p:d,f}=this.wNAF(c);l=p.constTimeNegate(t,l),d=p.constTimeNegate(a,d),d=new h(r.mul(d.px,n.beta),d.py,d.pz),i=l.add(d),o=u.add(f)}else{const{p:t,f:r}=this.wNAF(e);i=t,o=r}return h.normalizeZ([i,o])[0]}multiplyAndAddUnsafe(e,t,r){const n=h.BASE,s=(e,t)=>t!==ol&&t!==al&&e.equals(n)?e.multiply(t):e.multiplyUnsafe(t),i=s(this,t).add(s(e,r));return i.is0()?void 0:i}toAffine(e){return l(this,e)}isTorsionFree(){const{h:e,isTorsionFree:r}=t;if(e===al)return!0;if(r)return r(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:r}=t;return e===al?this:r?r(h,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return wa("isCompressed",e),this.assertValidity(),s(h,this,e)}toHex(e=!0){return wa("isCompressed",e),Ia(this.toRawBytes(e))}}h.BASE=new h(t.Gx,t.Gy,r.ONE),h.ZERO=new h(r.ZERO,r.ONE,r.ZERO);const d=t.nBitLength,p=pc(h,t.endo?Math.ceil(d/2):d);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:a,weierstrassEquation:o,isWithinCurveOrder:function(e){return Oa(e,al,t.n)}}}({...t,toBytes(e,t,n){const s=t.toAffine(),i=r.toBytes(s.x),o=Ra;return wa("isCompressed",n),n?o(Uint8Array.from([t.hasEvenY()?2:3]),i):o(Uint8Array.from([4]),i,r.toBytes(s.y))},fromBytes(e){const t=e.length,n=e[0],o=e.subarray(1);if(t!==s||2!==n&&3!==n){if(t===i&&4===n)return{x:r.fromBytes(o.subarray(0,r.BYTES)),y:r.fromBytes(o.subarray(r.BYTES,2*r.BYTES))};throw new Error("invalid Point, expected length of "+s+", or uncompressed "+i+", got "+t)}{const e=Ca(o);if(!Oa(e,al,r.ORDER))throw new Error("Point is not on curve");const t=u(e);let s;try{s=r.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return!(1&~n)!=((s&al)===al)&&(s=r.neg(s)),{x:e,y:s}}}}),d=e=>Ia(Ta(e,t.nByteLength));function p(e){return e>n>>al}const f=(e,t,r)=>Ca(e.slice(t,r));class g{constructor(e,t,r){Da("r",e,al,n),Da("s",t,al,n),this.r=e,this.s=t,null!=r&&(this.recovery=r),Object.freeze(this)}static fromCompact(e){const r=t.nByteLength;return e=La("compactSignature",e,2*r),new g(f(e,0,r),f(e,r,2*r))}static fromDER(e){const{r:t,s:r}=il.toSig(La("DER",e));return new g(t,r)}assertValidity(){}addRecoveryBit(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r:n,s,recovery:i}=this,l=w(La("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const u=2===i||3===i?n+t.n:n;if(u>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=1&i?"03":"02",p=c.fromHex(h+d(u)),f=a(u),g=o(-l*f),m=o(s*f),y=c.BASE.multiplyAndAddUnsafe(p,g,m);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return xa(this.toDERHex())}toDERHex(){return il.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return xa(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const m={isValidPrivateKey(e){try{return l(e),!0}catch(e){return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const e=nc(t.n);return function(e,t,r=!1){const n=e.length,s=rc(t),i=nc(t);if(n<16||n1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);const o=Xa(r?_a(e):Ca(e),t-za)+za;return r?Pa(o,s):Ta(o,s)}(t.randomBytes(e),t.n)},precompute:(e=8,t=c.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function y(e){const t=ya(e),r="string"==typeof e,n=(t||r)&&e.length;return t?n===s||n===i:r?n===2*s||n===2*i:e instanceof c}const b=t.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const r=Ca(e),n=8*e.length-t.nBitLength;return n>0?r>>BigInt(n):r},w=t.bits2int_modN||function(e){return o(b(e))},v=Ma(t.nBitLength);function E(e){return Da("num < 2^"+t.nBitLength,e,ol,v),Ta(e,t.nByteLength)}const S={lowS:t.lowS,prehash:!1},A={lowS:t.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,r=!0){if(y(e))throw new Error("first arg must be private key");if(!y(t))throw new Error("second arg must be public key");return c.fromHex(t).multiply(l(e)).toRawBytes(r)},sign:function(e,n,s=S){const{seed:i,k2sig:u}=function(e,n,s=S){if(["recovered","canonical"].some((e=>e in s)))throw new Error("sign() legacy options not supported");const{hash:i,randomBytes:u}=t;let{lowS:d,prehash:f,extraEntropy:m}=s;null==d&&(d=!0),e=La("msgHash",e),nl(s),f&&(e=La("prehashed msgHash",i(e)));const y=w(e),v=l(n),A=[E(v),E(y)];if(null!=m&&!1!==m){const e=!0===m?u(r.BYTES):m;A.push(La("extraEntropy",e))}const I=Ra(...A),k=y;return{seed:I,k2sig:function(e){const t=b(e);if(!h(t))return;const r=a(t),n=c.BASE.multiply(t).toAffine(),s=o(n.x);if(s===ol)return;const i=o(r*o(k+s*v));if(i===ol)return;let l=(n.x===s?0:2)|Number(n.y&al),u=i;return d&&p(i)&&(u=function(e){return p(e)?o(-e):e}(i),l^=1),new g(s,u,l)}}}(e,n,s),d=t,f=function(e,t,r){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=Fa(e),s=Fa(e),i=0;const o=()=>{n.fill(1),s.fill(0),i=0},a=(...e)=>r(s,n,...e),c=(e=Fa(0))=>{s=a(Ba([0]),e),n=a(),0!==e.length&&(s=a(Ba([1]),e),n=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const r=[];for(;e
0)throw new jl("Unexpected end of input")}():function*(){for(const t of e)r.append(t),yield*c();if(r.byteLength>0)throw new jl("Unexpected end of input")}()}Hl.bytes=0,Kl.fromReader=(e,t)=>{let r=1;return Kl(async function*(){for(;;)try{const{done:t,value:n}=await e.next(r);if(!0===t)return;null!=n&&(yield n)}catch(e){if("ERR_UNDER_READ"===e.code)return{done:!0,value:null};throw e}finally{r=1}}(),{...t??{},onLength:e=>{r=e}})};class Vl{readNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.readNext=zn(),this.haveNext=zn()}[Symbol.asyncIterator](){return this}async next(){if(null==this.nextResult&&await this.haveNext.promise,null==this.nextResult)throw new Error("HaveNext promise resolved but nextResult was undefined");const e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=zn(),e}async throw(e){return this.ended=!0,null!=e&&(this.haveNext.promise.catch((()=>{})),this.haveNext.reject(e)),{done:!0,value:void 0}}async return(){const e={done:!0,value:void 0};return this.ended=!0,this.nextResult=e,this.haveNext.resolve(),e}async push(e,t){await this._push(e,t)}async end(e,t){null!=e?await this.throw(e):await this._push(void 0,t)}async _push(e,t){if(null!=e&&this.ended)throw new Error("Cannot push value onto an ended pushable");for(;null!=this.nextResult;)await this.readNext.promise;null!=e?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=zn(),await Xn(this.readNext.promise,t?.signal,t)}}class Gl extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"}class Wl extends Error{code;constructor(e,t){super(e),this.code=t}}class Xl extends Wl{type;constructor(e){super(e,"ABORT_ERR"),this.type="aborted",this.name="AbortError"}}function Jl(e,t){const r=new Vl;e.sink(r).catch((async e=>{await r.end(e)})),e.sink=async e=>{for await(const t of e)await r.push(t);await r.end()};let n=e.source;null!=e.source[Symbol.iterator]?n=e.source[Symbol.iterator]():null!=e.source[Symbol.asyncIterator]&&(n=e.source[Symbol.asyncIterator]());const s=new Rn,i={read:async(e,t)=>{let r;t?.signal?.throwIfAborted();const i=new Promise(((e,n)=>{r=()=>{n(new Xl("Read aborted"))},t?.signal?.addEventListener("abort",r)}));try{if(null==e){const{done:e,value:t}=await Promise.race([n.next(),i]);return!0===e?new Rn:t}for(;s.byteLength({publicKey:Mc.getPublicKey(e),privateKey:e}),generateX25519SharedKey:(e,t)=>Mc.getSharedSecret(e.subarray(),t.subarray()),chaCha20Poly1305Encrypt:(e,t,r,n)=>Mu(n,t,r).encrypt(e.subarray()),chaCha20Poly1305Decrypt:(e,t,r,n,s)=>Mu(n,t,r).decrypt(e.subarray(),s)},$u=e=>{const t=g(2);return t[0]=e>>8,t[1]=e,t};$u.bytes=2;const qu=e=>{if(e.length<2)throw RangeError("Could not decode int16BE");if(e instanceof Uint8Array){let t=0;return t+=e[0]<<8,t+=e[1],t}return e.getUint16(0)};function ju(e,t){t.enabled&&nu&&(e?(t(`LOCAL_STATIC_PUBLIC_KEY ${en(e.publicKey,"hex")}`),t(`LOCAL_STATIC_PRIVATE_KEY ${en(e.privateKey,"hex")}`)):t("Missing local static keys."))}function zu(e,t){t.enabled&&nu&&(e?(t(`LOCAL_PUBLIC_EPHEMERAL_KEY ${en(e.publicKey,"hex")}`),t(`LOCAL_PRIVATE_EPHEMERAL_KEY ${en(e.privateKey,"hex")}`)):t("Missing local ephemeral keys."))}function Hu(e,t){t.enabled&&nu&&t(e?`REMOTE_EPHEMERAL_PUBLIC_KEY ${en(e.subarray(),"hex")}`:"Missing remote ephemeral keys.")}function Ku(e,t,r){r.enabled&&nu&&(r(`CIPHER_STATE_1 ${e.n.getUint64()} ${e.k&&en(e.k,"hex")}`),r(`CIPHER_STATE_2 ${t.n.getUint64()} ${t.k&&en(t.k,"hex")}`))}qu.bytes=2;class Vu extends Error{code;constructor(e="Invalid crypto exchange"){super(e),this.code=Vu.code}static code="ERR_INVALID_CRYPTO_EXCHANGE"}class Gu{n;bytes;view;constructor(e=0){this.n=e,this.bytes=f(12),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength),this.view.setUint32(4,e,!0)}increment(){this.n++,this.view.setUint32(4,this.n,!0)}getBytes(){return this.bytes}getUint64(){return this.n}assertValue(){if(this.n>4294967295)throw new Error("Cipherstate has reached maximum n, a new handshake must be performed")}}const Wu=f(0);class Xu{k;n;crypto;constructor(e,t=void 0,r=0){this.crypto=e,this.k=t,this.n=new Gu(r)}hasKey(){return Boolean(this.k)}encryptWithAd(e,t){if(!this.hasKey())return t;this.n.assertValue();const r=this.crypto.encrypt(t,this.n.getBytes(),e,this.k);return this.n.increment(),r}decryptWithAd(e,t,r){if(!this.hasKey())return t;this.n.assertValue();const n=this.crypto.decrypt(t,this.n.getBytes(),e,this.k,r);return this.n.increment(),n}}class Ju{cs;ck;h;crypto;constructor(e,t){this.crypto=e;const r=xt(t,"utf-8");this.h=function(e,t){if(t.length<=32){const e=f(32);return e.set(t),e}return e.hash(t)}(e,r),this.ck=this.h,this.cs=new Xu(e)}mixKey(e){const[t,r]=this.crypto.hkdf(this.ck,e);this.ck=t,this.cs=new Xu(this.crypto,r)}mixHash(e){this.h=this.crypto.hash(new Rn(this.h,e))}encryptAndHash(e){const t=this.cs.encryptWithAd(this.h,e);return this.mixHash(t),t}decryptAndHash(e){const t=this.cs.decryptWithAd(this.h,e);return this.mixHash(e),t}split(){const[e,t]=this.crypto.hkdf(this.ck,Wu);return[new Xu(this.crypto,e),new Xu(this.crypto,t)]}}class Qu{ss;s;e;rs;re;initiator;crypto;constructor(e){const{crypto:t,protocolName:r,prologue:n,initiator:s,s:i,e:o,rs:a,re:c}=e;this.crypto=t,this.ss=new Ju(t,r),this.ss.mixHash(n),this.initiator=s,this.s=i,this.e=o,this.rs=a,this.re=c}writeE(){if(this.e)throw new Error("ephemeral keypair is already set");const e=this.crypto.generateKeypair();return this.ss.mixHash(e.publicKey),this.e=e,e.publicKey}writeS(){if(!this.s)throw new Error("static keypair is not set");return this.ss.encryptAndHash(this.s.publicKey)}writeEE(){if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.re))}writeES(){if(this.initiator){if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.rs)throw new Error("remote static public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.rs))}else{if(!this.s)throw new Error("static keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.s,this.re))}}writeSE(){if(this.initiator){if(!this.s)throw new Error("static keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.s,this.re))}else{if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.rs)throw new Error("remote static public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.rs))}}readE(e,t=0){if(this.re)throw new Error("remote ephemeral public key is already set");if(e.byteLength>>3==1?n.multiaddr=e.bytes():e.skipType(7&t)}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(t=e.AddressInfo||(e.AddressInfo={})),e.codec=()=>(null==r&&(r=Er(((t,r,n={})=>{if(!1!==n.lengthDelimited&&r.fork(),null!=t.peerId&&t.peerId.byteLength>0&&(r.uint32(10),r.bytes(t.peerId)),null!=t.seq&&0n!==t.seq&&(r.uint32(16),r.uint64(t.seq)),null!=t.addresses)for(const n of t.addresses)r.uint32(26),e.AddressInfo.codec().encode(n,r);!1!==n.lengthDelimited&&r.ldelim()}),((t,r,n={})=>{const s={peerId:f(0),seq:0n,addresses:[]},i=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:s.peerId=t.bytes();break;case 2:s.seq=t.uint64();break;case 3:if(null!=n.limits?.addresses&&s.addresses.length===n.limits.addresses)throw new Sr('Decode error - map field "addresses" had too many elements');s.addresses.push(e.AddressInfo.codec().decode(t,t.uint32(),{limits:n.limits?.addresses$}));break;default:t.skipType(7&r)}}return s}))),r),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(qh||(qh={}));class zh{static createFromProtobuf=e=>{const t=qh.decode(e),r=Ml(st(t.peerId)),n=(t.addresses??[]).map((e=>vi(e.multiaddr))),s=t.seq;return new zh({peerId:r,multiaddrs:n,seqNumber:s})};static DOMAIN="libp2p-peer-record";static CODEC=$h;peerId;multiaddrs;seqNumber;domain=zh.DOMAIN;codec=zh.CODEC;marshaled;constructor(e){const{peerId:t,multiaddrs:r,seqNumber:n}=e;this.peerId=t,this.multiaddrs=r??[],this.seqNumber=n??BigInt(Date.now())}marshal(){return null==this.marshaled&&(this.marshaled=qh.encode({peerId:this.peerId.toMultihash().bytes,seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map((e=>({multiaddr:e.bytes})))})),this.marshaled}equals(e){return e instanceof zh&&!!this.peerId.equals(e.peerId)&&this.seqNumber===e.seqNumber&&!!function(e,t){const r=(e,t)=>e.toString().localeCompare(t.toString());return e.length===t.length&&(t.sort(r),e.sort(r).every(((e,r)=>t[r].equals(e))))}(this.multiaddrs,e.multiaddrs)}}!function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.publicKey&&e.publicKey.byteLength>0&&(t.uint32(10),t.bytes(e.publicKey)),null!=e.payloadType&&e.payloadType.byteLength>0&&(t.uint32(18),t.bytes(e.payloadType)),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(26),t.bytes(e.payload)),null!=e.signature&&e.signature.byteLength>0&&(t.uint32(42),t.bytes(e.signature)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={publicKey:f(0),payloadType:f(0),payload:f(0),signature:f(0)},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.publicKey=e.bytes();break;case 2:n.payloadType=e.bytes();break;case 3:n.payload=e.bytes();break;case 5:n.signature=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(jh||(jh={}));class Hh extends Error{constructor(e="Invalid signature"){super(e),this.name="InvalidSignatureError"}}class Kh{static createFromProtobuf=async e=>{const t=jh.decode(e),r=Il(t.publicKey);return new Kh({publicKey:r,payloadType:t.payloadType,payload:t.payload,signature:t.signature})};static seal=async(e,t)=>{if(null==t)throw new Error("Missing private key");const r=e.domain,n=e.codec,s=e.marshal(),i=Vh(r,n,s),o=await t.sign(i.subarray());return new Kh({publicKey:t.publicKey,payloadType:n,payload:s,signature:o})};static openAndCertify=async(e,t)=>{const r=await Kh.createFromProtobuf(e);if(!await r.validate(t))throw new Hh("Envelope signature is not valid for the given domain");return r};publicKey;payloadType;payload;signature;marshaled;constructor(e){const{publicKey:t,payloadType:r,payload:n,signature:s}=e;this.publicKey=t,this.payloadType=r,this.payload=n,this.signature=s}marshal(){return null==this.marshaled&&(this.marshaled=jh.encode({publicKey:kl(this.publicKey),payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return _n(this.marshal(),e.marshal())}async validate(e){const t=Vh(e,this.payloadType,this.payload);return this.publicKey.verify(t.subarray(),this.signature)}}const Vh=(e,t,r)=>{const n=xt(e),s=_(n.byteLength),i=_(t.length),o=_(r.length);return new Rn(s,n,i,t,o,r)};var Gh=__webpack_require__(5507);const Wh=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"].map((e=>new Gh.Netmask(e)));function Xh(e){for(const t of Wh)if(t.contains(e))return!0;return!1}function Jh(e){return zs(e)?Xh(e):/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(e)?function(e){const t=e.split(":");if(t.length<2)return!1;const r=t[t.length-1].padStart(4,"0"),n=t[t.length-2].padStart(4,"0");return Xh(`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(r.substring(0,2),16)}.${parseInt(r.substring(2),16)}`)}(e):/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)?function(e){const t=e.split(":");return Xh(t[t.length-1])}(e):Hs(e)?function(e){return/^::$/.test(e)||/^::1$/.test(e)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(e)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(e)||/^ff([0-9a-fA-F]{2,2}):/i.test(e)}(e):void 0}function Qh(e){try{if(!function(e){try{const[[t]]=e.stringTuples();return 4===t||41===t}catch{}return!1}(e))return!1;const[[,t]]=e.stringTuples();return null!=t&&(Jh(t)??!1)}catch{}return!0}const Zh=e=>({match:t=>!(t.length<1)&&!!e(t[0])&&t.slice(1),pattern:"fn"}),Yh=e=>({match:t=>Zh((t=>t===e)).match(t),pattern:e}),ed=()=>({match:e=>Zh((e=>"string"==typeof e)).match(e),pattern:"{string}"}),td=()=>({match:e=>Zh((e=>!isNaN(parseInt(e)))).match(e),pattern:"{number}"}),rd=()=>({match:e=>{if(e.length<2)return!1;if("p2p"!==e[0]&&"ipfs"!==e[0])return!1;if(!e[1].startsWith("Q")&&!e[1].startsWith("1"))return!1;try{Ee.decode(`z${e[1]}`)}catch(e){return!1}return e.slice(2)},pattern:"/p2p/{peerid}"}),nd=()=>({match:e=>{if(e.length<2)return!1;if("certhash"!==e[0])return!1;try{ke.decode(e[1])}catch{return!1}return e.slice(2)},pattern:"/certhash/{certhash}"}),sd=e=>({match:t=>{const r=e.match(t);return!1===r?t:r},pattern:`optional(${e.pattern})`}),id=(...e)=>({match:t=>{let r;for(const n of e){const e=n.match(t);!1!==e&&(null==r||e.length>>3){case 5:n.protocolVersion=e.string();break;case 6:n.agentVersion=e.string();break;case 1:n.publicKey=e.bytes();break;case 2:if(null!=r.limits?.listenAddrs&&n.listenAddrs.length===r.limits.listenAddrs)throw new Sr('Decode error - map field "listenAddrs" had too many elements');n.listenAddrs.push(e.bytes());break;case 4:n.observedAddr=e.bytes();break;case 3:if(null!=r.limits?.protocols&&n.protocols.length===r.limits.protocols)throw new Sr('Decode error - map field "protocols" had too many elements');n.protocols.push(e.string());break;case 8:n.signedPeerRecord=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(qd||(qd={}));const jd="ipfs",zd=5e3,Hd=1,Kd=1,Vd=10,Gd=8192,Wd=!0,Xd=!0;class Jd{host;protocol;started;timeout;peerId;privateKey;peerStore;registrar;addressManager;maxInboundStreams;maxOutboundStreams;maxMessageSize;maxObservedAddresses;events;runOnLimitedConnection;log;constructor(e,t){var r,n;this.protocol=t.protocol,this.started=!1,this.peerId=e.peerId,this.privateKey=e.privateKey,this.peerStore=e.peerStore,this.registrar=e.registrar,this.addressManager=e.addressManager,this.events=e.events,this.log=t.log,this.timeout=t.timeout??zd,this.maxInboundStreams=t.maxInboundStreams??Hd,this.maxOutboundStreams=t.maxOutboundStreams??Kd,this.maxMessageSize=t.maxMessageSize??Gd,this.maxObservedAddresses=t.maxObservedAddresses??Vd,this.runOnLimitedConnection=t.runOnLimitedConnection??Xd,this.host={protocolVersion:`${t.protocolPrefix??jd}/0.1.0`,agentVersion:(r=e.nodeInfo,n=t.agentVersion,null!=n?n:r.userAgent)}}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:xt(this.host.agentVersion),ProtocolVersion:xt(this.host.protocolVersion)}}),await this.registrar.handle(this.protocol,(e=>{this.handleProtocol(e).catch((e=>{this.log.error(e)}))}),{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnLimitedConnection:this.runOnLimitedConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.protocol),this.started=!1}}class Qd extends Jd{constructor(e,t={}){super(e,{...t,protocol:`/${t.protocolPrefix??jd}/id/1.0.0`,log:e.logger.forComponent("libp2p:identify")}),(t.runOnConnectionOpen??Wd)&&e.events.addEventListener("connection:open",(e=>{const t=e.detail;this.identify(t).catch((e=>{e.name!==xo.name&&this.log.error("error during identify trigged by connection:open",e)}))}))}[xl]=["@libp2p/identify"];async _identify(e,t={}){let r;if(null==t.signal){const e=AbortSignal.timeout(this.timeout);t={...t,signal:e}}try{r=await e.newStream(this.protocol,{...t,runOnLimitedConnection:this.runOnLimitedConnection});const n=$d(r,{maxDataLength:this.maxMessageSize}).pb(qd),s=await n.read(t);return await r.close(t),s}catch(e){throw r?.abort(e),e}}async identify(e,t={}){const r=await this._identify(e,t),{publicKey:n,protocols:s,observedAddr:i}=r;if(null==n)throw new Co("public key was missing from identify message");const o=Fl(Il(n).toCID());if(!e.remotePeer.equals(o))throw new Co("identified peer does not match the expected peer");if(this.peerId.equals(o))throw new Co("identified peer is our own peer id?");return this.maybeAddObservedAddress(i),this.log("identify completed for peer %p and protocols %o",o,s),async function(e,t,r,n,s){if(r("received identify from %p",n.remotePeer),null==s)throw new Co("message was null or undefined");const i={};if(s.listenAddrs.length>0&&(i.addresses=s.listenAddrs.map((e=>({isCertified:!1,multiaddr:vi(e)})))),s.protocols.length>0&&(i.protocols=s.protocols),null!=s.publicKey){const e=Il(s.publicKey);if(!Dl(e).equals(n.remotePeer))throw new Co("public key did not match remote PeerId");i.publicKey=e}let o;if(null!=s.signedPeerRecord){r.trace("received signedPeerRecord from %p",n.remotePeer);let t=s.signedPeerRecord;const a=await Kh.openAndCertify(t,zh.DOMAIN);let c=zh.createFromProtobuf(a.payload);const l=Fl(a.publicKey.toCID());if(!c.peerId.equals(l))throw new Co("signing key does not match PeerId in the PeerRecord");if(!n.remotePeer.equals(c.peerId))throw new Co("signing key does not match remote PeerId");let u;try{u=await e.get(c.peerId)}catch(e){if("NotFoundError"!==e.name)throw e}if(null!=u&&(i.metadata=u.metadata,null!=u.peerRecordEnvelope)){const e=await Kh.createFromProtobuf(u.peerRecordEnvelope),n=zh.createFromProtobuf(e.payload);n.seqNumber>=c.seqNumber&&(r("sequence number was lower or equal to existing sequence number - stored: %d received: %d",n.seqNumber,c.seqNumber),c=n,t=u.peerRecordEnvelope)}i.peerRecordEnvelope=t,i.addresses=c.multiaddrs.map((e=>({isCertified:!0,multiaddr:e}))),o={seq:c.seqNumber,addresses:c.multiaddrs}}else r("%p did not send a signed peer record",n.remotePeer);if(r.trace("patching %p with",n.remotePeer,i),await e.patch(n.remotePeer,i),null!=s.agentVersion||null!=s.protocolVersion){const t={};null!=s.agentVersion&&(t.AgentVersion=xt(s.agentVersion)),null!=s.protocolVersion&&(t.ProtocolVersion=xt(s.protocolVersion)),r.trace("merging %p metadata",n.remotePeer,t),await e.merge(n.remotePeer,{metadata:t})}const a={peerId:n.remotePeer,protocolVersion:s.protocolVersion,agentVersion:s.agentVersion,publicKey:s.publicKey,listenAddrs:s.listenAddrs.map((e=>vi(e))),observedAddr:null==s.observedAddr?void 0:vi(s.observedAddr),protocols:s.protocols,signedPeerRecord:o,connection:n};return t.safeDispatchEvent("peer:identify",{detail:a}),a}(this.peerStore,this.events,this.log,e,r)}maybeAddObservedAddress(e){const t=function(e){if(null!=e&&e.length>0)try{return vi(e)}catch{}}(e);null!=t&&(this.log.trace("our observed address was %a",t),Qh(t)?this.log.trace("our observed address was private"):41!==t.stringTuples()[0][0]||function(e){try{const[[r,n]]=e.stringTuples();if(null==n)return!1;if(41===r)return t=n,new js("2000::/3").contains(t)}catch{}var t;return!1}(t)?wd.exactMatch(t)||(this.log.trace("storing the observed address"),this.addressManager.addObservedAddr(t)):this.log.trace("our observed address was IPv6 but not a global unicast address"))}async handleProtocol(e){const{connection:t,stream:r}=e,n=AbortSignal.timeout(this.timeout);try{const e=await this.peerStore.get(this.peerId),s=this.addressManager.getAddresses().map((e=>e.decapsulateCode(Zs("p2p").code)));let i=e.peerRecordEnvelope;if(s.length>0&&null==i){const e=new zh({peerId:this.peerId,multiaddrs:s});i=(await Kh.seal(e,this.privateKey)).marshal().subarray()}let o=t.remoteAddr.bytes;md.matches(t.remoteAddr)||(o=void 0);const a=$d(r).pb(qd);await a.write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:kl(this.privateKey.publicKey),listenAddrs:s.map((e=>e.bytes)),signedPeerRecord:i,observedAddr:o,protocols:e.protocols},{signal:n}),await r.close({signal:n})}catch(e){this.log.error("could not respond to identify request",e),r.abort(e)}}}function Zd(e={}){return t=>new Qd(t,e)}function Yd(e,t){const r=function(e){if(null!=e){if("function"==typeof e[Symbol.iterator])return e[Symbol.iterator]();if("function"==typeof e[Symbol.asyncIterator])return e[Symbol.asyncIterator]();if("function"==typeof e.next)return e}throw new Error("argument is not an iterator or iterable")}(e).return?.();var n;null!=(n=r)&&"function"==typeof n.then&&"function"==typeof n.catch&&"function"==typeof n.finally&&r.catch((e=>{t.error("could not cause iterator to return",e)}))}const ep=()=>{const e=new Error("Delay aborted");return e.name="AbortError",e},tp=new WeakMap,rp=function({clearTimeout:e,setTimeout:t}={}){return(r,{value:n,signal:s}={})=>{if(s?.aborted)return Promise.reject(ep());let i,o,a;const c=e??clearTimeout,l=()=>{c(i),a(ep())},u=new Promise(((e,c)=>{o=()=>{s&&s.removeEventListener("abort",l),e(n)},a=c,i=(t??setTimeout)(o,r)}));return s&&s.addEventListener("abort",l,{once:!0}),tp.set(u,(()=>{c(i),i=null,o()})),u}}();class np extends Error{remainingPoints;msBeforeNext;consumedPoints;isFirstInDuration;constructor(e="Rate limit exceeded",t){super(e),this.name="RateLimitError",this.remainingPoints=t.remainingPoints,this.msBeforeNext=t.msBeforeNext,this.consumedPoints=t.consumedPoints,this.isFirstInDuration=t.isFirstInDuration}}class sp extends Error{static name="QueueFullError";constructor(e="The queue was full"){super(e),this.name="QueueFullError"}}class ip{memoryStorage;points;duration;blockDuration;execEvenly;execEvenlyMinDelayMs;keyPrefix;constructor(e={}){this.points=e.points??4,this.duration=e.duration??1,this.blockDuration=e.blockDuration??0,this.execEvenly=e.execEvenly??!1,this.execEvenlyMinDelayMs=e.execEvenlyMinDelayMs??1e3*this.duration/this.points,this.keyPrefix=e.keyPrefix??"rlflx",this.memoryStorage=new op}async consume(e,t=1,r={}){const n=this.getKey(e),s=this._getKeySecDuration(r);let i=this.memoryStorage.incrby(n,t,s);if(i.remainingPoints=Math.max(this.points-i.consumedPoints,0),i.consumedPoints>this.points)throw this.blockDuration>0&&i.consumedPoints<=this.points+t&&(i=this.memoryStorage.set(n,i.consumedPoints,this.blockDuration)),new np("Rate limit exceeded",i);if(this.execEvenly&&i.msBeforeNext>0&&!i.isFirstInDuration){let e=Math.ceil(i.msBeforeNext/(i.remainingPoints+2));e{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;tnull!=e&&e>Date.now()-r)).map((({multiaddr:e,isCertified:t})=>({multiaddr:vi(e),isCertified:t??!1}))),metadata:t.metadata,peerRecordEnvelope:t.peerRecordEnvelope??void 0,tags:n}}function sg(e,t){return null==e&&null==t||null!=e&&null!=t&&_n(e,t)}function ig(e,t,r){if(e.length!==t.length)return!1;for(let n=0;n>>3){case 1:n.key=e.string();break;case 2:n.value=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(t=e.Peer$metadataEntry||(e.Peer$metadataEntry={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.key&&""!==e.key&&(t.uint32(10),t.string(e.key)),null!=e.value&&(t.uint32(18),eg.codec().encode(e.value,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={key:""},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.key=e.string();break;case 2:n.value=eg.codec().decode(e,e.uint32(),{limits:r.limits?.value});break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(r=e.Peer$tagsEntry||(e.Peer$tagsEntry={})),e.codec=()=>(null==n&&(n=Er(((t,r,n={})=>{if(!1!==n.lengthDelimited&&r.fork(),null!=t.addresses)for(const e of t.addresses)r.uint32(10),Yf.codec().encode(e,r);if(null!=t.protocols)for(const e of t.protocols)r.uint32(18),r.string(e);if(null!=t.publicKey&&(r.uint32(34),r.bytes(t.publicKey)),null!=t.peerRecordEnvelope&&(r.uint32(42),r.bytes(t.peerRecordEnvelope)),null!=t.metadata&&0!==t.metadata.size)for(const[n,s]of t.metadata.entries())r.uint32(50),e.Peer$metadataEntry.codec().encode({key:n,value:s},r);if(null!=t.tags&&0!==t.tags.size)for(const[n,s]of t.tags.entries())r.uint32(58),e.Peer$tagsEntry.codec().encode({key:n,value:s},r);null!=t.updated&&(r.uint32(64),r.uint64Number(t.updated)),!1!==n.lengthDelimited&&r.ldelim()}),((t,r,n={})=>{const s={addresses:[],protocols:[],metadata:new Map,tags:new Map},i=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:if(null!=n.limits?.addresses&&s.addresses.length===n.limits.addresses)throw new Sr('Decode error - map field "addresses" had too many elements');s.addresses.push(Yf.codec().decode(t,t.uint32(),{limits:n.limits?.addresses$}));break;case 2:if(null!=n.limits?.protocols&&s.protocols.length===n.limits.protocols)throw new Sr('Decode error - map field "protocols" had too many elements');s.protocols.push(t.string());break;case 4:s.publicKey=t.bytes();break;case 5:s.peerRecordEnvelope=t.bytes();break;case 6:{if(null!=n.limits?.metadata&&s.metadata.size===n.limits.metadata)throw new Ar('Decode error - map field "metadata" had too many elements');const r=e.Peer$metadataEntry.codec().decode(t,t.uint32());s.metadata.set(r.key,r.value);break}case 7:{if(null!=n.limits?.tags&&s.tags.size===n.limits.tags)throw new Ar('Decode error - map field "tags" had too many elements');const r=e.Peer$tagsEntry.codec().decode(t,t.uint32(),{limits:{value:n.limits?.tags$value}});s.tags.set(r.key,r.value);break}case 8:s.updated=t.uint64Number();break;default:t.skipType(7&r)}}return s}))),n),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(Zf||(Zf={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.multiaddr&&e.multiaddr.byteLength>0&&(t.uint32(10),t.bytes(e.multiaddr)),null!=e.isCertified&&(t.uint32(16),t.bool(e.isCertified)),null!=e.observed&&(t.uint32(24),t.uint64Number(e.observed)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={multiaddr:f(0)},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.multiaddr=e.bytes();break;case 2:n.isCertified=e.bool();break;case 3:n.observed=e.uint64Number();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(Yf||(Yf={})),function(e){let t;e.codec=()=>(null==t&&(t=Er(((e,t,r={})=>{!1!==r.lengthDelimited&&t.fork(),null!=e.value&&0!==e.value&&(t.uint32(8),t.uint32(e.value)),null!=e.expiry&&(t.uint32(16),t.uint64(e.expiry)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t,r={})=>{const n={value:0},s=null==t?e.len:e.pos+t;for(;e.pos>>3){case 1:n.value=e.uint32();break;case 2:n.expiry=e.uint64();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>$t(t,e.codec()),e.decode=(t,r)=>K(t,e.codec(),r)}(eg||(eg={}));const ag="/",cg=(new TextEncoder).encode(ag),lg=cg[0];class ug{_buf;constructor(e,t){if("string"==typeof e)this._buf=xt(e);else{if(!(e instanceof Uint8Array))throw new Error("Invalid key, should be String of Uint8Array");this._buf=e}if(null==t&&(t=!0),t&&this.clean(),0===this._buf.byteLength||this._buf[0]!==lg)throw new Error("Invalid key")}toString(e="utf8"){return en(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new ug(e.join(ag))}static random(){return new ug(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||"string"==typeof e?new ug(e):"function"==typeof e.uint8Array?new ug(e.uint8Array()):null}clean(){if(null!=this._buf&&0!==this._buf.byteLength||(this._buf=cg),this._buf[0]!==lg){const e=new Uint8Array(this._buf.byteLength+1);e.fill(lg,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===lg;)this._buf=this._buf.subarray(0,-1)}less(e){const t=this.list(),r=e.list();for(let e=0;e{function a(){r?.removeEventListener("abort",u),e.removeEventListener(t,c),null!=n?.errorEvent&&e.removeEventListener(n.errorEvent,l)}const c=e=>{try{if(!1===n?.filter?.(e))return}catch(e){return a(),void o(e)}a(),i(e)},l=e=>{a(),o(e.detail)},u=()=>{a(),o(s)};r?.addEventListener("abort",u),e.addEventListener(t,c),null!=n?.errorEvent&&e.addEventListener(n.errorEvent,l)}))}class hm{deferred;signal;constructor(e){this.signal=e,this.deferred=zn(),this.onAbort=this.onAbort.bind(this),this.signal?.addEventListener("abort",this.onAbort)}onAbort(){this.deferred.reject(this.signal?.reason??new lo)}cleanup(){this.signal?.removeEventListener("abort",this.onAbort)}}class dm{id;fn;options;recipients;status;timeline;controller;constructor(e,t){this.id=`${parseInt(String(1e9*Math.random()),10).toString()}${Date.now()}`,this.status="queued",this.fn=e,this.options=t,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,this.controller.signal,this.onAbort=this.onAbort.bind(this)}abort(e){this.controller.abort(e)}onAbort(){this.recipients.reduce(((e,t)=>e&&!0===t.signal?.aborted),!0)&&(this.controller.abort(new lo),this.cleanup())}async join(e={}){const t=new hm(e.signal);return this.recipients.push(t),e.signal?.addEventListener("abort",this.onAbort),t.deferred.promise}async run(){this.status="running",this.timeline.started=Date.now();try{this.controller.signal.throwIfAborted();const e=await Xn(this.fn({...this.options??{},signal:this.controller.signal}),this.controller.signal);this.recipients.forEach((t=>{t.deferred.resolve(e)})),this.status="complete"}catch(e){this.recipients.forEach((t=>{t.deferred.reject(e)})),this.status="errored"}finally{this.timeline.finished=Date.now(),this.cleanup()}}cleanup(){this.recipients.forEach((e=>{e.cleanup(),e.signal?.removeEventListener("abort",this.onAbort)}))}}class pm extends Rs{concurrency;maxSize;queue;pending;sort;constructor(e={}){super(),this.concurrency=e.concurrency??Number.POSITIVE_INFINITY,this.maxSize=e.maxSize??Number.POSITIVE_INFINITY,this.pending=0,null!=e.metricName&&e.metrics?.registerMetricGroup(e.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})}),this.sort=e.sort,this.queue=[]}tryToStartAnother(){if(0===this.size)return queueMicrotask((()=>{this.safeDispatchEvent("empty")})),0===this.running&&queueMicrotask((()=>{this.safeDispatchEvent("idle")})),!1;if(this.pending0)throw new ny("Unexpected end of input")}():function*(){for(const t of e)r.append(t),yield*c();if(r.byteLength>0)throw new ny("Unexpected end of input")}()}ly.bytes=0,uy.fromReader=(e,t)=>{let r=1;return uy(async function*(){for(;;)try{const{done:t,value:n}=await e.next(r);if(!0===t)return;null!=n&&(yield n)}catch(e){if("ERR_UNDER_READ"===e.code)return{done:!0,value:null};throw e}finally{r=1}}(),{...t??{},onLength:e=>{r=e}})};class hy{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=zn(),this.haveNext=zn()}[Symbol.asyncIterator](){return this}async next(){if(null==this.nextResult&&await this.haveNext.promise,null==this.nextResult)throw new Error("HaveNext promise resolved but nextResult was undefined");const e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=zn(),e}async throw(e){return this.ended=!0,this.error=e,null!=e&&(this.haveNext.promise.catch((()=>{})),this.haveNext.reject(e)),{done:!0,value:void 0}}async return(){const e={done:!0,value:void 0};return this.ended=!0,this.nextResult=e,this.haveNext.resolve(),e}async push(e,t){await this._push(e,t)}async end(e,t){null!=e?await this.throw(e):await this._push(void 0,t)}async _push(e,t){if(null!=e&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;null!=this.nextResult;)await this.readNext.promise;null!=e?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=zn(),await Xn(this.readNext.promise,t?.signal,t)}}class dy extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"}class py extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"}class fy extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"}class gy extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"}function my(e,t={}){const r=function(e,t){const r=new hy;e.sink(r).catch((async e=>{await r.end(e)})),e.sink=async e=>{for await(const t of e)await r.push(t);await r.end()};let n=e.source;null!=e.source[Symbol.iterator]?n=e.source[Symbol.iterator]():null!=e.source[Symbol.asyncIterator]&&(n=e.source[Symbol.asyncIterator]());const s=new Rn;return{read:async e=>{if(e?.signal?.throwIfAborted(),null==e?.bytes){const{done:t,value:r}=await Xn(n.next(),e?.signal);return!0===t?null:r}for(;s.byteLengththis._search(s,i))))yield e}async _search(e,t){try{const r=await this._getTXTRecord(e,t);let n,s;t.visits[e]=!0;const i=function(e){return e.startsWith(Ow.ROOT_PREFIX)?Ow.ROOT_PREFIX:e.startsWith(Ow.BRANCH_PREFIX)?Ow.BRANCH_PREFIX:e.startsWith(Ow.RECORD_PREFIX)?Ow.RECORD_PREFIX:""}(r);try{switch(i){case Ow.ROOT_PREFIX:return n=Ow.parseAndVerifyRoot(r,t.publicKey),await this._search(n,t);case Ow.BRANCH_PREFIX:return s=Ow.parseBranch(r),n=function(e,t){const r={};for(const[n,s]of e.entries())t.visits[s]&&(r[n]=!0);if(Object.keys(r).length===e.length)throw new Error("Unresolvable circular path detected");let n;do{n=Math.floor(Math.random()*e.length)}while(r[n]);return e[n]}(s,t),await this._search(n,t);case Ow.RECORD_PREFIX:return Iw.fromString(r);default:return null}}catch(t){return $w.error(`Failed to search DNS tree ${i} at subdomain ${e}: ${t}`),null}}catch(t){return $w.error(`Failed to retrieve TXT record at subdomain ${e}: ${t}`),null}}async _getTXTRecord(e,t){if(this._DNSTreeCache[e])return this._DNSTreeCache[e];const r=e!==t.domain?`${e}.${t.domain}`:t.domain,n=await this.dns.resolveTXT(r);if(!n.length)throw new Error("Received empty result array while fetching TXT record");if(!n[0].length)throw new Error("Received empty TXT record");const s=n.join("");return this._DNSTreeCache[e]=s,s}}const jw=new bn("peer-discovery-dns");class zw extends Rs{nextPeer;_started;_components;_options;constructor(e,t){super(),this._started=!1,this._components=e,this._options=t;const{enrUrls:r}=t;jw.info("Use following EIP-1459 ENR Tree URLs: ",r)}async start(){jw.info("Starting peer discovery via dns"),this._started=!0,await this.findPeers()}async findPeers(){if(!this.nextPeer){let{enrUrls:e}=this._options;Array.isArray(e)||(e=[e]);const{wantedNodeCapabilityCount:t}=this._options,r=await qw.dnsOverHttp();this.nextPeer=r.getNextPeer.bind(r,e,t)}for await(const e of this.nextPeer()){if(!this._started)return;const{peerInfo:t,shardInfo:r}=e;if(!t)continue;const n={[Py]:{value:this._options.tagValue??50,ttl:this._options.tagTTL??1e8}};let s=!1;await this._components.peerStore.has(t.id)?(await this._components.peerStore.get(t.id)).tags.has(Py)||(s=!0,await this._components.peerStore.merge(t.id,{tags:n})):(s=!0,await this._components.peerStore.save(t.id,{tags:n,...r&&{metadata:{shardInfo:gn(r)}}})),s&&this.dispatchEvent(new CustomEvent("peer",{detail:t}))}}stop(){this._started=!1}get[oh](){return!0}get[Symbol.toStringTag](){return Jr}}function Hw(e){return e.filter((e=>"open"===e.status)).sort(((e,t)=>t.timeline.open-e.timeline.open)).at(0)}const Kw="consumed";class Vw{multicodec;getConnections;addEventListener;log;ongoingCreation=new Set;streamPool=new Map;constructor(e,t,r){this.multicodec=e,this.getConnections=t,this.addEventListener=r,this.log=new bn(`stream-manager:${e}`),this.addEventListener("peer:update",this.handlePeerUpdateStreamPool)}async getStream(e){const t=e.toString(),r=this.streamPool.get(t);r&&(this.streamPool.delete(t),await r);let n=this.getOpenStreamForCodec(e);return n?(this.log.info(`Found existing stream peerId=${t} multicodec=${this.multicodec}`),this.lockStream(t,n),n):(n=await this.createStream(e),this.lockStream(t,n),n)}async createStream(e,t=0){const r=Hw(this.getConnections(e));if(!r)throw new Error(`Failed to get a connection to the peer peerId=${e.toString()} multicodec=${this.multicodec}`);let n,s;for(let i=0;i0&&s[s.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]0&&s[s.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]0?(console.log("Message ".concat(n+1," (ID: ").concat(c.id,") sent successfully.")),xv++,vv&&(vv.textContent=xv.toString()),Lv(c)):console.warn("Failed to send message ".concat(n+1," (ID: ").concat(c.id,"):"),l.failures),[3,5];case 4:return u=h.sent(),console.error("Error sending message ".concat(n+1," (ID: ").concat(c.id,"):"),u),[3,5];case 5:return[4,new Promise((function(e){return setTimeout(e,100)}))];case 6:h.sent(),h.label=7;case 7:return n++,[3,1];case 8:return console.log("Message batch sending complete."),[2]}}))}))},n=function(){return Ov(l,void 0,void 0,(function(){var r;return Dv(this,(function(n){switch(n.label){case 0:return r=kn(pv,{clusterId:42,shard:0}),console.log("Subscribing to messages..."),[4,e.nextFilter.subscribe(r,(function(e){console.log("Raw Waku message received, payload length:",e.payload.length);var r=function(e){try{var t=wv.decode(e);return{id:t.id,timestamp:Number(t.timestamp),senderPeerId:t.senderPeerId,content:t.content}}catch(e){return console.error("Failed to decode message:",e),null}}(e.payload);r?(console.log("Decoded chat message:",r),r.senderPeerId===t?(Cv++,Ev&&(Ev.textContent=Cv.toString()),console.log("Received own message (loopback):",r.id)):(_v++,Sv&&(Sv.textContent=_v.toString()),Lv(r),console.log("Received message from other peer:",r.id))):console.warn("Could not decode received Waku message. Payload might be malformed or not a ChatMessage.")}))];case 1:return n.sent(),console.log("Subscription active."),[2]}}))}))},(s=document.getElementById("sendMessageButton"))&&s.addEventListener("click",(function(){console.log("Send Message Button clicked"),r()})),(i=document.getElementById("searchButton"))&&i.addEventListener("click",(function(){console.log("Search button clicked"),Rv(Nv())})),(o=document.getElementById("searchInput"))&&o.addEventListener("input",(function(){console.log("Search input changed"),Rv(Nv())})),[4,n()];case 2:return u.sent(),console.log("Application setup complete. Click 'Send New Message Batch' to send messages."),[3,4];case 3:return a=u.sent(),console.error("Critical error during app initialization:",a),(c=document.getElementById("peerIdDisplay"))&&(c.textContent="Error connecting to Waku Network."),[3,4];case 4:return[2]}}))}))}()}))})()})();
+(()=>{var __webpack_modules__={194:e=>{e.exports=function(e){if(!e)throw Error("hashlru must have a max value, of type number, greater than 0");var t=0,r=Object.create(null),n=Object.create(null);function s(s,i){r[s]=i,++t>=e&&(t=0,n=r,r=Object.create(null))}return{has:function(e){return void 0!==r[e]||void 0!==n[e]},remove:function(e){void 0!==r[e]&&(r[e]=void 0),void 0!==n[e]&&(n[e]=void 0)},get:function(e){var t=r[e];return void 0!==t?t:void 0!==(t=n[e])?(s(e,t),t):void 0},set:function(e,t){void 0!==r[e]?r[e]=t:s(e,t)},clear:function(){r=Object.create(null),n=Object.create(null)}}}},228:e=>{"use strict";var t=Object.prototype.hasOwnProperty,r="~";function n(){}function s(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function i(e,t,n,i,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new s(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,n,s=[];if(0===this._eventsCount)return s;for(n in e=this._events)t.call(e,n)&&s.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},a.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var s=0,i=n.length,o=new Array(i);s{"use strict";var n=t,s=r(3262),i=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function o(e,t){var r=0,n={};for(t|=0;r