>>0,U[L]=j%f>>>0,j=j/f>>>0;if(j!==0)throw new Error("Non-zero carry");O=H,P++}for(var C=B-O;C!==B&&U[C]===0;)C++;for(var W=u.repeat(T);C>>0,B=new Uint8Array(z);M[T];){var U=t[M.charCodeAt(T)];if(U===255)return;for(var j=0,H=z-1;(U!==0||j>>0,B[H]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");P=j,T++}if(M[T]!==" "){for(var L=z-P;L!==z&&B[L]===0;)L++;for(var C=new Uint8Array(O+(z-L)),W=O;L!==z;)C[W++]=B[L++];return C}}}function I(M){var T=S(M);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:v,decodeUnsafe:S,decode:I}}var k3=B3,K3=k3,q0=K3;var FI=new Uint8Array(0);var U0=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var z0=r=>new TextEncoder().encode(r),B0=r=>new TextDecoder().decode(r);var eh=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},th=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return K0(this,e)}},rh=class{constructor(e){this.decoders=e}or(e){return K0(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},K0=(r,e)=>new rh({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),ih=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new eh(e,t,i),this.decoder=new th(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Yn=({name:r,prefix:e,encode:t,decode:i})=>new ih(r,e,t,i),Ti=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=q0(t,e);return Yn({prefix:r,name:e,encode:i,decode:s=>ci(n(s))})},j3=(r,e,t,i)=>{let n={};for(let b=0;b=8&&(f-=8,o[c++]=255&u>>f)}if(f>=t||255&u<<8-f)throw new SyntaxError("Unexpected end of data");return o},V3=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<Yn({prefix:e,name:r,encode(n){return V3(n,i,t)},decode(n){return j3(n,i,t,r)}});var $3=Yn({prefix:"\0",name:"identity",encode:r=>B0(r),decode:r=>z0(r)});var sh={};Dt(sh,{base2:()=>H3});var H3=Xe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var oh={};Dt(oh,{base8:()=>G3});var G3=Xe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ah={};Dt(ah,{base10:()=>W3});var W3=Ti({prefix:"9",name:"base10",alphabet:"0123456789"});var fh={};Dt(fh,{base16:()=>J3,base16upper:()=>Y3});var J3=Xe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Y3=Xe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ch={};Dt(ch,{base32:()=>Xn,base32hex:()=>e6,base32hexpad:()=>r6,base32hexpadupper:()=>i6,base32hexupper:()=>t6,base32pad:()=>Z3,base32padupper:()=>Q3,base32upper:()=>X3,base32z:()=>n6});var Xn=Xe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),X3=Xe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Z3=Xe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Q3=Xe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),e6=Xe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),t6=Xe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),r6=Xe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),i6=Xe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),n6=Xe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var hh={};Dt(hh,{base36:()=>s6,base36upper:()=>o6});var s6=Ti({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),o6=Ti({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var uh={};Dt(uh,{base58btc:()=>Ur,base58flickr:()=>a6});var Ur=Ti({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),a6=Ti({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var dh={};Dt(dh,{base64:()=>f6,base64pad:()=>c6,base64url:()=>h6,base64urlpad:()=>u6});var f6=Xe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),c6=Xe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),h6=Xe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),u6=Xe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var lh={};Dt(lh,{base256emoji:()=>b6});var j0=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),d6=j0.reduce((r,e,t)=>(r[t]=e,r),[]),l6=j0.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function p6(r){return r.reduce((e,t)=>(e+=d6[t],e),"")}function g6(r){let e=[];for(let t of r){let i=l6[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var b6=Yn({prefix:"\u{1F680}",name:"base256emoji",encode:p6,decode:g6});var vh={};Dt(vh,{sha256:()=>L6,sha512:()=>F6});var v6=H0,V0=128,m6=127,y6=~m6,w6=Math.pow(2,31);function H0(r,e,t){e=e||[],t=t||0;for(var i=t;r>=w6;)e[t++]=r&255|V0,r/=128;for(;r&y6;)e[t++]=r&255|V0,r>>>=7;return e[t]=r|0,H0.bytes=t-i+1,e}var _6=ph,x6=128,$0=127;function ph(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw ph.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&$0)<=x6);return ph.bytes=s-i,t}var E6=Math.pow(2,7),S6=Math.pow(2,14),I6=Math.pow(2,21),M6=Math.pow(2,28),A6=Math.pow(2,35),R6=Math.pow(2,42),T6=Math.pow(2,49),D6=Math.pow(2,56),P6=Math.pow(2,63),N6=function(r){return r[to.decode(r,e),to.decode.bytes],Zn=(r,e,t=0)=>(to.encode(r,e,t),e),Qn=r=>to.encodingLength(r);var mn=(r,e)=>{let t=e.byteLength,i=Qn(r),n=i+Qn(t),s=new Uint8Array(n+t);return Zn(r,s,0),Zn(t,s,i),s.set(e,n),new es(r,t,e,s)},G0=r=>{let e=ci(r),[t,i]=ro(e),[n,s]=ro(e.subarray(i)),o=e.subarray(i+s);if(o.byteLength!==n)throw new Error("Incorrect length");return new es(t,n,o,e)},W0=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&U0(r.bytes,e.bytes),es=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}};var bh=({name:r,code:e,encode:t})=>new gh(r,e,t),gh=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?mn(this.code,t):t.then(i=>mn(this.code,i))}else throw Error("Unknown type, must be binary type")}};var Y0=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),L6=bh({name:"sha2-256",code:18,encode:Y0("SHA-256")}),F6=bh({name:"sha2-512",code:19,encode:Y0("SHA-512")});var mh={};Dt(mh,{identity:()=>z6});var X0=0,q6="identity",Z0=ci,U6=r=>mn(X0,Z0(r)),z6={code:X0,name:q6,encode:Z0,digest:U6};var iM=new TextEncoder,nM=new TextDecoder;var La=class r{constructor(e,t,i,n){this.code=t,this.version=e,this.multihash=i,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Oa,byteLength:Oa,code:Ca,version:Ca,multihash:Ca,bytes:Ca,_baseCache:Oa,asCID:Oa})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==no)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==$6)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,i=mn(e,t);return r.createV1(this.code,i)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&W0(this.multihash,e.multihash)}toString(e){let{bytes:t,version:i,_baseCache:n}=this;switch(i){case 0:return j6(t,n,e||Ur.encoder);default:return V6(t,n,e||Xn.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return G6(/^0\.0/,W6),!!(e&&(e[ep]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof r)return e;if(e!=null&&e.asCID===e){let{version:t,code:i,multihash:n,bytes:s}=e;return new r(t,i,n,s||Q0(t,i,n.bytes))}else if(e!=null&&e[ep]===!0){let{version:t,multihash:i,code:n}=e,s=G0(i);return r.create(t,n,s)}else return null}static create(e,t,i){if(typeof t!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(t!==no)throw new Error(`Version 0 CID must use dag-pb (code: ${no}) block encoding`);return new r(e,t,i,i.bytes)}case 1:{let n=Q0(e,t,i.bytes);return new r(e,t,i,n)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,no,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,i]=r.decodeFirst(e);if(i.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),i=t.size-t.multihashSize,n=ci(e.subarray(i,i+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=n.subarray(t.multihashSize-t.digestSize),o=new es(t.multihashCode,t.digestSize,s,n);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,i=()=>{let[v,S]=ro(e.subarray(t));return t+=S,v},n=i(),s=no;if(n===18?(n=0,t=0):n===1&&(s=i()),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let o=t,f=i(),u=i(),c=t+u,b=c-o;return{version:n,codec:s,multihashCode:f,digestSize:u,multihashSize:b,size:c}}static parse(e,t){let[i,n]=K6(e,t),s=r.decode(n);return s._baseCache.set(i,e),s}},K6=(r,e)=>{switch(r[0]){case"Q":{let t=e||Ur;return[Ur.prefix,t.decode(`${Ur.prefix}${r}`)]}case Ur.prefix:{let t=e||Ur;return[Ur.prefix,t.decode(r)]}case Xn.prefix:{let t=e||Xn;return[Xn.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},j6=(r,e,t)=>{let{prefix:i}=t;if(i!==Ur.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(i);if(n==null){let s=t.encode(r).slice(1);return e.set(i,s),s}else return n},V6=(r,e,t)=>{let{prefix:i}=t,n=e.get(i);if(n==null){let s=t.encode(r);return e.set(i,s),s}else return n},no=112,$6=18,Q0=(r,e,t)=>{let i=Qn(r),n=i+Qn(e),s=new Uint8Array(n+t.byteLength);return Zn(r,s,0),Zn(e,s,i),s.set(t,n),s},ep=Symbol.for("@ipld/js-cid/CID"),Ca={writable:!1,configurable:!1,enumerable:!0},Oa={writable:!1,enumerable:!1,configurable:!1},H6="0.0.0-dev",G6=(r,e)=>{if(r.test(H6))console.warn(e);else throw new Error(e)},W6=`CID.isCID(v) is deprecated and will be removed in the next major release.
+Following code pattern:
+
+if (CID.isCID(value)) {
+ doSomethingWithCID(value)
+}
+
+Is replaced with:
+
+const cid = CID.asCID(value)
+if (cid) {
+ // Make sure to use cid instead of value
+ doSomethingWithCID(cid)
+}
+`;var yh={...nh,...sh,...oh,...ah,...fh,...ch,...hh,...uh,...dh,...lh},dM={...vh,...mh};function rp(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var tp=rp("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),wh=rp("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=eo(r.length);for(let t=0;t"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new nw:typeof navigator<"u"?dp(navigator.userAgent):hw()}function fw(r){return r!==""&&aw.reduce(function(e,t){var i=t[0],n=t[1];if(e)return e;var s=n.exec(r);return!!s&&[i,s]},!1)}function dp(r){var e=fw(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new iw;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(r){return r.message}return null}var Bp=Nw(),Ih;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(Ih||(Ih={}));var or;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(or||(or={}));var kp="0123456789abcdef",at=class r{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){let i=e.toLowerCase();Ka[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(zp>Ka[i])&&console.log.apply(console,t)}debug(...e){this._log(r.levels.DEBUG,e)}info(...e){this._log(r.levels.INFO,e)}warn(...e){this._log(r.levels.WARNING,e)}makeError(e,t,i){if(Up)return this.makeError("censored error",t,{});t||(t=r.errors.UNKNOWN_ERROR),i||(i={});let n=[];Object.keys(i).forEach(u=>{let c=i[u];try{if(c instanceof Uint8Array){let b="";for(let v=0;v>4],b+=kp[c[v]&15];n.push(u+"=Uint8Array(0x"+b+")")}else n.push(u+"="+JSON.stringify(c))}catch{n.push(u+"="+JSON.stringify(i[u].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);let s=e,o="";switch(t){case or.NUMERIC_FAULT:{o="NUMERIC_FAULT";let u=e;switch(u){case"overflow":case"underflow":case"division-by-zero":o+="-"+u;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case or.CALL_EXCEPTION:case or.INSUFFICIENT_FUNDS:case or.MISSING_NEW:case or.NONCE_EXPIRED:case or.REPLACEMENT_UNDERPRICED:case or.TRANSACTION_REPLACED:case or.UNPREDICTABLE_GAS_LIMIT:o=t;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");let f=new Error(e);return f.reason=s,f.code=t,Object.keys(i).forEach(function(u){f[u]=i[u]}),f}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,r.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,n){e||this.throwError(t,i,n)}assertArgument(e,t,i,n){e||this.throwArgumentError(t,i,n)}checkNormalize(e){e==null&&(e="platform missing String.prototype.normalize"),Bp&&this.throwError("platform missing String.prototype.normalize",r.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Bp})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",et&&this.throwError("too many arguments"+i,r.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",r.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return Sh||(Sh=new r(Fp)),Sh}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),qp){if(!e)return;this.globalLogger().throwError("error censorship permanent",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Up=!!e,qp=!!t}static setLogLevel(e){let t=Ka[e.toLowerCase()];if(t==null){r.globalLogger().warn("invalid log level - "+e);return}zp=t}static from(e){return new r(e)}};at.errors=or;at.levels=Ih;var Kp="bytes/5.7.0";var nt=new at(Kp);function Vp(r){return!!r.toHexString}function is(r){return r.slice||(r.slice=function(){let e=Array.prototype.slice.call(arguments);return is(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function $p(r){return ar(r)&&!(r.length%2)||Ah(r)}function jp(r){return typeof r=="number"&&r==r&&r%1===0}function Ah(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!jp(r.length)||r.length<0)return!1;for(let e=0;e=256)return!1}return!0}function We(r,e){if(e||(e={}),typeof r=="number"){nt.checkSafeUint53(r,"invalid arrayify value");let t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),is(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Vp(r)&&(r=r.toHexString()),ar(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":nt.throwArgumentError("hex data is odd-length","value",r));let i=[];for(let n=0;nWe(n)),t=e.reduce((n,s)=>n+s.length,0),i=new Uint8Array(t);return e.reduce((n,s)=>(i.set(s,n),n+s.length),0),is(i)}function Cw(r,e){r=We(r),r.length>e&&nt.throwArgumentError("value out of range","value",arguments[0]);let t=new Uint8Array(e);return t.set(r,e-r.length),is(t)}function ar(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}var Mh="0123456789abcdef";function _t(r,e){if(e||(e={}),typeof r=="number"){nt.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=Mh[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Vp(r))return r.toHexString();if(ar(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":nt.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(Ah(r)){let t="0x";for(let i=0;i>4]+Mh[n&15]}return t}return nt.throwArgumentError("invalid hexlify value","value",r)}function ja(r){if(typeof r!="string")r=_t(r);else if(!ar(r)||r.length%2)return null;return(r.length-2)/2}function Va(r,e,t){return typeof r!="string"?r=_t(r):(!ar(r)||r.length%2)&&nt.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function Di(r,e){for(typeof r!="string"?r=_t(r):ar(r)||nt.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&nt.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function $a(r){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if($p(r)){let t=We(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=_t(t.slice(0,32)),e.s=_t(t.slice(32,64))):t.length===65?(e.r=_t(t.slice(0,32)),e.s=_t(t.slice(32,64)),e.v=t[64]):nt.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:nt.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=_t(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){let n=Cw(We(e._vs),32);e._vs=_t(n);let s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&nt.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),n[0]&=127;let o=_t(n);e.s==null?e.s=o:e.s!==o&&nt.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?nt.throwArgumentError("signature missing v and recoveryParam","signature",r):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{let n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&nt.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!ar(e.r)?nt.throwArgumentError("signature missing or invalid r","signature",r):e.r=Di(e.r,32),e.s==null||!ar(e.s)?nt.throwArgumentError("signature missing or invalid s","signature",r):e.s=Di(e.s,32);let t=We(e.s);t[0]>=128&&nt.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);let i=_t(t);e._vs&&(ar(e._vs)||nt.throwArgumentError("signature invalid _vs","signature",r),e._vs=Di(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&nt.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function ns(r){return"0x"+Hp.default.keccak_256(We(r))}var Jp=qe(Ph());var Wp="bignumber/5.7.0";var Ow=Jp.default.BN,sA=new at(Wp);function Nh(r){return new Ow(r,36).toString(16)}var Yp="strings/5.7.0";var Xp=new at(Yp),oo;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(oo||(oo={}));var wn;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(wn||(wn={}));function Fw(r,e,t,i,n){return Xp.throwArgumentError(`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function Zp(r,e,t,i,n){if(r===wn.BAD_PREFIX||r===wn.UNEXPECTED_CONTINUE){let s=0;for(let o=e+1;o>6===2;o++)s++;return s}return r===wn.OVERRUN?t.length-e-1:0}function qw(r,e,t,i,n){return r===wn.OVERLONG?(i.push(n),0):(i.push(65533),Zp(r,e,t,i,n))}var Uw=Object.freeze({error:Fw,ignore:Zp,replace:qw});function ao(r,e=oo.current){e!=oo.current&&(Xp.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i>6|192),t.push(n&63|128);else if((n&64512)==55296){i++;let s=r.charCodeAt(i);if(i>=r.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");let o=65536+((n&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(n>>12|224),t.push(n>>6&63|128),t.push(n&63|128)}return We(t)}var Qp=`Ethereum Signed Message:
+`;function Ha(r){return typeof r=="string"&&(r=ao(r)),ns(Rh([ao(Qp),ao(String(r.length)),r]))}var e1="address/5.7.0";var fo=new at(e1);function t1(r){ar(r,20)||fo.throwArgumentError("invalid address","address",r),r=r.toLowerCase();let e=r.substring(2).split(""),t=new Uint8Array(40);for(let n=0;n<40;n++)t[n]=e[n].charCodeAt(0);let i=We(ns(t));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}var Bw=9007199254740991;function kw(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}var Ch={};for(let r=0;r<10;r++)Ch[String(r)]=String(r);for(let r=0;r<26;r++)Ch[String.fromCharCode(65+r)]=String(10+r);var r1=Math.floor(kw(Bw));function Kw(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>Ch[i]).join("");for(;e.length>=r1;){let i=e.substring(0,r1);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function i1(r){let e=null;if(typeof r!="string"&&fo.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=t1(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&fo.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==Kw(r)&&fo.throwArgumentError("bad icap checksum","address",r),e=Nh(r.substring(4));e.length<40;)e="0"+e;e=t1("0x"+e)}else fo.throwArgumentError("invalid address","address",r);return e}var n1="properties/5.7.0";var OA=new at(n1);function ss(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}var Ce=qe(Ph()),$r=qe(lo());function ds(r,e,t){return t={path:e,exports:{},require:function(i,n){return u8(i,n??t.path)}},r(t,t.exports),t.exports}function u8(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Hh=k1;function k1(r,e){if(!r)throw new Error(e||"Assertion failed")}k1.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var ur=ds(function(r,e){"use strict";var t=e;function i(o,f){if(Array.isArray(o))return o.slice();if(!o)return[];var u=[];if(typeof o!="string"){for(var c=0;c>8,S=b&255;v?u.push(v,S):u.push(S)}return u}t.toArray=i;function n(o){return o.length===1?"0"+o:o}t.zero2=n;function s(o){for(var f="",u=0;u(S>>1)-1?T=(S>>1)-O:T=O,I.isubn(T)):T=0,v[M]=T,I.iushrn(1)}return v}t.getNAF=i;function n(u,c){var b=[[],[]];u=u.clone(),c=c.clone();for(var v=0,S=0,I;u.cmpn(-v)>0||c.cmpn(-S)>0;){var M=u.andln(3)+v&3,T=c.andln(3)+S&3;M===3&&(M=-1),T===3&&(T=-1);var O;M&1?(I=u.andln(7)+v&7,(I===3||I===5)&&T===2?O=-M:O=M):O=0,b[0].push(O);var P;T&1?(I=c.andln(7)+S&7,(I===3||I===5)&&M===2?P=-T:P=T):P=0,b[1].push(P),2*v===O+1&&(v=1-v),2*S===P+1&&(S=1-S),u.iushrn(1),c.iushrn(1)}return b}t.getJSF=n;function s(u,c,b){var v="_"+c;u.prototype[c]=function(){return this[v]!==void 0?this[v]:this[v]=b.call(this)}}t.cachedProperty=s;function o(u){return typeof u=="string"?t.toArray(u,"hex"):u}t.parseBytes=o;function f(u){return new Ce.default(u,"hex","le")}t.intFromLE=f}),Xa=zt.getNAF,d8=zt.getJSF,Za=zt.assert;function Oi(r,e){this.type=r,this.p=new Ce.default(e.p,16),this.red=e.prime?Ce.default.red(e.prime):Ce.default.mont(this.p),this.zero=new Ce.default(0).toRed(this.red),this.one=new Ce.default(1).toRed(this.red),this.two=new Ce.default(2).toRed(this.red),this.n=e.n&&new Ce.default(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var xn=Oi;Oi.prototype.point=function(){throw new Error("Not implemented")};Oi.prototype.validate=function(){throw new Error("Not implemented")};Oi.prototype._fixedNafMul=function(e,t){Za(e.precomputed);var i=e._getDoubles(),n=Xa(t,1,this._bitLength),s=(1<=f;c--)u=(u<<1)+n[c];o.push(u)}for(var b=this.jpoint(null,null,null),v=this.jpoint(null,null,null),S=s;S>0;S--){for(f=0;f=0;u--){for(var c=0;u>=0&&o[u]===0;u--)c++;if(u>=0&&c++,f=f.dblp(c),u<0)break;var b=o[u];Za(b!==0),e.type==="affine"?b>0?f=f.mixedAdd(s[b-1>>1]):f=f.mixedAdd(s[-b-1>>1].neg()):b>0?f=f.add(s[b-1>>1]):f=f.add(s[-b-1>>1].neg())}return e.type==="affine"?f.toP():f};Oi.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,u=this._wnafT3,c=0,b,v,S;for(b=0;b=1;b-=2){var M=b-1,T=b;if(o[M]!==1||o[T]!==1){u[M]=Xa(i[M],o[M],this._bitLength),u[T]=Xa(i[T],o[T],this._bitLength),c=Math.max(u[M].length,c),c=Math.max(u[T].length,c);continue}var O=[t[M],null,null,t[T]];t[M].y.cmp(t[T].y)===0?(O[1]=t[M].add(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg())):t[M].y.cmp(t[T].y.redNeg())===0?(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].add(t[T].neg())):(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg()));var P=[-3,-1,-5,-7,0,7,5,1,3],z=d8(i[M],i[T]);for(c=Math.max(z[0].length,c),u[M]=new Array(c),u[T]=new Array(c),v=0;v=0;b--){for(var L=0;b>=0;){var C=!0;for(v=0;v=0&&L++,j=j.dblp(L),b<0)break;for(v=0;v0?S=f[v][W-1>>1]:W<0&&(S=f[v][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(b=0;b=Math.ceil((e.bitLength()+1)/t.step):!1};Xt.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s=0&&(I=c,M=b),v.negative&&(v=v.neg(),S=S.neg()),I.negative&&(I=I.neg(),M=M.neg()),[{a:v,b:S},{a:I,b:M}]};Zt.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),u=o.mul(n.a),c=s.mul(i.b),b=o.mul(n.b),v=e.sub(f).sub(u),S=c.add(b).neg();return{k1:v,k2:S}};Zt.prototype.pointFromX=function(e,t){e=new Ce.default(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};Zt.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};Zt.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};ft.prototype.isInfinity=function(){return this.inf};ft.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(this.x.cmp(e.x)===0)return this.curve.point(null,null);var t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};ft.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(e.cmpn(0)===0)return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)};ft.prototype.getX=function(){return this.x.fromRed()};ft.prototype.getY=function(){return this.y.fromRed()};ft.prototype.mul=function(e){return e=new Ce.default(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)};ft.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};ft.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};ft.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||this.x.cmp(e.x)===0&&this.y.cmp(e.y)===0)};ft.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};ft.prototype.toJ=function(){if(this.inf)return this.curve.jpoint(null,null,null);var e=this.curve.jpoint(this.x,this.y,this.curve.one);return e};function gt(r,e,t,i){xn.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Ce.default(0)):(this.x=new Ce.default(e,16),this.y=new Ce.default(t,16),this.z=new Ce.default(i,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}Gh(gt,xn.BasePoint);Zt.prototype.jpoint=function(e,t,i){return new gt(this,e,t,i)};gt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};gt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};gt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),u=n.redSub(s),c=o.redSub(f);if(u.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=u.redSqr(),v=b.redMul(u),S=n.redMul(b),I=c.redSqr().redIAdd(v).redISub(S).redISub(S),M=c.redMul(S.redISub(I)).redISub(o.redMul(v)),T=this.z.redMul(e.z).redMul(u);return this.curve.jpoint(I,M,T)};gt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),u=s.redSub(o);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var c=f.redSqr(),b=c.redMul(f),v=i.redMul(c),S=u.redSqr().redIAdd(b).redISub(v).redISub(v),I=u.redMul(v.redISub(S)).redISub(s.redMul(b)),M=this.z.redMul(f);return this.curve.jpoint(S,I,M)};gt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};gt.prototype.inspect=function(){return this.isInfinity()?"":""};gt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Ja=ds(function(r,e){"use strict";var t=e;t.base=xn,t.short=p8,t.mont=null,t.edwards=null}),Ya=ds(function(r,e){"use strict";var t=e,i=zt.assert;function n(f){f.type==="short"?this.curve=new Ja.short(f):f.type==="edwards"?this.curve=new Ja.edwards(f):this.curve=new Ja.mont(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function s(f,u){Object.defineProperty(t,f,{configurable:!0,enumerable:!0,get:function(){var c=new n(u);return Object.defineProperty(t,f,{configurable:!0,enumerable:!0,value:c}),c}})}s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:$r.default.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:$r.default.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:$r.default.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:$r.default.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:$r.default.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:$r.default.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:$r.default.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var o;try{o=null.crash()}catch{o=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:$r.default.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function Ci(r){if(!(this instanceof Ci))return new Ci(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ur.toArray(r.entropy,r.entropyEnc||"hex"),t=ur.toArray(r.nonce,r.nonceEnc||"hex"),i=ur.toArray(r.pers,r.persEnc||"hex");Hh(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var K1=Ci;Ci.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var s=0;s=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1};Ci.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=ur.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length"};var g8=zt.assert;function Qa(r,e){if(r instanceof Qa)return r;this._importDER(r,e)||(g8(r.r&&r.s,"Signature without r or s"),this.r=new Ce.default(r.r,16),this.s=new Ce.default(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var ef=Qa;function b8(){this.place=0}function jh(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function B1(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}Qa.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=B1(t),i=B1(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Vh(n,t.length),n=n.concat(t),n.push(2),Vh(n,i.length);var s=n.concat(i),o=[48];return Vh(o,s.length),o=o.concat(s),zt.encode(o,e)};var v8=function(){throw new Error("unsupported")},j1=zt.assert;function Yt(r){if(!(this instanceof Yt))return new Yt(r);typeof r=="string"&&(j1(Object.prototype.hasOwnProperty.call(Ya,r),"Unknown curve "+r),r=Ya[r]),r instanceof Ya.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var m8=Yt;Yt.prototype.keyPair=function(e){return new Wh(this,e)};Yt.prototype.keyFromPrivate=function(e,t){return Wh.fromPrivate(this,e,t)};Yt.prototype.keyFromPublic=function(e,t){return Wh.fromPublic(this,e,t)};Yt.prototype.genKeyPair=function(e){e||(e={});for(var t=new K1({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||v8(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Ce.default(2));;){var s=new Ce.default(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};Yt.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};Yt.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new Ce.default(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),u=new K1({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),c=this.n.sub(new Ce.default(1)),b=0;;b++){var v=n.k?n.k(b):new Ce.default(u.generate(this.n.byteLength()));if(v=this._truncateToN(v,!0),!(v.cmpn(1)<=0||v.cmp(c)>=0)){var S=this.g.mul(v);if(!S.isInfinity()){var I=S.getX(),M=I.umod(this.n);if(M.cmpn(0)!==0){var T=v.invm(this.n).mul(M.mul(t.getPrivate()).iadd(e));if(T=T.umod(this.n),T.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(M)!==0?2:0);return n.canonical&&T.cmp(this.nh)>0&&(T=this.n.sub(T),O^=1),new ef({r:M,s:T,recoveryParam:O})}}}}}};Yt.prototype.verify=function(e,t,i,n){e=this._truncateToN(new Ce.default(e,16)),i=this.keyFromPublic(i,n),t=new ef(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var f=o.invm(this.n),u=f.mul(e).umod(this.n),c=f.mul(s).umod(this.n),b;return this.curve._maxwellTrick?(b=this.g.jmulAdd(u,i.getPublic(),c),b.isInfinity()?!1:b.eqXToP(s)):(b=this.g.mulAdd(u,i.getPublic(),c),b.isInfinity()?!1:b.getX().umod(this.n).cmp(s)===0)};Yt.prototype.recoverPubKey=function(r,e,t,i){j1((3&t)===t,"The recovery param is more than two bits"),e=new ef(e,i);var n=this.n,s=new Ce.default(r),o=e.r,f=e.s,u=t&1,c=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");c?o=this.curve.pointFromX(o.add(this.curve.n),u):o=this.curve.pointFromX(o,u);var b=e.r.invm(n),v=n.sub(s).mul(b).umod(n),S=f.mul(b).umod(n);return this.g.mulAdd(v,o,S)};Yt.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new ef(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var y8=ds(function(r,e){"use strict";var t=e;t.version="6.5.4",t.utils=zt,t.rand=function(){throw new Error("unsupported")},t.curve=Ja,t.curves=Ya,t.ec=m8,t.eddsa=null}),V1=y8.ec;var $1="signing-key/5.7.0";var Yh=new at($1),Jh=null;function Hr(){return Jh||(Jh=new V1("secp256k1")),Jh}var Xh=class{constructor(e){ss(this,"curve","secp256k1"),ss(this,"privateKey",_t(e)),ja(this.privateKey)!==32&&Yh.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let t=Hr().keyFromPrivate(We(this.privateKey));ss(this,"publicKey","0x"+t.getPublic(!1,"hex")),ss(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),ss(this,"_isSigningKey",!0)}_addPoint(e){let t=Hr().keyFromPublic(We(this.publicKey)),i=Hr().keyFromPublic(We(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){let t=Hr().keyFromPrivate(We(this.privateKey)),i=We(e);i.length!==32&&Yh.throwArgumentError("bad digest length","digest",e);let n=t.sign(i,{canonical:!0});return $a({recoveryParam:n.recoveryParam,r:Di("0x"+n.r.toString(16),32),s:Di("0x"+n.s.toString(16),32)})}computeSharedSecret(e){let t=Hr().keyFromPrivate(We(this.privateKey)),i=Hr().keyFromPublic(We(Zh(e)));return Di("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}};function H1(r,e){let t=$a(e),i={r:We(t.r),s:We(t.s)};return"0x"+Hr().recoverPubKey(We(r),i,t.recoveryParam).encode("hex",!1)}function Zh(r,e){let t=We(r);if(t.length===32){let i=new Xh(t);return e?"0x"+Hr().keyFromPrivate(t).getPublic(!0,"hex"):i.publicKey}else{if(t.length===33)return e?_t(t):"0x"+Hr().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+Hr().keyFromPublic(t).getPublic(!0,"hex"):_t(t)}return Yh.throwArgumentError("invalid public or private key","key","[REDACTED]")}var G1="transactions/5.7.0";var pR=new at(G1),W1;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(W1||(W1={}));function w8(r){let e=Zh(r);return i1(Va(ns(Va(e,1)),12))}function J1(r,e){return w8(H1(We(r),e))}var Eu=qe(ig()),xb=qe(cg()),Eo=qe(Js()),ws=qe(ug()),Sf=qe(gg());var Eb=qe(fb());var cb={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var E4=":";function So(r){let[e,t]=r.split(E4);return{namespace:e,reference:t}}function Sb(r,e){return r.includes(":")?[r]:e.chains||[]}var S4=Object.defineProperty,hb=Object.getOwnPropertySymbols,I4=Object.prototype.hasOwnProperty,M4=Object.prototype.propertyIsEnumerable,ub=(r,e,t)=>e in r?S4(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,db=(r,e)=>{for(var t in e||(e={}))I4.call(e,t)&&ub(r,t,e[t]);if(hb)for(var t of hb(e))M4.call(e,t)&&ub(r,t,e[t]);return r},A4="ReactNative",Ft={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"};var R4="js";function Io(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Tn(){return!(0,wi.getDocument)()&&!!(0,wi.getNavigator)()&&navigator.product===A4}function _s(){return!Io()&&!!(0,wi.getNavigator)()&&!!(0,wi.getDocument)()}function Mo(){return Tn()?Ft.reactNative:Io()?Ft.node:_s()?Ft.browser:Ft.unknown}function Ib(){var r;try{return Tn()&&typeof window<"u"&&typeof window?.Application<"u"?(r=window.Application)==null?void 0:r.applicationId:void 0}catch{return}}function T4(r,e){let t=ys.parse(r);return t=db(db({},t),e),r=ys.stringify(t),r}function xs(){return(0,_b.getWindowMetadata)()||{name:"",description:"",url:"",icons:[""]}}function D4(){if(Mo()===Ft.reactNative&&typeof window<"u"&&typeof window?.Platform<"u"){let{OS:t,Version:i}=window.Platform;return[t,i].join("-")}let r=lp();if(r===null)return"unknown";let e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function P4(){var r;let e=Mo();return e===Ft.browser?[e,((r=(0,wi.getLocation)())==null?void 0:r.host)||"unknown"].join(":"):e}function Su(r,e,t){let i=D4(),n=P4();return[[r,e].join("-"),[R4,t].join("-"),i,n].join("/")}function Mb({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:f}){let u=t.split("?"),c=Su(r,e,i),b={auth:n,ua:c,projectId:s,useOnCloseEvent:o||void 0,origin:f||void 0},v=T4(u[1]||"",b);return u[0]+"?"+v}function An(r,e){return r.filter(t=>e.includes(t)).length===r.length}function Iu(r){return Object.fromEntries(r.entries())}function Mu(r){return new Map(Object.entries(r))}function _i(r=yi.FIVE_MINUTES,e){let t=(0,yi.toMiliseconds)(r||yi.FIVE_MINUTES),i,n,s;return{resolve:o=>{s&&i&&(clearTimeout(s),i(o))},reject:o=>{s&&n&&(clearTimeout(s),n(o))},done:()=>new Promise((o,f)=>{s=setTimeout(()=>{f(new Error(e))},t),i=o,n=f})}}function Dn(r,e,t){return new Promise(async(i,n)=>{let s=setTimeout(()=>n(new Error(t)),e);try{let o=await r;i(o)}catch(o){n(o)}clearTimeout(s)})}function Ab(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${r}`)}function Rb(r){return Ab("topic",r)}function Tb(r){return Ab("id",r)}function If(r){let[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function st(r,e){return(0,yi.fromMiliseconds)((e||Date.now())+(0,yi.toMiliseconds)(r))}function Xr(r){return Date.now()>=(0,yi.toMiliseconds)(r)}function Oe(r,e){return`${r}${e?`:${e}`:""}`}function N4(r=[],e=[]){return[...new Set([...r,...e])]}async function Db({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;let n=typeof t=="string"?JSON.parse(t):t,s=n?.href;if(typeof s!="string")return;let o=C4(s,r,e),f=Mo();if(f===Ft.browser){if(!((i=(0,wi.getDocument)())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,O4()?"_blank":"_self","noreferrer noopener")}else f===Ft.reactNative&&typeof window?.Linking<"u"&&await window.Linking.openURL(o)}catch(n){console.error(n)}}function C4(r,e,t){let i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){let s=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${L4(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function Pb(r,e){let t="";try{if(_s()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function Au(r,e){if(!r.includes(e))return null;let t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Ru(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function Ao(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function O4(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function L4(r,e=!1){let t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function Nb(r){return Buffer.from(r,"base64").toString("utf-8")}var F4="https://rpc.walletconnect.org/v1";async function q4(r,e,t,i,n,s){switch(t.t){case"eip191":return U4(r,e,t.s);case"eip1271":return await z4(r,e,t.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function U4(r,e,t){return J1(Ha(e),t).toLowerCase()===r.toLowerCase()}async function z4(r,e,t,i,n,s){let o=So(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{let f="0x1626ba7e",u="0000000000000000000000000000000000000000000000000000000000000040",c="0000000000000000000000000000000000000000000000000000000000000041",b=t.substring(2),v=Ha(e).substring(2),S=f+v+u+c+b,I=await fetch(`${s||F4}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:B4(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:S},"latest"]})}),{result:M}=await I.json();return M?M.slice(0,f.length).toLowerCase()===f.toLowerCase():!1}catch(f){return console.error("isValidEip1271Signature: ",f),!1}}function B4(){return Date.now()+Math.floor(Math.random()*1e3)}var k4=Object.defineProperty,K4=Object.defineProperties,j4=Object.getOwnPropertyDescriptors,lb=Object.getOwnPropertySymbols,V4=Object.prototype.hasOwnProperty,$4=Object.prototype.propertyIsEnumerable,pb=(r,e,t)=>e in r?k4(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,H4=(r,e)=>{for(var t in e||(e={}))V4.call(e,t)&&pb(r,t,e[t]);if(lb)for(var t of lb(e))$4.call(e,t)&&pb(r,t,e[t]);return r},G4=(r,e)=>K4(r,j4(e)),W4="did:pkh:",Tu=r=>r?.split(":"),J4=r=>{let e=r&&Tu(r);if(e)return r.includes(W4)?e[3]:e[1]},Mf=r=>{let e=r&&Tu(r);if(e)return e[2]+":"+e[3]},Ro=r=>{let e=r&&Tu(r);if(e)return e.pop()};async function Du(r){let{cacao:e,projectId:t}=r,{s:i,p:n}=e,s=Pu(n,n.iss),o=Ro(n.iss);return await q4(o,s,i,Mf(n.iss),t)}var Pu=(r,e)=>{let t=`${r.domain} wants you to sign in with your Ethereum account:`,i=Ro(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0,s=`URI: ${r.aud||r.uri}`,o=`Version: ${r.version}`,f=`Chain ID: ${J4(e)}`,u=`Nonce: ${r.nonce}`,c=`Issued At: ${r.iat}`,b=r.exp?`Expiration Time: ${r.exp}`:void 0,v=r.nbf?`Not Before: ${r.nbf}`:void 0,S=r.requestId?`Request ID: ${r.requestId}`:void 0,I=r.resources?`Resources:${r.resources.map(T=>`
+- ${T}`).join("")}`:void 0,M=To(r.resources);if(M){let T=xo(M);n=r_(n,T)}return[t,i,"",n,"",s,o,f,u,c,b,v,S,I].filter(T=>T!=null).join(`
+`)};function Y4(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function X4(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function Rn(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");let e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{let i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{let s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function Z4(r,e,t,i={}){return t?.sort((n,s)=>n.localeCompare(s)),{att:{[r]:Q4(e,t,i)}}}function Q4(r,e,t={}){e=e?.sort((n,s)=>n.localeCompare(s));let i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function Cb(r){return Rn(r),`urn:recap:${Y4(r).replace(/=/g,"")}`}function xo(r){let e=X4(r.replace("urn:recap:",""));return Rn(e),e}function Ob(r,e,t){let i=Z4(r,e,t);return Cb(i)}function e_(r){return r&&r.includes("urn:recap:")}function Lb(r,e){let t=xo(r),i=xo(e),n=t_(t,i);return Cb(n)}function t_(r,e){Rn(r),Rn(e);let t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return t.forEach(n=>{var s,o;Object.keys(((s=r.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((f,u)=>f.localeCompare(u)).forEach(f=>{var u,c;i.att[n]=G4(H4({},i.att[n]),{[f]:((u=r.att[n])==null?void 0:u[f])||((c=e.att[n])==null?void 0:c[f])})})}),i}function r_(r="",e){Rn(e);let t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;let i=[],n=0;Object.keys(e.att).forEach(f=>{let u=Object.keys(e.att[f]).map(v=>({ability:v.split("/")[0],action:v.split("/")[1]}));u.sort((v,S)=>v.action.localeCompare(S.action));let c={};u.forEach(v=>{c[v.ability]||(c[v.ability]=[]),c[v.ability].push(v.action)});let b=Object.keys(c).map(v=>(n++,`(${n}) '${v}': '${c[v].join("', '")}' for '${f}'.`));i.push(b.join(", ").replace(".,","."))});let s=i.join(" "),o=`${t}${s}`;return`${r?r+" ":""}${o}`}function Nu(r){var e;let t=xo(r);Rn(t);let i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function Cu(r){let e=xo(r);Rn(e);let t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function To(r){if(!r)return;let e=r?.[r.length-1];return e_(e)?e:void 0}var Fb="base10",It="base16",Zr="base64pad",Es="base64url",Do="utf8",qb=0,lr=1,Ss=2,i_=0,gb=1,_o=12,Ou=32;function Ub(){let r=Sf.generateKeyPair();return{privateKey:Ze(r.secretKey,It),publicKey:Ze(r.publicKey,It)}}function Af(){let r=(0,Eo.randomBytes)(Ou);return Ze(r,It)}function zb(r,e){let t=Sf.sharedKey(rt(r,It),rt(e,It),!0),i=new xb.HKDF(ws.SHA256,t).expand(Ou);return Ze(i,It)}function Is(r){let e=(0,ws.hash)(rt(r,It));return Ze(e,It)}function pr(r){let e=(0,ws.hash)(rt(r,Do));return Ze(e,It)}function Bb(r){return rt(`${r}`,Fb)}function ki(r){return Number(Ze(r,Fb))}function kb(r){let e=Bb(typeof r.type<"u"?r.type:qb);if(ki(e)===lr&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");let t=typeof r.senderPublicKey<"u"?rt(r.senderPublicKey,It):void 0,i=typeof r.iv<"u"?rt(r.iv,It):(0,Eo.randomBytes)(_o),n=new Eu.ChaCha20Poly1305(rt(r.symKey,It)).seal(i,rt(r.message,Do));return $b({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:r.encoding})}function Kb(r,e){let t=Bb(Ss),i=(0,Eo.randomBytes)(_o),n=rt(r,Do);return $b({type:t,sealed:n,iv:i,encoding:e})}function jb(r){let e=new Eu.ChaCha20Poly1305(rt(r.symKey,It)),{sealed:t,iv:i}=Ms({encoded:r.encoded,encoding:r?.encoding}),n=e.open(i,t);if(n===null)throw new Error("Failed to decrypt");return Ze(n,Do)}function Vb(r,e){let{sealed:t}=Ms({encoded:r,encoding:e});return Ze(t,Do)}function $b(r){let{encoding:e=Zr}=r;if(ki(r.type)===Ss)return Ze(vn([r.type,r.sealed]),e);if(ki(r.type)===lr){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Ze(vn([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return Ze(vn([r.type,r.iv,r.sealed]),e)}function Ms(r){let{encoded:e,encoding:t=Zr}=r,i=rt(e,t),n=i.slice(i_,gb),s=gb;if(ki(n)===lr){let c=s+Ou,b=c+_o,v=i.slice(s,c),S=i.slice(c,b),I=i.slice(b);return{type:n,sealed:I,iv:S,senderPublicKey:v}}if(ki(n)===Ss){let c=i.slice(s),b=(0,Eo.randomBytes)(_o);return{type:n,sealed:c,iv:b}}let o=s+_o,f=i.slice(s,o),u=i.slice(o);return{type:n,sealed:u,iv:f}}function Hb(r,e){let t=Ms({encoded:r,encoding:e?.encoding});return Lu({type:ki(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?Ze(t.senderPublicKey,It):void 0,receiverPublicKey:e?.receiverPublicKey})}function Lu(r){let e=r?.type||qb;if(e===lr){if(typeof r?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof r?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r?.senderPublicKey,receiverPublicKey:r?.receiverPublicKey}}function Fu(r){return r.type===lr&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function qu(r){return r.type===Ss}function n_(r){return new Eb.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function s_(r){let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function o_(r){return Buffer.from(s_(r),"base64")}function Gb(r,e){let[t,i,n]=r.split("."),s=o_(n);if(s.length!==64)throw new Error("Invalid signature length");let o=s.slice(0,32).toString("hex"),f=s.slice(32,64).toString("hex"),u=`${t}.${i}`,c=new ws.SHA256().update(Buffer.from(u)).digest(),b=n_(e),v=Buffer.from(c).toString("hex");if(!b.verify(v,{r:o,s:f}))throw new Error("Invalid signature");return ts(r).payload}var a_="irn";function Rf(r){return r?.relay||{protocol:a_}}function As(r){let e=cb[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}var f_=Object.defineProperty,c_=Object.defineProperties,h_=Object.getOwnPropertyDescriptors,bb=Object.getOwnPropertySymbols,u_=Object.prototype.hasOwnProperty,d_=Object.prototype.propertyIsEnumerable,vb=(r,e,t)=>e in r?f_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,mb=(r,e)=>{for(var t in e||(e={}))u_.call(e,t)&&vb(r,t,e[t]);if(bb)for(var t of bb(e))d_.call(e,t)&&vb(r,t,e[t]);return r},l_=(r,e)=>c_(r,h_(e));function p_(r,e="-"){let t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){let s=n.replace(i,""),o=r[n];t[s]=o}}),t}function Uu(r){if(!r.includes("wc:")){let u=Nb(r);u!=null&&u.includes("wc:")&&(r=u)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;let e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),s=typeof t<"u"?r.substring(t):"",o=ys.parse(s),f=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:g_(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:p_(o),methods:f,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function g_(r){return r.startsWith("//")?r.substring(2):r}function b_(r,e="-"){let t="relay",i={};return Object.keys(r).forEach(n=>{let s=t+e+n;r[n]&&(i[s]=r[n])}),i}function zu(r){return`${r.protocol}:${r.topic}@${r.version}?`+ys.stringify(mb(l_(mb({symKey:r.symKey},b_(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function Po(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function Rs(r){let e=[];return r.forEach(t=>{let[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function v_(r){let e=[];return Object.values(r).forEach(t=>{e.push(...Rs(t.accounts))}),e}function m_(r,e){let t=[];return Object.values(r).forEach(i=>{Rs(i.accounts).includes(e)&&t.push(...i.methods)}),t}function y_(r,e){let t=[];return Object.values(r).forEach(i=>{Rs(i.accounts).includes(e)&&t.push(...i.events)}),t}function w_(r){let e={};return r?.forEach(t=>{let[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function Bu(r,e){e=e.map(i=>i.replace("did:pkh:",""));let t=w_(e);for(let[i,n]of Object.entries(t))n.methods?n.methods=N4(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}var __={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},x_={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function X(r,e){let{message:t,code:i}=x_[r];return{message:e?`${t} ${e}`:t,code:i}}function Ue(r,e){let{message:t,code:i}=__[r];return{message:e?`${t} ${e}`:t,code:i}}function ji(r,e){return Array.isArray(r)?typeof e<"u"&&r.length?r.every(e):!0:!1}function No(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function vt(r){return typeof r>"u"}function Ye(r,e){return e&&vt(r)?!0:typeof r=="string"&&!!r.trim().length}function ku(r,e){return e&&vt(r)?!0:typeof r=="number"&&!isNaN(r)}function Wb(r,e){let{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t),s=!0;return An(n,i)?(i.forEach(o=>{let{accounts:f,methods:u,events:c}=r.namespaces[o],b=Rs(f),v=t[o];(!An(Sb(o,v),b)||!An(v.methods,u)||!An(v.events,c))&&(s=!1)}),s):!1}function Ef(r){return Ye(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function E_(r){if(Ye(r,!1)&&r.includes(":")){let e=r.split(":");if(e.length===3){let t=e[0]+":"+e[1];return!!e[2]&&Ef(t)}}return!1}function Jb(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(Ye(r,!1)){if(e(r))return!0;let t=Nb(r);return e(t)}}catch{}return!1}function Yb(r){var e;return(e=r?.proposer)==null?void 0:e.publicKey}function Xb(r){return r?.topic}function Zb(r,e){let t=null;return Ye(r?.publicKey,!1)||(t=X("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function yb(r){let e=!0;return ji(r)?r.length&&(e=r.every(t=>Ye(t,!1))):e=!1,e}function S_(r,e,t){let i=null;return ji(e)&&e.length?e.forEach(n=>{i||Ef(n)||(i=Ue("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):Ef(r)||(i=Ue("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function I_(r,e,t){let i=null;return Object.entries(r).forEach(([n,s])=>{if(i)return;let o=S_(n,Sb(n,s),`${e} ${t}`);o&&(i=o)}),i}function M_(r,e){let t=null;return ji(r)?r.forEach(i=>{t||E_(i)||(t=Ue("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=Ue("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function A_(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=M_(i?.accounts,`${e} namespace`);n&&(t=n)}),t}function R_(r,e){let t=null;return yb(r?.methods)?yb(r?.events)||(t=Ue("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=Ue("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function Qb(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=R_(i,`${e}, namespace`);n&&(t=n)}),t}function ev(r,e,t){let i=null;if(r&&No(r)){let n=Qb(r,e);n&&(i=n);let s=I_(r,e,t);s&&(i=s)}else i=X("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function Tf(r,e){let t=null;if(r&&No(r)){let i=Qb(r,e);i&&(t=i);let n=A_(r,e);n&&(t=n)}else t=X("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function Ku(r){return Ye(r.protocol,!0)}function tv(r,e){let t=!1;return e&&!r?t=!0:r&&ji(r)&&r.length&&r.forEach(i=>{t=Ku(i)}),t}function rv(r){return typeof r=="number"}function Mt(r){return typeof r<"u"&&typeof r!==null}function iv(r){return!(!r||typeof r!="object"||!r.code||!ku(r.code,!1)||!r.message||!Ye(r.message,!1))}function nv(r){return!(vt(r)||!Ye(r.method,!1))}function sv(r){return!(vt(r)||vt(r.result)&&vt(r.error)||!ku(r.id,!1)||!Ye(r.jsonrpc,!1))}function ov(r){return!(vt(r)||!Ye(r.name,!1))}function ju(r,e){return!(!Ef(e)||!v_(r).includes(e))}function av(r,e,t){return Ye(t,!1)?m_(r,e).includes(t):!1}function fv(r,e,t){return Ye(t,!1)?y_(r,e).includes(t):!1}function Vu(r,e,t){let i=null,n=T_(r),s=D_(e),o=Object.keys(n),f=Object.keys(s),u=wb(Object.keys(r)),c=wb(Object.keys(e)),b=u.filter(v=>!c.includes(v));return b.length&&(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces.
+ Required: ${b.toString()}
+ Received: ${Object.keys(e).toString()}`)),An(o,f)||(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces.
+ Required: ${o.toString()}
+ Approved: ${f.toString()}`)),Object.keys(e).forEach(v=>{if(!v.includes(":")||i)return;let S=Rs(e[v].accounts);S.includes(v)||(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${v}
+ Required: ${v}
+ Approved: ${S.toString()}`))}),o.forEach(v=>{i||(An(n[v].methods,s[v].methods)?An(n[v].events,s[v].events)||(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${v}`)):i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${v}`))}),i}function T_(r){let e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function wb(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function D_(r){let e={};return Object.keys(r).forEach(t=>{t.includes(":")?e[t]=r[t]:Rs(r[t].accounts)?.forEach(n=>{e[n]={accounts:r[t].accounts.filter(s=>s.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}),e}function cv(r,e){return ku(r,!1)&&r<=e.max&&r>=e.min}function $u(){let r=Mo();return new Promise(e=>{switch(r){case Ft.browser:e(P_());break;case Ft.reactNative:e(N_());break;case Ft.node:e(C_());break;default:e(!0)}})}function P_(){return _s()&&navigator?.onLine}async function N_(){return Tn()&&typeof window<"u"&&window!=null&&window.NetInfo?(await window?.NetInfo.fetch())?.isConnected:!0}function C_(){return!0}function hv(r){switch(Mo()){case Ft.browser:O_(r);break;case Ft.reactNative:L_(r);break;case Ft.node:break}}function O_(r){!Tn()&&_s()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function L_(r){Tn()&&typeof window<"u"&&window!=null&&window.NetInfo&&window?.NetInfo.addEventListener(e=>r(e?.isConnected))}var xu={},Ki=class{static get(e){return xu[e]}static set(e,t){xu[e]=t}static delete(e){delete xu[e]}};var Mv=qe(un());var Rt={};Dt(Rt,{DEFAULT_ERROR:()=>Oo,IBaseJsonRpcProvider:()=>Uf,IEvents:()=>Lo,IJsonRpcConnection:()=>Yu,IJsonRpcProvider:()=>Fo,INTERNAL_ERROR:()=>Df,INVALID_PARAMS:()=>pv,INVALID_REQUEST:()=>dv,METHOD_NOT_FOUND:()=>lv,PARSE_ERROR:()=>uv,RESERVED_ERROR_CODES:()=>Hu,SERVER_ERROR:()=>Co,SERVER_ERROR_CODE_RANGE:()=>Pf,STANDARD_ERROR_MAP:()=>Vi,formatErrorMessage:()=>Sv,formatJsonRpcError:()=>Pn,formatJsonRpcRequest:()=>br,formatJsonRpcResult:()=>Ts,getBigIntRpcId:()=>gr,getError:()=>Cf,getErrorByCode:()=>Of,isHttpUrl:()=>H_,isJsonRpcError:()=>At,isJsonRpcPayload:()=>Zu,isJsonRpcRequest:()=>Ds,isJsonRpcResponse:()=>Gi,isJsonRpcResult:()=>kt,isJsonRpcValidationInvalid:()=>G_,isLocalhostUrl:()=>Xu,isNodeJs:()=>Ev,isReservedErrorCode:()=>Nf,isServerErrorCode:()=>F_,isValidDefaultRoute:()=>Ff,isValidErrorCode:()=>gv,isValidLeadingWildcardRoute:()=>k_,isValidRoute:()=>B_,isValidTrailingWildcardRoute:()=>K_,isValidWildcardRoute:()=>qf,isWsUrl:()=>zf,parseConnectionError:()=>Gu,payloadId:()=>Qr,validateJsonRpcError:()=>q_});var uv="PARSE_ERROR",dv="INVALID_REQUEST",lv="METHOD_NOT_FOUND",pv="INVALID_PARAMS",Df="INTERNAL_ERROR",Co="SERVER_ERROR",Hu=[-32700,-32600,-32601,-32602,-32603],Pf=[-32e3,-32099],Vi={[uv]:{code:-32700,message:"Parse error"},[dv]:{code:-32600,message:"Invalid Request"},[lv]:{code:-32601,message:"Method not found"},[pv]:{code:-32602,message:"Invalid params"},[Df]:{code:-32603,message:"Internal error"},[Co]:{code:-32e3,message:"Server error"}},Oo=Co;function F_(r){return r<=Pf[0]&&r>=Pf[1]}function Nf(r){return Hu.includes(r)}function gv(r){return typeof r=="number"}function Cf(r){return Object.keys(Vi).includes(r)?Vi[r]:Vi[Oo]}function Of(r){let e=Object.values(Vi).find(t=>t.code===r);return e||Vi[Oo]}function q_(r){if(typeof r.error.code>"u")return{valid:!1,error:"Missing code for JSON-RPC error"};if(typeof r.error.message>"u")return{valid:!1,error:"Missing message for JSON-RPC error"};if(!gv(r.error.code))return{valid:!1,error:`Invalid error code type for JSON-RPC: ${r.error.code}`};if(Nf(r.error.code)){let e=Of(r.error.code);if(e.message!==Vi[Oo].message&&r.error.message===e.message)return{valid:!1,error:`Invalid error code message for JSON-RPC: ${r.error.code}`}}return{valid:!0}}function Gu(r,e,t){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${t} RPC url at ${e}`):r}var Nt={};Dt(Nt,{isNodeJs:()=>Ev});var xv=qe(Ju());qt(Nt,qe(Ju()));var Ev=xv.isNode;qt(Rt,Nt);function Qr(r=3){let e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function gr(r=6){return BigInt(Qr(r))}function br(r,e,t){return{id:t||Qr(),jsonrpc:"2.0",method:r,params:e}}function Ts(r,e){return{id:r,jsonrpc:"2.0",result:e}}function Pn(r,e,t){return{id:r,jsonrpc:"2.0",error:Sv(e,t)}}function Sv(r,e){return typeof r>"u"?Cf(Df):(typeof r=="string"&&(r=Object.assign(Object.assign({},Cf(Co)),{message:r})),typeof e<"u"&&(r.data=e),Nf(r.code)&&(r=Of(r.code)),r)}function B_(r){return r.includes("*")?qf(r):!/\W/g.test(r)}function Ff(r){return r==="*"}function qf(r){return Ff(r)?!0:!(!r.includes("*")||r.split("*").length!==2||r.split("*").filter(e=>e.trim()==="").length!==1)}function k_(r){return!Ff(r)&&qf(r)&&!r.split("*")[0].trim()}function K_(r){return!Ff(r)&&qf(r)&&!r.split("*")[1].trim()}var Lo=class{},Yu=class extends Lo{constructor(e){super()}},Uf=class extends Lo{constructor(){super()}},Fo=class extends Uf{constructor(e){super()}};var j_="^https?:",V_="^wss?:";function $_(r){let e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Iv(r,e){let t=$_(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function H_(r){return Iv(r,j_)}function zf(r){return Iv(r,V_)}function Xu(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function Zu(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function Ds(r){return Zu(r)&&"method"in r}function Gi(r){return Zu(r)&&(kt(r)||At(r))}function kt(r){return"result"in r}function At(r){return"error"in r}function G_(r){return"error"in r&&r.valid===!1}var Bf=class extends Fo{constructor(e){super(e),this.events=new Mv.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(br(e.method,e.params||[],e.id||gr().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{At(s)?n(s.error):i(s.result)});try{await this.connection.send(e,t)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Gi(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};var Pv=qe(un());var W_=()=>typeof WebSocket<"u"?WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:Rv(),J_=()=>typeof WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Tv=r=>r.split("?")[0],Dv=10,Y_=W_(),kf=class{constructor(e){if(this.url=e,this.events=new Pv.EventEmitter,this.registering=!1,!zf(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Wt(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!zf(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){let t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{let n=new URLSearchParams(e).get("origin"),s=(0,Rt.isReactNative)()?{headers:{origin:n}}:{rejectUnauthorized:!Xu(e)},o=new Y_(e,[],s);J_()?o.onerror=f=>{let u=f;i(this.emitError(u.error))}:o.on("error",f=>{i(this.emitError(f))}),o.onopen=()=>{this.onOpen(o),t(o)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;let t=typeof e.data=="string"?Fr(e.data):e.data;this.events.emit("payload",t)}onError(e,t){let i=this.parseError(t),n=i.message||i.toString(),s=Pn(e,n);this.events.emit("payload",s)}parseError(e,t=this.url){return Gu(e,Tv(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Dv&&this.events.setMaxListeners(Dv)}emitError(e){let t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${Tv(this.url)}`));return this.events.emit("register_error",t),t}};var Om=qe(dm()),Lm=qe(za()),Fm="wc",qm=2,Ld="core",ii=`${Fm}@2:${Ld}:`,AE={name:Ld,logger:"error"},RE={database:":memory:"},TE="crypto",lm="client_ed25519_seed",DE=re.ONE_DAY,PE="keychain",NE="0.3",CE="messages",OE="0.3",LE=re.SIX_HOURS,FE="publisher",Fd="irn",qE="error",Um="wss://relay.walletconnect.org",UE="relayer",Tt={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},zE="_subscription",rr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},BE=.1;var dd="2.17.2";var $e={link_mode:"link_mode",relay:"relay"},kE="0.3",KE="WALLETCONNECT_CLIENT_ID",pm="WALLETCONNECT_LINK_MODE_APPS",ti={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"};var jE="subscription",VE="0.3",$E=re.FIVE_SECONDS*1e3,HE="pairing",GE="0.3";var Ko={wc_pairingDelete:{req:{ttl:re.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:re.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:re.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:re.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:re.ONE_DAY,prompt:!1,tag:0},res:{ttl:re.ONE_DAY,prompt:!1,tag:0}}},Yi={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},vr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},WE="history",JE="0.3",YE="expirer",Kt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},XE="0.3";var ZE="verify-api",QE="https://verify.walletconnect.com",zm="https://verify.walletconnect.org",Os=zm,e9=`${Os}/v3`,t9=[QE,zm],r9="echo",i9="https://echo.walletconnect.com";var mr={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},ri={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},ir={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Xi={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Zi={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},Ls={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},n9=.1,s9="event-client",o9=86400,a9="https://pulse.walletconnect.org/batch";function f9(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,U=new Uint8Array(B);P!==z;){for(var j=M[P],H=0,L=B-1;(j!==0||H>>0,U[L]=j%f>>>0,j=j/f>>>0;if(j!==0)throw new Error("Non-zero carry");O=H,P++}for(var C=B-O;C!==B&&U[C]===0;)C++;for(var W=u.repeat(T);C>>0,B=new Uint8Array(z);M[T];){var U=t[M.charCodeAt(T)];if(U===255)return;for(var j=0,H=z-1;(U!==0||j>>0,B[H]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");P=j,T++}if(M[T]!==" "){for(var L=z-P;L!==z&&B[L]===0;)L++;for(var C=new Uint8Array(O+(z-L)),W=O;L!==z;)C[W++]=B[L++];return C}}}function I(M){var T=S(M);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:v,decodeUnsafe:S,decode:I}}var c9=f9,h9=c9,Bm=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},u9=r=>new TextEncoder().encode(r),d9=r=>new TextDecoder().decode(r),ld=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},pd=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return km(this,e)}},gd=class{constructor(e){this.decoders=e}or(e){return km(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},km=(r,e)=>new gd({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),bd=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new ld(e,t,i),this.decoder=new pd(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Qf=({name:r,prefix:e,encode:t,decode:i})=>new bd(r,e,t,i),$o=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=h9(t,e);return Qf({prefix:r,name:e,encode:i,decode:s=>Bm(n(s))})},l9=(r,e,t,i)=>{let n={};for(let b=0;b