@dcl/vesting-dashboard 3.4.0 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{t as fh,k as j2,c as k2,p as Ei,g as W2,a as V2,r as G2,b as J2,d as wr,m as Y2,u as X2,i as eu,h as Rp,e as Tp,f as Z2,j as ht,B as ci,l as Q2,n as hi,o as Np,q as tu,s as Il,_ as e6}from"./index-9ab4b2f8.js";const t6=`Ethereum Signed Message:
1
+ import{t as fh,k as j2,c as k2,p as Ei,g as W2,a as V2,r as G2,b as J2,d as wr,m as Y2,u as X2,i as eu,h as Rp,e as Tp,f as Z2,j as ht,B as ci,l as Q2,n as hi,o as Np,q as tu,s as Il,_ as e6}from"./index-e375682a.js";const t6=`Ethereum Signed Message:
2
2
  `;function $p(r){return typeof r=="string"&&(r=fh(r)),j2(k2([fh(t6),fh(String(r.length)),r]))}var Dl=globalThis&&globalThis.__spreadArray||function(r,e,t){if(t||arguments.length===2)for(var n=0,a=e.length,o;n<a;n++)(o||!(n in e))&&(o||(o=Array.prototype.slice.call(e,0,n)),o[n]=e[n]);return r.concat(o||Array.prototype.slice.call(e))},r6=function(){function r(e,t,n){this.name=e,this.version=t,this.os=n,this.type="browser"}return r}(),i6=function(){function r(e){this.version=e,this.type="node",this.name="node",this.os=Ei.platform}return r}(),n6=function(){function r(e,t,n,a){this.name=e,this.version=t,this.os=n,this.bot=a,this.type="bot-device"}return r}(),s6=function(){function r(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return r}(),a6=function(){function r(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return r}(),o6=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,c6=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Al=3,f6=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",o6]],Ml=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function h6(r){return r?Pl(r):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new a6:typeof navigator<"u"?Pl(navigator.userAgent):l6()}function u6(r){return r!==""&&f6.reduce(function(e,t){var n=t[0],a=t[1];if(e)return e;var o=a.exec(r);return!!o&&[n,o]},!1)}function Pl(r){var e=u6(r);if(!e)return null;var t=e[0],n=e[1];if(t==="searchbot")return new s6;var a=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);a?a.length<Al&&(a=Dl(Dl([],a,!0),p6(Al-a.length),!0)):a=[];var o=a.join("."),f=d6(r),h=c6.exec(r);return h&&h[1]?new n6(t,o,f,h[1]):new r6(t,o,f)}function d6(r){for(var e=0,t=Ml.length;e<t;e++){var n=Ml[e],a=n[0],o=n[1],f=o.exec(r);if(f)return a}return null}function l6(){var r=typeof Ei<"u"&&Ei.version;return r?new i6(Ei.version.slice(1)):null}function p6(r){for(var e=[],t=0;t<r;t++)e.push("0");return e}var be={};/*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -46,4 +46,4 @@ __p += '`),mt&&(ue+=`' +
46
46
  function print() { __p += __j.call(arguments, '') }
47
47
  `:`;
48
48
  `)+ue+`return __p
49
- }`;var at=El(function(){return yt(C,Me+"return "+ue).apply(t,B)});if(at.source=ue,Zf(at))throw at;return at}function X3(i){return _t(i).toLowerCase()}function Z3(i){return _t(i).toUpperCase()}function Q3(i,s,c){if(i=_t(i),i&&(c||s===t))return Cu(i);if(!i||!(s=jr(s)))return i;var g=gi(i),S=gi(s),C=Ru(g,S),B=Tu(g,S)+1;return yn(g,C,B).join("")}function e2(i,s,c){if(i=_t(i),i&&(c||s===t))return i.slice(0,$u(i)+1);if(!i||!(s=jr(s)))return i;var g=gi(i),S=Tu(g,gi(s))+1;return yn(g,0,S).join("")}function t2(i,s,c){if(i=_t(i),i&&(c||s===t))return i.replace(Ft,"");if(!i||!(s=jr(s)))return i;var g=gi(i),S=Ru(g,gi(s));return yn(g,S).join("")}function r2(i,s){var c=de,g=$;if(jt(s)){var S="separator"in s?s.separator:S;c="length"in s?st(s.length):c,g="omission"in s?jr(s.omission):g}i=_t(i);var C=i.length;if(Ss(i)){var B=gi(i);C=B.length}if(c>=C)return i;var k=c-xs(g);if(k<1)return g;var Q=B?yn(B,0,k).join(""):i.slice(0,k);if(S===t)return Q+g;if(B&&(k+=Q.length-k),Qf(S)){if(i.slice(k).search(S)){var se,ae=Q;for(S.global||(S=gf(S.source,_t(br.exec(S))+"g")),S.lastIndex=0;se=S.exec(ae);)var ue=se.index;Q=Q.slice(0,ue===t?k:ue)}}else if(i.indexOf(jr(S),k)!=k){var ve=Q.lastIndexOf(S);ve>-1&&(Q=Q.slice(0,ve))}return Q+g}function i2(i){return i=_t(i),i&&ke.test(i)?i.replace(li,Rg):i}var n2=Cs(function(i,s,c){return i+(c?" ":"")+s.toUpperCase()}),rh=Sd("toUpperCase");function _l(i,s,c){return i=_t(i),s=c?t:s,s===t?Ag(i)?$g(i):mg(i):i.match(s)||[]}var El=ct(function(i,s){try{return ir(i,t,s)}catch(c){return Zf(c)?c:new Ke(c)}}),s2=Ji(function(i,s){return Zr(s,function(c){c=Ti(c),Vi(i,c,Yf(i[c],i))}),i});function a2(i){var s=i==null?0:i.length,c=Ne();return i=s?Ht(i,function(g){if(typeof g[1]!="function")throw new Qr(f);return[c(g[0]),g[1]]}):[],ct(function(g){for(var S=-1;++S<s;){var C=i[S];if(ir(C[0],this,g))return ir(C[1],this,g)}})}function o2(i){return Rb(ti(i,_))}function ih(i){return function(){return i}}function c2(i,s){return i==null||i!==i?s:i}var f2=Id(),h2=Id(!0);function $r(i){return i}function nh(i){return td(typeof i=="function"?i:ti(i,_))}function u2(i){return id(ti(i,_))}function d2(i,s){return nd(i,ti(s,_))}var l2=ct(function(i,s){return function(c){return ua(c,i,s)}}),p2=ct(function(i,s){return function(c){return ua(i,c,s)}});function sh(i,s,c){var g=nr(s),S=Lo(s,g);c==null&&!(jt(s)&&(S.length||!g.length))&&(c=s,s=i,i=this,S=Lo(s,nr(s)));var C=!(jt(c)&&"chain"in c)||!!c.chain,B=Xi(i);return Zr(S,function(k){var Q=s[k];i[k]=Q,B&&(i.prototype[k]=function(){var se=this.__chain__;if(C||se){var ae=i(this.__wrapped__),ue=ae.__actions__=Rr(this.__actions__);return ue.push({func:Q,args:arguments,thisArg:i}),ae.__chain__=se,ae}return Q.apply(i,ln([this.value()],arguments))})}),i}function g2(){return vt._===this&&(vt._=zg),this}function ah(){}function b2(i){return i=st(i),ct(function(s){return sd(s,i)})}var v2=Ff(Ht),m2=Ff(Du),y2=Ff(cf);function Sl(i){return jf(i)?ff(Ti(i)):Jb(i)}function w2(i){return function(s){return i==null?t:Gn(i,s)}}var _2=Ad(),E2=Ad(!0);function oh(){return[]}function ch(){return!1}function S2(){return{}}function x2(){return""}function I2(){return!0}function D2(i,s){if(i=st(i),i<1||i>R)return[];var c=D,g=vr(i,D);s=Ne(s),i-=D;for(var S=df(g,s);++c<i;)s(c);return S}function A2(i){return Xe(i)?Ht(i,Ti):kr(i)?[i]:Rr(Kd(_t(i)))}function M2(i){var s=++Ug;return _t(i)+s}var P2=Ho(function(i,s){return i+s},0),O2=qf("ceil"),C2=Ho(function(i,s){return i/s},1),R2=qf("floor");function T2(i){return i&&i.length?$o(i,$r,Sf):t}function N2(i,s){return i&&i.length?$o(i,Ne(s,2),Sf):t}function $2(i){return Pu(i,$r)}function L2(i,s){return Pu(i,Ne(s,2))}function F2(i){return i&&i.length?$o(i,$r,Af):t}function q2(i,s){return i&&i.length?$o(i,Ne(s,2),Af):t}var U2=Ho(function(i,s){return i*s},1),B2=qf("round"),z2=Ho(function(i,s){return i-s},0);function H2(i){return i&&i.length?uf(i,$r):0}function K2(i,s){return i&&i.length?uf(i,Ne(s,2)):0}return A.after=uy,A.ary=el,A.assign=Zy,A.assignIn=pl,A.assignInWith=tc,A.assignWith=Qy,A.at=e3,A.before=tl,A.bind=Yf,A.bindAll=s2,A.bindKey=rl,A.castArray=Sy,A.chain=Xd,A.chunk=Rv,A.compact=Tv,A.concat=Nv,A.cond=a2,A.conforms=o2,A.constant=ih,A.countBy=Hm,A.create=t3,A.curry=il,A.curryRight=nl,A.debounce=sl,A.defaults=r3,A.defaultsDeep=i3,A.defer=dy,A.delay=ly,A.difference=$v,A.differenceBy=Lv,A.differenceWith=Fv,A.drop=qv,A.dropRight=Uv,A.dropRightWhile=Bv,A.dropWhile=zv,A.fill=Hv,A.filter=jm,A.flatMap=Vm,A.flatMapDeep=Gm,A.flatMapDepth=Jm,A.flatten=Vd,A.flattenDeep=Kv,A.flattenDepth=jv,A.flip=py,A.flow=f2,A.flowRight=h2,A.fromPairs=kv,A.functions=h3,A.functionsIn=u3,A.groupBy=Ym,A.initial=Vv,A.intersection=Gv,A.intersectionBy=Jv,A.intersectionWith=Yv,A.invert=l3,A.invertBy=p3,A.invokeMap=Zm,A.iteratee=nh,A.keyBy=Qm,A.keys=nr,A.keysIn=Nr,A.map=Jo,A.mapKeys=b3,A.mapValues=v3,A.matches=u2,A.matchesProperty=d2,A.memoize=Xo,A.merge=m3,A.mergeWith=gl,A.method=l2,A.methodOf=p2,A.mixin=sh,A.negate=Zo,A.nthArg=b2,A.omit=y3,A.omitBy=w3,A.once=gy,A.orderBy=ey,A.over=v2,A.overArgs=by,A.overEvery=m2,A.overSome=y2,A.partial=Xf,A.partialRight=al,A.partition=ty,A.pick=_3,A.pickBy=bl,A.property=Sl,A.propertyOf=w2,A.pull=em,A.pullAll=Jd,A.pullAllBy=tm,A.pullAllWith=rm,A.pullAt=im,A.range=_2,A.rangeRight=E2,A.rearg=vy,A.reject=ny,A.remove=nm,A.rest=my,A.reverse=Gf,A.sampleSize=ay,A.set=S3,A.setWith=x3,A.shuffle=oy,A.slice=sm,A.sortBy=hy,A.sortedUniq=dm,A.sortedUniqBy=lm,A.split=V3,A.spread=yy,A.tail=pm,A.take=gm,A.takeRight=bm,A.takeRightWhile=vm,A.takeWhile=mm,A.tap=Tm,A.throttle=wy,A.thru=Go,A.toArray=ul,A.toPairs=vl,A.toPairsIn=ml,A.toPath=A2,A.toPlainObject=ll,A.transform=I3,A.unary=_y,A.union=ym,A.unionBy=wm,A.unionWith=_m,A.uniq=Em,A.uniqBy=Sm,A.uniqWith=xm,A.unset=D3,A.unzip=Jf,A.unzipWith=Yd,A.update=A3,A.updateWith=M3,A.values=Ns,A.valuesIn=P3,A.without=Im,A.words=_l,A.wrap=Ey,A.xor=Dm,A.xorBy=Am,A.xorWith=Mm,A.zip=Pm,A.zipObject=Om,A.zipObjectDeep=Cm,A.zipWith=Rm,A.entries=vl,A.entriesIn=ml,A.extend=pl,A.extendWith=tc,sh(A,A),A.add=P2,A.attempt=El,A.camelCase=T3,A.capitalize=yl,A.ceil=O2,A.clamp=O3,A.clone=xy,A.cloneDeep=Dy,A.cloneDeepWith=Ay,A.cloneWith=Iy,A.conformsTo=My,A.deburr=wl,A.defaultTo=c2,A.divide=C2,A.endsWith=N3,A.eq=vi,A.escape=$3,A.escapeRegExp=L3,A.every=Km,A.find=km,A.findIndex=kd,A.findKey=n3,A.findLast=Wm,A.findLastIndex=Wd,A.findLastKey=s3,A.floor=R2,A.forEach=Zd,A.forEachRight=Qd,A.forIn=a3,A.forInRight=o3,A.forOwn=c3,A.forOwnRight=f3,A.get=eh,A.gt=Py,A.gte=Oy,A.has=d3,A.hasIn=th,A.head=Gd,A.identity=$r,A.includes=Xm,A.indexOf=Wv,A.inRange=C3,A.invoke=g3,A.isArguments=Xn,A.isArray=Xe,A.isArrayBuffer=Cy,A.isArrayLike=Tr,A.isArrayLikeObject=Jt,A.isBoolean=Ry,A.isBuffer=wn,A.isDate=Ty,A.isElement=Ny,A.isEmpty=$y,A.isEqual=Ly,A.isEqualWith=Fy,A.isError=Zf,A.isFinite=qy,A.isFunction=Xi,A.isInteger=ol,A.isLength=Qo,A.isMap=cl,A.isMatch=Uy,A.isMatchWith=By,A.isNaN=zy,A.isNative=Hy,A.isNil=jy,A.isNull=Ky,A.isNumber=fl,A.isObject=jt,A.isObjectLike=kt,A.isPlainObject=va,A.isRegExp=Qf,A.isSafeInteger=ky,A.isSet=hl,A.isString=ec,A.isSymbol=kr,A.isTypedArray=Ts,A.isUndefined=Wy,A.isWeakMap=Vy,A.isWeakSet=Gy,A.join=Xv,A.kebabCase=F3,A.last=ii,A.lastIndexOf=Zv,A.lowerCase=q3,A.lowerFirst=U3,A.lt=Jy,A.lte=Yy,A.max=T2,A.maxBy=N2,A.mean=$2,A.meanBy=L2,A.min=F2,A.minBy=q2,A.stubArray=oh,A.stubFalse=ch,A.stubObject=S2,A.stubString=x2,A.stubTrue=I2,A.multiply=U2,A.nth=Qv,A.noConflict=g2,A.noop=ah,A.now=Yo,A.pad=B3,A.padEnd=z3,A.padStart=H3,A.parseInt=K3,A.random=R3,A.reduce=ry,A.reduceRight=iy,A.repeat=j3,A.replace=k3,A.result=E3,A.round=B2,A.runInContext=Y,A.sample=sy,A.size=cy,A.snakeCase=W3,A.some=fy,A.sortedIndex=am,A.sortedIndexBy=om,A.sortedIndexOf=cm,A.sortedLastIndex=fm,A.sortedLastIndexBy=hm,A.sortedLastIndexOf=um,A.startCase=G3,A.startsWith=J3,A.subtract=z2,A.sum=H2,A.sumBy=K2,A.template=Y3,A.times=D2,A.toFinite=Zi,A.toInteger=st,A.toLength=dl,A.toLower=X3,A.toNumber=ni,A.toSafeInteger=Xy,A.toString=_t,A.toUpper=Z3,A.trim=Q3,A.trimEnd=e2,A.trimStart=t2,A.truncate=r2,A.unescape=i2,A.uniqueId=M2,A.upperCase=n2,A.upperFirst=rh,A.each=Zd,A.eachRight=Qd,A.first=Gd,sh(A,function(){var i={};return Ci(A,function(s,c){xt.call(A.prototype,c)||(i[c]=s)}),i}(),{chain:!1}),A.VERSION=n,Zr(["bind","bindKey","curry","curryRight","partial","partialRight"],function(i){A[i].placeholder=A}),Zr(["drop","take"],function(i,s){gt.prototype[i]=function(c){c=c===t?1:tr(st(c),0);var g=this.__filtered__&&!s?new gt(this):this.clone();return g.__filtered__?g.__takeCount__=vr(c,g.__takeCount__):g.__views__.push({size:vr(c,D),type:i+(g.__dir__<0?"Right":"")}),g},gt.prototype[i+"Right"]=function(c){return this.reverse()[i](c).reverse()}}),Zr(["filter","map","takeWhile"],function(i,s){var c=s+1,g=c==w||c==O;gt.prototype[i]=function(S){var C=this.clone();return C.__iteratees__.push({iteratee:Ne(S,3),type:c}),C.__filtered__=C.__filtered__||g,C}}),Zr(["head","last"],function(i,s){var c="take"+(s?"Right":"");gt.prototype[i]=function(){return this[c](1).value()[0]}}),Zr(["initial","tail"],function(i,s){var c="drop"+(s?"":"Right");gt.prototype[i]=function(){return this.__filtered__?new gt(this):this[c](1)}}),gt.prototype.compact=function(){return this.filter($r)},gt.prototype.find=function(i){return this.filter(i).head()},gt.prototype.findLast=function(i){return this.reverse().find(i)},gt.prototype.invokeMap=ct(function(i,s){return typeof i=="function"?new gt(this):this.map(function(c){return ua(c,i,s)})}),gt.prototype.reject=function(i){return this.filter(Zo(Ne(i)))},gt.prototype.slice=function(i,s){i=st(i);var c=this;return c.__filtered__&&(i>0||s<0)?new gt(c):(i<0?c=c.takeRight(-i):i&&(c=c.drop(i)),s!==t&&(s=st(s),c=s<0?c.dropRight(-s):c.take(s-i)),c)},gt.prototype.takeRightWhile=function(i){return this.reverse().takeWhile(i).reverse()},gt.prototype.toArray=function(){return this.take(D)},Ci(gt.prototype,function(i,s){var c=/^(?:filter|find|map|reject)|While$/.test(s),g=/^(?:head|last)$/.test(s),S=A[g?"take"+(s=="last"?"Right":""):s],C=g||/^find/.test(s);S&&(A.prototype[s]=function(){var B=this.__wrapped__,k=g?[1]:arguments,Q=B instanceof gt,se=k[0],ae=Q||Xe(B),ue=function(ut){var mt=S.apply(A,ln([ut],k));return g&&ve?mt[0]:mt};ae&&c&&typeof se=="function"&&se.length!=1&&(Q=ae=!1);var ve=this.__chain__,Me=!!this.__actions__.length,$e=C&&!ve,at=Q&&!Me;if(!C&&ae){B=at?B:new gt(this);var Le=i.apply(B,k);return Le.__actions__.push({func:Go,args:[ue],thisArg:t}),new ei(Le,ve)}return $e&&at?i.apply(this,k):(Le=this.thru(ue),$e?g?Le.value()[0]:Le.value():Le)})}),Zr(["pop","push","shift","sort","splice","unshift"],function(i){var s=wo[i],c=/^(?:push|sort|unshift)$/.test(i)?"tap":"thru",g=/^(?:pop|shift)$/.test(i);A.prototype[i]=function(){var S=arguments;if(g&&!this.__chain__){var C=this.value();return s.apply(Xe(C)?C:[],S)}return this[c](function(B){return s.apply(Xe(B)?B:[],S)})}}),Ci(gt.prototype,function(i,s){var c=A[s];if(c){var g=c.name+"";xt.call(Ms,g)||(Ms[g]=[]),Ms[g].push({name:s,func:c})}}),Ms[zo(t,J).name]=[{name:"wrapper",func:t}],gt.prototype.clone=ib,gt.prototype.reverse=nb,gt.prototype.value=sb,A.prototype.at=Nm,A.prototype.chain=$m,A.prototype.commit=Lm,A.prototype.next=Fm,A.prototype.plant=Um,A.prototype.reverse=Bm,A.prototype.toJSON=A.prototype.valueOf=A.prototype.value=zm,A.prototype.first=A.prototype.head,na&&(A.prototype[na]=qm),A},Is=Lg();Gt?((Gt.exports=Is)._=Is,Ct._=Is):vt._=Is}).call(wr)})(Pc,Pc.exports);var Px=Pc.exports,Ox=Object.defineProperty,Cx=Object.defineProperties,Rx=Object.getOwnPropertyDescriptors,dp=Object.getOwnPropertySymbols,Tx=Object.prototype.hasOwnProperty,Nx=Object.prototype.propertyIsEnumerable,lp=(r,e,t)=>e in r?Ox(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,pp=(r,e)=>{for(var t in e||(e={}))Tx.call(e,t)&&lp(r,t,e[t]);if(dp)for(var t of dp(e))Nx.call(e,t)&&lp(r,t,e[t]);return r},gp=(r,e)=>Cx(r,Rx(e));const $x={Accept:"application/json","Content-Type":"application/json"},Lx="POST",bp={headers:$x,method:Lx},vp=10;let Ki=class{constructor(e,t=!1){if(this.url=e,this.disableProviderPing=t,this.events=new hi.EventEmitter,this.isAvailable=!1,this.registering=!1,!q0(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=t}get connected(){return this.isAvailable}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(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const t=on(e),n=await(await Il(this.url,gp(pp({},bp),{body:t}))).json();this.onPayload({data:n})}catch(t){this.onError(e.id,t)}}async register(e=this.url){if(!q0(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((n,a)=>{this.events.once("register_error",o=>{this.resetMaxListeners(),a(o)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return a(new Error("HTTP connection is missing or invalid"));n()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const t=on({id:1,jsonrpc:"2.0",method:"test",params:[]});await Il(e,gp(pp({},bp),{body:t}))}this.onOpen()}catch(t){const n=this.parseError(t);throw this.events.emit("register_error",n),this.onClose(),n}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const t=typeof e.data=="string"?cs(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const n=this.parseError(t),a=n.message||n.toString(),o=Gc(e,a);this.events.emit("payload",o)}parseError(e,t=this.url){return B1(e,t,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>vp&&this.events.setMaxListeners(vp)}};const mp="error",Fx="wss://relay.walletconnect.org",qx="wc",Ux="universal_provider",yp=`${qx}@2:${Ux}:`,fg="https://rpc.walletconnect.org/v1/",Bs="generic",Bx=`${fg}bundler`,Ii={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var zx=Object.defineProperty,Hx=Object.defineProperties,Kx=Object.getOwnPropertyDescriptors,wp=Object.getOwnPropertySymbols,jx=Object.prototype.hasOwnProperty,kx=Object.prototype.propertyIsEnumerable,_p=(r,e,t)=>e in r?zx(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ac=(r,e)=>{for(var t in e||(e={}))jx.call(e,t)&&_p(r,t,e[t]);if(wp)for(var t of wp(e))kx.call(e,t)&&_p(r,t,e[t]);return r},Wx=(r,e)=>Hx(r,Kx(e));function Si(r,e,t){var n;const a=Ks(r);return((n=e.rpcMap)==null?void 0:n[a.reference])||`${fg}?chainId=${a.namespace}:${a.reference}&projectId=${t}`}function bs(r){return r.includes(":")?r.split(":")[1]:r}function hg(r){return r.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function Vx(r,e){const t=Object.keys(e.namespaces).filter(a=>a.includes(r));if(!t.length)return[];const n=[];return t.forEach(a=>{const o=e.namespaces[a].accounts;n.push(...o)}),n}function Mh(r={},e={}){const t=Ep(r),n=Ep(e);return Px.merge(t,n)}function Ep(r){var e,t,n,a;const o={};if(!$a(r))return o;for(const[f,h]of Object.entries(r)){const p=bu(f)?[f]:h.chains,l=h.methods||[],m=h.events||[],_=h.rpcMap||{},M=Aa(f);o[M]=Wx(ac(ac({},o[M]),h),{chains:hc(p,(e=o[M])==null?void 0:e.chains),methods:hc(l,(t=o[M])==null?void 0:t.methods),events:hc(m,(n=o[M])==null?void 0:n.events),rpcMap:ac(ac({},_),(a=o[M])==null?void 0:a.rpcMap)})}return o}function Gx(r){return r.includes(":")?r.split(":")[2]:r}function Sp(r){const e={};for(const[t,n]of Object.entries(r)){const a=n.methods||[],o=n.events||[],f=n.accounts||[],h=bu(t)?[t]:n.chains?n.chains:hg(n.accounts);e[t]={chains:h,methods:a,events:o,accounts:f}}return e}function Ph(r){return typeof r=="number"?r:r.includes("0x")?parseInt(r,16):(r=r.includes(":")?r.split(":")[1]:r,isNaN(Number(r))?r:Number(r))}const ug={},Et=r=>ug[r],Oh=(r,e)=>{ug[r]=e};class Jx{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var n;const a=bs(t);e[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||Si(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new xi(new Ki(n,Et("disableProviderPing")))}}var Yx=Object.defineProperty,Xx=Object.defineProperties,Zx=Object.getOwnPropertyDescriptors,xp=Object.getOwnPropertySymbols,Qx=Object.prototype.hasOwnProperty,eI=Object.prototype.propertyIsEnumerable,Ip=(r,e,t)=>e in r?Yx(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Dp=(r,e)=>{for(var t in e||(e={}))Qx.call(e,t)&&Ip(r,t,e[t]);if(xp)for(var t of xp(e))eI.call(e,t)&&Ip(r,t,e[t]);return r},Ap=(r,e)=>Xx(r,Zx(e));class tI{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const n=t||Si(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new xi(new Ki(n,Et("disableProviderPing")))}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var n;const a=parseInt(bs(t));e[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,n;let a=e.request.params?(t=e.request.params[0])==null?void 0:t.chainId:"0x0";a=a.startsWith("0x")?a:`0x${a}`;const o=parseInt(a,16);if(this.isChainApproved(o))this.setDefaultChain(`${o}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:a}]},chainId:(n=this.namespace.chains)==null?void 0:n[0]}),this.setDefaultChain(`${o}`);else throw new Error(`Failed to switch to chain 'eip155:${o}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,n,a;const o=(n=(t=e.request)==null?void 0:t.params)==null?void 0:n[0];if(!o)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const f=this.client.session.get(e.topic),h=((a=f==null?void 0:f.sessionProperties)==null?void 0:a.capabilities)||{};if(h!=null&&h[o])return h==null?void 0:h[o];const p=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Ap(Dp({},f.sessionProperties||{}),{capabilities:Ap(Dp({},h||{}),{[o]:p})})})}catch(l){console.warn("Failed to update session with capabilities",l)}return p}async getCallStatus(e){var t,n;const a=this.client.session.get(e.topic),o=(t=a.sessionProperties)==null?void 0:t.bundler_name;if(o){const h=this.getBundlerUrl(e.chainId,o);try{return await this.getUserOperationReceipt(h,e)}catch(p){console.warn("Failed to fetch call status from bundler",p,h)}}const f=(n=a.sessionProperties)==null?void 0:n.bundler_url;if(f)try{return await this.getUserOperationReceipt(f,e)}catch(h){console.warn("Failed to fetch call status from custom bundler",h,f)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var n;const a=new URL(e),o=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(xn("eth_getUserOperationReceipt",[(n=t.request.params)==null?void 0:n[0]]))});if(!o.ok)throw new Error(`Failed to fetch user operation receipt - ${o.status}`);return await o.json()}getBundlerUrl(e,t){return`${Bx}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}class rI{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var n;const a=bs(t);e[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||Si(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new xi(new Ki(n,Et("disableProviderPing")))}}class iI{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var n;const a=bs(t);e[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||Si(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new xi(new Ki(n,Et("disableProviderPing")))}}class nI{constructor(e){this.name="algorand",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const n=t||Si(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.chainId=e,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var n;e[t]=this.createHttpProvider(t,(n=this.namespace.rpcMap)==null?void 0:n[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||Si(e,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new xi(new Ki(n,Et("disableProviderPing")))}}class sI{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const n=this.getCardanoRPCUrl(t),a=bs(t);e[a]=this.createHttpProvider(a,n)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||this.getCardanoRPCUrl(e);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new xi(new Ki(n,Et("disableProviderPing")))}}class aI{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var n;const a=bs(t);e[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||Si(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new xi(new Ki(n,Et("disableProviderPing")))}}class oI{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var n;const a=bs(t);e[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||Si(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new xi(new Ki(n,Et("disableProviderPing")))}}class cI{constructor(e){this.name="near",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const n=t||Si(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var n;e[t]=this.createHttpProvider(t,(n=this.namespace.rpcMap)==null?void 0:n[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||Si(e,this.namespace);return typeof n>"u"?void 0:new xi(new Ki(n,Et("disableProviderPing")))}}class fI{constructor(e){this.name=Bs,this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){var e,t;const n={};return(t=(e=this.namespace)==null?void 0:e.accounts)==null||t.forEach(a=>{const o=Ks(a);n[`${o.namespace}:${o.reference}`]=this.createHttpProvider(a)}),n}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||Si(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new xi(new Ki(n,Et("disableProviderPing")))}}var hI=Object.defineProperty,uI=Object.defineProperties,dI=Object.getOwnPropertyDescriptors,Mp=Object.getOwnPropertySymbols,lI=Object.prototype.hasOwnProperty,pI=Object.prototype.propertyIsEnumerable,Pp=(r,e,t)=>e in r?hI(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,oc=(r,e)=>{for(var t in e||(e={}))lI.call(e,t)&&Pp(r,t,e[t]);if(Mp)for(var t of Mp(e))pI.call(e,t)&&Pp(r,t,e[t]);return r},Ch=(r,e)=>uI(r,dI(e));let gI=class dg{constructor(e){this.events=new tu,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:Ya(Wc({level:(e==null?void 0:e.logger)||mp})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const t=new dg(e);return await t.initialize(),t}async request(e,t,n){const[a,o]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(a).request({request:oc({},e),chainId:`${a}:${o}`,topic:this.session.topic,expiry:n})}sendAsync(e,t,n,a){const o=new Date().getTime();this.request(e,n,a).then(f=>t(null,Vc(o,f))).catch(f=>t(f,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:It("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:n,response:a}=await this.client.authenticate(e,t);n&&(this.uri=n,this.events.emit("display_uri",n));const o=await a();if(this.session=o.session,this.session){const f=Sp(this.session.namespaces);this.namespaces=Mh(this.namespaces,f),this.persist("namespaces",this.namespaces),this.onConnect()}return o}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let t=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(t>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:n,approval:a}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});n&&(this.uri=n,this.events.emit("display_uri",n)),await a().then(o=>{this.session=o;const f=Sp(o.namespaces);this.namespaces=Mh(this.namespaces,f),this.persist("namespaces",this.namespaces)}).catch(o=>{if(o.message!==cg)throw o;t++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[n,a]=this.validateChain(e),o=this.getProvider(n);o.name===Bs?o.setDefaultChain(`${n}:${a}`,t):o.setDefaultChain(a,t)}catch(n){if(!/Please call connect/.test(n.message))throw n}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if(Bi(t)){for(const n of t)e.deletePairings?this.client.core.expirer.set(n.topic,0):await this.client.core.relayer.subscriber.unsubscribe(n.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await xu.init({core:this.providerOpts.core,logger:this.providerOpts.logger||mp,relayUrl:this.providerOpts.relayUrl||Fx,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(t=>Aa(t)))];Oh("client",this.client),Oh("events",this.events),Oh("disableProviderPing",this.disableProviderPing),e.forEach(t=>{if(!this.session)return;const n=Vx(t,this.session),a=hg(n),o=Mh(this.namespaces,this.optionalNamespaces),f=Ch(oc({},o[t]),{accounts:n,chains:a});switch(t){case"eip155":this.rpcProviders[t]=new tI({namespace:f});break;case"algorand":this.rpcProviders[t]=new nI({namespace:f});break;case"solana":this.rpcProviders[t]=new rI({namespace:f});break;case"cosmos":this.rpcProviders[t]=new iI({namespace:f});break;case"polkadot":this.rpcProviders[t]=new Jx({namespace:f});break;case"cip34":this.rpcProviders[t]=new sI({namespace:f});break;case"elrond":this.rpcProviders[t]=new aI({namespace:f});break;case"multiversx":this.rpcProviders[t]=new oI({namespace:f});break;case"near":this.rpcProviders[t]=new cI({namespace:f});break;default:this.rpcProviders[Bs]?this.rpcProviders[Bs].updateNamespace(f):this.rpcProviders[Bs]=new fI({namespace:f})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:t}=e,{event:n}=t;if(n.name==="accountsChanged"){const a=n.data;a&&Bi(a)&&this.events.emit("accountsChanged",a.map(Gx))}else if(n.name==="chainChanged"){const a=t.chainId,o=t.event.data,f=Aa(a),h=Ph(a)!==Ph(o)?`${f}:${Ph(o)}`:a;this.onChainChanged(h)}else this.events.emit(n.name,n.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var n;const{namespaces:a}=t,o=(n=this.client)==null?void 0:n.session.get(e);this.session=Ch(oc({},o),{namespaces:a}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Ch(oc({},It("USER_DISCONNECTED")),{data:e.topic}))}),this.on(Ii.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Bs]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace((t=this.session)==null?void 0:t.namespaces[e])})}setNamespaces(e){const{namespaces:t,optionalNamespaces:n,sessionProperties:a}=e;t&&Object.keys(t).length&&(this.namespaces=t),n&&Object.keys(n).length&&(this.optionalNamespaces=n),this.sessionProperties=a,this.persist("namespaces",t),this.persist("optionalNamespaces",n)}validateChain(e){const[t,n]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,n];if(t&&!Object.keys(this.namespaces||{}).map(f=>Aa(f)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&n)return[t,n];const a=Aa(Object.keys(this.namespaces)[0]),o=this.rpcProviders[a].getDefaultChain();return[a,o]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){if(!this.namespaces)return;const[n,a]=this.validateChain(e);a&&(t||this.getProvider(n).setDefaultChain(a),this.namespaces[n]?this.namespaces[n].defaultChain=a:this.namespaces[`${n}:${a}`]?this.namespaces[`${n}:${a}`].defaultChain=a:this.namespaces[`${n}:${a}`]={defaultChain:a},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",a))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,t){this.client.core.storage.setItem(`${yp}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${yp}/${e}`)}};const bI=gI,vI="wc",mI="ethereum_provider",yI=`${vI}@2:${mI}:`,wI="https://rpc.walletconnect.org/v1/",Zh=["eth_sendTransaction","personal_sign"],_I=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],Qh=["chainChanged","accountsChanged"],EI=["chainChanged","accountsChanged","message","disconnect","connect"];var SI=Object.defineProperty,xI=Object.defineProperties,II=Object.getOwnPropertyDescriptors,Op=Object.getOwnPropertySymbols,DI=Object.prototype.hasOwnProperty,AI=Object.prototype.propertyIsEnumerable,Cp=(r,e,t)=>e in r?SI(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,zs=(r,e)=>{for(var t in e||(e={}))DI.call(e,t)&&Cp(r,t,e[t]);if(Op)for(var t of Op(e))AI.call(e,t)&&Cp(r,t,e[t]);return r},Rh=(r,e)=>xI(r,II(e));function Oc(r){return Number(r[0].split(":")[1])}function cc(r){return`0x${r.toString(16)}`}function MI(r){const{chains:e,optionalChains:t,methods:n,optionalMethods:a,events:o,optionalEvents:f,rpcMap:h}=r;if(!Bi(e))throw new Error("Invalid chains");const p={chains:e,methods:n||Zh,events:o||Qh,rpcMap:zs({},e.length?{[Oc(e)]:h[Oc(e)]}:{})},l=o==null?void 0:o.filter(I=>!Qh.includes(I)),m=n==null?void 0:n.filter(I=>!Zh.includes(I));if(!t&&!f&&!a&&!(l!=null&&l.length)&&!(m!=null&&m.length))return{required:e.length?p:void 0};const _=(l==null?void 0:l.length)&&(m==null?void 0:m.length)||!t,M={chains:[...new Set(_?p.chains.concat(t||[]):t)],methods:[...new Set(p.methods.concat(a!=null&&a.length?a:_I))],events:[...new Set(p.events.concat(f!=null&&f.length?f:EI))],rpcMap:h};return{required:e.length?p:void 0,optional:t.length?M:void 0}}class Iu{constructor(){this.events=new hi.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=yI,this.on=(e,t)=>(this.events.on(e,t),this),this.once=(e,t)=>(this.events.once(e,t),this),this.removeListener=(e,t)=>(this.events.removeListener(e,t),this),this.off=(e,t)=>(this.events.off(e,t),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const t=new Iu;return await t.initialize(e),t}async request(e,t){return await this.signer.request(e,this.formatChainId(this.chainId),t)}sendAsync(e,t,n){this.signer.sendAsync(e,t,this.formatChainId(this.chainId),n)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:t,optional:n}=MI(this.rpc);try{const a=await new Promise(async(f,h)=>{var p;this.rpc.showQrModal&&((p=this.modal)==null||p.subscribeModal(l=>{!l.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),h(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(Rh(zs({namespaces:zs({},t&&{[this.namespace]:t})},n&&{optionalNamespaces:{[this.namespace]:n}}),{pairingTopic:e==null?void 0:e.pairingTopic})).then(l=>{f(l)}).catch(l=>{h(new Error(l.message))})});if(!a)return;const o=t0(a.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:cc(this.chainId)})}catch(a){throw this.signer.logger.error(a),a}finally{this.modal&&this.modal.closeModal()}}async authenticate(e,t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e==null?void 0:e.chains});try{const n=await new Promise(async(o,f)=>{var h;this.rpc.showQrModal&&((h=this.modal)==null||h.subscribeModal(p=>{!p.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),f(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(Rh(zs({},e),{chains:this.rpc.chains}),t).then(p=>{o(p)}).catch(p=>{f(new Error(p.message))})}),a=n.session;if(a){const o=t0(a.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:cc(this.chainId)})}return n}catch(n){throw this.signer.logger.error(n),n}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:t}=e,{event:n}=t;n.name==="accountsChanged"?(this.accounts=this.parseAccounts(n.data),this.events.emit("accountsChanged",this.accounts)):n.name==="chainChanged"?this.setChainId(this.formatChainId(n.data)):this.events.emit(n.name,n.data),this.events.emit("session_event",e)}),this.signer.on("chainChanged",e=>{const t=parseInt(e);this.chainId=t,this.events.emit("chainChanged",cc(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",Rh(zs({},It("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var t,n;this.rpc.showQrModal&&((t=this.modal)==null||t.closeModal(),(n=this.modal)==null||n.openModal({uri:e})),this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const t=e.filter(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n));t.length&&(this.chainId=t[0],this.events.emit("chainChanged",cc(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const t=this.parseChainId(e);this.chainId=t,this.switchEthereumChain(t)}}parseAccountId(e){const[t,n,a]=e.split(":");return{chainId:`${t}:${n}`,address:a}}setAccounts(e){this.accounts=e.filter(t=>this.parseChainId(this.parseAccountId(t).chainId)===this.chainId).map(t=>this.parseAccountId(t).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var t,n;const a=(t=e==null?void 0:e.chains)!=null?t:[],o=(n=e==null?void 0:e.optionalChains)!=null?n:[],f=a.concat(o);if(!f.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const h=a.length?(e==null?void 0:e.methods)||Zh:[],p=a.length?(e==null?void 0:e.events)||Qh:[],l=(e==null?void 0:e.optionalMethods)||[],m=(e==null?void 0:e.optionalEvents)||[],_=(e==null?void 0:e.rpcMap)||this.buildRpcMap(f,e.projectId),M=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:a==null?void 0:a.map(I=>this.formatChainId(I)),optionalChains:o.map(I=>this.formatChainId(I)),methods:h,events:p,optionalMethods:l,optionalEvents:m,rpcMap:_,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:M,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,t){const n={};return e.forEach(a=>{n[a]=this.getRpcUrl(a,t)}),n}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?Oc(this.rpc.chains):Oc(this.rpc.optionalChains),this.signer=await bI.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let t;try{const{WalletConnectModal:n}=await e6(()=>import("./index-1d8346ff.js").then(a=>a.i),["assets/index-1d8346ff.js","assets/index-9ab4b2f8.js","assets/index-d326c9c7.css"]);t=n}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(t)try{this.modal=new t(zs({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(n){throw this.signer.logger.error(n),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:t,optionalChains:n,rpcMap:a}=e;t&&Bi(t)&&(this.rpc.chains=t.map(o=>this.formatChainId(o)),t.forEach(o=>{this.rpc.rpcMap[o]=(a==null?void 0:a[o])||this.getRpcUrl(o)})),n&&Bi(n)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=n==null?void 0:n.map(o=>this.formatChainId(o)),n.forEach(o=>{this.rpc.rpcMap[o]=(a==null?void 0:a[o])||this.getRpcUrl(o)}))}getRpcUrl(e,t){var n;return((n=this.rpc.rpcMap)==null?void 0:n[e])||`${wI}?chainId=eip155:${e}&projectId=${t||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),t=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:t==null?void 0:t.accounts),this.setAccounts(t==null?void 0:t.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(t=>this.signer.logger.warn(t))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(t=>this.parseAccount(t))}}const iD=Iu;export{iD as EthereumProvider,EI as OPTIONAL_EVENTS,_I as OPTIONAL_METHODS,Qh as REQUIRED_EVENTS,Zh as REQUIRED_METHODS,Iu as default};
49
+ }`;var at=El(function(){return yt(C,Me+"return "+ue).apply(t,B)});if(at.source=ue,Zf(at))throw at;return at}function X3(i){return _t(i).toLowerCase()}function Z3(i){return _t(i).toUpperCase()}function Q3(i,s,c){if(i=_t(i),i&&(c||s===t))return Cu(i);if(!i||!(s=jr(s)))return i;var g=gi(i),S=gi(s),C=Ru(g,S),B=Tu(g,S)+1;return yn(g,C,B).join("")}function e2(i,s,c){if(i=_t(i),i&&(c||s===t))return i.slice(0,$u(i)+1);if(!i||!(s=jr(s)))return i;var g=gi(i),S=Tu(g,gi(s))+1;return yn(g,0,S).join("")}function t2(i,s,c){if(i=_t(i),i&&(c||s===t))return i.replace(Ft,"");if(!i||!(s=jr(s)))return i;var g=gi(i),S=Ru(g,gi(s));return yn(g,S).join("")}function r2(i,s){var c=de,g=$;if(jt(s)){var S="separator"in s?s.separator:S;c="length"in s?st(s.length):c,g="omission"in s?jr(s.omission):g}i=_t(i);var C=i.length;if(Ss(i)){var B=gi(i);C=B.length}if(c>=C)return i;var k=c-xs(g);if(k<1)return g;var Q=B?yn(B,0,k).join(""):i.slice(0,k);if(S===t)return Q+g;if(B&&(k+=Q.length-k),Qf(S)){if(i.slice(k).search(S)){var se,ae=Q;for(S.global||(S=gf(S.source,_t(br.exec(S))+"g")),S.lastIndex=0;se=S.exec(ae);)var ue=se.index;Q=Q.slice(0,ue===t?k:ue)}}else if(i.indexOf(jr(S),k)!=k){var ve=Q.lastIndexOf(S);ve>-1&&(Q=Q.slice(0,ve))}return Q+g}function i2(i){return i=_t(i),i&&ke.test(i)?i.replace(li,Rg):i}var n2=Cs(function(i,s,c){return i+(c?" ":"")+s.toUpperCase()}),rh=Sd("toUpperCase");function _l(i,s,c){return i=_t(i),s=c?t:s,s===t?Ag(i)?$g(i):mg(i):i.match(s)||[]}var El=ct(function(i,s){try{return ir(i,t,s)}catch(c){return Zf(c)?c:new Ke(c)}}),s2=Ji(function(i,s){return Zr(s,function(c){c=Ti(c),Vi(i,c,Yf(i[c],i))}),i});function a2(i){var s=i==null?0:i.length,c=Ne();return i=s?Ht(i,function(g){if(typeof g[1]!="function")throw new Qr(f);return[c(g[0]),g[1]]}):[],ct(function(g){for(var S=-1;++S<s;){var C=i[S];if(ir(C[0],this,g))return ir(C[1],this,g)}})}function o2(i){return Rb(ti(i,_))}function ih(i){return function(){return i}}function c2(i,s){return i==null||i!==i?s:i}var f2=Id(),h2=Id(!0);function $r(i){return i}function nh(i){return td(typeof i=="function"?i:ti(i,_))}function u2(i){return id(ti(i,_))}function d2(i,s){return nd(i,ti(s,_))}var l2=ct(function(i,s){return function(c){return ua(c,i,s)}}),p2=ct(function(i,s){return function(c){return ua(i,c,s)}});function sh(i,s,c){var g=nr(s),S=Lo(s,g);c==null&&!(jt(s)&&(S.length||!g.length))&&(c=s,s=i,i=this,S=Lo(s,nr(s)));var C=!(jt(c)&&"chain"in c)||!!c.chain,B=Xi(i);return Zr(S,function(k){var Q=s[k];i[k]=Q,B&&(i.prototype[k]=function(){var se=this.__chain__;if(C||se){var ae=i(this.__wrapped__),ue=ae.__actions__=Rr(this.__actions__);return ue.push({func:Q,args:arguments,thisArg:i}),ae.__chain__=se,ae}return Q.apply(i,ln([this.value()],arguments))})}),i}function g2(){return vt._===this&&(vt._=zg),this}function ah(){}function b2(i){return i=st(i),ct(function(s){return sd(s,i)})}var v2=Ff(Ht),m2=Ff(Du),y2=Ff(cf);function Sl(i){return jf(i)?ff(Ti(i)):Jb(i)}function w2(i){return function(s){return i==null?t:Gn(i,s)}}var _2=Ad(),E2=Ad(!0);function oh(){return[]}function ch(){return!1}function S2(){return{}}function x2(){return""}function I2(){return!0}function D2(i,s){if(i=st(i),i<1||i>R)return[];var c=D,g=vr(i,D);s=Ne(s),i-=D;for(var S=df(g,s);++c<i;)s(c);return S}function A2(i){return Xe(i)?Ht(i,Ti):kr(i)?[i]:Rr(Kd(_t(i)))}function M2(i){var s=++Ug;return _t(i)+s}var P2=Ho(function(i,s){return i+s},0),O2=qf("ceil"),C2=Ho(function(i,s){return i/s},1),R2=qf("floor");function T2(i){return i&&i.length?$o(i,$r,Sf):t}function N2(i,s){return i&&i.length?$o(i,Ne(s,2),Sf):t}function $2(i){return Pu(i,$r)}function L2(i,s){return Pu(i,Ne(s,2))}function F2(i){return i&&i.length?$o(i,$r,Af):t}function q2(i,s){return i&&i.length?$o(i,Ne(s,2),Af):t}var U2=Ho(function(i,s){return i*s},1),B2=qf("round"),z2=Ho(function(i,s){return i-s},0);function H2(i){return i&&i.length?uf(i,$r):0}function K2(i,s){return i&&i.length?uf(i,Ne(s,2)):0}return A.after=uy,A.ary=el,A.assign=Zy,A.assignIn=pl,A.assignInWith=tc,A.assignWith=Qy,A.at=e3,A.before=tl,A.bind=Yf,A.bindAll=s2,A.bindKey=rl,A.castArray=Sy,A.chain=Xd,A.chunk=Rv,A.compact=Tv,A.concat=Nv,A.cond=a2,A.conforms=o2,A.constant=ih,A.countBy=Hm,A.create=t3,A.curry=il,A.curryRight=nl,A.debounce=sl,A.defaults=r3,A.defaultsDeep=i3,A.defer=dy,A.delay=ly,A.difference=$v,A.differenceBy=Lv,A.differenceWith=Fv,A.drop=qv,A.dropRight=Uv,A.dropRightWhile=Bv,A.dropWhile=zv,A.fill=Hv,A.filter=jm,A.flatMap=Vm,A.flatMapDeep=Gm,A.flatMapDepth=Jm,A.flatten=Vd,A.flattenDeep=Kv,A.flattenDepth=jv,A.flip=py,A.flow=f2,A.flowRight=h2,A.fromPairs=kv,A.functions=h3,A.functionsIn=u3,A.groupBy=Ym,A.initial=Vv,A.intersection=Gv,A.intersectionBy=Jv,A.intersectionWith=Yv,A.invert=l3,A.invertBy=p3,A.invokeMap=Zm,A.iteratee=nh,A.keyBy=Qm,A.keys=nr,A.keysIn=Nr,A.map=Jo,A.mapKeys=b3,A.mapValues=v3,A.matches=u2,A.matchesProperty=d2,A.memoize=Xo,A.merge=m3,A.mergeWith=gl,A.method=l2,A.methodOf=p2,A.mixin=sh,A.negate=Zo,A.nthArg=b2,A.omit=y3,A.omitBy=w3,A.once=gy,A.orderBy=ey,A.over=v2,A.overArgs=by,A.overEvery=m2,A.overSome=y2,A.partial=Xf,A.partialRight=al,A.partition=ty,A.pick=_3,A.pickBy=bl,A.property=Sl,A.propertyOf=w2,A.pull=em,A.pullAll=Jd,A.pullAllBy=tm,A.pullAllWith=rm,A.pullAt=im,A.range=_2,A.rangeRight=E2,A.rearg=vy,A.reject=ny,A.remove=nm,A.rest=my,A.reverse=Gf,A.sampleSize=ay,A.set=S3,A.setWith=x3,A.shuffle=oy,A.slice=sm,A.sortBy=hy,A.sortedUniq=dm,A.sortedUniqBy=lm,A.split=V3,A.spread=yy,A.tail=pm,A.take=gm,A.takeRight=bm,A.takeRightWhile=vm,A.takeWhile=mm,A.tap=Tm,A.throttle=wy,A.thru=Go,A.toArray=ul,A.toPairs=vl,A.toPairsIn=ml,A.toPath=A2,A.toPlainObject=ll,A.transform=I3,A.unary=_y,A.union=ym,A.unionBy=wm,A.unionWith=_m,A.uniq=Em,A.uniqBy=Sm,A.uniqWith=xm,A.unset=D3,A.unzip=Jf,A.unzipWith=Yd,A.update=A3,A.updateWith=M3,A.values=Ns,A.valuesIn=P3,A.without=Im,A.words=_l,A.wrap=Ey,A.xor=Dm,A.xorBy=Am,A.xorWith=Mm,A.zip=Pm,A.zipObject=Om,A.zipObjectDeep=Cm,A.zipWith=Rm,A.entries=vl,A.entriesIn=ml,A.extend=pl,A.extendWith=tc,sh(A,A),A.add=P2,A.attempt=El,A.camelCase=T3,A.capitalize=yl,A.ceil=O2,A.clamp=O3,A.clone=xy,A.cloneDeep=Dy,A.cloneDeepWith=Ay,A.cloneWith=Iy,A.conformsTo=My,A.deburr=wl,A.defaultTo=c2,A.divide=C2,A.endsWith=N3,A.eq=vi,A.escape=$3,A.escapeRegExp=L3,A.every=Km,A.find=km,A.findIndex=kd,A.findKey=n3,A.findLast=Wm,A.findLastIndex=Wd,A.findLastKey=s3,A.floor=R2,A.forEach=Zd,A.forEachRight=Qd,A.forIn=a3,A.forInRight=o3,A.forOwn=c3,A.forOwnRight=f3,A.get=eh,A.gt=Py,A.gte=Oy,A.has=d3,A.hasIn=th,A.head=Gd,A.identity=$r,A.includes=Xm,A.indexOf=Wv,A.inRange=C3,A.invoke=g3,A.isArguments=Xn,A.isArray=Xe,A.isArrayBuffer=Cy,A.isArrayLike=Tr,A.isArrayLikeObject=Jt,A.isBoolean=Ry,A.isBuffer=wn,A.isDate=Ty,A.isElement=Ny,A.isEmpty=$y,A.isEqual=Ly,A.isEqualWith=Fy,A.isError=Zf,A.isFinite=qy,A.isFunction=Xi,A.isInteger=ol,A.isLength=Qo,A.isMap=cl,A.isMatch=Uy,A.isMatchWith=By,A.isNaN=zy,A.isNative=Hy,A.isNil=jy,A.isNull=Ky,A.isNumber=fl,A.isObject=jt,A.isObjectLike=kt,A.isPlainObject=va,A.isRegExp=Qf,A.isSafeInteger=ky,A.isSet=hl,A.isString=ec,A.isSymbol=kr,A.isTypedArray=Ts,A.isUndefined=Wy,A.isWeakMap=Vy,A.isWeakSet=Gy,A.join=Xv,A.kebabCase=F3,A.last=ii,A.lastIndexOf=Zv,A.lowerCase=q3,A.lowerFirst=U3,A.lt=Jy,A.lte=Yy,A.max=T2,A.maxBy=N2,A.mean=$2,A.meanBy=L2,A.min=F2,A.minBy=q2,A.stubArray=oh,A.stubFalse=ch,A.stubObject=S2,A.stubString=x2,A.stubTrue=I2,A.multiply=U2,A.nth=Qv,A.noConflict=g2,A.noop=ah,A.now=Yo,A.pad=B3,A.padEnd=z3,A.padStart=H3,A.parseInt=K3,A.random=R3,A.reduce=ry,A.reduceRight=iy,A.repeat=j3,A.replace=k3,A.result=E3,A.round=B2,A.runInContext=Y,A.sample=sy,A.size=cy,A.snakeCase=W3,A.some=fy,A.sortedIndex=am,A.sortedIndexBy=om,A.sortedIndexOf=cm,A.sortedLastIndex=fm,A.sortedLastIndexBy=hm,A.sortedLastIndexOf=um,A.startCase=G3,A.startsWith=J3,A.subtract=z2,A.sum=H2,A.sumBy=K2,A.template=Y3,A.times=D2,A.toFinite=Zi,A.toInteger=st,A.toLength=dl,A.toLower=X3,A.toNumber=ni,A.toSafeInteger=Xy,A.toString=_t,A.toUpper=Z3,A.trim=Q3,A.trimEnd=e2,A.trimStart=t2,A.truncate=r2,A.unescape=i2,A.uniqueId=M2,A.upperCase=n2,A.upperFirst=rh,A.each=Zd,A.eachRight=Qd,A.first=Gd,sh(A,function(){var i={};return Ci(A,function(s,c){xt.call(A.prototype,c)||(i[c]=s)}),i}(),{chain:!1}),A.VERSION=n,Zr(["bind","bindKey","curry","curryRight","partial","partialRight"],function(i){A[i].placeholder=A}),Zr(["drop","take"],function(i,s){gt.prototype[i]=function(c){c=c===t?1:tr(st(c),0);var g=this.__filtered__&&!s?new gt(this):this.clone();return g.__filtered__?g.__takeCount__=vr(c,g.__takeCount__):g.__views__.push({size:vr(c,D),type:i+(g.__dir__<0?"Right":"")}),g},gt.prototype[i+"Right"]=function(c){return this.reverse()[i](c).reverse()}}),Zr(["filter","map","takeWhile"],function(i,s){var c=s+1,g=c==w||c==O;gt.prototype[i]=function(S){var C=this.clone();return C.__iteratees__.push({iteratee:Ne(S,3),type:c}),C.__filtered__=C.__filtered__||g,C}}),Zr(["head","last"],function(i,s){var c="take"+(s?"Right":"");gt.prototype[i]=function(){return this[c](1).value()[0]}}),Zr(["initial","tail"],function(i,s){var c="drop"+(s?"":"Right");gt.prototype[i]=function(){return this.__filtered__?new gt(this):this[c](1)}}),gt.prototype.compact=function(){return this.filter($r)},gt.prototype.find=function(i){return this.filter(i).head()},gt.prototype.findLast=function(i){return this.reverse().find(i)},gt.prototype.invokeMap=ct(function(i,s){return typeof i=="function"?new gt(this):this.map(function(c){return ua(c,i,s)})}),gt.prototype.reject=function(i){return this.filter(Zo(Ne(i)))},gt.prototype.slice=function(i,s){i=st(i);var c=this;return c.__filtered__&&(i>0||s<0)?new gt(c):(i<0?c=c.takeRight(-i):i&&(c=c.drop(i)),s!==t&&(s=st(s),c=s<0?c.dropRight(-s):c.take(s-i)),c)},gt.prototype.takeRightWhile=function(i){return this.reverse().takeWhile(i).reverse()},gt.prototype.toArray=function(){return this.take(D)},Ci(gt.prototype,function(i,s){var c=/^(?:filter|find|map|reject)|While$/.test(s),g=/^(?:head|last)$/.test(s),S=A[g?"take"+(s=="last"?"Right":""):s],C=g||/^find/.test(s);S&&(A.prototype[s]=function(){var B=this.__wrapped__,k=g?[1]:arguments,Q=B instanceof gt,se=k[0],ae=Q||Xe(B),ue=function(ut){var mt=S.apply(A,ln([ut],k));return g&&ve?mt[0]:mt};ae&&c&&typeof se=="function"&&se.length!=1&&(Q=ae=!1);var ve=this.__chain__,Me=!!this.__actions__.length,$e=C&&!ve,at=Q&&!Me;if(!C&&ae){B=at?B:new gt(this);var Le=i.apply(B,k);return Le.__actions__.push({func:Go,args:[ue],thisArg:t}),new ei(Le,ve)}return $e&&at?i.apply(this,k):(Le=this.thru(ue),$e?g?Le.value()[0]:Le.value():Le)})}),Zr(["pop","push","shift","sort","splice","unshift"],function(i){var s=wo[i],c=/^(?:push|sort|unshift)$/.test(i)?"tap":"thru",g=/^(?:pop|shift)$/.test(i);A.prototype[i]=function(){var S=arguments;if(g&&!this.__chain__){var C=this.value();return s.apply(Xe(C)?C:[],S)}return this[c](function(B){return s.apply(Xe(B)?B:[],S)})}}),Ci(gt.prototype,function(i,s){var c=A[s];if(c){var g=c.name+"";xt.call(Ms,g)||(Ms[g]=[]),Ms[g].push({name:s,func:c})}}),Ms[zo(t,J).name]=[{name:"wrapper",func:t}],gt.prototype.clone=ib,gt.prototype.reverse=nb,gt.prototype.value=sb,A.prototype.at=Nm,A.prototype.chain=$m,A.prototype.commit=Lm,A.prototype.next=Fm,A.prototype.plant=Um,A.prototype.reverse=Bm,A.prototype.toJSON=A.prototype.valueOf=A.prototype.value=zm,A.prototype.first=A.prototype.head,na&&(A.prototype[na]=qm),A},Is=Lg();Gt?((Gt.exports=Is)._=Is,Ct._=Is):vt._=Is}).call(wr)})(Pc,Pc.exports);var Px=Pc.exports,Ox=Object.defineProperty,Cx=Object.defineProperties,Rx=Object.getOwnPropertyDescriptors,dp=Object.getOwnPropertySymbols,Tx=Object.prototype.hasOwnProperty,Nx=Object.prototype.propertyIsEnumerable,lp=(r,e,t)=>e in r?Ox(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,pp=(r,e)=>{for(var t in e||(e={}))Tx.call(e,t)&&lp(r,t,e[t]);if(dp)for(var t of dp(e))Nx.call(e,t)&&lp(r,t,e[t]);return r},gp=(r,e)=>Cx(r,Rx(e));const $x={Accept:"application/json","Content-Type":"application/json"},Lx="POST",bp={headers:$x,method:Lx},vp=10;let Ki=class{constructor(e,t=!1){if(this.url=e,this.disableProviderPing=t,this.events=new hi.EventEmitter,this.isAvailable=!1,this.registering=!1,!q0(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=t}get connected(){return this.isAvailable}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(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const t=on(e),n=await(await Il(this.url,gp(pp({},bp),{body:t}))).json();this.onPayload({data:n})}catch(t){this.onError(e.id,t)}}async register(e=this.url){if(!q0(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((n,a)=>{this.events.once("register_error",o=>{this.resetMaxListeners(),a(o)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return a(new Error("HTTP connection is missing or invalid"));n()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const t=on({id:1,jsonrpc:"2.0",method:"test",params:[]});await Il(e,gp(pp({},bp),{body:t}))}this.onOpen()}catch(t){const n=this.parseError(t);throw this.events.emit("register_error",n),this.onClose(),n}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const t=typeof e.data=="string"?cs(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const n=this.parseError(t),a=n.message||n.toString(),o=Gc(e,a);this.events.emit("payload",o)}parseError(e,t=this.url){return B1(e,t,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>vp&&this.events.setMaxListeners(vp)}};const mp="error",Fx="wss://relay.walletconnect.org",qx="wc",Ux="universal_provider",yp=`${qx}@2:${Ux}:`,fg="https://rpc.walletconnect.org/v1/",Bs="generic",Bx=`${fg}bundler`,Ii={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var zx=Object.defineProperty,Hx=Object.defineProperties,Kx=Object.getOwnPropertyDescriptors,wp=Object.getOwnPropertySymbols,jx=Object.prototype.hasOwnProperty,kx=Object.prototype.propertyIsEnumerable,_p=(r,e,t)=>e in r?zx(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ac=(r,e)=>{for(var t in e||(e={}))jx.call(e,t)&&_p(r,t,e[t]);if(wp)for(var t of wp(e))kx.call(e,t)&&_p(r,t,e[t]);return r},Wx=(r,e)=>Hx(r,Kx(e));function Si(r,e,t){var n;const a=Ks(r);return((n=e.rpcMap)==null?void 0:n[a.reference])||`${fg}?chainId=${a.namespace}:${a.reference}&projectId=${t}`}function bs(r){return r.includes(":")?r.split(":")[1]:r}function hg(r){return r.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function Vx(r,e){const t=Object.keys(e.namespaces).filter(a=>a.includes(r));if(!t.length)return[];const n=[];return t.forEach(a=>{const o=e.namespaces[a].accounts;n.push(...o)}),n}function Mh(r={},e={}){const t=Ep(r),n=Ep(e);return Px.merge(t,n)}function Ep(r){var e,t,n,a;const o={};if(!$a(r))return o;for(const[f,h]of Object.entries(r)){const p=bu(f)?[f]:h.chains,l=h.methods||[],m=h.events||[],_=h.rpcMap||{},M=Aa(f);o[M]=Wx(ac(ac({},o[M]),h),{chains:hc(p,(e=o[M])==null?void 0:e.chains),methods:hc(l,(t=o[M])==null?void 0:t.methods),events:hc(m,(n=o[M])==null?void 0:n.events),rpcMap:ac(ac({},_),(a=o[M])==null?void 0:a.rpcMap)})}return o}function Gx(r){return r.includes(":")?r.split(":")[2]:r}function Sp(r){const e={};for(const[t,n]of Object.entries(r)){const a=n.methods||[],o=n.events||[],f=n.accounts||[],h=bu(t)?[t]:n.chains?n.chains:hg(n.accounts);e[t]={chains:h,methods:a,events:o,accounts:f}}return e}function Ph(r){return typeof r=="number"?r:r.includes("0x")?parseInt(r,16):(r=r.includes(":")?r.split(":")[1]:r,isNaN(Number(r))?r:Number(r))}const ug={},Et=r=>ug[r],Oh=(r,e)=>{ug[r]=e};class Jx{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var n;const a=bs(t);e[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||Si(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new xi(new Ki(n,Et("disableProviderPing")))}}var Yx=Object.defineProperty,Xx=Object.defineProperties,Zx=Object.getOwnPropertyDescriptors,xp=Object.getOwnPropertySymbols,Qx=Object.prototype.hasOwnProperty,eI=Object.prototype.propertyIsEnumerable,Ip=(r,e,t)=>e in r?Yx(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Dp=(r,e)=>{for(var t in e||(e={}))Qx.call(e,t)&&Ip(r,t,e[t]);if(xp)for(var t of xp(e))eI.call(e,t)&&Ip(r,t,e[t]);return r},Ap=(r,e)=>Xx(r,Zx(e));class tI{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const n=t||Si(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new xi(new Ki(n,Et("disableProviderPing")))}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var n;const a=parseInt(bs(t));e[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,n;let a=e.request.params?(t=e.request.params[0])==null?void 0:t.chainId:"0x0";a=a.startsWith("0x")?a:`0x${a}`;const o=parseInt(a,16);if(this.isChainApproved(o))this.setDefaultChain(`${o}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:a}]},chainId:(n=this.namespace.chains)==null?void 0:n[0]}),this.setDefaultChain(`${o}`);else throw new Error(`Failed to switch to chain 'eip155:${o}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,n,a;const o=(n=(t=e.request)==null?void 0:t.params)==null?void 0:n[0];if(!o)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const f=this.client.session.get(e.topic),h=((a=f==null?void 0:f.sessionProperties)==null?void 0:a.capabilities)||{};if(h!=null&&h[o])return h==null?void 0:h[o];const p=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Ap(Dp({},f.sessionProperties||{}),{capabilities:Ap(Dp({},h||{}),{[o]:p})})})}catch(l){console.warn("Failed to update session with capabilities",l)}return p}async getCallStatus(e){var t,n;const a=this.client.session.get(e.topic),o=(t=a.sessionProperties)==null?void 0:t.bundler_name;if(o){const h=this.getBundlerUrl(e.chainId,o);try{return await this.getUserOperationReceipt(h,e)}catch(p){console.warn("Failed to fetch call status from bundler",p,h)}}const f=(n=a.sessionProperties)==null?void 0:n.bundler_url;if(f)try{return await this.getUserOperationReceipt(f,e)}catch(h){console.warn("Failed to fetch call status from custom bundler",h,f)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var n;const a=new URL(e),o=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(xn("eth_getUserOperationReceipt",[(n=t.request.params)==null?void 0:n[0]]))});if(!o.ok)throw new Error(`Failed to fetch user operation receipt - ${o.status}`);return await o.json()}getBundlerUrl(e,t){return`${Bx}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}class rI{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var n;const a=bs(t);e[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||Si(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new xi(new Ki(n,Et("disableProviderPing")))}}class iI{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var n;const a=bs(t);e[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||Si(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new xi(new Ki(n,Et("disableProviderPing")))}}class nI{constructor(e){this.name="algorand",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const n=t||Si(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.chainId=e,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var n;e[t]=this.createHttpProvider(t,(n=this.namespace.rpcMap)==null?void 0:n[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||Si(e,this.namespace,this.client.core.projectId);return typeof n>"u"?void 0:new xi(new Ki(n,Et("disableProviderPing")))}}class sI{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const n=this.getCardanoRPCUrl(t),a=bs(t);e[a]=this.createHttpProvider(a,n)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||this.getCardanoRPCUrl(e);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new xi(new Ki(n,Et("disableProviderPing")))}}class aI{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var n;const a=bs(t);e[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||Si(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new xi(new Ki(n,Et("disableProviderPing")))}}class oI{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var n;const a=bs(t);e[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||Si(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new xi(new Ki(n,Et("disableProviderPing")))}}class cI{constructor(e){this.name="near",this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const n=t||Si(`${this.name}:${e}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,n)}this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var n;e[t]=this.createHttpProvider(t,(n=this.namespace.rpcMap)==null?void 0:n[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||Si(e,this.namespace);return typeof n>"u"?void 0:new xi(new Ki(n,Et("disableProviderPing")))}}class fI{constructor(e){this.name=Bs,this.namespace=e.namespace,this.events=Et("events"),this.client=Et("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Ii.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){var e,t;const n={};return(t=(e=this.namespace)==null?void 0:e.accounts)==null||t.forEach(a=>{const o=Ks(a);n[`${o.namespace}:${o.reference}`]=this.createHttpProvider(a)}),n}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||Si(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new xi(new Ki(n,Et("disableProviderPing")))}}var hI=Object.defineProperty,uI=Object.defineProperties,dI=Object.getOwnPropertyDescriptors,Mp=Object.getOwnPropertySymbols,lI=Object.prototype.hasOwnProperty,pI=Object.prototype.propertyIsEnumerable,Pp=(r,e,t)=>e in r?hI(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,oc=(r,e)=>{for(var t in e||(e={}))lI.call(e,t)&&Pp(r,t,e[t]);if(Mp)for(var t of Mp(e))pI.call(e,t)&&Pp(r,t,e[t]);return r},Ch=(r,e)=>uI(r,dI(e));let gI=class dg{constructor(e){this.events=new tu,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:Ya(Wc({level:(e==null?void 0:e.logger)||mp})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const t=new dg(e);return await t.initialize(),t}async request(e,t,n){const[a,o]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(a).request({request:oc({},e),chainId:`${a}:${o}`,topic:this.session.topic,expiry:n})}sendAsync(e,t,n,a){const o=new Date().getTime();this.request(e,n,a).then(f=>t(null,Vc(o,f))).catch(f=>t(f,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:It("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:n,response:a}=await this.client.authenticate(e,t);n&&(this.uri=n,this.events.emit("display_uri",n));const o=await a();if(this.session=o.session,this.session){const f=Sp(this.session.namespaces);this.namespaces=Mh(this.namespaces,f),this.persist("namespaces",this.namespaces),this.onConnect()}return o}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let t=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(t>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:n,approval:a}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});n&&(this.uri=n,this.events.emit("display_uri",n)),await a().then(o=>{this.session=o;const f=Sp(o.namespaces);this.namespaces=Mh(this.namespaces,f),this.persist("namespaces",this.namespaces)}).catch(o=>{if(o.message!==cg)throw o;t++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[n,a]=this.validateChain(e),o=this.getProvider(n);o.name===Bs?o.setDefaultChain(`${n}:${a}`,t):o.setDefaultChain(a,t)}catch(n){if(!/Please call connect/.test(n.message))throw n}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if(Bi(t)){for(const n of t)e.deletePairings?this.client.core.expirer.set(n.topic,0):await this.client.core.relayer.subscriber.unsubscribe(n.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await xu.init({core:this.providerOpts.core,logger:this.providerOpts.logger||mp,relayUrl:this.providerOpts.relayUrl||Fx,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(t=>Aa(t)))];Oh("client",this.client),Oh("events",this.events),Oh("disableProviderPing",this.disableProviderPing),e.forEach(t=>{if(!this.session)return;const n=Vx(t,this.session),a=hg(n),o=Mh(this.namespaces,this.optionalNamespaces),f=Ch(oc({},o[t]),{accounts:n,chains:a});switch(t){case"eip155":this.rpcProviders[t]=new tI({namespace:f});break;case"algorand":this.rpcProviders[t]=new nI({namespace:f});break;case"solana":this.rpcProviders[t]=new rI({namespace:f});break;case"cosmos":this.rpcProviders[t]=new iI({namespace:f});break;case"polkadot":this.rpcProviders[t]=new Jx({namespace:f});break;case"cip34":this.rpcProviders[t]=new sI({namespace:f});break;case"elrond":this.rpcProviders[t]=new aI({namespace:f});break;case"multiversx":this.rpcProviders[t]=new oI({namespace:f});break;case"near":this.rpcProviders[t]=new cI({namespace:f});break;default:this.rpcProviders[Bs]?this.rpcProviders[Bs].updateNamespace(f):this.rpcProviders[Bs]=new fI({namespace:f})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:t}=e,{event:n}=t;if(n.name==="accountsChanged"){const a=n.data;a&&Bi(a)&&this.events.emit("accountsChanged",a.map(Gx))}else if(n.name==="chainChanged"){const a=t.chainId,o=t.event.data,f=Aa(a),h=Ph(a)!==Ph(o)?`${f}:${Ph(o)}`:a;this.onChainChanged(h)}else this.events.emit(n.name,n.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var n;const{namespaces:a}=t,o=(n=this.client)==null?void 0:n.session.get(e);this.session=Ch(oc({},o),{namespaces:a}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Ch(oc({},It("USER_DISCONNECTED")),{data:e.topic}))}),this.on(Ii.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Bs]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace((t=this.session)==null?void 0:t.namespaces[e])})}setNamespaces(e){const{namespaces:t,optionalNamespaces:n,sessionProperties:a}=e;t&&Object.keys(t).length&&(this.namespaces=t),n&&Object.keys(n).length&&(this.optionalNamespaces=n),this.sessionProperties=a,this.persist("namespaces",t),this.persist("optionalNamespaces",n)}validateChain(e){const[t,n]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,n];if(t&&!Object.keys(this.namespaces||{}).map(f=>Aa(f)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&n)return[t,n];const a=Aa(Object.keys(this.namespaces)[0]),o=this.rpcProviders[a].getDefaultChain();return[a,o]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){if(!this.namespaces)return;const[n,a]=this.validateChain(e);a&&(t||this.getProvider(n).setDefaultChain(a),this.namespaces[n]?this.namespaces[n].defaultChain=a:this.namespaces[`${n}:${a}`]?this.namespaces[`${n}:${a}`].defaultChain=a:this.namespaces[`${n}:${a}`]={defaultChain:a},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",a))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,t){this.client.core.storage.setItem(`${yp}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${yp}/${e}`)}};const bI=gI,vI="wc",mI="ethereum_provider",yI=`${vI}@2:${mI}:`,wI="https://rpc.walletconnect.org/v1/",Zh=["eth_sendTransaction","personal_sign"],_I=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],Qh=["chainChanged","accountsChanged"],EI=["chainChanged","accountsChanged","message","disconnect","connect"];var SI=Object.defineProperty,xI=Object.defineProperties,II=Object.getOwnPropertyDescriptors,Op=Object.getOwnPropertySymbols,DI=Object.prototype.hasOwnProperty,AI=Object.prototype.propertyIsEnumerable,Cp=(r,e,t)=>e in r?SI(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,zs=(r,e)=>{for(var t in e||(e={}))DI.call(e,t)&&Cp(r,t,e[t]);if(Op)for(var t of Op(e))AI.call(e,t)&&Cp(r,t,e[t]);return r},Rh=(r,e)=>xI(r,II(e));function Oc(r){return Number(r[0].split(":")[1])}function cc(r){return`0x${r.toString(16)}`}function MI(r){const{chains:e,optionalChains:t,methods:n,optionalMethods:a,events:o,optionalEvents:f,rpcMap:h}=r;if(!Bi(e))throw new Error("Invalid chains");const p={chains:e,methods:n||Zh,events:o||Qh,rpcMap:zs({},e.length?{[Oc(e)]:h[Oc(e)]}:{})},l=o==null?void 0:o.filter(I=>!Qh.includes(I)),m=n==null?void 0:n.filter(I=>!Zh.includes(I));if(!t&&!f&&!a&&!(l!=null&&l.length)&&!(m!=null&&m.length))return{required:e.length?p:void 0};const _=(l==null?void 0:l.length)&&(m==null?void 0:m.length)||!t,M={chains:[...new Set(_?p.chains.concat(t||[]):t)],methods:[...new Set(p.methods.concat(a!=null&&a.length?a:_I))],events:[...new Set(p.events.concat(f!=null&&f.length?f:EI))],rpcMap:h};return{required:e.length?p:void 0,optional:t.length?M:void 0}}class Iu{constructor(){this.events=new hi.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=yI,this.on=(e,t)=>(this.events.on(e,t),this),this.once=(e,t)=>(this.events.once(e,t),this),this.removeListener=(e,t)=>(this.events.removeListener(e,t),this),this.off=(e,t)=>(this.events.off(e,t),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const t=new Iu;return await t.initialize(e),t}async request(e,t){return await this.signer.request(e,this.formatChainId(this.chainId),t)}sendAsync(e,t,n){this.signer.sendAsync(e,t,this.formatChainId(this.chainId),n)}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:t,optional:n}=MI(this.rpc);try{const a=await new Promise(async(f,h)=>{var p;this.rpc.showQrModal&&((p=this.modal)==null||p.subscribeModal(l=>{!l.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),h(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(Rh(zs({namespaces:zs({},t&&{[this.namespace]:t})},n&&{optionalNamespaces:{[this.namespace]:n}}),{pairingTopic:e==null?void 0:e.pairingTopic})).then(l=>{f(l)}).catch(l=>{h(new Error(l.message))})});if(!a)return;const o=t0(a.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:cc(this.chainId)})}catch(a){throw this.signer.logger.error(a),a}finally{this.modal&&this.modal.closeModal()}}async authenticate(e,t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e==null?void 0:e.chains});try{const n=await new Promise(async(o,f)=>{var h;this.rpc.showQrModal&&((h=this.modal)==null||h.subscribeModal(p=>{!p.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),f(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(Rh(zs({},e),{chains:this.rpc.chains}),t).then(p=>{o(p)}).catch(p=>{f(new Error(p.message))})}),a=n.session;if(a){const o=t0(a.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:cc(this.chainId)})}return n}catch(n){throw this.signer.logger.error(n),n}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:t}=e,{event:n}=t;n.name==="accountsChanged"?(this.accounts=this.parseAccounts(n.data),this.events.emit("accountsChanged",this.accounts)):n.name==="chainChanged"?this.setChainId(this.formatChainId(n.data)):this.events.emit(n.name,n.data),this.events.emit("session_event",e)}),this.signer.on("chainChanged",e=>{const t=parseInt(e);this.chainId=t,this.events.emit("chainChanged",cc(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",Rh(zs({},It("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var t,n;this.rpc.showQrModal&&((t=this.modal)==null||t.closeModal(),(n=this.modal)==null||n.openModal({uri:e})),this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const t=e.filter(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n));t.length&&(this.chainId=t[0],this.events.emit("chainChanged",cc(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const t=this.parseChainId(e);this.chainId=t,this.switchEthereumChain(t)}}parseAccountId(e){const[t,n,a]=e.split(":");return{chainId:`${t}:${n}`,address:a}}setAccounts(e){this.accounts=e.filter(t=>this.parseChainId(this.parseAccountId(t).chainId)===this.chainId).map(t=>this.parseAccountId(t).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var t,n;const a=(t=e==null?void 0:e.chains)!=null?t:[],o=(n=e==null?void 0:e.optionalChains)!=null?n:[],f=a.concat(o);if(!f.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const h=a.length?(e==null?void 0:e.methods)||Zh:[],p=a.length?(e==null?void 0:e.events)||Qh:[],l=(e==null?void 0:e.optionalMethods)||[],m=(e==null?void 0:e.optionalEvents)||[],_=(e==null?void 0:e.rpcMap)||this.buildRpcMap(f,e.projectId),M=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:a==null?void 0:a.map(I=>this.formatChainId(I)),optionalChains:o.map(I=>this.formatChainId(I)),methods:h,events:p,optionalMethods:l,optionalEvents:m,rpcMap:_,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:M,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,t){const n={};return e.forEach(a=>{n[a]=this.getRpcUrl(a,t)}),n}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?Oc(this.rpc.chains):Oc(this.rpc.optionalChains),this.signer=await bI.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let t;try{const{WalletConnectModal:n}=await e6(()=>import("./index-8a03b7c6.js").then(a=>a.i),["assets/index-8a03b7c6.js","assets/index-e375682a.js","assets/index-ead02a18.css"]);t=n}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(t)try{this.modal=new t(zs({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(n){throw this.signer.logger.error(n),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:t,optionalChains:n,rpcMap:a}=e;t&&Bi(t)&&(this.rpc.chains=t.map(o=>this.formatChainId(o)),t.forEach(o=>{this.rpc.rpcMap[o]=(a==null?void 0:a[o])||this.getRpcUrl(o)})),n&&Bi(n)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=n==null?void 0:n.map(o=>this.formatChainId(o)),n.forEach(o=>{this.rpc.rpcMap[o]=(a==null?void 0:a[o])||this.getRpcUrl(o)}))}getRpcUrl(e,t){var n;return((n=this.rpc.rpcMap)==null?void 0:n[e])||`${wI}?chainId=eip155:${e}&projectId=${t||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),t=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:t==null?void 0:t.accounts),this.setAccounts(t==null?void 0:t.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(t=>this.signer.logger.warn(t))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(t=>this.parseAccount(t))}}const iD=Iu;export{iD as EthereumProvider,EI as OPTIONAL_EVENTS,_I as OPTIONAL_METHODS,Qh as REQUIRED_EVENTS,Zh as REQUIRED_METHODS,Iu as default};
package/index.html CHANGED
@@ -6,11 +6,11 @@
6
6
  <meta name="theme-color" content="#000000" />
7
7
  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400" rel="stylesheet" />
8
8
  <script defer src="https://use.fontawesome.com/releases/v5.0.1/js/all.js"></script>
9
- <link rel="manifest" href="https://cdn.decentraland.org/@dcl/vesting-dashboard/3.4.0/manifest.json" />
10
- <link rel="shortcut icon" href="https://cdn.decentraland.org/@dcl/vesting-dashboard/3.4.0/favicon.ico" />
9
+ <link rel="manifest" href="https://cdn.decentraland.org/@dcl/vesting-dashboard/3.4.1/manifest.json" />
10
+ <link rel="shortcut icon" href="https://cdn.decentraland.org/@dcl/vesting-dashboard/3.4.1/favicon.ico" />
11
11
  <title>Decentraland's Vesting Dashboard</title>
12
- <script type="module" crossorigin src="https://cdn.decentraland.org/@dcl/vesting-dashboard/3.4.0/assets/index-9ab4b2f8.js"></script>
13
- <link rel="stylesheet" href="https://cdn.decentraland.org/@dcl/vesting-dashboard/3.4.0/assets/index-d326c9c7.css">
12
+ <script type="module" crossorigin src="https://cdn.decentraland.org/@dcl/vesting-dashboard/3.4.1/assets/index-e375682a.js"></script>
13
+ <link rel="stylesheet" href="https://cdn.decentraland.org/@dcl/vesting-dashboard/3.4.1/assets/index-ead02a18.css">
14
14
  </head>
15
15
 
16
16
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcl/vesting-dashboard",
3
- "version": "3.4.0",
3
+ "version": "3.4.1",
4
4
  "description": "Static website for the vesting dashboard",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,6 +17,6 @@
17
17
  "type": "git",
18
18
  "url": "https://github.com/decentraland/vesting-dashboard.git"
19
19
  },
20
- "homepage": "https://cdn.decentraland.org/@dcl/vesting-dashboard/3.4.0",
21
- "commit": "3b0c1c17246bea385c50df229b44eabd6037bfab"
20
+ "homepage": "https://cdn.decentraland.org/@dcl/vesting-dashboard/3.4.1",
21
+ "commit": "f9cd1588209f922f2c195e82237efb943817a736"
22
22
  }